@xoxno/sdk-js 1.0.217 → 1.0.219
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/cjs/sdk/stellar/__tests__/auth-policy.test.d.ts +1 -0
- package/dist/cjs/sdk/stellar/__tests__/math/account.test.d.ts +10 -0
- package/dist/cjs/sdk/stellar/__tests__/math/parity.test.d.ts +14 -0
- package/dist/cjs/sdk/stellar/__tests__/math/scaled-rates.test.d.ts +6 -0
- package/dist/cjs/sdk/stellar/__tests__/route-verify.test.d.ts +1 -0
- package/dist/cjs/sdk/stellar/auth-policy.d.ts +106 -0
- package/dist/cjs/sdk/stellar/contracts.d.ts +6 -0
- package/dist/cjs/sdk/stellar/index.d.ts +3 -0
- package/dist/cjs/sdk/stellar/math/account.d.ts +183 -0
- package/dist/cjs/sdk/stellar/math/index.d.ts +12 -0
- package/dist/cjs/sdk/stellar/math/limits.d.ts +80 -0
- package/dist/cjs/sdk/stellar/math/projection.d.ts +53 -0
- package/dist/cjs/sdk/stellar/math/rates.d.ts +34 -0
- package/dist/cjs/sdk/stellar/math/scaled.d.ts +99 -0
- package/dist/cjs/sdk/stellar/route-verify.d.ts +100 -0
- package/dist/cjs/sdk/stellar/scval-encode.d.ts +10 -0
- package/dist/cjs/sdk/stellar/swap.d.ts +26 -6
- package/dist/index.cjs +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/sdk/stellar/__tests__/auth-policy.test.d.ts +1 -0
- package/dist/sdk/stellar/__tests__/math/account.test.d.ts +10 -0
- package/dist/sdk/stellar/__tests__/math/parity.test.d.ts +14 -0
- package/dist/sdk/stellar/__tests__/math/scaled-rates.test.d.ts +6 -0
- package/dist/sdk/stellar/__tests__/route-verify.test.d.ts +1 -0
- package/dist/sdk/stellar/auth-policy.d.ts +106 -0
- package/dist/sdk/stellar/contracts.d.ts +6 -0
- package/dist/sdk/stellar/index.cjs +1 -1
- package/dist/sdk/stellar/index.d.ts +3 -0
- package/dist/sdk/stellar/index.esm.js +1 -1
- package/dist/sdk/stellar/math/account.d.ts +183 -0
- package/dist/sdk/stellar/math/index.d.ts +12 -0
- package/dist/sdk/stellar/math/limits.d.ts +80 -0
- package/dist/sdk/stellar/math/projection.d.ts +53 -0
- package/dist/sdk/stellar/math/rates.d.ts +34 -0
- package/dist/sdk/stellar/math/scaled.d.ts +99 -0
- package/dist/sdk/stellar/route-verify.d.ts +100 -0
- package/dist/sdk/stellar/scval-encode.d.ts +10 -0
- package/dist/sdk/stellar/swap.d.ts +26 -6
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! For license information please see index.cjs.LICENSE.txt */
|
|
2
|
-
"undefined"!=typeof globalThis&&void 0===globalThis.self&&(globalThis.self=globalThis),(()=>{var e={526(e,t){"use strict";t.byteLength=function(e){var t=a(e),r=t[0],o=t[1];return 3*(r+o)/4-o},t.toByteArray=function(e){var t,r,i=a(e),u=i[0],s=i[1],l=new n(function(e,t,r){return 3*(t+r)/4-r}(0,u,s)),p=0,d=s>0?u-4:u;for(r=0;r<d;r+=4)t=o[e.charCodeAt(r)]<<18|o[e.charCodeAt(r+1)]<<12|o[e.charCodeAt(r+2)]<<6|o[e.charCodeAt(r+3)],l[p++]=t>>16&255,l[p++]=t>>8&255,l[p++]=255&t;return 2===s&&(t=o[e.charCodeAt(r)]<<2|o[e.charCodeAt(r+1)]>>4,l[p++]=255&t),1===s&&(t=o[e.charCodeAt(r)]<<10|o[e.charCodeAt(r+1)]<<4|o[e.charCodeAt(r+2)]>>2,l[p++]=t>>8&255,l[p++]=255&t),l},t.fromByteArray=function(e){for(var t,o=e.length,n=o%3,i=[],u=16383,a=0,l=o-n;a<l;a+=u)i.push(s(e,a,a+u>l?l:a+u));return 1===n?(t=e[o-1],i.push(r[t>>2]+r[t<<4&63]+"==")):2===n&&(t=(e[o-2]<<8)+e[o-1],i.push(r[t>>10]+r[t>>4&63]+r[t<<2&63]+"=")),i.join("")};for(var r=[],o=[],n="undefined"!=typeof Uint8Array?Uint8Array:Array,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",u=0;u<64;++u)r[u]=i[u],o[i.charCodeAt(u)]=u;function a(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function s(e,t,o){for(var n,i,u=[],a=t;a<o;a+=3)n=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),u.push(r[(i=n)>>18&63]+r[i>>12&63]+r[i>>6&63]+r[63&i]);return u.join("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63},287(e,t,r){"use strict";const o=r(526),n=r(251),i="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;t.hp=s,t.IS=50;const u=2147483647;function a(e){if(e>u)throw new RangeError('The value "'+e+'" is invalid for option "size"');const t=new Uint8Array(e);return Object.setPrototypeOf(t,s.prototype),t}function s(e,t,r){if("number"==typeof e){if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return d(e)}return l(e,t,r)}function l(e,t,r){if("string"==typeof e)return function(e,t){if("string"==typeof t&&""!==t||(t="utf8"),!s.isEncoding(t))throw new TypeError("Unknown encoding: "+t);const r=0|g(e,t);let o=a(r);const n=o.write(e,t);return n!==r&&(o=o.slice(0,n)),o}(e,t);if(ArrayBuffer.isView(e))return function(e){if(K(e,Uint8Array)){const t=new Uint8Array(e);return f(t.buffer,t.byteOffset,t.byteLength)}return c(e)}(e);if(null==e)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(K(e,ArrayBuffer)||e&&K(e.buffer,ArrayBuffer))return f(e,t,r);if("undefined"!=typeof SharedArrayBuffer&&(K(e,SharedArrayBuffer)||e&&K(e.buffer,SharedArrayBuffer)))return f(e,t,r);if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type number');const o=e.valueOf&&e.valueOf();if(null!=o&&o!==e)return s.from(o,t,r);const n=function(e){if(s.isBuffer(e)){const t=0|h(e.length),r=a(t);return 0===r.length||e.copy(r,0,0,t),r}return void 0!==e.length?"number"!=typeof e.length||Z(e.length)?a(0):c(e):"Buffer"===e.type&&Array.isArray(e.data)?c(e.data):void 0}(e);if(n)return n;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return s.from(e[Symbol.toPrimitive]("string"),t,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function p(e){if("number"!=typeof e)throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function d(e){return p(e),a(e<0?0:0|h(e))}function c(e){const t=e.length<0?0:0|h(e.length),r=a(t);for(let o=0;o<t;o+=1)r[o]=255&e[o];return r}function f(e,t,r){if(t<0||e.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(r||0))throw new RangeError('"length" is outside of buffer bounds');let o;return o=void 0===t&&void 0===r?new Uint8Array(e):void 0===r?new Uint8Array(e,t):new Uint8Array(e,t,r),Object.setPrototypeOf(o,s.prototype),o}function h(e){if(e>=u)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+u.toString(16)+" bytes");return 0|e}function g(e,t){if(s.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||K(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);const r=e.length,o=arguments.length>2&&!0===arguments[2];if(!o&&0===r)return 0;let n=!1;for(;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return V(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return j(e).length;default:if(n)return o?-1:V(e).length;t=(""+t).toLowerCase(),n=!0}}function y(e,t,r){let o=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return I(this,t,r);case"utf8":case"utf-8":return q(this,t,r);case"ascii":return E(this,t,r);case"latin1":case"binary":return _(this,t,r);case"base64":return P(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return R(this,t,r);default:if(o)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),o=!0}}function b(e,t,r){const o=e[t];e[t]=e[r],e[r]=o}function S(e,t,r,o,n){if(0===e.length)return-1;if("string"==typeof r?(o=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),Z(r=+r)&&(r=n?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(n)return-1;r=e.length-1}else if(r<0){if(!n)return-1;r=0}if("string"==typeof t&&(t=s.from(t,o)),s.isBuffer(t))return 0===t.length?-1:m(e,t,r,o,n);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?n?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):m(e,[t],r,o,n);throw new TypeError("val must be string, number or Buffer")}function m(e,t,r,o,n){let i,u=1,a=e.length,s=t.length;if(void 0!==o&&("ucs2"===(o=String(o).toLowerCase())||"ucs-2"===o||"utf16le"===o||"utf-16le"===o)){if(e.length<2||t.length<2)return-1;u=2,a/=2,s/=2,r/=2}function l(e,t){return 1===u?e[t]:e.readUInt16BE(t*u)}if(n){let o=-1;for(i=r;i<a;i++)if(l(e,i)===l(t,-1===o?0:i-o)){if(-1===o&&(o=i),i-o+1===s)return o*u}else-1!==o&&(i-=i-o),o=-1}else for(r+s>a&&(r=a-s),i=r;i>=0;i--){let r=!0;for(let o=0;o<s;o++)if(l(e,i+o)!==l(t,o)){r=!1;break}if(r)return i}return-1}function T(e,t,r,o){r=Number(r)||0;const n=e.length-r;o?(o=Number(o))>n&&(o=n):o=n;const i=t.length;let u;for(o>i/2&&(o=i/2),u=0;u<o;++u){const o=parseInt(t.substr(2*u,2),16);if(Z(o))return u;e[r+u]=o}return u}function w(e,t,r,o){return X(V(t,e.length-r),e,r,o)}function v(e,t,r,o){return X(function(e){const t=[];for(let r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}(t),e,r,o)}function x(e,t,r,o){return X(j(t),e,r,o)}function A(e,t,r,o){return X(function(e,t){let r,o,n;const i=[];for(let u=0;u<e.length&&!((t-=2)<0);++u)r=e.charCodeAt(u),o=r>>8,n=r%256,i.push(n),i.push(o);return i}(t,e.length-r),e,r,o)}function P(e,t,r){return 0===t&&r===e.length?o.fromByteArray(e):o.fromByteArray(e.slice(t,r))}function q(e,t,r){r=Math.min(e.length,r);const o=[];let n=t;for(;n<r;){const t=e[n];let i=null,u=t>239?4:t>223?3:t>191?2:1;if(n+u<=r){let r,o,a,s;switch(u){case 1:t<128&&(i=t);break;case 2:r=e[n+1],128==(192&r)&&(s=(31&t)<<6|63&r,s>127&&(i=s));break;case 3:r=e[n+1],o=e[n+2],128==(192&r)&&128==(192&o)&&(s=(15&t)<<12|(63&r)<<6|63&o,s>2047&&(s<55296||s>57343)&&(i=s));break;case 4:r=e[n+1],o=e[n+2],a=e[n+3],128==(192&r)&&128==(192&o)&&128==(192&a)&&(s=(15&t)<<18|(63&r)<<12|(63&o)<<6|63&a,s>65535&&s<1114112&&(i=s))}}null===i?(i=65533,u=1):i>65535&&(i-=65536,o.push(i>>>10&1023|55296),i=56320|1023&i),o.push(i),n+=u}return function(e){const t=e.length;if(t<=k)return String.fromCharCode.apply(String,e);let r="",o=0;for(;o<t;)r+=String.fromCharCode.apply(String,e.slice(o,o+=k));return r}(o)}s.TYPED_ARRAY_SUPPORT=function(){try{const e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),42===e.foo()}catch(e){return!1}}(),s.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(s.prototype,"parent",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.buffer}}),Object.defineProperty(s.prototype,"offset",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.byteOffset}}),s.poolSize=8192,s.from=function(e,t,r){return l(e,t,r)},Object.setPrototypeOf(s.prototype,Uint8Array.prototype),Object.setPrototypeOf(s,Uint8Array),s.alloc=function(e,t,r){return function(e,t,r){return p(e),e<=0?a(e):void 0!==t?"string"==typeof r?a(e).fill(t,r):a(e).fill(t):a(e)}(e,t,r)},s.allocUnsafe=function(e){return d(e)},s.allocUnsafeSlow=function(e){return d(e)},s.isBuffer=function(e){return null!=e&&!0===e._isBuffer&&e!==s.prototype},s.compare=function(e,t){if(K(e,Uint8Array)&&(e=s.from(e,e.offset,e.byteLength)),K(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(e)||!s.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;let r=e.length,o=t.length;for(let n=0,i=Math.min(r,o);n<i;++n)if(e[n]!==t[n]){r=e[n],o=t[n];break}return r<o?-1:o<r?1:0},s.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},s.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return s.alloc(0);let r;if(void 0===t)for(t=0,r=0;r<e.length;++r)t+=e[r].length;const o=s.allocUnsafe(t);let n=0;for(r=0;r<e.length;++r){let t=e[r];if(K(t,Uint8Array))n+t.length>o.length?(s.isBuffer(t)||(t=s.from(t)),t.copy(o,n)):Uint8Array.prototype.set.call(o,t,n);else{if(!s.isBuffer(t))throw new TypeError('"list" argument must be an Array of Buffers');t.copy(o,n)}n+=t.length}return o},s.byteLength=g,s.prototype._isBuffer=!0,s.prototype.swap16=function(){const e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let t=0;t<e;t+=2)b(this,t,t+1);return this},s.prototype.swap32=function(){const e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let t=0;t<e;t+=4)b(this,t,t+3),b(this,t+1,t+2);return this},s.prototype.swap64=function(){const e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let t=0;t<e;t+=8)b(this,t,t+7),b(this,t+1,t+6),b(this,t+2,t+5),b(this,t+3,t+4);return this},s.prototype.toString=function(){const e=this.length;return 0===e?"":0===arguments.length?q(this,0,e):y.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(e){if(!s.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===s.compare(this,e)},s.prototype.inspect=function(){let e="";const r=t.IS;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"},i&&(s.prototype[i]=s.prototype.inspect),s.prototype.compare=function(e,t,r,o,n){if(K(e,Uint8Array)&&(e=s.from(e,e.offset,e.byteLength)),!s.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===o&&(o=0),void 0===n&&(n=this.length),t<0||r>e.length||o<0||n>this.length)throw new RangeError("out of range index");if(o>=n&&t>=r)return 0;if(o>=n)return-1;if(t>=r)return 1;if(this===e)return 0;let i=(n>>>=0)-(o>>>=0),u=(r>>>=0)-(t>>>=0);const a=Math.min(i,u),l=this.slice(o,n),p=e.slice(t,r);for(let e=0;e<a;++e)if(l[e]!==p[e]){i=l[e],u=p[e];break}return i<u?-1:u<i?1:0},s.prototype.includes=function(e,t,r){return-1!==this.indexOf(e,t,r)},s.prototype.indexOf=function(e,t,r){return S(this,e,t,r,!0)},s.prototype.lastIndexOf=function(e,t,r){return S(this,e,t,r,!1)},s.prototype.write=function(e,t,r,o){if(void 0===t)o="utf8",r=this.length,t=0;else if(void 0===r&&"string"==typeof t)o=t,r=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t>>>=0,isFinite(r)?(r>>>=0,void 0===o&&(o="utf8")):(o=r,r=void 0)}const n=this.length-t;if((void 0===r||r>n)&&(r=n),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");o||(o="utf8");let i=!1;for(;;)switch(o){case"hex":return T(this,e,t,r);case"utf8":case"utf-8":return w(this,e,t,r);case"ascii":case"latin1":case"binary":return v(this,e,t,r);case"base64":return x(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,e,t,r);default:if(i)throw new TypeError("Unknown encoding: "+o);o=(""+o).toLowerCase(),i=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const k=4096;function E(e,t,r){let o="";r=Math.min(e.length,r);for(let n=t;n<r;++n)o+=String.fromCharCode(127&e[n]);return o}function _(e,t,r){let o="";r=Math.min(e.length,r);for(let n=t;n<r;++n)o+=String.fromCharCode(e[n]);return o}function I(e,t,r){const o=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>o)&&(r=o);let n="";for(let o=t;o<r;++o)n+=Q[e[o]];return n}function R(e,t,r){const o=e.slice(t,r);let n="";for(let e=0;e<o.length-1;e+=2)n+=String.fromCharCode(o[e]+256*o[e+1]);return n}function O(e,t,r){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}function B(e,t,r,o,n,i){if(!s.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>n||t<i)throw new RangeError('"value" argument is out of bounds');if(r+o>e.length)throw new RangeError("Index out of range")}function M(e,t,r,o,n){W(t,o,n,e,r,7);let i=Number(t&BigInt(4294967295));e[r++]=i,i>>=8,e[r++]=i,i>>=8,e[r++]=i,i>>=8,e[r++]=i;let u=Number(t>>BigInt(32)&BigInt(4294967295));return e[r++]=u,u>>=8,e[r++]=u,u>>=8,e[r++]=u,u>>=8,e[r++]=u,r}function U(e,t,r,o,n){W(t,o,n,e,r,7);let i=Number(t&BigInt(4294967295));e[r+7]=i,i>>=8,e[r+6]=i,i>>=8,e[r+5]=i,i>>=8,e[r+4]=i;let u=Number(t>>BigInt(32)&BigInt(4294967295));return e[r+3]=u,u>>=8,e[r+2]=u,u>>=8,e[r+1]=u,u>>=8,e[r]=u,r+8}function C(e,t,r,o,n,i){if(r+o>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function L(e,t,r,o,i){return t=+t,r>>>=0,i||C(e,0,r,4),n.write(e,t,r,o,23,4),r+4}function $(e,t,r,o,i){return t=+t,r>>>=0,i||C(e,0,r,8),n.write(e,t,r,o,52,8),r+8}s.prototype.slice=function(e,t){const r=this.length;(e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e);const o=this.subarray(e,t);return Object.setPrototypeOf(o,s.prototype),o},s.prototype.readUintLE=s.prototype.readUIntLE=function(e,t,r){e>>>=0,t>>>=0,r||O(e,t,this.length);let o=this[e],n=1,i=0;for(;++i<t&&(n*=256);)o+=this[e+i]*n;return o},s.prototype.readUintBE=s.prototype.readUIntBE=function(e,t,r){e>>>=0,t>>>=0,r||O(e,t,this.length);let o=this[e+--t],n=1;for(;t>0&&(n*=256);)o+=this[e+--t]*n;return o},s.prototype.readUint8=s.prototype.readUInt8=function(e,t){return e>>>=0,t||O(e,1,this.length),this[e]},s.prototype.readUint16LE=s.prototype.readUInt16LE=function(e,t){return e>>>=0,t||O(e,2,this.length),this[e]|this[e+1]<<8},s.prototype.readUint16BE=s.prototype.readUInt16BE=function(e,t){return e>>>=0,t||O(e,2,this.length),this[e]<<8|this[e+1]},s.prototype.readUint32LE=s.prototype.readUInt32LE=function(e,t){return e>>>=0,t||O(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},s.prototype.readUint32BE=s.prototype.readUInt32BE=function(e,t){return e>>>=0,t||O(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},s.prototype.readBigUInt64LE=Y((function(e){F(e>>>=0,"offset");const t=this[e],r=this[e+7];void 0!==t&&void 0!==r||H(e,this.length-8);const o=t+256*this[++e]+65536*this[++e]+this[++e]*2**24,n=this[++e]+256*this[++e]+65536*this[++e]+r*2**24;return BigInt(o)+(BigInt(n)<<BigInt(32))})),s.prototype.readBigUInt64BE=Y((function(e){F(e>>>=0,"offset");const t=this[e],r=this[e+7];void 0!==t&&void 0!==r||H(e,this.length-8);const o=t*2**24+65536*this[++e]+256*this[++e]+this[++e],n=this[++e]*2**24+65536*this[++e]+256*this[++e]+r;return(BigInt(o)<<BigInt(32))+BigInt(n)})),s.prototype.readIntLE=function(e,t,r){e>>>=0,t>>>=0,r||O(e,t,this.length);let o=this[e],n=1,i=0;for(;++i<t&&(n*=256);)o+=this[e+i]*n;return n*=128,o>=n&&(o-=Math.pow(2,8*t)),o},s.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||O(e,t,this.length);let o=t,n=1,i=this[e+--o];for(;o>0&&(n*=256);)i+=this[e+--o]*n;return n*=128,i>=n&&(i-=Math.pow(2,8*t)),i},s.prototype.readInt8=function(e,t){return e>>>=0,t||O(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},s.prototype.readInt16LE=function(e,t){e>>>=0,t||O(e,2,this.length);const r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt16BE=function(e,t){e>>>=0,t||O(e,2,this.length);const r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt32LE=function(e,t){return e>>>=0,t||O(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},s.prototype.readInt32BE=function(e,t){return e>>>=0,t||O(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},s.prototype.readBigInt64LE=Y((function(e){F(e>>>=0,"offset");const t=this[e],r=this[e+7];void 0!==t&&void 0!==r||H(e,this.length-8);const o=this[e+4]+256*this[e+5]+65536*this[e+6]+(r<<24);return(BigInt(o)<<BigInt(32))+BigInt(t+256*this[++e]+65536*this[++e]+this[++e]*2**24)})),s.prototype.readBigInt64BE=Y((function(e){F(e>>>=0,"offset");const t=this[e],r=this[e+7];void 0!==t&&void 0!==r||H(e,this.length-8);const o=(t<<24)+65536*this[++e]+256*this[++e]+this[++e];return(BigInt(o)<<BigInt(32))+BigInt(this[++e]*2**24+65536*this[++e]+256*this[++e]+r)})),s.prototype.readFloatLE=function(e,t){return e>>>=0,t||O(e,4,this.length),n.read(this,e,!0,23,4)},s.prototype.readFloatBE=function(e,t){return e>>>=0,t||O(e,4,this.length),n.read(this,e,!1,23,4)},s.prototype.readDoubleLE=function(e,t){return e>>>=0,t||O(e,8,this.length),n.read(this,e,!0,52,8)},s.prototype.readDoubleBE=function(e,t){return e>>>=0,t||O(e,8,this.length),n.read(this,e,!1,52,8)},s.prototype.writeUintLE=s.prototype.writeUIntLE=function(e,t,r,o){e=+e,t>>>=0,r>>>=0,o||B(this,e,t,r,Math.pow(2,8*r)-1,0);let n=1,i=0;for(this[t]=255&e;++i<r&&(n*=256);)this[t+i]=e/n&255;return t+r},s.prototype.writeUintBE=s.prototype.writeUIntBE=function(e,t,r,o){e=+e,t>>>=0,r>>>=0,o||B(this,e,t,r,Math.pow(2,8*r)-1,0);let n=r-1,i=1;for(this[t+n]=255&e;--n>=0&&(i*=256);)this[t+n]=e/i&255;return t+r},s.prototype.writeUint8=s.prototype.writeUInt8=function(e,t,r){return e=+e,t>>>=0,r||B(this,e,t,1,255,0),this[t]=255&e,t+1},s.prototype.writeUint16LE=s.prototype.writeUInt16LE=function(e,t,r){return e=+e,t>>>=0,r||B(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},s.prototype.writeUint16BE=s.prototype.writeUInt16BE=function(e,t,r){return e=+e,t>>>=0,r||B(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},s.prototype.writeUint32LE=s.prototype.writeUInt32LE=function(e,t,r){return e=+e,t>>>=0,r||B(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},s.prototype.writeUint32BE=s.prototype.writeUInt32BE=function(e,t,r){return e=+e,t>>>=0,r||B(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},s.prototype.writeBigUInt64LE=Y((function(e,t=0){return M(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))})),s.prototype.writeBigUInt64BE=Y((function(e,t=0){return U(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))})),s.prototype.writeIntLE=function(e,t,r,o){if(e=+e,t>>>=0,!o){const o=Math.pow(2,8*r-1);B(this,e,t,r,o-1,-o)}let n=0,i=1,u=0;for(this[t]=255&e;++n<r&&(i*=256);)e<0&&0===u&&0!==this[t+n-1]&&(u=1),this[t+n]=(e/i|0)-u&255;return t+r},s.prototype.writeIntBE=function(e,t,r,o){if(e=+e,t>>>=0,!o){const o=Math.pow(2,8*r-1);B(this,e,t,r,o-1,-o)}let n=r-1,i=1,u=0;for(this[t+n]=255&e;--n>=0&&(i*=256);)e<0&&0===u&&0!==this[t+n+1]&&(u=1),this[t+n]=(e/i|0)-u&255;return t+r},s.prototype.writeInt8=function(e,t,r){return e=+e,t>>>=0,r||B(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},s.prototype.writeInt16LE=function(e,t,r){return e=+e,t>>>=0,r||B(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},s.prototype.writeInt16BE=function(e,t,r){return e=+e,t>>>=0,r||B(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},s.prototype.writeInt32LE=function(e,t,r){return e=+e,t>>>=0,r||B(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},s.prototype.writeInt32BE=function(e,t,r){return e=+e,t>>>=0,r||B(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},s.prototype.writeBigInt64LE=Y((function(e,t=0){return M(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),s.prototype.writeBigInt64BE=Y((function(e,t=0){return U(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),s.prototype.writeFloatLE=function(e,t,r){return L(this,e,t,!0,r)},s.prototype.writeFloatBE=function(e,t,r){return L(this,e,t,!1,r)},s.prototype.writeDoubleLE=function(e,t,r){return $(this,e,t,!0,r)},s.prototype.writeDoubleBE=function(e,t,r){return $(this,e,t,!1,r)},s.prototype.copy=function(e,t,r,o){if(!s.isBuffer(e))throw new TypeError("argument should be a Buffer");if(r||(r=0),o||0===o||(o=this.length),t>=e.length&&(t=e.length),t||(t=0),o>0&&o<r&&(o=r),o===r)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(o<0)throw new RangeError("sourceEnd out of bounds");o>this.length&&(o=this.length),e.length-t<o-r&&(o=e.length-t+r);const n=o-r;return this===e&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(t,r,o):Uint8Array.prototype.set.call(e,this.subarray(r,o),t),n},s.prototype.fill=function(e,t,r,o){if("string"==typeof e){if("string"==typeof t?(o=t,t=0,r=this.length):"string"==typeof r&&(o=r,r=this.length),void 0!==o&&"string"!=typeof o)throw new TypeError("encoding must be a string");if("string"==typeof o&&!s.isEncoding(o))throw new TypeError("Unknown encoding: "+o);if(1===e.length){const t=e.charCodeAt(0);("utf8"===o&&t<128||"latin1"===o)&&(e=t)}}else"number"==typeof e?e&=255:"boolean"==typeof e&&(e=Number(e));if(t<0||this.length<t||this.length<r)throw new RangeError("Out of range index");if(r<=t)return this;let n;if(t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(n=t;n<r;++n)this[n]=e;else{const i=s.isBuffer(e)?e:s.from(e,o),u=i.length;if(0===u)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(n=0;n<r-t;++n)this[n+t]=i[n%u]}return this};const N={};function D(e,t,r){N[e]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:t.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${e}]`,this.stack,delete this.name}get code(){return e}set code(e){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:e,writable:!0})}toString(){return`${this.name} [${e}]: ${this.message}`}}}function G(e){let t="",r=e.length;const o="-"===e[0]?1:0;for(;r>=o+4;r-=3)t=`_${e.slice(r-3,r)}${t}`;return`${e.slice(0,r)}${t}`}function W(e,t,r,o,n,i){if(e>r||e<t){const o="bigint"==typeof t?"n":"";let n;throw n=i>3?0===t||t===BigInt(0)?`>= 0${o} and < 2${o} ** ${8*(i+1)}${o}`:`>= -(2${o} ** ${8*(i+1)-1}${o}) and < 2 ** ${8*(i+1)-1}${o}`:`>= ${t}${o} and <= ${r}${o}`,new N.ERR_OUT_OF_RANGE("value",n,e)}!function(e,t,r){F(t,"offset"),void 0!==e[t]&&void 0!==e[t+r]||H(t,e.length-(r+1))}(o,n,i)}function F(e,t){if("number"!=typeof e)throw new N.ERR_INVALID_ARG_TYPE(t,"number",e)}function H(e,t,r){if(Math.floor(e)!==e)throw F(e,r),new N.ERR_OUT_OF_RANGE(r||"offset","an integer",e);if(t<0)throw new N.ERR_BUFFER_OUT_OF_BOUNDS;throw new N.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${t}`,e)}D("ERR_BUFFER_OUT_OF_BOUNDS",(function(e){return e?`${e} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),D("ERR_INVALID_ARG_TYPE",(function(e,t){return`The "${e}" argument must be of type number. Received type ${typeof t}`}),TypeError),D("ERR_OUT_OF_RANGE",(function(e,t,r){let o=`The value of "${e}" is out of range.`,n=r;return Number.isInteger(r)&&Math.abs(r)>2**32?n=G(String(r)):"bigint"==typeof r&&(n=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(n=G(n)),n+="n"),o+=` It must be ${t}. Received ${n}`,o}),RangeError);const z=/[^+/0-9A-Za-z-_]/g;function V(e,t){let r;t=t||1/0;const o=e.length;let n=null;const i=[];for(let u=0;u<o;++u){if(r=e.charCodeAt(u),r>55295&&r<57344){if(!n){if(r>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(u+1===o){(t-=3)>-1&&i.push(239,191,189);continue}n=r;continue}if(r<56320){(t-=3)>-1&&i.push(239,191,189),n=r;continue}r=65536+(n-55296<<10|r-56320)}else n&&(t-=3)>-1&&i.push(239,191,189);if(n=null,r<128){if((t-=1)<0)break;i.push(r)}else if(r<2048){if((t-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function j(e){return o.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace(z,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function X(e,t,r,o){let n;for(n=0;n<o&&!(n+r>=t.length||n>=e.length);++n)t[n+r]=e[n];return n}function K(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function Z(e){return e!=e}const Q=function(){const e="0123456789abcdef",t=new Array(256);for(let r=0;r<16;++r){const o=16*r;for(let n=0;n<16;++n)t[o+n]=e[r]+e[n]}return t}();function Y(e){return"undefined"==typeof BigInt?J:e}function J(){throw new Error("BigInt not supported")}},251(e,t){t.read=function(e,t,r,o,n){var i,u,a=8*n-o-1,s=(1<<a)-1,l=s>>1,p=-7,d=r?n-1:0,c=r?-1:1,f=e[t+d];for(d+=c,i=f&(1<<-p)-1,f>>=-p,p+=a;p>0;i=256*i+e[t+d],d+=c,p-=8);for(u=i&(1<<-p)-1,i>>=-p,p+=o;p>0;u=256*u+e[t+d],d+=c,p-=8);if(0===i)i=1-l;else{if(i===s)return u?NaN:1/0*(f?-1:1);u+=Math.pow(2,o),i-=l}return(f?-1:1)*u*Math.pow(2,i-o)},t.write=function(e,t,r,o,n,i){var u,a,s,l=8*i-n-1,p=(1<<l)-1,d=p>>1,c=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,f=o?0:i-1,h=o?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,u=p):(u=Math.floor(Math.log(t)/Math.LN2),t*(s=Math.pow(2,-u))<1&&(u--,s*=2),(t+=u+d>=1?c/s:c*Math.pow(2,1-d))*s>=2&&(u++,s/=2),u+d>=p?(a=0,u=p):u+d>=1?(a=(t*s-1)*Math.pow(2,n),u+=d):(a=t*Math.pow(2,d-1)*Math.pow(2,n),u=0));n>=8;e[r+f]=255&a,f+=h,a/=256,n-=8);for(u=u<<n|a,l+=n;l>0;e[r+f]=255&u,f+=h,u/=256,l-=8);e[r+f-h]|=128*g}},586(e,t,r){"use strict";r.d(t,{STELLAR_GOVERNANCE_ZERO_PREDECESSOR:()=>Bt,STELLAR_LENDING_TOPICS:()=>Jr,STELLAR_NETWORKS:()=>o,STELLAR_NETWORK_PASSPHRASE:()=>u,SYNTHETIC_EVENT_ORDER_STRIDE:()=>to,buildSameTokenRepaySwapSteps:()=>wo,buildStellarAcceptOwnershipTx:()=>dt,buildStellarAddRewardsTx:()=>Rt,buildStellarApproveBlendPoolTx:()=>bt,buildStellarApproveTokenTx:()=>mt,buildStellarBatchSwapTx:()=>co,buildStellarBorrowBatchTx:()=>N,buildStellarBorrowTx:()=>D,buildStellarCctpForwardTx:()=>xo,buildStellarClaimRevenueTx:()=>It,buildStellarCreateLiquidityPoolTx:()=>Et,buildStellarExecuteCancellerResetTx:()=>_r,buildStellarExecuteStrategyTx:()=>po,buildStellarFlashLoanTx:()=>j,buildStellarGovernanceAddSpokeImmediateTx:()=>Br,buildStellarGovernanceCreateHubImmediateTx:()=>Or,buildStellarGovernanceExecuteGovernanceUpgradeTx:()=>vr,buildStellarGovernanceExecuteGrantGovernanceRoleTx:()=>Ar,buildStellarGovernanceExecuteRevokeGovernanceRoleTx:()=>Pr,buildStellarGovernanceExecuteTransferGovOwnTx:()=>qr,buildStellarGovernanceExecuteTx:()=>wr,buildStellarGovernanceExecuteUpdateDelayTx:()=>xr,buildStellarGovernancePauseTx:()=>Ur,buildStellarGovernanceRevokeRoleImmediateTx:()=>Mr,buildStellarGovernanceSetOracleSanityBoundsImmediateTx:()=>Rr,buildStellarGovernanceSetSpokeAssetFlagsImmediateTx:()=>Ir,buildStellarGrantRoleTx:()=>st,buildStellarLendingIdentifier:()=>ro,buildStellarLiquidateTx:()=>z,buildStellarMigrateFromBlendTx:()=>X,buildStellarMigrateTx:()=>it,buildStellarMultiplyTx:()=>K,buildStellarPauseTx:()=>ut,buildStellarProposeAddAssetToSpokeTx:()=>Zt,buildStellarProposeAddSpokeTx:()=>Xt,buildStellarProposeApproveBlendPoolTx:()=>nr,buildStellarProposeApproveTokenTx:()=>rr,buildStellarProposeCancellerResetTx:()=>Er,buildStellarProposeConfigureAssetOracleTx:()=>fr,buildStellarProposeConfigureMarketOracleTx:()=>hr,buildStellarProposeCreateHubTx:()=>jt,buildStellarProposeCreateLiquidityPoolTx:()=>ur,buildStellarProposeDeployPoolTx:()=>sr,buildStellarProposeEditAssetInSpokeTx:()=>Qt,buildStellarProposeEditOracleToleranceTx:()=>gr,buildStellarProposeGovernanceUpgradeTx:()=>yr,buildStellarProposeGrantGovernanceRoleTx:()=>Sr,buildStellarProposeMigrateControllerTx:()=>dr,buildStellarProposeRemoveAssetFromSpokeTx:()=>Yt,buildStellarProposeRemoveSpokeTx:()=>Kt,buildStellarProposeRevokeBlendPoolTx:()=>ir,buildStellarProposeRevokeGovernanceRoleTx:()=>mr,buildStellarProposeRevokeTokenTx:()=>or,buildStellarProposeSetAccumulatorTx:()=>zt,buildStellarProposeSetAggregatorTx:()=>Ht,buildStellarProposeSetMinBorrowCollatTx:()=>tr,buildStellarProposeSetPositionLimitsTx:()=>Vt,buildStellarProposeSetPositionManagerTx:()=>er,buildStellarProposeSetPriceAggregatorTx:()=>Ft,buildStellarProposeSetSpokeLiquidationCurveTx:()=>Jt,buildStellarProposeSetSwapAggregatorTx:()=>Wt,buildStellarProposeTransferCtrlOwnershipTx:()=>cr,buildStellarProposeTransferGovOwnTx:()=>Tr,buildStellarProposeUnpauseTx:()=>Cr,buildStellarProposeUpdateDelayTx:()=>br,buildStellarProposeUpgradeControllerTx:()=>pr,buildStellarProposeUpgradePoolParamsTx:()=>ar,buildStellarProposeUpgradePoolTx:()=>lr,buildStellarRenewAccountTx:()=>kt,buildStellarRepayBatchTx:()=>F,buildStellarRepayDebtWithCollateralTx:()=>Y,buildStellarRepayTx:()=>H,buildStellarRevokeBlendPoolTx:()=>St,buildStellarRevokeRoleTx:()=>lt,buildStellarRevokeTokenTx:()=>Tt,buildStellarSetAccumulatorTx:()=>gt,buildStellarSetAggregatorTx:()=>ht,buildStellarSetMarketOracleConfigTx:()=>vt,buildStellarSetOracleSanityBoundsTx:()=>Pt,buildStellarSetOracleToleranceTx:()=>xt,buildStellarSetOracleTx:()=>wt,buildStellarSetPositionLimitsTx:()=>yt,buildStellarSetPriceAggregatorTx:()=>ft,buildStellarSetSpokeAssetFlagsTx:()=>At,buildStellarSetSwapAggregatorTx:()=>ct,buildStellarSupplyBatchTx:()=>L,buildStellarSupplyTx:()=>$,buildStellarSwapCollateralTx:()=>Q,buildStellarSwapDebtTx:()=>Z,buildStellarTransferOwnershipTx:()=>pt,buildStellarUnpauseTx:()=>at,buildStellarUpdateAccountThresholdTx:()=>Ot,buildStellarUpdateIndexesTx:()=>qt,buildStellarUpgradeControllerTx:()=>nt,buildStellarUpgradeLiquidityPoolParamsTx:()=>_t,buildStellarWithdrawBatchTx:()=>G,buildStellarWithdrawTx:()=>W,buildTx:()=>U,decodeStellarLendingEvent:()=>eo,decodeStellarLiquidateReturn:()=>V,encodeAssetOracle:()=>rt,encodeInterestRateModel:()=>ze,encodeMarketOracleConfigInput:()=>ot,encodeMarketParamsRaw:()=>Ve,encodePositionLimits:()=>je,encodePriceKey:()=>Xe,encodeStrategyPayloadToRouteXdr:()=>lo,extractEventOrder:()=>oo,getStellarAccountPositions:()=>fe,getStellarActiveUsersSeries:()=>Le,getStellarAggregatorQuote:()=>ao,getStellarAsset:()=>le,getStellarAssetGraph:()=>Te,getStellarAssetMarkets:()=>ye,getStellarAssetPage:()=>ge,getStellarAssets:()=>ne,getStellarCampaignLeaderboard:()=>Re,getStellarCampaignMe:()=>Fe,getStellarDefiLlamaDimensions:()=>Ne,getStellarDeployment:()=>i,getStellarDetailedMarkets:()=>oe,getStellarFeeRevenueSeries:()=>Me,getStellarGovernanceProposals:()=>qe,getStellarHolderDistribution:()=>Ie,getStellarHub:()=>pe,getStellarHubGraph:()=>we,getStellarHubHolders:()=>Se,getStellarHubs:()=>ie,getStellarLendingContext:()=>te,getStellarLendingLiveState:()=>re,getStellarLiquidationsLeaderboard:()=>_e,getStellarLiquidationsSeries:()=>Ue,getStellarParticipantCounts:()=>Ee,getStellarPnlByScope:()=>We,getStellarPositionsLeaderboard:()=>ke,getStellarPositionsPnl:()=>Ge,getStellarQuoteTokens:()=>so,getStellarRateSpreadSeries:()=>$e,getStellarReserve:()=>se,getStellarReserveGraph:()=>xe,getStellarReserveHolders:()=>be,getStellarReserves:()=>ae,getStellarRevenueSeries:()=>Be,getStellarSpoke:()=>de,getStellarSpokeGraph:()=>ve,getStellarSpokeHolders:()=>me,getStellarSpokes:()=>ue,getStellarStatsHistory:()=>Oe,getStellarUserActivity:()=>Ae,getStellarUserActivityPage:()=>Pe,getStellarUserHistory:()=>De,getStellarUserPositions:()=>ce,getStellarVolumeSeries:()=>Ce,getStellarWalletBalance:()=>he,mapQuoteResponseToAggregatorSwap:()=>go,mapQuoteResponseToStrategyPayload:()=>fo,mapQuoteResponseToStrategySwap:()=>ho,mapSorobanError:()=>Po,mapStellarPositionActivityType:()=>io,prepareStellarBuiltTx:()=>mo,prepareStellarTxXdr:()=>So,stellarLendingDispatchKey:()=>Nr,stellarLendingRead:()=>He,stellarNetworks:()=>n,syntheticEventOrder:()=>no,tagStellarInvokedContractError:()=>bo,toBase64Xdr:()=>Lr,toStellarPositionMode:()=>To});const o={stellarMainnet:{name:"mainnet",passphrase:"Public Global Stellar Network ; September 2015",horizonUrl:"https://horizon.stellar.org",sorobanRpcUrl:"https://stellar-gateway.xoxno.com",quoteUrl:"https://stellar-swap.xoxno.com",explorerNetwork:"public",aquariusApiUrl:"https://amm-api.aqua.network",aquariusRouter:"CBQDHNBFBZYE4MKPWBSJOPIYLW4SFSXAXUTSXJN76GNKYVYPCKWC6QUK",lendingController:"CAUCMIN5KSXEVZ7NMXR3LZATGD5EFIEUI5XWTFLYRO2R5OTXI22WE5JX",aggregatorRouter:"CCVENFSVCBYDHVOACFZXMNNYVOZ3LKXPZYU5LUI4N7KTXOKRVYD7F3TR",governance:"CC44PEQW7HSEPKAZ5ZRPH2JS5M5KVJXCUBLJ2ZX4E3WCDKMNFILHC2AD",priceAggregator:"CBGUF2G2Q7HCVCWYISDXBHPVBGMYNXA7PG2VET66YBZX6IKOOV27NSMV",positionNftContract:"CAWCSG77AY2W24QZ6ZXLHZU4UXEFHZBM6EI4A4IF7JB5CTY4XND3TI6C"},stellarTestnet:{name:"testnet",passphrase:"Test SDF Network ; September 2015",horizonUrl:"https://horizon-testnet.stellar.org",sorobanRpcUrl:"https://stellar-testnet-gateway.xoxno.com",quoteUrl:"https://testnet-stellar-swap.xoxno.com",explorerNetwork:"testnet",aquariusApiUrl:"https://amm-api-testnet.aqua.network",aquariusRouter:"CBCFTQSPDBAIZ6R6PJQKSQWKNKWH2QIV3I4J72SHWBIK3ADRRAM5A6GD",lendingController:"CCXRWJ6SIU2WPFEGLFGJVITPL57QAYIMIO6OAM2NBGNDQSSCK2FFV3F3",aggregatorRouter:"CDNTWMWW2WGYTKIZTJYNGNVQQZI4KTC5BQRZ3275KESRX5T4O3AYECL5",governance:"CDS33JDOYH3F3FL4QUQ6DV4WKHML2AKHF4LADTZ57FRUAEBTE7NMY5FQ",priceAggregator:"CAALOOTIDXCX7D7FMQIBSSAJLPKOM3GMXS4UUSTDIG42JCRRJHOPUHOP",positionNftContract:"CDVN5JU675MEDPVRPCYC45AHFC275UH57WEU5OTFE4WFGZBNN7HTLPSY"}},n=o;function i(e){return o["testnet"===e?"stellarTestnet":"stellarMainnet"]}const u={mainnet:o.stellarMainnet.passphrase,testnet:o.stellarTestnet.passphrase},a=require("@stellar/stellar-sdk");var s=r(287);const l=["Soroswap","Aquarius","Phoenix","Sushi","CometDex"],p={Soroswap:0,Aquarius:1,Phoenix:2,Sushi:3,CometDex:4},d=1e6,c=e=>new a.Address(e).toScVal(),f=e=>new a.ScInt(e).toI128(),h=e=>a.xdr.ScVal.scvU32(e),g=e=>{if("number"==typeof e&&!Number.isSafeInteger(e))throw new Error("Stellar builder: u64 numbers must be safe integers; pass a decimal string for larger values");return new a.ScInt("string"==typeof e?e:e.toString()).toU64()},y=e=>a.xdr.ScVal.scvBool(e),b=e=>a.xdr.ScVal.scvString(e),S=e=>a.xdr.ScVal.scvSymbol(e),m=()=>a.xdr.ScVal.scvVoid(),T=e=>a.xdr.ScVal.scvVec(e),w=(e,t=32)=>{const r=e.startsWith("0x")?e.slice(2):e,o=s.hp.from(r,"hex");if(o.length!==t)throw new Error(`Stellar builder: expected a ${t}-byte BytesN (got ${o.length} bytes from "${e}")`);return a.xdr.ScVal.scvBytes(o)},v=(e,t)=>null==e?m():t(e),x=(e,t)=>k({asset:c(t),hub_id:h(e)}),A=(e,t,r)=>a.xdr.ScVal.scvVec([x(e,t),f(r)]),P=e=>a.xdr.ScVal.scvVec(e.map((e=>A(e.hubId,e.asset,e.amount)))),q=e=>{if("Transfer"===e)return T([S("Transfer")]);if(e&&"object"==typeof e&&"Credit"in e){const t=e.Credit;if("number"==typeof t&&!Number.isInteger(t))throw new Error(`Stellar builder: SeizeMode Credit account id must be an integer u64, got ${t}`);return T([S("Credit"),g(t)])}throw new Error(`Stellar builder: SeizeMode must be 'Transfer' or { Credit: accountId }, got ${JSON.stringify(e)}`)},k=e=>{const t=Object.keys(e).sort().map((t=>new a.xdr.ScMapEntry({key:S(t),val:e[t]})));return a.xdr.ScVal.scvMap(t)};class E{assets=[];amounts=[];ops=[];weights=[];constructor(e){this.amounts.push(e)}asset(e){const t=this.assets.indexOf(e);if(-1!==t)return t;if(this.assets.length>=256)throw new Error("Stellar builder: strategy references more than 256 distinct addresses");return this.assets.push(e),this.assets.length-1}amount(e){if(this.amounts.length>=126)throw new Error("Stellar builder: strategy references too many distinct amounts");return this.amounts.push(e),this.amounts.length-1}weight(e){if(this.weights.length>=32)throw new Error("Stellar builder: strategy uses more than 32 split weights");if(!Number.isInteger(e)||e<=0||e>d)throw new Error(`Stellar builder: split weight ${e} outside 1..=1000000`);return this.weights.push(e),this.weights.length-1}emit(e,t,r,o,n){this.ops.push([e,t,r,o,n])}emitPath(e,t){e.hops.forEach(((r,o)=>{if(r.tokenIn===r.tokenOut)throw new Error("Stellar builder: hop swaps a token for itself");const n=e.hops[o-1];if(n&&r.tokenIn!==n.tokenOut)throw new Error("Stellar builder: hop does not chain onto its predecessor's output");this.emit(p[r.venue],0===o?t:1,this.asset(r.pool),this.asset(r.tokenIn),this.asset(r.tokenOut))}))}lowerPaths(e){const t=e.filter((e=>e.hops.length>0)),r=Array.from({length:t.length},(()=>!1));for(let e=0;e<t.length;e+=1){if(r[e])continue;const o=t[e].hops[0]?.tokenIn,n=[];for(let r=e;r<t.length;r+=1)t[r].hops[0]?.tokenIn===o&&n.push(r);const i=n.reduce(((e,r)=>e+t[r].splitPpm),0);if(i>d)throw new Error(`Stellar builder: split weights for one token sum to ${i}, above 1000000`);const u=i===d;let a=d;n.forEach(((e,o)=>{r[e]=!0;const i=t[e];let s;if(o+1===n.length&&u)s=0;else{if(0===a)throw new Error("Stellar builder: split weights exhaust the group before its last path");const e=Math.floor(i.splitPpm*d/a);a-=Math.min(i.splitPpm,a),s=128+this.weight(e)}this.emitPath(i,s)}))}}toBytes(e,t,r){if(0===this.ops.length)throw new Error("Stellar builder: strategy lowered to zero instructions");if(this.ops.length>48)throw new Error(`Stellar builder: strategy has ${this.ops.length} instructions, the router accepts 48`);const o=[1,e,t,0,r>>>24&255,r>>>16&255,r>>>8&255,255&r,this.ops.length,this.weights.length];for(const e of this.ops)o.push(...e);for(const e of this.weights)o.push(e>>>16&255,e>>>8&255,255&e);return s.hp.from(o)}get assetList(){return this.assets}get amountList(){return this.amounts}}const _=e=>{const t=new E(e.totalMinOut),r=t.asset(e.tokenIn),o=t.asset(e.tokenOut);if(r===o)throw new Error("Stellar builder: `tokenIn` and `tokenOut` are the same asset");if(e.burnPool){const o=t.asset(e.burnPool),n=t.amountList.length;for(const r of e.burnMinAmounts??[])t.amount(r);t.emit(5,0,o,r,n)}if(t.lowerPaths(e.paths),e.mintPool){const r=e.preSwapAmount;if(r&&BigInt(r)>0n){const o=e.mintPoolTokens;if(!o||2!==o.length)throw new Error("Stellar builder: `preSwapAmount` needs `mintPoolTokens` to name the pool’s two constituents");const[n,i]=o,[u,a]=e.preSwapFromA?[n,i]:[i,n];t.emit(p.Aquarius,2+t.amount(r),t.asset(e.mintPool),t.asset(u),t.asset(a))}t.emit(6,0,t.asset(e.mintPool),o,t.amount(e.mintMinShares??"1"))}const n=Number(e.referralId??0);if(!Number.isInteger(n)||n<0||n>4294967295)throw new Error(`Stellar builder: referral id ${e.referralId} does not fit the wire’s u32`);return k({amounts:a.xdr.ScVal.scvVec(t.amountList.map((e=>f(e)))),assets:a.xdr.ScVal.scvVec(t.assetList.map((e=>c(e)))),ops:a.xdr.ScVal.scvBytes(t.toBytes(r,o,n))})},I=e=>{const t=s.hp.from(e);if(0===t.length)throw new Error("Stellar builder: strategy swap bytes must be non-empty base64 routeXdr, 0x hex string, or Uint8Array");return a.xdr.ScVal.scvBytes(t)},R=()=>a.xdr.ScVal.scvBytes(s.hp.alloc(0)),O=e=>{const t=e.trim();if(t.startsWith("0x")){const e=t.slice(2);if(!((r=e).length>0&&r.length%2==0&&/^[0-9a-fA-F]+$/.test(r)))throw new Error("Stellar builder: strategy swap bytes hex string must be 0x-prefixed and even-length");return s.hp.from(e,"hex")}var r;if(!/^[A-Za-z0-9+/]+={0,2}$/.test(t))throw new Error("Stellar builder: strategy swap bytes must be base64 routeXdr or 0x-prefixed hex");const o=s.hp.from(t,"base64");if(0===o.length)throw new Error("Stellar builder: strategy swap bytes must be non-empty base64 routeXdr, 0x hex string, or Uint8Array");return o},B=e=>{if("string"==typeof e)return I(O(e));if(e instanceof Uint8Array)return 0===e.length?R():I(e);if(e&&"object"==typeof e)return"routeXdr"in(r=e)&&"string"==typeof r.routeXdr?I(O(e.routeXdr)):(e=>"swapXdr"in e&&"string"==typeof e.swapXdr)(e)?I(O(e.swapXdr)):(e=>"bytes"in e&&("string"==typeof e.bytes||e.bytes instanceof Uint8Array))(e)?"string"==typeof e.bytes?I(O(e.bytes)):0===e.bytes.length?R():I(e.bytes):(t=(e=>{if(!e||"object"!=typeof e)throw new Error("Stellar builder: decoded strategy `steps` must be a StrategyPayload ({ paths, tokenIn, tokenOut, totalMinOut })");const t=e;if(!Array.isArray(t.paths)||0===t.paths.length&&!t.burnPool&&!t.mintPool)throw new Error("Stellar builder: `steps.paths` needs a strategy path or a liquidity burn/mint operation");if("string"!=typeof t.tokenIn)throw new Error("Stellar builder: `steps.tokenIn` must be a contract address");if("string"!=typeof t.tokenOut)throw new Error("Stellar builder: `steps.tokenOut` must be a contract address");if("string"!=typeof t.totalMinOut)throw new Error("Stellar builder: `steps.totalMinOut` must be an i128 decimal string");const r=new Map;for(const[e,o]of t.paths.entries()){if(!o||"number"!=typeof o.splitPpm||o.splitPpm<=0||!Array.isArray(o.hops)||0===o.hops.length)throw new Error(`Stellar builder: \`steps.paths[${e}]\` must have splitPpm > 0 and a non-empty hops array`);for(const[t,r]of o.hops.entries())if(!r||"string"!=typeof r.pool||"string"!=typeof r.tokenIn||"string"!=typeof r.tokenOut||!l.includes(r.venue))throw new Error(`Stellar builder: \`steps.paths[${e}].hops[${t}]\` must have pool, tokenIn, tokenOut, and a valid Soroban venue`);const t=o.hops[0];r.set(t.tokenIn,(r.get(t.tokenIn)??0)+o.splitPpm)}for(const[e,o]of r){if(o>d)throw new Error(`Stellar builder: \`steps.paths[].splitPpm\` for ${e} sums to ${o}, above 1000000`);if(!t.mintPool&&o!==d)throw new Error(`Stellar builder: \`steps.paths[].splitPpm\` for ${e} must sum to 1000000, got ${o}`)}return t})(e),a.xdr.ScVal.scvBytes(s.hp.from(_(t).toXDR("base64"),"base64")));var t,r;throw new Error("Stellar builder: `steps` must be opaque strategy bytes (`routeXdr`, base64/hex string, or Uint8Array)")},M=e=>{if("string"==typeof e)return(e=>{const t=e.startsWith("0x")?e.slice(2):e,r=s.hp.from(t,"hex");return a.xdr.ScVal.scvBytes(r)})(e);if(e instanceof Uint8Array)return a.xdr.ScVal.scvBytes(s.hp.from(e));throw new Error("Stellar builder: `data` must be a hex string or Uint8Array (Soroban Bytes payload)")};function U(e,t,r){if(!e.controllerAddress)throw new Error("Stellar lending controllerAddress is required");const o=new a.Contract(e.controllerAddress),n=new a.Account(e.caller,e.sourceSequence);return{xdr:new a.TransactionBuilder(n,{fee:e.fee??a.BASE_FEE,networkPassphrase:u[e.network]}).addOperation(o.call(t,...r)).setTimeout(e.timeoutSeconds??300).build().toXDR()}}function C(e){if(!Number.isInteger(e)||e<1||e>4294967295)throw new Error("Stellar builder: spokeId must be an integer from 1 to 4294967295");return h(e)}function L(e,t){const r=t.accountNonce??0;return U(e,"supply",[c(e.caller),g(r),C(t.spokeId),P([...t.assets])])}function $(e,t){return L(e,{accountNonce:t.accountNonce,spokeId:t.spokeId,assets:[{hubId:t.hubId,asset:t.asset,amount:t.amount}]})}function N(e,t){return U(e,"borrow",[c(e.caller),g(t.accountNonce),P([...t.borrows]),v(t.to,c)])}function D(e,t){return N(e,{accountNonce:t.accountNonce,borrows:[{hubId:t.hubId,asset:t.asset,amount:t.amount}],to:t.to})}function G(e,t){return U(e,"withdraw",[c(e.caller),g(t.accountNonce),P([...t.withdrawals]),v(t.to,c)])}function W(e,t){return G(e,{accountNonce:t.accountNonce,withdrawals:[{hubId:t.hubId,asset:t.asset,amount:t.amount}],to:t.to})}function F(e,t){return U(e,"repay",[c(e.caller),g(t.accountNonce),P([...t.payments])])}function H(e,t){return F(e,{accountNonce:t.accountNonce,payments:[{hubId:t.hubId,asset:t.asset,amount:t.amount}]})}function z(e,t){return U(e,"liquidate",[c(e.caller),g(t.accountNonce),P([...t.debtPayments]),q(t.seizeMode??"Transfer")])}function V(e){const t=(0,a.scValToNative)(a.xdr.ScVal.fromXDR(e,"base64"));if("bigint"==typeof t||"number"==typeof t)return t.toString();throw new Error("Stellar builder: liquidate return value must be a u64, got "+typeof t)}function j(e,t){return U(e,"flash_loan",[c(e.caller),x(t.hubId,t.asset),f(t.amount),c(t.receiver),M(t.data)])}function X(e,t){return U(e,"migrate_from_blend",[c(e.caller),g(t.accountId),C(t.spokeId),h(t.hubId),c(t.blendPool),T(t.collateralTokens.map(c)),T(t.supplyTokens.map(c)),(r=t.debtCaps.map((e=>({token:e.token,amount:e.cap}))),a.xdr.ScVal.scvVec(r.map((e=>{return t=e.token,r=e.amount,a.xdr.ScVal.scvVec([c(t),f(r)]);var t,r}))))]);var r}function K(e,t){const r=t.accountNonce??0;return U(e,"multiply",[c(e.caller),g(r),C(t.spokeId),x(t.collateral.hubId,t.collateral.asset),f(t.debtToFlashLoan),x(t.debt.hubId,t.debt.asset),h(t.mode),B(t.steps),v(t.initialPayment,(e=>A(e.hubId,e.asset,e.amount))),v(t.convertSwap,B)])}function Z(e,t){return U(e,"swap_debt",[c(e.caller),g(t.accountNonce),x(t.existingDebt.hubId,t.existingDebt.asset),f(t.newDebtAmount),x(t.newDebt.hubId,t.newDebt.asset),B(t.steps)])}function Q(e,t){return U(e,"swap_collateral",[c(e.caller),g(t.accountNonce),x(t.current.hubId,t.current.asset),f(t.fromAmount),x(t.newCollateral.hubId,t.newCollateral.asset),B(t.steps)])}function Y(e,t){return U(e,"repay_debt_with_collateral",[c(e.caller),g(t.accountNonce),x(t.collateral.hubId,t.collateral.asset),f(t.collateralAmount),x(t.debt.hubId,t.debt.asset),B(t.steps),y(t.closePosition)])}const J="/stellar-lending",ee=encodeURIComponent,te=(e,t)=>e.fetchWithTimeout(`${J}/context`,t),re=(e,t)=>e.fetchWithTimeout(`${J}/live-state`,t),oe=(e,t)=>e.fetchWithTimeout(`${J}/markets/detailed`,t),ne=(e,t)=>e.fetchWithTimeout(`${J}/assets`,t),ie=(e,t)=>e.fetchWithTimeout(`${J}/hubs`,t),ue=(e,t)=>e.fetchWithTimeout(`${J}/spokes`,t),ae=(e,t={},r)=>e.fetchWithTimeout(`${J}/reserves`,{...r,params:{...t}}),se=(e,t,r,o,n)=>e.fetchWithTimeout(`${J}/reserves/${t}/${r}/${ee(o)}`,n),le=(e,t,r)=>e.fetchWithTimeout(`${J}/assets/${ee(t)}`,r),pe=(e,t,r)=>e.fetchWithTimeout(`${J}/hubs/${t}`,r),de=(e,t,r)=>e.fetchWithTimeout(`${J}/spokes/${t}`,r),ce=(e,t,r)=>e.fetchWithTimeout(`${J}/users/${ee(t)}/positions`,r),fe=(e,t,r)=>e.fetchWithTimeout(`${J}/accounts/${ee(t)}/positions`,r),he=(e,t,r,o)=>e.fetchWithTimeout(`${J}/users/${ee(t)}/assets/${ee(r)}/balance`,o),ge=(e,t,r,o)=>e.fetchWithTimeout(`${J}/assets/${ee(t)}/page`,{...o,params:{...r}}),ye=(e,t,r,o)=>e.fetchWithTimeout(`${J}/assets/${ee(t)}/markets`,{...o,params:{side:r}}),be=(e,t,r,o,n,i)=>e.fetchWithTimeout(`${J}/reserves/${t}/${r}/${ee(o)}/holders`,{...i,params:{side:n}}),Se=(e,t,r,o)=>e.fetchWithTimeout(`${J}/hubs/${t}/holders`,{...o,params:{side:r}}),me=(e,t,r,o)=>e.fetchWithTimeout(`${J}/spokes/${t}/holders`,{...o,params:{side:r}}),Te=(e,t,r,o)=>e.fetchWithTimeout(`${J}/assets/${ee(t)}/graph`,{...o,params:{...r}}),we=(e,t,r,o)=>e.fetchWithTimeout(`${J}/hubs/${t}/graph`,{...o,params:{...r}}),ve=(e,t,r,o)=>e.fetchWithTimeout(`${J}/spokes/${t}/graph`,{...o,params:{...r}}),xe=(e,t,r,o,n,i)=>e.fetchWithTimeout(`${J}/reserves/${t}/${r}/${ee(o)}/graph`,{...i,params:{...n}}),Ae=(e,t,r={},o)=>e.fetchWithTimeout(`${J}/users/${ee(t)}/activity`,{...o,params:{...r}}),Pe=(e,t,r={},o)=>e.fetchWithTimeout(`${J}/users/${ee(t)}/activity/page`,{...o,params:{...r}}),qe=(e,t={},r)=>e.fetchWithTimeout(`${J}/governance/proposals`,{...r,params:{...t}}),ke=(e,t={},r)=>e.fetchWithTimeout(`${J}/positions`,{...r,params:{...t}}),Ee=(e,t={},r)=>e.fetchWithTimeout(`${J}/participants`,{...r,params:{...t}}),_e=(e,t={},r)=>e.fetchWithTimeout(`${J}/liquidations/leaderboard`,{...r,params:{...t}}),Ie=(e,t={},r)=>e.fetchWithTimeout(`${J}/distribution`,{...r,params:{...t}}),Re=(e,t={},r)=>e.fetchWithTimeout(`${J}/campaign/leaderboard`,{...r,params:{...t}}),Oe=(e,t,r)=>e.fetchWithTimeout(`${J}/stats/history`,{...r,params:{...t}}),Be=(e,t,r)=>e.fetchWithTimeout(`${J}/revenue`,{...r,params:{...t}}),Me=(e,t,r)=>e.fetchWithTimeout(`${J}/revenue/fees`,{...r,params:{...t}}),Ue=(e,t,r)=>e.fetchWithTimeout(`${J}/liquidations`,{...r,params:{...t}}),Ce=(e,t,r)=>e.fetchWithTimeout(`${J}/volume`,{...r,params:{...t}}),Le=(e,t,r)=>e.fetchWithTimeout(`${J}/active-users`,{...r,params:{...t}}),$e=(e,t,r)=>e.fetchWithTimeout(`${J}/rate-spread`,{...r,params:{...t}}),Ne=(e,t,r)=>e.fetchWithTimeout(`${J}/defillama`,{...r,params:{...t}}),De=(e,t,r,o)=>e.fetchWithTimeout(`${J}/users/${ee(t)}/history`,{...o,params:{...r}}),Ge=(e,t,r)=>e.fetchWithTimeout(`${J}/pnl`,{...r,params:{accountId:t}}),We=(e,t,r)=>e.fetchWithTimeout(`${J}/pnl/scope`,{...r,params:{scope:t}}),Fe=(e,t,r)=>e.fetchWithTimeout(`${J}/campaign/me`,{...r,params:{owner:t}}),He=e=>({context:t=>te(e,t),liveState:t=>re(e,t),marketsDetailed:t=>oe(e,t),assets:t=>ne(e,t),hubs:t=>ie(e,t),spokes:t=>ue(e,t),reserves:(t={},r)=>void 0!==r||"hubId"in t||"spokeId"in t||"asset"in t?ae(e,t,r):ae(e,{},t),reserve:(t,r,o,n)=>se(e,t,r,o,n),asset:(t,r)=>le(e,t,r),hub:(t,r)=>pe(e,t,r),spoke:(t,r)=>de(e,t,r),userPositions:(t,r)=>ce(e,t,r),accountPositions:(t,r)=>fe(e,t,r),walletBalance:(t,r,o)=>he(e,t,r,o),assetPage:(t,r,o)=>ge(e,t,r,o),assetMarkets:(t,r,o)=>ye(e,t,r,o),reserveHolders:(t,r,o,n,i)=>be(e,t,r,o,n,i),hubHolders:(t,r,o)=>Se(e,t,r,o),spokeHolders:(t,r,o)=>me(e,t,r,o),assetGraph:(t,r,o)=>Te(e,t,r,o),hubGraph:(t,r,o)=>we(e,t,r,o),spokeGraph:(t,r,o)=>ve(e,t,r,o),reserveGraph:(t,r,o,n,i)=>xe(e,t,r,o,n,i),userActivity:(t,r={},o)=>Ae(e,t,r,o),userActivityPage:(t,r={},o)=>Pe(e,t,r,o),governanceProposals:(t={},r)=>qe(e,t,r),positionsLeaderboard:(t={},r)=>ke(e,t,r),participants:(t={},r)=>Ee(e,t,r),liquidationsLeaderboard:(t={},r)=>_e(e,t,r),distribution:(t={},r)=>Ie(e,t,r),campaignLeaderboard:(t={},r)=>Re(e,t,r),statsHistory:(t,r)=>Oe(e,t,r),revenue:(t,r)=>Be(e,t,r),feeRevenue:(t,r)=>Me(e,t,r),liquidations:(t,r)=>Ue(e,t,r),volume:(t,r)=>Ce(e,t,r),activeUsers:(t,r)=>Le(e,t,r),rateSpread:(t,r)=>$e(e,t,r),defillama:(t,r)=>Ne(e,t,r),userHistory:(t,r,o)=>De(e,t,r,o),positionsPnl:(t,r)=>Ge(e,t,r),pnlByScope:(t,r)=>We(e,t,r),campaignMe:(t,r)=>Fe(e,t,r)}),ze=e=>k({base_borrow_rate:f(e.baseBorrowRateRay),max_borrow_rate:f(e.maxBorrowRateRay),max_utilization:f(e.maxUtilizationRay),mid_utilization:f(e.midUtilizationRay),optimal_utilization:f(e.optimalUtilizationRay),reserve_factor:h(e.reserveFactorBps),slope1:f(e.slope1Ray),slope2:f(e.slope2Ray),slope3:f(e.slope3Ray)}),Ve=e=>k({asset_decimals:h(e.assetDecimals),asset_id:c(e.assetId),base_borrow_rate:f(e.baseBorrowRateRay),flashloan_fee:h(e.flashloanFeeBps),is_flashloanable:y(e.isFlashloanable),max_borrow_rate:f(e.maxBorrowRateRay),max_utilization:f(e.maxUtilizationRay),mid_utilization:f(e.midUtilizationRay),optimal_utilization:f(e.optimalUtilizationRay),reserve_factor:h(e.reserveFactorBps),slope1:f(e.slope1Ray),slope2:f(e.slope2Ray),slope3:f(e.slope3Ray)}),je=e=>k({max_borrow_positions:h(e.maxBorrowPositions),max_supply_positions:h(e.maxSupplyPositions)}),Xe=e=>{if("Token"in e&&e.Token)return T([S("Token"),c(e.Token)]);if("Ref"in e&&e.Ref)return T([S("Ref"),S(e.Ref)]);throw new Error(`Stellar builder: PriceKey must be { Token } or { Ref }, got ${JSON.stringify(e)}`)},Ke=e=>{if("Stellar"in e)return T([S("Stellar"),c(e.Stellar)]);if("Symbol"in e)return T([S("Symbol"),S(e.Symbol)]);if("String"in e)return T([S("String"),b(e.String)]);throw new Error(`Stellar builder: unknown OracleAssetRef ${JSON.stringify(e)}`)},Ze=e=>{if("Spot"===e)return T([S("Spot")]);if(e&&"object"==typeof e&&"Twap"in e)return T([S("Twap"),h(Number(e.Twap))]);throw new Error(`Stellar builder: unknown OracleReadMode ${JSON.stringify(e)}`)},Qe=e=>{if("Reflector"===e||"RedStone"===e||"Xoxno"===e)return T([S(e)]);throw new Error(`Stellar builder: unknown ProviderKind "${e}"`)},Ye=e=>{if("Market"===e||"Fundamental"===e)return T([S(e)]);throw new Error(`Stellar builder: unknown FeedNature "${e}"`)},Je=e=>{if("Reflector"in e){const t=e.Reflector;return T([S("Reflector"),k({asset:Ke(t.asset),contract:c(t.contract),read_mode:Ze(t.readMode)})])}if("MultiFeed"in e){const t=e.MultiFeed;return T([S("MultiFeed"),k({contract:c(t.contract),feed_id:b(t.feedId),kind:Qe(t.kind),nature:Ye(t.nature)})])}throw new Error(`Stellar builder: unknown ProviderRef ${JSON.stringify(e)}`)},et=e=>{const t=e;return k({decimals:h(t.decimals),max_stale_seconds:g(t.maxStaleSeconds),provider:Je(t.provider)})},tt=e=>{if("RequireDisjoint"===e)return T([S("RequireDisjoint")]);if(e&&"object"==typeof e&&"AllowShared"in e){const t=e.AllowShared;return T([S("AllowShared"),T(t.map((e=>k({contract:c(e.contract),kind:Qe(e.kind)}))))])}throw new Error(`Stellar builder: unknown IndependencePolicy ${JSON.stringify(e)}`)},rt=e=>{const t=e,r=t.sources??[];let o,n;if("number"==typeof t.toleranceBps)o=1e4+t.toleranceBps,n=Math.max(1,Math.floor(1e8/o));else{const e=t.tolerance??{};o=Number(e.upperRatioBps),n=Number(e.lowerRatioBps)}return k({asset_decimals:h(Number(t.assetDecimals)),independence:tt(t.independence),max_price_stale_seconds:g(Number(t.maxPriceStaleSeconds)),max_sanity_price_wad:f(String(t.maxSanityPriceWad)),min_sanity_price_wad:f(String(t.minSanityPriceWad)),sources:T(r.map((e=>(e=>{if("Feed"in e)return T([S("Feed"),et(e.Feed)]);if("Scaled"in e){const t=e.Scaled;return T([S("Scaled"),k({factor:et(t.factor),max_factor_wad:f(t.maxFactorWad),min_factor_wad:f(t.minFactorWad),quote:Xe(t.quote)})])}if("LpShare"in e){const t=e.LpShare;return T([S("LpShare"),k({key_a:Xe(t.keyA),key_b:Xe(t.keyB),kind:T([S(t.kind||"ConstantProduct")]),pool:c(t.pool),reserve_a_decimals:h(t.reserveADecimals),reserve_b_decimals:h(t.reserveBDecimals),share_decimals:h(t.shareDecimals)})])}throw new Error(`Stellar builder: unknown PriceSource ${JSON.stringify(e)}`)})(e)))),tolerance:k({lower_ratio_bps:h(n),upper_ratio_bps:h(o)})})},ot=rt;function nt(e,t){return U(e,"upgrade",[w(t.wasmHash)])}function it(e,t){return U(e,"migrate",[h(t.newVersion)])}function ut(e){return U(e,"pause",[])}function at(e){return U(e,"unpause",[])}function st(e,t){return U(e,"grant_role",[c(t.account),S(t.role)])}function lt(e,t){return U(e,"revoke_role",[c(t.account),S(t.role)])}function pt(e,t){return U(e,"transfer_ownership",[c(t.newOwner),h(t.liveUntilLedger)])}function dt(e){return U(e,"accept_ownership",[])}function ct(e,t){return U(e,"set_swap_aggregator",[c(t.aggregator)])}function ft(e,t){return U(e,"set_price_aggregator",[c(t.aggregator)])}const ht=ct;function gt(e,t){return U(e,"set_accumulator",[c(t.accumulator)])}function yt(e,t){return U(e,"set_position_limits",[je(t)])}function bt(e,t){return U(e,"approve_blend_pool",[c(t.pool)])}function St(e,t){return U(e,"revoke_blend_pool",[c(t.pool)])}const mt=bt,Tt=St;function wt(e,t){return U(e,"set_oracle",[Xe(t.key),rt(t.oracle)])}const vt=wt;function xt(e,t){const r=t.toleranceBps,o=t.upperRatioBps??1e4+r,n=t.lowerRatioBps??Math.max(1,Math.floor(1e8/o));return U(e,"set_tolerance",[Xe(t.key),k({lower_ratio_bps:h(n),upper_ratio_bps:h(o)})])}function At(e,t){return U(e,"set_spoke_asset_flags",[h(t.spokeId),x(t.hubId,t.asset),y(t.paused),y(t.frozen),y(t.noSeize)])}function Pt(e,t){return U(e,"set_oracle_sanity_bounds",[c(t.asset),f(t.minPriceWad),f(t.maxPriceWad)])}function qt(e,t){return U(e,"update_indexes",[c(e.caller),T(t.assets.map((e=>x(e.hubId,e.asset))))])}function kt(e,t){return U(e,"renew_account",[c(e.caller),g(t.accountNonce)])}function Et(e,t){return U(e,"create_liquidity_pool",[h(t.hubId),c(t.asset),Ve(t.params)])}function _t(e,t){return U(e,"upgrade_liquidity_pool_params",[x(t.hubId,t.asset),ze(t.params)])}function It(e,t){return U(e,"claim_revenue",[c(e.caller),T(t.assets.map((e=>x(e.hubId,e.asset))))])}function Rt(e,t){return U(e,"add_rewards",[c(e.caller),P(t.rewards)])}function Ot(e,t){return U(e,"update_account_threshold",[c(e.caller),y(t.hasRisks),T(t.accountNonces.map((e=>g(e))))])}const Bt="00".repeat(32),Mt=e=>{if("string"==typeof e)return w(e);const t=s.hp.from(e);if(32!==t.length)throw new Error(`Stellar governance builder: expected a 32-byte salt (got ${t.length} bytes)`);return a.xdr.ScVal.scvBytes(t)},Ut=(e,...t)=>T([S(e),...t]),Ct=e=>k({new_owner:c(e.newOwner),live_until_ledger:h(e.liveUntilLedger)}),Lt=e=>k({asset:c(e.asset),bonus:h(e.bonus),borrow_cap:f(e.borrowCap),can_borrow:y(e.canBorrow),can_collateral:y(e.canCollateral),frozen:y(e.frozen),hub_id:h(e.hubId),paused:y(e.paused),liquidation_fees:h(e.liquidationFees),ltv:h(e.ltv),no_seize:y(e.noSeize),spoke_id:h(e.spokeId),supply_cap:f(e.supplyCap),threshold:h(e.threshold)}),$t=e=>k({account:c(e.account),role:S(e.role)});function Nt(e,t,r){if(!e.governanceAddress)throw new Error("Stellar governanceAddress is required");const o=new a.Contract(e.governanceAddress),n=new a.Account(e.caller,e.sourceSequence);return{xdr:new a.TransactionBuilder(n,{fee:e.fee??a.BASE_FEE,networkPassphrase:u[e.network]}).addOperation(o.call(t,...r)).setTimeout(e.timeoutSeconds??300).build().toXDR()}}const Dt=(e,t,r)=>Nt(e,"propose",[c(e.caller),t,Mt(r)]),Gt=(e,t,r)=>Nt(e,"execute_self",[m(),t,Mt(r)]);function Wt(e,t,r){return Dt(e,Ut("SetSwapAggregator",c(t.aggregator)),r)}function Ft(e,t,r){return Dt(e,Ut("SetPriceAggregator",c(t.aggregator)),r)}const Ht=Wt;function zt(e,t,r){return Dt(e,Ut("SetAccumulator",c(t.accumulator)),r)}function Vt(e,t,r){return Dt(e,Ut("SetPositionLimits",je(t)),r)}function jt(e,t){return Dt(e,Ut("CreateHub"),t)}function Xt(e,t){return Dt(e,Ut("AddSpoke"),t)}function Kt(e,t,r){return Dt(e,Ut("RemoveSpoke",h(t.spokeId)),r)}function Zt(e,t,r){return Dt(e,Ut("AddAssetToSpoke",Lt(t)),r)}function Qt(e,t,r){return Dt(e,Ut("EditAssetInSpoke",Lt(t)),r)}function Yt(e,t,r){return Dt(e,Ut("RemoveAssetFromSpoke",k({hub_asset:x((o=t).hubId,o.asset),spoke_id:h(o.spokeId)})),r);var o}function Jt(e,t,r){return Dt(e,Ut("SetSpokeLiquidationCurve",k({hf_for_max_bonus_wad:f((o=t).hfForMaxBonusWad),liquidation_bonus_factor_bps:h(o.liquidationBonusFactorBps),spoke_id:h(o.spokeId),target_hf_wad:f(o.targetHfWad)})),r);var o}function er(e,t,r){return Dt(e,Ut("SetPositionManager",c(t.manager),y(t.isActive)),r)}function tr(e,t,r){return Dt(e,Ut("SetMinBorrowCollateralUsd",f(t.floorWad)),r)}function rr(e,t,r){return Dt(e,Ut("ApproveToken",c(t.token)),r)}function or(e,t,r){return Dt(e,Ut("RevokeToken",c(t.token)),r)}function nr(e,t,r){return Dt(e,Ut("ApproveBlendPool",c(t.pool)),r)}function ir(e,t,r){return Dt(e,Ut("RevokeBlendPool",c(t.pool)),r)}function ur(e,t,r){return Dt(e,Ut("CreateLiquidityPool",k({asset:c((o=t).asset),hub_id:h(o.hubId),params:Ve(o.params)})),r);var o}function ar(e,t,r){return Dt(e,Ut("UpgradeLiquidityPoolParams",k({hub_asset:x((o=t).hubId,o.asset),params:ze(o.params)})),r);var o}function sr(e,t,r){return Dt(e,Ut("DeployPool",w(t.wasmHash)),r)}function lr(e,t,r){return Dt(e,Ut("UpgradePool",w(t.wasmHash)),r)}function pr(e,t,r){return Dt(e,Ut("UpgradeController",w(t.wasmHash)),r)}function dr(e,t,r){return Dt(e,Ut("MigrateController",h(t.newVersion)),r)}function cr(e,t,r){return Dt(e,Ut("TransferCtrlOwnership",Ct(t)),r)}function fr(e,t,r){return Dt(e,Ut("ConfigureAssetOracle",k({key:Xe((o=t).key),oracle:rt(o.oracle)})),r);var o}const hr=fr;function gr(e,t,r){return Dt(e,Ut("EditOracleTolerance",k({key:Xe((o=t).key),tolerance:h(o.tolerance)})),r);var o}function yr(e,t,r){return Dt(e,Ut("UpgradeGov",w(t.wasmHash)),r)}function br(e,t,r){return Dt(e,Ut("UpdateGovDelay",h(t.newDelay)),r)}function Sr(e,t,r){return Dt(e,Ut("GrantGovRole",$t(t)),r)}function mr(e,t,r){return Dt(e,Ut("RevokeGovRole",$t(t)),r)}function Tr(e,t,r){return Dt(e,Ut("TransferGovOwnership",Ct(t)),r)}function wr(e,t){const r=T(t.argsXdr.map((e=>a.xdr.ScVal.fromXDR(e,"base64")))),o=Mt(t.predecessor??Bt);return Nt(e,"execute",[m(),c(t.target),S(t.functionName),r,o,Mt(t.salt)])}function vr(e,t,r){return Gt(e,Ut("UpgradeGov",w(t.wasmHash)),r)}function xr(e,t,r){return Gt(e,Ut("UpdateGovDelay",h(t.newDelay)),r)}function Ar(e,t,r){return Gt(e,Ut("GrantGovRole",$t(t)),r)}function Pr(e,t,r){return Gt(e,Ut("RevokeGovRole",$t(t)),r)}function qr(e,t,r){return Gt(e,Ut("TransferGovOwnership",Ct(t)),r)}const kr=e=>T(e.map(c));function Er(e,t,r){return Nt(e,"propose_canceller_reset",[kr(t.newCancellers),Mt(r)])}function _r(e,t,r){return Nt(e,"execute_canceller_reset",[v(t.executor,c),kr(t.newCancellers),Mt(r)])}function Ir(e,t){return Nt(e,"set_spoke_asset_flags",[c(e.caller),h(t.spokeId),x(t.hubId,t.asset),y(t.paused),y(t.frozen),y(t.noSeize)])}function Rr(e,t){return Nt(e,"set_oracle_sanity_bounds",[c(e.caller),c(t.asset),f(t.minPriceWad),f(t.maxPriceWad)])}function Or(e){return Nt(e,"create_hub",[c(e.caller)])}function Br(e){return Nt(e,"add_spoke",[c(e.caller)])}function Mr(e,t){return Nt(e,"revoke_role_immediate",[c(t.account),S(t.role)])}function Ur(e){return Nt(e,"pause",[c(e.caller)])}function Cr(e,t){return Dt(e,Ut("Unpause"),t)}const Lr=e=>e.toXDR("base64"),$r=e=>a.xdr.ScVal.fromXDR(e,"base64"),Nr=e=>e.map((e=>String((0,a.scValToNative)($r(e))))).join(":"),Dr=e=>"bigint"==typeof e||"number"==typeof e?e.toString():String(e),Gr=e=>Number(e),Wr=e=>String(e),Fr=e=>e instanceof Uint8Array?s.hp.from(e).toString("hex"):s.hp.isBuffer(e)?e.toString("hex"):String(e),Hr=["None","Multiply","Long","Short"],zr=["supply","borrow","withdraw","repay","liq_repay","liq_seize","multiply","param_upd","sw_debt_r","sw_col_wd","rp_col_wd","rp_col_r","close_wd","migrate","rp_col_net","liq_credit"],Vr=e=>Array.isArray(e)?e:[],jr=(e,t)=>{const r="Borrow"===t;return{action:(o=e[0],zr[Gr(o)]??Dr(o)),positionType:t,hubId:Gr(e[1]),asset:Wr(e[2]),scaledAmountRay:Dr(e[3]),indexRay:Dr(e[4]),amount:Dr(e[5]),liquidationThresholdBps:r?void 0:Gr(e[6]),liquidationBonusBps:r?void 0:Gr(e[7]),loanToValueBps:r?void 0:Gr(e[8]),liquidationFeesBps:r?void 0:Gr(e[9])};var o},Xr=e=>{return{owner:Wr(e[0]),spokeId:Gr(e[1]),mode:(t=e[2],Hr[Gr(t)]??"None")};var t},Kr=e=>Array.isArray(e)?e[1]:void 0,Zr=e=>{const t=(r=e,Array.isArray(r)?Wr(r[0]):Wr(r));var r;if("Token"===t)return{Token:Wr(Kr(e))};if("Ref"===t)return{Ref:Wr(Kr(e))};if(e&&"object"==typeof e&&!Array.isArray(e)){const t=e;if(void 0!==t.Token)return{Token:Wr(t.Token)};if(void 0!==t.Ref)return{Ref:Wr(t.Ref)}}return{Token:Wr(e)}},Qr=e=>{const t=e.tolerance??{};return{assetDecimals:Gr(e.asset_decimals),maxPriceStaleSeconds:Gr(e.max_price_stale_seconds),sources:Vr(e.sources).map((e=>e)),tolerance:{upperRatio:Gr(t.upper_ratio_bps),lowerRatio:Gr(t.lower_ratio_bps)},independence:e.independence,minSanityPriceWad:Dr(e.min_sanity_price_wad),maxSanityPriceWad:Dr(e.max_sanity_price_wad)}},Yr={"market:create":e=>({topic:"market:create",data:{hubId:Gr(e.hub_id),baseAsset:Wr(e.base_asset),maxBorrowRate:Dr(e.max_borrow_rate),baseBorrowRate:Dr(e.base_borrow_rate),slope1:Dr(e.slope1),slope2:Dr(e.slope2),slope3:Dr(e.slope3),midUtilization:Dr(e.mid_utilization),optimalUtilization:Dr(e.optimal_utilization),maxUtilization:Dr(e.max_utilization),reserveFactor:Gr(e.reserve_factor),marketAddress:Wr(e.market_address)}}),"market:params_update":e=>({topic:"market:params_update",data:{asset:Wr(e.asset),maxBorrowRateRay:Dr(e.max_borrow_rate),baseBorrowRateRay:Dr(e.base_borrow_rate),slope1Ray:Dr(e.slope1),slope2Ray:Dr(e.slope2),slope3Ray:Dr(e.slope3),midUtilizationRay:Dr(e.mid_utilization),optimalUtilizationRay:Dr(e.optimal_utilization),maxUtilizationRay:Dr(e.max_utilization),reserveFactorBps:Gr(e.reserve_factor)}}),"market:batch_state_update":e=>({topic:"market:batch_state_update",data:{updates:Vr(e).map((e=>{return t=Vr(e),{hubId:Gr(t[0]),asset:Wr(t[1]),timestamp:Gr(t[2]),supplyIndexRay:Dr(t[3]),borrowIndexRay:Dr(t[4]),cash:Dr(t[5]),suppliedRay:Dr(t[6]),borrowedRay:Dr(t[7]),revenueRay:Dr(t[8])};var t}))}}),"market:batch_params_update":e=>({topic:"market:batch_params_update",data:{updates:Vr(e).map((e=>{const t=e;return{hubId:Gr(t.hub_id),asset:Wr(t.asset),params:(r=t.params,{maxBorrowRateRay:Dr(r.max_borrow_rate),baseBorrowRateRay:Dr(r.base_borrow_rate),slope1Ray:Dr(r.slope1),slope2Ray:Dr(r.slope2),slope3Ray:Dr(r.slope3),midUtilizationRay:Dr(r.mid_utilization),optimalUtilizationRay:Dr(r.optimal_utilization),maxUtilizationRay:Dr(r.max_utilization),reserveFactorBps:Gr(r.reserve_factor),isFlashloanable:Boolean(r.is_flashloanable),flashloanFeeBps:Gr(r.flashloan_fee),assetId:Wr(r.asset_id),assetDecimals:Gr(r.asset_decimals)})};var r}))}}),"position:batch_update":e=>{const t=Vr(e);return{topic:"position:batch_update",data:{accountId:Dr(t[0]),accountAttributes:Xr(Vr(t[1])),updates:[...Vr(t[2]).map((e=>jr(Vr(e),"Deposit"))),...Vr(t[3]).map((e=>jr(Vr(e),"Borrow")))]}}},"position:flash_loan":e=>({topic:"position:flash_loan",data:{hubId:Gr(e.hub_id),asset:Wr(e.asset),receiver:Wr(e.receiver),caller:Wr(e.caller),amount:Dr(e.amount),fee:Dr(e.fee)}}),"config:asset_oracle":e=>({topic:"config:asset_oracle",data:{key:Zr(e.key),oracle:Qr(e.oracle)}}),"config:oracle":e=>({topic:"config:oracle",data:{asset:Wr(e.asset),oracle:Qr(e.config??e.oracle)}}),"position:liquidation":e=>({topic:"position:liquidation",data:{liquidator:Wr(e.liquidator),accountId:Dr(e.account_id),repaidUsdWad:Dr(e.repaid_usd_wad),bonusBps:Dr(e.bonus_bps)}}),"debt:bad_debt":e=>({topic:"debt:bad_debt",data:{accountId:Dr(e.account_id),totalBorrowUsdWad:Dr(e.total_borrow_usd_wad),totalCollateralUsdWad:Dr(e.total_collateral_usd_wad)}}),"strategy:initial_payment":e=>({topic:"strategy:initial_payment",data:{token:Wr(e.token),amount:Dr(e.amount),usdValueWad:Dr(e.usd_value_wad),accountId:Dr(e.account_id)}}),"strategy:fee":e=>({topic:"strategy:fee",data:{hubId:Gr(e.hub_id),asset:Wr(e.asset),amount:Dr(e.amount),fee:Dr(e.fee),amountSent:Dr(e.amount_sent)}}),"config:approve_blend_pool":e=>({topic:"config:approve_blend_pool",data:{pool:Wr(e.pool??e.blend_pool??e.token),approved:Boolean(e.approved??e.is_approved??!0)}}),"config:approve_token":e=>({topic:"config:approve_token",data:{wasmHash:Fr(e.wasm_hash??e.pool),approved:Boolean(e.approved)}}),"config:swap_aggregator":e=>({topic:"config:swap_aggregator",data:{aggregator:Wr(e.aggregator??e.swap_aggregator)}}),"config:price_aggregator":e=>({topic:"config:price_aggregator",data:{aggregator:Wr(e.aggregator??e.price_aggregator)}}),"config:aggregator":e=>({topic:"config:aggregator",data:{aggregator:Wr(e.aggregator)}}),"config:accumulator":e=>({topic:"config:accumulator",data:{accumulator:Wr(e.accumulator)}}),"config:pool_template":e=>({topic:"config:pool_template",data:{wasmHash:Fr(e.wasm_hash)}}),"config:position_limits":e=>({topic:"config:position_limits",data:{maxSupplyPositions:Gr(e.max_supply_positions),maxBorrowPositions:Gr(e.max_borrow_positions)}}),"config:min_borrow_collateral":e=>({topic:"config:min_borrow_collateral",data:{minBorrowCollateralUsdWad:Dr(e.min_borrow_collateral_usd_wad??e.floor_wad??e.value)}}),"config:oracle_disabled":e=>({topic:"config:oracle_disabled",data:{asset:Wr(e.asset)}}),"config:spoke":e=>{const t=e.spoke;return{topic:"config:spoke",data:{spokeId:Gr(t.spoke_id),isDeprecated:Boolean(t.is_deprecated),liquidationTargetHfWad:Dr(t.liquidation_target_hf_wad),healthFactorForMaxBonusWad:Dr(t.hf_for_max_bonus_wad),liquidationBonusFactorBps:Gr(t.liquidation_bonus_factor_bps)}}}},Jr=Object.freeze(Object.keys(Yr));function eo(e,t){const r=Nr(e),o=Yr[r];return o?o((0,a.scValToNative)($r(t))):null}const to=1e4;function ro(e,t){return`${e}-${BigInt(t).toString(10)}`}function oo(e){const t=e.split("-");return t.length>=2&&parseInt(t[1],10)||0}function no(e,t=0){return e*to+t}function io(e){switch(e){case"liq_repay":return"lendingLiquidateRepayDebt";case"liq_seize":return"lendingLiquidateSeizeCollateral";case"liq_credit":default:return"lendingUpdateAccountPosition";case"param_upd":return"lendingUpdateAccountParameters"}}const uo=(e,t,r)=>{const o=new URL(t,e.endsWith("/")?e:`${e}/`);if(r)for(const[e,t]of Object.entries(r))void 0!==t&&o.searchParams.set(e,String(t));return o.toString()};async function ao(e,t){if(!t.baseUrl)throw new Error("Stellar quote baseUrl is required");if(null==e.amountIn==(null==e.amountOut))throw new Error("getStellarAggregatorQuote: exactly one of `amountIn` or `amountOut` must be provided");const r=uo(t.baseUrl,"api/v1/quote",{from:e.from,to:e.to,amountIn:e.amountIn,amountOut:e.amountOut,maxHops:e.maxHops,maxSplits:e.maxSplits,slippage:e.slippage,includePaths:e.includePaths,sender:e.sender,router:e.router,referralId:e.referralId,platform:e.platform,fresh:e.fresh}),o=await fetch(r,t.fetchOptions);if(!o.ok){const e=await o.text().catch((()=>""));throw new Error(`Stellar quote server responded ${o.status} ${o.statusText} for ${r} — ${e}`)}return await o.json()}async function so(e){if(!e.baseUrl)throw new Error("Stellar quote baseUrl is required");const t=uo(e.baseUrl,"api/v1/tokens"),r=await fetch(t,e.fetchOptions);if(!r.ok){const e=await r.text().catch((()=>""));throw new Error(`Stellar quote server responded ${r.status} ${r.statusText} for ${t} — ${e}`)}return await r.json()}const lo=e=>_(e).toXDR("base64");function po(e,t){if(!e.routerAddress)throw new Error("Stellar aggregator routerAddress is required");const r=new a.Contract(e.routerAddress),o=new a.Account(e.caller,e.sourceSequence),n=B(((e,t)=>(e=>Boolean(e&&"object"==typeof e&&!(e instanceof Uint8Array)&&"paths"in e))(e)&&void 0===e.referralId?{...e,referralId:t??0}:e)(t,e.referralId));return{xdr:new a.TransactionBuilder(o,{fee:e.fee??a.BASE_FEE,networkPassphrase:u[e.network]}).addOperation(r.call("execute_strategy",c(e.caller),f(e.totalIn),n)).setTimeout(e.timeoutSeconds??300).build().toXDR()}}function co(e,t){return po(e,t)}function fo(e,t={}){if("string"!=typeof e.amountOutMin)throw new Error("mapQuoteResponseToStrategyPayload: quote response is missing `amountOutMin`. Pass `slippage` when fetching the quote.");return{paths:e.paths?e.paths.map((e=>({hops:e.swaps.map(yo),splitPpm:e.splitPpm}))):[{hops:e.hops.map(yo),splitPpm:1e6}],referralId:t.referralId??0,tokenIn:e.from,tokenOut:e.to,totalMinOut:e.amountOutMin}}function ho(e,t={}){const r=e;return"string"==typeof r.routeXdr&&r.routeXdr.length>0?{routeXdr:r.routeXdr}:fo(e,t)}const go=fo,yo=e=>({amountOut:e.amountOut,pool:e.address,tokenIn:e.from,tokenOut:e.to,venue:e.dex});function bo(e,t){const r=t instanceof Error?t.message:String(t);return new Error(`[xoxno-invoked:${e}] ${r}`)}async function So(e,t,r){const o=a.TransactionBuilder.fromXDR(t,r?.network?u[r.network]:"");try{return(await e.prepareTransaction(o)).toXDR()}catch(e){if(r?.invokedContractId)throw bo(r.invokedContractId,e);throw e}}async function mo(e,t,r){return So(e,t.xdr,r)}function To(e){if(e<=0||e>4)throw new Error(`Invalid PositionMode ${e} for Stellar — expected 1 (Normal) through 4 (Short). "None" (0) has no Stellar equivalent.`);return e-1}function wo(e,t){return new Uint8Array(0)}const vo=e=>{const t=e.startsWith("0x")?e.slice(2):e;if(t.length%2!=0)throw new Error("buildStellarCctpForwardTx: hex input must have even length");return s.hp.from(t,"hex")};function xo(e){const t=new a.Account(e.caller,e.sourceSequence),r=new a.Contract(e.forwarderAddress).call("mint_and_forward",a.xdr.ScVal.scvBytes(vo(e.message)),a.xdr.ScVal.scvBytes(vo(e.attestation)));return{xdr:new a.TransactionBuilder(t,{fee:e.fee??"10000000",networkPassphrase:u[e.network]}).addOperation(r).setTimeout(e.timeoutSeconds??120).build().toXDR()}}const Ao={1:{name:"AssetNotSupported",message:"This asset is not supported by the protocol."},2:{name:"AssetAlreadySupported",message:"This asset is already supported."},3:{name:"InvalidTicker",message:"Invalid asset ticker."},6:{name:"InvalidAsset",message:"Invalid asset address."},10:{name:"InvalidWasmHash",message:"The WASM hash is empty or invalid."},11:{name:"InvalidExchangeSrc",message:"The oracle configuration is invalid."},12:{name:"PairNotActive",message:"No oracle is configured for this asset."},32:{name:"OwnerNotSet",message:"The contract owner has not been set."},39:{name:"InvalidTimelockDelay",message:"The timelock delay is out of the allowed range."},41:{name:"InvalidRole",message:"The caller does not hold the required role."},43:{name:"HubNotActive",message:"This hub is not active."},44:{name:"NotAuthorized",message:"The caller is not authorized to perform this action."},46:{name:"OperationNotCancellable",message:"This governance operation cannot be cancelled."},113:{name:"InvalidLiqThreshold",message:"LTV, liquidation threshold, or bonus is out of bounds."},116:{name:"InvalidBorrowParams",message:"Supply or borrow cap configuration is invalid."},117:{name:"InvalidUtilRange",message:"Interest-rate utilization breakpoints are invalid."},132:{name:"AssetDecimalsTooHigh",message:"Asset decimals exceed the protocol maximum (27)."},300:{name:"SpokeNotFound",message:"This spoke does not exist."},301:{name:"SpokeDeprecated",message:"This spoke has been deprecated."},307:{name:"AssetNotInSpoke",message:"This asset is not listed on the spoke."},308:{name:"AssetAlreadyInSpoke",message:"This asset is already listed in the spoke."},309:{name:"SpokeAssetInUse",message:"This spoke asset still has live positions; drain usage before removal."},315:{name:"SpokeAssetPaused",message:"This spoke asset is paused."},316:{name:"SpokeAssetFrozen",message:"This spoke asset is frozen."},317:{name:"SpokeAssetFlagRelaxation",message:"Guardian flag updates may only tighten; clearing a flag requires the timelocked edit."},318:{name:"SpokeAssetSeizureHalted",message:"Liquidation seizure is halted for this spoke asset."},220:{name:"InvalidOracleBase",message:"The oracle quote asset/market is missing or invalid."},221:{name:"InvalidOracleDecimals",message:"The oracle decimals value is invalid."},224:{name:"InvalidSanityBounds",message:"Oracle sanity bounds are invalid (require 0 < min < max)."},225:{name:"OracleCycleDetected",message:"A cycle was detected in the oracle quote chain."}};function Po(e){const t=e.match(/Error\(Contract,\s*#(\d+)\)/);if(!t)return null;const r=Number(t[1]),o=Ao[r];return o?{code:r,...o}:null}}},t={};function r(o){var n=t[o];if(void 0!==n)return n.exports;var i=t[o]={exports:{}};return e[o](i,i.exports,r),i.exports}r.d=(e,t)=>{for(var o in t)r.o(t,o)&&!r.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};(()=>{"use strict";r.r(o),r.d(o,{Chain:()=>u,DEFAULT_REQUEST_TIMEOUT_MS:()=>i,STELLAR_GOVERNANCE_ZERO_PREDECESSOR:()=>g.STELLAR_GOVERNANCE_ZERO_PREDECESSOR,STELLAR_LENDING_TOPICS:()=>g.STELLAR_LENDING_TOPICS,STELLAR_NETWORKS:()=>g.STELLAR_NETWORKS,STELLAR_NETWORK_PASSPHRASE:()=>g.STELLAR_NETWORK_PASSPHRASE,SYNTHETIC_EVENT_ORDER_STRIDE:()=>g.SYNTHETIC_EVENT_ORDER_STRIDE,XOXNOClient:()=>a,buildSameTokenRepaySwapSteps:()=>g.buildSameTokenRepaySwapSteps,buildSdk:()=>m,buildStellarAcceptOwnershipTx:()=>g.buildStellarAcceptOwnershipTx,buildStellarAddRewardsTx:()=>g.buildStellarAddRewardsTx,buildStellarApproveBlendPoolTx:()=>g.buildStellarApproveBlendPoolTx,buildStellarApproveTokenTx:()=>g.buildStellarApproveTokenTx,buildStellarBatchSwapTx:()=>g.buildStellarBatchSwapTx,buildStellarBorrowBatchTx:()=>g.buildStellarBorrowBatchTx,buildStellarBorrowTx:()=>g.buildStellarBorrowTx,buildStellarCctpForwardTx:()=>g.buildStellarCctpForwardTx,buildStellarClaimRevenueTx:()=>g.buildStellarClaimRevenueTx,buildStellarCreateLiquidityPoolTx:()=>g.buildStellarCreateLiquidityPoolTx,buildStellarExecuteCancellerResetTx:()=>g.buildStellarExecuteCancellerResetTx,buildStellarExecuteStrategyTx:()=>g.buildStellarExecuteStrategyTx,buildStellarFlashLoanTx:()=>g.buildStellarFlashLoanTx,buildStellarGovernanceAddSpokeImmediateTx:()=>g.buildStellarGovernanceAddSpokeImmediateTx,buildStellarGovernanceCreateHubImmediateTx:()=>g.buildStellarGovernanceCreateHubImmediateTx,buildStellarGovernanceExecuteGovernanceUpgradeTx:()=>g.buildStellarGovernanceExecuteGovernanceUpgradeTx,buildStellarGovernanceExecuteGrantGovernanceRoleTx:()=>g.buildStellarGovernanceExecuteGrantGovernanceRoleTx,buildStellarGovernanceExecuteRevokeGovernanceRoleTx:()=>g.buildStellarGovernanceExecuteRevokeGovernanceRoleTx,buildStellarGovernanceExecuteTransferGovOwnTx:()=>g.buildStellarGovernanceExecuteTransferGovOwnTx,buildStellarGovernanceExecuteTx:()=>g.buildStellarGovernanceExecuteTx,buildStellarGovernanceExecuteUpdateDelayTx:()=>g.buildStellarGovernanceExecuteUpdateDelayTx,buildStellarGovernancePauseTx:()=>g.buildStellarGovernancePauseTx,buildStellarGovernanceRevokeRoleImmediateTx:()=>g.buildStellarGovernanceRevokeRoleImmediateTx,buildStellarGovernanceSetOracleSanityBoundsImmediateTx:()=>g.buildStellarGovernanceSetOracleSanityBoundsImmediateTx,buildStellarGovernanceSetSpokeAssetFlagsImmediateTx:()=>g.buildStellarGovernanceSetSpokeAssetFlagsImmediateTx,buildStellarGrantRoleTx:()=>g.buildStellarGrantRoleTx,buildStellarLendingIdentifier:()=>g.buildStellarLendingIdentifier,buildStellarLiquidateTx:()=>g.buildStellarLiquidateTx,buildStellarMigrateFromBlendTx:()=>g.buildStellarMigrateFromBlendTx,buildStellarMigrateTx:()=>g.buildStellarMigrateTx,buildStellarMultiplyTx:()=>g.buildStellarMultiplyTx,buildStellarPauseTx:()=>g.buildStellarPauseTx,buildStellarProposeAddAssetToSpokeTx:()=>g.buildStellarProposeAddAssetToSpokeTx,buildStellarProposeAddSpokeTx:()=>g.buildStellarProposeAddSpokeTx,buildStellarProposeApproveBlendPoolTx:()=>g.buildStellarProposeApproveBlendPoolTx,buildStellarProposeApproveTokenTx:()=>g.buildStellarProposeApproveTokenTx,buildStellarProposeCancellerResetTx:()=>g.buildStellarProposeCancellerResetTx,buildStellarProposeConfigureAssetOracleTx:()=>g.buildStellarProposeConfigureAssetOracleTx,buildStellarProposeConfigureMarketOracleTx:()=>g.buildStellarProposeConfigureMarketOracleTx,buildStellarProposeCreateHubTx:()=>g.buildStellarProposeCreateHubTx,buildStellarProposeCreateLiquidityPoolTx:()=>g.buildStellarProposeCreateLiquidityPoolTx,buildStellarProposeDeployPoolTx:()=>g.buildStellarProposeDeployPoolTx,buildStellarProposeEditAssetInSpokeTx:()=>g.buildStellarProposeEditAssetInSpokeTx,buildStellarProposeEditOracleToleranceTx:()=>g.buildStellarProposeEditOracleToleranceTx,buildStellarProposeGovernanceUpgradeTx:()=>g.buildStellarProposeGovernanceUpgradeTx,buildStellarProposeGrantGovernanceRoleTx:()=>g.buildStellarProposeGrantGovernanceRoleTx,buildStellarProposeMigrateControllerTx:()=>g.buildStellarProposeMigrateControllerTx,buildStellarProposeRemoveAssetFromSpokeTx:()=>g.buildStellarProposeRemoveAssetFromSpokeTx,buildStellarProposeRemoveSpokeTx:()=>g.buildStellarProposeRemoveSpokeTx,buildStellarProposeRevokeBlendPoolTx:()=>g.buildStellarProposeRevokeBlendPoolTx,buildStellarProposeRevokeGovernanceRoleTx:()=>g.buildStellarProposeRevokeGovernanceRoleTx,buildStellarProposeRevokeTokenTx:()=>g.buildStellarProposeRevokeTokenTx,buildStellarProposeSetAccumulatorTx:()=>g.buildStellarProposeSetAccumulatorTx,buildStellarProposeSetAggregatorTx:()=>g.buildStellarProposeSetAggregatorTx,buildStellarProposeSetMinBorrowCollatTx:()=>g.buildStellarProposeSetMinBorrowCollatTx,buildStellarProposeSetPositionLimitsTx:()=>g.buildStellarProposeSetPositionLimitsTx,buildStellarProposeSetPositionManagerTx:()=>g.buildStellarProposeSetPositionManagerTx,buildStellarProposeSetPriceAggregatorTx:()=>g.buildStellarProposeSetPriceAggregatorTx,buildStellarProposeSetSpokeLiquidationCurveTx:()=>g.buildStellarProposeSetSpokeLiquidationCurveTx,buildStellarProposeSetSwapAggregatorTx:()=>g.buildStellarProposeSetSwapAggregatorTx,buildStellarProposeTransferCtrlOwnershipTx:()=>g.buildStellarProposeTransferCtrlOwnershipTx,buildStellarProposeTransferGovOwnTx:()=>g.buildStellarProposeTransferGovOwnTx,buildStellarProposeUnpauseTx:()=>g.buildStellarProposeUnpauseTx,buildStellarProposeUpdateDelayTx:()=>g.buildStellarProposeUpdateDelayTx,buildStellarProposeUpgradeControllerTx:()=>g.buildStellarProposeUpgradeControllerTx,buildStellarProposeUpgradePoolParamsTx:()=>g.buildStellarProposeUpgradePoolParamsTx,buildStellarProposeUpgradePoolTx:()=>g.buildStellarProposeUpgradePoolTx,buildStellarRenewAccountTx:()=>g.buildStellarRenewAccountTx,buildStellarRepayBatchTx:()=>g.buildStellarRepayBatchTx,buildStellarRepayDebtWithCollateralTx:()=>g.buildStellarRepayDebtWithCollateralTx,buildStellarRepayTx:()=>g.buildStellarRepayTx,buildStellarRevokeBlendPoolTx:()=>g.buildStellarRevokeBlendPoolTx,buildStellarRevokeRoleTx:()=>g.buildStellarRevokeRoleTx,buildStellarRevokeTokenTx:()=>g.buildStellarRevokeTokenTx,buildStellarSetAccumulatorTx:()=>g.buildStellarSetAccumulatorTx,buildStellarSetAggregatorTx:()=>g.buildStellarSetAggregatorTx,buildStellarSetMarketOracleConfigTx:()=>g.buildStellarSetMarketOracleConfigTx,buildStellarSetOracleSanityBoundsTx:()=>g.buildStellarSetOracleSanityBoundsTx,buildStellarSetOracleToleranceTx:()=>g.buildStellarSetOracleToleranceTx,buildStellarSetOracleTx:()=>g.buildStellarSetOracleTx,buildStellarSetPositionLimitsTx:()=>g.buildStellarSetPositionLimitsTx,buildStellarSetPriceAggregatorTx:()=>g.buildStellarSetPriceAggregatorTx,buildStellarSetSpokeAssetFlagsTx:()=>g.buildStellarSetSpokeAssetFlagsTx,buildStellarSetSwapAggregatorTx:()=>g.buildStellarSetSwapAggregatorTx,buildStellarSupplyBatchTx:()=>g.buildStellarSupplyBatchTx,buildStellarSupplyTx:()=>g.buildStellarSupplyTx,buildStellarSwapCollateralTx:()=>g.buildStellarSwapCollateralTx,buildStellarSwapDebtTx:()=>g.buildStellarSwapDebtTx,buildStellarTransferOwnershipTx:()=>g.buildStellarTransferOwnershipTx,buildStellarUnpauseTx:()=>g.buildStellarUnpauseTx,buildStellarUpdateAccountThresholdTx:()=>g.buildStellarUpdateAccountThresholdTx,buildStellarUpdateIndexesTx:()=>g.buildStellarUpdateIndexesTx,buildStellarUpgradeControllerTx:()=>g.buildStellarUpgradeControllerTx,buildStellarUpgradeLiquidityPoolParamsTx:()=>g.buildStellarUpgradeLiquidityPoolParamsTx,buildStellarWithdrawBatchTx:()=>g.buildStellarWithdrawBatchTx,buildStellarWithdrawTx:()=>g.buildStellarWithdrawTx,buildTx:()=>g.buildTx,decodeStellarLendingEvent:()=>g.decodeStellarLendingEvent,decodeStellarLiquidateReturn:()=>g.decodeStellarLiquidateReturn,encodeAssetOracle:()=>g.encodeAssetOracle,encodeInterestRateModel:()=>g.encodeInterestRateModel,encodeMarketOracleConfigInput:()=>g.encodeMarketOracleConfigInput,encodeMarketParamsRaw:()=>g.encodeMarketParamsRaw,encodePositionLimits:()=>g.encodePositionLimits,encodePriceKey:()=>g.encodePriceKey,encodeStrategyPayloadToRouteXdr:()=>g.encodeStrategyPayloadToRouteXdr,extractEventOrder:()=>g.extractEventOrder,getStellarAccountPositions:()=>g.getStellarAccountPositions,getStellarActiveUsersSeries:()=>g.getStellarActiveUsersSeries,getStellarAggregatorQuote:()=>g.getStellarAggregatorQuote,getStellarAsset:()=>g.getStellarAsset,getStellarAssetGraph:()=>g.getStellarAssetGraph,getStellarAssetMarkets:()=>g.getStellarAssetMarkets,getStellarAssetPage:()=>g.getStellarAssetPage,getStellarAssets:()=>g.getStellarAssets,getStellarCampaignLeaderboard:()=>g.getStellarCampaignLeaderboard,getStellarCampaignMe:()=>g.getStellarCampaignMe,getStellarDefiLlamaDimensions:()=>g.getStellarDefiLlamaDimensions,getStellarDeployment:()=>g.getStellarDeployment,getStellarDetailedMarkets:()=>g.getStellarDetailedMarkets,getStellarFeeRevenueSeries:()=>g.getStellarFeeRevenueSeries,getStellarGovernanceProposals:()=>g.getStellarGovernanceProposals,getStellarHolderDistribution:()=>g.getStellarHolderDistribution,getStellarHub:()=>g.getStellarHub,getStellarHubGraph:()=>g.getStellarHubGraph,getStellarHubHolders:()=>g.getStellarHubHolders,getStellarHubs:()=>g.getStellarHubs,getStellarLendingContext:()=>g.getStellarLendingContext,getStellarLendingLiveState:()=>g.getStellarLendingLiveState,getStellarLiquidationsLeaderboard:()=>g.getStellarLiquidationsLeaderboard,getStellarLiquidationsSeries:()=>g.getStellarLiquidationsSeries,getStellarParticipantCounts:()=>g.getStellarParticipantCounts,getStellarPnlByScope:()=>g.getStellarPnlByScope,getStellarPositionsLeaderboard:()=>g.getStellarPositionsLeaderboard,getStellarPositionsPnl:()=>g.getStellarPositionsPnl,getStellarQuoteTokens:()=>g.getStellarQuoteTokens,getStellarRateSpreadSeries:()=>g.getStellarRateSpreadSeries,getStellarReserve:()=>g.getStellarReserve,getStellarReserveGraph:()=>g.getStellarReserveGraph,getStellarReserveHolders:()=>g.getStellarReserveHolders,getStellarReserves:()=>g.getStellarReserves,getStellarRevenueSeries:()=>g.getStellarRevenueSeries,getStellarSpoke:()=>g.getStellarSpoke,getStellarSpokeGraph:()=>g.getStellarSpokeGraph,getStellarSpokeHolders:()=>g.getStellarSpokeHolders,getStellarSpokes:()=>g.getStellarSpokes,getStellarStatsHistory:()=>g.getStellarStatsHistory,getStellarUserActivity:()=>g.getStellarUserActivity,getStellarUserActivityPage:()=>g.getStellarUserActivityPage,getStellarUserHistory:()=>g.getStellarUserHistory,getStellarUserPositions:()=>g.getStellarUserPositions,getStellarVolumeSeries:()=>g.getStellarVolumeSeries,getStellarWalletBalance:()=>g.getStellarWalletBalance,isValidCollectionTicker:()=>s,isValidNftIdentifier:()=>l,mapQuoteResponseToAggregatorSwap:()=>g.mapQuoteResponseToAggregatorSwap,mapQuoteResponseToStrategyPayload:()=>g.mapQuoteResponseToStrategyPayload,mapQuoteResponseToStrategySwap:()=>g.mapQuoteResponseToStrategySwap,mapSorobanError:()=>g.mapSorobanError,mapStellarPositionActivityType:()=>g.mapStellarPositionActivityType,prepareStellarBuiltTx:()=>g.prepareStellarBuiltTx,prepareStellarTxXdr:()=>g.prepareStellarTxXdr,stellarLendingDispatchKey:()=>g.stellarLendingDispatchKey,stellarLendingRead:()=>g.stellarLendingRead,stellarNetworks:()=>g.stellarNetworks,syntheticEventOrder:()=>g.syntheticEventOrder,tagStellarInvokedContractError:()=>g.tagStellarInvokedContractError,toBase64Xdr:()=>g.toBase64Xdr,toStellarPositionMode:()=>g.toStellarPositionMode});const e="erd1qqqqqqqqqqqqqpgq705fxpfrjne0tl3ece0rrspykq88mynn4kxs2cg43s",t="erd1qqqqqqqqqqqqqpgqd9rvv2n378e27jcts8vfwynpx0gfl5ufz6hqhfy0u0",n="erd1qqqqqqqqqqqqqpgq8xwzu82v8ex3h4ayl5lsvxqxnhecpwyvwe0sf2qj4e",i=3e4;var u;!function(e){e.MAINNET="1",e.DEVNET="D"}(u||(u={}));class a{apiUrl;chain;init;config;constructor(r){if(!r?.apiUrl?.trim())throw new Error("XOXNOClient: apiUrl is required");const{chain:o=u.MAINNET,apiUrl:i,...a}=r;this.apiUrl=i.trim().replace(/\/$/,""),this.chain=o,this.init=a,this.config=o==u.MAINNET?{mediaUrl:"https://media.xoxno.com",gatewayUrl:"https://gateway.xoxno.com",XO_SC:"erd1qqqqqqqqqqqqqpgq6wegs2xkypfpync8mn2sa5cmpqjlvrhwz5nqgepyg8",FM_SC:e,DR_SC:t,KG_SC:n,Staking_SC:"erd1qqqqqqqqqqqqqpgqvpkd3g3uwludduv3797j54qt6c888wa59w2shntt6z",Manager_SC:"erd1qqqqqqqqqqqqqpgqg9fa0dmpn8fu3fnleeqn5zt8rl8mdqjkys5s2gtas7",P2P_SC:"erd1qqqqqqqqqqqqqpgq47y8hnct68v6asjv6gxem6h9rumn9frzah0skhxxt6"}:{mediaUrl:"https://devnet-media.xoxno.com",gatewayUrl:"https://devnet-gateway.xoxno.com",XO_SC:"erd1qqqqqqqqqqqqqpgql0dnz6n5hpuw8cptlt00khd0nn4ja8eadsfq2xrqw4",FM_SC:e,DR_SC:t,KG_SC:n,Staking_SC:"erd1qqqqqqqqqqqqqpgqsc5hnewwpep8qq0d7kjjzrquapuucrygah0s85zres",Manager_SC:"erd1qqqqqqqqqqqqqpgqluclyhfsa2uw7q9cjwd8knk989hg57u8ah0slq2nlr",P2P_SC:"erd1qqqqqqqqqqqqqpgqfja7ukpngrun78ueq583l0vd6aj4ekhrah0sa9wyrv"}}fetchWithTimeout=async(e,{params:t,...r}={})=>{const{next:o,cache:n,debug:u,timeout:a,...s}=this.init,{next:l,cache:p,debug:d,timeout:c,headers:f,method:h="GET",...g}=r,y=f?.Authorization,b="Bearer undefined"===y?void 0:y,S="GET"!==h&&"HEAD"!==h&&"PUT"!==h,m={...f,Referer:"https://xoxno.sdk","User-Agent":"XOXNO/1.0/SDK",...S?{"Content-Type":"application/json"}:{},...b?{Authorization:b}:{}},T=Object.entries(t??{}).filter((([,e])=>void 0!==e)).flatMap((([e,t])=>Array.isArray(t)?t.filter((e=>void 0!==e)).map((t=>`${e}=${encodeURIComponent(t)}`)):`${e}=${encodeURIComponent(t)}`)).join("&"),w=`${this.apiUrl}${e}${T.length?`?${T}`:""}`,{revalidate:v,...x}=o??{},{revalidate:A,...P}=l??{},q="GET"!==h||b?void 0:A??v,k="GET"!==h||b||q?void 0:p??n,E=g.body,_=c??a??(null==E?i:0),I=_>0?AbortSignal.timeout(_):void 0,R=g.signal??s.signal,O=I&&R?AbortSignal.any([R,I]):I??R,B={...s,...g,method:h,...Object.keys(m).length?{headers:m}:{},...O?{signal:O}:{},cache:k,next:{...x,...P,revalidate:q}};(d??u)&&console.debug("SDK fetch: ",w,B);const M=await fetch(w,B).catch((e=>{if(e instanceof Error&&!e.message.match(/^http(s?):\/\//))throw Object.assign(new Error(`${w}: ${e.message}`),{cause:e});throw e})),U=await M.text();if(!M.ok){let e;try{e=JSON.parse(U)}catch{e={message:U}}const t=[w,M.status,M.statusText,e.message].filter(Boolean).join(";;");throw new Error(t)}try{return JSON.parse(U)}catch{return U}}}const s=e=>{const t=/^0x[a-fA-F0-9]{1,64}-[a-zA-Z0-9_]+-[a-zA-Z0-9_]+(<.+>)?$/.test(decodeURIComponent(e)),r=/^[A-Z0-9]{3,10}-[a-z0-9]{6}$/.test(e),o=/^C[A-Z2-7]{55}$/.test(e);return t||r||o},l=e=>{const t=/^0x[a-fA-F0-9]{1,64}$/.test(e),r=/^[A-Za-z0-9]{3,10}-[A-Za-z0-9]{6}-[A-Za-z0-9]{2,7}(?:-\d+(?:-[A-Za-z0-9]+)?)?$/.test(e),o=/^C[A-Z2-7]{55}-\d+$/.test(e);return t||r||o};class p extends Error{constructor(e){super(`Invalid collection ticker: ${e}`)}}class d extends Error{constructor(e){super(`Invalid address: ${e}`)}}Error,Error;const c=e=>!!e&&(e.startsWith("erd1")&&62===e.length||/^0x[a-fA-F0-9]{40,64}$/.test(e)||/^[1-9A-HJ-NP-Za-km-z]{32,44}$/.test(e)||/^[GC][A-Z2-7]{55}$/.test(e)),f={"/liquid/xoxno/rate":{input:{},output:{}},"/liquid/xoxno/liquid-supply":{input:{},output:{}},"/liquid/xoxno/staked":{input:{},output:{}},"/user/login":{input:{},output:{},POST:{input:{},output:{},body:{}}},"/user/:address/network-account":{input:{},output:{}},"/user/:address/token-inventory":{input:{},output:{}},"/user/network-account":{input:{},output:{},POST:{input:{},output:{},body:{}}},"/user/me/profile":{input:{},output:{},securityMode:"requiredAny"},"/user/:address/profile":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/me":{input:{},output:{},securityMode:"requiredAny"},"/user/me/settings":{input:{},output:{},securityMode:"optionalAny"},"/user/me/settings/notification-preferences":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"optionalAny"}},"/user/me/settings/email":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"},DELETE:{input:{},output:{},body:{},securityMode:"requiredJwt"}},"/user/me/settings/phone":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/me/settings/billing":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/me/settings/verify-email":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/buy/signature":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/upload-picture":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/upload-banner":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/reset-picture":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/reset-banner":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:tag/creator/is-registered":{input:{},output:{}},"/user/:address/creator/profile":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/creator/upload-picture":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/creator/upload-banner":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/creator/reset-picture":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/creator/reset-banner":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/favorite/collections":{input:{},output:{}},"/user/favorite/:favoriteId":{input:{},output:{},securityMode:"requiredAny"},"/user/:address/follow":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/favorite/users":{input:{},output:{}},"/tokens":{input:{},output:{}},"/tokens/swap":{input:{},output:{}},"/stellar/tokens":{input:{},output:{}},"/tokens/restricted":{input:{},output:{}},"/tokens/usd-price":{input:{},output:{}},"/tokens/egld/fiat-price":{input:{},output:{}},"/tokens/xoxno/info":{input:{},output:{}},"/liquid/xoxno/stats":{input:{},output:{}},"/liquid/egld/stats":{input:{},output:{}},"/liquid/sui/stats":{input:{},output:{}},"/analytics/marketplace-unique-users":{input:{},output:{}},"/integrations/liquid-staking/multiversx/revenue":{input:{},output:{}},"/liquid/egld/rate":{input:{},output:{}},"/liquid/egld/liquid-supply":{input:{},output:{}},"/liquid/egld/staked":{input:{},output:{}},"/liquid/egld/pending-fees":{input:{},output:{}},"/liquid/egld/pending-undelegate":{input:{},output:{}},"/liquid/egld/pending-delegate":{input:{},output:{}},"/liquid/egld/execute-delegate":{input:{},output:{}},"/liquid/egld/execute-undelegate":{input:{},output:{}},"/liquid/egld/execute-undelegate-providers":{input:{},output:{}},"/liquid/egld/protocol-apr":{input:{},output:{}},"/liquid/egld/providers":{input:{},output:{}},"/user/:address/delegation":{input:{},output:{}},"/lending/market/:token/profile":{input:{},output:{}},"/lending/market/query":{input:{},output:{}},"/lending/governance/proposals":{input:{},output:{}},"/lending/governance/proposal/:id":{input:{},output:{}},"/user/lending/:address":{input:{},output:{}},"/lending/market/indexes":{input:{},output:{}},"/user/lending/position/:identifier":{input:{},output:{}},"/lending/pnl":{input:{},output:{}},"/user/lending/pnl/:address":{input:{},output:{}},"/user/lending/summary/:identifier":{input:{},output:{}},"/user/lending/image/:nonce":{input:{},output:{}},"/lending/market/emode-categories":{input:{},output:{}},"/lending/market/:token/emode-categories":{input:{},output:{}},"/lending/market/:token/analytics":{input:{},output:{}},"/lending/stats/history":{input:{},output:{}},"/lending/market/:token/average":{input:{},output:{}},"/lending/leaderboard":{input:{},output:{}},"/lending/leaderboard/liquidate":{input:{},output:{}},"/lending/leaderboard/clean-bad-debt":{input:{},output:{}},"/lending/stats":{input:{},output:{}},"/lending/market/prices":{input:{},output:{}},"/integrations/lending/stellar":{input:{},output:{}},"/integrations/lending/multiversx":{input:{},output:{}},"/integrations/lending/multiversx/revenue":{input:{},output:{}},"/integrations/lending/multiversx/liquidations":{input:{},output:{}},"/integrations/lending/multiversx/active-users":{input:{},output:{}},"/integrations/lending/stellar/history":{input:{},output:{}},"/integrations/lending/stellar/revenue":{input:{},output:{}},"/integrations/lending/stellar/active-users":{input:{},output:{}},"/nft/query":{input:{},output:{}},"/nft/:identifier/like":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/inventory-summary":{input:{},output:{}},"/user/:address/offers":{input:{},output:{}},"/nft/offer/query":{input:{},output:{}},"/nft/offer/:identifier":{input:{},output:{}},"/user/:address/favorite/nfts":{input:{},output:{}},"/collection/:collection/attributes":{input:{},output:{}},"/nft/:identifier/offers":{input:{},output:{}},"/collection/:collection/ranks":{input:{},output:{}},"/collection/:collection/listings":{input:{},output:{}},"/nft/pinned":{input:{},output:{}},"/nft/sign-withdraw":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/collection/:collection/sign-offer":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/collection/:collection/sign-mint":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/nft/:identifier":{input:{},output:{}},"/collection/:collection/profile":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/collection/:collection/floor-price":{input:{},output:{}},"/collection/floor-price":{input:{},output:{}},"/collection/pinned":{input:{},output:{}},"/collection/pinned-drops":{input:{},output:{}},"/collection/:collection/pinned-drops":{input:{},output:{}},"/collection/:collection/pinned":{input:{},output:{}},"/collection/:collection/follow":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/collection/query":{input:{},output:{}},"/collection/drops/query":{input:{},output:{}},"/collection/:collection/drop-info":{input:{},output:{},securityMode:"optionalAny"},"/collection/:creatorTag/:collectionTag/drop-info":{input:{},output:{},securityMode:"optionalAny"},"/collection/:collection/upload-picture":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/collection/:collection/upload-banner":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/collection/:collection/reset-picture":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/collection/:collection/reset-banner":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/collection/:collection/holders":{input:{},output:{}},"/collection/:collection/holders/export":{input:{},output:{}},"/collection/:collection/owner":{input:{},output:{}},"/collection/:collection/stats":{input:{},output:{}},"/collection/stats/query":{input:{},output:{}},"/collection/global-offer/query":{input:{},output:{}},"/user/:address/creator/listing":{input:{},output:{}},"/user/:address/creator/details":{input:{},output:{}},"/launchpad/:scAddress/shareholders/royalties":{input:{},output:{}},"/launchpad/:scAddress/shareholders/collection/:collectionTag":{input:{},output:{}},"/pool/:poolId/profile":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/pool/:poolId/whitelist":{input:{},output:{}},"/pool/:poolId/upload-picture":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/staking/available-pools":{input:{},output:{}},"/user/:address/staking/owned-collections":{input:{},output:{}},"/user/:address/staking/owned-pools":{input:{},output:{}},"/user/:address/staking/summary":{input:{},output:{}},"/user/:address/staking/creator":{input:{},output:{}},"/user/:address/staking/collection/:collection":{input:{},output:{}},"/user/:address/staking/pool/:poolId/nfts":{input:{},output:{}},"/collection/:collection/staking/summary":{input:{},output:{},securityMode:"optionalAny"},"/collection/:collection/staking/delegators":{input:{},output:{}},"/collection/staking/explore":{input:{},output:{}},"/user/:creatorTag/owned-services":{input:{},output:{}},"/search":{input:{},output:{}},"/user/search":{input:{},output:{}},"/collection/search":{input:{},output:{}},"/collection/drops/search":{input:{},output:{}},"/nft/search/query":{input:{},output:{}},"/lending/market-sc":{input:{},output:{}},"/lending/active-accounts":{input:{},output:{}},"/lending/account/:nonce/attributes":{input:{},output:{}},"/lending/account/:nonce/positions":{input:{},output:{}},"/lending/market/:token/price/egld":{input:{},output:{}},"/faucet":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/stellar-lending/assets":{input:{},output:{}},"/stellar-lending/context":{input:{},output:{}},"/stellar-lending/live-state":{input:{},output:{}},"/stellar-lending/markets/detailed":{input:{},output:{}},"/stellar-lending/hubs":{input:{},output:{}},"/stellar-lending/spokes":{input:{},output:{}},"/stellar-lending/reserves":{input:{},output:{}},"/stellar-lending/reserves/:spokeId/:hubId/:asset":{input:{},output:{}},"/stellar-lending/reserves/:spokeId/:hubId/:asset/holders":{input:{},output:{}},"/stellar-lending/hubs/:hubId/holders":{input:{},output:{}},"/stellar-lending/spokes/:spokeId/holders":{input:{},output:{}},"/stellar-lending/assets/:asset":{input:{},output:{}},"/stellar-lending/assets/:asset/page":{input:{},output:{}},"/stellar-lending/assets/:asset/markets":{input:{},output:{}},"/stellar-lending/hubs/:hubId":{input:{},output:{}},"/stellar-lending/spokes/:spokeId":{input:{},output:{}},"/stellar-lending/users/:owner/positions":{input:{},output:{}},"/stellar-lending/users/:owner/activity":{input:{},output:{}},"/stellar-lending/accounts/:accountId/positions":{input:{},output:{}},"/stellar-lending/governance/proposals":{input:{},output:{}},"/stellar-lending/assets/:asset/graph":{input:{},output:{}},"/stellar-lending/hubs/:hubId/graph":{input:{},output:{}},"/stellar-lending/spokes/:spokeId/graph":{input:{},output:{}},"/stellar-lending/reserves/:spokeId/:hubId/:asset/graph":{input:{},output:{}},"/stellar-lending/stats/history":{input:{},output:{}},"/stellar-lending/pnl":{input:{},output:{}},"/stellar-lending/campaign/leaderboard":{input:{},output:{}},"/stellar-lending/campaign/me":{input:{},output:{}},"/stellar-lending/positions":{input:{},output:{}},"/stellar-lending/users/:accountId/history":{input:{},output:{}},"/stellar-lending/pnl/scope":{input:{},output:{}},"/stellar-lending/revenue":{input:{},output:{}},"/stellar-lending/revenue/fees":{input:{},output:{}},"/stellar-lending/participants":{input:{},output:{}},"/stellar-lending/liquidations":{input:{},output:{}},"/stellar-lending/liquidations/leaderboard":{input:{},output:{}},"/stellar-lending/volume":{input:{},output:{}},"/stellar-lending/active-users":{input:{},output:{}},"/stellar-lending/distribution":{input:{},output:{}},"/stellar-lending/rate-spread":{input:{},output:{}},"/stellar-lending/defillama":{input:{},output:{}},"/user/notifications":{input:{},output:{},securityMode:"requiredAny"},"/user/notifications/unread-count":{input:{},output:{},securityMode:"requiredAny"},"/user/notifications/clear":{input:{},output:{},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/notifications/read":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/mobile/device/register":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredWeb2"}},"/mobile/device/:deviceId":{input:{},output:{},securityMode:"requiredWeb2",DELETE:{input:{},output:{},body:{},securityMode:"requiredWeb2"}},"/mobile/history":{input:{},output:{},securityMode:"requiredAny"},"/mobile/history/unread-count":{input:{},output:{},securityMode:"requiredAny"},"/mobile/history/:notificationId/read":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/mobile/history/read-all":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/mobile/history/clear-all":{input:{},output:{},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/mobile/history/clear-id/:notificationId":{input:{},output:{},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/eventNotifications/event/:eventId/update":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/eventNotifications/event/:eventId/reminder":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/eventNotifications/creator/marketing":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/eventNotifications/user/:userId/direct":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/stellar/challenge":{input:{},output:{}},"/user/native-token":{input:{},output:{}},"/user/web2":{input:{},output:{},securityMode:"requiredWeb2"},"/user/web2/session-cookie":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredWeb2"}},"/user/web2/wallet":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredWeb2"}},"/user/web2/wallet-switch":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredWeb2"}},"/user/web2/wallet-link":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredWeb2"}},"/user/web2/:index/wallet-link":{input:{},output:{},DELETE:{input:{},output:{},body:{},securityMode:"requiredWeb2"}},"/user/web2/shards":{input:{},output:{},securityMode:"requiredWeb2"},"/activity/query":{input:{},output:{}},"/activity/:identifier":{input:{},output:{}},"/analytics/volume":{input:{},output:{}},"/collection/:collection/analytics/volume":{input:{},output:{}},"/collections/analytics/volume":{input:{},output:{}},"/user/:address/analytics/volume":{input:{},output:{}},"/analytics/overview":{input:{},output:{}},"/user/stats":{input:{},output:{}},"/user/xoxno-drop":{input:{},output:{}},"/user/me/xoxno-drop":{input:{},output:{},securityMode:"requiredAny"},"/transactions/:txHash":{input:{},output:{}},"/transactions/:txHash/status":{input:{},output:{}},"/transaction/cost":{input:{},output:{},POST:{input:{},output:{},body:{}}},"/transactions":{input:{},output:{},POST:{input:{},output:{},body:{}}},"/transactions/batch":{input:{},output:{},POST:{input:{},output:{},body:{}}},"/user/chat/message":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/chat/conversation":{input:{},output:{},securityMode:"requiredAny"},"/user/chat/conversation/:conversationId":{input:{},output:{},securityMode:"requiredAny",DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/chat/conversation-summary":{input:{},output:{},securityMode:"requiredAny"},"/user/chat/conversation/:conversationId/message/:messageId":{input:{},output:{},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/chat/block":{input:{},output:{},securityMode:"requiredAny"},"/user/chat/block/:address":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/chat/token":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/hatom/user/:address":{input:{},output:{}},"/countries":{input:{},output:{}},"/event":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId":{input:{},output:{},securityMode:"optionalAny",PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/profile/query":{input:{},output:{}},"/event/:eventId/profile":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/background":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/description":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/description/image":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/description/image/:imageId":{input:{},output:{},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/register":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/ticket":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/ticket/:ticketId":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"},POST:{input:{},output:{},body:{}}},"/event/:eventId/stage":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/stage/:stageId":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/calculate-prices":{input:{},output:{},POST:{input:{},output:{},body:{}}},"/event/:eventId/validate-discount":{input:{},output:{},POST:{input:{},output:{},body:{}}},"/user/:address/creator/events":{input:{},output:{},securityMode:"optionalAny"},"/event/:eventId/invite":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/invite/query":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/invite/:inviteId":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/voucher/query":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/questions":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/question":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/question/:questionId":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/guest/query":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/guest/:address":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/guest-export":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/role":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"},securityMode:"requiredAny"},"/event/:eventId/role/:roleId":{input:{},output:{},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/guest":{input:{},output:{},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/roleOf/:address":{input:{},output:{},securityMode:"requiredAny"},"/user/me/event":{input:{},output:{},securityMode:"requiredAny"},"/user/me/events/past":{input:{},output:{},securityMode:"requiredAny"},"/user/me/events/hosted":{input:{},output:{},securityMode:"requiredAny"},"/user/me/events/upcoming":{input:{},output:{},securityMode:"requiredAny"},"/user/me/event/badge":{input:{},output:{},securityMode:"requiredAny"},"/user/me/event/badge/payload":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/scan":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/voucher":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/voucher/:voucherCode":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/manual-check-in":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/answered-questions/:address":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/guest/approve":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/google-pass/:address":{input:{},output:{}},"/event/profile/location":{input:{},output:{}},"/event/:eventId/referral-config":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/referral-config/:configId":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/referral-configs":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/referral":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/referral/:referralCode":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/referrals":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/referrals/self-serviced":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/notify-attendees":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/notify/global-broadcast":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/blend/:address":{input:{},output:{}},"/stellar/aggregator/quote":{input:{},output:{}},"/perp/exchange/acceptTerms":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/perp/exchange/sendAsset":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/perp/exchange/sendExternalAsset":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/perp/exchange/deposit":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/perp/exchange/withdraw":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/perp/exchange/order":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/tradingview/bars/:symbol":{input:{},output:{}},"/tradingview/coin/:symbol":{input:{},output:{}},"/perp/coin/:symbol":{input:{},output:{}},"/perp/coin/spot/:symbol":{input:{},output:{}},"/perp/coins":{input:{},output:{}},"/perp/legal-check/:address":{input:{},output:{}},"/perp/coins/spot":{input:{},output:{}},"/perp/orderbook/:symbol":{input:{},output:{}},"/perp/trades/:symbol":{input:{},output:{}},"/perp/stats/spot/:symbol":{input:{},output:{}},"/perp/stats/:symbol":{input:{},output:{}},"/perp/subscribe":{input:{},output:{},POST:{input:{},output:{},body:{}}},"/perp/unsubscribe":{input:{},output:{},POST:{input:{},output:{},body:{}}},"/stellar-lending/users/:owner/assets/:asset/balance":{input:{},output:{}},"/stellar-lending/users/:owner/activity/page":{input:{},output:{}}},h=["PATCH","POST","DELETE","PUT"];var g=r(586);const y=e=>e.replace(/-([a-z])/g,((e,t)=>t.toUpperCase())),b=()=>({static:{},params:{},leaves:[]});function S(e,t,r,o){const{input:n,output:i,...u}=t,a=async(t={})=>{const n={...r,...t},i=e.replace(/:([a-zA-Z_]+)/g,((e,t)=>`${n[t]}`)),u=[...e.matchAll(/:([a-zA-Z_]+)/g)].map((e=>e[1])),a=Object.fromEntries(Object.entries(n).filter((([e])=>!u.includes(e)))),l=/:address[^A-Z]/.test(e)||"address"in a,f=/:collection[^A-Z]/.test(e)||"collection"in a;if(l){const e=n.address;if(!c(e))throw new d(e)}if(f){const e=n.collection;if(Array.isArray(e)?e.some((e=>!s(e))):!s(e))throw new p(e)}const h=Object.fromEntries(Object.entries(a).map((([e,t])=>[e,t instanceof FormData?t:"filter"===e||"body"===e?JSON.stringify(t):Array.isArray(t)?t.join(","):t]))),{body:g,auth:y,method:b,headers:S,cache:m,next:T,debug:w,signal:v,credentials:x,mode:A,redirect:P,referrer:q,referrerPolicy:k,integrity:E,keepalive:_,priority:I,window:R,continuationToken:O,...B}=h,M=y?`Bearer ${y}`:void 0;e.startsWith("/stellar-lending/")&&void 0!==O&&(B.continuationToken=O);const U={...S,...M?{Authorization:M}:{},...O&&!e.startsWith("/stellar-lending/")?{"X-Continuation-Token":String(O)}:{}},C={...T,tags:[...T?.tags??[],i]};return o.fetchWithTimeout(i,{method:b,params:B,body:g,headers:U,cache:m,debug:w,...Object.fromEntries(Object.entries({signal:v,credentials:x,mode:A,redirect:P,referrer:q,referrerPolicy:k,integrity:E,keepalive:_,priority:I,window:R}).filter((([,e])=>void 0!==e))),...C?{next:C}:{}})},l=(e={})=>a(e);for(const e of Object.keys(u))h.includes(e)&&(l[e]=t=>a({...t,method:t.method??e.toUpperCase()}));return l}function m(e){const t=function(){const e=b();for(const[t,r]of Object.entries(f)){const o=t.split("/").filter(Boolean);let n=e;for(const e of o)if(e.startsWith(":")){const t=y(e.slice(1));n=n.params[t]||=b()}else{const t=y(e);n=n.static[t]||=b()}n.leaves.push({rawPath:t,def:r})}return e}(),r=(t,o)=>{const n=t.leaves.length,i=Object.keys(t.static).length,u=Object.keys(t.params).length;let a;if(1===n&&i+u>0){const{rawPath:r,def:n}=t.leaves[0];a=S(r,n,o,e)}else{a={};for(const{rawPath:r,def:n}of t.leaves)a[y(r.split("/").pop().replace(/^:/,""))]=S(r,n,o,e)}for(const[e,n]of Object.entries(t.static)){const t=r(n,o);let i=t;if(t&&"object"==typeof t&&e in t&&"function"==typeof t[e]){const r=t[e],o=Object.fromEntries(Object.entries(t).filter((([t])=>t!==e)));1===r.length||(Object.assign(r,o),i=r)}void 0===a[e]?a[e]=i:"function"==typeof a[e]?Object.assign(a[e],i):"function"==typeof i?(Object.assign(i,a[e]),a[e]=i):Object.assign(a[e],i)}for(const[e,n]of Object.entries(t.params)){const t=t=>{const i=r(n,{...o,[e]:t});if(i&&"object"==typeof i&&1===Object.keys(i).length&&e in i&&"function"==typeof i[e]){const t=i[e],r=(...e)=>t(...e);return Object.assign(r,t)}return i};if(a[e]){const r=a[e];a[e]=e=>({...r(e),...t(e)})}else a[e]=t}return a};return r(t,{})}})(),module.exports=o})();
|
|
2
|
+
"undefined"!=typeof globalThis&&void 0===globalThis.self&&(globalThis.self=globalThis),(()=>{var e={526(e,t){"use strict";t.byteLength=function(e){var t=s(e),r=t[0],o=t[1];return 3*(r+o)/4-o},t.toByteArray=function(e){var t,r,i=s(e),a=i[0],u=i[1],l=new n(function(e,t,r){return 3*(t+r)/4-r}(0,a,u)),p=0,d=u>0?a-4:a;for(r=0;r<d;r+=4)t=o[e.charCodeAt(r)]<<18|o[e.charCodeAt(r+1)]<<12|o[e.charCodeAt(r+2)]<<6|o[e.charCodeAt(r+3)],l[p++]=t>>16&255,l[p++]=t>>8&255,l[p++]=255&t;return 2===u&&(t=o[e.charCodeAt(r)]<<2|o[e.charCodeAt(r+1)]>>4,l[p++]=255&t),1===u&&(t=o[e.charCodeAt(r)]<<10|o[e.charCodeAt(r+1)]<<4|o[e.charCodeAt(r+2)]>>2,l[p++]=t>>8&255,l[p++]=255&t),l},t.fromByteArray=function(e){for(var t,o=e.length,n=o%3,i=[],a=16383,s=0,l=o-n;s<l;s+=a)i.push(u(e,s,s+a>l?l:s+a));return 1===n?(t=e[o-1],i.push(r[t>>2]+r[t<<4&63]+"==")):2===n&&(t=(e[o-2]<<8)+e[o-1],i.push(r[t>>10]+r[t>>4&63]+r[t<<2&63]+"=")),i.join("")};for(var r=[],o=[],n="undefined"!=typeof Uint8Array?Uint8Array:Array,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0;a<64;++a)r[a]=i[a],o[i.charCodeAt(a)]=a;function s(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function u(e,t,o){for(var n,i,a=[],s=t;s<o;s+=3)n=(e[s]<<16&16711680)+(e[s+1]<<8&65280)+(255&e[s+2]),a.push(r[(i=n)>>18&63]+r[i>>12&63]+r[i>>6&63]+r[63&i]);return a.join("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63},287(e,t,r){"use strict";const o=r(526),n=r(251),i="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;t.hp=u,t.IS=50;const a=2147483647;function s(e){if(e>a)throw new RangeError('The value "'+e+'" is invalid for option "size"');const t=new Uint8Array(e);return Object.setPrototypeOf(t,u.prototype),t}function u(e,t,r){if("number"==typeof e){if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return d(e)}return l(e,t,r)}function l(e,t,r){if("string"==typeof e)return function(e,t){if("string"==typeof t&&""!==t||(t="utf8"),!u.isEncoding(t))throw new TypeError("Unknown encoding: "+t);const r=0|g(e,t);let o=s(r);const n=o.write(e,t);return n!==r&&(o=o.slice(0,n)),o}(e,t);if(ArrayBuffer.isView(e))return function(e){if(K(e,Uint8Array)){const t=new Uint8Array(e);return f(t.buffer,t.byteOffset,t.byteLength)}return c(e)}(e);if(null==e)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(K(e,ArrayBuffer)||e&&K(e.buffer,ArrayBuffer))return f(e,t,r);if("undefined"!=typeof SharedArrayBuffer&&(K(e,SharedArrayBuffer)||e&&K(e.buffer,SharedArrayBuffer)))return f(e,t,r);if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type number');const o=e.valueOf&&e.valueOf();if(null!=o&&o!==e)return u.from(o,t,r);const n=function(e){if(u.isBuffer(e)){const t=0|h(e.length),r=s(t);return 0===r.length||e.copy(r,0,0,t),r}return void 0!==e.length?"number"!=typeof e.length||Z(e.length)?s(0):c(e):"Buffer"===e.type&&Array.isArray(e.data)?c(e.data):void 0}(e);if(n)return n;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return u.from(e[Symbol.toPrimitive]("string"),t,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function p(e){if("number"!=typeof e)throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function d(e){return p(e),s(e<0?0:0|h(e))}function c(e){const t=e.length<0?0:0|h(e.length),r=s(t);for(let o=0;o<t;o+=1)r[o]=255&e[o];return r}function f(e,t,r){if(t<0||e.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(r||0))throw new RangeError('"length" is outside of buffer bounds');let o;return o=void 0===t&&void 0===r?new Uint8Array(e):void 0===r?new Uint8Array(e,t):new Uint8Array(e,t,r),Object.setPrototypeOf(o,u.prototype),o}function h(e){if(e>=a)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a.toString(16)+" bytes");return 0|e}function g(e,t){if(u.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||K(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);const r=e.length,o=arguments.length>2&&!0===arguments[2];if(!o&&0===r)return 0;let n=!1;for(;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return V(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return X(e).length;default:if(n)return o?-1:V(e).length;t=(""+t).toLowerCase(),n=!0}}function y(e,t,r){let o=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return q(this,t,r);case"utf8":case"utf-8":return R(this,t,r);case"ascii":return P(this,t,r);case"latin1":case"binary":return k(this,t,r);case"base64":return I(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return B(this,t,r);default:if(o)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),o=!0}}function m(e,t,r){const o=e[t];e[t]=e[r],e[r]=o}function b(e,t,r,o,n){if(0===e.length)return-1;if("string"==typeof r?(o=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),Z(r=+r)&&(r=n?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(n)return-1;r=e.length-1}else if(r<0){if(!n)return-1;r=0}if("string"==typeof t&&(t=u.from(t,o)),u.isBuffer(t))return 0===t.length?-1:S(e,t,r,o,n);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?n?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):S(e,[t],r,o,n);throw new TypeError("val must be string, number or Buffer")}function S(e,t,r,o,n){let i,a=1,s=e.length,u=t.length;if(void 0!==o&&("ucs2"===(o=String(o).toLowerCase())||"ucs-2"===o||"utf16le"===o||"utf-16le"===o)){if(e.length<2||t.length<2)return-1;a=2,s/=2,u/=2,r/=2}function l(e,t){return 1===a?e[t]:e.readUInt16BE(t*a)}if(n){let o=-1;for(i=r;i<s;i++)if(l(e,i)===l(t,-1===o?0:i-o)){if(-1===o&&(o=i),i-o+1===u)return o*a}else-1!==o&&(i-=i-o),o=-1}else for(r+u>s&&(r=s-u),i=r;i>=0;i--){let r=!0;for(let o=0;o<u;o++)if(l(e,i+o)!==l(t,o)){r=!1;break}if(r)return i}return-1}function w(e,t,r,o){r=Number(r)||0;const n=e.length-r;o?(o=Number(o))>n&&(o=n):o=n;const i=t.length;let a;for(o>i/2&&(o=i/2),a=0;a<o;++a){const o=parseInt(t.substr(2*a,2),16);if(Z(o))return a;e[r+a]=o}return a}function T(e,t,r,o){return j(V(t,e.length-r),e,r,o)}function v(e,t,r,o){return j(function(e){const t=[];for(let r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}(t),e,r,o)}function x(e,t,r,o){return j(X(t),e,r,o)}function A(e,t,r,o){return j(function(e,t){let r,o,n;const i=[];for(let a=0;a<e.length&&!((t-=2)<0);++a)r=e.charCodeAt(a),o=r>>8,n=r%256,i.push(n),i.push(o);return i}(t,e.length-r),e,r,o)}function I(e,t,r){return 0===t&&r===e.length?o.fromByteArray(e):o.fromByteArray(e.slice(t,r))}function R(e,t,r){r=Math.min(e.length,r);const o=[];let n=t;for(;n<r;){const t=e[n];let i=null,a=t>239?4:t>223?3:t>191?2:1;if(n+a<=r){let r,o,s,u;switch(a){case 1:t<128&&(i=t);break;case 2:r=e[n+1],128==(192&r)&&(u=(31&t)<<6|63&r,u>127&&(i=u));break;case 3:r=e[n+1],o=e[n+2],128==(192&r)&&128==(192&o)&&(u=(15&t)<<12|(63&r)<<6|63&o,u>2047&&(u<55296||u>57343)&&(i=u));break;case 4:r=e[n+1],o=e[n+2],s=e[n+3],128==(192&r)&&128==(192&o)&&128==(192&s)&&(u=(15&t)<<18|(63&r)<<12|(63&o)<<6|63&s,u>65535&&u<1114112&&(i=u))}}null===i?(i=65533,a=1):i>65535&&(i-=65536,o.push(i>>>10&1023|55296),i=56320|1023&i),o.push(i),n+=a}return function(e){const t=e.length;if(t<=E)return String.fromCharCode.apply(String,e);let r="",o=0;for(;o<t;)r+=String.fromCharCode.apply(String,e.slice(o,o+=E));return r}(o)}u.TYPED_ARRAY_SUPPORT=function(){try{const e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),42===e.foo()}catch(e){return!1}}(),u.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(u.prototype,"parent",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.buffer}}),Object.defineProperty(u.prototype,"offset",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.byteOffset}}),u.poolSize=8192,u.from=function(e,t,r){return l(e,t,r)},Object.setPrototypeOf(u.prototype,Uint8Array.prototype),Object.setPrototypeOf(u,Uint8Array),u.alloc=function(e,t,r){return function(e,t,r){return p(e),e<=0?s(e):void 0!==t?"string"==typeof r?s(e).fill(t,r):s(e).fill(t):s(e)}(e,t,r)},u.allocUnsafe=function(e){return d(e)},u.allocUnsafeSlow=function(e){return d(e)},u.isBuffer=function(e){return null!=e&&!0===e._isBuffer&&e!==u.prototype},u.compare=function(e,t){if(K(e,Uint8Array)&&(e=u.from(e,e.offset,e.byteLength)),K(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),!u.isBuffer(e)||!u.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;let r=e.length,o=t.length;for(let n=0,i=Math.min(r,o);n<i;++n)if(e[n]!==t[n]){r=e[n],o=t[n];break}return r<o?-1:o<r?1:0},u.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},u.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return u.alloc(0);let r;if(void 0===t)for(t=0,r=0;r<e.length;++r)t+=e[r].length;const o=u.allocUnsafe(t);let n=0;for(r=0;r<e.length;++r){let t=e[r];if(K(t,Uint8Array))n+t.length>o.length?(u.isBuffer(t)||(t=u.from(t)),t.copy(o,n)):Uint8Array.prototype.set.call(o,t,n);else{if(!u.isBuffer(t))throw new TypeError('"list" argument must be an Array of Buffers');t.copy(o,n)}n+=t.length}return o},u.byteLength=g,u.prototype._isBuffer=!0,u.prototype.swap16=function(){const e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let t=0;t<e;t+=2)m(this,t,t+1);return this},u.prototype.swap32=function(){const e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let t=0;t<e;t+=4)m(this,t,t+3),m(this,t+1,t+2);return this},u.prototype.swap64=function(){const e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let t=0;t<e;t+=8)m(this,t,t+7),m(this,t+1,t+6),m(this,t+2,t+5),m(this,t+3,t+4);return this},u.prototype.toString=function(){const e=this.length;return 0===e?"":0===arguments.length?R(this,0,e):y.apply(this,arguments)},u.prototype.toLocaleString=u.prototype.toString,u.prototype.equals=function(e){if(!u.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===u.compare(this,e)},u.prototype.inspect=function(){let e="";const r=t.IS;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"},i&&(u.prototype[i]=u.prototype.inspect),u.prototype.compare=function(e,t,r,o,n){if(K(e,Uint8Array)&&(e=u.from(e,e.offset,e.byteLength)),!u.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===o&&(o=0),void 0===n&&(n=this.length),t<0||r>e.length||o<0||n>this.length)throw new RangeError("out of range index");if(o>=n&&t>=r)return 0;if(o>=n)return-1;if(t>=r)return 1;if(this===e)return 0;let i=(n>>>=0)-(o>>>=0),a=(r>>>=0)-(t>>>=0);const s=Math.min(i,a),l=this.slice(o,n),p=e.slice(t,r);for(let e=0;e<s;++e)if(l[e]!==p[e]){i=l[e],a=p[e];break}return i<a?-1:a<i?1:0},u.prototype.includes=function(e,t,r){return-1!==this.indexOf(e,t,r)},u.prototype.indexOf=function(e,t,r){return b(this,e,t,r,!0)},u.prototype.lastIndexOf=function(e,t,r){return b(this,e,t,r,!1)},u.prototype.write=function(e,t,r,o){if(void 0===t)o="utf8",r=this.length,t=0;else if(void 0===r&&"string"==typeof t)o=t,r=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t>>>=0,isFinite(r)?(r>>>=0,void 0===o&&(o="utf8")):(o=r,r=void 0)}const n=this.length-t;if((void 0===r||r>n)&&(r=n),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");o||(o="utf8");let i=!1;for(;;)switch(o){case"hex":return w(this,e,t,r);case"utf8":case"utf-8":return T(this,e,t,r);case"ascii":case"latin1":case"binary":return v(this,e,t,r);case"base64":return x(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,e,t,r);default:if(i)throw new TypeError("Unknown encoding: "+o);o=(""+o).toLowerCase(),i=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const E=4096;function P(e,t,r){let o="";r=Math.min(e.length,r);for(let n=t;n<r;++n)o+=String.fromCharCode(127&e[n]);return o}function k(e,t,r){let o="";r=Math.min(e.length,r);for(let n=t;n<r;++n)o+=String.fromCharCode(e[n]);return o}function q(e,t,r){const o=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>o)&&(r=o);let n="";for(let o=t;o<r;++o)n+=Y[e[o]];return n}function B(e,t,r){const o=e.slice(t,r);let n="";for(let e=0;e<o.length-1;e+=2)n+=String.fromCharCode(o[e]+256*o[e+1]);return n}function _(e,t,r){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}function O(e,t,r,o,n,i){if(!u.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>n||t<i)throw new RangeError('"value" argument is out of bounds');if(r+o>e.length)throw new RangeError("Index out of range")}function U(e,t,r,o,n){F(t,o,n,e,r,7);let i=Number(t&BigInt(4294967295));e[r++]=i,i>>=8,e[r++]=i,i>>=8,e[r++]=i,i>>=8,e[r++]=i;let a=Number(t>>BigInt(32)&BigInt(4294967295));return e[r++]=a,a>>=8,e[r++]=a,a>>=8,e[r++]=a,a>>=8,e[r++]=a,r}function M(e,t,r,o,n){F(t,o,n,e,r,7);let i=Number(t&BigInt(4294967295));e[r+7]=i,i>>=8,e[r+6]=i,i>>=8,e[r+5]=i,i>>=8,e[r+4]=i;let a=Number(t>>BigInt(32)&BigInt(4294967295));return e[r+3]=a,a>>=8,e[r+2]=a,a>>=8,e[r+1]=a,a>>=8,e[r]=a,r+8}function C(e,t,r,o,n,i){if(r+o>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function L(e,t,r,o,i){return t=+t,r>>>=0,i||C(e,0,r,4),n.write(e,t,r,o,23,4),r+4}function D(e,t,r,o,i){return t=+t,r>>>=0,i||C(e,0,r,8),n.write(e,t,r,o,52,8),r+8}u.prototype.slice=function(e,t){const r=this.length;(e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e);const o=this.subarray(e,t);return Object.setPrototypeOf(o,u.prototype),o},u.prototype.readUintLE=u.prototype.readUIntLE=function(e,t,r){e>>>=0,t>>>=0,r||_(e,t,this.length);let o=this[e],n=1,i=0;for(;++i<t&&(n*=256);)o+=this[e+i]*n;return o},u.prototype.readUintBE=u.prototype.readUIntBE=function(e,t,r){e>>>=0,t>>>=0,r||_(e,t,this.length);let o=this[e+--t],n=1;for(;t>0&&(n*=256);)o+=this[e+--t]*n;return o},u.prototype.readUint8=u.prototype.readUInt8=function(e,t){return e>>>=0,t||_(e,1,this.length),this[e]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(e,t){return e>>>=0,t||_(e,2,this.length),this[e]|this[e+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(e,t){return e>>>=0,t||_(e,2,this.length),this[e]<<8|this[e+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(e,t){return e>>>=0,t||_(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(e,t){return e>>>=0,t||_(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},u.prototype.readBigUInt64LE=Q((function(e){G(e>>>=0,"offset");const t=this[e],r=this[e+7];void 0!==t&&void 0!==r||H(e,this.length-8);const o=t+256*this[++e]+65536*this[++e]+this[++e]*2**24,n=this[++e]+256*this[++e]+65536*this[++e]+r*2**24;return BigInt(o)+(BigInt(n)<<BigInt(32))})),u.prototype.readBigUInt64BE=Q((function(e){G(e>>>=0,"offset");const t=this[e],r=this[e+7];void 0!==t&&void 0!==r||H(e,this.length-8);const o=t*2**24+65536*this[++e]+256*this[++e]+this[++e],n=this[++e]*2**24+65536*this[++e]+256*this[++e]+r;return(BigInt(o)<<BigInt(32))+BigInt(n)})),u.prototype.readIntLE=function(e,t,r){e>>>=0,t>>>=0,r||_(e,t,this.length);let o=this[e],n=1,i=0;for(;++i<t&&(n*=256);)o+=this[e+i]*n;return n*=128,o>=n&&(o-=Math.pow(2,8*t)),o},u.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||_(e,t,this.length);let o=t,n=1,i=this[e+--o];for(;o>0&&(n*=256);)i+=this[e+--o]*n;return n*=128,i>=n&&(i-=Math.pow(2,8*t)),i},u.prototype.readInt8=function(e,t){return e>>>=0,t||_(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},u.prototype.readInt16LE=function(e,t){e>>>=0,t||_(e,2,this.length);const r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt16BE=function(e,t){e>>>=0,t||_(e,2,this.length);const r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt32LE=function(e,t){return e>>>=0,t||_(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},u.prototype.readInt32BE=function(e,t){return e>>>=0,t||_(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},u.prototype.readBigInt64LE=Q((function(e){G(e>>>=0,"offset");const t=this[e],r=this[e+7];void 0!==t&&void 0!==r||H(e,this.length-8);const o=this[e+4]+256*this[e+5]+65536*this[e+6]+(r<<24);return(BigInt(o)<<BigInt(32))+BigInt(t+256*this[++e]+65536*this[++e]+this[++e]*2**24)})),u.prototype.readBigInt64BE=Q((function(e){G(e>>>=0,"offset");const t=this[e],r=this[e+7];void 0!==t&&void 0!==r||H(e,this.length-8);const o=(t<<24)+65536*this[++e]+256*this[++e]+this[++e];return(BigInt(o)<<BigInt(32))+BigInt(this[++e]*2**24+65536*this[++e]+256*this[++e]+r)})),u.prototype.readFloatLE=function(e,t){return e>>>=0,t||_(e,4,this.length),n.read(this,e,!0,23,4)},u.prototype.readFloatBE=function(e,t){return e>>>=0,t||_(e,4,this.length),n.read(this,e,!1,23,4)},u.prototype.readDoubleLE=function(e,t){return e>>>=0,t||_(e,8,this.length),n.read(this,e,!0,52,8)},u.prototype.readDoubleBE=function(e,t){return e>>>=0,t||_(e,8,this.length),n.read(this,e,!1,52,8)},u.prototype.writeUintLE=u.prototype.writeUIntLE=function(e,t,r,o){e=+e,t>>>=0,r>>>=0,o||O(this,e,t,r,Math.pow(2,8*r)-1,0);let n=1,i=0;for(this[t]=255&e;++i<r&&(n*=256);)this[t+i]=e/n&255;return t+r},u.prototype.writeUintBE=u.prototype.writeUIntBE=function(e,t,r,o){e=+e,t>>>=0,r>>>=0,o||O(this,e,t,r,Math.pow(2,8*r)-1,0);let n=r-1,i=1;for(this[t+n]=255&e;--n>=0&&(i*=256);)this[t+n]=e/i&255;return t+r},u.prototype.writeUint8=u.prototype.writeUInt8=function(e,t,r){return e=+e,t>>>=0,r||O(this,e,t,1,255,0),this[t]=255&e,t+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(e,t,r){return e=+e,t>>>=0,r||O(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(e,t,r){return e=+e,t>>>=0,r||O(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(e,t,r){return e=+e,t>>>=0,r||O(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(e,t,r){return e=+e,t>>>=0,r||O(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},u.prototype.writeBigUInt64LE=Q((function(e,t=0){return U(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeBigUInt64BE=Q((function(e,t=0){return M(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeIntLE=function(e,t,r,o){if(e=+e,t>>>=0,!o){const o=Math.pow(2,8*r-1);O(this,e,t,r,o-1,-o)}let n=0,i=1,a=0;for(this[t]=255&e;++n<r&&(i*=256);)e<0&&0===a&&0!==this[t+n-1]&&(a=1),this[t+n]=(e/i|0)-a&255;return t+r},u.prototype.writeIntBE=function(e,t,r,o){if(e=+e,t>>>=0,!o){const o=Math.pow(2,8*r-1);O(this,e,t,r,o-1,-o)}let n=r-1,i=1,a=0;for(this[t+n]=255&e;--n>=0&&(i*=256);)e<0&&0===a&&0!==this[t+n+1]&&(a=1),this[t+n]=(e/i|0)-a&255;return t+r},u.prototype.writeInt8=function(e,t,r){return e=+e,t>>>=0,r||O(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},u.prototype.writeInt16LE=function(e,t,r){return e=+e,t>>>=0,r||O(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},u.prototype.writeInt16BE=function(e,t,r){return e=+e,t>>>=0,r||O(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},u.prototype.writeInt32LE=function(e,t,r){return e=+e,t>>>=0,r||O(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},u.prototype.writeInt32BE=function(e,t,r){return e=+e,t>>>=0,r||O(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},u.prototype.writeBigInt64LE=Q((function(e,t=0){return U(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeBigInt64BE=Q((function(e,t=0){return M(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeFloatLE=function(e,t,r){return L(this,e,t,!0,r)},u.prototype.writeFloatBE=function(e,t,r){return L(this,e,t,!1,r)},u.prototype.writeDoubleLE=function(e,t,r){return D(this,e,t,!0,r)},u.prototype.writeDoubleBE=function(e,t,r){return D(this,e,t,!1,r)},u.prototype.copy=function(e,t,r,o){if(!u.isBuffer(e))throw new TypeError("argument should be a Buffer");if(r||(r=0),o||0===o||(o=this.length),t>=e.length&&(t=e.length),t||(t=0),o>0&&o<r&&(o=r),o===r)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(o<0)throw new RangeError("sourceEnd out of bounds");o>this.length&&(o=this.length),e.length-t<o-r&&(o=e.length-t+r);const n=o-r;return this===e&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(t,r,o):Uint8Array.prototype.set.call(e,this.subarray(r,o),t),n},u.prototype.fill=function(e,t,r,o){if("string"==typeof e){if("string"==typeof t?(o=t,t=0,r=this.length):"string"==typeof r&&(o=r,r=this.length),void 0!==o&&"string"!=typeof o)throw new TypeError("encoding must be a string");if("string"==typeof o&&!u.isEncoding(o))throw new TypeError("Unknown encoding: "+o);if(1===e.length){const t=e.charCodeAt(0);("utf8"===o&&t<128||"latin1"===o)&&(e=t)}}else"number"==typeof e?e&=255:"boolean"==typeof e&&(e=Number(e));if(t<0||this.length<t||this.length<r)throw new RangeError("Out of range index");if(r<=t)return this;let n;if(t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(n=t;n<r;++n)this[n]=e;else{const i=u.isBuffer(e)?e:u.from(e,o),a=i.length;if(0===a)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(n=0;n<r-t;++n)this[n+t]=i[n%a]}return this};const $={};function N(e,t,r){$[e]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:t.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${e}]`,this.stack,delete this.name}get code(){return e}set code(e){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:e,writable:!0})}toString(){return`${this.name} [${e}]: ${this.message}`}}}function W(e){let t="",r=e.length;const o="-"===e[0]?1:0;for(;r>=o+4;r-=3)t=`_${e.slice(r-3,r)}${t}`;return`${e.slice(0,r)}${t}`}function F(e,t,r,o,n,i){if(e>r||e<t){const o="bigint"==typeof t?"n":"";let n;throw n=i>3?0===t||t===BigInt(0)?`>= 0${o} and < 2${o} ** ${8*(i+1)}${o}`:`>= -(2${o} ** ${8*(i+1)-1}${o}) and < 2 ** ${8*(i+1)-1}${o}`:`>= ${t}${o} and <= ${r}${o}`,new $.ERR_OUT_OF_RANGE("value",n,e)}!function(e,t,r){G(t,"offset"),void 0!==e[t]&&void 0!==e[t+r]||H(t,e.length-(r+1))}(o,n,i)}function G(e,t){if("number"!=typeof e)throw new $.ERR_INVALID_ARG_TYPE(t,"number",e)}function H(e,t,r){if(Math.floor(e)!==e)throw G(e,r),new $.ERR_OUT_OF_RANGE(r||"offset","an integer",e);if(t<0)throw new $.ERR_BUFFER_OUT_OF_BOUNDS;throw new $.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${t}`,e)}N("ERR_BUFFER_OUT_OF_BOUNDS",(function(e){return e?`${e} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),N("ERR_INVALID_ARG_TYPE",(function(e,t){return`The "${e}" argument must be of type number. Received type ${typeof t}`}),TypeError),N("ERR_OUT_OF_RANGE",(function(e,t,r){let o=`The value of "${e}" is out of range.`,n=r;return Number.isInteger(r)&&Math.abs(r)>2**32?n=W(String(r)):"bigint"==typeof r&&(n=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(n=W(n)),n+="n"),o+=` It must be ${t}. Received ${n}`,o}),RangeError);const z=/[^+/0-9A-Za-z-_]/g;function V(e,t){let r;t=t||1/0;const o=e.length;let n=null;const i=[];for(let a=0;a<o;++a){if(r=e.charCodeAt(a),r>55295&&r<57344){if(!n){if(r>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(a+1===o){(t-=3)>-1&&i.push(239,191,189);continue}n=r;continue}if(r<56320){(t-=3)>-1&&i.push(239,191,189),n=r;continue}r=65536+(n-55296<<10|r-56320)}else n&&(t-=3)>-1&&i.push(239,191,189);if(n=null,r<128){if((t-=1)<0)break;i.push(r)}else if(r<2048){if((t-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function X(e){return o.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace(z,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function j(e,t,r,o){let n;for(n=0;n<o&&!(n+r>=t.length||n>=e.length);++n)t[n+r]=e[n];return n}function K(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function Z(e){return e!=e}const Y=function(){const e="0123456789abcdef",t=new Array(256);for(let r=0;r<16;++r){const o=16*r;for(let n=0;n<16;++n)t[o+n]=e[r]+e[n]}return t}();function Q(e){return"undefined"==typeof BigInt?J:e}function J(){throw new Error("BigInt not supported")}},251(e,t){t.read=function(e,t,r,o,n){var i,a,s=8*n-o-1,u=(1<<s)-1,l=u>>1,p=-7,d=r?n-1:0,c=r?-1:1,f=e[t+d];for(d+=c,i=f&(1<<-p)-1,f>>=-p,p+=s;p>0;i=256*i+e[t+d],d+=c,p-=8);for(a=i&(1<<-p)-1,i>>=-p,p+=o;p>0;a=256*a+e[t+d],d+=c,p-=8);if(0===i)i=1-l;else{if(i===u)return a?NaN:1/0*(f?-1:1);a+=Math.pow(2,o),i-=l}return(f?-1:1)*a*Math.pow(2,i-o)},t.write=function(e,t,r,o,n,i){var a,s,u,l=8*i-n-1,p=(1<<l)-1,d=p>>1,c=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,f=o?0:i-1,h=o?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,a=p):(a=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-a))<1&&(a--,u*=2),(t+=a+d>=1?c/u:c*Math.pow(2,1-d))*u>=2&&(a++,u/=2),a+d>=p?(s=0,a=p):a+d>=1?(s=(t*u-1)*Math.pow(2,n),a+=d):(s=t*Math.pow(2,d-1)*Math.pow(2,n),a=0));n>=8;e[r+f]=255&s,f+=h,s/=256,n-=8);for(a=a<<n|s,l+=n;l>0;e[r+f]=255&a,f+=h,a/=256,l-=8);e[r+f-h]|=128*g}},723(e,t,r){"use strict";r.d(t,{BPS:()=>Ko,DEFAULT_MIN_BORROW_COLLATERAL_USD_WAD:()=>kn,LIQUIDATION_BUFFER_BPS:()=>Xn,RAY:()=>Xo,RAY_DECIMALS:()=>Zo,STELLAR_GOVERNANCE_ZERO_PREDECESSOR:()=>Ot,STELLAR_LENDING_TOPICS:()=>Jr,STELLAR_NETWORKS:()=>o,STELLAR_NETWORK_PASSPHRASE:()=>a,STELLAR_ROUTE_MAX_BYTES:()=>lo,SYNTHETIC_EVENT_ORDER_STRIDE:()=>to,StellarAuthPolicyError:()=>Ao,StellarRouteVerificationError:()=>po,WAD:()=>jo,WAD_DECIMALS:()=>Yo,aggregateAccountRisk:()=>zn,annualBorrowRateRay:()=>In,assertStellarAuthEntries:()=>_o,assertStellarPreparedTxAuth:()=>$o,baseToRay:()=>hn,baseToShort:()=>Sn,baseValueWad:()=>yn,buildLiveSnapshot:()=>Mn,buildSameTokenRepaySwapSteps:()=>Ho,buildStellarAcceptOwnershipTx:()=>dt,buildStellarAddRewardsTx:()=>Bt,buildStellarApproveBlendPoolTx:()=>mt,buildStellarApproveTokenTx:()=>St,buildStellarBatchSwapTx:()=>So,buildStellarBorrowBatchTx:()=>$,buildStellarBorrowTx:()=>N,buildStellarCctpForwardTx:()=>Vo,buildStellarClaimRevenueTx:()=>qt,buildStellarCreateLiquidityPoolTx:()=>Pt,buildStellarExecuteCancellerResetTx:()=>kr,buildStellarExecuteStrategyTx:()=>bo,buildStellarFlashLoanTx:()=>X,buildStellarGovernanceAddSpokeImmediateTx:()=>Or,buildStellarGovernanceCreateHubImmediateTx:()=>_r,buildStellarGovernanceExecuteGovernanceUpgradeTx:()=>vr,buildStellarGovernanceExecuteGrantGovernanceRoleTx:()=>Ar,buildStellarGovernanceExecuteRevokeGovernanceRoleTx:()=>Ir,buildStellarGovernanceExecuteTransferGovOwnTx:()=>Rr,buildStellarGovernanceExecuteTx:()=>Tr,buildStellarGovernanceExecuteUpdateDelayTx:()=>xr,buildStellarGovernancePauseTx:()=>Mr,buildStellarGovernanceRevokeRoleImmediateTx:()=>Ur,buildStellarGovernanceSetOracleSanityBoundsImmediateTx:()=>Br,buildStellarGovernanceSetSpokeAssetFlagsImmediateTx:()=>qr,buildStellarGrantRoleTx:()=>ut,buildStellarLendingIdentifier:()=>ro,buildStellarLiquidateTx:()=>z,buildStellarMigrateFromBlendTx:()=>j,buildStellarMigrateTx:()=>it,buildStellarMultiplyTx:()=>K,buildStellarPauseTx:()=>at,buildStellarProposeAddAssetToSpokeTx:()=>Zt,buildStellarProposeAddSpokeTx:()=>jt,buildStellarProposeApproveBlendPoolTx:()=>nr,buildStellarProposeApproveTokenTx:()=>rr,buildStellarProposeCancellerResetTx:()=>Pr,buildStellarProposeConfigureAssetOracleTx:()=>fr,buildStellarProposeConfigureMarketOracleTx:()=>hr,buildStellarProposeCreateHubTx:()=>Xt,buildStellarProposeCreateLiquidityPoolTx:()=>ar,buildStellarProposeDeployPoolTx:()=>ur,buildStellarProposeEditAssetInSpokeTx:()=>Yt,buildStellarProposeEditOracleToleranceTx:()=>gr,buildStellarProposeGovernanceUpgradeTx:()=>yr,buildStellarProposeGrantGovernanceRoleTx:()=>br,buildStellarProposeMigrateControllerTx:()=>dr,buildStellarProposeRemoveAssetFromSpokeTx:()=>Qt,buildStellarProposeRemoveSpokeTx:()=>Kt,buildStellarProposeRevokeBlendPoolTx:()=>ir,buildStellarProposeRevokeGovernanceRoleTx:()=>Sr,buildStellarProposeRevokeTokenTx:()=>or,buildStellarProposeSetAccumulatorTx:()=>zt,buildStellarProposeSetAggregatorTx:()=>Ht,buildStellarProposeSetMinBorrowCollatTx:()=>tr,buildStellarProposeSetPositionLimitsTx:()=>Vt,buildStellarProposeSetPositionManagerTx:()=>er,buildStellarProposeSetPriceAggregatorTx:()=>Gt,buildStellarProposeSetSpokeLiquidationCurveTx:()=>Jt,buildStellarProposeSetSwapAggregatorTx:()=>Ft,buildStellarProposeTransferCtrlOwnershipTx:()=>cr,buildStellarProposeTransferGovOwnTx:()=>wr,buildStellarProposeUnpauseTx:()=>Cr,buildStellarProposeUpdateDelayTx:()=>mr,buildStellarProposeUpgradeControllerTx:()=>pr,buildStellarProposeUpgradePoolParamsTx:()=>sr,buildStellarProposeUpgradePoolTx:()=>lr,buildStellarRenewAccountTx:()=>Et,buildStellarRepayBatchTx:()=>G,buildStellarRepayDebtWithCollateralTx:()=>Q,buildStellarRepayTx:()=>H,buildStellarRevokeBlendPoolTx:()=>bt,buildStellarRevokeRoleTx:()=>lt,buildStellarRevokeTokenTx:()=>wt,buildStellarSetAccumulatorTx:()=>gt,buildStellarSetAggregatorTx:()=>ht,buildStellarSetMarketOracleConfigTx:()=>vt,buildStellarSetOracleSanityBoundsTx:()=>It,buildStellarSetOracleToleranceTx:()=>xt,buildStellarSetOracleTx:()=>Tt,buildStellarSetPositionLimitsTx:()=>yt,buildStellarSetPriceAggregatorTx:()=>ft,buildStellarSetSpokeAssetFlagsTx:()=>At,buildStellarSetSwapAggregatorTx:()=>ct,buildStellarSupplyBatchTx:()=>L,buildStellarSupplyTx:()=>D,buildStellarSwapCollateralTx:()=>Y,buildStellarSwapDebtTx:()=>Z,buildStellarTransferOwnershipTx:()=>pt,buildStellarUnpauseTx:()=>st,buildStellarUpdateAccountThresholdTx:()=>_t,buildStellarUpdateIndexesTx:()=>Rt,buildStellarUpgradeControllerTx:()=>nt,buildStellarUpgradeLiquidityPoolParamsTx:()=>kt,buildStellarWithdrawBatchTx:()=>W,buildStellarWithdrawTx:()=>F,buildTx:()=>M,burnShares:()=>Nn,computeAccountRisk:()=>Vn,decodeStellarLendingEvent:()=>eo,decodeStellarLiquidateReturn:()=>V,decodeStellarRouteBytes:()=>fo,depositRateRay:()=>Rn,divByIntHalfUp:()=>rn,encodeAssetOracle:()=>rt,encodeInterestRateModel:()=>ze,encodeMarketOracleConfigInput:()=>ot,encodeMarketParamsRaw:()=>Ve,encodePositionLimits:()=>Xe,encodePriceKey:()=>je,encodeStrategyPayloadToRouteXdr:()=>mo,extractEventOrder:()=>oo,getStellarAccountPositions:()=>fe,getStellarActiveUsersSeries:()=>Le,getStellarAggregatorQuote:()=>so,getStellarAsset:()=>le,getStellarAssetGraph:()=>we,getStellarAssetMarkets:()=>ye,getStellarAssetPage:()=>ge,getStellarAssets:()=>ne,getStellarCampaignLeaderboard:()=>Be,getStellarCampaignMe:()=>Ge,getStellarDefiLlamaDimensions:()=>$e,getStellarDeployment:()=>i,getStellarDetailedMarkets:()=>oe,getStellarFeeRevenueSeries:()=>Ue,getStellarGovernanceProposals:()=>Re,getStellarHolderDistribution:()=>qe,getStellarHub:()=>pe,getStellarHubGraph:()=>Te,getStellarHubHolders:()=>be,getStellarHubs:()=>ie,getStellarLendingContext:()=>te,getStellarLendingLiveState:()=>re,getStellarLiquidationsLeaderboard:()=>ke,getStellarLiquidationsSeries:()=>Me,getStellarParticipantCounts:()=>Pe,getStellarPnlByScope:()=>Fe,getStellarPositionsLeaderboard:()=>Ee,getStellarPositionsPnl:()=>We,getStellarQuoteTokens:()=>uo,getStellarRateSpreadSeries:()=>De,getStellarReserve:()=>ue,getStellarReserveGraph:()=>xe,getStellarReserveHolders:()=>me,getStellarReserves:()=>se,getStellarRevenueSeries:()=>Oe,getStellarSpoke:()=>de,getStellarSpokeGraph:()=>ve,getStellarSpokeHolders:()=>Se,getStellarSpokes:()=>ae,getStellarStatsHistory:()=>_e,getStellarUserActivity:()=>Ae,getStellarUserActivityPage:()=>Ie,getStellarUserHistory:()=>Ne,getStellarUserPositions:()=>ce,getStellarVolumeSeries:()=>Ce,getStellarWalletBalance:()=>he,liveIndexKey:()=>Un,mapQuoteResponseToAggregatorSwap:()=>vo,mapQuoteResponseToStrategyPayload:()=>wo,mapQuoteResponseToStrategySwap:()=>To,mapSorobanError:()=>ci,mapStellarPositionActivityType:()=>io,maxBorrow:()=>ri,maxRepay:()=>ii,maxSupply:()=>ni,maxWithdraw:()=>oi,mintShares:()=>$n,mulDivCeil:()=>en,mulDivFloor:()=>Jo,mulDivHalfUp:()=>tn,numberToScaled:()=>wn,numberToWad:()=>Tn,positionValueWad:()=>gn,prepareStellarBuiltTx:()=>Fo,prepareStellarTxXdr:()=>Wo,projectAccountRisk:()=>ui,projectReserveApy:()=>pi,rayAprToApy:()=>Pn,rayAprToNumber:()=>En,rayToNumber:()=>bn,rescaleCeil:()=>an,rescaleFloor:()=>nn,rescaleHalfUp:()=>sn,reserveKey:()=>qn,resolveReserve:()=>Bn,stellarAuthPolicyForInvocation:()=>Lo,stellarLendingDispatchKey:()=>$r,stellarLendingRead:()=>He,stellarNetworks:()=>n,stellarTokenContractId:()=>ho,syntheticEventOrder:()=>no,tagStellarInvokedContractError:()=>No,toBase64Xdr:()=>Lr,toBigInt:()=>Qo,toStellarPositionMode:()=>Go,unscale:()=>pn,unscaleBorrowCeil:()=>cn,unscaleHalfUp:()=>fn,unscaleSupplyFloor:()=>dn,utilizationRay:()=>An,valueBasePosition:()=>Wn,valueScaledPosition:()=>Dn,verifyStellarRouteBytes:()=>yo,wadToNumber:()=>mn});const o={stellarMainnet:{name:"mainnet",passphrase:"Public Global Stellar Network ; September 2015",horizonUrl:"https://horizon.stellar.org",sorobanRpcUrl:"https://stellar-gateway.xoxno.com",quoteUrl:"https://stellar-swap.xoxno.com",explorerNetwork:"public",aquariusApiUrl:"https://amm-api.aqua.network",aquariusRouter:"CBQDHNBFBZYE4MKPWBSJOPIYLW4SFSXAXUTSXJN76GNKYVYPCKWC6QUK",lendingController:"CAUCMIN5KSXEVZ7NMXR3LZATGD5EFIEUI5XWTFLYRO2R5OTXI22WE5JX",lendingPool:"CBXRNDQMAJFG4VUKMKFEMFS75UUXE2SPSNV4LEEFCSNBCN66PYRWBKXO",aggregatorRouter:"CCVENFSVCBYDHVOACFZXMNNYVOZ3LKXPZYU5LUI4N7KTXOKRVYD7F3TR",governance:"CC44PEQW7HSEPKAZ5ZRPH2JS5M5KVJXCUBLJ2ZX4E3WCDKMNFILHC2AD",priceAggregator:"CBGUF2G2Q7HCVCWYISDXBHPVBGMYNXA7PG2VET66YBZX6IKOOV27NSMV",positionNftContract:"CAWCSG77AY2W24QZ6ZXLHZU4UXEFHZBM6EI4A4IF7JB5CTY4XND3TI6C"},stellarTestnet:{name:"testnet",passphrase:"Test SDF Network ; September 2015",horizonUrl:"https://horizon-testnet.stellar.org",sorobanRpcUrl:"https://stellar-testnet-gateway.xoxno.com",quoteUrl:"https://testnet-stellar-swap.xoxno.com",explorerNetwork:"testnet",aquariusApiUrl:"https://amm-api-testnet.aqua.network",aquariusRouter:"CBCFTQSPDBAIZ6R6PJQKSQWKNKWH2QIV3I4J72SHWBIK3ADRRAM5A6GD",lendingController:"CCXRWJ6SIU2WPFEGLFGJVITPL57QAYIMIO6OAM2NBGNDQSSCK2FFV3F3",lendingPool:"CBSGF6QOQAMPFBEVSYPEQHSZRIHJ6RCGUPCRDMUX36DEKRWFAO2PZB5A",aggregatorRouter:"CDNTWMWW2WGYTKIZTJYNGNVQQZI4KTC5BQRZ3275KESRX5T4O3AYECL5",governance:"CDS33JDOYH3F3FL4QUQ6DV4WKHML2AKHF4LADTZ57FRUAEBTE7NMY5FQ",priceAggregator:"CAALOOTIDXCX7D7FMQIBSSAJLPKOM3GMXS4UUSTDIG42JCRRJHOPUHOP",positionNftContract:"CDVN5JU675MEDPVRPCYC45AHFC275UH57WEU5OTFE4WFGZBNN7HTLPSY"}},n=o;function i(e){return o["testnet"===e?"stellarTestnet":"stellarMainnet"]}const a={mainnet:o.stellarMainnet.passphrase,testnet:o.stellarTestnet.passphrase},s=require("@stellar/stellar-sdk");var u=r(287);const l=["Soroswap","Aquarius","Phoenix","Sushi","CometDex"],p={Soroswap:0,Aquarius:1,Phoenix:2,Sushi:3,CometDex:4},d=1e6,c=e=>new s.Address(e).toScVal(),f=e=>new s.ScInt(e).toI128(),h=e=>s.xdr.ScVal.scvU32(e),g=e=>{if("number"==typeof e&&!Number.isSafeInteger(e))throw new Error("Stellar builder: u64 numbers must be safe integers; pass a decimal string for larger values");return new s.ScInt("string"==typeof e?e:e.toString()).toU64()},y=e=>s.xdr.ScVal.scvBool(e),m=e=>s.xdr.ScVal.scvString(e),b=e=>s.xdr.ScVal.scvSymbol(e),S=()=>s.xdr.ScVal.scvVoid(),w=e=>s.xdr.ScVal.scvVec(e),T=(e,t=32)=>{const r=e.startsWith("0x")?e.slice(2):e,o=u.hp.from(r,"hex");if(o.length!==t)throw new Error(`Stellar builder: expected a ${t}-byte BytesN (got ${o.length} bytes from "${e}")`);return s.xdr.ScVal.scvBytes(o)},v=(e,t)=>null==e?S():t(e),x=(e,t)=>E({asset:c(t),hub_id:h(e)}),A=(e,t,r)=>s.xdr.ScVal.scvVec([x(e,t),f(r)]),I=e=>s.xdr.ScVal.scvVec(e.map((e=>A(e.hubId,e.asset,e.amount)))),R=e=>{if("Transfer"===e)return w([b("Transfer")]);if(e&&"object"==typeof e&&"Credit"in e){const t=e.Credit;if("number"==typeof t&&!Number.isInteger(t))throw new Error(`Stellar builder: SeizeMode Credit account id must be an integer u64, got ${t}`);return w([b("Credit"),g(t)])}throw new Error(`Stellar builder: SeizeMode must be 'Transfer' or { Credit: accountId }, got ${JSON.stringify(e)}`)},E=e=>{const t=Object.keys(e).sort().map((t=>new s.xdr.ScMapEntry({key:b(t),val:e[t]})));return s.xdr.ScVal.scvMap(t)};class P{assets=[];amounts=[];ops=[];weights=[];constructor(e){this.amounts.push(e)}asset(e){const t=this.assets.indexOf(e);if(-1!==t)return t;if(this.assets.length>=256)throw new Error("Stellar builder: strategy references more than 256 distinct addresses");return this.assets.push(e),this.assets.length-1}amount(e){if(this.amounts.length>=126)throw new Error("Stellar builder: strategy references too many distinct amounts");return this.amounts.push(e),this.amounts.length-1}weight(e){if(this.weights.length>=32)throw new Error("Stellar builder: strategy uses more than 32 split weights");if(!Number.isInteger(e)||e<=0||e>d)throw new Error(`Stellar builder: split weight ${e} outside 1..=1000000`);return this.weights.push(e),this.weights.length-1}emit(e,t,r,o,n){this.ops.push([e,t,r,o,n])}emitPath(e,t){e.hops.forEach(((r,o)=>{if(r.tokenIn===r.tokenOut)throw new Error("Stellar builder: hop swaps a token for itself");const n=e.hops[o-1];if(n&&r.tokenIn!==n.tokenOut)throw new Error("Stellar builder: hop does not chain onto its predecessor's output");this.emit(p[r.venue],0===o?t:1,this.asset(r.pool),this.asset(r.tokenIn),this.asset(r.tokenOut))}))}lowerPaths(e){const t=e.filter((e=>e.hops.length>0)),r=Array.from({length:t.length},(()=>!1));for(let e=0;e<t.length;e+=1){if(r[e])continue;const o=t[e].hops[0]?.tokenIn,n=[];for(let r=e;r<t.length;r+=1)t[r].hops[0]?.tokenIn===o&&n.push(r);const i=n.reduce(((e,r)=>e+t[r].splitPpm),0);if(i>d)throw new Error(`Stellar builder: split weights for one token sum to ${i}, above 1000000`);const a=i===d;let s=d;n.forEach(((e,o)=>{r[e]=!0;const i=t[e];let u;if(o+1===n.length&&a)u=0;else{if(0===s)throw new Error("Stellar builder: split weights exhaust the group before its last path");const e=Math.floor(i.splitPpm*d/s);s-=Math.min(i.splitPpm,s),u=128+this.weight(e)}this.emitPath(i,u)}))}}toBytes(e,t,r){if(0===this.ops.length)throw new Error("Stellar builder: strategy lowered to zero instructions");if(this.ops.length>48)throw new Error(`Stellar builder: strategy has ${this.ops.length} instructions, the router accepts 48`);const o=[1,e,t,0,r>>>24&255,r>>>16&255,r>>>8&255,255&r,this.ops.length,this.weights.length];for(const e of this.ops)o.push(...e);for(const e of this.weights)o.push(e>>>16&255,e>>>8&255,255&e);return u.hp.from(o)}get assetList(){return this.assets}get amountList(){return this.amounts}}const k=e=>{const t=new P(e.totalMinOut),r=t.asset(e.tokenIn),o=t.asset(e.tokenOut);if(r===o)throw new Error("Stellar builder: `tokenIn` and `tokenOut` are the same asset");if(e.burnPool){const o=t.asset(e.burnPool),n=t.amountList.length;for(const r of e.burnMinAmounts??[])t.amount(r);t.emit(5,0,o,r,n)}if(t.lowerPaths(e.paths),e.mintPool){const r=e.preSwapAmount;if(r&&BigInt(r)>0n){const o=e.mintPoolTokens;if(!o||2!==o.length)throw new Error("Stellar builder: `preSwapAmount` needs `mintPoolTokens` to name the pool’s two constituents");const[n,i]=o,[a,s]=e.preSwapFromA?[n,i]:[i,n];t.emit(p.Aquarius,2+t.amount(r),t.asset(e.mintPool),t.asset(a),t.asset(s))}t.emit(6,0,t.asset(e.mintPool),o,t.amount(e.mintMinShares??"1"))}const n=Number(e.referralId??0);if(!Number.isInteger(n)||n<0||n>4294967295)throw new Error(`Stellar builder: referral id ${e.referralId} does not fit the wire’s u32`);return E({amounts:s.xdr.ScVal.scvVec(t.amountList.map((e=>f(e)))),assets:s.xdr.ScVal.scvVec(t.assetList.map((e=>c(e)))),ops:s.xdr.ScVal.scvBytes(t.toBytes(r,o,n))})},q=e=>{const t=u.hp.from(e);if(0===t.length)throw new Error("Stellar builder: strategy swap bytes must be non-empty base64 routeXdr, 0x hex string, or Uint8Array");return s.xdr.ScVal.scvBytes(t)},B=()=>s.xdr.ScVal.scvBytes(u.hp.alloc(0)),_=e=>{const t=e.trim();if(t.startsWith("0x")){const e=t.slice(2);if(!((r=e).length>0&&r.length%2==0&&/^[0-9a-fA-F]+$/.test(r)))throw new Error("Stellar builder: strategy swap bytes hex string must be 0x-prefixed and even-length");return u.hp.from(e,"hex")}var r;if(!/^[A-Za-z0-9+/]+={0,2}$/.test(t))throw new Error("Stellar builder: strategy swap bytes must be base64 routeXdr or 0x-prefixed hex");const o=u.hp.from(t,"base64");if(0===o.length)throw new Error("Stellar builder: strategy swap bytes must be non-empty base64 routeXdr, 0x hex string, or Uint8Array");return o},O=e=>{if("string"==typeof e)return q(_(e));if(e instanceof Uint8Array)return 0===e.length?B():q(e);if(e&&"object"==typeof e)return"routeXdr"in(r=e)&&"string"==typeof r.routeXdr?q(_(e.routeXdr)):(e=>"swapXdr"in e&&"string"==typeof e.swapXdr)(e)?q(_(e.swapXdr)):(e=>"bytes"in e&&("string"==typeof e.bytes||e.bytes instanceof Uint8Array))(e)?"string"==typeof e.bytes?q(_(e.bytes)):0===e.bytes.length?B():q(e.bytes):(t=(e=>{if(!e||"object"!=typeof e)throw new Error("Stellar builder: decoded strategy `steps` must be a StrategyPayload ({ paths, tokenIn, tokenOut, totalMinOut })");const t=e;if(!Array.isArray(t.paths)||0===t.paths.length&&!t.burnPool&&!t.mintPool)throw new Error("Stellar builder: `steps.paths` needs a strategy path or a liquidity burn/mint operation");if("string"!=typeof t.tokenIn)throw new Error("Stellar builder: `steps.tokenIn` must be a contract address");if("string"!=typeof t.tokenOut)throw new Error("Stellar builder: `steps.tokenOut` must be a contract address");if("string"!=typeof t.totalMinOut)throw new Error("Stellar builder: `steps.totalMinOut` must be an i128 decimal string");const r=new Map;for(const[e,o]of t.paths.entries()){if(!o||"number"!=typeof o.splitPpm||o.splitPpm<=0||!Array.isArray(o.hops)||0===o.hops.length)throw new Error(`Stellar builder: \`steps.paths[${e}]\` must have splitPpm > 0 and a non-empty hops array`);for(const[t,r]of o.hops.entries())if(!r||"string"!=typeof r.pool||"string"!=typeof r.tokenIn||"string"!=typeof r.tokenOut||!l.includes(r.venue))throw new Error(`Stellar builder: \`steps.paths[${e}].hops[${t}]\` must have pool, tokenIn, tokenOut, and a valid Soroban venue`);const t=o.hops[0];r.set(t.tokenIn,(r.get(t.tokenIn)??0)+o.splitPpm)}for(const[e,o]of r){if(o>d)throw new Error(`Stellar builder: \`steps.paths[].splitPpm\` for ${e} sums to ${o}, above 1000000`);if(!t.mintPool&&o!==d)throw new Error(`Stellar builder: \`steps.paths[].splitPpm\` for ${e} must sum to 1000000, got ${o}`)}return t})(e),s.xdr.ScVal.scvBytes(u.hp.from(k(t).toXDR("base64"),"base64")));var t,r;throw new Error("Stellar builder: `steps` must be opaque strategy bytes (`routeXdr`, base64/hex string, or Uint8Array)")},U=e=>{if("string"==typeof e)return(e=>{const t=e.startsWith("0x")?e.slice(2):e,r=u.hp.from(t,"hex");return s.xdr.ScVal.scvBytes(r)})(e);if(e instanceof Uint8Array)return s.xdr.ScVal.scvBytes(u.hp.from(e));throw new Error("Stellar builder: `data` must be a hex string or Uint8Array (Soroban Bytes payload)")};function M(e,t,r){if(!e.controllerAddress)throw new Error("Stellar lending controllerAddress is required");const o=new s.Contract(e.controllerAddress),n=new s.Account(e.caller,e.sourceSequence);return{xdr:new s.TransactionBuilder(n,{fee:e.fee??s.BASE_FEE,networkPassphrase:a[e.network]}).addOperation(o.call(t,...r)).setTimeout(e.timeoutSeconds??300).build().toXDR()}}function C(e){if(!Number.isInteger(e)||e<1||e>4294967295)throw new Error("Stellar builder: spokeId must be an integer from 1 to 4294967295");return h(e)}function L(e,t){const r=t.accountNonce??0;return M(e,"supply",[c(e.caller),g(r),C(t.spokeId),I([...t.assets])])}function D(e,t){return L(e,{accountNonce:t.accountNonce,spokeId:t.spokeId,assets:[{hubId:t.hubId,asset:t.asset,amount:t.amount}]})}function $(e,t){return M(e,"borrow",[c(e.caller),g(t.accountNonce),I([...t.borrows]),v(t.to,c)])}function N(e,t){return $(e,{accountNonce:t.accountNonce,borrows:[{hubId:t.hubId,asset:t.asset,amount:t.amount}],to:t.to})}function W(e,t){return M(e,"withdraw",[c(e.caller),g(t.accountNonce),I([...t.withdrawals]),v(t.to,c)])}function F(e,t){return W(e,{accountNonce:t.accountNonce,withdrawals:[{hubId:t.hubId,asset:t.asset,amount:t.amount}],to:t.to})}function G(e,t){return M(e,"repay",[c(e.caller),g(t.accountNonce),I([...t.payments])])}function H(e,t){return G(e,{accountNonce:t.accountNonce,payments:[{hubId:t.hubId,asset:t.asset,amount:t.amount}]})}function z(e,t){return M(e,"liquidate",[c(e.caller),g(t.accountNonce),I([...t.debtPayments]),R(t.seizeMode??"Transfer")])}function V(e){const t=(0,s.scValToNative)(s.xdr.ScVal.fromXDR(e,"base64"));if("bigint"==typeof t||"number"==typeof t)return t.toString();throw new Error("Stellar builder: liquidate return value must be a u64, got "+typeof t)}function X(e,t){return M(e,"flash_loan",[c(e.caller),x(t.hubId,t.asset),f(t.amount),c(t.receiver),U(t.data)])}function j(e,t){return M(e,"migrate_from_blend",[c(e.caller),g(t.accountId),C(t.spokeId),h(t.hubId),c(t.blendPool),w(t.collateralTokens.map(c)),w(t.supplyTokens.map(c)),(r=t.debtCaps.map((e=>({token:e.token,amount:e.cap}))),s.xdr.ScVal.scvVec(r.map((e=>{return t=e.token,r=e.amount,s.xdr.ScVal.scvVec([c(t),f(r)]);var t,r}))))]);var r}function K(e,t){const r=t.accountNonce??0;return M(e,"multiply",[c(e.caller),g(r),C(t.spokeId),x(t.collateral.hubId,t.collateral.asset),f(t.debtToFlashLoan),x(t.debt.hubId,t.debt.asset),h(t.mode),O(t.steps),v(t.initialPayment,(e=>A(e.hubId,e.asset,e.amount))),v(t.convertSwap,O)])}function Z(e,t){return M(e,"swap_debt",[c(e.caller),g(t.accountNonce),x(t.existingDebt.hubId,t.existingDebt.asset),f(t.newDebtAmount),x(t.newDebt.hubId,t.newDebt.asset),O(t.steps)])}function Y(e,t){return M(e,"swap_collateral",[c(e.caller),g(t.accountNonce),x(t.current.hubId,t.current.asset),f(t.fromAmount),x(t.newCollateral.hubId,t.newCollateral.asset),O(t.steps)])}function Q(e,t){return M(e,"repay_debt_with_collateral",[c(e.caller),g(t.accountNonce),x(t.collateral.hubId,t.collateral.asset),f(t.collateralAmount),x(t.debt.hubId,t.debt.asset),O(t.steps),y(t.closePosition)])}const J="/stellar-lending",ee=encodeURIComponent,te=(e,t)=>e.fetchWithTimeout(`${J}/context`,t),re=(e,t)=>e.fetchWithTimeout(`${J}/live-state`,t),oe=(e,t)=>e.fetchWithTimeout(`${J}/markets/detailed`,t),ne=(e,t)=>e.fetchWithTimeout(`${J}/assets`,t),ie=(e,t)=>e.fetchWithTimeout(`${J}/hubs`,t),ae=(e,t)=>e.fetchWithTimeout(`${J}/spokes`,t),se=(e,t={},r)=>e.fetchWithTimeout(`${J}/reserves`,{...r,params:{...t}}),ue=(e,t,r,o,n)=>e.fetchWithTimeout(`${J}/reserves/${t}/${r}/${ee(o)}`,n),le=(e,t,r)=>e.fetchWithTimeout(`${J}/assets/${ee(t)}`,r),pe=(e,t,r)=>e.fetchWithTimeout(`${J}/hubs/${t}`,r),de=(e,t,r)=>e.fetchWithTimeout(`${J}/spokes/${t}`,r),ce=(e,t,r)=>e.fetchWithTimeout(`${J}/users/${ee(t)}/positions`,r),fe=(e,t,r)=>e.fetchWithTimeout(`${J}/accounts/${ee(t)}/positions`,r),he=(e,t,r,o)=>e.fetchWithTimeout(`${J}/users/${ee(t)}/assets/${ee(r)}/balance`,o),ge=(e,t,r,o)=>e.fetchWithTimeout(`${J}/assets/${ee(t)}/page`,{...o,params:{...r}}),ye=(e,t,r,o)=>e.fetchWithTimeout(`${J}/assets/${ee(t)}/markets`,{...o,params:{side:r}}),me=(e,t,r,o,n,i)=>e.fetchWithTimeout(`${J}/reserves/${t}/${r}/${ee(o)}/holders`,{...i,params:{side:n}}),be=(e,t,r,o)=>e.fetchWithTimeout(`${J}/hubs/${t}/holders`,{...o,params:{side:r}}),Se=(e,t,r,o)=>e.fetchWithTimeout(`${J}/spokes/${t}/holders`,{...o,params:{side:r}}),we=(e,t,r,o)=>e.fetchWithTimeout(`${J}/assets/${ee(t)}/graph`,{...o,params:{...r}}),Te=(e,t,r,o)=>e.fetchWithTimeout(`${J}/hubs/${t}/graph`,{...o,params:{...r}}),ve=(e,t,r,o)=>e.fetchWithTimeout(`${J}/spokes/${t}/graph`,{...o,params:{...r}}),xe=(e,t,r,o,n,i)=>e.fetchWithTimeout(`${J}/reserves/${t}/${r}/${ee(o)}/graph`,{...i,params:{...n}}),Ae=(e,t,r={},o)=>e.fetchWithTimeout(`${J}/users/${ee(t)}/activity`,{...o,params:{...r}}),Ie=(e,t,r={},o)=>e.fetchWithTimeout(`${J}/users/${ee(t)}/activity/page`,{...o,params:{...r}}),Re=(e,t={},r)=>e.fetchWithTimeout(`${J}/governance/proposals`,{...r,params:{...t}}),Ee=(e,t={},r)=>e.fetchWithTimeout(`${J}/positions`,{...r,params:{...t}}),Pe=(e,t={},r)=>e.fetchWithTimeout(`${J}/participants`,{...r,params:{...t}}),ke=(e,t={},r)=>e.fetchWithTimeout(`${J}/liquidations/leaderboard`,{...r,params:{...t}}),qe=(e,t={},r)=>e.fetchWithTimeout(`${J}/distribution`,{...r,params:{...t}}),Be=(e,t={},r)=>e.fetchWithTimeout(`${J}/campaign/leaderboard`,{...r,params:{...t}}),_e=(e,t,r)=>e.fetchWithTimeout(`${J}/stats/history`,{...r,params:{...t}}),Oe=(e,t,r)=>e.fetchWithTimeout(`${J}/revenue`,{...r,params:{...t}}),Ue=(e,t,r)=>e.fetchWithTimeout(`${J}/revenue/fees`,{...r,params:{...t}}),Me=(e,t,r)=>e.fetchWithTimeout(`${J}/liquidations`,{...r,params:{...t}}),Ce=(e,t,r)=>e.fetchWithTimeout(`${J}/volume`,{...r,params:{...t}}),Le=(e,t,r)=>e.fetchWithTimeout(`${J}/active-users`,{...r,params:{...t}}),De=(e,t,r)=>e.fetchWithTimeout(`${J}/rate-spread`,{...r,params:{...t}}),$e=(e,t,r)=>e.fetchWithTimeout(`${J}/defillama`,{...r,params:{...t}}),Ne=(e,t,r,o)=>e.fetchWithTimeout(`${J}/users/${ee(t)}/history`,{...o,params:{...r}}),We=(e,t,r)=>e.fetchWithTimeout(`${J}/pnl`,{...r,params:{accountId:t}}),Fe=(e,t,r)=>e.fetchWithTimeout(`${J}/pnl/scope`,{...r,params:{scope:t}}),Ge=(e,t,r)=>e.fetchWithTimeout(`${J}/campaign/me`,{...r,params:{owner:t}}),He=e=>({context:t=>te(e,t),liveState:t=>re(e,t),marketsDetailed:t=>oe(e,t),assets:t=>ne(e,t),hubs:t=>ie(e,t),spokes:t=>ae(e,t),reserves:(t={},r)=>void 0!==r||"hubId"in t||"spokeId"in t||"asset"in t?se(e,t,r):se(e,{},t),reserve:(t,r,o,n)=>ue(e,t,r,o,n),asset:(t,r)=>le(e,t,r),hub:(t,r)=>pe(e,t,r),spoke:(t,r)=>de(e,t,r),userPositions:(t,r)=>ce(e,t,r),accountPositions:(t,r)=>fe(e,t,r),walletBalance:(t,r,o)=>he(e,t,r,o),assetPage:(t,r,o)=>ge(e,t,r,o),assetMarkets:(t,r,o)=>ye(e,t,r,o),reserveHolders:(t,r,o,n,i)=>me(e,t,r,o,n,i),hubHolders:(t,r,o)=>be(e,t,r,o),spokeHolders:(t,r,o)=>Se(e,t,r,o),assetGraph:(t,r,o)=>we(e,t,r,o),hubGraph:(t,r,o)=>Te(e,t,r,o),spokeGraph:(t,r,o)=>ve(e,t,r,o),reserveGraph:(t,r,o,n,i)=>xe(e,t,r,o,n,i),userActivity:(t,r={},o)=>Ae(e,t,r,o),userActivityPage:(t,r={},o)=>Ie(e,t,r,o),governanceProposals:(t={},r)=>Re(e,t,r),positionsLeaderboard:(t={},r)=>Ee(e,t,r),participants:(t={},r)=>Pe(e,t,r),liquidationsLeaderboard:(t={},r)=>ke(e,t,r),distribution:(t={},r)=>qe(e,t,r),campaignLeaderboard:(t={},r)=>Be(e,t,r),statsHistory:(t,r)=>_e(e,t,r),revenue:(t,r)=>Oe(e,t,r),feeRevenue:(t,r)=>Ue(e,t,r),liquidations:(t,r)=>Me(e,t,r),volume:(t,r)=>Ce(e,t,r),activeUsers:(t,r)=>Le(e,t,r),rateSpread:(t,r)=>De(e,t,r),defillama:(t,r)=>$e(e,t,r),userHistory:(t,r,o)=>Ne(e,t,r,o),positionsPnl:(t,r)=>We(e,t,r),pnlByScope:(t,r)=>Fe(e,t,r),campaignMe:(t,r)=>Ge(e,t,r)}),ze=e=>E({base_borrow_rate:f(e.baseBorrowRateRay),max_borrow_rate:f(e.maxBorrowRateRay),max_utilization:f(e.maxUtilizationRay),mid_utilization:f(e.midUtilizationRay),optimal_utilization:f(e.optimalUtilizationRay),reserve_factor:h(e.reserveFactorBps),slope1:f(e.slope1Ray),slope2:f(e.slope2Ray),slope3:f(e.slope3Ray)}),Ve=e=>E({asset_decimals:h(e.assetDecimals),asset_id:c(e.assetId),base_borrow_rate:f(e.baseBorrowRateRay),flashloan_fee:h(e.flashloanFeeBps),is_flashloanable:y(e.isFlashloanable),max_borrow_rate:f(e.maxBorrowRateRay),max_utilization:f(e.maxUtilizationRay),mid_utilization:f(e.midUtilizationRay),optimal_utilization:f(e.optimalUtilizationRay),reserve_factor:h(e.reserveFactorBps),slope1:f(e.slope1Ray),slope2:f(e.slope2Ray),slope3:f(e.slope3Ray)}),Xe=e=>E({max_borrow_positions:h(e.maxBorrowPositions),max_supply_positions:h(e.maxSupplyPositions)}),je=e=>{if("Token"in e&&e.Token)return w([b("Token"),c(e.Token)]);if("Ref"in e&&e.Ref)return w([b("Ref"),b(e.Ref)]);throw new Error(`Stellar builder: PriceKey must be { Token } or { Ref }, got ${JSON.stringify(e)}`)},Ke=e=>{if("Stellar"in e)return w([b("Stellar"),c(e.Stellar)]);if("Symbol"in e)return w([b("Symbol"),b(e.Symbol)]);if("String"in e)return w([b("String"),m(e.String)]);throw new Error(`Stellar builder: unknown OracleAssetRef ${JSON.stringify(e)}`)},Ze=e=>{if("Spot"===e)return w([b("Spot")]);if(e&&"object"==typeof e&&"Twap"in e)return w([b("Twap"),h(Number(e.Twap))]);throw new Error(`Stellar builder: unknown OracleReadMode ${JSON.stringify(e)}`)},Ye=e=>{if("Reflector"===e||"RedStone"===e||"Xoxno"===e)return w([b(e)]);throw new Error(`Stellar builder: unknown ProviderKind "${e}"`)},Qe=e=>{if("Market"===e||"Fundamental"===e)return w([b(e)]);throw new Error(`Stellar builder: unknown FeedNature "${e}"`)},Je=e=>{if("Reflector"in e){const t=e.Reflector;return w([b("Reflector"),E({asset:Ke(t.asset),contract:c(t.contract),read_mode:Ze(t.readMode)})])}if("MultiFeed"in e){const t=e.MultiFeed;return w([b("MultiFeed"),E({contract:c(t.contract),feed_id:m(t.feedId),kind:Ye(t.kind),nature:Qe(t.nature)})])}throw new Error(`Stellar builder: unknown ProviderRef ${JSON.stringify(e)}`)},et=e=>{const t=e;return E({decimals:h(t.decimals),max_stale_seconds:g(t.maxStaleSeconds),provider:Je(t.provider)})},tt=e=>{if("RequireDisjoint"===e)return w([b("RequireDisjoint")]);if(e&&"object"==typeof e&&"AllowShared"in e){const t=e.AllowShared;return w([b("AllowShared"),w(t.map((e=>E({contract:c(e.contract),kind:Ye(e.kind)}))))])}throw new Error(`Stellar builder: unknown IndependencePolicy ${JSON.stringify(e)}`)},rt=e=>{const t=e,r=t.sources??[];let o,n;if("number"==typeof t.toleranceBps)o=1e4+t.toleranceBps,n=Math.max(1,Math.floor(1e8/o));else{const e=t.tolerance??{};o=Number(e.upperRatioBps),n=Number(e.lowerRatioBps)}return E({asset_decimals:h(Number(t.assetDecimals)),independence:tt(t.independence),max_price_stale_seconds:g(Number(t.maxPriceStaleSeconds)),max_sanity_price_wad:f(String(t.maxSanityPriceWad)),min_sanity_price_wad:f(String(t.minSanityPriceWad)),sources:w(r.map((e=>(e=>{if("Feed"in e)return w([b("Feed"),et(e.Feed)]);if("Scaled"in e){const t=e.Scaled;return w([b("Scaled"),E({factor:et(t.factor),max_factor_wad:f(t.maxFactorWad),min_factor_wad:f(t.minFactorWad),quote:je(t.quote)})])}if("LpShare"in e){const t=e.LpShare;return w([b("LpShare"),E({key_a:je(t.keyA),key_b:je(t.keyB),kind:w([b(t.kind||"ConstantProduct")]),pool:c(t.pool),reserve_a_decimals:h(t.reserveADecimals),reserve_b_decimals:h(t.reserveBDecimals),share_decimals:h(t.shareDecimals)})])}throw new Error(`Stellar builder: unknown PriceSource ${JSON.stringify(e)}`)})(e)))),tolerance:E({lower_ratio_bps:h(n),upper_ratio_bps:h(o)})})},ot=rt;function nt(e,t){return M(e,"upgrade",[T(t.wasmHash)])}function it(e,t){return M(e,"migrate",[h(t.newVersion)])}function at(e){return M(e,"pause",[])}function st(e){return M(e,"unpause",[])}function ut(e,t){return M(e,"grant_role",[c(t.account),b(t.role)])}function lt(e,t){return M(e,"revoke_role",[c(t.account),b(t.role)])}function pt(e,t){return M(e,"transfer_ownership",[c(t.newOwner),h(t.liveUntilLedger)])}function dt(e){return M(e,"accept_ownership",[])}function ct(e,t){return M(e,"set_swap_aggregator",[c(t.aggregator)])}function ft(e,t){return M(e,"set_price_aggregator",[c(t.aggregator)])}const ht=ct;function gt(e,t){return M(e,"set_accumulator",[c(t.accumulator)])}function yt(e,t){return M(e,"set_position_limits",[Xe(t)])}function mt(e,t){return M(e,"approve_blend_pool",[c(t.pool)])}function bt(e,t){return M(e,"revoke_blend_pool",[c(t.pool)])}const St=mt,wt=bt;function Tt(e,t){return M(e,"set_oracle",[je(t.key),rt(t.oracle)])}const vt=Tt;function xt(e,t){const r=t.toleranceBps,o=t.upperRatioBps??1e4+r,n=t.lowerRatioBps??Math.max(1,Math.floor(1e8/o));return M(e,"set_tolerance",[je(t.key),E({lower_ratio_bps:h(n),upper_ratio_bps:h(o)})])}function At(e,t){return M(e,"set_spoke_asset_flags",[h(t.spokeId),x(t.hubId,t.asset),y(t.paused),y(t.frozen),y(t.noSeize)])}function It(e,t){return M(e,"set_oracle_sanity_bounds",[c(t.asset),f(t.minPriceWad),f(t.maxPriceWad)])}function Rt(e,t){return M(e,"update_indexes",[c(e.caller),w(t.assets.map((e=>x(e.hubId,e.asset))))])}function Et(e,t){return M(e,"renew_account",[c(e.caller),g(t.accountNonce)])}function Pt(e,t){return M(e,"create_liquidity_pool",[h(t.hubId),c(t.asset),Ve(t.params)])}function kt(e,t){return M(e,"upgrade_liquidity_pool_params",[x(t.hubId,t.asset),ze(t.params)])}function qt(e,t){return M(e,"claim_revenue",[c(e.caller),w(t.assets.map((e=>x(e.hubId,e.asset))))])}function Bt(e,t){return M(e,"add_rewards",[c(e.caller),I(t.rewards)])}function _t(e,t){return M(e,"update_account_threshold",[c(e.caller),y(t.hasRisks),w(t.accountNonces.map((e=>g(e))))])}const Ot="00".repeat(32),Ut=e=>{if("string"==typeof e)return T(e);const t=u.hp.from(e);if(32!==t.length)throw new Error(`Stellar governance builder: expected a 32-byte salt (got ${t.length} bytes)`);return s.xdr.ScVal.scvBytes(t)},Mt=(e,...t)=>w([b(e),...t]),Ct=e=>E({new_owner:c(e.newOwner),live_until_ledger:h(e.liveUntilLedger)}),Lt=e=>E({asset:c(e.asset),bonus:h(e.bonus),borrow_cap:f(e.borrowCap),can_borrow:y(e.canBorrow),can_collateral:y(e.canCollateral),frozen:y(e.frozen),hub_id:h(e.hubId),paused:y(e.paused),liquidation_fees:h(e.liquidationFees),ltv:h(e.ltv),no_seize:y(e.noSeize),spoke_id:h(e.spokeId),supply_cap:f(e.supplyCap),threshold:h(e.threshold)}),Dt=e=>E({account:c(e.account),role:b(e.role)});function $t(e,t,r){if(!e.governanceAddress)throw new Error("Stellar governanceAddress is required");const o=new s.Contract(e.governanceAddress),n=new s.Account(e.caller,e.sourceSequence);return{xdr:new s.TransactionBuilder(n,{fee:e.fee??s.BASE_FEE,networkPassphrase:a[e.network]}).addOperation(o.call(t,...r)).setTimeout(e.timeoutSeconds??300).build().toXDR()}}const Nt=(e,t,r)=>$t(e,"propose",[c(e.caller),t,Ut(r)]),Wt=(e,t,r)=>$t(e,"execute_self",[S(),t,Ut(r)]);function Ft(e,t,r){return Nt(e,Mt("SetSwapAggregator",c(t.aggregator)),r)}function Gt(e,t,r){return Nt(e,Mt("SetPriceAggregator",c(t.aggregator)),r)}const Ht=Ft;function zt(e,t,r){return Nt(e,Mt("SetAccumulator",c(t.accumulator)),r)}function Vt(e,t,r){return Nt(e,Mt("SetPositionLimits",Xe(t)),r)}function Xt(e,t){return Nt(e,Mt("CreateHub"),t)}function jt(e,t){return Nt(e,Mt("AddSpoke"),t)}function Kt(e,t,r){return Nt(e,Mt("RemoveSpoke",h(t.spokeId)),r)}function Zt(e,t,r){return Nt(e,Mt("AddAssetToSpoke",Lt(t)),r)}function Yt(e,t,r){return Nt(e,Mt("EditAssetInSpoke",Lt(t)),r)}function Qt(e,t,r){return Nt(e,Mt("RemoveAssetFromSpoke",E({hub_asset:x((o=t).hubId,o.asset),spoke_id:h(o.spokeId)})),r);var o}function Jt(e,t,r){return Nt(e,Mt("SetSpokeLiquidationCurve",E({hf_for_max_bonus_wad:f((o=t).hfForMaxBonusWad),liquidation_bonus_factor_bps:h(o.liquidationBonusFactorBps),spoke_id:h(o.spokeId),target_hf_wad:f(o.targetHfWad)})),r);var o}function er(e,t,r){return Nt(e,Mt("SetPositionManager",c(t.manager),y(t.isActive)),r)}function tr(e,t,r){return Nt(e,Mt("SetMinBorrowCollateralUsd",f(t.floorWad)),r)}function rr(e,t,r){return Nt(e,Mt("ApproveToken",c(t.token)),r)}function or(e,t,r){return Nt(e,Mt("RevokeToken",c(t.token)),r)}function nr(e,t,r){return Nt(e,Mt("ApproveBlendPool",c(t.pool)),r)}function ir(e,t,r){return Nt(e,Mt("RevokeBlendPool",c(t.pool)),r)}function ar(e,t,r){return Nt(e,Mt("CreateLiquidityPool",E({asset:c((o=t).asset),hub_id:h(o.hubId),params:Ve(o.params)})),r);var o}function sr(e,t,r){return Nt(e,Mt("UpgradeLiquidityPoolParams",E({hub_asset:x((o=t).hubId,o.asset),params:ze(o.params)})),r);var o}function ur(e,t,r){return Nt(e,Mt("DeployPool",T(t.wasmHash)),r)}function lr(e,t,r){return Nt(e,Mt("UpgradePool",T(t.wasmHash)),r)}function pr(e,t,r){return Nt(e,Mt("UpgradeController",T(t.wasmHash)),r)}function dr(e,t,r){return Nt(e,Mt("MigrateController",h(t.newVersion)),r)}function cr(e,t,r){return Nt(e,Mt("TransferCtrlOwnership",Ct(t)),r)}function fr(e,t,r){return Nt(e,Mt("ConfigureAssetOracle",E({key:je((o=t).key),oracle:rt(o.oracle)})),r);var o}const hr=fr;function gr(e,t,r){return Nt(e,Mt("EditOracleTolerance",E({key:je((o=t).key),tolerance:h(o.tolerance)})),r);var o}function yr(e,t,r){return Nt(e,Mt("UpgradeGov",T(t.wasmHash)),r)}function mr(e,t,r){return Nt(e,Mt("UpdateGovDelay",h(t.newDelay)),r)}function br(e,t,r){return Nt(e,Mt("GrantGovRole",Dt(t)),r)}function Sr(e,t,r){return Nt(e,Mt("RevokeGovRole",Dt(t)),r)}function wr(e,t,r){return Nt(e,Mt("TransferGovOwnership",Ct(t)),r)}function Tr(e,t){const r=w(t.argsXdr.map((e=>s.xdr.ScVal.fromXDR(e,"base64")))),o=Ut(t.predecessor??Ot);return $t(e,"execute",[S(),c(t.target),b(t.functionName),r,o,Ut(t.salt)])}function vr(e,t,r){return Wt(e,Mt("UpgradeGov",T(t.wasmHash)),r)}function xr(e,t,r){return Wt(e,Mt("UpdateGovDelay",h(t.newDelay)),r)}function Ar(e,t,r){return Wt(e,Mt("GrantGovRole",Dt(t)),r)}function Ir(e,t,r){return Wt(e,Mt("RevokeGovRole",Dt(t)),r)}function Rr(e,t,r){return Wt(e,Mt("TransferGovOwnership",Ct(t)),r)}const Er=e=>w(e.map(c));function Pr(e,t,r){return $t(e,"propose_canceller_reset",[Er(t.newCancellers),Ut(r)])}function kr(e,t,r){return $t(e,"execute_canceller_reset",[v(t.executor,c),Er(t.newCancellers),Ut(r)])}function qr(e,t){return $t(e,"set_spoke_asset_flags",[c(e.caller),h(t.spokeId),x(t.hubId,t.asset),y(t.paused),y(t.frozen),y(t.noSeize)])}function Br(e,t){return $t(e,"set_oracle_sanity_bounds",[c(e.caller),c(t.asset),f(t.minPriceWad),f(t.maxPriceWad)])}function _r(e){return $t(e,"create_hub",[c(e.caller)])}function Or(e){return $t(e,"add_spoke",[c(e.caller)])}function Ur(e,t){return $t(e,"revoke_role_immediate",[c(t.account),b(t.role)])}function Mr(e){return $t(e,"pause",[c(e.caller)])}function Cr(e,t){return Nt(e,Mt("Unpause"),t)}const Lr=e=>e.toXDR("base64"),Dr=e=>s.xdr.ScVal.fromXDR(e,"base64"),$r=e=>e.map((e=>String((0,s.scValToNative)(Dr(e))))).join(":"),Nr=e=>"bigint"==typeof e||"number"==typeof e?e.toString():String(e),Wr=e=>Number(e),Fr=e=>String(e),Gr=e=>e instanceof Uint8Array?u.hp.from(e).toString("hex"):u.hp.isBuffer(e)?e.toString("hex"):String(e),Hr=["None","Multiply","Long","Short"],zr=["supply","borrow","withdraw","repay","liq_repay","liq_seize","multiply","param_upd","sw_debt_r","sw_col_wd","rp_col_wd","rp_col_r","close_wd","migrate","rp_col_net","liq_credit"],Vr=e=>Array.isArray(e)?e:[],Xr=(e,t)=>{const r="Borrow"===t;return{action:(o=e[0],zr[Wr(o)]??Nr(o)),positionType:t,hubId:Wr(e[1]),asset:Fr(e[2]),scaledAmountRay:Nr(e[3]),indexRay:Nr(e[4]),amount:Nr(e[5]),liquidationThresholdBps:r?void 0:Wr(e[6]),liquidationBonusBps:r?void 0:Wr(e[7]),loanToValueBps:r?void 0:Wr(e[8]),liquidationFeesBps:r?void 0:Wr(e[9])};var o},jr=e=>{return{owner:Fr(e[0]),spokeId:Wr(e[1]),mode:(t=e[2],Hr[Wr(t)]??"None")};var t},Kr=e=>Array.isArray(e)?e[1]:void 0,Zr=e=>{const t=(r=e,Array.isArray(r)?Fr(r[0]):Fr(r));var r;if("Token"===t)return{Token:Fr(Kr(e))};if("Ref"===t)return{Ref:Fr(Kr(e))};if(e&&"object"==typeof e&&!Array.isArray(e)){const t=e;if(void 0!==t.Token)return{Token:Fr(t.Token)};if(void 0!==t.Ref)return{Ref:Fr(t.Ref)}}return{Token:Fr(e)}},Yr=e=>{const t=e.tolerance??{};return{assetDecimals:Wr(e.asset_decimals),maxPriceStaleSeconds:Wr(e.max_price_stale_seconds),sources:Vr(e.sources).map((e=>e)),tolerance:{upperRatio:Wr(t.upper_ratio_bps),lowerRatio:Wr(t.lower_ratio_bps)},independence:e.independence,minSanityPriceWad:Nr(e.min_sanity_price_wad),maxSanityPriceWad:Nr(e.max_sanity_price_wad)}},Qr={"market:create":e=>({topic:"market:create",data:{hubId:Wr(e.hub_id),baseAsset:Fr(e.base_asset),maxBorrowRate:Nr(e.max_borrow_rate),baseBorrowRate:Nr(e.base_borrow_rate),slope1:Nr(e.slope1),slope2:Nr(e.slope2),slope3:Nr(e.slope3),midUtilization:Nr(e.mid_utilization),optimalUtilization:Nr(e.optimal_utilization),maxUtilization:Nr(e.max_utilization),reserveFactor:Wr(e.reserve_factor),marketAddress:Fr(e.market_address)}}),"market:params_update":e=>({topic:"market:params_update",data:{asset:Fr(e.asset),maxBorrowRateRay:Nr(e.max_borrow_rate),baseBorrowRateRay:Nr(e.base_borrow_rate),slope1Ray:Nr(e.slope1),slope2Ray:Nr(e.slope2),slope3Ray:Nr(e.slope3),midUtilizationRay:Nr(e.mid_utilization),optimalUtilizationRay:Nr(e.optimal_utilization),maxUtilizationRay:Nr(e.max_utilization),reserveFactorBps:Wr(e.reserve_factor)}}),"market:batch_state_update":e=>({topic:"market:batch_state_update",data:{updates:Vr(e).map((e=>{return t=Vr(e),{hubId:Wr(t[0]),asset:Fr(t[1]),timestamp:Wr(t[2]),supplyIndexRay:Nr(t[3]),borrowIndexRay:Nr(t[4]),cash:Nr(t[5]),suppliedRay:Nr(t[6]),borrowedRay:Nr(t[7]),revenueRay:Nr(t[8])};var t}))}}),"market:batch_params_update":e=>({topic:"market:batch_params_update",data:{updates:Vr(e).map((e=>{const t=e;return{hubId:Wr(t.hub_id),asset:Fr(t.asset),params:(r=t.params,{maxBorrowRateRay:Nr(r.max_borrow_rate),baseBorrowRateRay:Nr(r.base_borrow_rate),slope1Ray:Nr(r.slope1),slope2Ray:Nr(r.slope2),slope3Ray:Nr(r.slope3),midUtilizationRay:Nr(r.mid_utilization),optimalUtilizationRay:Nr(r.optimal_utilization),maxUtilizationRay:Nr(r.max_utilization),reserveFactorBps:Wr(r.reserve_factor),isFlashloanable:Boolean(r.is_flashloanable),flashloanFeeBps:Wr(r.flashloan_fee),assetId:Fr(r.asset_id),assetDecimals:Wr(r.asset_decimals)})};var r}))}}),"position:batch_update":e=>{const t=Vr(e);return{topic:"position:batch_update",data:{accountId:Nr(t[0]),accountAttributes:jr(Vr(t[1])),updates:[...Vr(t[2]).map((e=>Xr(Vr(e),"Deposit"))),...Vr(t[3]).map((e=>Xr(Vr(e),"Borrow")))]}}},"position:flash_loan":e=>({topic:"position:flash_loan",data:{hubId:Wr(e.hub_id),asset:Fr(e.asset),receiver:Fr(e.receiver),caller:Fr(e.caller),amount:Nr(e.amount),fee:Nr(e.fee)}}),"config:asset_oracle":e=>({topic:"config:asset_oracle",data:{key:Zr(e.key),oracle:Yr(e.oracle)}}),"config:oracle":e=>({topic:"config:oracle",data:{asset:Fr(e.asset),oracle:Yr(e.config??e.oracle)}}),"position:liquidation":e=>({topic:"position:liquidation",data:{liquidator:Fr(e.liquidator),accountId:Nr(e.account_id),repaidUsdWad:Nr(e.repaid_usd_wad),bonusBps:Nr(e.bonus_bps)}}),"debt:bad_debt":e=>({topic:"debt:bad_debt",data:{accountId:Nr(e.account_id),totalBorrowUsdWad:Nr(e.total_borrow_usd_wad),totalCollateralUsdWad:Nr(e.total_collateral_usd_wad)}}),"strategy:initial_payment":e=>({topic:"strategy:initial_payment",data:{token:Fr(e.token),amount:Nr(e.amount),usdValueWad:Nr(e.usd_value_wad),accountId:Nr(e.account_id)}}),"strategy:fee":e=>({topic:"strategy:fee",data:{hubId:Wr(e.hub_id),asset:Fr(e.asset),amount:Nr(e.amount),fee:Nr(e.fee),amountSent:Nr(e.amount_sent)}}),"config:approve_blend_pool":e=>({topic:"config:approve_blend_pool",data:{pool:Fr(e.pool??e.blend_pool??e.token),approved:Boolean(e.approved??e.is_approved??!0)}}),"config:approve_token":e=>({topic:"config:approve_token",data:{wasmHash:Gr(e.wasm_hash??e.pool),approved:Boolean(e.approved)}}),"config:swap_aggregator":e=>({topic:"config:swap_aggregator",data:{aggregator:Fr(e.aggregator??e.swap_aggregator)}}),"config:price_aggregator":e=>({topic:"config:price_aggregator",data:{aggregator:Fr(e.aggregator??e.price_aggregator)}}),"config:aggregator":e=>({topic:"config:aggregator",data:{aggregator:Fr(e.aggregator)}}),"config:accumulator":e=>({topic:"config:accumulator",data:{accumulator:Fr(e.accumulator)}}),"config:pool_template":e=>({topic:"config:pool_template",data:{wasmHash:Gr(e.wasm_hash)}}),"config:position_limits":e=>({topic:"config:position_limits",data:{maxSupplyPositions:Wr(e.max_supply_positions),maxBorrowPositions:Wr(e.max_borrow_positions)}}),"config:min_borrow_collateral":e=>({topic:"config:min_borrow_collateral",data:{minBorrowCollateralUsdWad:Nr(e.min_borrow_collateral_usd_wad??e.floor_wad??e.value)}}),"config:oracle_disabled":e=>({topic:"config:oracle_disabled",data:{asset:Fr(e.asset)}}),"config:spoke":e=>{const t=e.spoke;return{topic:"config:spoke",data:{spokeId:Wr(t.spoke_id),isDeprecated:Boolean(t.is_deprecated),liquidationTargetHfWad:Nr(t.liquidation_target_hf_wad),healthFactorForMaxBonusWad:Nr(t.hf_for_max_bonus_wad),liquidationBonusFactorBps:Wr(t.liquidation_bonus_factor_bps)}}}},Jr=Object.freeze(Object.keys(Qr));function eo(e,t){const r=$r(e),o=Qr[r];return o?o((0,s.scValToNative)(Dr(t))):null}const to=1e4;function ro(e,t){return`${e}-${BigInt(t).toString(10)}`}function oo(e){const t=e.split("-");return t.length>=2&&parseInt(t[1],10)||0}function no(e,t=0){return e*to+t}function io(e){switch(e){case"liq_repay":return"lendingLiquidateRepayDebt";case"liq_seize":return"lendingLiquidateSeizeCollateral";case"liq_credit":default:return"lendingUpdateAccountPosition";case"param_upd":return"lendingUpdateAccountParameters"}}const ao=(e,t,r)=>{const o=new URL(t,e.endsWith("/")?e:`${e}/`);if(r)for(const[e,t]of Object.entries(r))void 0!==t&&o.searchParams.set(e,String(t));return o.toString()};async function so(e,t){if(!t.baseUrl)throw new Error("Stellar quote baseUrl is required");if(null==e.amountIn==(null==e.amountOut))throw new Error("getStellarAggregatorQuote: exactly one of `amountIn` or `amountOut` must be provided");const r=ao(t.baseUrl,"api/v1/quote",{from:e.from,to:e.to,amountIn:e.amountIn,amountOut:e.amountOut,maxHops:e.maxHops,maxSplits:e.maxSplits,slippage:e.slippage,includePaths:e.includePaths,sender:e.sender,router:e.router,referralId:e.referralId,platform:e.platform,fresh:e.fresh}),o=await fetch(r,t.fetchOptions);if(!o.ok){const e=await o.text().catch((()=>""));throw new Error(`Stellar quote server responded ${o.status} ${o.statusText} for ${r} — ${e}`)}return await o.json()}async function uo(e){if(!e.baseUrl)throw new Error("Stellar quote baseUrl is required");const t=ao(e.baseUrl,"api/v1/tokens"),r=await fetch(t,e.fetchOptions);if(!r.ok){const e=await r.text().catch((()=>""));throw new Error(`Stellar quote server responded ${r.status} ${r.statusText} for ${t} — ${e}`)}return await r.json()}const lo=16384;class po extends Error{code;constructor(e,t){super(`Stellar route verification failed [${e}]: ${t}`),this.name="StellarRouteVerificationError",this.code=e}}const co=(e,t)=>{throw new po(e,t)};function fo(e){const t=(e=>{const t="string"==typeof e?e:e&&"object"==typeof e&&"routeXdr"in e?e.routeXdr:void 0;if("string"==typeof t&&t.length>2*lo)return co("OVERSIZED",`encoded route has ${t.length} characters`);try{return u.hp.from(O(e).bytes())}catch(e){return co("MALFORMED",e instanceof Error?e.message:String(e))}})(e);0===t.length&&co("MALFORMED","route is empty"),t.length>lo&&co("OVERSIZED",`route has ${t.length} bytes, above ${lo}`);const r=(e=>{let t;try{t=s.xdr.ScVal.fromXDR(e)}catch(e){return co("MALFORMED",`payload is not one XDR ScVal: ${e instanceof Error?e.message:String(e)}`)}if("scvMap"!==t.switch().name)return co("MALFORMED","payload must be a StrategyPayload map");const r=t.map()??[];if("amounts,assets,ops"!==r.map((e=>"scvSymbol"===e.key().switch().name?e.key().sym().toString():"")).join(","))return co("MALFORMED","payload fields must be exactly amounts, assets, ops");const[o,n,i]=r.map((e=>e.val()));return"scvVec"!==o.switch().name||"scvVec"!==n.switch().name||"scvBytes"!==i.switch().name?co("MALFORMED","payload field has the wrong type"):{amounts:o.vec()??[],assets:n.vec()??[],ops:u.hp.from(i.bytes())}})(t),o=r.assets.length,n=r.amounts.length;0===o&&co("MALFORMED","asset registry is empty"),(o>256||n>126)&&co("OVERSIZED",`registries hold ${o} assets and ${n} amounts`);const i=r.assets.map(((e,t)=>"scvAddress"!==e.switch().name?co("MALFORMED",`assets[${t}] is not an address`):s.Address.fromScAddress(e.address()).toString())),a=r.amounts.map(((e,t)=>"scvI128"!==e.switch().name?co("MALFORMED",`amounts[${t}] is not an i128`):(0,s.scValToBigInt)(e))),p=r.ops;p.length<10&&co("MALFORMED","program header is truncated"),p.length>346&&co("OVERSIZED",`program has ${p.length} bytes, above 346`);const c=e=>{const t=p[e];return void 0===t?co("MALFORMED",`program byte ${e} is missing`):t},f=c(0);1!==f&&co("UNSUPPORTED_VERSION",`program version ${f}, expected 1`);const h=c(8),g=c(9);0===h&&co("INVALID_STRUCTURE","program has no instructions"),(h>48||g>32)&&co("OVERSIZED",`program declares ${h} instructions and ${g} weights`);const y=10+5*h;p.length!==y+3*g&&co("MALFORMED","program length does not match its instruction and weight counts");const m=c(1),b=c(2),S=c(3);(m>=o||b>=o||S>=n)&&co("MALFORMED","header index is outside its registry"),m===b&&co("INVALID_STRUCTURE","token_in equals token_out");const w=p.readUInt32BE(4),T=[];for(let e=0;e<g;e+=1){const t=p.readUIntBE(y+3*e,3);(0===t||t>d)&&co("INVALID_STRUCTURE",`split weight ${t} outside 1..=1000000`),T.push(t)}const v=e=>i[e]??co("MALFORMED",`asset index ${e} is outside the registry`),x=e=>a[e]??co("MALFORMED",`amount index ${e} is outside the registry`),A=[];let I;for(let e=0;e<h;e+=1){const t=10+5*e,r=c(t),o=c(t+1),i=c(t+2),a=c(t+3),s=c(t+4);let u;if(r>6&&co("UNKNOWN_OPCODE",`instruction ${e} has opcode ${r}`),0===o)u={kind:"all"};else if(1===o)void 0!==I&&I===a||co("INVALID_STRUCTURE",`instruction ${e} does not chain onto its predecessor`),u={kind:"prev"};else if(o>=128){const t=T[o-128];void 0===t&&co("MALFORMED",`instruction ${e} weight index is out of range`),u={kind:"ppm",ppm:t}}else u={kind:"fixed",amount:x(o-2)};const p=v(i);5!==r&&6!==r?(a===s&&co("INVALID_STRUCTURE",`instruction ${e} swaps a token for itself`),A.push({kind:"swap",venue:l[r],mode:u,pool:p,tokenIn:v(a),tokenOut:v(s)}),I=s):("all"!==u.kind&&co("MALFORMED",`liquidity instruction ${e} must use mode All`),s>=n&&co("MALFORMED",`instruction ${e} amount index is out of range`),A.push({kind:5===r?"burn":"mint",pool:p,shareToken:v(a),amountIndex:s}),I=6===r?a:void 0)}const R=x(S);return R<=0n&&co("MIN_OUT_TOO_LOW",`encoded total_min_out is ${R}`),{version:f,tokenIn:v(m),tokenOut:v(b),totalMinOut:R,referralId:w,assets:i,amounts:a,ops:A,weights:T}}function ho(e,t){if(s.StrKey.isValidContract(e))return e;if(!t)return co("EXPECTATION_MISSING",`token ${e} is not a contract id; pass \`network\` to derive its asset contract`);try{const r=e.indexOf(":");return("XLM"===e||"native"===e?s.Asset.native():new s.Asset(e.slice(0,r),e.slice(r+1))).contractId(a[t])}catch{return co("MALFORMED",`token id ${e} is not a contract id or a classic asset`)}}const go=(e,t)=>"bigint"==typeof e?e:/^\d+$/.test(e)?BigInt(e):co("EXPECTATION_MISSING",`${t} must be a base-unit integer string`);function yo(e,t){const r=go(t.minOut,"expected.minOut");r<=0n&&co("EXPECTATION_MISSING","expected.minOut must be positive");const o=fo(e);if(o.tokenIn!==t.tokenIn&&co("TOKEN_IN_MISMATCH",`route spends ${o.tokenIn}, expected ${t.tokenIn}`),o.tokenOut!==t.tokenOut&&co("TOKEN_OUT_MISMATCH",`route delivers ${o.tokenOut}, expected ${t.tokenOut}`),o.totalMinOut<r&&co("MIN_OUT_TOO_LOW",`route enforces a minimum of ${o.totalMinOut}, below the expected ${r}`),void 0!==t.amountIn){const e=go(t.amountIn,"expected.amountIn");for(const t of o.ops)"swap"===t.kind&&"fixed"===t.mode.kind&&t.tokenIn===o.tokenIn&&t.mode.amount>e&&co("AMOUNT_IN_EXCEEDED",`a leg spends ${t.mode.amount}, above the input ${e}`)}return o}const mo=e=>k(e).toXDR("base64");function bo(e,t){if(!e.routerAddress)throw new Error("Stellar aggregator routerAddress is required");const r=new s.Contract(e.routerAddress),o=new s.Account(e.caller,e.sourceSequence),n=O(((e,t)=>(e=>Boolean(e&&"object"==typeof e&&!(e instanceof Uint8Array)&&"paths"in e))(e)&&void 0===e.referralId?{...e,referralId:t??0}:e)(t,e.referralId));return{xdr:new s.TransactionBuilder(o,{fee:e.fee??s.BASE_FEE,networkPassphrase:a[e.network]}).addOperation(r.call("execute_strategy",c(e.caller),f(e.totalIn),n)).setTimeout(e.timeoutSeconds??300).build().toXDR()}}function So(e,t){return bo(e,t)}function wo(e,t={}){if("string"!=typeof e.amountOutMin)throw new Error("mapQuoteResponseToStrategyPayload: quote response is missing `amountOutMin`. Pass `slippage` when fetching the quote.");return{paths:e.paths?e.paths.map((e=>({hops:e.swaps.map(xo),splitPpm:e.splitPpm}))):[{hops:e.hops.map(xo),splitPpm:1e6}],referralId:t.referralId??0,tokenIn:e.from,tokenOut:e.to,totalMinOut:e.amountOutMin}}function To(e,t={}){const r=t.expected??{},o="string"==typeof e.routeXdr&&e.routeXdr.length>0?{routeXdr:e.routeXdr}:wo(e,t),n=[e.amountOutMin,r.minOut].filter((e=>void 0!==e)).map((e=>{if("bigint"==typeof e)return e;if("string"!=typeof e||!/^\d+$/.test(e))throw new po("MALFORMED","minimum output must be a base-unit integer string");return BigInt(e)})).reduce(((e,t)=>void 0===e||t>e?t:e),void 0);if(void 0===n)throw new po("EXPECTATION_MISSING","quote has no `amountOutMin`; pass `slippage` when fetching it or `expected.minOut`");return yo(o,{tokenIn:ho(r.tokenIn??e.from,t.network),tokenOut:ho(r.tokenOut??e.to,t.network),minOut:n,amountIn:r.amountIn??e.amountIn}),o}const vo=wo,xo=e=>({amountOut:e.amountOut,pool:e.address,tokenIn:e.from,tokenOut:e.to,venue:e.dex});class Ao extends Error{code;offender;constructor(e,t,r){super(`Stellar authorization check failed [${e}]: ${t}${r?` — ${r.contract}.${r.fn}(${r.args.join(", ")})`:""}`),this.name="StellarAuthPolicyError",this.code=e,this.offender=r}}const Io=e=>"scvAddress"===e?.switch().name?s.Address.fromScAddress(e.address()).toString():void 0,Ro=e=>"scvI128"===e?.switch().name?(0,s.scValToBigInt)(e):void 0,Eo=e=>"scvVec"===e?.switch().name?e.vec()??[]:void 0,Po=(e,t)=>"scvMap"===e?.switch().name?(e.map()??[]).find((e=>"scvSymbol"===e.key().switch().name&&e.key().sym().toString()===t))?.val():void 0,ko=e=>Io(e)??Ro(e)?.toString()??e.toXDR("base64"),qo=e=>({contract:s.Address.fromScAddress(e.contractAddress()).toString(),fn:e.functionName().toString(),args:e.args().map(ko)}),Bo=e=>{const t=e.function();return"sorobanAuthorizedFunctionTypeContractFn"===t.switch().name?t.contractFn():void 0};function _o(e,t,r){const o=e.filter((e=>{const o=e.credentials();return("sorobanCredentialsAddress"===o.switch().name?s.Address.fromScAddress(o.address().address()).toString():r??t.caller)===t.caller}));if(o.length>1)throw new Ao("DUPLICATE_ENTRY",`${o.length} authorization entries for ${t.caller}, expected one`);const n=o[0];if(!n)return;const i=Bo(n.rootInvocation());if(!i)throw new Ao("UNEXPECTED_ROOT","root is not a contract call");const a=qo(i);if(a.contract!==t.root.contract||a.fn!==t.root.fn)throw new Ao("UNEXPECTED_ROOT",`expected ${t.root.contract}.${t.root.fn}`,a);const u=t.transfers.map((()=>0n)),l=(t.calls??[]).map((()=>0));for(const e of n.rootInvocation().subInvocations()){const r=Bo(e);if(!r)throw new Ao("UNEXPECTED_CALL","sub-invocation is not a contract call");const o=qo(r);if(e.subInvocations().length>0)throw new Ao("NESTED_INVOCATION","sub-invocation carries its own sub-invocations",o);const n=(t.calls??[]).findIndex((e=>e.contract===o.contract&&e.fn===o.fn));if(-1!==n){const e=(t.calls??[])[n],i=e.reject(r.args());if(i)throw new Ao("UNEXPECTED_CALL",i,o);if(l[n]=(l[n]??0)+1,(l[n]??0)>e.maxCount)throw new Ao("UNEXPECTED_CALL",`more than ${e.maxCount} calls`,o);continue}if("transfer"!==o.fn||3!==r.args().length)throw new Ao("UNEXPECTED_CALL","only `transfer` is allowed",o);if(!t.transfers.some((e=>e.token===o.contract)))throw new Ao("UNEXPECTED_TOKEN","transfer on an unexpected token",o);const[i,a,s]=r.args();if(Io(i)!==t.caller)throw new Ao("UNEXPECTED_SENDER","transfer is not from the caller",o);const p=Io(a),d=t.transfers.findIndex((e=>e.token===o.contract&&e.to===p));if(-1===d)throw new Ao("UNEXPECTED_RECIPIENT","transfer to an unexpected recipient",o);const c=Ro(s),f=t.transfers[d],h=(u[d]??0n)+(c??0n);if(void 0===c||c<=0n||h>f.maxAmount)throw new Ao("AMOUNT_EXCEEDED",`transfers total ${h}, above the expected ${f.maxAmount}`,o);u[d]=h}}const Oo=e=>{throw new Ao("MALFORMED_TRANSACTION",e)},Uo=(e,t)=>{const r=new Map;for(const t of Eo(e)??Oo("payments argument is not a vector")){const[e,o]=Eo(t)??[],n=Io(Po(e,"asset")),i=Ro(o);if(void 0===n||void 0===i||i<0n)return Oo("payment is not a (HubAssetKey, i128) tuple");r.set(n,(r.get(n)??0n)+i)}return[...r].map((([e,r])=>({token:e,to:t,maxAmount:r})))},Mo=new Set([1,3,5]),Co=(e,t,r)=>({contract:e,fn:"submit",maxCount:2,reject:e=>{if(4!==e.length)return"submit must have four arguments";if(Io(e[0])!==t)return"`from` is not the caller";if(Io(e[1])!==r||Io(e[2])!==r)return"`spender` and `to` must be the lending controller";const o=Eo(e[3]);if(!o)return"requests is not a vector";for(const e of o){const t=Po(e,"request_type");if("scvU32"!==t?.switch().name||!Mo.has(t.u32()))return"request is not a withdraw, withdraw-collateral, or repay"}}});function Lo(e,t,r){const{contract:o,fn:n}=qo(t),i=t.args(),a={caller:e,root:{contract:o,fn:n},transfers:[]};if(o===r.governance)return a;if(o===r.aggregatorRouter){if("execute_strategy"!==n)return a;const t=Ro(i[1]);if(Io(i[0])!==e||void 0===t||"scvBytes"!==i[2]?.switch().name)return Oo("execute_strategy arguments must be (caller, total_in, swap_xdr)");const r=fo(i[2].bytes());return a.transfers=[{token:r.tokenIn,to:o,maxAmount:t}],a}if(o!==r.lendingController)throw new Ao("UNSUPPORTED_CONTRACT",`no authorization policy for contract ${o}; pass an explicit policy`);if(Io(i[0])!==e)throw new Ao("CALLER_MISMATCH",`${n} is not invoked for ${e}`);switch(n){case"supply":a.transfers=Uo(i[3],r.lendingPool);break;case"repay":case"liquidate":a.transfers=Uo(i[2],r.lendingPool);break;case"multiply":{const e=i[8];e&&"scvVoid"!==e.switch().name&&(a.transfers=Uo(s.xdr.ScVal.scvVec([e]),o));break}case"migrate_from_blend":{const t=Io(i[4])??Oo("blend_pool is not an address");a.calls=[Co(t,e,o)];break}}return a}const Do=e=>{let t;try{t=s.xdr.TransactionEnvelope.fromXDR(e,"base64")}catch{return Oo("not a transaction envelope")}if("envelopeTypeTx"!==t.switch().name)return Oo("expected a regular (v1) transaction");const r=t.v1().tx(),o=r.operations()[0];if(!o||1!==r.operations().length)return Oo("expected exactly one operation");const n=o.body();if("invokeHostFunction"!==n.switch().name)return Oo("operation is not a contract invocation");const i=n.invokeHostFunctionOp();return"hostFunctionTypeInvokeContract"!==i.hostFunction().switch().name?Oo("host function is not a contract call"):{source:(a=o.sourceAccount()??r.sourceAccount(),s.StrKey.encodeEd25519PublicKey("keyTypeMuxedEd25519"===a.switch().name?a.med25519().ed25519():a.ed25519())),op:i,call:i.hostFunction().invokeContract()};var a};function $o(e,t){const r=Do(e);if(void 0!==t.builtXdr&&Do(t.builtXdr).op.hostFunction().toXDR("base64")!==r.op.hostFunction().toXDR("base64"))throw new Ao("INVOCATION_CHANGED","the prepared transaction does not invoke what was built",qo(r.call));const o=t.policy??Lo(t.caller,r.call,{...i(t.network),...t.deployment});_o(r.op.auth(),o,r.source)}function No(e,t){const r=t instanceof Error?t.message:String(t);return new Error(`[xoxno-invoked:${e}] ${r}`)}async function Wo(e,t,r){const o=s.TransactionBuilder.fromXDR(t,r?.network?a[r.network]:"");try{return(await e.prepareTransaction(o)).toXDR()}catch(e){if(r?.invokedContractId)throw No(r.invokedContractId,e);throw e}}async function Fo(e,t,r){return Wo(e,t.xdr,r)}function Go(e){if(e<=0||e>4)throw new Error(`Invalid PositionMode ${e} for Stellar — expected 1 (Normal) through 4 (Short). "None" (0) has no Stellar equivalent.`);return e-1}function Ho(e,t){return new Uint8Array(0)}const zo=e=>{const t=e.startsWith("0x")?e.slice(2):e;if(t.length%2!=0)throw new Error("buildStellarCctpForwardTx: hex input must have even length");return u.hp.from(t,"hex")};function Vo(e){const t=new s.Account(e.caller,e.sourceSequence),r=new s.Contract(e.forwarderAddress).call("mint_and_forward",s.xdr.ScVal.scvBytes(zo(e.message)),s.xdr.ScVal.scvBytes(zo(e.attestation)));return{xdr:new s.TransactionBuilder(t,{fee:e.fee??"10000000",networkPassphrase:a[e.network]}).addOperation(r).setTimeout(e.timeoutSeconds??120).build().toXDR()}}const Xo=10n**27n,jo=10n**18n,Ko=10000n,Zo=27,Yo=18;function Qo(e,t="value"){let r;if("bigint"==typeof e)r=e;else if("number"==typeof e){if(!Number.isSafeInteger(e))throw new Error(`Stellar math: ${t} must be a safe integer, got ${e}`);r=BigInt(e)}else{const o=e.trim();if(!/^-?\d+$/.test(o))throw new Error(`Stellar math: ${t} must be a decimal integer string, got "${e}"`);r=BigInt(o)}if(r<0n)throw new Error(`Stellar math: ${t} must be non-negative, got ${r}`);return r}function Jo(e,t,r){if(0n===r)throw new Error("Stellar math: division by zero");return e*t/r}function en(e,t,r){if(0n===r)throw new Error("Stellar math: division by zero");const o=e*t,n=o/r;return o%r===0n?n:n+1n}function tn(e,t,r){if(0n===r)throw new Error("Stellar math: division by zero");return(e*t+r/2n)/r}function rn(e,t){if(0n===t)throw new Error("Stellar math: division by zero");const r=e/t;return e%t>=t/2n+t%2n?r+1n:r}const on=e=>10n**BigInt(e);function nn(e,t,r){return t===r?e:r>t?e*on(r-t):e/on(t-r)}function an(e,t,r){if(t===r)return e;if(r>t)return e*on(r-t);const o=on(t-r),n=e/o;return e%o===0n?n:n+1n}function sn(e,t,r){return t===r?e:r>t?e*on(r-t):rn(e,on(t-r))}const un={floor:Jo,ceil:en,halfUp:tn},ln={floor:nn,ceil:an,halfUp:sn};function pn(e,t,r,o){return ln[o](un[o](e,t,Xo),Zo,r)}function dn(e,t,r){return pn(Qo(e,"scaledRay"),Qo(t,"indexRay"),r,"floor")}function cn(e,t,r){return pn(Qo(e,"scaledRay"),Qo(t,"indexRay"),r,"ceil")}function fn(e,t,r){return pn(Qo(e,"scaledRay"),Qo(t,"indexRay"),r,"halfUp")}function hn(e,t){if(t>Zo)throw new Error(`Stellar math: decimals ${t} exceed RAY scale`);return nn(e,t,Zo)}function gn(e,t,r,o){const n=un[o](e,t,Xo),i=ln[o](n,Zo,Yo);return un[o](i,r,jo)}function yn(e,t,r,o){const n=ln[o](hn(e,t),Zo,Yo);return un[o](n,r,jo)}const mn=e=>Number(e)/1e18,bn=e=>Number(e)/1e27,Sn=(e,t)=>Number(e)/10**t;function wn(e,t){if(!Number.isFinite(e)||e<=0||e>=1e21)return 0n;const r=e.toFixed(t),[o="0",n=""]=r.split(".");return BigInt(o+n.padEnd(t,"0"))}const Tn=e=>wn(e,Yo),vn=(e,t)=>tn(e,t,Xo),xn=(e,t)=>tn(e,Xo,t);function An(e,t){return 0n===t?0n:xn(e,t)}function In(e,t){const r=e>Xo?Xo:e,o=Qo(t.baseRateRay,"irm.baseRateRay"),n=Qo(t.slope1Ray,"irm.slope1Ray"),i=Qo(t.slope2Ray,"irm.slope2Ray"),a=Qo(t.slope3Ray,"irm.slope3Ray"),s=Qo(t.midUtilizationRay,"irm.midUtilizationRay"),u=Qo(t.optimalUtilizationRay,"irm.optimalUtilizationRay"),l=Qo(t.maxBorrowRateRay,"irm.maxBorrowRateRay");let p;if(r<s)p=o+xn(vn(r,n),s);else if(r<u){const e=u-s;p=o+n+xn(vn(r-s,i),e)}else{const e=Xo-u;p=o+n+i+(0n===e?0n:xn(vn(r-u,a),e))}return p>l?l:p}function Rn(e,t,r){return 0n===e||!Number.isInteger(r)||r<0||r>=1e4?0n:tn(vn(e,t),Ko-BigInt(r),Ko)}const En=e=>bn(e),Pn=e=>Math.expm1(bn(e)),kn=5n*jo,qn=(e,t,r)=>`${e}:${t}:${r}`;function Bn(e,t,r,o){const n=Array.isArray(e)?e:void 0,i=n?n.find((e=>e.spokeId===t&&e.hubId===r&&e.asset===o)):e[qn(t,r,o)]??Object.values(e).find((e=>e.spokeId===t&&e.hubId===r&&e.asset===o));if(!i)throw new Error(`Stellar math: no reserve for ${qn(t,r,o)}`);return i}const _n=/^0*[1-9]\d*$/,On=e=>"string"==typeof e&&_n.test(e)?BigInt(e).toString():null,Un=(e,t)=>`${e}:${t}`;function Mn(e){const t=new Map,r=new Map,o=new Set,n=new Set;for(const i of e?.indexes??[]){const e=Un(i.hubId,i.asset),a=On(i.supplyIndex),s=On(i.borrowIndex),u=On(i.usdPrice),l=t.get(e),p=l&&On(l.supplyIndex)===a&&On(l.borrowIndex)===s&&On(l.usdPrice)===u;null==a||null==s||null==u||l&&!p?o.add(e):l||t.set(e,i);const d=!1===i.valid||!0===i.stale||!0===i.deviation,c=r.get(i.asset);null==u||d||void 0!==c&&c.toString()!==u?n.add(i.asset):void 0===c&&r.set(i.asset,BigInt(u))}for(const e of o)t.delete(e);for(const e of n)r.delete(e);return{indexes:t,prices:r,rejectedIndexKeys:o,rejectedAssets:n}}const Cn=(e,t)=>Jo(e,BigInt(t),Ko);function Ln(e,t,r,o){const n="supply"===e.side,i=Math.min(e.entryLtvBps,e.entryLiquidationThresholdBps);return{side:e.side,hubId:e.hubId,asset:e.asset,decimals:e.decimals,scaledRay:e.scaledRay.toString(),indexRay:e.indexRay.toString(),usdPriceWad:e.priceWad.toString(),usdPrice:mn(e.priceWad),amountBase:t.toString(),amountShort:Sn(t,e.decimals),usdWad:r.toString(),usd:mn(r),gateUsdWad:o.toString(),entryLtvBps:e.entryLtvBps,entryLiquidationThresholdBps:e.entryLiquidationThresholdBps,entryLiquidationBonusBps:e.entryLiquidationBonusBps,entryLiquidationFeesBps:e.entryLiquidationFeesBps,ltvWeightedUsdWad:n?Cn(o,i).toString():"0",liquidationWeightedUsdWad:n?Cn(o,e.entryLiquidationThresholdBps).toString():"0",liveDataUsed:e.liveDataUsed}}function Dn(e){if("supply"===e.side)return Ln(e,pn(e.scaledRay,e.indexRay,e.decimals,"floor"),gn(e.scaledRay,e.indexRay,e.priceWad,"halfUp"),gn(e.scaledRay,e.indexRay,e.priceWad,"floor"));const t=pn(e.scaledRay,e.indexRay,e.decimals,"ceil"),r=gn(e.scaledRay,e.indexRay,e.priceWad,"ceil");return Ln(e,t,r,r)}function $n(e,t,r,o){const n=hn(t,r);return"supply"===e?Jo(n,Xo,o):en(n,Xo,o)}function Nn(e,t,r,o){const n=hn(t,r);return"supply"===e?en(n,Xo,o):Jo(n,Xo,o)}function Wn(e,t){return Dn({...e,scaledRay:$n(e.side,t,e.decimals,e.indexRay)})}const Fn=(...e)=>{for(const t of e){const e=On(t);if(null!=e)return BigInt(e)}return Xo};function Gn(e,t,r,o){const n=Qo("supply"===e?t.supplyScaledRay:t.borrowScaledRay,`${e}ScaledRay`);if(0n===n)return null;const i=o.indexes.get(Un(t.hubId,t.asset)),a=o.prices.get(t.asset),s="supply"===e?Fn(i?.supplyIndex,t.liveSupplyIndexRay,r.liveSupplyIndexRay,t.supplyIndexRay):Fn(i?.borrowIndex,t.liveBorrowIndexRay,r.liveBorrowIndexRay,t.borrowIndexRay),u=a??Tn(r.usdPrice);return Dn({side:e,hubId:t.hubId,asset:t.asset,decimals:r.assetDecimals,scaledRay:n,indexRay:s,priceWad:u,entryLtvBps:t.entryLtvBps,entryLiquidationThresholdBps:t.entryLiquidationThresholdBps,entryLiquidationBonusBps:t.entryLiquidationBonusBps,entryLiquidationFeesBps:t.entryLiquidationFeesBps,liveDataUsed:void 0!==i&&void 0!==a})}const Hn=(e,t)=>e.reduce(((e,r)=>e+BigInt(t(r))),0n);function zn(e,t,r,o,n){const i=Hn(t,(e=>e.usdWad)),a=Hn(t,(e=>e.ltvWeightedUsdWad)),s=Hn(t,(e=>e.liquidationWeightedUsdWad)),u=Hn(r,(e=>e.usdWad)),l=0n===u?null:Jo(s,jo,u),p=0n===s?0:Number(u)/Number(s)*100,d=a<o||a<=u?0n:a-u;return{...e,supplies:t,borrows:r,totalCollateralUsdWad:i.toString(),totalCollateralUsd:mn(i),ltvWeightedCollateralUsdWad:a.toString(),ltvWeightedCollateralUsd:mn(a),liquidationWeightedCollateralUsdWad:s.toString(),liquidationWeightedCollateralUsd:mn(s),totalDebtUsdWad:u.toString(),totalDebtUsd:mn(u),healthFactorWad:null===l?null:l.toString(),healthFactor:null===l?null:mn(l),healthPercent:p,borrowLimitUsdWad:a.toString(),borrowLimitUsd:mn(a),availableBorrowUsdWad:d.toString(),availableBorrowUsd:mn(d),minBorrowCollateralUsdWad:o.toString(),minBorrowCollateralUsd:mn(o),isLiquidatable:null!==l&&l<jo,liveDataValid:n}}function Vn(e){const{positions:t,reserves:r,liveState:o}=e,n=t[0];if(!n)throw new Error("Stellar math: computeAccountRisk needs at least one position row");for(const e of t)if(e.accountId!==n.accountId)throw new Error(`Stellar math: computeAccountRisk received mixed account ids (${n.accountId}, ${e.accountId})`);const i=Mn(o),a=[],s=[];for(const e of t){const t=Bn(r,e.spokeId,e.hubId,e.asset),o=Gn("supply",e,t,i);o&&a.push(o);const n=Gn("borrow",e,t,i);n&&s.push(n)}const u=null!=o?.minBorrowCollateralUsdWad?Qo(o.minBorrowCollateralUsdWad,"minBorrowCollateralUsdWad"):kn,l=void 0!==o&&[...a,...s].every((e=>e.liveDataUsed));return zn({accountId:n.accountId,owner:n.owner,spokeId:n.spokeId,mode:n.positionMode},a,s,u,l)}const Xn=200n,jn=e=>e.reduce(((e,t)=>t.amount<e.amount?t:e)),Kn=e=>e<0n?0n:e,Zn=(e,t,r,o)=>({amountBase:e.amount,amountShort:Sn(e.amount,t),isFullClose:r,reason:e.reason,projectedUtilization:o}),Yn=e=>({amountBase:0n,amountShort:0,isFullClose:!1,reason:e,projectedUtilization:null});function Qn(e){const t=e.assetDecimals,r=Qo(e.irm.maxUtilizationRay,"irm.maxUtilizationRay");return{suppliedBase:wn(e.hubPool.suppliedShort,t),borrowedBase:wn(e.hubPool.borrowedShort,t),cashBase:wn(e.availableLiquidityShort,t),spokeSuppliedBase:wn(e.suppliedShort,t),spokeBorrowedBase:wn(e.borrowedShort,t),maxUtilizationRay:r>=Xo?null:r}}const Jn=(e,t)=>e<=0n?null:Number(t)/Number(e);function ei(e,t){if(e<=0n||!t(0n))return 0n;let r=0n,o=e+1n;for(;o-r>1n;){const e=(r+o)/2n;t(e)?r=e:o=e}return r}const ti=(e,t)=>e.find((e=>e.hubId===t.hubId&&e.asset===t.asset));function ri(e,t,r){if(t.paused)return Yn("paused");if(t.frozen)return Yn("frozen");if(!t.isBorrowable)return Yn("cap");const o=t.assetDecimals,n=Qn(t),i=ti(e.borrows,t),a=Mn(r).indexes.get(Un(t.hubId,t.asset)),s=i?BigInt(i.indexRay):Qo(a?.borrowIndex??t.liveBorrowIndexRay,"borrowIndex"),u=i?BigInt(i.usdPriceWad):function(e,t){return Mn(t).prices.get(e.asset)??Tn(e.usdPrice)}(t,r),l=i?BigInt(i.scaledRay):0n,p=BigInt(e.totalDebtUsdWad)-(i?BigInt(i.usdWad):0n),d=BigInt(e.ltvWeightedCollateralUsdWad),c=BigInt(e.minBorrowCollateralUsdWad),f=[];if(d<c)f.push({amount:0n,reason:"minCollateral"});else{const t=d-BigInt(e.totalDebtUsdWad),r=t<=0n||u<=0n?0n:Jo(t,10n**BigInt(o),u),n=e=>p+gn(l+$n("borrow",e,o,s),s,u,"ceil");f.push({amount:0n===r?0n:ei(r+16n,(e=>n(e)<=d)),reason:"ltv"})}f.push({amount:Kn(Qo(t.borrowCap,"borrowCap")-n.spokeBorrowedBase),reason:"cap"});const h=tn(n.suppliedBase,Xn,Ko);f.push({amount:Kn(n.cashBase-h),reason:"liquidity"});const g=function(e,t){const r=e.maxUtilizationRay;if(null===r)return null;const o=hn(e.suppliedBase,t);return 0n===o?null:ei(Kn(Jo(e.suppliedBase,r,Xo)-e.borrowedBase)+16n,(n=>An(hn(e.borrowedBase+n,t),o)<=r))}(n,o);null!==g&&f.push({amount:g,reason:"utilizationCap"});const y=jn(f);return Zn(y,o,!1,Jn(n.suppliedBase,n.borrowedBase+y.amount))}function oi(e,t,r){if(t.paused)return Yn("paused");const o=ti(e.supplies,t);if(!o)return Yn(null);const n=o.decimals,i=Qn(t),a=BigInt(o.scaledRay),s=BigInt(o.indexRay),u=BigInt(o.usdPriceWad),l=BigInt(o.amountBase),p=pn(a,s,n,"halfUp"),d=BigInt(e.totalDebtUsdWad),c=BigInt(e.minBorrowCollateralUsdWad),f=BigInt(Math.min(o.entryLtvBps,o.entryLiquidationThresholdBps)),h=[];let g=!0;if(d>0n&&f>0n){const t=d>c?d:c,r=c>d?"minCollateral":"healthFactor",i=BigInt(e.ltvWeightedCollateralUsdWad)-BigInt(o.ltvWeightedUsdWad);if(i<t){g=!1;const e=t-i,l=en(e,Ko,f),d=BigInt(o.gateUsdWad)-l,c=d<=0n?0n:Jo(d,10n**BigInt(n),u),y=p>0n?p-1n:0n,m=c+16n>y?y:c+16n,b=e=>{const t=Nn("supply",e,n,s);return Jo(gn(t>=a?0n:a-t,s,u,"floor"),f,Ko)};h.push({amount:ei(m,(t=>b(t)>=e)),reason:r})}}h.push({amount:l,reason:null}),h.push({amount:i.cashBase,reason:"liquidity"});const y=function(e,t){const r=e.maxUtilizationRay;if(null===r||0n===e.borrowedBase)return null;if(0n===r)return 0n;const o=en(e.borrowedBase,Xo,r),n=e.suppliedBase<o?0n:e.suppliedBase-o+16n,i=hn(e.borrowedBase,t);return ei(n>e.suppliedBase?e.suppliedBase:n,(o=>{const n=hn(e.suppliedBase-o,t);return n>0n&&An(i,n)<=r}))}(i,n);null!==y&&h.push({amount:y,reason:"utilizationCap"});const m=jn(h),b=g&&m.amount>=l;return Zn(m,n,b,Jn(i.suppliedBase-m.amount,i.borrowedBase))}function ni(e){if(e.paused)return Yn("paused");if(e.frozen)return Yn("frozen");const t=e.assetDecimals,r=Qn(e),o={amount:Kn(Qo(e.supplyCap,"supplyCap")-r.spokeSuppliedBase),reason:"cap"};return Zn(o,t,!1,Jn(r.suppliedBase+o.amount,r.borrowedBase))}function ii(e,t,r){if(t.paused)return Yn("paused");const o=ti(e.borrows,t);if(!o)return Yn(null);const n=o.decimals,i=Qn(t),a=BigInt(o.amountBase),s=void 0===r?null:Qo(r,"walletBalance"),u=null!==s&&s<a?{amount:s,reason:"liquidity"}:{amount:a,reason:null};return Zn(u,n,u.amount>=a,Jn(i.suppliedBase,Kn(i.borrowedBase-u.amount)))}const ai=(e,t)=>e.hubId===t.hubId&&e.asset===t.asset,si=e=>{if("bigint"==typeof e)return e;const t=e.trim();if(!/^-?\d+$/.test(t))throw new Error(`Stellar math: delta amountBase must be an integer string, got "${e}"`);return BigInt(t)};function ui(e,t){const r=[...e.supplies],o=[...e.borrows];for(const e of t){const t="supply"===e.side?r:o,n=t.findIndex((t=>ai(t,e))),i=-1===n?void 0:t[n],a=si(e.amountBase);let s;if(i){const e={side:i.side,hubId:i.hubId,asset:i.asset,decimals:i.decimals,indexRay:BigInt(i.indexRay),priceWad:BigInt(i.usdPriceWad),entryLtvBps:i.entryLtvBps,entryLiquidationThresholdBps:i.entryLiquidationThresholdBps,entryLiquidationBonusBps:i.entryLiquidationBonusBps,entryLiquidationFeesBps:i.entryLiquidationFeesBps,liveDataUsed:i.liveDataUsed},t=BigInt(i.scaledRay);let r;if(a>=0n)r=t+$n(e.side,a,e.decimals,e.indexRay);else{const o=-a,n=o>=("supply"===e.side?pn(t,e.indexRay,e.decimals,"halfUp"):BigInt(i.amountBase))?t:Nn(e.side,o,e.decimals,e.indexRay);r=n>=t?0n:t-n}s=0n===r?null:Dn({...e,scaledRay:r})}else s=a<=0n?null:Wn(li(e),a);-1===n?s&&t.push(s):s?t[n]=s:t.splice(n,1)}return zn({accountId:e.accountId,owner:e.owner,spokeId:e.spokeId,mode:e.mode},r,o,BigInt(e.minBorrowCollateralUsdWad),e.liveDataValid)}function li(e){const t=e.reserve;if(!t)throw new Error(`Stellar math: projectAccountRisk needs \`reserve\` for a new ${e.side} position on ${e.hubId}:${e.asset}`);return{side:e.side,hubId:e.hubId,asset:e.asset,decimals:t.assetDecimals,indexRay:Qo("supply"===e.side?t.liveSupplyIndexRay:t.liveBorrowIndexRay,"reserve live index"),priceWad:Tn(t.usdPrice),entryLtvBps:t.collateralFactorBps,entryLiquidationThresholdBps:t.liquidationThresholdBps,entryLiquidationBonusBps:t.liquidationPenaltyBps,entryLiquidationFeesBps:t.liquidationFeesBps,liveDataUsed:!1}}function pi(e,t=0n,r=0n){const o=e.assetDecimals,n=e=>e<0n?0n:e,i=n(wn(e.hubPool.suppliedShort,o)+si(t)),a=An(hn(n(wn(e.hubPool.borrowedShort,o)+si(r)),o),hn(i,o)),s=In(a,e.irm),u=Rn(a,s,e.irm.reserveFactorBps);return{utilization:bn(a),utilizationRay:a.toString(),borrowAprRay:s.toString(),supplyAprRay:u.toString(),borrowApr:En(s),supplyApr:En(u),borrowApy:Pn(s),supplyApy:Pn(u)}}const di={1:{name:"AssetNotSupported",message:"This asset is not supported by the protocol."},2:{name:"AssetAlreadySupported",message:"This asset is already supported."},3:{name:"InvalidTicker",message:"Invalid asset ticker."},6:{name:"InvalidAsset",message:"Invalid asset address."},10:{name:"InvalidWasmHash",message:"The WASM hash is empty or invalid."},11:{name:"InvalidExchangeSrc",message:"The oracle configuration is invalid."},12:{name:"PairNotActive",message:"No oracle is configured for this asset."},32:{name:"OwnerNotSet",message:"The contract owner has not been set."},39:{name:"InvalidTimelockDelay",message:"The timelock delay is out of the allowed range."},41:{name:"InvalidRole",message:"The caller does not hold the required role."},43:{name:"HubNotActive",message:"This hub is not active."},44:{name:"NotAuthorized",message:"The caller is not authorized to perform this action."},46:{name:"OperationNotCancellable",message:"This governance operation cannot be cancelled."},113:{name:"InvalidLiqThreshold",message:"LTV, liquidation threshold, or bonus is out of bounds."},116:{name:"InvalidBorrowParams",message:"Supply or borrow cap configuration is invalid."},117:{name:"InvalidUtilRange",message:"Interest-rate utilization breakpoints are invalid."},132:{name:"AssetDecimalsTooHigh",message:"Asset decimals exceed the protocol maximum (27)."},300:{name:"SpokeNotFound",message:"This spoke does not exist."},301:{name:"SpokeDeprecated",message:"This spoke has been deprecated."},307:{name:"AssetNotInSpoke",message:"This asset is not listed on the spoke."},308:{name:"AssetAlreadyInSpoke",message:"This asset is already listed in the spoke."},309:{name:"SpokeAssetInUse",message:"This spoke asset still has live positions; drain usage before removal."},315:{name:"SpokeAssetPaused",message:"This spoke asset is paused."},316:{name:"SpokeAssetFrozen",message:"This spoke asset is frozen."},317:{name:"SpokeAssetFlagRelaxation",message:"Guardian flag updates may only tighten; clearing a flag requires the timelocked edit."},318:{name:"SpokeAssetSeizureHalted",message:"Liquidation seizure is halted for this spoke asset."},220:{name:"InvalidOracleBase",message:"The oracle quote asset/market is missing or invalid."},221:{name:"InvalidOracleDecimals",message:"The oracle decimals value is invalid."},224:{name:"InvalidSanityBounds",message:"Oracle sanity bounds are invalid (require 0 < min < max)."},225:{name:"OracleCycleDetected",message:"A cycle was detected in the oracle quote chain."}};function ci(e){const t=e.match(/Error\(Contract,\s*#(\d+)\)/);if(!t)return null;const r=Number(t[1]),o=di[r];return o?{code:r,...o}:null}}},t={};function r(o){var n=t[o];if(void 0!==n)return n.exports;var i=t[o]={exports:{}};return e[o](i,i.exports,r),i.exports}r.d=(e,t)=>{for(var o in t)r.o(t,o)&&!r.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};(()=>{"use strict";r.r(o),r.d(o,{BPS:()=>g.BPS,Chain:()=>a,DEFAULT_MIN_BORROW_COLLATERAL_USD_WAD:()=>g.DEFAULT_MIN_BORROW_COLLATERAL_USD_WAD,DEFAULT_REQUEST_TIMEOUT_MS:()=>i,LIQUIDATION_BUFFER_BPS:()=>g.LIQUIDATION_BUFFER_BPS,RAY:()=>g.RAY,RAY_DECIMALS:()=>g.RAY_DECIMALS,STELLAR_GOVERNANCE_ZERO_PREDECESSOR:()=>g.STELLAR_GOVERNANCE_ZERO_PREDECESSOR,STELLAR_LENDING_TOPICS:()=>g.STELLAR_LENDING_TOPICS,STELLAR_NETWORKS:()=>g.STELLAR_NETWORKS,STELLAR_NETWORK_PASSPHRASE:()=>g.STELLAR_NETWORK_PASSPHRASE,STELLAR_ROUTE_MAX_BYTES:()=>g.STELLAR_ROUTE_MAX_BYTES,SYNTHETIC_EVENT_ORDER_STRIDE:()=>g.SYNTHETIC_EVENT_ORDER_STRIDE,StellarAuthPolicyError:()=>g.StellarAuthPolicyError,StellarRouteVerificationError:()=>g.StellarRouteVerificationError,WAD:()=>g.WAD,WAD_DECIMALS:()=>g.WAD_DECIMALS,XOXNOClient:()=>s,aggregateAccountRisk:()=>g.aggregateAccountRisk,annualBorrowRateRay:()=>g.annualBorrowRateRay,assertStellarAuthEntries:()=>g.assertStellarAuthEntries,assertStellarPreparedTxAuth:()=>g.assertStellarPreparedTxAuth,baseToRay:()=>g.baseToRay,baseToShort:()=>g.baseToShort,baseValueWad:()=>g.baseValueWad,buildLiveSnapshot:()=>g.buildLiveSnapshot,buildSameTokenRepaySwapSteps:()=>g.buildSameTokenRepaySwapSteps,buildSdk:()=>S,buildStellarAcceptOwnershipTx:()=>g.buildStellarAcceptOwnershipTx,buildStellarAddRewardsTx:()=>g.buildStellarAddRewardsTx,buildStellarApproveBlendPoolTx:()=>g.buildStellarApproveBlendPoolTx,buildStellarApproveTokenTx:()=>g.buildStellarApproveTokenTx,buildStellarBatchSwapTx:()=>g.buildStellarBatchSwapTx,buildStellarBorrowBatchTx:()=>g.buildStellarBorrowBatchTx,buildStellarBorrowTx:()=>g.buildStellarBorrowTx,buildStellarCctpForwardTx:()=>g.buildStellarCctpForwardTx,buildStellarClaimRevenueTx:()=>g.buildStellarClaimRevenueTx,buildStellarCreateLiquidityPoolTx:()=>g.buildStellarCreateLiquidityPoolTx,buildStellarExecuteCancellerResetTx:()=>g.buildStellarExecuteCancellerResetTx,buildStellarExecuteStrategyTx:()=>g.buildStellarExecuteStrategyTx,buildStellarFlashLoanTx:()=>g.buildStellarFlashLoanTx,buildStellarGovernanceAddSpokeImmediateTx:()=>g.buildStellarGovernanceAddSpokeImmediateTx,buildStellarGovernanceCreateHubImmediateTx:()=>g.buildStellarGovernanceCreateHubImmediateTx,buildStellarGovernanceExecuteGovernanceUpgradeTx:()=>g.buildStellarGovernanceExecuteGovernanceUpgradeTx,buildStellarGovernanceExecuteGrantGovernanceRoleTx:()=>g.buildStellarGovernanceExecuteGrantGovernanceRoleTx,buildStellarGovernanceExecuteRevokeGovernanceRoleTx:()=>g.buildStellarGovernanceExecuteRevokeGovernanceRoleTx,buildStellarGovernanceExecuteTransferGovOwnTx:()=>g.buildStellarGovernanceExecuteTransferGovOwnTx,buildStellarGovernanceExecuteTx:()=>g.buildStellarGovernanceExecuteTx,buildStellarGovernanceExecuteUpdateDelayTx:()=>g.buildStellarGovernanceExecuteUpdateDelayTx,buildStellarGovernancePauseTx:()=>g.buildStellarGovernancePauseTx,buildStellarGovernanceRevokeRoleImmediateTx:()=>g.buildStellarGovernanceRevokeRoleImmediateTx,buildStellarGovernanceSetOracleSanityBoundsImmediateTx:()=>g.buildStellarGovernanceSetOracleSanityBoundsImmediateTx,buildStellarGovernanceSetSpokeAssetFlagsImmediateTx:()=>g.buildStellarGovernanceSetSpokeAssetFlagsImmediateTx,buildStellarGrantRoleTx:()=>g.buildStellarGrantRoleTx,buildStellarLendingIdentifier:()=>g.buildStellarLendingIdentifier,buildStellarLiquidateTx:()=>g.buildStellarLiquidateTx,buildStellarMigrateFromBlendTx:()=>g.buildStellarMigrateFromBlendTx,buildStellarMigrateTx:()=>g.buildStellarMigrateTx,buildStellarMultiplyTx:()=>g.buildStellarMultiplyTx,buildStellarPauseTx:()=>g.buildStellarPauseTx,buildStellarProposeAddAssetToSpokeTx:()=>g.buildStellarProposeAddAssetToSpokeTx,buildStellarProposeAddSpokeTx:()=>g.buildStellarProposeAddSpokeTx,buildStellarProposeApproveBlendPoolTx:()=>g.buildStellarProposeApproveBlendPoolTx,buildStellarProposeApproveTokenTx:()=>g.buildStellarProposeApproveTokenTx,buildStellarProposeCancellerResetTx:()=>g.buildStellarProposeCancellerResetTx,buildStellarProposeConfigureAssetOracleTx:()=>g.buildStellarProposeConfigureAssetOracleTx,buildStellarProposeConfigureMarketOracleTx:()=>g.buildStellarProposeConfigureMarketOracleTx,buildStellarProposeCreateHubTx:()=>g.buildStellarProposeCreateHubTx,buildStellarProposeCreateLiquidityPoolTx:()=>g.buildStellarProposeCreateLiquidityPoolTx,buildStellarProposeDeployPoolTx:()=>g.buildStellarProposeDeployPoolTx,buildStellarProposeEditAssetInSpokeTx:()=>g.buildStellarProposeEditAssetInSpokeTx,buildStellarProposeEditOracleToleranceTx:()=>g.buildStellarProposeEditOracleToleranceTx,buildStellarProposeGovernanceUpgradeTx:()=>g.buildStellarProposeGovernanceUpgradeTx,buildStellarProposeGrantGovernanceRoleTx:()=>g.buildStellarProposeGrantGovernanceRoleTx,buildStellarProposeMigrateControllerTx:()=>g.buildStellarProposeMigrateControllerTx,buildStellarProposeRemoveAssetFromSpokeTx:()=>g.buildStellarProposeRemoveAssetFromSpokeTx,buildStellarProposeRemoveSpokeTx:()=>g.buildStellarProposeRemoveSpokeTx,buildStellarProposeRevokeBlendPoolTx:()=>g.buildStellarProposeRevokeBlendPoolTx,buildStellarProposeRevokeGovernanceRoleTx:()=>g.buildStellarProposeRevokeGovernanceRoleTx,buildStellarProposeRevokeTokenTx:()=>g.buildStellarProposeRevokeTokenTx,buildStellarProposeSetAccumulatorTx:()=>g.buildStellarProposeSetAccumulatorTx,buildStellarProposeSetAggregatorTx:()=>g.buildStellarProposeSetAggregatorTx,buildStellarProposeSetMinBorrowCollatTx:()=>g.buildStellarProposeSetMinBorrowCollatTx,buildStellarProposeSetPositionLimitsTx:()=>g.buildStellarProposeSetPositionLimitsTx,buildStellarProposeSetPositionManagerTx:()=>g.buildStellarProposeSetPositionManagerTx,buildStellarProposeSetPriceAggregatorTx:()=>g.buildStellarProposeSetPriceAggregatorTx,buildStellarProposeSetSpokeLiquidationCurveTx:()=>g.buildStellarProposeSetSpokeLiquidationCurveTx,buildStellarProposeSetSwapAggregatorTx:()=>g.buildStellarProposeSetSwapAggregatorTx,buildStellarProposeTransferCtrlOwnershipTx:()=>g.buildStellarProposeTransferCtrlOwnershipTx,buildStellarProposeTransferGovOwnTx:()=>g.buildStellarProposeTransferGovOwnTx,buildStellarProposeUnpauseTx:()=>g.buildStellarProposeUnpauseTx,buildStellarProposeUpdateDelayTx:()=>g.buildStellarProposeUpdateDelayTx,buildStellarProposeUpgradeControllerTx:()=>g.buildStellarProposeUpgradeControllerTx,buildStellarProposeUpgradePoolParamsTx:()=>g.buildStellarProposeUpgradePoolParamsTx,buildStellarProposeUpgradePoolTx:()=>g.buildStellarProposeUpgradePoolTx,buildStellarRenewAccountTx:()=>g.buildStellarRenewAccountTx,buildStellarRepayBatchTx:()=>g.buildStellarRepayBatchTx,buildStellarRepayDebtWithCollateralTx:()=>g.buildStellarRepayDebtWithCollateralTx,buildStellarRepayTx:()=>g.buildStellarRepayTx,buildStellarRevokeBlendPoolTx:()=>g.buildStellarRevokeBlendPoolTx,buildStellarRevokeRoleTx:()=>g.buildStellarRevokeRoleTx,buildStellarRevokeTokenTx:()=>g.buildStellarRevokeTokenTx,buildStellarSetAccumulatorTx:()=>g.buildStellarSetAccumulatorTx,buildStellarSetAggregatorTx:()=>g.buildStellarSetAggregatorTx,buildStellarSetMarketOracleConfigTx:()=>g.buildStellarSetMarketOracleConfigTx,buildStellarSetOracleSanityBoundsTx:()=>g.buildStellarSetOracleSanityBoundsTx,buildStellarSetOracleToleranceTx:()=>g.buildStellarSetOracleToleranceTx,buildStellarSetOracleTx:()=>g.buildStellarSetOracleTx,buildStellarSetPositionLimitsTx:()=>g.buildStellarSetPositionLimitsTx,buildStellarSetPriceAggregatorTx:()=>g.buildStellarSetPriceAggregatorTx,buildStellarSetSpokeAssetFlagsTx:()=>g.buildStellarSetSpokeAssetFlagsTx,buildStellarSetSwapAggregatorTx:()=>g.buildStellarSetSwapAggregatorTx,buildStellarSupplyBatchTx:()=>g.buildStellarSupplyBatchTx,buildStellarSupplyTx:()=>g.buildStellarSupplyTx,buildStellarSwapCollateralTx:()=>g.buildStellarSwapCollateralTx,buildStellarSwapDebtTx:()=>g.buildStellarSwapDebtTx,buildStellarTransferOwnershipTx:()=>g.buildStellarTransferOwnershipTx,buildStellarUnpauseTx:()=>g.buildStellarUnpauseTx,buildStellarUpdateAccountThresholdTx:()=>g.buildStellarUpdateAccountThresholdTx,buildStellarUpdateIndexesTx:()=>g.buildStellarUpdateIndexesTx,buildStellarUpgradeControllerTx:()=>g.buildStellarUpgradeControllerTx,buildStellarUpgradeLiquidityPoolParamsTx:()=>g.buildStellarUpgradeLiquidityPoolParamsTx,buildStellarWithdrawBatchTx:()=>g.buildStellarWithdrawBatchTx,buildStellarWithdrawTx:()=>g.buildStellarWithdrawTx,buildTx:()=>g.buildTx,burnShares:()=>g.burnShares,computeAccountRisk:()=>g.computeAccountRisk,decodeStellarLendingEvent:()=>g.decodeStellarLendingEvent,decodeStellarLiquidateReturn:()=>g.decodeStellarLiquidateReturn,decodeStellarRouteBytes:()=>g.decodeStellarRouteBytes,depositRateRay:()=>g.depositRateRay,divByIntHalfUp:()=>g.divByIntHalfUp,encodeAssetOracle:()=>g.encodeAssetOracle,encodeInterestRateModel:()=>g.encodeInterestRateModel,encodeMarketOracleConfigInput:()=>g.encodeMarketOracleConfigInput,encodeMarketParamsRaw:()=>g.encodeMarketParamsRaw,encodePositionLimits:()=>g.encodePositionLimits,encodePriceKey:()=>g.encodePriceKey,encodeStrategyPayloadToRouteXdr:()=>g.encodeStrategyPayloadToRouteXdr,extractEventOrder:()=>g.extractEventOrder,getStellarAccountPositions:()=>g.getStellarAccountPositions,getStellarActiveUsersSeries:()=>g.getStellarActiveUsersSeries,getStellarAggregatorQuote:()=>g.getStellarAggregatorQuote,getStellarAsset:()=>g.getStellarAsset,getStellarAssetGraph:()=>g.getStellarAssetGraph,getStellarAssetMarkets:()=>g.getStellarAssetMarkets,getStellarAssetPage:()=>g.getStellarAssetPage,getStellarAssets:()=>g.getStellarAssets,getStellarCampaignLeaderboard:()=>g.getStellarCampaignLeaderboard,getStellarCampaignMe:()=>g.getStellarCampaignMe,getStellarDefiLlamaDimensions:()=>g.getStellarDefiLlamaDimensions,getStellarDeployment:()=>g.getStellarDeployment,getStellarDetailedMarkets:()=>g.getStellarDetailedMarkets,getStellarFeeRevenueSeries:()=>g.getStellarFeeRevenueSeries,getStellarGovernanceProposals:()=>g.getStellarGovernanceProposals,getStellarHolderDistribution:()=>g.getStellarHolderDistribution,getStellarHub:()=>g.getStellarHub,getStellarHubGraph:()=>g.getStellarHubGraph,getStellarHubHolders:()=>g.getStellarHubHolders,getStellarHubs:()=>g.getStellarHubs,getStellarLendingContext:()=>g.getStellarLendingContext,getStellarLendingLiveState:()=>g.getStellarLendingLiveState,getStellarLiquidationsLeaderboard:()=>g.getStellarLiquidationsLeaderboard,getStellarLiquidationsSeries:()=>g.getStellarLiquidationsSeries,getStellarParticipantCounts:()=>g.getStellarParticipantCounts,getStellarPnlByScope:()=>g.getStellarPnlByScope,getStellarPositionsLeaderboard:()=>g.getStellarPositionsLeaderboard,getStellarPositionsPnl:()=>g.getStellarPositionsPnl,getStellarQuoteTokens:()=>g.getStellarQuoteTokens,getStellarRateSpreadSeries:()=>g.getStellarRateSpreadSeries,getStellarReserve:()=>g.getStellarReserve,getStellarReserveGraph:()=>g.getStellarReserveGraph,getStellarReserveHolders:()=>g.getStellarReserveHolders,getStellarReserves:()=>g.getStellarReserves,getStellarRevenueSeries:()=>g.getStellarRevenueSeries,getStellarSpoke:()=>g.getStellarSpoke,getStellarSpokeGraph:()=>g.getStellarSpokeGraph,getStellarSpokeHolders:()=>g.getStellarSpokeHolders,getStellarSpokes:()=>g.getStellarSpokes,getStellarStatsHistory:()=>g.getStellarStatsHistory,getStellarUserActivity:()=>g.getStellarUserActivity,getStellarUserActivityPage:()=>g.getStellarUserActivityPage,getStellarUserHistory:()=>g.getStellarUserHistory,getStellarUserPositions:()=>g.getStellarUserPositions,getStellarVolumeSeries:()=>g.getStellarVolumeSeries,getStellarWalletBalance:()=>g.getStellarWalletBalance,isValidCollectionTicker:()=>u,isValidNftIdentifier:()=>l,liveIndexKey:()=>g.liveIndexKey,mapQuoteResponseToAggregatorSwap:()=>g.mapQuoteResponseToAggregatorSwap,mapQuoteResponseToStrategyPayload:()=>g.mapQuoteResponseToStrategyPayload,mapQuoteResponseToStrategySwap:()=>g.mapQuoteResponseToStrategySwap,mapSorobanError:()=>g.mapSorobanError,mapStellarPositionActivityType:()=>g.mapStellarPositionActivityType,maxBorrow:()=>g.maxBorrow,maxRepay:()=>g.maxRepay,maxSupply:()=>g.maxSupply,maxWithdraw:()=>g.maxWithdraw,mintShares:()=>g.mintShares,mulDivCeil:()=>g.mulDivCeil,mulDivFloor:()=>g.mulDivFloor,mulDivHalfUp:()=>g.mulDivHalfUp,numberToScaled:()=>g.numberToScaled,numberToWad:()=>g.numberToWad,positionValueWad:()=>g.positionValueWad,prepareStellarBuiltTx:()=>g.prepareStellarBuiltTx,prepareStellarTxXdr:()=>g.prepareStellarTxXdr,projectAccountRisk:()=>g.projectAccountRisk,projectReserveApy:()=>g.projectReserveApy,rayAprToApy:()=>g.rayAprToApy,rayAprToNumber:()=>g.rayAprToNumber,rayToNumber:()=>g.rayToNumber,rescaleCeil:()=>g.rescaleCeil,rescaleFloor:()=>g.rescaleFloor,rescaleHalfUp:()=>g.rescaleHalfUp,reserveKey:()=>g.reserveKey,resolveReserve:()=>g.resolveReserve,stellarAuthPolicyForInvocation:()=>g.stellarAuthPolicyForInvocation,stellarLendingDispatchKey:()=>g.stellarLendingDispatchKey,stellarLendingRead:()=>g.stellarLendingRead,stellarNetworks:()=>g.stellarNetworks,stellarTokenContractId:()=>g.stellarTokenContractId,syntheticEventOrder:()=>g.syntheticEventOrder,tagStellarInvokedContractError:()=>g.tagStellarInvokedContractError,toBase64Xdr:()=>g.toBase64Xdr,toBigInt:()=>g.toBigInt,toStellarPositionMode:()=>g.toStellarPositionMode,unscale:()=>g.unscale,unscaleBorrowCeil:()=>g.unscaleBorrowCeil,unscaleHalfUp:()=>g.unscaleHalfUp,unscaleSupplyFloor:()=>g.unscaleSupplyFloor,utilizationRay:()=>g.utilizationRay,valueBasePosition:()=>g.valueBasePosition,valueScaledPosition:()=>g.valueScaledPosition,verifyStellarRouteBytes:()=>g.verifyStellarRouteBytes,wadToNumber:()=>g.wadToNumber});const e="erd1qqqqqqqqqqqqqpgq705fxpfrjne0tl3ece0rrspykq88mynn4kxs2cg43s",t="erd1qqqqqqqqqqqqqpgqd9rvv2n378e27jcts8vfwynpx0gfl5ufz6hqhfy0u0",n="erd1qqqqqqqqqqqqqpgq8xwzu82v8ex3h4ayl5lsvxqxnhecpwyvwe0sf2qj4e",i=3e4;var a;!function(e){e.MAINNET="1",e.DEVNET="D"}(a||(a={}));class s{apiUrl;chain;init;config;constructor(r){if(!r?.apiUrl?.trim())throw new Error("XOXNOClient: apiUrl is required");const{chain:o=a.MAINNET,apiUrl:i,...s}=r;this.apiUrl=i.trim().replace(/\/$/,""),this.chain=o,this.init=s,this.config=o==a.MAINNET?{mediaUrl:"https://media.xoxno.com",gatewayUrl:"https://gateway.xoxno.com",XO_SC:"erd1qqqqqqqqqqqqqpgq6wegs2xkypfpync8mn2sa5cmpqjlvrhwz5nqgepyg8",FM_SC:e,DR_SC:t,KG_SC:n,Staking_SC:"erd1qqqqqqqqqqqqqpgqvpkd3g3uwludduv3797j54qt6c888wa59w2shntt6z",Manager_SC:"erd1qqqqqqqqqqqqqpgqg9fa0dmpn8fu3fnleeqn5zt8rl8mdqjkys5s2gtas7",P2P_SC:"erd1qqqqqqqqqqqqqpgq47y8hnct68v6asjv6gxem6h9rumn9frzah0skhxxt6"}:{mediaUrl:"https://devnet-media.xoxno.com",gatewayUrl:"https://devnet-gateway.xoxno.com",XO_SC:"erd1qqqqqqqqqqqqqpgql0dnz6n5hpuw8cptlt00khd0nn4ja8eadsfq2xrqw4",FM_SC:e,DR_SC:t,KG_SC:n,Staking_SC:"erd1qqqqqqqqqqqqqpgqsc5hnewwpep8qq0d7kjjzrquapuucrygah0s85zres",Manager_SC:"erd1qqqqqqqqqqqqqpgqluclyhfsa2uw7q9cjwd8knk989hg57u8ah0slq2nlr",P2P_SC:"erd1qqqqqqqqqqqqqpgqfja7ukpngrun78ueq583l0vd6aj4ekhrah0sa9wyrv"}}fetchWithTimeout=async(e,{params:t,...r}={})=>{const{next:o,cache:n,debug:a,timeout:s,...u}=this.init,{next:l,cache:p,debug:d,timeout:c,headers:f,method:h="GET",...g}=r,y=f?.Authorization,m="Bearer undefined"===y?void 0:y,b="GET"!==h&&"HEAD"!==h&&"PUT"!==h,S={...f,Referer:"https://xoxno.sdk","User-Agent":"XOXNO/1.0/SDK",...b?{"Content-Type":"application/json"}:{},...m?{Authorization:m}:{}},w=Object.entries(t??{}).filter((([,e])=>void 0!==e)).flatMap((([e,t])=>Array.isArray(t)?t.filter((e=>void 0!==e)).map((t=>`${e}=${encodeURIComponent(t)}`)):`${e}=${encodeURIComponent(t)}`)).join("&"),T=`${this.apiUrl}${e}${w.length?`?${w}`:""}`,{revalidate:v,...x}=o??{},{revalidate:A,...I}=l??{},R="GET"!==h||m?void 0:A??v,E="GET"!==h||m||R?void 0:p??n,P=g.body,k=c??s??(null==P?i:0),q=k>0?AbortSignal.timeout(k):void 0,B=g.signal??u.signal,_=q&&B?AbortSignal.any([B,q]):q??B,O={...u,...g,method:h,...Object.keys(S).length?{headers:S}:{},..._?{signal:_}:{},cache:E,next:{...x,...I,revalidate:R}};(d??a)&&console.debug("SDK fetch: ",T,O);const U=await fetch(T,O).catch((e=>{if(e instanceof Error&&!e.message.match(/^http(s?):\/\//))throw Object.assign(new Error(`${T}: ${e.message}`),{cause:e});throw e})),M=await U.text();if(!U.ok){let e;try{e=JSON.parse(M)}catch{e={message:M}}const t=[T,U.status,U.statusText,e.message].filter(Boolean).join(";;");throw new Error(t)}try{return JSON.parse(M)}catch{return M}}}const u=e=>{const t=/^0x[a-fA-F0-9]{1,64}-[a-zA-Z0-9_]+-[a-zA-Z0-9_]+(<.+>)?$/.test(decodeURIComponent(e)),r=/^[A-Z0-9]{3,10}-[a-z0-9]{6}$/.test(e),o=/^C[A-Z2-7]{55}$/.test(e);return t||r||o},l=e=>{const t=/^0x[a-fA-F0-9]{1,64}$/.test(e),r=/^[A-Za-z0-9]{3,10}-[A-Za-z0-9]{6}-[A-Za-z0-9]{2,7}(?:-\d+(?:-[A-Za-z0-9]+)?)?$/.test(e),o=/^C[A-Z2-7]{55}-\d+$/.test(e);return t||r||o};class p extends Error{constructor(e){super(`Invalid collection ticker: ${e}`)}}class d extends Error{constructor(e){super(`Invalid address: ${e}`)}}Error,Error;const c=e=>!!e&&(e.startsWith("erd1")&&62===e.length||/^0x[a-fA-F0-9]{40,64}$/.test(e)||/^[1-9A-HJ-NP-Za-km-z]{32,44}$/.test(e)||/^[GC][A-Z2-7]{55}$/.test(e)),f={"/liquid/xoxno/rate":{input:{},output:{}},"/liquid/xoxno/liquid-supply":{input:{},output:{}},"/liquid/xoxno/staked":{input:{},output:{}},"/user/login":{input:{},output:{},POST:{input:{},output:{},body:{}}},"/user/:address/network-account":{input:{},output:{}},"/user/:address/token-inventory":{input:{},output:{}},"/user/network-account":{input:{},output:{},POST:{input:{},output:{},body:{}}},"/user/me/profile":{input:{},output:{},securityMode:"requiredAny"},"/user/:address/profile":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/me":{input:{},output:{},securityMode:"requiredAny"},"/user/me/settings":{input:{},output:{},securityMode:"optionalAny"},"/user/me/settings/notification-preferences":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"optionalAny"}},"/user/me/settings/email":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"},DELETE:{input:{},output:{},body:{},securityMode:"requiredJwt"}},"/user/me/settings/phone":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/me/settings/billing":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/me/settings/verify-email":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/buy/signature":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/upload-picture":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/upload-banner":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/reset-picture":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/reset-banner":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:tag/creator/is-registered":{input:{},output:{}},"/user/:address/creator/profile":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/creator/upload-picture":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/creator/upload-banner":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/creator/reset-picture":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/creator/reset-banner":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/favorite/collections":{input:{},output:{}},"/user/favorite/:favoriteId":{input:{},output:{},securityMode:"requiredAny"},"/user/:address/follow":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/favorite/users":{input:{},output:{}},"/tokens":{input:{},output:{}},"/tokens/swap":{input:{},output:{}},"/stellar/tokens":{input:{},output:{}},"/tokens/restricted":{input:{},output:{}},"/tokens/usd-price":{input:{},output:{}},"/tokens/egld/fiat-price":{input:{},output:{}},"/tokens/xoxno/info":{input:{},output:{}},"/liquid/xoxno/stats":{input:{},output:{}},"/liquid/egld/stats":{input:{},output:{}},"/liquid/sui/stats":{input:{},output:{}},"/analytics/marketplace-unique-users":{input:{},output:{}},"/integrations/liquid-staking/multiversx/revenue":{input:{},output:{}},"/liquid/egld/rate":{input:{},output:{}},"/liquid/egld/liquid-supply":{input:{},output:{}},"/liquid/egld/staked":{input:{},output:{}},"/liquid/egld/pending-fees":{input:{},output:{}},"/liquid/egld/pending-undelegate":{input:{},output:{}},"/liquid/egld/pending-delegate":{input:{},output:{}},"/liquid/egld/execute-delegate":{input:{},output:{}},"/liquid/egld/execute-undelegate":{input:{},output:{}},"/liquid/egld/execute-undelegate-providers":{input:{},output:{}},"/liquid/egld/protocol-apr":{input:{},output:{}},"/liquid/egld/providers":{input:{},output:{}},"/user/:address/delegation":{input:{},output:{}},"/lending/market/:token/profile":{input:{},output:{}},"/lending/market/query":{input:{},output:{}},"/lending/governance/proposals":{input:{},output:{}},"/lending/governance/proposal/:id":{input:{},output:{}},"/user/lending/:address":{input:{},output:{}},"/lending/market/indexes":{input:{},output:{}},"/user/lending/position/:identifier":{input:{},output:{}},"/lending/pnl":{input:{},output:{}},"/user/lending/pnl/:address":{input:{},output:{}},"/user/lending/summary/:identifier":{input:{},output:{}},"/user/lending/image/:nonce":{input:{},output:{}},"/lending/market/emode-categories":{input:{},output:{}},"/lending/market/:token/emode-categories":{input:{},output:{}},"/lending/market/:token/analytics":{input:{},output:{}},"/lending/stats/history":{input:{},output:{}},"/lending/market/:token/average":{input:{},output:{}},"/lending/leaderboard":{input:{},output:{}},"/lending/leaderboard/liquidate":{input:{},output:{}},"/lending/leaderboard/clean-bad-debt":{input:{},output:{}},"/lending/stats":{input:{},output:{}},"/lending/market/prices":{input:{},output:{}},"/integrations/lending/stellar":{input:{},output:{}},"/integrations/lending/multiversx":{input:{},output:{}},"/integrations/lending/multiversx/revenue":{input:{},output:{}},"/integrations/lending/multiversx/liquidations":{input:{},output:{}},"/integrations/lending/multiversx/active-users":{input:{},output:{}},"/integrations/lending/stellar/history":{input:{},output:{}},"/integrations/lending/stellar/revenue":{input:{},output:{}},"/integrations/lending/stellar/active-users":{input:{},output:{}},"/nft/query":{input:{},output:{}},"/nft/:identifier/like":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/inventory-summary":{input:{},output:{}},"/user/:address/offers":{input:{},output:{}},"/nft/offer/query":{input:{},output:{}},"/nft/offer/:identifier":{input:{},output:{}},"/user/:address/favorite/nfts":{input:{},output:{}},"/collection/:collection/attributes":{input:{},output:{}},"/nft/:identifier/offers":{input:{},output:{}},"/collection/:collection/ranks":{input:{},output:{}},"/collection/:collection/listings":{input:{},output:{}},"/nft/pinned":{input:{},output:{}},"/nft/sign-withdraw":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/collection/:collection/sign-offer":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/collection/:collection/sign-mint":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/nft/:identifier":{input:{},output:{}},"/collection/:collection/profile":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/collection/:collection/floor-price":{input:{},output:{}},"/collection/floor-price":{input:{},output:{}},"/collection/pinned":{input:{},output:{}},"/collection/pinned-drops":{input:{},output:{}},"/collection/:collection/pinned-drops":{input:{},output:{}},"/collection/:collection/pinned":{input:{},output:{}},"/collection/:collection/follow":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/collection/query":{input:{},output:{}},"/collection/drops/query":{input:{},output:{}},"/collection/:collection/drop-info":{input:{},output:{},securityMode:"optionalAny"},"/collection/:creatorTag/:collectionTag/drop-info":{input:{},output:{},securityMode:"optionalAny"},"/collection/:collection/upload-picture":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/collection/:collection/upload-banner":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/collection/:collection/reset-picture":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/collection/:collection/reset-banner":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/collection/:collection/holders":{input:{},output:{}},"/collection/:collection/holders/export":{input:{},output:{}},"/collection/:collection/owner":{input:{},output:{}},"/collection/:collection/stats":{input:{},output:{}},"/collection/stats/query":{input:{},output:{}},"/collection/global-offer/query":{input:{},output:{}},"/user/:address/creator/listing":{input:{},output:{}},"/user/:address/creator/details":{input:{},output:{}},"/launchpad/:scAddress/shareholders/royalties":{input:{},output:{}},"/launchpad/:scAddress/shareholders/collection/:collectionTag":{input:{},output:{}},"/pool/:poolId/profile":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/pool/:poolId/whitelist":{input:{},output:{}},"/pool/:poolId/upload-picture":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/:address/staking/available-pools":{input:{},output:{}},"/user/:address/staking/owned-collections":{input:{},output:{}},"/user/:address/staking/owned-pools":{input:{},output:{}},"/user/:address/staking/summary":{input:{},output:{}},"/user/:address/staking/creator":{input:{},output:{}},"/user/:address/staking/collection/:collection":{input:{},output:{}},"/user/:address/staking/pool/:poolId/nfts":{input:{},output:{}},"/collection/:collection/staking/summary":{input:{},output:{},securityMode:"optionalAny"},"/collection/:collection/staking/delegators":{input:{},output:{}},"/collection/staking/explore":{input:{},output:{}},"/user/:creatorTag/owned-services":{input:{},output:{}},"/search":{input:{},output:{}},"/user/search":{input:{},output:{}},"/collection/search":{input:{},output:{}},"/collection/drops/search":{input:{},output:{}},"/nft/search/query":{input:{},output:{}},"/lending/market-sc":{input:{},output:{}},"/lending/active-accounts":{input:{},output:{}},"/lending/account/:nonce/attributes":{input:{},output:{}},"/lending/account/:nonce/positions":{input:{},output:{}},"/lending/market/:token/price/egld":{input:{},output:{}},"/faucet":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/stellar-lending/assets":{input:{},output:{}},"/stellar-lending/context":{input:{},output:{}},"/stellar-lending/live-state":{input:{},output:{}},"/stellar-lending/markets/detailed":{input:{},output:{}},"/stellar-lending/hubs":{input:{},output:{}},"/stellar-lending/spokes":{input:{},output:{}},"/stellar-lending/reserves":{input:{},output:{}},"/stellar-lending/reserves/:spokeId/:hubId/:asset":{input:{},output:{}},"/stellar-lending/reserves/:spokeId/:hubId/:asset/holders":{input:{},output:{}},"/stellar-lending/hubs/:hubId/holders":{input:{},output:{}},"/stellar-lending/spokes/:spokeId/holders":{input:{},output:{}},"/stellar-lending/assets/:asset":{input:{},output:{}},"/stellar-lending/assets/:asset/page":{input:{},output:{}},"/stellar-lending/assets/:asset/markets":{input:{},output:{}},"/stellar-lending/hubs/:hubId":{input:{},output:{}},"/stellar-lending/spokes/:spokeId":{input:{},output:{}},"/stellar-lending/users/:owner/positions":{input:{},output:{}},"/stellar-lending/users/:owner/activity":{input:{},output:{}},"/stellar-lending/accounts/:accountId/positions":{input:{},output:{}},"/stellar-lending/governance/proposals":{input:{},output:{}},"/stellar-lending/assets/:asset/graph":{input:{},output:{}},"/stellar-lending/hubs/:hubId/graph":{input:{},output:{}},"/stellar-lending/spokes/:spokeId/graph":{input:{},output:{}},"/stellar-lending/reserves/:spokeId/:hubId/:asset/graph":{input:{},output:{}},"/stellar-lending/stats/history":{input:{},output:{}},"/stellar-lending/pnl":{input:{},output:{}},"/stellar-lending/campaign/leaderboard":{input:{},output:{}},"/stellar-lending/campaign/me":{input:{},output:{}},"/stellar-lending/positions":{input:{},output:{}},"/stellar-lending/users/:accountId/history":{input:{},output:{}},"/stellar-lending/pnl/scope":{input:{},output:{}},"/stellar-lending/revenue":{input:{},output:{}},"/stellar-lending/revenue/fees":{input:{},output:{}},"/stellar-lending/participants":{input:{},output:{}},"/stellar-lending/liquidations":{input:{},output:{}},"/stellar-lending/liquidations/leaderboard":{input:{},output:{}},"/stellar-lending/volume":{input:{},output:{}},"/stellar-lending/active-users":{input:{},output:{}},"/stellar-lending/distribution":{input:{},output:{}},"/stellar-lending/rate-spread":{input:{},output:{}},"/stellar-lending/defillama":{input:{},output:{}},"/user/notifications":{input:{},output:{},securityMode:"requiredAny"},"/user/notifications/unread-count":{input:{},output:{},securityMode:"requiredAny"},"/user/notifications/clear":{input:{},output:{},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/notifications/read":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/mobile/device/register":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredWeb2"}},"/mobile/device/:deviceId":{input:{},output:{},securityMode:"requiredWeb2",DELETE:{input:{},output:{},body:{},securityMode:"requiredWeb2"}},"/mobile/history":{input:{},output:{},securityMode:"requiredAny"},"/mobile/history/unread-count":{input:{},output:{},securityMode:"requiredAny"},"/mobile/history/:notificationId/read":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/mobile/history/read-all":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/mobile/history/clear-all":{input:{},output:{},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/mobile/history/clear-id/:notificationId":{input:{},output:{},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/eventNotifications/event/:eventId/update":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/eventNotifications/event/:eventId/reminder":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/eventNotifications/creator/marketing":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/eventNotifications/user/:userId/direct":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/stellar/challenge":{input:{},output:{}},"/user/native-token":{input:{},output:{}},"/user/web2":{input:{},output:{},securityMode:"requiredWeb2"},"/user/web2/session-cookie":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredWeb2"}},"/user/web2/wallet":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredWeb2"}},"/user/web2/wallet-switch":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredWeb2"}},"/user/web2/wallet-link":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredWeb2"}},"/user/web2/:index/wallet-link":{input:{},output:{},DELETE:{input:{},output:{},body:{},securityMode:"requiredWeb2"}},"/user/web2/shards":{input:{},output:{},securityMode:"requiredWeb2"},"/activity/query":{input:{},output:{}},"/activity/:identifier":{input:{},output:{}},"/analytics/volume":{input:{},output:{}},"/collection/:collection/analytics/volume":{input:{},output:{}},"/collections/analytics/volume":{input:{},output:{}},"/user/:address/analytics/volume":{input:{},output:{}},"/analytics/overview":{input:{},output:{}},"/user/stats":{input:{},output:{}},"/user/xoxno-drop":{input:{},output:{}},"/user/me/xoxno-drop":{input:{},output:{},securityMode:"requiredAny"},"/transactions/:txHash":{input:{},output:{}},"/transactions/:txHash/status":{input:{},output:{}},"/transaction/cost":{input:{},output:{},POST:{input:{},output:{},body:{}}},"/transactions":{input:{},output:{},POST:{input:{},output:{},body:{}}},"/transactions/batch":{input:{},output:{},POST:{input:{},output:{},body:{}}},"/user/chat/message":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/chat/conversation":{input:{},output:{},securityMode:"requiredAny"},"/user/chat/conversation/:conversationId":{input:{},output:{},securityMode:"requiredAny",DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/chat/conversation-summary":{input:{},output:{},securityMode:"requiredAny"},"/user/chat/conversation/:conversationId/message/:messageId":{input:{},output:{},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/chat/block":{input:{},output:{},securityMode:"requiredAny"},"/user/chat/block/:address":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/chat/token":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/hatom/user/:address":{input:{},output:{}},"/countries":{input:{},output:{}},"/event":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId":{input:{},output:{},securityMode:"optionalAny",PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/profile/query":{input:{},output:{}},"/event/:eventId/profile":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/background":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/description":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/description/image":{input:{},output:{},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/description/image/:imageId":{input:{},output:{},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/register":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/ticket":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/ticket/:ticketId":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"},PUT:{input:{},output:{},body:{},securityMode:"requiredAny"},POST:{input:{},output:{},body:{}}},"/event/:eventId/stage":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/stage/:stageId":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/calculate-prices":{input:{},output:{},POST:{input:{},output:{},body:{}}},"/event/:eventId/validate-discount":{input:{},output:{},POST:{input:{},output:{},body:{}}},"/user/:address/creator/events":{input:{},output:{},securityMode:"optionalAny"},"/event/:eventId/invite":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/invite/query":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/invite/:inviteId":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/voucher/query":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/questions":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/question":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/question/:questionId":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/guest/query":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/guest/:address":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/guest-export":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/role":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"},securityMode:"requiredAny"},"/event/:eventId/role/:roleId":{input:{},output:{},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/guest":{input:{},output:{},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/roleOf/:address":{input:{},output:{},securityMode:"requiredAny"},"/user/me/event":{input:{},output:{},securityMode:"requiredAny"},"/user/me/events/past":{input:{},output:{},securityMode:"requiredAny"},"/user/me/events/hosted":{input:{},output:{},securityMode:"requiredAny"},"/user/me/events/upcoming":{input:{},output:{},securityMode:"requiredAny"},"/user/me/event/badge":{input:{},output:{},securityMode:"requiredAny"},"/user/me/event/badge/payload":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/scan":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/voucher":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/voucher/:voucherCode":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/manual-check-in":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/answered-questions/:address":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/guest/approve":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/google-pass/:address":{input:{},output:{}},"/event/profile/location":{input:{},output:{}},"/event/:eventId/referral-config":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/referral-config/:configId":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/referral-configs":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/referral":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/referral/:referralCode":{input:{},output:{},PATCH:{input:{},output:{},body:{},securityMode:"requiredAny"},DELETE:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/event/:eventId/referrals":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/referrals/self-serviced":{input:{},output:{},securityMode:"requiredAny"},"/event/:eventId/notify-attendees":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/notify/global-broadcast":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/user/blend/:address":{input:{},output:{}},"/stellar/aggregator/quote":{input:{},output:{}},"/perp/exchange/acceptTerms":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/perp/exchange/sendAsset":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/perp/exchange/sendExternalAsset":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/perp/exchange/deposit":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/perp/exchange/withdraw":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/perp/exchange/order":{input:{},output:{},POST:{input:{},output:{},body:{},securityMode:"requiredAny"}},"/tradingview/bars/:symbol":{input:{},output:{}},"/tradingview/coin/:symbol":{input:{},output:{}},"/perp/coin/:symbol":{input:{},output:{}},"/perp/coin/spot/:symbol":{input:{},output:{}},"/perp/coins":{input:{},output:{}},"/perp/legal-check/:address":{input:{},output:{}},"/perp/coins/spot":{input:{},output:{}},"/perp/orderbook/:symbol":{input:{},output:{}},"/perp/trades/:symbol":{input:{},output:{}},"/perp/stats/spot/:symbol":{input:{},output:{}},"/perp/stats/:symbol":{input:{},output:{}},"/perp/subscribe":{input:{},output:{},POST:{input:{},output:{},body:{}}},"/perp/unsubscribe":{input:{},output:{},POST:{input:{},output:{},body:{}}},"/stellar-lending/users/:owner/assets/:asset/balance":{input:{},output:{}},"/stellar-lending/users/:owner/activity/page":{input:{},output:{}}},h=["PATCH","POST","DELETE","PUT"];var g=r(723);const y=e=>e.replace(/-([a-z])/g,((e,t)=>t.toUpperCase())),m=()=>({static:{},params:{},leaves:[]});function b(e,t,r,o){const{input:n,output:i,...a}=t,s=async(t={})=>{const n={...r,...t},i=e.replace(/:([a-zA-Z_]+)/g,((e,t)=>`${n[t]}`)),a=[...e.matchAll(/:([a-zA-Z_]+)/g)].map((e=>e[1])),s=Object.fromEntries(Object.entries(n).filter((([e])=>!a.includes(e)))),l=/:address[^A-Z]/.test(e)||"address"in s,f=/:collection[^A-Z]/.test(e)||"collection"in s;if(l){const e=n.address;if(!c(e))throw new d(e)}if(f){const e=n.collection;if(Array.isArray(e)?e.some((e=>!u(e))):!u(e))throw new p(e)}const h=Object.fromEntries(Object.entries(s).map((([e,t])=>[e,t instanceof FormData?t:"filter"===e||"body"===e?JSON.stringify(t):Array.isArray(t)?t.join(","):t]))),{body:g,auth:y,method:m,headers:b,cache:S,next:w,debug:T,signal:v,credentials:x,mode:A,redirect:I,referrer:R,referrerPolicy:E,integrity:P,keepalive:k,priority:q,window:B,continuationToken:_,...O}=h,U=y?`Bearer ${y}`:void 0;e.startsWith("/stellar-lending/")&&void 0!==_&&(O.continuationToken=_);const M={...b,...U?{Authorization:U}:{},..._&&!e.startsWith("/stellar-lending/")?{"X-Continuation-Token":String(_)}:{}},C={...w,tags:[...w?.tags??[],i]};return o.fetchWithTimeout(i,{method:m,params:O,body:g,headers:M,cache:S,debug:T,...Object.fromEntries(Object.entries({signal:v,credentials:x,mode:A,redirect:I,referrer:R,referrerPolicy:E,integrity:P,keepalive:k,priority:q,window:B}).filter((([,e])=>void 0!==e))),...C?{next:C}:{}})},l=(e={})=>s(e);for(const e of Object.keys(a))h.includes(e)&&(l[e]=t=>s({...t,method:t.method??e.toUpperCase()}));return l}function S(e){const t=function(){const e=m();for(const[t,r]of Object.entries(f)){const o=t.split("/").filter(Boolean);let n=e;for(const e of o)if(e.startsWith(":")){const t=y(e.slice(1));n=n.params[t]||=m()}else{const t=y(e);n=n.static[t]||=m()}n.leaves.push({rawPath:t,def:r})}return e}(),r=(t,o)=>{const n=t.leaves.length,i=Object.keys(t.static).length,a=Object.keys(t.params).length;let s;if(1===n&&i+a>0){const{rawPath:r,def:n}=t.leaves[0];s=b(r,n,o,e)}else{s={};for(const{rawPath:r,def:n}of t.leaves)s[y(r.split("/").pop().replace(/^:/,""))]=b(r,n,o,e)}for(const[e,n]of Object.entries(t.static)){const t=r(n,o);let i=t;if(t&&"object"==typeof t&&e in t&&"function"==typeof t[e]){const r=t[e],o=Object.fromEntries(Object.entries(t).filter((([t])=>t!==e)));1===r.length||(Object.assign(r,o),i=r)}void 0===s[e]?s[e]=i:"function"==typeof s[e]?Object.assign(s[e],i):"function"==typeof i?(Object.assign(i,s[e]),s[e]=i):Object.assign(s[e],i)}for(const[e,n]of Object.entries(t.params)){const t=t=>{const i=r(n,{...o,[e]:t});if(i&&"object"==typeof i&&1===Object.keys(i).length&&e in i&&"function"==typeof i[e]){const t=i[e],r=(...e)=>t(...e);return Object.assign(r,t)}return i};if(s[e]){const r=s[e];s[e]=e=>({...r(e),...t(e)})}else s[e]=t}return s};return r(t,{})}})(),module.exports=o})();
|