@ethersphere/bee-js 13.2.1-upcoming.g0a9168d → 13.2.1-upcoming.g612af23
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.
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/*! For license information please see index.browser.min.js.LICENSE.txt */
|
|
2
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.BeeJs=t():e.BeeJs=t()}(this,(()=>(()=>{var e={20(e,t){"use strict";var n;async function r(e){return new Promise(((t,n)=>e.then(n,t)))}async function o(e){return new Promise((t=>setTimeout((()=>{t(!0)}),e)))}function i(e,t=Math.random){for(let n=e.length-1;n>0;n--){const r=Math.floor(t()*(n+1)),o=e[n];e[n]=e[r],e[r]=o}return e}function s(e,t,n=Math.random){return i(H(0,e.length-1),n).slice(0,t)}function a(e,t,n=Math.random){return Math.floor(n()*(t-e+1))+e}function c(e,t,n){return t>=e.x&&t<e.x+e.width&&n>=e.y&&n<e.y+e.height}function u(e,t=Math.random){return t()<e}function l(e,t=Math.random){return e[Math.floor(e.length*t())]}function f(e){if(!e.length)throw Error("Received empty array");return e[e.length-1]}function h(e,t,n){return n(t.reduce(((e,t)=>t(e)),e))}function d(e,t){if(null==e)return null;const n=t.split(".");let r=e;for(const o of n){if(null===r[o]||void 0===r[o])return null;r=r[o]}return r}function p(e,t,n){const r=t.split(/\.|\[/);let o=e;for(let i=0;i<r.length;i++){const e=r[i],t=i<r.length-1&&r[i+1].includes("]"),s=e.includes("]")?e.replace(/\[|\]/g,""):e;if(i===r.length-1)return o[s]=n,n;g(o[s])||(o[s]=t?[]:{}),o=o[s]}return n}function m(e,t){return Math.round(e/t)*t}function g(e,t=!0){return!(!e||t&&!b(e._readableState)||t&&e.constructor&&(e.constructor.isBuffer||"AbortController"==e.constructor.name||"AbortSignal"==e.constructor.name||"Uint8Array"==e.constructor.name||"ArrayBuffer"===e.constructor.name||"ReadableStream"===e.constructor.name))&&"object"==typeof e}function y(e){return g(e)&&!Array.isArray(e)}function w(e){return Array.isArray(e)&&0===e.length}function b(e){return void 0===e}function v(e){return"[object Function]"===Object.prototype.toString.call(e)||"[object AsyncFunction]"===Object.prototype.toString.call(e)}function B(e){return"[object String]"===Object.prototype.toString.call(e)}function E(e){return"number"==typeof e&&isFinite(e)}function x(e){return!0===e||!1===e}function T(e){return"[object Date]"===Object.prototype.toString.call(e)}function R(e){return!B(e)||0===e.trim().length}function z(e){return E(e)&&Number.isInteger(e)&&e>=1}function A(e){return B(e)&&null!==e.match(/^-?\d+$/)}function k(e){return B(e)&&null!==e.match(/^(0x)?[0-9a-f]+$/i)}t.DH=t.Or=t.Rb=t.AO=t.FQ=t.iQ=t.DO=t.o8=t.yI=t.O3=t.ie=t.Xx=void 0;const S="!@#$%^&*()_+-=[]{}|;:<>?,./".split(""),O="abcdefghijklmnopqrstuvwxyz",$=O+"ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890",I=$+"!@#$%^&*()_+-=[]{}|;:<>?,./",_=["—","\\","東","京","都","𝖆","𝖇","𝖈","👾","🙇","💁","🙅","ᚠ","ᛇ","ᚻ","ᛦ"],V="0123456789abcdef";function D(e,t){if(R(e))throw new TypeError(`Expected string${t?.name?` for ${t.name}`:""}, got: `+e);if(t&&(void 0!==t.min&&e.length<t.min||void 0!==t.max&&e.length>t.max))throw RangeError(`Expected string${t?.name?` for ${t.name}`:""} length in range: ${t.min??"-inf"}..${t.max??"inf"}; got: ${e.length}`);return e}function P(e,t){if(void 0!==t.min&&e<t.min||void 0!==t.max&&e>t.max)throw RangeError(`Expected value${t?.name?` for ${t.name}`:""} in range: ${t.min??"-inf"}..${t.max??"inf"}; got: ${e}`)}function N(e,t){if(E(e))return t&&P(e,t),e;if(!B(e)||!e.match(/^-?\d+(\.\d+)?$/))throw new TypeError(`Expected number${t?.name?` for ${t.name}`:""}, got: `+e);const n=parseFloat(e);return t&&P(n,t),n}function C(e,t){return Math.trunc(N(e,t))}function F(e,t){if(!y(e))throw new TypeError(`Expected object${t?.name?` for ${t.name}`:""}, got: `+e);return e}function M(e){return B(e)&&null!==e.match(/^https?:\/\/.+/)}function U(e){return"bigint"==typeof e}function G(e,t){if(!U(e))throw new TypeError(`Expected bigint${t?.name?` for ${t.name}`:""}, got: `+e);if(void 0!==t?.min&&e<t?.min||void 0!==t?.max&&e>t?.max)throw RangeError(`Expected value${t?.name?` for ${t.name}`:""} in range: ${t.min??"-inf"}..${t.max??"inf"}; got: ${e}`);return e}function L(e,t){for(const[n,r]of Object.entries(t))if(!r(e[n]))throw TypeError(`${n} in value does not exist or match shape`);for(const n of Object.keys(e))if(!t[n])throw TypeError(`${n} exists in value but not in shape`);return!0}function j(e,t){if(y(e)&&y(t))for(const n in t)y(t[n])?(e[n]||(e[n]={}),j(e[n],t[n])):Array.isArray(t[n])?e[n]=[...t[n]]:(null!==t[n]&&void 0!==t[n]||null===e[n]||void 0===e[n])&&(e[n]=t[n]);return e}function Z(e,t){const n={};for(const r of e)for(const e of Object.keys(r))n[e]?n[e]=t(n[e],r[e]):n[e]=r[e];return n}function q(e,t){Array.prototype.push.apply(e,t)}function H(e,t){const n=[];for(let r=e;r<=t;r++)n.push(r);return n}function W(e,t=()=>!1){return e.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"").split("").map((e=>/[a-z0-9]/.test(e)||t(e)?e:"-")).join("").replace(/-+/g,"-").replace(/^-|-$/g,"")}function J(e,t){if(0===t.length)return 0;const n=e.toLowerCase(),r=t.toLowerCase();return e===t?1e4:n.startsWith(r)?1e4-e.length:n.includes(r)?5e3-e.length:new RegExp(".*"+r.split("").join(".*")+".*").test(n)?1e3-e.length:0}const K={"&":"&",""":'"',"'":"'",">":">","<":"<"};function X(e,t){const n=e.indexOf(t);return-1===n?null:e.slice(0,n)}function Y(e,t){const n=e.indexOf(t);return-1===n?null:e.slice(n+t.length)}function Q(e,t){const n=e.lastIndexOf(t);return-1===n?null:e.slice(0,n)}function ee(e,t){const n=e.lastIndexOf(t);return-1===n?null:e.slice(n+t.length)}function te(e,t,n=!1){const r=n?e.lastIndexOf(t):e.indexOf(t);return-1===r?n?[null,e]:[e,null]:[e.slice(0,r),e.slice(r+t.length)]}function ne(e,t){let n=[e];for(const r of t)n=n.flatMap((e=>e.split(r)));return n.filter((e=>e))}function re(e){const t=f(e.split(/\\|\//g)),n=t.lastIndexOf(".",t.length-1);return n<=0?"":t.slice(n+1)}function oe(e){const t=f(e.split(/\\|\//g)),n=t.lastIndexOf(".",t.length-1);return n<=0?t:t.slice(0,n)}function ie(e){return e.split("\n").map((e=>e.trim().replace(/\s+/g," "))).filter((e=>e.length>0)).join("\n")}function se(e){return e.charAt(0).toUpperCase()+e.slice(1)}function ae(e){return e.charAt(0).toLowerCase()+e.slice(1)}function ce(e){if(!e)return!1;const t=e.charCodeAt(0);return t>=65&&t<=90||t>=97&&t<=122}function ue(e){if(!e)return!1;const t=e.charCodeAt(0);return t>=48&&t<=57}function le(e){return ce(e)||ue(e)}const fe=" \n\t\r.,?!:;\"'`(){}[]~@#$%^&*-+=|<>/\\".split("");function he(e){return fe.includes(e)}function de(e,t,n=0){const r=t.exec(e.slice(n));return r?{index:r.index,match:r[0]}:null}function pe(e,t,n=!0){if(!n)return t.every((t=>t instanceof RegExp?t.test(e):-1!==e.indexOf(t,0)));let r=0;for(const o of t)if(o instanceof RegExp){const t=de(e,o,r);if(!t)return!1;r=t.index+t.match.length}else{const t=e.indexOf(o,r);if(-1===t)return!1;r=t+o.length}return!0}function me(e,t,n=0){const r=[];let o=e.indexOf(t,n);for(;-1!==o;)r.push(o),o=e.indexOf(t,o+t.length);return r}function ge(e,t,n=0){let r=-1;for(const o of t){const t=e.indexOf(o,n);-1!==t&&(-1===r||t<r)&&(r=t)}return r}function ye(e,t=0){for(let n=t;n<e.length;n++)if(he(e[n]))return n;return-1}function we(e,t=0){for(let n=t;n<e.length;n++)if("#"===e[n]&&le(e[n+1]))return n;return-1}function be(e,t,n=0){return e.slice(0,n).lastIndexOf(t)}function ve(e,t=0,n="{",r="}"){let o=1;for(let i=t;i<e.length;i++)if(e.slice(i,i+r.length)===r){if(0==--o)return i}else e.slice(i,i+n.length)===n&&o++;return-1}function Be(e,t){const n=t.wordBoundary?ge(e,[`${t.opening} `,`${t.opening}\n`],t.start||0):e.indexOf(t.opening,t.start||0);if(-1===n)return null;const r=ve(e,n+t.opening.length,t.opening,t.closing);return-1===r?null:t.exclusive?e.slice(n+t.opening.length,r):e.slice(n,r+t.closing.length)}const Ee="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",xe="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";function Te(e,t){const n=t.length;let r=0,o=0;const i=[];for(let s=0;s<e.length;s++){const a=e[s];if("="===a)break;const c=t.indexOf(a);if(-1===c)throw new Error(`Invalid character: ${a}`);o=o<<Math.log2(n)|c,r+=Math.log2(n),r>=8&&(r-=8,i.push(o>>r&255))}return new Uint8Array(i)}function Re(e,t){const n=t.length;let r=0,o=0,i="";for(let s=0;s<e.length;s++)for(o=o<<8|e[s],r+=8;r>=Math.log2(n);)r-=Math.log2(n),i+=t[o>>r&n-1];return r>0&&(i+=t[o<<Math.log2(n)-r&n-1]),i.length%4!=0&&(i+="=".repeat(4-i.length%4)),i}function ze(e,t,n){const r=[];for(const o of n)o!==t&&r.push(e.replace(t,o));return r}function Ae(e){const t=e.lastIndexOf(" ");if(-1===t)return{line:e,rest:""};return{line:e.slice(0,t),rest:e.slice(t+1)}}function ke(e){const t=e.reduce(((e,t)=>e.length<t.length?e:t));let n="";for(let r=0;r<t.length;r++){const o=t[r];if(!e.every((e=>e[r]===o)))break;n+=o}return n}function Se(e,t){return new RegExp(`\\b${t}\\b`).test(e)}function Oe(e,t,n=[]){let r="";for(;t<e.length&&(le(e[t])||n.includes(e[t]));)r+=e[t++];return r}function $e(e,t,n,r="$",o=":"){if(""===n)return e;let i=e.indexOf(`${r}${t}`);for(;-1!==i;){if(e[i+t.length+1]===o)if(e[i+t.length+2]===o)e=e.replace(`${r}${t}${o}${o}`,n);else{const s=Oe(e,i+t.length+2,["_"]);e=e.replace(`${r}${t}${o}${s}`,n)}else e=e.replace(`${r}${t}`,n);i=e.indexOf(`${r}${t}`,i+n.length)}return e}function Ie(e,t="$",n=":"){let r=e.indexOf(t);for(;-1!==r;){const o=Oe(e,r+1);if(e[r+o.length+1]===n)if(e[r+o.length+2]===n)e=e.replace(`${t}${o}${n}${n}`,"");else{const i=Oe(e,r+o.length+2);e=e.replace(`${t}${o}${n}${i}`,i)}r=e.indexOf(t,r+1)}return e}function _e(e,t=!0){const n=Object.entries(e).filter((([e,t])=>null!=t)).map((([e,t])=>`${e}=${encodeURIComponent(t)}`)).join("&");return n?(t?"?":"")+n:""}function Ve(e){return String(Math.floor(e)).padStart(2,"0")}function De(e){const t=Math.floor(e/36e5);e%=36e5;const n=Math.floor(e/6e4);e%=6e4;const r=Math.floor(e/1e3);return t?`${Ve(t)}:${Ve(n)}:${Ve(r)}`:`${Ve(n)}:${Ve(r)}`}function Pe(e){return Math.floor((T(e)?e.getTime():e)/864e5)}const Ne={today:(e,t)=>Ve(e)+":"+Ve(t),yesterday:()=>"Yesterday",monday:()=>"Mon",tuesday:()=>"Tue",wednesday:()=>"Wed",thursday:()=>"Thu",friday:()=>"Fri",saturday:()=>"Sat",sunday:()=>"Sun",weeks:e=>`${e}w`};const Ce={now:()=>"A few seconds",seconds:e=>`${e} seconds`,minutes:e=>`${e} minutes`,hours:e=>`${e} hours`,days:e=>`${e} days`,weeks:e=>`${e} weeks`};function Fe(e,n){const r=n?.now??Date.now(),o=n?.labels||Ce;let i=(r-(t.Or.isDate(e)?e.getTime():e))/1e3;return i<10?o.now():i<120?o.seconds(Math.floor(i)):(i/=60,i<120?o.minutes(Math.floor(i)):(i/=60,i<48?o.hours(Math.floor(i)):(i/=24,i<14?o.days(Math.floor(i)):(i/=7,o.weeks(Math.floor(i))))))}const Me={};const Ue={s:1e3,m:6e4,h:36e5,d:864e5};const Ge={0:"sunday",1:"monday",2:"tuesday",3:"wednesday",4:"thursday",5:"friday",6:"saturday"};function Le(e){return{zeroBasedIndex:e,day:Ge[e]}}function je(e){return Le(e.getDay())}const Ze={ms:1,milli:1,millis:1,millisecond:1,milliseconds:1,s:1e3,sec:1e3,second:1e3,seconds:1e3,m:6e4,min:6e4,minute:6e4,minutes:6e4,h:36e5,hour:36e5,hours:36e5,d:864e5,day:864e5,days:864e5,w:6048e5,week:6048e5,weeks:6048e5,month:2592e6,months:2592e6,y:31536e6,year:31536e6,years:31536e6};const qe={b:0,byte:0,bytes:0,kb:1,kilobyte:1,kilobytes:1,mb:2,megabyte:2,megabytes:2,gb:3,gigabyte:3,gigabytes:3,tb:4,terabyte:4,terabytes:4};const He=new Map;function We(e,t=!1){e=e.filter((e=>e)),t&&B(e[1])&&(e[1]="../"+e[1]);let n="";B(e[0])&&e[0].includes("://")&&(n=X(e[0],"://")??"",e[0]=Y(e[0],"://")??"");const r=e.map((e=>String(e))).flatMap((e=>e.split("/"))),o=[];for(let i=0;i<r.length;i++)"."!==r[i]&&(".."===r[i]?(!n||o.length>1)&&o.pop():o.push(r[i]));return(n?n+"://":"")+o.join("/").replaceAll(/\/{2,}/g,"/")}function Je(e){const t=Object.keys(e).sort(((e,t)=>e.localeCompare(t))),n={};for(const r of t)n[r]=Xe(e[r]);return n}function Ke(e){const t=[];return e.sort(((e,t)=>JSON.stringify(Xe(e)).localeCompare(JSON.stringify(Xe(t))))).forEach((e=>t.push(Xe(e)))),t}function Xe(e){return Array.isArray(e)?Ke(e):g(e)?Je(e):e}function Ye(e,t){return JSON.stringify(Xe(e))===JSON.stringify(Xe(t))}function Qe(e){const t=Object.keys(e);return t[Math.floor(Math.random()*t.length)]}const et=[1e3,1e6,1e9,1e12,1e15,1e18,1e21,1e24,1e27,1e30,1e9,1e16,1e18,1e18,1e18,1e33],tt=["thousand","million","billion","trillion","quadrillion","quintillion","sextillion","septillion","octillion","nonillion","gwei","bzz","btc","eth","dai","decillion"],nt=["K","M","B","T","Qa","Qi","Sx","Sp","O","N","gwei","bzz","eth","btc","dai","D"];function rt(e){const t=parseFloat(e);if(isNaN(t))throw Error("makeNumber got NaN for input");const n=e.replace(/^-?[0-9.]+/,"").trim(),r=nt.findIndex((e=>e.toLowerCase()===n.toLowerCase()));return-1===r?t:t*et[r]}function ot(e,t,n){return e<t?t:e>n?n:e}function it(e,t,n){return e+(n?"["+t+"]":(e.length?".":"")+t)}function st(e,t,n,r,o){if(!g(t))return t;for(const[i,s]of Object.entries(t)){const t=it(n,i,r);Array.isArray(s)?o?st(e,s,t,!0,o):e[t]=s.map((e=>st(Array.isArray(e)?[]:{},e,"",!1,o))):g(s)?st(e,s,t,!1,o):e[t]=s}return e}function at(e,t){const n={};for(const r of e){n[t(r)]=r}return n}function ct(e,t){const n=Math.ceil(e.length/t),r=[];for(let o=0;o<e.length;o+=n)r.push(e.slice(o,o+n));return r}function ut(e,t){const n=[],r=Math.ceil(e.length/t);for(let o=0;o<r;o++)n.push(e.slice(o*t,o*t+t));return n}function lt(e,t){return Object.fromEntries(Object.entries(e).sort(t))}function ft(e,t){const n=[];let r=[];return e.forEach(((o,i)=>{(0===i||!t(o,e[i-1]))&&(r=[],n.push(r)),r.push(o)})),n}function ht(e,t,n,r=100){if(e.map.has(t)){const n=e.keys.indexOf(t);e.keys.splice(n,1)}if(e.map.set(t,n),e.keys.push(t),e.keys.length>r){const t=e.keys.shift();t&&e.map.delete(t)}}class dt{constructor(e){this.value=e}static of(e){return new dt(e)}static empty(){return new dt(null)}map(e){return new dt(null!==this.value&&void 0!==this.value?e(this.value):null)}mapAsync(e){return null!==this.value&&void 0!==this.value?e(this.value).then((e=>dt.of(e))):Promise.resolve(dt.empty())}ifPresent(e){return null!==this.value&&void 0!==this.value&&e(this.value),this}ifPresentAsync(e){return null!==this.value&&void 0!==this.value?e(this.value).then((()=>this)):Promise.resolve(this)}ifAbsent(e){return(null===this.value||void 0===this.value)&&e(),this}ifAbsentAsync(e){return null===this.value||void 0===this.value?e().then((()=>this)):Promise.resolve(this)}getOrFallback(e){return this.value??e()}getOrFallbackAsync(e){return null!==this.value&&void 0!==this.value?Promise.resolve(this.value):e()}getOrThrow(){if(null===this.value||void 0===this.value)throw Error("Optional.value is empty");return this.value}}t.Xx=dt;class pt{constructor(e){this.value=e,this.children=[]}}function mt(e,t){if(Math.log2(e.length)%1!=0)throw new Error("Array length must be a power of 2");let n=[...e];for(;n.length>1;){const e=[];for(let r=0;r<n.length;r+=2){const o=n[r+1];e.push(t(n[r],o))}n=e}return n[0]}function gt(...e){const t=e.reduce(((e,t)=>e+t.length),0),n=new Uint8Array(t);let r=0;return e.forEach((e=>{n.set(e,r),r+=e.length})),n}function yt(e){return 137===e[0]&&80===e[1]&&78===e[2]&&71===e[3]}function wt(e){return 255===e[0]&&216===e[1]}function bt(e){return 87===e[8]&&69===e[9]&&66===e[10]&&80===e[11]}function vt(e,t){const n=new ArrayBuffer(8);return new DataView(n).setBigUint64(0,BigInt(e),"LE"===t),new Uint8Array(n)}function Bt(e,t){const n=new Uint8Array(32);let r=e;if("LE"===t){for(let e=0;e<32;e++)n[e]=Number(0xffn&r),r>>=8n;return n}for(let o=31;o>=0;o--)n[o]=Number(0xffn&r),r>>=8n;return n}function Et(e,t){let n=0n;if("LE"===t){for(let t=31;t>=0;t--)n=n<<8n|BigInt(e[t]);return n}for(let r=0;r<32;r++)n=n<<8n|BigInt(e[r]);return n}function xt(e,t){const n=[];for(let r=0;r<e.length;r+=t)n.push(e.subarray(r,r+t));return n}const Tt=[0,1,0,32898,2147483648,32906,2147483648,2147516416,0,32907,0,2147483649,2147483648,2147516545,2147483648,32777,0,138,0,136,0,2147516425,0,2147483658,0,2147516555,2147483648,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,0,32778,2147483648,2147483658,2147483648,2147516545,2147483648,32896,0,2147483649,2147483648,2147516424];function Rt(e){for(let t=0;t<24;t++){const n=e[0]^e[10]^e[20]^e[30]^e[40],r=e[1]^e[11]^e[21]^e[31]^e[41],o=e[2]^e[12]^e[22]^e[32]^e[42],i=e[3]^e[13]^e[23]^e[33]^e[43],s=e[4]^e[14]^e[24]^e[34]^e[44],a=e[5]^e[15]^e[25]^e[35]^e[45],c=e[6]^e[16]^e[26]^e[36]^e[46],u=e[7]^e[17]^e[27]^e[37]^e[47],l=e[8]^e[18]^e[28]^e[38]^e[48],f=e[9]^e[19]^e[29]^e[39]^e[49],h=l^(o<<1|i>>>31),d=f^(i<<1|o>>>31),p=n^(s<<1|a>>>31),m=r^(a<<1|s>>>31),g=o^(c<<1|u>>>31),y=i^(u<<1|c>>>31),w=s^(l<<1|f>>>31),b=a^(f<<1|l>>>31),v=c^(n<<1|r>>>31),B=u^(r<<1|n>>>31);e[0]^=h,e[1]^=d,e[2]^=p,e[3]^=m,e[4]^=g,e[5]^=y,e[6]^=w,e[7]^=b,e[8]^=v,e[9]^=B,e[10]^=h,e[11]^=d,e[12]^=p,e[13]^=m,e[14]^=g,e[15]^=y,e[16]^=w,e[17]^=b,e[18]^=v,e[19]^=B,e[20]^=h,e[21]^=d,e[22]^=p,e[23]^=m,e[24]^=g,e[25]^=y,e[26]^=w,e[27]^=b,e[28]^=v,e[29]^=B,e[30]^=h,e[31]^=d,e[32]^=p,e[33]^=m,e[34]^=g,e[35]^=y,e[36]^=w,e[37]^=b,e[38]^=v,e[39]^=B,e[40]^=h,e[41]^=d,e[42]^=p,e[43]^=m,e[44]^=g,e[45]^=y,e[46]^=w,e[47]^=b,e[48]^=v,e[49]^=B;const E=e[0],x=e[1],T=e[2]<<1|e[3]>>>31,R=e[3]<<1|e[2]>>>31,z=e[5]<<30|e[4]>>>2,A=e[4]<<30|e[5]>>>2,k=e[6]<<28|e[7]>>>4,S=e[7]<<28|e[6]>>>4,O=e[8]<<27|e[9]>>>5,$=e[9]<<27|e[8]>>>5,I=e[11]<<4|e[10]>>>28,_=e[10]<<4|e[11]>>>28,V=e[13]<<12|e[12]>>>20,D=e[12]<<12|e[13]>>>20,P=e[14]<<6|e[15]>>>26,N=e[15]<<6|e[14]>>>26,C=e[17]<<23|e[16]>>>9,F=e[16]<<23|e[17]>>>9,M=e[18]<<20|e[19]>>>12,U=e[19]<<20|e[18]>>>12,G=e[20]<<3|e[21]>>>29,L=e[21]<<3|e[20]>>>29,j=e[22]<<10|e[23]>>>22,Z=e[23]<<10|e[22]>>>22,q=e[25]<<11|e[24]>>>21,H=e[24]<<11|e[25]>>>21,W=e[26]<<25|e[27]>>>7,J=e[27]<<25|e[26]>>>7,K=e[29]<<7|e[28]>>>25,X=e[28]<<7|e[29]>>>25,Y=e[31]<<9|e[30]>>>23,Q=e[30]<<9|e[31]>>>23,ee=e[33]<<13|e[32]>>>19,te=e[32]<<13|e[33]>>>19,ne=e[34]<<15|e[35]>>>17,re=e[35]<<15|e[34]>>>17,oe=e[36]<<21|e[37]>>>11,ie=e[37]<<21|e[36]>>>11,se=e[38]<<8|e[39]>>>24,ae=e[39]<<8|e[38]>>>24,ce=e[40]<<18|e[41]>>>14,ue=e[41]<<18|e[40]>>>14,le=e[42]<<2|e[43]>>>30,fe=e[43]<<2|e[42]>>>30,he=e[45]<<29|e[44]>>>3,de=e[44]<<29|e[45]>>>3,pe=e[47]<<24|e[46]>>>8,me=e[46]<<24|e[47]>>>8,ge=e[48]<<14|e[49]>>>18,ye=e[49]<<14|e[48]>>>18;e[0]=E^~V&q,e[1]=x^~D&H,e[2]=V^~q&oe,e[3]=D^~H&ie,e[4]=q^~oe&ge,e[5]=H^~ie&ye,e[6]=oe^~ge&E,e[7]=ie^~ye&x,e[8]=ge^~E&V,e[9]=ye^~x&D,e[10]=k^~M&G,e[11]=S^~U&L,e[12]=M^~G&ee,e[13]=U^~L&te,e[14]=G^~ee&he,e[15]=L^~te&de,e[16]=ee^~he&k,e[17]=te^~de&S,e[18]=he^~k&M,e[19]=de^~S&U,e[20]=T^~P&W,e[21]=R^~N&J,e[22]=P^~W&se,e[23]=N^~J&ae,e[24]=W^~se&ce,e[25]=J^~ae&ue,e[26]=se^~ce&T,e[27]=ae^~ue&R,e[28]=ce^~T&P,e[29]=ue^~R&N,e[30]=O^~I&j,e[31]=$^~_&Z,e[32]=I^~j&ne,e[33]=_^~Z&re,e[34]=j^~ne&pe,e[35]=Z^~re&me,e[36]=ne^~pe&O,e[37]=re^~me&$,e[38]=pe^~O&I,e[39]=me^~$&_,e[40]=z^~C&K,e[41]=A^~F&X,e[42]=C^~K&Y,e[43]=F^~X&Q,e[44]=K^~Y&le,e[45]=X^~Q&fe,e[46]=Y^~le&z,e[47]=Q^~fe&A,e[48]=le^~z&C,e[49]=fe^~A&F,e[0]^=Tt[2*t],e[1]^=Tt[2*t+1]}}function zt(e){const t=[];for(let n=0;n<e.length;n+=4)t.push(e[n]|e[n+1]<<8|e[n+2]<<16|e[n+3]<<24);return t}function At(e,t){if(!e.length){const e=new Uint8Array(136);return e[0]=t,e[135]=128,[zt(e)]}const n=xt(e,136),r=n[n.length-1];if(r.length<136){const e=new Uint8Array(136);e.set(r),e[r.length]=t,e[135]|=128,n[n.length-1]=e}if(136===r.length){const e=new Uint8Array(136);e[0]=t,e[135]=128,n.push(e)}return n.map(zt)}function kt(e,t){for(const n of t){for(let t=0;t<34;t+=2)e[t]^=n[t+1],e[t+1]^=n[t];Rt(e)}return e}function St(e){return new Uint8Array([e[1],e[1]>>-24,e[1]>>-16,e[1]>>-8,e[0],e[0]>>8,e[0]>>16,e[0]>>24,e[3],e[3]>>-24,e[3]>>-16,e[3]>>-8,e[2],e[2]>>8,e[2]>>16,e[2]>>24,e[5],e[5]>>-24,e[5]>>-16,e[5]>>-8,e[4],e[4]>>8,e[4]>>16,e[4]>>24,e[7],e[7]>>-24,e[7]>>-16,e[7]>>-8,e[6],e[6]>>8,e[6]>>16,e[6]>>24])}function Ot(e){return St(kt(new Array(50).fill(0),At(e,1)))}function $t(e,t,n=0){if(e.length>=t)return e;const r=new Uint8Array(t);return r.fill(n),r.set(e,t-e.length),r}function It(e,t,n=0){if(e.length>=t)return e;const r=new Uint8Array(t);return r.fill(n),r.set(e,0),r}function _t(e,t){return(e%t+t)%t}function Vt(e,t){_t(e,t);let[n,r]=[0n,1n],[o,i]=[t,e];for(;0n!==i;){const e=o/i;[n,r]=[r,n-e*r],[o,i]=[i,o-e*i]}if(o>1n)throw new Error("a is not invertible");return n<0n&&t,n}function Dt(e,t){return 0n===_t(e,t)?0n:t%4n===3n?function(e,t,n){let r=1n;for(_t(e,n);t>0;)t%2n===1n&&_t(r*e,n),_t(e*e,n);return r}(e,(t+1n)/4n,t):null}const Pt=0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2fn,Nt=0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n,Ct=0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798n,Ft=0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8n;function Mt(e,t,n){if(0n===t)return[0n,0n];const r=_t(3n*e*e*Vt(2n*t,n),n),o=_t(r*r-2n*e,n);return[o,_t(r*(e-o)-t,n)]}function Ut(e,t,n,r,o){if(0n===e&&0n===t)return[n,r];if(0n===n&&0n===r)return[e,t];if(e===n&&t===_t(-r,o))return[0n,0n];if(e===n&&t===r)return Mt(e,t,o);const i=_t((r-t)*Vt(n-e,o),o),s=_t(i*i-e-n,o);return[s,_t(i*(e-s)-t,o)]}function Gt(e,t,n,r){let o=[0n,0n],i=[e,t];const s=n.toString(2);for(const a of s)"0"===a?(Ut(o[0],o[1],i[0],i[1],r),Mt(o[0],o[1],r)):(Ut(o[0],o[1],i[0],i[1],r),Mt(i[0],i[1],r));return o}function Lt(e,t,n){if(t<=0n||t>=Nt)throw new Error("Invalid private key");if(n||_t(Et(Ot(gt(Ot(Bt(t,"BE")),Bt(e,"BE"))),"BE"),Nt),n<=0n||n>=Nt)throw new Error("Invalid nonce");const r=_t(e,Nt),o=Gt(Ct,Ft,n,Pt),i=_t(o[0],Nt);let s=_t((r+_t(i,Nt)*t)*Vt(n,Nt),Nt);if(0n===i||0n===s)throw new Error("Invalid r or s value");let a=o[1]%2n===0n?27n:28n;return s>Nt/2n&&(27n===a?28n:27n),[i,s,a]}class jt{constructor(e){this.cursor=0,this.buffer=e}read(e){const t=this.buffer.subarray(this.cursor,this.cursor+e);return this.cursor+=e,t}max(){return this.buffer.length-this.cursor}}class Zt{constructor(e){this.buffer=e,this.cursor=0}write(e){const t=Math.min(this.max(),e.max());return this.buffer.set(e.read(t),this.cursor),this.cursor+=t,t}max(){return this.buffer.length-this.cursor}}class qt{constructor(e,t=0n){this.span=t,this.writer=new Zt(new Uint8Array(e))}build(){return gt(vt(this.span,"LE"),this.writer.buffer)}hash(){const e=mt(xt(this.writer.buffer,32),((e,t)=>qt.hashFunction(gt(e,t))));return qt.hashFunction(gt(vt(this.span,"LE"),e))}}qt.hashFunction=Ot;class Ht{constructor(e,t=4096){this.counters=[1],this.capacity=t,this.chunks=[new qt(t)],this.onChunk=e}static async root(e,t=4096){const r=new n(n.NOOP,t);return await r.append(e),r.finalize()}async append(e,t=0,n=0n){const r=new jt(e);for(;r.max()>0;){0===this.chunks[t].writer.max()&&await this.elevate(t);const e=this.chunks[t].writer.write(r);n?this.chunks[t].span+=n:this.chunks[0].span+=BigInt(e)}}async elevate(e){this.counters[e]=++this.counters[e]%(this.capacity/32),this.chunks[e+1]||(this.chunks.push(new qt(this.capacity)),this.counters.push(1)),await this.append(this.chunks[e].hash(),e+1,this.chunks[e].span),await this.onChunk(this.chunks[e]),this.chunks[e]=new qt(this.capacity)}async finalize(e=0){return this.chunks[e+1]?1===this.counters[e]?(await this.elevate(e+1),this.chunks[e+1]=this.chunks[e],this.finalize(e+1)):(await this.elevate(e),this.finalize(e+1)):(await this.onChunk(this.chunks[e]),this.chunks[e])}}n=Ht,Ht.NOOP=async e=>{};class Wt{constructor(e,t){if(t<0)throw Error("Scale must be non-negative");this.value=BigInt(e),this.scale=t}static cast(e){if(!e)throw Error("Cannot cast falsy value to FixedPointNumber");if(e instanceof Wt)return e;const t=G(e.value),n=N(e.scale);return new Wt(t,n)}static fromDecimalString(e,t){/e\-\d+$/i.test(e)&&(e=parseFloat(e).toFixed(t));let[n,r]=e.split(".");return r=(r||"").padEnd(t,"0").slice(0,t),new Wt(BigInt(n+r),t)}static fromFloat(e,t){return Wt.fromDecimalString(e.toString(),t)}add(e){return this.assertSameScale(e),new Wt(this.value+e.value,this.scale)}subtract(e){return this.assertSameScale(e),new Wt(this.value-e.value,this.scale)}multiply(e){return new Wt(this.value*e,this.scale)}divmod(e){if(0n===e)throw new Error("Division by zero is not allowed");const t=this.value/e,n=this.value%e;return[new Wt(t,this.scale),new Wt(n,this.scale)]}exchange(e,t,n){if("*"===e){const e=this.value*t.value/10n**BigInt(this.scale);return new Wt(e,n)}this.assertSameScale(t);const r=this.value*10n**BigInt(n)/t.value;return new Wt(r,n)}compare(e){return this.assertSameScale(e),this.value>e.value?1:this.value<e.value?-1:0}toDecimalString(){if(0===this.scale)return this.value.toString();const e=this.value.toString();return`${e.slice(0,-this.scale)||"0"}.${e.slice(-this.scale).padStart(this.scale,"0")}`}toString(){return this.value.toString()}toJSON(){return this.toString()}toFloat(){return parseFloat(this.toDecimalString())}assertSameScale(e){if(this.scale!==e.scale)throw new Error(`Scale mismatch: expected ${this.scale}, but got ${e.scale}`)}}function Jt(e,t,n,r){const o=e.findIndex((e=>e===`--${t}`||e.startsWith(`--${t}=`))),i=e[o];if(!i)return(n||{})[r||t||""]||null;if(i.includes("="))return i.split("=")[1];const s=e[o+1];return s&&!s.startsWith("-")?s:(n||{})[r||t||""]||null}function Kt(e,t,n,r){const o=Jt(e,t,n,r);if(!o)throw new Error(`Missing argument ${t}`);return o}function Xt(e,t){const n=e[t];e.splice(t,1),e.unshift(n)}function Yt(e,t){return{x:e.x+t.x,y:e.y+t.y}}function Qt(e,t){return{x:e.x*t,y:e.y*t}}function en(e,t,n){return{x:e.x+Math.cos(t)*n,y:e.y+Math.sin(t)*n}}function tn(e,t){return Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2)}function nn(e,t,n="row-first"){const r=[];if("column-first"===n)for(let o=0;o<e.length;o++)for(let n=0;n<e[0].length;n++)t(o,n)&&r.push({x:o,y:n});else for(let o=0;o<e[0].length;o++)for(let n=0;n<e.length;n++)t(n,o)&&r.push({x:n,y:o});return r}function rn(e,t,n){return!e[t-1]?.[n]}function on(e,t,n){return!e[t+1]?.[n]}function sn(e,t,n){return!e[t][n-1]}function an(e,t,n){return!e[t][n+1]}function cn(e,t,n){const r=[];return e[t][n]?function(e,t,n){return e[t+1]?.[n]&&e[t-1]?.[n]&&!e[t][n-1]&&!e[t][n+1]}(e,t,n)||function(e,t,n){return e[t][n+1]&&e[t][n-1]&&!e[t-1]?.[n]&&!e[t+1]?.[n]}(e,t,n)?[]:(!e[t-1]?.[n-1]&&rn(e,t,n)&&sn(e,t,n)&&r.push({x:t,y:n}),!e[t+1]?.[n-1]&&on(e,t,n)&&sn(e,t,n)&&r.push({x:t+1,y:n}),!e[t-1]?.[n+1]&&rn(e,t,n)&&an(e,t,n)&&r.push({x:t,y:n+1}),!e[t+1]?.[n+1]&&on(e,t,n)&&an(e,t,n)&&r.push({x:t+1,y:n+1}),r):(e[t-1]?.[n]&&e[t][n-1]&&r.push({x:t,y:n}),e[t+1]?.[n]&&e[t][n-1]&&r.push({x:t+1,y:n}),e[t-1]?.[n]&&e[t][n+1]&&r.push({x:t,y:n+1}),e[t+1]?.[n]&&e[t][n+1]&&r.push({x:t+1,y:n+1}),r)}function un(e,t){return t.map((t=>function(e,t){return Math.atan2(t.y-e.y,t.x-e.x)}(e,t))).sort(((e,t)=>e-t))}function ln(e,t,n,r){const o=(r.y-n.y)*(t.x-e.x)-(r.x-n.x)*(t.y-e.y);if(0===o)return null;let i=e.y-n.y,s=e.x-n.x;const a=(r.x-n.x)*i-(r.y-n.y)*s,c=(t.x-e.x)*i-(t.y-e.y)*s;return i>0&&i<1&&s>0&&s<1?{x:e.x+i*(t.x-e.x),y:e.y+i*(t.y-e.y)}:null}function fn(e,t,n){const r=[],o=en(e,n,1e4);for(const i of t){const t=ln(e,o,i.start,i.end);t&&r.push(t)}return r.length?r.reduce(((t,n)=>tn(e,n)<tn(e,t)?n:t)):null}t.ie=Wt;class hn{constructor(){this.subscribers=[]}subscribe(e){return this.subscribers.push(e),()=>{this.subscribers=this.subscribers.filter((t=>t!==e))}}publish(e){this.subscribers.forEach((t=>t(e)))}clear(){this.subscribers=[]}getSubscriberCount(){return this.subscribers.length}}t.O3=class{constructor(e,t){this.queue=[],this.running=0,this.onProcessed=new hn,this.onDrained=new hn,this.concurrency=e,this.capacity=t}process(){if(this.running>=this.concurrency)return;const e=this.queue.shift();e&&(this.running++,e().finally((()=>{this.running--,this.process(),this.onProcessed.publish(),0===this.running&&this.onDrained.publish()})))}enqueue(e){if(this.queue.length<this.capacity)return this.queue.push(e),this.process(),Promise.resolve();if(this.onProcessed.getSubscriberCount())throw Error("Queue capacity is full");return new Promise((t=>{this.onProcessed.subscribe((()=>{this.queue.length<this.capacity&&(this.queue.push(e),this.process(),this.onProcessed.clear(),t())}))}))}drain(){if(0===this.running)return Promise.resolve();if(this.onDrained.getSubscriberCount())throw Error("Already draining");return new Promise((e=>{this.onDrained.subscribe((()=>{this.onDrained.clear(),e()}))}))}};class dn{constructor(){this.forks=new Map}insert(e,t){if(0===e.length)return void(this.handler=t);const n=e[0];let r,o=n;if(n.startsWith(":")&&n.slice(1),!this.forks.has(o)){const e=new dn;r&&(e.variableName=r),this.forks.set(o,e)}this.forks.get(o).insert(e.slice(1),t)}async handle(e,t,n,r){if(0===e.length)return!!this.handler&&(await this.handler(t,n,r),!0);const o=e[0],i=this.forks.get(o);if(i)return i.handle(e.slice(1),t,n,r);const s=this.forks.get(":");if(s)return s.variableName&&r.set(s.variableName,decodeURIComponent(o)),s.handle(e.slice(1),t,n,r);const a=this.forks.get("*");return!!a&&(r.set("wildcard",e.join("/")),!!a.handler&&(await a.handler(t,n,r),!0))}}t.yI={hexToUint8Array:function(e){(e.startsWith("0x")||e.startsWith("0X"))&&(e=e.slice(2));const t=e.length/2,n=new Uint8Array(t);for(let r=0;r<t;r++){const t=parseInt(e.slice(2*r,2*r+2),16);n[r]=t}return n},uint8ArrayToHex:function(e){return Array.from(e).map((e=>e.toString(16).padStart(2,"0"))).join("")},binaryToUint8Array:function(e){const t=Math.ceil(e.length/8),n=new Uint8Array(t);for(let r=0;r<t;r++){const t=parseInt(e.slice(8*r,8*r+8),2);n[r]=t}return n},uint8ArrayToBinary:function(e){return Array.from(e).map((e=>e.toString(2).padStart(8,"0"))).join("")},base64ToUint8Array:function(e){return Te(e,Ee)},uint8ArrayToBase64:function(e){return Re(e,Ee)},base32ToUint8Array:function(e){return Te(e,xe)},uint8ArrayToBase32:function(e){return Re(e,xe)},log2Reduce:mt,partition:xt,concatBytes:gt,numberToUint8:function(e){return new Uint8Array([e])},uint8ToNumber:function(e){return e[0]},numberToUint16:function(e,t){const n=new ArrayBuffer(2);return new DataView(n).setUint16(0,e,"LE"===t),new Uint8Array(n)},uint16ToNumber:function(e,t){return new DataView(e.buffer).getUint16(e.byteOffset,"LE"===t)},numberToUint32:function(e,t){const n=new ArrayBuffer(4);return new DataView(n).setUint32(0,e,"LE"===t),new Uint8Array(n)},uint32ToNumber:function(e,t){return new DataView(e.buffer).getUint32(e.byteOffset,"LE"===t)},numberToUint64:vt,uint64ToNumber:function(e,t){return new DataView(e.buffer).getBigUint64(e.byteOffset,"LE"===t)},numberToUint256:Bt,uint256ToNumber:Et,sliceBytes:function(e,t){const n=[];let r=0;for(const o of t)n.push(e.subarray(r,r+o)),r+=o;return n},keccak256:Ot,sha3_256:function(e){return St(kt(new Array(50).fill(0),At(e,6)))},proximity:function(e,t){const n=Math.min(e.length,t.length);for(let r=0;r<n;r++){const n=e[r]^t[r];for(let e=0;e<8;e++)if(n>>7-e&1)return 8*r+e}return 8*Math.min(e.length,t.length)},commonPrefix:function(e,t){const n=Math.min(e.length,t.length);for(let r=0;r<n;r++)if(e[r]!==t[r])return e.subarray(0,r);return e.subarray(0,n)},setBit:function(e,t,n,r){const o=Math.floor(t/8),i=t%8;1===n?e[o]|=1<<("BE"===r?7-i:i):e[o]&=~(1<<("BE"===r?7-i:i))},getBit:function(e,t,n){const r=t%8;return e[Math.floor(t/8)]>>("BE"===n?7-r:r)&1},indexOf:function(e,t,n=0){for(let r=n;r<e.length;r++)for(let n=0;n<t.length&&e[r+n]===t[n];n++)if(n===t.length-1)return r;return-1},equals:function(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0},padStart:$t,padStartToMultiple:function(e,t,n=0){const r=e.length%t;return 0===r?e:$t(e,e.length+t-r,n)},padEnd:It,padEndToMultiple:function(e,t,n=0){const r=e.length%t;return 0===r?e:It(e,e.length+t-r,n)},xorCypher:function(e,t){const n=new Uint8Array(e.length);for(let r=0;r<e.length;r++)n[r]=e[r]^t[r%t.length];return n},isUtf8:function(e){for(let t=0;t<e.length;t++){const n=e[t];if(!(n<128))if(192==(224&n)){if(t+1>=e.length||128!=(192&e[t+1]))return!1;t+=1}else if(224==(240&n)){if(t+2>=e.length||128!=(192&e[t+1])||128!=(192&e[t+2]))return!1;t+=2}else{if(240!=(248&n))return!1;if(t+3>=e.length||128!=(192&e[t+1])||128!=(192&e[t+2])||128!=(192&e[t+3]))return!1;t+=3}}return!0}},t.o8={intBetween:a,floatBetween:function(e,t,n=Math.random){return n()*(t-e)+e},chance:u,signed:function(){return 2*Math.random()-1},makeSeededRng:function(e){let t=e,n=3405648695,r=3735928559;return function(){return t+=n,n^=t<<7,t*=r,r^=t<<13,t^=n^r,(t>>>0)/4294967296}},point:function(e,t,n,r=Math.random){let o,i;do{o=a(0,e-1,r),i=a(0,t-1,r)}while(n&&c(n,o,i));return[o,i]},procs:function(e,t=Math.random){const n=Math.floor(e);return u(e-n,t)?n+1:n}},t.DO={countUnique:function(e,t,n,r,o){const i=t?e.map(t):e,s={};for(const c of i)s[c]=(s[c]||0)+1;const a=r?lt(s,o?(e,t)=>e[1]-t[1]:(e,t)=>t[1]-e[1]):s;return n?Object.keys(a):a},makeUnique:function(e,t){return Object.values(at(e,t))},splitBySize:function(e,t){const n=[];for(let r=0;r<e.length;r+=t)n.push(e.slice(r,r+t));return n},splitByCount:ct,index:at,indexCollection:function(e,t){const n={};for(const r of e){const e=t(r);n[e]||(n[e]=[]),n[e].push(r)}return n},onlyOrThrow:function(e){if(1===e.length)return e[0];throw Error(`Expected exactly one element, actual: ${e.length}`)},onlyOrNull:function(e){return 1===e.length?e[0]:null},firstOrThrow:function(e){if(!e.length)throw Error("Received empty array");return e[0]},firstOrNull:function(e){return e.length>0?e[0]:null},shuffle:i,initialize:function(e,t){const n=[];for(let r=0;r<e;r++)n.push(t(r));return n},initialize2D:function(e,t,n){const r=[];for(let o=0;o<e;o++){r.push([]);for(let e=0;e<t;e++)r[o].push(n)}return r},rotate2D:function(e){const t=[];for(let n=0;n<e[0].length;n++){t.push([]);for(let r=0;r<e.length;r++)t[n].push(e[r][n])}return t},containsShape:function(e,t,n,r){if(n<0||r<0||r+t[0].length>e[0].length||n+t.length>e.length)return!1;for(let o=0;o<t.length;o++)for(let i=0;i<t[o].length;i++)if(void 0!==t[o][i]&&e[n+o][r+i]!==t[o][i])return!1;return!0},glue:function(e,t){const n=[];for(let r=0;r<e.length;r++)n.push(e[r]),r<e.length-1&&(v(t)?n.push(t()):n.push(t));return n},pluck:function(e,t){return e.map((e=>e[t]))},pick:l,pickMany:function(e,t,n=Math.random){if(t>e.length)throw new Error(`Count (${t}) is greater than array length (${e.length})`);return s(e,t,n).map((t=>e[t]))},pickManyUnique:function(e,t,n,r=Math.random){if(t>e.length)throw new Error(`Count (${t}) is greater than array length (${e.length})`);const o=[];for(;o.length<t;){const t=l(e,r);o.some((e=>n(e,t)))||o.push(t)}return o},pickWeighted:function(e,t,n){if(void 0===n&&(n=Math.random()),e.length!==t.length)throw new Error("Array length mismatch");let r=t.reduce(((e,t)=>e+t),0);const o=n*r;for(let i=0;i<e.length-1;i++)if(r-=t[i],o>=r)return e[i];return f(e)},pickRandomIndices:s,pickGuaranteed:function(e,n,r,o,s,a=Math.random){const c=e.filter((e=>e!==n&&e!==r)),u=[];for(null!==n&&u.push(n);c.length&&u.length<o;){const e=t.o8.intBetween(0,c.length-1,a);s(c[e],u)&&u.push(c[e]),c.splice(e,1)}return i(u,a),{values:u,indexOfGuaranteed:null!==n?u.indexOf(n):-1}},last:f,pipe:h,makePipe:function(e,t){return n=>h(n,e,t)},sortWeighted:function(e,t,n=Math.random){const r=t.map((e=>n()*e)),o=[];for(let i=0;i<e.length;i++)o.push([e[i],r[i]]);return o.sort(((e,t)=>t[1]-e[1])).map((e=>e[0]))},pushAll:q,unshiftAll:function(e,t){Array.prototype.unshift.apply(e,t)},filterAndRemove:function(e,t){const n=[];for(let r=e.length-1;r>=0;r--)t(e[r])&&n.push(e.splice(r,1)[0]);return n},merge:function(e,t){const n=Object.keys(t);for(const r of n)Array.isArray(t[r])&&Array.isArray(e[r])&&q(e[r],t[r])},empty:function(e){return e.splice(0,e.length),e},pushToBucket:function(e,t,n){e[t]||(e[t]=[]),e[t].push(n)},unshiftAndLimit:function(e,t,n){for(e.unshift(t);e.length>n;)e.pop()},atRolling:function(e,t){let n=t%e.length;return n<0&&(n+=e.length),e[n]},group:ft,createOscillator:function(e){let t=0;return{next:()=>e[t++%e.length]}},organiseWithLimits:function(e,t,n,r,o){const i={};for(const s of Object.keys(t))i[s]=[];i[r]=[],o&&(e=e.sort(o));for(const s of e){const e=s[n],o=t[e]?e:r;i[o].length>=t[o]?i[r].push(s):i[o].push(s)}return i},tickPlaybook:function(e){if(0===e.length)return null;const t=e[0];return t.ttlMax?--t.ttl<=0&&e.shift():t.ttlMax=t.ttl,{progress:(t.ttlMax-t.ttl)/t.ttlMax,data:t.data}},getArgument:Jt,getBooleanArgument:function(e,t,n,r){const o=e.some((e=>e.endsWith("-"+t))),i=Jt(e,t,n,r);if(!i&&o)return!0;if(!i&&!o)return null;if(["true","1","yes","y","on"].includes(i.toLowerCase()))return!0;if(["false","0","no","n","off"].includes(i.toLowerCase()))return!1;throw Error(`Invalid boolean argument ${t}: ${i}`)},getNumberArgument:function(e,t,n,r){const o=Jt(e,t,n,r);if(!o)return null;try{return rt(o)}catch{throw new Error(`Invalid number argument ${t}: ${o}`)}},requireStringArgument:Kt,requireNumberArgument:function(e,t,n,r){const o=Kt(e,t,n,r);try{return rt(o)}catch{throw new Error(`Invalid argument ${t}: ${o}`)}},bringToFront:function(e,t){const n=[...e];return Xt(n,t),n},bringToFrontInPlace:Xt,findInstance:function(e,t){const n=e.find((e=>e instanceof t));return dt.of(n)},filterInstances:function(e,t){return e.filter((e=>e instanceof t))},interleave:function(e,t){const n=[],r=Math.max(e.length,t.length);for(let o=0;o<r;o++)e[o]&&n.push(e[o]),t[o]&&n.push(t[o]);return n},toggle:function(e,t){return e.includes(t)?e.filter((e=>e!==t)):[...e,t]},createHierarchy:function(e,t,n,r,o=!1){const i=new Map,s=[];e.forEach((e=>{const n=new pt(e);i.set(e[t],n)})),e.forEach((e=>{const r=i.get(e[t]);if(!r)return;const o=e[n];if(o){const e=i.get(o);e&&e.children.push(r)}else s.push(r)}));const a=e=>{e.children.sort(((e,t)=>{const n=e.value[r],i=t.value[r];return o?i-n:n-i})),e.children.forEach(a)};return s.forEach(a),s},multicall:function(e){return()=>e.forEach((e=>e()))},maxBy:function(e,t){return e.reduce(((e,n)=>t(e)>t(n)?e:n))},minBy:function(e,t){return e.reduce(((e,n)=>t(e)<t(n)?e:n))},allIndexOf:function(e,t){const n=[];return e.forEach(((e,r)=>{t(e)&&n.push(r)})),n}},t.iQ={sleepMillis:o,forever:async function(e,t,n){for(;;){try{await e()}catch(r){n&&n("Error in forever",r)}await o(t)}},scheduleMany:function(e,t){for(let n=0;n<e.length;n++){const r=e[n],o=t[n],i=Math.max(0,o.getTime()-Date.now());setTimeout(r,i)}},waitFor:async function(e,t){let n=t.requiredConsecutivePasses||1,r=0;for(let i=0;i<t.attempts;i++){try{if(await e()){if(r++,r>=n)return}else r=0}catch{r=0}i<t.attempts-1&&await o(t.waitMillis)}throw Error("Timed out waiting for predicate")},expandError:function(e,t){if(B(e))return e;const n=Object.keys(e);e.message&&!n.includes("message")&&n.push("message");const r=n.map((t=>`${t}: ${e[t]}`)).join("; ");return t&&e.stack?r+"\n"+e.stack:r},runAndSetInterval:function(e,t){e();const n=setInterval((()=>{e()}),t);return()=>clearInterval(n)},whereAmI:function(){const e=globalThis.process;return e?!0===e.browser?"browser":"node":"browser"},withRetries:async function(e,t,n,r,i,s){let a=null;for(let u=0;u<=t;u++)try{return await e()}catch(c){if(a=c,u===t)break;const e=n+u/(t-1)*(r-n);i&&i("Error in withRetries, retrying",{attempt:u+1,allowedFailures:t,delayMillis:e,error:c}),s&&s(),await o(e)}throw a}},t.FQ={make:rt,sum:function(e){return e.reduce(((e,t)=>e+t),0)},average:function(e){return e.reduce(((e,t)=>e+t),0)/e.length},median:function(e){const t=[...e].sort(((e,t)=>e-t)),n=Math.floor(t.length/2);return t.length%2==0?(t[n]+t[n-1])/2:t[n]},getDistanceFromMidpoint:function(e,t){return e-(t-1)/2},clamp:ot,range:H,interpolate:function(e,t,n){return e+(t-e)*n},createSequence:function(){let e=0;return{next:()=>e++}},increment:function(e,t,n){const r=e+t;return r>n?n:r},decrement:function(e,t,n){const r=e-t;return r<n?n:r},format:function(e,t){const n=t?.longForm??!1,r=t?.unit?` ${t.unit}`:"",o=n?tt:nt,i=t?.precision??1;if(e<et[0])return`${e}${r}`;for(let s=0;s<et.length-1;s++)if(e<et[s+1])return`${(e/et[s]).toFixed(i)}${n?" ":""}${o[s]}${r}`;return`${(e/et[et.length-1]).toFixed(i)}${n?" ":""}${o[et.length-1]}${r}`},fromDecimals:function(e,t,n){let r=e.length-t;if(r<=0)return"0."+"0".repeat(-r)+e+(n?" "+n:"");let o=e.substring(0,r);return""===o&&(o="0"),o+"."+e.substring(r)+(n?" "+n:"")},makeStorage:function(e,t=1024){const n=parseFloat(e);if(isNaN(n))throw Error("makeStorage got NaN for input");const r=e.replace(/^-?[0-9.]+/,"").trim().toLowerCase(),o=""===r?0:qe[r];if(null==o)throw Error(`Unknown unit: "${r}"`);return Math.ceil(n*t**o)},asMegabytes:function(e){return e/1024/1024},convertBytes:function(e,t=1024){return e>=t*t*t*t?(e/t/t/t/t).toFixed(3)+" TB":e>=t*t*t?(e/t/t/t).toFixed(3)+" GB":e>=t*t?(e/t/t).toFixed(3)+" MB":e>=t?(e/t).toFixed(3)+" KB":e+" B"},hexToRgb:function(e){const t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e.toLowerCase());if(!t)throw new Error("Invalid hex color: "+e);return[parseInt(t[1],16),parseInt(t[2],16),parseInt(t[3],16)]},rgbToHex:function(e){return"#"+e.map((e=>e.toString(16).padStart(2,"0"))).join("")},haversineDistanceToMeters:function(e,t,n,r){const o=e*Math.PI/180,i=n*Math.PI/180,s=(n-e)*Math.PI/180,a=(r-t)*Math.PI/180,c=Math.sin(s/2)*Math.sin(s/2)+Math.cos(o)*Math.cos(i)*Math.sin(a/2)*Math.sin(a/2);return 2*Math.atan2(Math.sqrt(c),Math.sqrt(1-c))*6371e3},roundToNearest:m,formatDistance:function(e){return e>1e3?(e/1e3).toFixed(0)+" km":e>=500?m(e,100)+" m":e>=100?m(e,50)+" m":m(e,10)+" m"},triangularNumber:function(e){return e*(e+1)/2},searchFloat:function(e){const t=e.match(/-?\d+(\.\d+)?/);if(!t)throw Error("No float found in "+e);return parseFloat(t[0])},binomialSample:function(e,t,n=Math.random){const r=e*t,o=Math.sqrt(e*t*(1-t)),i=(n()+n()+n()+n()+n()+n()-3)*Math.SQRT2,s=Math.round(r+o*i);return Math.max(0,Math.min(e,s))},toSignificantDigits:function(e,t){if(!e.includes("."))return e;if(0===parseFloat(e))return"0";const[n,r]=e.split("."),o=n.replace("-",""),i=o.length;if(i>=t)return n;if("0"!==o){const e=t-i,o=r.slice(0,e);return/[1-9]/.test(o)?`${n}.${o.replace(/0+$/,"")}`:n}const s=t+(r.match(/^0*/)?.[0].length??0);return`${n}.${r.slice(0,s)}`}},t.AO={getTimestamp:function(e,t){const n=new Date(t?.now||Date.now()),r=t?.labels||Ne,o=T(e)?e:new Date(e);if(Pe(n)===Pe(o))return r.today(o.getUTCHours(),o.getUTCMinutes(),o.getUTCHours()>12);if(Pe(n)-Pe(o)==1)return r.yesterday();const i=je(o);return Pe(n)-Pe(o)<7?r[i.day]():r.weeks(Math.round((n.getTime()-o.getTime())/6048e5))},getTimeDelta:Fe,secondsToHumanTime:function(e,t=Ce){return Fe(0,{now:1e3*e,labels:t})},countCycles:function(e,t,n){const r=(n?.now??Date.now())-e;return{cycles:Math.floor(r/t),remaining:t/(n?.precision??1)-Math.ceil(r%t/(n?.precision??1))}},isoDate:function(e){return(e||new Date).toISOString().slice(0,10)},throttle:function(e,t){return(!Me[e]||Date.now()>Me[e])&&(Me[e]=Date.now()+t,!0)},timeSince:function(e,t,n){return t=T(t)?t.getTime():t,((n=n?T(n)?n.getTime():n:Date.now())-t)/Ue[e]},dateTimeSlug:function(e){return(e||new Date).toISOString().slice(0,19).replace(/T|:/g,"-")},unixTimestamp:function(e){return Math.ceil((e||Date.now())/1e3)},fromUtcString:function(e){const t=new Date(e);return new Date(t.getTime()-6e4*t.getTimezoneOffset())},fromMillis:function(e){return new Date(e)},getProgress:function(e,t,n,r){r||(r=Date.now());const o=r-e,i=o/t,s=i*n;return{deltaMs:o,progress:t/n,baseTimeMs:i,totalTimeMs:s,remainingTimeMs:s-o}},humanizeTime:De,humanizeProgress:function(e){return`[${Math.floor(100*e.progress)}%] ${De(e.deltaMs)} out of ${De(e.totalTimeMs)} (${De(e.remainingTimeMs)} left) [${Math.round(e.baseTimeMs)} ms each]`},createTimeDigits:Ve,mapDayNumber:Le,getDayInfoFromDate:je,getDayInfoFromDateTimeString:function(e){return je(new Date(e))},seconds:function(e){return 1e3*e},minutes:function(e){return 6e4*e},hours:function(e){return 36e5*e},days:function(e){return 864e5*e},make:function(e){const t=parseFloat(e);if(isNaN(t))throw Error("makeDate got NaN for input");const n=e.replace(/^-?[0-9.]+/,"").trim().toLowerCase(),r=""===n?1:Ze[n];if(!r)throw Error(`Unknown unit: "${n}"`);return Math.ceil(t*r)},normalizeTime:function(e){let[t,n]=e.split(":");E(parseInt(t,10))||(t="0"),E(parseInt(n,10))||(n="0");let r=ot(C(t),0,23),o=ot(C(n),0,59);return`${Ve(r)}:${Ve(o)}`},absoluteDays:Pe},t.Rb={safeParse:function(e){try{return JSON.parse(e)}catch{return null}},deleteDeep:function(e,t){const n=Q(t,"."),r=ee(t,".");if(!n||!r)return;const o=d(e,n);o&&delete o[r]},getDeep:d,setDeep:p,incrementDeep:function(e,t,n=1){const r=d(e,t)||0;return p(e,t,r+n),r},ensureDeep:function(e,t,n){return d(e,t)||p(e,t,n)},replaceDeep:function(e,t,n){const r=d(e,t);if(!r)throw new Error("Key '"+t+"' does not exist.");return p(e,t,n),r},getFirstDeep:function(e,t,n){for(const r of t){const t=d(e,r);if(t)return t}if(n){const t=Object.values(e);if(t.length)return t[0]}return null},deepMergeInPlace:j,deepMerge2:function(e,t){const n={};return j(n,e),j(n,t),n},deepMerge3:function(e,t,n){const r={};return j(r,e),j(r,t),j(r,n),r},mapAllAsync:async function(e,t){const n=[];for(const r of e)n.push(await t(r));return n},cloneWithJson:function(e){return JSON.parse(JSON.stringify(e))},sortObject:Je,sortArray:Ke,sortAny:Xe,deepEquals:Ye,deepEqualsEvery:function(...e){for(let t=1;t<e.length;t++)if(!Ye(e[t-1],e[t]))return!1;return!0},runOn:function(e,t){return t(e),e},ifPresent:function(e,t){e&&t(e)},zip:Z,zipSum:function(e){return Z(e,((e,t)=>e+t))},removeEmptyArrays:function(e){for(const t of Object.keys(e))(w(e[t])||Array.isArray(e[t])&&e[t].every((e=>null==e)))&&delete e[t];return e},removeEmptyValues:function(e){for(const t of Object.entries(e))(null===t[1]||void 0===t[1]||B(t[1])&&R(t[1]))&&delete e[t[0]];return e},flatten:function(e,t=!1,n){return st({},e,n||"",!1,t)},unflatten:function e(t){if(!g(t))return t;const n=Array.isArray(t)?[]:{};for(const[r,o]of Object.entries(t))Array.isArray(o)?p(n,r,o.map((t=>e(t)))):p(n,r,o);return n},match:function(e,t,n){return t[e]?t[e]:n},sort:lt,map:function(e,t){const n={};for(const r of Object.entries(e))n[r[0]]=t(r[1]);return n},mapIterable:function(e,t){const n=[];let r=0;for(const o of e)n.push(t(o,r++));return n},filterKeys:function(e,t){const n={};for(const[r,o]of Object.entries(e))t(r)&&(n[r]=o);return n},filterValues:function(e,t){const n={};for(const[r,o]of Object.entries(e))t(o)&&(n[r]=o);return n},rethrow:async function(e,t){try{return await e()}catch{throw t}},setSomeOnObject:function(e,t,n){null!=n&&(e[t]=n)},setSomeDeep:function(e,t,n,r){const o=d(n,r);null!=o&&p(e,t,o)},flip:function(e){const t={};for(const[n,r]of Object.entries(e))t[r]=n;return t},getAllPermutations:function(e){const t=Object.keys(e),n=t.map((t=>e[t].length)),r=n.reduce(((e,t)=>e*t));let o=1;const i=[1];for(let a=0;a<n.length-1;a++)o*=n[a],i.push(o);const s=[];for(let a=0;a<r;a++){const n={};for(let r=0;r<t.length;r++){const o=e[t[r]],s=Math.floor(a/i[r])%o.length;n[t[r]]=o[s]}s.push(n)}return s},countTruthyValues:function(e){return Object.values(e).filter((e=>e)).length},transformToArray:function(e){const t=[],n=Object.keys(e),r=e[n[0]].length;for(let o=0;o<r;o++){const r={};for(const t of n)r[t]=e[t][o];t.push(r)}return t},setMulti:function(e,t,n){for(const r of e)r[t]=n},incrementMulti:function(e,t,n=1){for(const r of e)r[t]+=n},createBidirectionalMap:function(){return{map:new Map,keys:[]}},createTemporalBidirectionalMap:function(){return{map:new Map,keys:[]}},pushToBidirectionalMap:ht,unshiftToBidirectionalMap:function(e,t,n,r=100){if(e.map.has(t)){const n=e.keys.indexOf(t);e.keys.splice(n,1)}if(e.map.set(t,n),e.keys.unshift(t),e.keys.length>r){const t=e.keys.shift();t&&e.map.delete(t)}},addToTemporalBidirectionalMap:function(e,t,n,r,o=100){ht(e,t,{validUntil:Date.now()+r,data:n},o)},getFromTemporalBidirectionalMap:function(e,t){const n=e.map.get(t);return n&&n.validUntil>Date.now()?n.data:null},createStatefulToggle:function(e){let t;return n=>{const r=n===e&&t!==e;return t=n,r}},diffKeys:function(e,t){const n=Object.keys(e),r=Object.keys(t);return{uniqueToA:n.filter((e=>!r.includes(e))),uniqueToB:r.filter((e=>!n.includes(e)))}},pickRandomKey:Qe,mapRandomKey:function(e,t){const n=Qe(e);return e[n]=t(e[n]),n},fromObjectString:function(e){return e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=e.replace(/\r\n/g,"\n")).replace(/(\w+)\((.+)\)/g,((e,t,n)=>`${t}(${n.replaceAll(",",",")})`))).replace(/(,)(\s+})/g,"$2")).replace(/\.\.\..+?,/g,"")).replace(/({\s+)([a-zA-Z]\w+),/g,"$1$2: '$2',")).replace(/(,\s+)([a-zA-Z]\w+),/g,"$1$2: '$2',")).replace(/:(.+)\?(.+):/g,((e,t,n)=>`: (${t.trim()} && ${n.trim()}) ||`))).replace(/([a-zA-Z0-9]+)( ?: ?{)/g,'"$1"$2')).replace(/([a-zA-Z0-9]+) ?: ?(.+?)(,|\n|})/g,((e,t,n,r)=>`"${t}":"${n.trim()}"${r}`))).replace(/("'|'")/g,'"')).replaceAll(",",","),JSON.parse(e)},toQueryString:_e,parseQueryString:function(e){const t={},n=e.split("&");for(const r of n){const[e,n]=r.split("=");e&&n&&(t[e]=decodeURIComponent(n))}return t},hasKey:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},selectMax:function(e,t){let n=null,r=-1/0;for(const[o,i]of Object.entries(e)){const e=t(i);e>r&&(r=e,n=o)}return n?[n,e[n]]:null},reposition:function(e,t,n,r){const o=e.find((e=>e[t]===n)),i=e.find((e=>e[t]===n+r));o&&i?(o[t]=n+r,i[t]=n):o&&(o[t]=n+r),e.sort(((e,n)=>N(e[t])-N(n[t]))),e.forEach(((e,n)=>e[t]=n+1))},unwrapSingleKey:function(e){const t=Object.keys(e);if(1===t.length)return e[t[0]];throw new Error("Expected object to have a single key")},parseKeyValues:function(e,t=":"){return Object.fromEntries(e.map((e=>te(e,t))).map((e=>e[0]&&e[1]?[ie(e[0]),ie(e[1])]:null)).filter((e=>e)))},errorMatches:function(e,t){if(!e)return!1;const n=e.message;return"string"==typeof n&&n.includes(t)}},t.Or={isFunction:v,isObject:g,isStrictlyObject:y,isEmptyArray:w,isEmptyObject:function(e){return y(e)&&0===Object.keys(e).length},isUndefined:b,isString:B,isNumber:E,isBoolean:x,isDate:T,isBlank:R,isId:z,isIntegerString:A,isHexString:k,isUrl:M,isBigint:U,isNullable:function(e,t){return null==t||e(t)},asString:D,asHexString:function(e,t){if(!k(e))throw new TypeError(`Expected hex string${t?.name?` for ${t.name}`:""}, got: `+e);if(t?.strictPrefix&&!e.startsWith("0x")&&!e.startsWith("0X"))throw new TypeError(`Expected hex string with 0x prefix${t?.name?` for ${t.name}`:""}, got: `+e);const n=e.replace(/^0x/i,"");if(n.length%2!=0&&!t?.uneven)throw RangeError(`Expected even number of hex digits${t?.name?` for ${t.name}`:""}; got: `+e);if(t&&t.byteLength&&n.length!==2*t.byteLength)throw RangeError(`Expected hex string${t?.name?` for ${t.name}`:""} of byte length ${t.byteLength}; got: `+n);return`0x${n}`},asSafeString:function(e,t){if(!D(e,t).split("").every((e=>"_"===e||le(e))))throw new TypeError(`Expected safe string${t?.name?` for ${t.name}`:""}, got: `+e);return e},asIntegerString:function(e,t){if(!A(e))throw new TypeError(`Expected integer string${t?.name?` for ${t.name}`:""}, got: `+e);const n=BigInt(e);if(t&&(t.min&&n<t.min||t.max&&n>t.max))throw RangeError(`Expected integer string${t?.name?` for ${t.name}`:""} in range: ${t.min??"-inf"}..${t.max??"inf"}; got: `+n);return e},asNumber:N,asFunction:function(e,t){if(!v(e))throw new TypeError(`Expected function${t?.name?` for ${t.name}`:""}, got: `+e);return e},asInteger:C,asBoolean:function(e,t){if("true"===e)return!0;if("false"===e)return!1;if(!x(e))throw new TypeError(`Expected boolean${t?.name?` for ${t.name}`:""}, got: `+e);return e},asDate:function(e,t){if(!T(e))throw new TypeError(`Expected date${t?.name?` for ${t.name}`:""}, got: `+e);return e},asNullableString:function(e){return R(e)?null:e},asEmptiableString:function(e,t){if(!B(e))throw new TypeError(`Expected string${t?.name?` for ${t.name}`:""}, got: `+e);return e},asId:function(e,t){if(z(e))return e;const n=parseInt(e,10);if(!z(n))throw new TypeError(`Expected id${t?.name?` for ${t.name}`:""}, got: `+e);return n},asTime:function(e,t){if(!B(e))throw new TypeError(`Expected time${t?.name?` for ${t.name}`:""}, got: `+e);const n=e.split(":");if(2!==n.length)throw new TypeError(`Expected time${t?.name?` for ${t.name}`:""}, got: `+e);const r=parseInt(n[0],10),o=parseInt(n[1],10);if(!E(r)||!E(o)||r<0||r>23||o<0||o>59)throw new TypeError(`Expected time, got${t?.name?` for ${t.name}`:""}: `+e);return`${String(r).padStart(2,"0")}:${String(o).padStart(2,"0")}`},asArray:function(e,t){if(!Array.isArray(e))throw new TypeError(`Expected array${t?.name?` for ${t.name}`:""}, got: `+e);return e},asObject:F,asNullableObject:function(e,t){return null===e?null:F(e,t)},asStringMap:function(e,t){const n=F(e,t);for(const r of Object.keys(n))if(!B(n[r]))throw new TypeError(`Expected string map${t?.name?` for ${t.name}`:""}, got: `+e);return n},asNumericDictionary:function(e,t){const n=F(e),r=Object.keys(n),o=Object.values(n);if(!r.every(B)||!o.every(E))throw new TypeError(`Expected numeric dictionary${t?.name?` for ${t.name}`:""}, got: `+e);return n},asUrl:function(e,t){if(!M(e))throw new TypeError(`Expected url${t?.name?` for ${t.name}`:""}, got: `+e);return e},asBigint:G,asEmptiable:function(e,t){return""===t?void 0:e(t)},asNullable:function(e,t){return null==t?null:e(t)},asOptional:function(e,t){return null==t?void 0:e(t)},enforceObjectShape:L,enforceArrayShape:function(e,t){return e.every((e=>L(e,t)))},isPng:yt,isJpg:wt,isWebp:bt,isImage:function(e){return yt(e)||wt(e)||bt(e)}},t.DH={tokenizeByCount:function(e,t){return ut(e,Math.ceil(e.length/t))},tokenizeByLength:ut,searchHex:function(e,t){const n=new RegExp(`[0-9a-f]{${t}}`,"i"),r=e.match(n);return r?r[0]:null},searchSubstring:function(e,t,n=S){const r=ne(e,n);for(const o of r)if(t(o))return o;return null},randomHex:function(e,t=Math.random){let n="";for(let r=0;r<e;r++)n+=V[Math.floor(16*t())];return n},randomLetter:function(e,t=Math.random){let n="";for(let r=0;r<e;r++)n+=O[Math.floor(26*t())];return n},randomAlphanumeric:function(e,t=Math.random){let n="";for(let r=0;r<e;r++)n+=$[Math.floor(62*t())];return n},randomRichAscii:function(e,t=Math.random){let n="";for(let r=0;r<e;r++)n+=I[Math.floor(89*t())];return n},randomUnicode:function(e,t=Math.random){let n="";for(let r=0;r<e;r++)n+=_[Math.floor(t()*_.length)];return n},includesAny:function(e,t){return t.some((t=>e.includes(t)))},slugify:W,normalForm:function(e){return W(e).replaceAll("-","")},enumify:function(e){return W(e).replace(/-/g,"_").toUpperCase()},escapeHtml:function(e){return e.replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")},decodeHtmlEntities:function(e){let t=e.replace(/&#(\d+);/g,((e,t)=>String.fromCharCode(t))).replace(/&#x(\d+);/g,((e,t)=>String.fromCharCode(parseInt(t,16))));for(const[n,r]of Object.entries(K))t=t.replaceAll(n,r);return t},after:Y,afterLast:ee,before:X,beforeLast:Q,betweenWide:function(e,t,n){const r=Q(e,n);return r?Y(r,t):null},betweenNarrow:function(e,t,n){const r=Y(e,t);return r?X(r,n):null},getPreLine:function(e){return e.replace(/ +/g," ").replace(/^ /gm,"")},containsWord:Se,containsWords:function(e,t,n){return"any"===n?t.some((t=>Se(e,t))):t.every((t=>Se(e,t)))},joinUrl:We,getFuzzyMatchScore:J,sortByFuzzyScore:function(e,t){return e.filter((e=>J(e,t))).sort(((e,n)=>J(n,t)-J(e,t)))},splitOnce:te,splitAll:ne,randomize:function(e,t=Math.random){return e.replace(/\{(.+?)\}/g,((e,n)=>l(n.split("|"),t)))},expand:function e(t){const n=t.match(/\{(.+?)\}/);if(!n||!n.index)return[t];const r=n[1].split(","),o=t.slice(0,n.index),i=t.slice(n.index+n[0].length);let s=[];for(const a of r){const t=e(o+a+i);s=s.concat(t)}return s},shrinkTrim:ie,capitalize:se,decapitalize:ae,csvEscape:function(e){return e.match(/"|,/)?`"${e.replace(/"/g,'""')}"`:e},parseCsv:function(e,t=",",n='"'){const r=[];let o="",i=!1;const s=e.split("");for(const a of s)a!==t||i?a!==n||(o||i)&&!i?o+=a:i=!i:(r.push(o),o="");return r.push(o),r},surroundInOut:function(e,t){return t+e.split("").join(t)+t},getExtension:re,getBasename:oe,normalizeEmail:function(e){let[t,n]=e.split("@");t=ie(t.replaceAll(".","").toLowerCase()).replaceAll(" ","");const[r]=t.split("+");if(!r||!n||-1===n.indexOf(".")||n.indexOf(".")===n.length-1)throw new Error("Invalid email");return n=ie(n.toLowerCase()).replaceAll(" ",""),`${r}@${n}`},normalizeFilename:function(e){const t=oe(e),n=re(e);return n?`${t}.${n}`:t},parseFilename:function(e){const t=oe(e),n=re(e);return{basename:t,extension:n,filename:n?`${t}.${n}`:t}},camelToTitle:function(e){return se(e.replace(/([A-Z])/g," $1"))},slugToTitle:function(e){return e.split("-").map(se).join(" ")},slugToCamel:function(e){return ae(e.split("-").map(se).join(""))},joinHumanly:function(e,t=", ",n=" and "){return e&&e.length?1===e.length?e[0]:2===e.length?`${e[0]}${n}${e[1]}`:`${e.slice(0,e.length-1).join(t)}${n}${e[e.length-1]}`:""},findWeightedPair:ve,extractBlock:Be,extractAllBlocks:function(e,t){const n=[];let r=t.wordBoundary?ge(e,[`${t.opening} `,`${t.opening}\n`],t.start||0):e.indexOf(t.opening,t.start||0);for(;;){if(-1===r)return n;const o=Be(e,{...t,start:r});if(!o)return n;n.push(o),r=t.wordBoundary?ge(e,[`${t.opening} `,`${t.opening}\n`],r+o.length):e.indexOf(t.opening,r+o.length)}},replaceBlocks:function(e,n,r){let o=0;for(;;){const i=t.DH.extractBlock(e,{...r,start:o});if(!i)return e;const s=n(i);o=e.indexOf(i,o)+s.length,e=e.replace(i,s)}},indexOfEarliest:ge,lastIndexOfBefore:be,parseHtmlAttributes:function(e){const t={},n=e.match(/([a-z\-]+)="([^"]+)"/g);if(n)for(const r of n){const[e,n]=te(r,"=");t[e]=n.slice(1,n.length-1)}return t},readNextWord:Oe,readWordsAfterAll:function(e,t,n=[]){const r=me(e,t),o=[];for(const i of r)o.push(Oe(e,i+t.length,n));return o},resolveVariables:function(e,t,n="$",r=":"){for(const o in t)e=$e(e,o,t[o],n,r);return e=Ie(e)},resolveVariableWithDefaultSyntax:$e,resolveRemainingVariablesWithDefaults:Ie,isLetter:ce,isDigit:ue,isLetterOrDigit:le,isValidObjectPathCharacter:function(e){return le(e)||"."===e||"["===e||"]"===e||"_"===e},insert:function(e,t,n,r,o){return e.slice(0,t)+r+e.slice(t,t+n)+o+e.slice(t+n)},indexOfRegex:de,allIndexOf:me,lineMatches:pe,linesMatchInOrder:function(e,t,n=!0){let r=0;for(const o of t){let t=!1;for(;!t&&r<e.length;)pe(e[r],o,n)&&(t=!0),r++;if(!t)return!1}return!0},represent:function e(t,n="json",r=0){if(t&&v(t.represent)){const e=t.represent();if(B(e))return"json"===n&&0===r?JSON.stringify(e):e}if(g(t,!1)){if(r>1)return"[object Object]";if("json"===n){if(Array.isArray(t)){const n=t.map((t=>e(t,"json",r+1)));return 0===r?JSON.stringify(n):n}const n={};t.message&&(n.message=e(t.message,"json",r+1));for(const[o,i]of Object.entries(t))n[o]=e(i,"json",r+1);return 0===r?JSON.stringify(n):n}if("key-value"===n){const n=Object.keys(t);return t.message&&!n.includes("message")&&n.unshift("message"),n.map((n=>`${n}=${JSON.stringify(e(t[n],"json",r+1))}`)).join(" ")}}return b(t)&&(t="undefined"),0===r?JSON.stringify(t):t},resolveMarkdownLinks:function(e,t){let n=e.indexOf("](");for(;-1!==n;){const r=be(e,"[",n),o=e.indexOf(")",n);if(-1!==r&&-1!==o){const[n,i]=e.slice(r+1,o).split("]("),s=t(n,i);e=e.slice(0,r)+s+e.slice(o+1)}n=e.indexOf("](",n+1)}return e},buildUrl:function(e,t,n){return We([e,t])+_e(n||{})},isChinese:function(e){return/^[\u4E00-\u9FA5]+$/.test(e)},replaceBetweenStrings:function(e,t,n,r,o=!0){const i=e.indexOf(t),s=e.indexOf(n,i+t.length);if(-1===i||-1===s)throw Error("Start or end not found");return o?e.substring(0,i+t.length)+r+e.substring(s):e.substring(0,i)+r+e.substring(s+n.length)},describeMarkdown:function(e){let t="p";return e.startsWith("#")?(t="h1",e=e.slice(1).trim()):e.startsWith("-")&&(t="li",e=e.slice(1).trim()),{type:t,isCapitalized:e[0]===e[0].toUpperCase(),hasPunctuation:/[.?!]$/.test(e),endsWithColon:/:$/.test(e)}},isBalanced:function(e,t="(",n=")"){let r=0,o=0;for(;o<e.length;)if(e.startsWith(t,o)?(r++,o+=t.length):e.startsWith(n,o)?(r--,o+=n.length):o++,r<0)return!1;return t===n?r%2==0:0===r},textToFormat:function(e){let t=(e=e.normalize("NFD").replace(/[\u0300-\u036f]/g,"")).length;for(;(e=e.replace(/(\w+)[\s,']+\w+/g,"$1")).length!==t;)t=e.length;return e=(e=(e=e.replaceAll(/[A-Z][a-zA-Z0-9]*/g,"A")).replaceAll(/[a-z][a-zA-Z0-9]*/g,"a")).replaceAll(/[\u4E00-\u9FA5]+/g,"Z")},splitFormatting:function(e,t){const n=[];let r=0;for(;r<e.length;){const o=e.indexOf(t,r);if(-1===o){n.push({string:e.slice(r),symbol:null});break}const i=e.indexOf(t,o+t.length);if(o>r&&-1!==i&&n.push({string:e.slice(r,o),symbol:null}),-1===i){n.push({string:e.slice(r),symbol:null});break}n.push({string:e.slice(o+t.length,i),symbol:t}),r=i+t.length}return n},splitHashtags:function(e){const t=[];let n=0;for(;n<e.length;){const r=we(e,n);if(-1===r){t.push({string:e.slice(n),symbol:null});break}const o=ye(e,r+1);if(-1===o){t.push({string:e.slice(n,r),symbol:null}),t.push({string:e.slice(r+1),symbol:"#"});break}r>n&&t.push({string:e.slice(n,r),symbol:null}),t.push({string:e.slice(r+1,o),symbol:"#"}),n=o}return t},splitUrls:function(e){const t=[];let n=0;for(;n<e.length;){const r=ge(e,["http://","https://"],n);if(-1===r){t.push({string:e.slice(n),symbol:null});break}const o=ge(e,[" ","\n"],r);if(-1===o){r>n&&t.push({string:e.slice(n,r),symbol:null}),t.push({string:e.slice(r),symbol:"http"});break}r>n&&t.push({string:e.slice(n,r),symbol:null}),t.push({string:e.slice(r,o),symbol:"http"}),n=o}return t},route:function(e,t){const n=e.split("/").filter((e=>e)),r=t.split("/").filter((e=>e));if(n.length!==r.length)return null;const o={};for(let i=0;i<n.length;i++){const e=n[i];if(e.startsWith(":"))o[e.slice(1)]=r[i];else if(e!==r[i])return null}return o},explodeReplace:ze,generateVariants:function(e,n,r,o=Math.random){const i=t.DO.shuffle(n.map((e=>({variants:t.DO.shuffle(e.variants.map((e=>e)),o),avoid:e.avoid}))),o),s=[];for(const t of i){const n=t.variants.filter((e=>e!==t.avoid)),o=n.find((t=>e.includes(t)));if(o&&(q(s,ze(e,o,n)),s.length>=r))break}if(s.length<r)for(const t of i){const n=t.variants.find((t=>e.includes(t)));if(n&&(q(s,ze(e,n,t.variants)),s.length>=r))break}return s.slice(0,r)},replaceWord:function(e,t,n,r=!1){const o=new RegExp(r?`(?<=\\s|^)${t}(?=\\s|$)`:`\\b${t}\\b`,"g");return e.replace(o,n)},replacePascalCaseWords:function(e,t){return e.replace(/\b[A-Z][a-zA-Z0-9]*\b/g,(e=>e.toUpperCase()===e?e:t(e)))},stripHtml:function(e){return e.replace(/<[^>]*>/g,"")},breakLine:Ae,measureTextWidth:function(e,t={}){return[...e].reduce(((e,n)=>e+(t[n]||1)),0)},toLines:function(e,t,n={}){const r=[];let o="",i=0;for(let s=0;s<e.length;s++){const a=e[s];if(o+=a,i+=n[a]||1,i>t){const{line:e,rest:t}=Ae(o);r.push(e),o=t,i=t.split("").map((e=>n[e]||1)).reduce(((e,t)=>e+t),0)}}return o&&r.push(o),r},levenshteinDistance:function(e,t){const n=[];for(let r=0;r<=e.length;r++)n[r]=[r];for(let r=0;r<=t.length;r++)n[0][r]=r;for(let r=1;r<=e.length;r++)for(let o=1;o<=t.length;o++){const i=e[r-1]===t[o-1]?0:1;n[r][o]=Math.min(n[r-1][o]+1,n[r][o-1]+1,n[r-1][o-1]+i)}return n[e.length][t.length]},findCommonPrefix:ke,findCommonDirectory:function(e){const t=ke(e),n=t.lastIndexOf("/");return-1===n?"":t.slice(0,n+1)}}},878(e,t,n){t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const n="color: "+this.color;t.splice(1,0,n,"color: inherit");let r=0,o=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(r++,"%c"===e&&(o=r))})),t.splice(o,0,n)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(n){}},t.load=function(){let e;try{e=t.storage.getItem("debug")||t.storage.getItem("DEBUG")}catch(n){}!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG);return e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let e;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[1],10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=n(945)(t);const{formatters:r}=e.exports;r.j=function(e){try{return JSON.stringify(e)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}},945(e,t,n){e.exports=function(e){function t(e){let n,o,i,s=null;function a(...e){if(!a.enabled)return;const r=a,o=Number(new Date),i=o-(n||o);r.diff=i,r.prev=n,r.curr=o,n=o,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let s=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((n,o)=>{if("%%"===n)return"%";s++;const i=t.formatters[o];if("function"==typeof i){const t=e[s];n=i.call(r,t),e.splice(s,1),s--}return n})),t.formatArgs.call(r,e);(r.log||t.log).apply(r,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=r,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==s?s:(o!==t.namespaces&&(o=t.namespaces,i=t.enabled(e)),i),set:e=>{s=e}}),"function"==typeof t.init&&t.init(a),a}function r(e,n){const r=t(this.namespace+(void 0===n?":":n)+e);return r.log=this.log,r}function o(e,t){let n=0,r=0,o=-1,i=0;for(;n<e.length;)if(r<t.length&&(t[r]===e[n]||"*"===t[r]))"*"===t[r]?(o=r,i=n,r++):(n++,r++);else{if(-1===o)return!1;r=o+1,i++,n=i}for(;r<t.length&&"*"===t[r];)r++;return r===t.length}return t.debug=t,t.default=t,t.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},t.disable=function(){const e=[...t.names,...t.skips.map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){t.save(e),t.namespaces=e,t.names=[],t.skips=[];const n=("string"==typeof e?e:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const r of n)"-"===r[0]?t.skips.push(r.slice(1)):t.names.push(r)},t.enabled=function(e){for(const n of t.skips)if(o(e,n))return!1;for(const n of t.names)if(o(e,n))return!0;return!1},t.humanize=n(192),t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach((n=>{t[n]=e[n]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let n=0;for(let t=0;t<e.length;t++)n=(n<<5)-n+e.charCodeAt(t),n|=0;return t.colors[Math.abs(n)%t.colors.length]},t.enable(t.load()),t}},192(e){var t=1e3,n=60*t,r=60*n,o=24*r,i=7*o,s=365.25*o;function a(e,t,n,r){var o=t>=1.5*n;return Math.round(e/n)+" "+r+(o?"s":"")}e.exports=function(e,c){c=c||{};var u=typeof e;if("string"===u&&e.length>0)return function(e){if((e=String(e)).length>100)return;var a=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!a)return;var c=parseFloat(a[1]);switch((a[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return c*s;case"weeks":case"week":case"w":return c*i;case"days":case"day":case"d":return c*o;case"hours":case"hour":case"hrs":case"hr":case"h":return c*r;case"minutes":case"minute":case"mins":case"min":case"m":return c*n;case"seconds":case"second":case"secs":case"sec":case"s":return c*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return c;default:return}}(e);if("number"===u&&isFinite(e))return c.long?function(e){var i=Math.abs(e);if(i>=o)return a(e,i,o,"day");if(i>=r)return a(e,i,r,"hour");if(i>=n)return a(e,i,n,"minute");if(i>=t)return a(e,i,t,"second");return e+" ms"}(e):function(e){var i=Math.abs(e);if(i>=o)return Math.round(e/o)+"d";if(i>=r)return Math.round(e/r)+"h";if(i>=n)return Math.round(e/n)+"m";if(i>=t)return Math.round(e/t)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},963(e,t,n){"use strict";const r=n(527),{MAX_LENGTH:o,MAX_SAFE_INTEGER:i}=n(197),{safeRe:s,t:a}=n(423),c=n(676),{compareIdentifiers:u}=n(956);class l{constructor(e,t){if(t=c(t),e instanceof l){if(e.loose===!!t.loose&&e.includePrerelease===!!t.includePrerelease)return e;e=e.version}else if("string"!=typeof e)throw new TypeError(`Invalid version. Must be a string. Got type "${typeof e}".`);if(e.length>o)throw new TypeError(`version is longer than ${o} characters`);r("SemVer",e,t),this.options=t,this.loose=!!t.loose,this.includePrerelease=!!t.includePrerelease;const n=e.trim().match(t.loose?s[a.LOOSE]:s[a.FULL]);if(!n)throw new TypeError(`Invalid Version: ${e}`);if(this.raw=e,this.major=+n[1],this.minor=+n[2],this.patch=+n[3],this.major>i||this.major<0)throw new TypeError("Invalid major version");if(this.minor>i||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>i||this.patch<0)throw new TypeError("Invalid patch version");n[4]?this.prerelease=n[4].split(".").map((e=>{if(/^[0-9]+$/.test(e)){const t=+e;if(t>=0&&t<i)return t}return e})):this.prerelease=[],this.build=n[5]?n[5].split("."):[],this.format()}format(){return this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length&&(this.version+=`-${this.prerelease.join(".")}`),this.version}toString(){return this.version}compare(e){if(r("SemVer.compare",this.version,this.options,e),!(e instanceof l)){if("string"==typeof e&&e===this.version)return 0;e=new l(e,this.options)}return e.version===this.version?0:this.compareMain(e)||this.comparePre(e)}compareMain(e){return e instanceof l||(e=new l(e,this.options)),this.major<e.major?-1:this.major>e.major?1:this.minor<e.minor?-1:this.minor>e.minor?1:this.patch<e.patch?-1:this.patch>e.patch?1:0}comparePre(e){if(e instanceof l||(e=new l(e,this.options)),this.prerelease.length&&!e.prerelease.length)return-1;if(!this.prerelease.length&&e.prerelease.length)return 1;if(!this.prerelease.length&&!e.prerelease.length)return 0;let t=0;do{const n=this.prerelease[t],o=e.prerelease[t];if(r("prerelease compare",t,n,o),void 0===n&&void 0===o)return 0;if(void 0===o)return 1;if(void 0===n)return-1;if(n!==o)return u(n,o)}while(++t)}compareBuild(e){e instanceof l||(e=new l(e,this.options));let t=0;do{const n=this.build[t],o=e.build[t];if(r("build compare",t,n,o),void 0===n&&void 0===o)return 0;if(void 0===o)return 1;if(void 0===n)return-1;if(n!==o)return u(n,o)}while(++t)}inc(e,t,n){if(e.startsWith("pre")){if(!t&&!1===n)throw new Error("invalid increment argument: identifier is empty");if(t){const e=`-${t}`.match(this.options.loose?s[a.PRERELEASELOOSE]:s[a.PRERELEASE]);if(!e||e[1]!==t)throw new Error(`invalid identifier: ${t}`)}}switch(e){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",t,n);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",t,n);break;case"prepatch":this.prerelease.length=0,this.inc("patch",t,n),this.inc("pre",t,n);break;case"prerelease":0===this.prerelease.length&&this.inc("patch",t,n),this.inc("pre",t,n);break;case"release":if(0===this.prerelease.length)throw new Error(`version ${this.raw} is not a prerelease`);this.prerelease.length=0;break;case"major":0===this.minor&&0===this.patch&&0!==this.prerelease.length||this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":0===this.patch&&0!==this.prerelease.length||this.minor++,this.patch=0,this.prerelease=[];break;case"patch":0===this.prerelease.length&&this.patch++,this.prerelease=[];break;case"pre":{const e=Number(n)?1:0;if(0===this.prerelease.length)this.prerelease=[e];else{let r=this.prerelease.length;for(;--r>=0;)"number"==typeof this.prerelease[r]&&(this.prerelease[r]++,r=-2);if(-1===r){if(t===this.prerelease.join(".")&&!1===n)throw new Error("invalid increment argument: identifier already exists");this.prerelease.push(e)}}if(t){let r=[t,e];if(!1===n&&(r=[t]),((e,t)=>{const n=t.split(".");if(n.length>e.length)return!1;for(let r=0;r<n.length;r++)if(0!==u(e[r],n[r]))return!1;return!0})(this.prerelease,t)){const e=this.prerelease[t.split(".").length];isNaN(e)&&(this.prerelease=r)}else this.prerelease=r}break}default:throw new Error(`invalid increment argument: ${e}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(".")}`),this}}e.exports=l},359(e,t,n){"use strict";const r=n(963);e.exports=(e,t)=>new r(e,t).major},197(e){"use strict";const t=Number.MAX_SAFE_INTEGER||9007199254740991;e.exports={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:16,MAX_SAFE_BUILD_LENGTH:250,MAX_SAFE_INTEGER:t,RELEASE_TYPES:["major","premajor","minor","preminor","patch","prepatch","prerelease"],SEMVER_SPEC_VERSION:"2.0.0",FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}},527(e){"use strict";const t="object"==typeof process&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...e)=>console.error("SEMVER",...e):()=>{};e.exports=t},956(e){"use strict";const t=/^[0-9]+$/,n=(e,n)=>{if("number"==typeof e&&"number"==typeof n)return e===n?0:e<n?-1:1;const r=t.test(e),o=t.test(n);return r&&o&&(e=+e,n=+n),e===n?0:r&&!o?-1:o&&!r?1:e<n?-1:1};e.exports={compareIdentifiers:n,rcompareIdentifiers:(e,t)=>n(t,e)}},676(e){"use strict";const t=Object.freeze({loose:!0}),n=Object.freeze({});e.exports=e=>e?"object"!=typeof e?t:e:n},423(e,t,n){"use strict";const{MAX_SAFE_COMPONENT_LENGTH:r,MAX_SAFE_BUILD_LENGTH:o,MAX_LENGTH:i}=n(197),s=n(527),a=(t=e.exports={}).re=[],c=t.safeRe=[],u=t.src=[],l=t.safeSrc=[],f=t.t={};let h=0;const d="[a-zA-Z0-9-]",p=[["\\s",1],["\\d",i],[d,o]],m=(e,t,n)=>{const r=(e=>{for(const[t,n]of p)e=e.split(`${t}*`).join(`${t}{0,${n}}`).split(`${t}+`).join(`${t}{1,${n}}`);return e})(t),o=h++;s(e,o,t),f[e]=o,u[o]=t,l[o]=r,a[o]=new RegExp(t,n?"g":void 0),c[o]=new RegExp(r,n?"g":void 0)};m("NUMERICIDENTIFIER","0|[1-9]\\d*"),m("NUMERICIDENTIFIERLOOSE","\\d+"),m("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${d}*`),m("MAINVERSION",`(${u[f.NUMERICIDENTIFIER]})\\.(${u[f.NUMERICIDENTIFIER]})\\.(${u[f.NUMERICIDENTIFIER]})`),m("MAINVERSIONLOOSE",`(${u[f.NUMERICIDENTIFIERLOOSE]})\\.(${u[f.NUMERICIDENTIFIERLOOSE]})\\.(${u[f.NUMERICIDENTIFIERLOOSE]})`),m("PRERELEASEIDENTIFIER",`(?:${u[f.NONNUMERICIDENTIFIER]}|${u[f.NUMERICIDENTIFIER]})`),m("PRERELEASEIDENTIFIERLOOSE",`(?:${u[f.NONNUMERICIDENTIFIER]}|${u[f.NUMERICIDENTIFIERLOOSE]})`),m("PRERELEASE",`(?:-(${u[f.PRERELEASEIDENTIFIER]}(?:\\.${u[f.PRERELEASEIDENTIFIER]})*))`),m("PRERELEASELOOSE",`(?:-?(${u[f.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${u[f.PRERELEASEIDENTIFIERLOOSE]})*))`),m("BUILDIDENTIFIER",`${d}+`),m("BUILD",`(?:\\+(${u[f.BUILDIDENTIFIER]}(?:\\.${u[f.BUILDIDENTIFIER]})*))`),m("FULLPLAIN",`v?${u[f.MAINVERSION]}${u[f.PRERELEASE]}?${u[f.BUILD]}?`),m("FULL",`^${u[f.FULLPLAIN]}$`),m("LOOSEPLAIN",`[v=\\s]*${u[f.MAINVERSIONLOOSE]}${u[f.PRERELEASELOOSE]}?${u[f.BUILD]}?`),m("LOOSE",`^${u[f.LOOSEPLAIN]}$`),m("GTLT","((?:<|>)?=?)"),m("XRANGEIDENTIFIERLOOSE",`${u[f.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),m("XRANGEIDENTIFIER",`${u[f.NUMERICIDENTIFIER]}|x|X|\\*`),m("XRANGEPLAIN",`[v=\\s]*(${u[f.XRANGEIDENTIFIER]})(?:\\.(${u[f.XRANGEIDENTIFIER]})(?:\\.(${u[f.XRANGEIDENTIFIER]})(?:${u[f.PRERELEASE]})?${u[f.BUILD]}?)?)?`),m("XRANGEPLAINLOOSE",`[v=\\s]*(${u[f.XRANGEIDENTIFIERLOOSE]})(?:\\.(${u[f.XRANGEIDENTIFIERLOOSE]})(?:\\.(${u[f.XRANGEIDENTIFIERLOOSE]})(?:${u[f.PRERELEASELOOSE]})?${u[f.BUILD]}?)?)?`),m("XRANGE",`^${u[f.GTLT]}\\s*${u[f.XRANGEPLAIN]}$`),m("XRANGELOOSE",`^${u[f.GTLT]}\\s*${u[f.XRANGEPLAINLOOSE]}$`),m("COERCEPLAIN",`(^|[^\\d])(\\d{1,${r}})(?:\\.(\\d{1,${r}}))?(?:\\.(\\d{1,${r}}))?`),m("COERCE",`${u[f.COERCEPLAIN]}(?:$|[^\\d])`),m("COERCEFULL",u[f.COERCEPLAIN]+`(?:${u[f.PRERELEASE]})?`+`(?:${u[f.BUILD]})?(?:$|[^\\d])`),m("COERCERTL",u[f.COERCE],!0),m("COERCERTLFULL",u[f.COERCEFULL],!0),m("LONETILDE","(?:~>?)"),m("TILDETRIM",`(\\s*)${u[f.LONETILDE]}\\s+`,!0),t.tildeTrimReplace="$1~",m("TILDE",`^${u[f.LONETILDE]}${u[f.XRANGEPLAIN]}$`),m("TILDELOOSE",`^${u[f.LONETILDE]}${u[f.XRANGEPLAINLOOSE]}$`),m("LONECARET","(?:\\^)"),m("CARETTRIM",`(\\s*)${u[f.LONECARET]}\\s+`,!0),t.caretTrimReplace="$1^",m("CARET",`^${u[f.LONECARET]}${u[f.XRANGEPLAIN]}$`),m("CARETLOOSE",`^${u[f.LONECARET]}${u[f.XRANGEPLAINLOOSE]}$`),m("COMPARATORLOOSE",`^${u[f.GTLT]}\\s*(${u[f.LOOSEPLAIN]})$|^$`),m("COMPARATOR",`^${u[f.GTLT]}\\s*(${u[f.FULLPLAIN]})$|^$`),m("COMPARATORTRIM",`(\\s*)${u[f.GTLT]}\\s*(${u[f.LOOSEPLAIN]}|${u[f.XRANGEPLAIN]})`,!0),t.comparatorTrimReplace="$1$2$3",m("HYPHENRANGE",`^\\s*(${u[f.XRANGEPLAIN]})\\s+-\\s+(${u[f.XRANGEPLAIN]})\\s*$`),m("HYPHENRANGELOOSE",`^\\s*(${u[f.XRANGEPLAINLOOSE]})\\s+-\\s+(${u[f.XRANGEPLAINLOOSE]})\\s*$`),m("STAR","(<|>)?=?\\s*\\*"),m("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$"),m("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")},497(){},61(){},320(){}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={exports:{}};return e[r](i,i.exports,n),i.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};return(()=>{"use strict";n.r(r),n.d(r,{BRANCHES:()=>pu,BZZ:()=>su,BatchId:()=>Nt,Bee:()=>qh,BeeArgumentError:()=>nu,BeeError:()=>tu,BeeModes:()=>fu,BeeResponseError:()=>ru,Bytes:()=>Pt,CHUNK_SIZE:()=>mu,ChunkBuilder:()=>zn,ChunkSplitter:()=>An,DAI:()=>au,Duration:()=>ou,EthAddress:()=>Ut,FeedIndex:()=>Lt,Identifier:()=>Zt,MantarayNode:()=>Sl,NULL_ADDRESS:()=>Kh,NULL_IDENTIFIER:()=>Xh,NULL_OWNER:()=>Yh,NULL_STAMP:()=>Wh,NULL_TOPIC:()=>Jh,PSS_TARGET_HEX_LENGTH_MAX:()=>gu,PeerAddress:()=>qt,PrivateKey:()=>en,PublicKey:()=>Jt,RedundancyLevel:()=>Bu,RedundancyStrategy:()=>Eu,Reference:()=>nn,RollingFeedReader:()=>Jf,RollingFeedWriter:()=>Wf,SECTION_SIZE:()=>du,STAMPS_DEPTH_MAX:()=>wu,STAMPS_DEPTH_MIN:()=>yu,SUPPORTED_BEE_VERSION:()=>Th,SUPPORTED_BEE_VERSION_EXACT:()=>xh,SWARM_GATEWAY_URL:()=>Hh,Signature:()=>Qt,Size:()=>iu,Span:()=>rn,Stamper:()=>ar,TAGS_LIMIT_MAX:()=>vu,TAGS_LIMIT_MIN:()=>bu,Topic:()=>sn,TransactionId:()=>an,Utils:()=>e,capacityBreakpoints:()=>xu,toBeeMode:()=>hu});var e={};n.r(e),n.d(e,{approximateOverheadForRedundancyLevel:()=>$n,convertEnvelopeToMarshaledStamp:()=>Ju,getAmountForDuration:()=>Hu,getCollectionSize:()=>Ml,getDepthForSize:()=>Wu,getFolderSize:()=>Vl,getRedundancyStat:()=>Nn,getRedundancyStats:()=>Pn,getStampCost:()=>Zu,getStampDuration:()=>qu,getStampEffectiveBytes:()=>rr,getStampEffectiveBytesBreakpoints:()=>or,getStampTheoreticalBytes:()=>Xn,getStampUsage:()=>Kn,makeCollectionFromFileList:()=>Fl,makeMaxTarget:()=>Qh,mapPostageBatch:()=>Ku,unmapPostageBatch:()=>Xu});const t="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0;function o(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function i(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function s(e,...t){if(!o(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function a(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.createHasher");i(e.outputLen),i(e.blockLen)}function c(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function u(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function l(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function f(e,t){return e<<32-t|e>>>t}const h=(()=>"function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex)(),d=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function p(e){if(s(e),h)return e.toHex();let t="";for(let n=0;n<e.length;n++)t+=d[e[n]];return t}const m=48,g=57,y=65,w=70,b=97,v=102;function B(e){return e>=m&&e<=g?e-m:e>=y&&e<=w?e-(y-10):e>=b&&e<=v?e-(b-10):void 0}function E(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);if(h)return Uint8Array.fromHex(e);const t=e.length,n=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const r=new Uint8Array(n);for(let o=0,i=0;o<n;o++,i+=2){const t=B(e.charCodeAt(i)),n=B(e.charCodeAt(i+1));if(void 0===t||void 0===n){const t=e[i]+e[i+1];throw new Error('hex string expected, got non-hex character "'+t+'" at index '+i)}r[o]=16*t+n}return r}function x(e){if("string"!=typeof e)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(e))}function T(e){return"string"==typeof e&&(e=x(e)),s(e),e}function R(...e){let t=0;for(let r=0;r<e.length;r++){const n=e[r];s(n),t+=n.length}const n=new Uint8Array(t);for(let r=0,o=0;r<e.length;r++){const t=e[r];n.set(t,o),o+=t.length}return n}class z{}function A(e){const t=t=>e().update(T(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function k(e=32){if(t&&"function"==typeof t.getRandomValues)return t.getRandomValues(new Uint8Array(e));if(t&&"function"==typeof t.randomBytes)return Uint8Array.from(t.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}function S(e,t,n){return e&t^e&n^t&n}class O extends z{constructor(e,t,n,r){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.buffer=new Uint8Array(e),this.view=l(this.buffer)}update(e){c(this),s(e=T(e));const{view:t,buffer:n,blockLen:r}=this,o=e.length;for(let i=0;i<o;){const s=Math.min(r-this.pos,o-i);if(s!==r)n.set(e.subarray(i,i+s),this.pos),this.pos+=s,i+=s,this.pos===r&&(this.process(t,0),this.pos=0);else{const t=l(e);for(;r<=o-i;i+=r)this.process(t,i)}}return this.length+=e.length,this.roundClean(),this}digestInto(e){c(this),function(e,t){s(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}(e,this),this.finished=!0;const{buffer:t,view:n,blockLen:r,isLE:o}=this;let{pos:i}=this;t[i++]=128,u(this.buffer.subarray(i)),this.padOffset>r-i&&(this.process(n,0),i=0);for(let s=i;s<r;s++)t[s]=0;!function(e,t,n,r){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,n,r);const o=BigInt(32),i=BigInt(4294967295),s=Number(n>>o&i),a=Number(n&i),c=r?4:0,u=r?0:4;e.setUint32(t+c,s,r),e.setUint32(t+u,a,r)}(n,r-8,BigInt(8*this.length),o),this.process(n,0);const a=l(e),f=this.outputLen;if(f%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const h=f/4,d=this.get();if(h>d.length)throw new Error("_sha2: outputLen bigger than state");for(let s=0;s<h;s++)a.setUint32(4*s,d[s],o)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:n,length:r,finished:o,destroyed:i,pos:s}=this;return e.destroyed=i,e.finished=o,e.length=r,e.pos=s,r%t&&e.buffer.set(n),e}clone(){return this._cloneInto()}}const $=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);const I=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),_=new Uint32Array(64);class V extends O{constructor(e=32){super(64,e,8,!1),this.A=0|$[0],this.B=0|$[1],this.C=0|$[2],this.D=0|$[3],this.E=0|$[4],this.F=0|$[5],this.G=0|$[6],this.H=0|$[7]}get(){const{A:e,B:t,C:n,D:r,E:o,F:i,G:s,H:a}=this;return[e,t,n,r,o,i,s,a]}set(e,t,n,r,o,i,s,a){this.A=0|e,this.B=0|t,this.C=0|n,this.D=0|r,this.E=0|o,this.F=0|i,this.G=0|s,this.H=0|a}process(e,t){for(let f=0;f<16;f++,t+=4)_[f]=e.getUint32(t,!1);for(let h=16;h<64;h++){const e=_[h-15],t=_[h-2],n=f(e,7)^f(e,18)^e>>>3,r=f(t,17)^f(t,19)^t>>>10;_[h]=r+_[h-7]+n+_[h-16]|0}let{A:n,B:r,C:o,D:i,E:s,F:a,G:c,H:u}=this;for(let h=0;h<64;h++){const e=u+(f(s,6)^f(s,11)^f(s,25))+((l=s)&a^~l&c)+I[h]+_[h]|0,t=(f(n,2)^f(n,13)^f(n,22))+S(n,r,o)|0;u=c,c=a,a=s,s=i+e|0,i=o,o=r,r=n,n=e+t|0}var l;n=n+this.A|0,r=r+this.B|0,o=o+this.C|0,i=i+this.D|0,s=s+this.E|0,a=a+this.F|0,c=c+this.G|0,u=u+this.H|0,this.set(n,r,o,i,s,a,c,u)}roundClean(){u(_)}destroy(){this.set(0,0,0,0,0,0,0,0),u(this.buffer)}}const D=A((()=>new V));class P extends z{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,a(e);const n=T(t);if(this.iHash=e.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const r=this.blockLen,o=new Uint8Array(r);o.set(n.length>r?e.create().update(n).digest():n);for(let i=0;i<o.length;i++)o[i]^=54;this.iHash.update(o),this.oHash=e.create();for(let i=0;i<o.length;i++)o[i]^=106;this.oHash.update(o),u(o)}update(e){return c(this),this.iHash.update(e),this}digestInto(e){c(this),s(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:n,finished:r,destroyed:o,blockLen:i,outputLen:s}=this;return e.finished=r,e.destroyed=o,e.blockLen=i,e.outputLen=s,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const N=(e,t,n)=>new P(e,t).update(n).digest();N.create=(e,t)=>new P(e,t);const C=BigInt(0),F=BigInt(1);function M(e,t=""){if("boolean"!=typeof e){throw new Error((t&&`"${t}"`)+"expected boolean, got type="+typeof e)}return e}function U(e,t,n=""){const r=o(e),i=e?.length,s=void 0!==t;if(!r||s&&i!==t){throw new Error((n&&`"${n}" `)+"expected Uint8Array"+(s?` of length ${t}`:"")+", got "+(r?`length=${i}`:"type="+typeof e))}return e}function G(e){const t=e.toString(16);return 1&t.length?"0"+t:t}function L(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);return""===e?C:BigInt("0x"+e)}function j(e){return L(p(e))}function Z(e){return s(e),L(p(Uint8Array.from(e).reverse()))}function q(e,t){return E(e.toString(16).padStart(2*t,"0"))}function H(e,t){return q(e,t).reverse()}function W(e,t,n){let r;if("string"==typeof t)try{r=E(t)}catch(s){throw new Error(e+" must be hex string or Uint8Array, cause: "+s)}else{if(!o(t))throw new Error(e+" must be hex string or Uint8Array");r=Uint8Array.from(t)}const i=r.length;if("number"==typeof n&&i!==n)throw new Error(e+" of length "+n+" expected, got "+i);return r}const J=e=>"bigint"==typeof e&&C<=e;function K(e,t,n,r){if(!function(e,t,n){return J(e)&&J(t)&&J(n)&&t<=e&&e<n}(t,n,r))throw new Error("expected valid "+e+": "+n+" <= n < "+r+", got "+t)}function X(e){let t;for(t=0;e>C;e>>=F,t+=1);return t}const Y=e=>(F<<BigInt(e))-F;function Q(e,t,n={}){if(!e||"object"!=typeof e)throw new Error("expected valid options object");function r(t,n,r){const o=e[t];if(r&&void 0===o)return;const i=typeof o;if(i!==n||null===o)throw new Error(`param "${t}" is invalid: expected ${n}, got ${i}`)}Object.entries(t).forEach((([e,t])=>r(e,t,!1))),Object.entries(n).forEach((([e,t])=>r(e,t,!0)))}function ee(e){const t=new WeakMap;return(n,...r)=>{const o=t.get(n);if(void 0!==o)return o;const i=e(n,...r);return t.set(n,i),i}}const te=BigInt(0),ne=BigInt(1),re=BigInt(2),oe=BigInt(3),ie=BigInt(4),se=BigInt(5),ae=BigInt(7),ce=BigInt(8),ue=BigInt(9),le=BigInt(16);function fe(e,t){const n=e%t;return n>=te?n:t+n}function he(e,t,n){let r=e;for(;t-- >te;)r*=r,r%=n;return r}function de(e,t){if(e===te)throw new Error("invert: expected non-zero number");if(t<=te)throw new Error("invert: expected positive modulus, got "+t);let n=fe(e,t),r=t,o=te,i=ne,s=ne,a=te;for(;n!==te;){const e=r/n,t=r%n,c=o-s*e,u=i-a*e;r=n,n=t,o=s,i=a,s=c,a=u}if(r!==ne)throw new Error("invert: does not exist");return fe(o,t)}function pe(e,t,n){if(!e.eql(e.sqr(t),n))throw new Error("Cannot find square root")}function me(e,t){const n=(e.ORDER+ne)/ie,r=e.pow(t,n);return pe(e,r,t),r}function ge(e,t){const n=(e.ORDER-se)/ce,r=e.mul(t,re),o=e.pow(r,n),i=e.mul(t,o),s=e.mul(e.mul(i,re),o),a=e.mul(i,e.sub(s,e.ONE));return pe(e,a,t),a}function ye(e){if(e<oe)throw new Error("sqrt is not defined for small field");let t=e-ne,n=0;for(;t%re===te;)t/=re,n++;let r=re;const o=Te(e);for(;1===Ee(o,r);)if(r++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(1===n)return me;let i=o.pow(r,t);const s=(t+ne)/re;return function(e,r){if(e.is0(r))return r;if(1!==Ee(e,r))throw new Error("Cannot find square root");let o=n,a=e.mul(e.ONE,i),c=e.pow(r,t),u=e.pow(r,s);for(;!e.eql(c,e.ONE);){if(e.is0(c))return e.ZERO;let t=1,n=e.sqr(c);for(;!e.eql(n,e.ONE);)if(t++,n=e.sqr(n),t===o)throw new Error("Cannot find square root");const r=ne<<BigInt(o-t-1),i=e.pow(a,r);o=t,a=e.sqr(i),c=e.mul(c,a),u=e.mul(u,i)}return u}}function we(e){return e%ie===oe?me:e%ce===se?ge:e%le===ue?function(e){const t=Te(e),n=ye(e),r=n(t,t.neg(t.ONE)),o=n(t,r),i=n(t,t.neg(r)),s=(e+ae)/le;return(e,t)=>{let n=e.pow(t,s),a=e.mul(n,r);const c=e.mul(n,o),u=e.mul(n,i),l=e.eql(e.sqr(a),t),f=e.eql(e.sqr(c),t);n=e.cmov(n,a,l),a=e.cmov(u,c,f);const h=e.eql(e.sqr(a),t),d=e.cmov(n,a,h);return pe(e,d,t),d}}(e):ye(e)}const be=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function ve(e,t,n){if(n<te)throw new Error("invalid exponent, negatives unsupported");if(n===te)return e.ONE;if(n===ne)return t;let r=e.ONE,o=t;for(;n>te;)n&ne&&(r=e.mul(r,o)),o=e.sqr(o),n>>=ne;return r}function Be(e,t,n=!1){const r=new Array(t.length).fill(n?e.ZERO:void 0),o=t.reduce(((t,n,o)=>e.is0(n)?t:(r[o]=t,e.mul(t,n))),e.ONE),i=e.inv(o);return t.reduceRight(((t,n,o)=>e.is0(n)?t:(r[o]=e.mul(t,r[o]),e.mul(t,n))),i),r}function Ee(e,t){const n=(e.ORDER-ne)/re,r=e.pow(t,n),o=e.eql(r,e.ONE),i=e.eql(r,e.ZERO),s=e.eql(r,e.neg(e.ONE));if(!o&&!i&&!s)throw new Error("invalid Legendre symbol result");return o?1:i?0:-1}function xe(e,t){void 0!==t&&i(t);const n=void 0!==t?t:e.toString(2).length;return{nBitLength:n,nByteLength:Math.ceil(n/8)}}function Te(e,t,n=!1,r={}){if(e<=te)throw new Error("invalid field: expected ORDER > 0, got "+e);let o,i,s,a=!1;if("object"==typeof t&&null!=t){if(r.sqrt||n)throw new Error("cannot specify opts in two arguments");const e=t;e.BITS&&(o=e.BITS),e.sqrt&&(i=e.sqrt),"boolean"==typeof e.isLE&&(n=e.isLE),"boolean"==typeof e.modFromBytes&&(a=e.modFromBytes),s=e.allowedLengths}else"number"==typeof t&&(o=t),r.sqrt&&(i=r.sqrt);const{nBitLength:c,nByteLength:u}=xe(e,o);if(u>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let l;const f=Object.freeze({ORDER:e,isLE:n,BITS:c,BYTES:u,MASK:Y(c),ZERO:te,ONE:ne,allowedLengths:s,create:t=>fe(t,e),isValid:t=>{if("bigint"!=typeof t)throw new Error("invalid field element: expected bigint, got "+typeof t);return te<=t&&t<e},is0:e=>e===te,isValidNot0:e=>!f.is0(e)&&f.isValid(e),isOdd:e=>(e&ne)===ne,neg:t=>fe(-t,e),eql:(e,t)=>e===t,sqr:t=>fe(t*t,e),add:(t,n)=>fe(t+n,e),sub:(t,n)=>fe(t-n,e),mul:(t,n)=>fe(t*n,e),pow:(e,t)=>ve(f,e,t),div:(t,n)=>fe(t*de(n,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>de(t,e),sqrt:i||(t=>(l||(l=we(e)),l(f,t))),toBytes:e=>n?H(e,u):q(e,u),fromBytes:(t,r=!0)=>{if(s){if(!s.includes(t.length)||t.length>u)throw new Error("Field.fromBytes: expected "+s+" bytes, got "+t.length);const e=new Uint8Array(u);e.set(t,n?0:e.length-t.length),t=e}if(t.length!==u)throw new Error("Field.fromBytes: expected "+u+" bytes, got "+t.length);let o=n?Z(t):j(t);if(a&&(o=fe(o,e)),!r&&!f.isValid(o))throw new Error("invalid field element: outside of range 0..ORDER");return o},invertBatch:e=>Be(f,e),cmov:(e,t,n)=>n?t:e});return Object.freeze(f)}function Re(e){if("bigint"!=typeof e)throw new Error("field order must be bigint");const t=e.toString(2).length;return Math.ceil(t/8)}function ze(e){const t=Re(e);return t+Math.ceil(t/2)}const Ae=BigInt(0),ke=BigInt(1);function Se(e,t){const n=t.negate();return e?n:t}function Oe(e,t){const n=Be(e.Fp,t.map((e=>e.Z)));return t.map(((t,r)=>e.fromAffine(t.toAffine(n[r]))))}function $e(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function Ie(e,t){$e(e,t);const n=2**e;return{windows:Math.ceil(t/e)+1,windowSize:2**(e-1),mask:Y(e),maxNumber:n,shiftBy:BigInt(e)}}function _e(e,t,n){const{windowSize:r,mask:o,maxNumber:i,shiftBy:s}=n;let a=Number(e&o),c=e>>s;a>r&&(a-=i,c+=ke);const u=t*r;return{nextN:c,offset:u+Math.abs(a)-1,isZero:0===a,isNeg:a<0,isNegF:t%2!=0,offsetF:u}}function Ve(e,t){if(!Array.isArray(e))throw new Error("array expected");e.forEach(((e,n)=>{if(!(e instanceof t))throw new Error("invalid point at index "+n)}))}function De(e,t){if(!Array.isArray(e))throw new Error("array of scalars expected");e.forEach(((e,n)=>{if(!t.isValid(e))throw new Error("invalid scalar at index "+n)}))}const Pe=new WeakMap,Ne=new WeakMap;function Ce(e){return Ne.get(e)||1}function Fe(e){if(e!==Ae)throw new Error("invalid wNAF")}class Me{constructor(e,t){this.BASE=e.BASE,this.ZERO=e.ZERO,this.Fn=e.Fn,this.bits=t}_unsafeLadder(e,t,n=this.ZERO){let r=e;for(;t>Ae;)t&ke&&(n=n.add(r)),r=r.double(),t>>=ke;return n}precomputeWindow(e,t){const{windows:n,windowSize:r}=Ie(t,this.bits),o=[];let i=e,s=i;for(let a=0;a<n;a++){s=i,o.push(s);for(let e=1;e<r;e++)s=s.add(i),o.push(s);i=s.double()}return o}wNAF(e,t,n){if(!this.Fn.isValid(n))throw new Error("invalid scalar");let r=this.ZERO,o=this.BASE;const i=Ie(e,this.bits);for(let s=0;s<i.windows;s++){const{nextN:e,offset:a,isZero:c,isNeg:u,isNegF:l,offsetF:f}=_e(n,s,i);n=e,c?o=o.add(Se(l,t[f])):r=r.add(Se(u,t[a]))}return Fe(n),{p:r,f:o}}wNAFUnsafe(e,t,n,r=this.ZERO){const o=Ie(e,this.bits);for(let i=0;i<o.windows&&n!==Ae;i++){const{nextN:e,offset:s,isZero:a,isNeg:c}=_e(n,i,o);if(n=e,!a){const e=t[s];r=r.add(c?e.negate():e)}}return Fe(n),r}getPrecomputes(e,t,n){let r=Pe.get(t);return r||(r=this.precomputeWindow(t,e),1!==e&&("function"==typeof n&&(r=n(r)),Pe.set(t,r))),r}cached(e,t,n){const r=Ce(e);return this.wNAF(r,this.getPrecomputes(r,e,n),t)}unsafe(e,t,n,r){const o=Ce(e);return 1===o?this._unsafeLadder(e,t,r):this.wNAFUnsafe(o,this.getPrecomputes(o,e,n),t,r)}createCache(e,t){$e(t,this.bits),Ne.set(e,t),Pe.delete(e)}hasCache(e){return 1!==Ce(e)}}function Ue(e,t,n){if(t){if(t.ORDER!==e)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return function(e){const t=be.reduce(((e,t)=>(e[t]="function",e)),{ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"});Q(e,t)}(t),t}return Te(e,{isLE:n})}const Ge=(e,t)=>(e+(e>=0?t:-t)/Je)/t;function Le(e){if(!["compact","recovered","der"].includes(e))throw new Error('Signature format must be "compact", "recovered", or "der"');return e}function je(e,t){const n={};for(let r of Object.keys(t))n[r]=void 0===e[r]?t[r]:e[r];return M(n.lowS,"lowS"),M(n.prehash,"prehash"),void 0!==n.format&&Le(n.format),n}class Ze extends Error{constructor(e=""){super(e)}}const qe={Err:Ze,_tlv:{encode:(e,t)=>{const{Err:n}=qe;if(e<0||e>256)throw new n("tlv.encode: wrong tag");if(1&t.length)throw new n("tlv.encode: unpadded data");const r=t.length/2,o=G(r);if(o.length/2&128)throw new n("tlv.encode: long form length too big");const i=r>127?G(o.length/2|128):"";return G(e)+i+o+t},decode(e,t){const{Err:n}=qe;let r=0;if(e<0||e>256)throw new n("tlv.encode: wrong tag");if(t.length<2||t[r++]!==e)throw new n("tlv.decode: wrong tlv");const o=t[r++];let i=0;if(!!(128&o)){const e=127&o;if(!e)throw new n("tlv.decode(long): indefinite length not supported");if(e>4)throw new n("tlv.decode(long): byte length is too big");const s=t.subarray(r,r+e);if(s.length!==e)throw new n("tlv.decode: length bytes not complete");if(0===s[0])throw new n("tlv.decode(long): zero leftmost byte");for(const t of s)i=i<<8|t;if(r+=e,i<128)throw new n("tlv.decode(long): not minimal encoding")}else i=o;const s=t.subarray(r,r+i);if(s.length!==i)throw new n("tlv.decode: wrong value length");return{v:s,l:t.subarray(r+i)}}},_int:{encode(e){const{Err:t}=qe;if(e<He)throw new t("integer: negative integers are not allowed");let n=G(e);if(8&Number.parseInt(n[0],16)&&(n="00"+n),1&n.length)throw new t("unexpected DER parsing assertion: unpadded hex");return n},decode(e){const{Err:t}=qe;if(128&e[0])throw new t("invalid signature integer: negative");if(0===e[0]&&!(128&e[1]))throw new t("invalid signature integer: unnecessary leading zero");return j(e)}},toSig(e){const{Err:t,_int:n,_tlv:r}=qe,o=W("signature",e),{v:i,l:s}=r.decode(48,o);if(s.length)throw new t("invalid signature: left bytes after parsing");const{v:a,l:c}=r.decode(2,i),{v:u,l:l}=r.decode(2,c);if(l.length)throw new t("invalid signature: left bytes after parsing");return{r:n.decode(a),s:n.decode(u)}},hexFromSig(e){const{_tlv:t,_int:n}=qe,r=t.encode(2,n.encode(e.r))+t.encode(2,n.encode(e.s));return t.encode(48,r)}},He=BigInt(0),We=BigInt(1),Je=BigInt(2),Ke=BigInt(3),Xe=BigInt(4);function Ye(e,t){const{BYTES:n}=e;let r;if("bigint"==typeof t)r=t;else{let i=W("private key",t);try{r=e.fromBytes(i)}catch(o){throw new Error(`invalid private key: expected ui8a of size ${n}, got ${typeof t}`)}}if(!e.isValidNot0(r))throw new Error("invalid private key: out of range [1..N-1]");return r}function Qe(e,t={}){const n=function(e,t,n={},r){if(void 0===r&&(r="edwards"===e),!t||"object"!=typeof t)throw new Error(`expected valid ${e} CURVE object`);for(const a of["p","n","h"]){const e=t[a];if(!("bigint"==typeof e&&e>Ae))throw new Error(`CURVE.${a} must be positive bigint`)}const o=Ue(t.p,n.Fp,r),i=Ue(t.n,n.Fn,r),s=["Gx","Gy","a","weierstrass"===e?"b":"d"];for(const a of s)if(!o.isValid(t[a]))throw new Error(`CURVE.${a} must be valid field element of CURVE.Fp`);return{CURVE:t=Object.freeze(Object.assign({},t)),Fp:o,Fn:i}}("weierstrass",e,t),{Fp:r,Fn:o}=n;let i=n.CURVE;const{h:s,n:a}=i;Q(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",wrapPrivateKey:"boolean"});const{endo:c}=t;if(c&&(!r.is0(i.a)||"bigint"!=typeof c.beta||!Array.isArray(c.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');const u=tt(r,o);function l(){if(!r.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}const f=t.toBytes||function(e,t,n){const{x:o,y:i}=t.toAffine(),s=r.toBytes(o);if(M(n,"isCompressed"),n){l();return R(et(!r.isOdd(i)),s)}return R(Uint8Array.of(4),s,r.toBytes(i))},h=t.fromBytes||function(e){U(e,void 0,"Point");const{publicKey:t,publicKeyUncompressed:n}=u,o=e.length,i=e[0],s=e.subarray(1);if(o!==t||2!==i&&3!==i){if(o===n&&4===i){const e=r.BYTES,t=r.fromBytes(s.subarray(0,e)),n=r.fromBytes(s.subarray(e,2*e));if(!m(t,n))throw new Error("bad point: is not on curve");return{x:t,y:n}}throw new Error(`bad point: got length ${o}, expected compressed=${t} or uncompressed=${n}`)}{const e=r.fromBytes(s);if(!r.isValid(e))throw new Error("bad point: is not on curve, wrong x");const t=d(e);let n;try{n=r.sqrt(t)}catch(a){const e=a instanceof Error?": "+a.message:"";throw new Error("bad point: is not on curve, sqrt error"+e)}l();return!(1&~i)!==r.isOdd(n)&&(n=r.neg(n)),{x:e,y:n}}};function d(e){const t=r.sqr(e),n=r.mul(t,e);return r.add(r.add(n,r.mul(e,i.a)),i.b)}function m(e,t){const n=r.sqr(t),o=d(e);return r.eql(n,o)}if(!m(i.Gx,i.Gy))throw new Error("bad curve params: generator point");const g=r.mul(r.pow(i.a,Ke),Xe),y=r.mul(r.sqr(i.b),BigInt(27));if(r.is0(r.add(g,y)))throw new Error("bad curve params: a or b");function w(e,t,n=!1){if(!r.isValid(t)||n&&r.is0(t))throw new Error(`bad point coordinate ${e}`);return t}function b(e){if(!(e instanceof T))throw new Error("ProjectivePoint expected")}function v(e){if(!c||!c.basises)throw new Error("no endo");return function(e,t,n){const[[r,o],[i,s]]=t,a=Ge(s*e,n),c=Ge(-o*e,n);let u=e-a*r-c*i,l=-a*o-c*s;const f=u<He,h=l<He;f&&(u=-u),h&&(l=-l);const d=Y(Math.ceil(X(n)/2))+We;if(u<He||u>=d||l<He||l>=d)throw new Error("splitScalar (endomorphism): failed, k="+e);return{k1neg:f,k1:u,k2neg:h,k2:l}}(e,c.basises,o.ORDER)}const B=ee(((e,t)=>{const{X:n,Y:o,Z:i}=e;if(r.eql(i,r.ONE))return{x:n,y:o};const s=e.is0();null==t&&(t=s?r.ONE:r.inv(i));const a=r.mul(n,t),c=r.mul(o,t),u=r.mul(i,t);if(s)return{x:r.ZERO,y:r.ZERO};if(!r.eql(u,r.ONE))throw new Error("invZ was invalid");return{x:a,y:c}})),E=ee((e=>{if(e.is0()){if(t.allowInfinityPoint&&!r.is0(e.Y))return;throw new Error("bad point: ZERO")}const{x:n,y:o}=e.toAffine();if(!r.isValid(n)||!r.isValid(o))throw new Error("bad point: x or y not field elements");if(!m(n,o))throw new Error("bad point: equation left != right");if(!e.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0}));function x(e,t,n,o,i){return n=new T(r.mul(n.X,e),n.Y,n.Z),t=Se(o,t),n=Se(i,n),t.add(n)}class T{constructor(e,t,n){this.X=w("x",e),this.Y=w("y",t,!0),this.Z=w("z",n),Object.freeze(this)}static CURVE(){return i}static fromAffine(e){const{x:t,y:n}=e||{};if(!e||!r.isValid(t)||!r.isValid(n))throw new Error("invalid affine point");if(e instanceof T)throw new Error("projective point not allowed");return r.is0(t)&&r.is0(n)?T.ZERO:new T(t,n,r.ONE)}static fromBytes(e){const t=T.fromAffine(h(U(e,void 0,"point")));return t.assertValidity(),t}static fromHex(e){return T.fromBytes(W("pointHex",e))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(e=8,t=!0){return A.createCache(this,e),t||this.multiply(Ke),this}assertValidity(){E(this)}hasEvenY(){const{y:e}=this.toAffine();if(!r.isOdd)throw new Error("Field doesn't support isOdd");return!r.isOdd(e)}equals(e){b(e);const{X:t,Y:n,Z:o}=this,{X:i,Y:s,Z:a}=e,c=r.eql(r.mul(t,a),r.mul(i,o)),u=r.eql(r.mul(n,a),r.mul(s,o));return c&&u}negate(){return new T(this.X,r.neg(this.Y),this.Z)}double(){const{a:e,b:t}=i,n=r.mul(t,Ke),{X:o,Y:s,Z:a}=this;let c=r.ZERO,u=r.ZERO,l=r.ZERO,f=r.mul(o,o),h=r.mul(s,s),d=r.mul(a,a),p=r.mul(o,s);return p=r.add(p,p),l=r.mul(o,a),l=r.add(l,l),c=r.mul(e,l),u=r.mul(n,d),u=r.add(c,u),c=r.sub(h,u),u=r.add(h,u),u=r.mul(c,u),c=r.mul(p,c),l=r.mul(n,l),d=r.mul(e,d),p=r.sub(f,d),p=r.mul(e,p),p=r.add(p,l),l=r.add(f,f),f=r.add(l,f),f=r.add(f,d),f=r.mul(f,p),u=r.add(u,f),d=r.mul(s,a),d=r.add(d,d),f=r.mul(d,p),c=r.sub(c,f),l=r.mul(d,h),l=r.add(l,l),l=r.add(l,l),new T(c,u,l)}add(e){b(e);const{X:t,Y:n,Z:o}=this,{X:s,Y:a,Z:c}=e;let u=r.ZERO,l=r.ZERO,f=r.ZERO;const h=i.a,d=r.mul(i.b,Ke);let p=r.mul(t,s),m=r.mul(n,a),g=r.mul(o,c),y=r.add(t,n),w=r.add(s,a);y=r.mul(y,w),w=r.add(p,m),y=r.sub(y,w),w=r.add(t,o);let v=r.add(s,c);return w=r.mul(w,v),v=r.add(p,g),w=r.sub(w,v),v=r.add(n,o),u=r.add(a,c),v=r.mul(v,u),u=r.add(m,g),v=r.sub(v,u),f=r.mul(h,w),u=r.mul(d,g),f=r.add(u,f),u=r.sub(m,f),f=r.add(m,f),l=r.mul(u,f),m=r.add(p,p),m=r.add(m,p),g=r.mul(h,g),w=r.mul(d,w),m=r.add(m,g),g=r.sub(p,g),g=r.mul(h,g),w=r.add(w,g),p=r.mul(m,w),l=r.add(l,p),p=r.mul(v,w),u=r.mul(y,u),u=r.sub(u,p),p=r.mul(y,m),f=r.mul(v,f),f=r.add(f,p),new T(u,l,f)}subtract(e){return this.add(e.negate())}is0(){return this.equals(T.ZERO)}multiply(e){const{endo:n}=t;if(!o.isValidNot0(e))throw new Error("invalid scalar: out of range");let r,i;const s=e=>A.cached(this,e,(e=>Oe(T,e)));if(n){const{k1neg:t,k1:o,k2neg:a,k2:c}=v(e),{p:u,f:l}=s(o),{p:f,f:h}=s(c);i=l.add(h),r=x(n.beta,u,f,t,a)}else{const{p:t,f:n}=s(e);r=t,i=n}return Oe(T,[r,i])[0]}multiplyUnsafe(e){const{endo:n}=t,r=this;if(!o.isValid(e))throw new Error("invalid scalar: out of range");if(e===He||r.is0())return T.ZERO;if(e===We)return r;if(A.hasCache(this))return this.multiply(e);if(n){const{k1neg:t,k1:o,k2neg:i,k2:s}=v(e),{p1:a,p2:c}=function(e,t,n,r){let o=t,i=e.ZERO,s=e.ZERO;for(;n>Ae||r>Ae;)n&ke&&(i=i.add(o)),r&ke&&(s=s.add(o)),o=o.double(),n>>=ke,r>>=ke;return{p1:i,p2:s}}(T,r,o,s);return x(n.beta,a,c,t,i)}return A.unsafe(r,e)}multiplyAndAddUnsafe(e,t,n){const r=this.multiplyUnsafe(t).add(e.multiplyUnsafe(n));return r.is0()?void 0:r}toAffine(e){return B(this,e)}isTorsionFree(){const{isTorsionFree:e}=t;return s===We||(e?e(T,this):A.unsafe(this,a).is0())}clearCofactor(){const{clearCofactor:e}=t;return s===We?this:e?e(T,this):this.multiplyUnsafe(s)}isSmallOrder(){return this.multiplyUnsafe(s).is0()}toBytes(e=!0){return M(e,"isCompressed"),this.assertValidity(),f(T,this,e)}toHex(e=!0){return p(this.toBytes(e))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}get px(){return this.X}get py(){return this.X}get pz(){return this.Z}toRawBytes(e=!0){return this.toBytes(e)}_setWindowSize(e){this.precompute(e)}static normalizeZ(e){return Oe(T,e)}static msm(e,t){return function(e,t,n,r){Ve(n,e),De(r,t);const o=n.length,i=r.length;if(o!==i)throw new Error("arrays of points and scalars must have equal length");const s=e.ZERO,a=X(BigInt(o));let c=1;a>12?c=a-3:a>4?c=a-2:a>0&&(c=2);const u=Y(c),l=new Array(Number(u)+1).fill(s);let f=s;for(let h=Math.floor((t.BITS-1)/c)*c;h>=0;h-=c){l.fill(s);for(let t=0;t<i;t++){const e=r[t],o=Number(e>>BigInt(h)&u);l[o]=l[o].add(n[t])}let e=s;for(let t=l.length-1,n=s;t>0;t--)n=n.add(l[t]),e=e.add(n);if(f=f.add(e),0!==h)for(let t=0;t<c;t++)f=f.double()}return f}(T,o,e,t)}static fromPrivateKey(e){return T.BASE.multiply(Ye(o,e))}}T.BASE=new T(i.Gx,i.Gy,r.ONE),T.ZERO=new T(r.ZERO,r.ONE,r.ZERO),T.Fp=r,T.Fn=o;const z=o.BITS,A=new Me(T,t.endo?Math.ceil(z/2):z);return T.BASE.precompute(8),T}function et(e){return Uint8Array.of(e?2:3)}function tt(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function nt(e,t={}){const{Fn:n}=e,r=t.randomBytes||k,o=Object.assign(tt(e.Fp,n),{seed:ze(n.ORDER)});function i(e){try{return!!Ye(n,e)}catch(t){return!1}}function s(e=r(o.seed)){return function(e,t,n=!1){const r=e.length,o=Re(t),i=ze(t);if(r<16||r<i||r>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+r);const s=fe(n?Z(e):j(e),t-ne)+ne;return n?H(s,o):q(s,o)}(U(e,o.seed,"seed"),n.ORDER)}function a(t,r=!0){return e.BASE.multiply(Ye(n,t)).toBytes(r)}function c(t){if("bigint"==typeof t)return!1;if(t instanceof e)return!0;const{secretKey:r,publicKey:i,publicKeyUncompressed:s}=o;if(n.allowedLengths||r===i)return;const a=W("key",t).length;return a===i||a===s}const u={isValidSecretKey:i,isValidPublicKey:function(t,n){const{publicKey:r,publicKeyUncompressed:i}=o;try{const o=t.length;return(!0!==n||o===r)&&((!1!==n||o===i)&&!!e.fromBytes(t))}catch(s){return!1}},randomSecretKey:s,isValidPrivateKey:i,randomPrivateKey:s,normPrivateKeyToScalar:e=>Ye(n,e),precompute:(t=8,n=e.BASE)=>n.precompute(t,!1)};return Object.freeze({getPublicKey:a,getSharedSecret:function(t,r,o=!0){if(!0===c(t))throw new Error("first arg must be private key");if(!1===c(r))throw new Error("second arg must be public key");const i=Ye(n,t);return e.fromHex(r).multiply(i).toBytes(o)},keygen:function(e){const t=s(e);return{secretKey:t,publicKey:a(t)}},Point:e,utils:u,lengths:o})}function rt(e,t,n={}){a(t),Q(n,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});const r=n.randomBytes||k,i=n.hmac||((e,...n)=>N(t,e,R(...n))),{Fp:s,Fn:c}=e,{ORDER:u,BITS:l}=c,{keygen:f,getPublicKey:h,getSharedSecret:d,utils:m,lengths:g}=nt(e,n),y={prehash:!1,lowS:"boolean"==typeof n.lowS&&n.lowS,format:void 0,extraEntropy:!1},w="compact";function b(e){return e>u>>We}function v(e,t){if(!c.isValidNot0(t))throw new Error(`invalid signature ${e}: out of range 1..Point.Fn.ORDER`);return t}class B{constructor(e,t,n){this.r=v("r",e),this.s=v("s",t),null!=n&&(this.recovery=n),Object.freeze(this)}static fromBytes(e,t=w){let n;if(function(e,t){Le(t);const n=g.signature;U(e,"compact"===t?n:"recovered"===t?n+1:void 0,`${t} signature`)}(e,t),"der"===t){const{r:t,s:n}=qe.toSig(U(e));return new B(t,n)}"recovered"===t&&(n=e[0],t="compact",e=e.subarray(1));const r=c.BYTES,o=e.subarray(0,r),i=e.subarray(r,2*r);return new B(c.fromBytes(o),c.fromBytes(i),n)}static fromHex(e,t){return this.fromBytes(E(e),t)}addRecoveryBit(e){return new B(this.r,this.s,e)}recoverPublicKey(t){const n=s.ORDER,{r:r,s:o,recovery:i}=this;if(null==i||![0,1,2,3].includes(i))throw new Error("recovery id invalid");if(u*Je<n&&i>1)throw new Error("recovery id is ambiguous for h>1 curve");const a=2===i||3===i?r+u:r;if(!s.isValid(a))throw new Error("recovery id 2 or 3 invalid");const l=s.toBytes(a),f=e.fromBytes(R(et(!(1&i)),l)),h=c.inv(a),d=T(W("msgHash",t)),p=c.create(-d*h),m=c.create(o*h),g=e.BASE.multiplyUnsafe(p).add(f.multiplyUnsafe(m));if(g.is0())throw new Error("point at infinify");return g.assertValidity(),g}hasHighS(){return b(this.s)}toBytes(e=w){if(Le(e),"der"===e)return E(qe.hexFromSig(this));const t=c.toBytes(this.r),n=c.toBytes(this.s);if("recovered"===e){if(null==this.recovery)throw new Error("recovery bit must be present");return R(Uint8Array.of(this.recovery),t,n)}return R(t,n)}toHex(e){return p(this.toBytes(e))}assertValidity(){}static fromCompact(e){return B.fromBytes(W("sig",e),"compact")}static fromDER(e){return B.fromBytes(W("sig",e),"der")}normalizeS(){return this.hasHighS()?new B(this.r,c.neg(this.s),this.recovery):this}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return p(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return p(this.toBytes("compact"))}}const x=n.bits2int||function(e){if(e.length>8192)throw new Error("input is too large");const t=j(e),n=8*e.length-l;return n>0?t>>BigInt(n):t},T=n.bits2int_modN||function(e){return c.create(x(e))},z=Y(l);function A(e){return K("num < 2^"+l,e,He,z),c.toBytes(e)}function S(e,n){return U(e,void 0,"message"),n?U(t(e),void 0,"prehashed message"):e}return Object.freeze({keygen:f,getPublicKey:h,getSharedSecret:d,utils:m,lengths:g,Point:e,sign:function(n,o,s={}){n=W("message",n);const{seed:a,k2sig:u}=function(t,n,o){if(["recovered","canonical"].some((e=>e in o)))throw new Error("sign() legacy options not supported");const{lowS:i,prehash:s,extraEntropy:a}=je(o,y);t=S(t,s);const u=T(t),l=Ye(c,n),f=[A(l),A(u)];if(null!=a&&!1!==a){const e=!0===a?r(g.secretKey):a;f.push(W("extraEntropy",e))}const h=R(...f),d=u;return{seed:h,k2sig:function(t){const n=x(t);if(!c.isValidNot0(n))return;const r=c.inv(n),o=e.BASE.multiply(n).toAffine(),s=c.create(o.x);if(s===He)return;const a=c.create(r*c.create(d+s*l));if(a===He)return;let u=(o.x===s?0:2)|Number(o.y&We),f=a;return i&&b(a)&&(f=c.neg(a),u^=1),new B(s,f,u)}}}(n,o,s);return function(e,t,n){if("number"!=typeof e||e<2)throw new Error("hashLen must be a number");if("number"!=typeof t||t<2)throw new Error("qByteLen must be a number");if("function"!=typeof n)throw new Error("hmacFn must be a function");const r=e=>new Uint8Array(e),o=e=>Uint8Array.of(e);let i=r(e),s=r(e),a=0;const c=()=>{i.fill(1),s.fill(0),a=0},u=(...e)=>n(s,i,...e),l=(e=r(0))=>{s=u(o(0),e),i=u(),0!==e.length&&(s=u(o(1),e),i=u())},f=()=>{if(a++>=1e3)throw new Error("drbg: tried 1000 values");let e=0;const n=[];for(;e<t;){i=u();const t=i.slice();n.push(t),e+=i.length}return R(...n)};return(e,t)=>{let n;for(c(),l(e);!(n=t(f()));)l();return c(),n}}(t.outputLen,c.BYTES,i)(a,u)},verify:function(t,n,r,i={}){const{lowS:s,prehash:a,format:u}=je(i,y);if(r=W("publicKey",r),n=S(W("message",n),a),"strict"in i)throw new Error("options.strict was renamed to lowS");const l=void 0===u?function(e){let t;const n="string"==typeof e||o(e),r=!n&&null!==e&&"object"==typeof e&&"bigint"==typeof e.r&&"bigint"==typeof e.s;if(!n&&!r)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");if(r)t=new B(e.r,e.s);else if(n){try{t=B.fromBytes(W("sig",e),"der")}catch(i){if(!(i instanceof qe.Err))throw i}if(!t)try{t=B.fromBytes(W("sig",e),"compact")}catch(s){return!1}}return t||!1}(t):B.fromBytes(W("sig",t),u);if(!1===l)return!1;try{const t=e.fromBytes(r);if(s&&l.hasHighS())return!1;const{r:o,s:i}=l,a=T(n),u=c.inv(i),f=c.create(a*u),h=c.create(o*u),d=e.BASE.multiplyUnsafe(f).add(t.multiplyUnsafe(h));if(d.is0())return!1;return c.create(d.x)===o}catch(f){return!1}},recoverPublicKey:function(e,t,n={}){const{prehash:r}=je(n,y);return t=S(t,r),B.fromBytes(e,"recovered").recoverPublicKey(t).toBytes()},Signature:B,hash:t})}function ot(e){const t={a:e.a,b:e.b,p:e.Fp.ORDER,n:e.n,h:e.h,Gx:e.Gx,Gy:e.Gy},n=e.Fp;let r=e.allowedPrivateKeyLengths?Array.from(new Set(e.allowedPrivateKeyLengths.map((e=>Math.ceil(e/2))))):void 0;return{CURVE:t,curveOpts:{Fp:n,Fn:Te(t.n,{BITS:e.nBitLength,allowedLengths:r,modFromBytes:e.wrapPrivateKey}),allowInfinityPoint:e.allowInfinityPoint,endo:e.endo,isTorsionFree:e.isTorsionFree,clearCofactor:e.clearCofactor,fromBytes:e.fromBytes,toBytes:e.toBytes}}}function it(e){const{CURVE:t,curveOpts:n,hash:r,ecdsaOpts:o}=function(e){const{CURVE:t,curveOpts:n}=ot(e),r={hmac:e.hmac,randomBytes:e.randomBytes,lowS:e.lowS,bits2int:e.bits2int,bits2int_modN:e.bits2int_modN};return{CURVE:t,curveOpts:n,hash:e.hash,ecdsaOpts:r}}(e);return function(e,t){const n=t.Point;return Object.assign({},t,{ProjectivePoint:n,CURVE:Object.assign({},e,xe(n.Fn.ORDER,n.Fn.BITS))})}(e,rt(Qe(t,n),r,o))}const st={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},at={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]},ct=BigInt(2);const ut=Te(st.p,{sqrt:function(e){const t=st.p,n=BigInt(3),r=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),a=BigInt(44),c=BigInt(88),u=e*e*e%t,l=u*u*e%t,f=he(l,n,t)*l%t,h=he(f,n,t)*l%t,d=he(h,ct,t)*u%t,p=he(d,o,t)*d%t,m=he(p,i,t)*p%t,g=he(m,a,t)*m%t,y=he(g,c,t)*g%t,w=he(y,a,t)*m%t,b=he(w,n,t)*l%t,v=he(b,s,t)*p%t,B=he(v,r,t)*u%t,E=he(B,ct,t);if(!ut.eql(ut.sqr(E),e))throw new Error("Cannot find square root");return E}}),lt=function(e,t){const n=t=>it({...e,hash:t});return{...n(t),create:n}}({...st,Fp:ut,lowS:!0,endo:at},D);function ft(e,t){const n=[];for(let r=0;r<e.length;r+=t)n.push(e.subarray(r,r+t));return n}function ht(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function dt(e,t){const n=Math.min(e.length,t.length);for(let r=0;r<n;r++)if(e[r]!==t[r])return e.subarray(0,r);return e.subarray(0,n)}function pt(e){return Array.from(e).map((e=>e.toString(16).padStart(2,"0"))).join("")}function mt(e,t){const n=new Uint8Array(32);let r=e;if("LE"===t){for(let e=0;e<32;e++)n[e]=Number(0xffn&r),r>>=8n;return n}for(let o=31;o>=0;o--)n[o]=Number(0xffn&r),r>>=8n;return n}function gt(e,t){let n=0n;if("LE"===t){for(let t=31;t>=0;t--)n=n<<8n|BigInt(e[t]);return n}for(let r=0;r<32;r++)n=n<<8n|BigInt(e[r]);return n}function yt(e){const t=e.startsWith("0x")||e.startsWith("0X")?e.slice(2):e;if(t.length%2!=0||!/^[0-9a-fA-F]*$/.test(t))throw new Error(`hexToUint8Array: invalid hex string: ${e}`);const n=new Uint8Array(t.length/2);for(let r=0;r<n.length;r++)n[r]=parseInt(t.slice(2*r,2*r+2),16);return n}var wt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bt="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";function vt(e,t){const n=t.length;let r=0,o=0;const i=[];for(let s=0;s<e.length;s++){const a=e.charAt(s);if("="===a)break;const c=t.indexOf(a);if(-1===c)throw new Error(`Invalid character: ${a}`);o=o<<Math.log2(n)|c,r+=Math.log2(n),r>=8&&(r-=8,i.push(o>>r&255))}return new Uint8Array(i)}function Bt(e,t,n){const r=t.length;let o=0,i=0,s="";for(const a of e)for(i=i<<8|a,o+=8;o>=Math.log2(r);)o-=Math.log2(r),s+=t.charAt(i>>o&r-1);return o>0&&(s+=t.charAt(i<<Math.log2(r)-o&r-1)),s.length%n!=0&&(s+="=".repeat(n-s.length%n)),s}function Et(e){return Bt(e,bt,8)}function xt(e){return new Uint8Array([e])}function Tt(e){return e[0]}function Rt(e,t){return new DataView(e.buffer,e.byteOffset,e.byteLength).getUint16(0,"LE"===t)}function zt(e,t){const n=new ArrayBuffer(4);return new DataView(n).setUint32(0,e,"LE"===t),new Uint8Array(n)}function At(e,t){const n=new ArrayBuffer(8);return new DataView(n).setBigUint64(0,e,"LE"===t),new Uint8Array(n)}function kt(e,t){return new DataView(e.buffer,e.byteOffset,e.byteLength).getBigUint64(0,"LE"===t)}var St=[0,1,0,32898,2147483648,32906,2147483648,2147516416,0,32907,0,2147483649,2147483648,2147516545,2147483648,32777,0,138,0,136,0,2147516425,0,2147483658,0,2147516555,2147483648,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,0,32778,2147483648,2147483658,2147483648,2147516545,2147483648,32896,0,2147483649,2147483648,2147516424];function Ot(e){return t=function(e,t){for(const n of t){for(let t=0;t<34;t+=2)e[t]=e[t]^n[t+1],e[t+1]=e[t+1]^n[t];$t(e)}return e}(new Array(50).fill(0),function(e,t){if(!e.length){const e=new Uint8Array(136);return e[0]=t,e[135]=128,[It(e)]}const n=ft(e,136),r=n[n.length-1];if(r.length<136){const e=new Uint8Array(136);e.set(r),e[r.length]=t,e[135]=128|e[135],n[n.length-1]=e}if(136===r.length){const e=new Uint8Array(136);e[0]=t,e[135]=128,n.push(e)}return n.map(It)}(e,1)),new Uint8Array([t[1],t[1]>>-24,t[1]>>-16,t[1]>>-8,t[0],t[0]>>8,t[0]>>16,t[0]>>24,t[3],t[3]>>-24,t[3]>>-16,t[3]>>-8,t[2],t[2]>>8,t[2]>>16,t[2]>>24,t[5],t[5]>>-24,t[5]>>-16,t[5]>>-8,t[4],t[4]>>8,t[4]>>16,t[4]>>24,t[7],t[7]>>-24,t[7]>>-16,t[7]>>-8,t[6],t[6]>>8,t[6]>>16,t[6]>>24]);var t}function $t(e){for(let t=0;t<24;t++){const n=e[0]^e[10]^e[20]^e[30]^e[40],r=e[1]^e[11]^e[21]^e[31]^e[41],o=e[2]^e[12]^e[22]^e[32]^e[42],i=e[3]^e[13]^e[23]^e[33]^e[43],s=e[4]^e[14]^e[24]^e[34]^e[44],a=e[5]^e[15]^e[25]^e[35]^e[45],c=e[6]^e[16]^e[26]^e[36]^e[46],u=e[7]^e[17]^e[27]^e[37]^e[47],l=e[8]^e[18]^e[28]^e[38]^e[48],f=e[9]^e[19]^e[29]^e[39]^e[49],h=l^(o<<1|i>>>31),d=f^(i<<1|o>>>31),p=n^(s<<1|a>>>31),m=r^(a<<1|s>>>31),g=o^(c<<1|u>>>31),y=i^(u<<1|c>>>31),w=s^(l<<1|f>>>31),b=a^(f<<1|l>>>31),v=c^(n<<1|r>>>31),B=u^(r<<1|n>>>31);e[0]^=h,e[1]^=d,e[2]^=p,e[3]^=m,e[4]^=g,e[5]^=y,e[6]^=w,e[7]^=b,e[8]^=v,e[9]^=B,e[10]^=h,e[11]^=d,e[12]^=p,e[13]^=m,e[14]^=g,e[15]^=y,e[16]^=w,e[17]^=b,e[18]^=v,e[19]^=B,e[20]^=h,e[21]^=d,e[22]^=p,e[23]^=m,e[24]^=g,e[25]^=y,e[26]^=w,e[27]^=b,e[28]^=v,e[29]^=B,e[30]^=h,e[31]^=d,e[32]^=p,e[33]^=m,e[34]^=g,e[35]^=y,e[36]^=w,e[37]^=b,e[38]^=v,e[39]^=B,e[40]^=h,e[41]^=d,e[42]^=p,e[43]^=m,e[44]^=g,e[45]^=y,e[46]^=w,e[47]^=b,e[48]^=v,e[49]^=B;const E=e[0],x=e[1],T=e[2]<<1|e[3]>>>31,R=e[3]<<1|e[2]>>>31,z=e[5]<<30|e[4]>>>2,A=e[4]<<30|e[5]>>>2,k=e[6]<<28|e[7]>>>4,S=e[7]<<28|e[6]>>>4,O=e[8]<<27|e[9]>>>5,$=e[9]<<27|e[8]>>>5,I=e[11]<<4|e[10]>>>28,_=e[10]<<4|e[11]>>>28,V=e[13]<<12|e[12]>>>20,D=e[12]<<12|e[13]>>>20,P=e[14]<<6|e[15]>>>26,N=e[15]<<6|e[14]>>>26,C=e[17]<<23|e[16]>>>9,F=e[16]<<23|e[17]>>>9,M=e[18]<<20|e[19]>>>12,U=e[19]<<20|e[18]>>>12,G=e[20]<<3|e[21]>>>29,L=e[21]<<3|e[20]>>>29,j=e[22]<<10|e[23]>>>22,Z=e[23]<<10|e[22]>>>22,q=e[25]<<11|e[24]>>>21,H=e[24]<<11|e[25]>>>21,W=e[26]<<25|e[27]>>>7,J=e[27]<<25|e[26]>>>7,K=e[29]<<7|e[28]>>>25,X=e[28]<<7|e[29]>>>25,Y=e[31]<<9|e[30]>>>23,Q=e[30]<<9|e[31]>>>23,ee=e[33]<<13|e[32]>>>19,te=e[32]<<13|e[33]>>>19,ne=e[34]<<15|e[35]>>>17,re=e[35]<<15|e[34]>>>17,oe=e[36]<<21|e[37]>>>11,ie=e[37]<<21|e[36]>>>11,se=e[38]<<8|e[39]>>>24,ae=e[39]<<8|e[38]>>>24,ce=e[40]<<18|e[41]>>>14,ue=e[41]<<18|e[40]>>>14,le=e[42]<<2|e[43]>>>30,fe=e[43]<<2|e[42]>>>30,he=e[45]<<29|e[44]>>>3,de=e[44]<<29|e[45]>>>3,pe=e[47]<<24|e[46]>>>8,me=e[46]<<24|e[47]>>>8,ge=e[48]<<14|e[49]>>>18,ye=e[49]<<14|e[48]>>>18;e[0]=E^~V&q,e[1]=x^~D&H,e[2]=V^~q&oe,e[3]=D^~H&ie,e[4]=q^~oe&ge,e[5]=H^~ie&ye,e[6]=oe^~ge&E,e[7]=ie^~ye&x,e[8]=ge^~E&V,e[9]=ye^~x&D,e[10]=k^~M&G,e[11]=S^~U&L,e[12]=M^~G&ee,e[13]=U^~L&te,e[14]=G^~ee&he,e[15]=L^~te&de,e[16]=ee^~he&k,e[17]=te^~de&S,e[18]=he^~k&M,e[19]=de^~S&U,e[20]=T^~P&W,e[21]=R^~N&J,e[22]=P^~W&se,e[23]=N^~J&ae,e[24]=W^~se&ce,e[25]=J^~ae&ue,e[26]=se^~ce&T,e[27]=ae^~ue&R,e[28]=ce^~T&P,e[29]=ue^~R&N,e[30]=O^~I&j,e[31]=$^~_&Z,e[32]=I^~j&ne,e[33]=_^~Z&re,e[34]=j^~ne&pe,e[35]=Z^~re&me,e[36]=ne^~pe&O,e[37]=re^~me&$,e[38]=pe^~O&I,e[39]=me^~$&_,e[40]=z^~C&K,e[41]=A^~F&X,e[42]=C^~K&Y,e[43]=F^~X&Q,e[44]=K^~Y&le,e[45]=X^~Q&fe,e[46]=Y^~le&z,e[47]=Q^~fe&A,e[48]=le^~z&C,e[49]=fe^~A&F,e[0]^=St[2*t],e[1]^=St[2*t+1]}}function It(e){const t=[];for(let n=0;n<e.length;n+=4)t.push(e[n]|e[n+1]<<8|e[n+2]<<16|e[n+3]<<24);return t}var _t=new TextDecoder,Vt=new TextEncoder,Dt=/^(0x)?[0-9a-fA-F]*$/i;var Pt=class e{bytes;length;constructor(t,n){if(!t)throw new Error(`Bytes#constructor: constructor parameter is falsy: ${t}`);if(t instanceof e)this.bytes=t.bytes;else if("string"==typeof t){if(!Dt.test(t)||t.replace(/^0x/i,"").length%2!=0)throw new Error(`Bytes#constructor: invalid hex string: ${t}`);this.bytes=yt(t)}else if(t instanceof ArrayBuffer)this.bytes=new Uint8Array(t.slice(0));else if(t instanceof Uint8Array)this.bytes=t.slice();else{const e=t;if("object"!=typeof(r=e)||null===r||"function"!=typeof r.toHex)throw new Error("Bytes#constructor: unsupported type: "+typeof t);this.bytes=yt(e.toHex())}var r;if(this.length=this.bytes.length,void 0!==n)if(Array.isArray(n)){if(!n.includes(this.length))throw new Error(`Bytes#checkByteLength: bytes length is ${this.length} but expected ${n.join(" or ")}`)}else if(this.length!==n)throw new Error(`Bytes#checkByteLength: bytes length is ${this.length} but expected ${n}`)}static keccak256(t){return new e(Ot(new e(t).toUint8Array()))}static concat(...t){const n=t.map((t=>t instanceof e?t.toUint8Array():t)),r=n.reduce(((e,t)=>e+t.length),0),o=new Uint8Array(r);let i=0;for(const e of n)o.set(e,i),i+=e.length;return o}static fromUtf8(t){return new e(Vt.encode(t))}static fromSlice(t,n,r){return new e(void 0===r?t.slice(n):t.slice(n,n+r))}offset(e){return new Uint8Array(this.bytes.slice(e))}toUint8Array(){return new Uint8Array(this.bytes)}toHex(){return pt(this.bytes)}toBase64(){return Bt(this.bytes,wt,4)}toBase32(){return Et(this.bytes)}toString(){return this.toHex()}toUtf8(){return _t.decode(this.bytes)}parsePayloadAsJson(){return JSON.parse(this.toUtf8())}toJSON(){return this.toHex()}equals(t){return this.toHex()===new e(t).toHex()}represent(){return this.toHex()}[Symbol.for("nodejs.util.inspect.custom")](){return this.represent()}},Nt=class extends Pt{static LENGTH=32;constructor(e){super(e,32)}},Ct=0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n;function Ft(e){if(e<=0n||e>=Ct)throw new Error("Invalid private key");const t=lt.Point.BASE.multiply(e);return[t.x,t.y]}function Mt(e){const t=new Uint8Array(20),n=Ot(Pt.concat(mt(e[0],"BE"),mt(e[1],"BE")));return t.set(n.subarray(12)),t}var Ut=class extends Pt{static LENGTH=20;constructor(e){super(e,20)}toChecksum(){return function(e){const t=pt(e),n=pt(Ot(Uint8Array.from(t,(e=>e.charCodeAt(0)))));let r="0x";for(let o=0;o<t.length;o++)r+=parseInt(n.charAt(o),16)>7?t.charAt(o).toUpperCase():t.charAt(o);return r}(this.bytes)}},Gt=new Uint8Array(8).fill(255,0,8),Lt=class e extends Pt{static LENGTH=8;static MINUS_ONE=new e(Gt);constructor(e){super(e,8)}static fromBigInt(t){return new e(At(t,"BE"))}toBigInt(){return kt(this.bytes,"BE")}next(){return pt(this.bytes)===pt(Gt)?e.fromBigInt(0n):e.fromBigInt(this.toBigInt()+1n)}},jt=new TextEncoder,Zt=class e extends Pt{static LENGTH=32;constructor(e){super(e,32)}static fromString(t){return new e(Ot(jt.encode(t)))}},qt=class extends Pt{static LENGTH=32;constructor(e){super(e,32)}};function Ht(e,t){const n=lt.sign(Ot(e),t,{prehash:!1}),r=0===n.recovery?27n:28n;return[n.r,n.s,r]}function Wt(e,t,n,r){const o=27n===r?0:1,i=new lt.Signature(t,n,o).recoverPublicKey(Ot(e));return[i.x,i.y]}var Jt=class extends Pt{static LENGTH=64;constructor(e){const t=new Pt(e);if(33===t.length){const[e,n]=function(e){if(33!==e.length||2!==e[0]&&3!==e[0])throw new Error("Invalid compressed public key");const t=lt.Point.fromBytes(e);return[t.x,t.y]}(t.toUint8Array());super(Pt.concat(mt(e,"BE"),mt(n,"BE")),64)}else super(e,64)}address(){const e=gt(this.bytes.slice(0,32),"BE"),t=gt(this.bytes.slice(32,64),"BE");return new Ut(Mt([e,t]))}toCompressedUint8Array(){const e=gt(this.bytes.slice(0,32),"BE"),t=gt(this.bytes.slice(32,64),"BE");return n=[e,t],lt.Point.fromAffine({x:n[0],y:n[1]}).toBytes(!0);var n}toCompressedHex(){return pt(this.toCompressedUint8Array())}},Kt=new TextEncoder,Xt=Kt.encode("Ethereum Signed Message:\n32");function Yt(e){const t=e instanceof Uint8Array?e:Kt.encode(e);return Pt.concat(Xt,Ot(t))}var Qt=class e extends Pt{static LENGTH=65;constructor(e){super(e,65)}static fromSlice(t,n){return new e(t.slice(n,n+e.LENGTH))}recoverPublicKey(e){const t=gt(this.bytes.slice(0,32),"BE"),n=gt(this.bytes.slice(32,64),"BE"),r=BigInt(this.bytes[64]),[o,i]=Wt(Yt(e),t,n,r);return new Jt(Pt.concat(mt(o,"BE"),mt(i,"BE")))}isValid(e,t){return this.recoverPublicKey(e).address().equals(t)}},en=class extends Pt{static LENGTH=32;constructor(e){super(e,32)}publicKey(){const[e,t]=Ft(this.toBigInt());return new Jt(Pt.concat(mt(e,"BE"),mt(t,"BE")))}sign(e){const[t,n,r]=Ht(Yt(e),this.toBigInt());return new Qt(Pt.concat(mt(t,"BE"),mt(n,"BE"),new Uint8Array([Number(r)])))}toBigInt(){return gt(this.bytes,"BE")}};function tn(e){const t=vt(e.toUpperCase().slice(1),bt);const n=t[1];if(250!==n&&251!==n)throw new Error("Unknown codec");return t.slice(-32)}var nn=class e extends Pt{static LENGTH=32;constructor(e){"string"==typeof e&&e.startsWith("bah5")?super(tn(e),32):super(e,[32,64])}toCid(t){if(this.length!==e.LENGTH)throw new Error(`Reference#toCid: only 32-byte references can be encoded as a CID, got ${this.length} bytes`);return`b${Et(Pt.concat(new Uint8Array([1]),new Uint8Array(["feed"===t?251:250]),new Uint8Array([1]),new Uint8Array([27]),new Uint8Array([32]))).replace(/=+$/,"")}${this.toBase32().replace(/=+$/,"")}`.toLowerCase()}static isValid(t){try{return new e(t),!0}catch{return!1}}},rn=class e extends Pt{static LENGTH=8;constructor(e){super(e,8)}static fromBigInt(t){return new e(At(t,"LE"))}toBigInt(){return kt(this.bytes,"LE")}static fromSlice(t,n){return new e(t.slice(n,n+e.LENGTH))}},on=new TextEncoder,sn=class e extends Pt{static LENGTH=32;constructor(e){super(e,32)}static fromString(t){return new e(Ot(on.encode(t)))}},an=class extends Pt{static LENGTH=32;constructor(e){super(e,32)}},cn=class{cursor=0;buffer;constructor(e){this.buffer=e}read(e){const t=this.buffer.subarray(this.cursor,this.cursor+e);return this.cursor+=e,t}max(){return this.buffer.length-this.cursor}},un=class{cursor=0;buffer;constructor(e){this.buffer=e}write(e){const t=Math.min(this.max(),e.max());return this.buffer.set(e.read(t),this.cursor),this.cursor+=t,t}max(){return this.buffer.length-this.cursor}};function ln(e,t,n){const r=new Uint8Array(n.length),o=new Uint8Array(36);o.set(e);for(let i=0,s=0;s<n.length;i++,s+=32){const e=t+i>>>0;o[32]=255&e,o[33]=e>>>8&255,o[34]=e>>>16&255,o[35]=e>>>24&255;const a=Ot(Ot(o)),c=Math.min(s+32,n.length);for(let t=s;t<c;t++)r[t]=n[t]^a[t-s]}return r}function fn(e,t){return ln(e,128,t)}function hn(e,t){return ln(e,0,t)}var dn=4096;function pn(e){const t=e.subarray(0,8),n=function(e){if(e.length>dn)throw new Error(`payload size ${e.length} exceeds maximum chunk payload size 4096`);const t=new Uint8Array(dn);t.set(e);let n=ft(t,32);for(;n.length>1;){const e=[];for(let t=0;t<n.length;t+=2)e.push(Ot(Pt.concat(n[t],n[t+1])));n=e}return n[0]}(e.subarray(8));return new nn(Ot(Pt.concat(t,n)))}yt("dc5b20847f43d67928f49cd4f85d696b5a7617b5");var mn=Zt.LENGTH,gn=Zt.LENGTH+65,yn=gn+rn.LENGTH,wn=(new TextEncoder).encode("Ethereum Signed Message:\n32");function bn(e,t){const n=Ot(Pt.concat(e,t));return Pt.concat(wn,n)}function vn(e,t,n){const[r,o,i]=Ht(bn(e,t),n);return Pt.concat(mt(r,"BE"),mt(o,"BE"),new Uint8Array([Number(i)]))}function Bn(e,t){const n=new Zt(e),r=new Ut(t);return new nn(Ot(Pt.concat(n.toUint8Array(),r.toUint8Array())))}function En(e,t,n){const r=new Zt(t),o=vn(r.toUint8Array(),e.address.toUint8Array(),n),i=new Ut(Mt(Ft(n))),s=Bn(r,i);return{data:Pt.concat(r.toUint8Array(),o,e.data),identifier:r,signature:new Qt(o),span:e.span,payload:e.payload,address:s,owner:i}}function xn(e,t){const n=e instanceof Pt?e.toUint8Array():e,r=new nn(t),o=new Zt(Pt.fromSlice(n,0,Zt.LENGTH)),i=n.slice(mn,mn+65),s=pn(n.slice(gn)),a=new Ut(function(e,t,n){const r=gt(n.subarray(0,32),"BE"),o=gt(n.subarray(32,64),"BE"),i=BigInt(n[64]);return Mt(Wt(bn(e,t),r,o,i))}(o.toUint8Array(),s.toUint8Array(),i)),c=Bn(o,a);if(!c.equals(r))throw new Error("SOC data does not match given address");const u=rn.fromSlice(n,gn),l=Pt.fromSlice(n,yn);return{data:n,identifier:o,signature:new Qt(i),span:u,payload:l,address:c,owner:a}}function Tn(e,t){if("string"==typeof e&&(e=Pt.fromUtf8(e)),e.length<1||e.length>4096)throw new RangeError(`payload size ${e.length} exceeds limits [1, 4096]`);const n=t?"bigint"==typeof t?rn.fromBigInt(t):t:rn.fromBigInt(BigInt(e.length)),r=new Pt(e),o=Pt.concat(n.toUint8Array(),r.toUint8Array()),i={data:o,span:n,payload:r,address:pn(o),toSingleOwnerChunk:(e,t)=>En(i,e,new en(t).toBigInt())};return i}function Rn(e){const t=new Pt(e);return Tn(t.toUint8Array().slice(rn.LENGTH),rn.fromSlice(t.toUint8Array(),0))}var zn=class{span;writer;constructor(e=0n){this.span=e,this.writer=new un(new Uint8Array(4096))}build(){return Pt.concat(At(this.span,"LE"),this.writer.buffer)}hash(){return pn(this.build())}encryptedHash(e){e||(e=new Uint8Array(32),crypto.getRandomValues(e));const t=fn(e,At(this.span,"LE")),n=hn(e,this.writer.buffer);return{address:pn(Pt.concat(t,n)),key:e}}},An=class e{static NOOP=async e=>[];refSize;encrypted;maxShards;chunks;pending=[[]];onBatch;onIntermediateChunk;hasParity=[!1];promotedLeaf=[!1];pendingEntries=[];constructor(e,t,n=!1,r){this.encrypted=n,this.refSize=n?64:32,this.maxShards=t??4096/this.refSize,this.chunks=[new zn],this.onBatch=e,this.onIntermediateChunk=r}static async root(t){const n=new e(e.NOOP);return await n.append(t),n.finalize()}static async encryptedRoot(t){const n=new e(e.NOOP,void 0,!0);await n.append(t);return(await n.finalize()).encryptedHash()}async append(e,t=0,n=0n){const r=new cn(e);for(;r.max()>0;){(0===this.chunks[t].writer.max()||n&&this.chunks[t].writer.max()<e.length)&&await this.elevate(t);const o=this.chunks[t].writer.write(r);n?this.chunks[t].span+=n:this.chunks[0].span+=BigInt(o)}}async elevate(e){this.pending[e]||(this.pending[e]=[]),await this.sealParities(e);const t=this.chunks[e].span;if(e>=1&&this.onIntermediateChunk&&!this.promotedLeaf[e]&&this.onIntermediateChunk(this.chunks[e],this.hasParity[e]??!1),this.hasParity[e]=!1,this.encrypted){const{address:n,key:r}=this.chunks[e].encryptedHash(),o=new Uint8Array(64);o.set(n.toUint8Array()),o.set(r,32),this.pending[e].push({entry:{chunk:this.chunks[e],key:r},ref:o,span:t})}else this.pending[e].push({entry:{chunk:this.chunks[e]},ref:this.chunks[e].hash().toUint8Array(),span:t});this.chunks[e]=new zn,this.promotedLeaf[e]=!1,this.pending[e].length>=this.maxShards&&await this.flushBatch(e)}async sealParities(e){const t=this.pendingEntries[e];if(!t?.length)return;this.pendingEntries[e]=[];const n=await this.onBatch(t);if(n.length>0){this.hasParity[e]=!0;for(const{chunk:t}of n)this.chunks[e].writer.write(new cn(t.hash().toUint8Array()))}}async flushBatch(e){this.chunks[e+1]||(this.chunks.push(new zn),this.pending.push([]),this.hasParity.push(!1),this.promotedLeaf.push(!1));const t=this.pending[e];this.pending[e]=[];for(const{ref:n,span:r}of t)await this.append(n,e+1,r);this.pendingEntries[e+1]||(this.pendingEntries[e+1]=[]),this.pendingEntries[e+1].push(...t.map((e=>e.entry))),t.length>=this.maxShards&&await this.sealParities(e+1)}async finalize(e=0){if(this.pending[e]?.length&&await this.flushBatch(e),!this.chunks[e+1])return await this.sealParities(e),e>=1&&this.onIntermediateChunk&&!this.promotedLeaf[e]&&this.onIntermediateChunk(this.chunks[e],this.hasParity[e]??!1),this.chunks[e];const t=this.chunks[e+1].writer;return 0===t.cursor||t.max()<this.refSize?(await this.elevate(e+1),await this.flushBatch(e+1),await this.sealParities(e),this.chunks[e+1]=this.chunks[e],this.hasParity[e+1]=this.hasParity[e]??!1,this.hasParity[e]=!1,this.promotedLeaf[e+1]=0===e||(this.promotedLeaf[e]??!1),this.finalize(e+1)):(await this.elevate(e),await this.flushBatch(e),this.finalize(e+1))}},kn=[[[],[]],[[95,69,47,29,15,6,2,1],[9,8,7,6,5,4,3,2]],[[105,96,87,78,70,62,54,47,40,33,27,21,16,11,7,4,2,1],[21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4]],[[93,88,83,78,74,69,64,60,55,51,46,42,38,34,30,27,23,20,17,14,11,9,6,4,3,2,1],[31,30,29,28,27,26,25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5]],[[37,36,35,34,33,32,31,30,29,28,27,26,25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1],[89,87,86,84,83,81,80,78,76,75,73,71,70,68,66,65,63,61,59,58,56,54,52,50,48,47,45,43,40,38,36,34,31,29,26,23,19]]],Sn=[[[],[]],[[47,34,23,14,7,3,1],[9,8,7,6,5,4,3]],[[52,48,43,39,35,31,27,23,20,16,13,10,8,5,3,2,1],[21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5]],[[46,44,41,39,37,34,32,30,27,25,23,21,19,17,15,13,11,10,8,7,5,4,3,2,1],[31,30,29,28,27,26,25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,6]],[[18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1],[87,84,81,78,75,71,68,65,61,58,54,50,47,43,38,34,29,23]]];function On(e,t,n){return e<=0||e>4?0:function(e,t){const[n,r]=e;for(let o=0;o<n.length;o++)if(t>=n[o])return r[o];return 0}(n?Sn[e]:kn[e],t)}function $n(e,t,n){return t<=0||e<=0?0:On(t,e,n)/e}var In={label:"medium",value:1,errorTolerance:.01},_n={label:"strong",value:2,errorTolerance:.05},Vn={label:"insane",value:3,errorTolerance:.1},Dn={label:"paranoid",value:4,errorTolerance:.5};function Pn(){return{medium:In,strong:_n,insane:Vn,paranoid:Dn}}function Nn(e){if("string"==typeof e)switch(e.toLowerCase()){case"medium":return In;case"strong":return _n;case"insane":return Vn;case"paranoid":return Dn;default:throw new Error(`Unknown redundancy level '${e}'`)}switch(e){case 1:return In;case 2:return _n;case 3:return Vn;case 4:return Dn;default:throw new Error(`Unknown redundancy level '${e}'`)}}function Cn(e,t){if(0===t.length)throw new Error("xorCypher: key must not be empty");const n=new Uint8Array(e.length);for(let r=0;r<e.length;r++)n[r]=e[r]^t[r%t.length];return n}new Uint8Array([0,0,1,25,2,50,26,198,3,223,51,238,27,104,199,75,4,100,224,14,52,141,239,129,28,193,105,248,200,8,76,113,5,138,101,47,225,36,15,33,53,147,142,218,240,18,130,69,29,181,194,125,106,39,249,185,201,154,9,120,77,228,114,166,6,191,139,98,102,221,48,253,226,152,37,179,16,145,34,136,54,208,148,206,143,150,219,189,241,210,19,92,131,56,70,64,30,66,182,163,195,72,126,110,107,58,40,84,250,133,186,61,202,94,155,159,10,21,121,43,78,212,229,172,115,243,167,87,7,112,192,247,140,128,99,13,103,74,222,237,49,197,254,24,227,165,153,119,38,184,180,124,17,68,146,217,35,32,137,46,55,63,209,91,149,188,207,205,144,135,151,178,220,252,190,97,242,86,211,171,20,42,93,158,132,60,57,83,71,109,65,162,31,45,67,216,183,123,164,118,196,23,73,236,127,12,111,246,108,161,59,82,41,157,85,170,251,96,134,177,187,204,62,90,203,89,95,176,156,169,160,81,11,245,22,235,122,117,44,215,79,174,213,233,230,231,173,232,116,214,244,234,168,80,88,175]),new Uint8Array([1,2,4,8,16,32,64,128,29,58,116,232,205,135,19,38,76,152,45,90,180,117,234,201,143,3,6,12,24,48,96,192,157,39,78,156,37,74,148,53,106,212,181,119,238,193,159,35,70,140,5,10,20,40,80,160,93,186,105,210,185,111,222,161,95,190,97,194,153,47,94,188,101,202,137,15,30,60,120,240,253,231,211,187,107,214,177,127,254,225,223,163,91,182,113,226,217,175,67,134,17,34,68,136,13,26,52,104,208,189,103,206,129,31,62,124,248,237,199,147,59,118,236,197,151,51,102,204,133,23,46,92,184,109,218,169,79,158,33,66,132,21,42,84,168,77,154,41,82,164,85,170,73,146,57,114,228,213,183,115,230,209,191,99,198,145,63,126,252,229,215,179,123,246,241,255,227,219,171,75,150,49,98,196,149,55,110,220,165,87,174,65,130,25,50,100,200,141,7,14,28,56,112,224,221,167,83,166,81,162,89,178,121,242,249,239,195,155,43,86,172,69,138,9,18,36,72,144,61,122,244,245,247,243,251,235,203,139,11,22,44,88,176,125,250,233,207,131,27,54,108,216,173,71,142]);var Fn=new TextEncoder,Mn=new TextDecoder,Un=new Uint8Array([47]),Gn=yt("5768b3b6a7db56d21d1abff40d41cebfc83448fed8d7e9b06ec0d3b073f28f7b");function Ln(e){return function(e,t,n=0){if(0===t.length)return Math.min(n,e.length);for(let r=n;r<e.length;r++)for(let n=0;n<t.length&&e[r+n]===t[n];n++)if(n===t.length-1)return r;return-1}(e,Un)>0}function jn(e,t){const n=Math.floor(t/8),r=t%8;e[n]=e[n]|1<<r}function Zn(e,t){const n=t%8;return 1==(e[Math.floor(t/8)]>>n&1)}var qn=class e{obfuscationKey;persisted=!1;loaded=!0;selfAddress=null;targetAddress=new Uint8Array(32);metadata=null;path=new Uint8Array(0);forks=new Map;parent=null;type=null;encrypt=!1;constructor(e){e?.encrypt&&(this.encrypt=!0),e?.targetAddress?this.targetAddress=e.targetAddress:this.encrypt&&(this.targetAddress=new Uint8Array(64)),e?.selfAddress&&(this.selfAddress=e.selfAddress),e?.metadata&&(this.metadata=e.metadata),this.obfuscationKey=e?.obfuscationKey??function(){const e=new Uint8Array(32);return crypto.getRandomValues(e),e}(),e?.path&&(this.path=e.path),e?.parent&&(this.parent=e.parent),this.type=e?.type??null}get fullPath(){return Pt.concat(this.parent?.fullPath??new Uint8Array(0),this.path)}get fullPathString(){return Mn.decode(this.fullPath)}async marshal(){for(const a of this.forks.values())a.node.selfAddress||(a.node.selfAddress=(await a.node.calculateSelfAddress()).toUint8Array());const e=!ht(this.targetAddress,new Uint8Array(this.targetAddress.length));let t=0;if(e)t=this.targetAddress.length;else for(const a of this.forks.values())if(a.node.selfAddress&&a.node.selfAddress.length>0){t=a.node.selfAddress.length;break}const n=new Uint8Array(32);n.set(Gn,0),n.set(xt(t),31);const r=e?this.targetAddress:new Uint8Array(t),o=new Uint8Array(32);for(const a of this.forks.keys())jn(o,a);const i=[];for(let a=0;a<256;a++)Zn(o,a)&&i.push(this.forks.get(a).marshal());const s=Cn(Pt.concat(n,r,o,...i),this.obfuscationKey);return Pt.concat(this.obfuscationKey,s)}hydrate(t){if(!this.selfAddress)throw new Error("MantarayNode#hydrate selfAddress is not set");const n=e.unmarshalFromData(t,this.selfAddress);this.targetAddress=n.targetAddress,this.obfuscationKey=n.obfuscationKey,this.encrypt=n.encrypt,this.forks=n.forks;for(const e of this.forks.values())e.node.parent=this;this.loaded=!0}static unmarshalFromData(t,n){if(t.length<64)throw new Error("MantarayNode#unmarshalFromData data too short");const r=t.subarray(0,32),o=Cn(t.subarray(32),r),i=new cn(o);if(!ht(i.read(31),Gn.slice(0,31)))throw new Error("MantarayNode#unmarshalFromData invalid version hash");const s=Tt(i.read(1)),a=i.read(s),c=new e({selfAddress:n,targetAddress:a,obfuscationKey:r,encrypt:64===s||64===n?.length});c.persisted=!0;const u=i.read(32),l=0===s?32:s;for(let e=0;e<256;e++)if(Zn(u,e)){const t=Jn.unmarshal(i,l);c.forks.set(e,t),t.node.parent=c,t.node.persisted=!0,t.node.loaded=!1}return c}addFork(t,n,r){this.selfAddress=null,this.type=null,t=t instanceof Uint8Array?t:Fn.encode(t);let o=this;for(;t.length;){const i=t.slice(0,30),s=0===(t=t.slice(30)).length,[a,c]=o.findClosest(i),u=i.slice(c.length);if(c.length&&(o=a),!u.length){s&&(o.assertSubtreeLoaded(),o.targetAddress=new nn(n).toUint8Array(),o.metadata=r??null,o.invalidate());continue}const l=new Jn(u,new e({targetAddress:s?new nn(n).toUint8Array():void 0,metadata:s?r:void 0,path:u,encrypt:this.encrypt}));o.assertSubtreeLoaded();const f=a.forks.get(u[0]);if(f){const e=Jn.split(l,f);o.forks.set(u[0],e),e.node.parent=o}else o.forks.set(u[0],l),l.node.parent=o;o.invalidate(),o=l.node}}relocate(e){this.path=e,this.loaded?this.type=null:null!==this.type&&(this.type=-9&this.type|(Ln(e)?8:0))}assertSubtreeLoaded(){if(!this.loaded)throw new Error(`MantarayNode: forks of "${this.fullPathString}" are not loaded - load the subtree before editing it`)}invalidate(){let e=this;for(;e;)e.selfAddress=null,e.type=null,e.persisted=!1,e=e.parent}removeFork(e){if(this.selfAddress=null,this.type=null,0===(e=e instanceof Uint8Array?e:Fn.encode(e)).length)throw new Error("MantarayNode#removeFork path cannot be empty");const t=this.find(e);if(!t)throw new Error("MantarayNode#removeFork fork not found");t.assertSubtreeLoaded();const[n,r]=this.findClosest(e.slice(0,e.length-1)),o=e.slice(r.length)[0],i=t.onlyChildFittingOneFork();i?(n.forks.delete(o),n.adopt(i,Pt.concat(t.path,i.prefix))):0===t.forks.size?n.forks.delete(o):t.clearEntry(),t.invalidate(),n.invalidate()}onlyChildFittingOneFork(){if(1!==this.forks.size)return;const e=[...this.forks.values()][0];return Pt.concat(this.path,e.prefix).length<=30?e:void 0}adopt(e,t){e.prefix=t,e.node.relocate(t),e.node.parent=this,this.forks.set(t[0],e)}clearEntry(){this.targetAddress=new Uint8Array(this.targetAddress.length),this.metadata=null}async calculateSelfAddress(){if(this.selfAddress)return new nn(this.selfAddress);if(this.encrypt)throw new Error("MantarayNode#calculateSelfAddress is not supported for encrypted nodes - use saveRecursively");return(await An.root(await this.marshal())).hash()}async saveRecursively(e){for(const r of this.forks.values())r.node.persisted||await r.node.saveRecursively(e);const t=new An((async t=>{for(const{chunk:n,key:r}of t)await e(n,r);return[]}),void 0,this.encrypt);await t.append(await this.marshal());const n=await t.finalize();if(this.encrypt){const{address:t,key:r}=n.encryptedHash();return await e(n,r),this.selfAddress=Pt.concat(t.toUint8Array(),r),this.persisted=!0,{reference:this.selfAddress,rootChunk:n,encryptionKey:r}}return await e(n),this.selfAddress=n.hash().toUint8Array(),this.persisted=!0,{reference:this.selfAddress,rootChunk:n}}find(e){const t=e instanceof Uint8Array?e:Fn.encode(e),[n,r]=this.findClosest(t);return r.length===t.length?n:null}findClosest(e,t=new Uint8Array){if(0===(e=e instanceof Uint8Array?e:Fn.encode(e)).length)return[this,t];const n=this.forks.get(e[0]);return n&&dt(n.prefix,e).length===n.prefix.length?n.node.findClosest(e.slice(n.prefix.length),Pt.concat(t,n.prefix)):[this,t]}collect(e=[]){for(const t of this.forks.values())ht(t.node.targetAddress,new Uint8Array(t.node.targetAddress.length))||e.push(t.node),t.node.collect(e);return e}collectAndMap(){const e={};for(const t of this.collect())e[t.fullPathString]=new nn(t.targetAddress).toHex();return e}determineType(){let e=0;const t=new Uint8Array(this.targetAddress.length);return ht(this.targetAddress,t)&&0!==this.forks.size||(e|=2),this.forks.size>0&&(e|=4),Ln(this.path)&&(e|=8),this.metadata&&(e|=16),e}},Hn=new TextEncoder,Wn=new TextDecoder;var Jn=class e{prefix;node;constructor(e,t){this.prefix=e,this.node=t}static split(t,n){const r=dt(t.prefix,n.prefix);if(r.length===t.prefix.length){const e=n.prefix.slice(r.length);return n.node.relocate(n.prefix.slice(r.length)),n.prefix=n.prefix.slice(r.length),n.node.parent=t.node,t.node.forks.set(e[0],n),t}if(r.length===n.prefix.length){const e=t.prefix.slice(r.length);return t.node.relocate(t.prefix.slice(r.length)),t.prefix=t.prefix.slice(r.length),t.node.parent=n.node,n.node.forks.set(e[0],t),n}const o=new qn({path:r,encrypt:t.node.encrypt}),i=new e(t.prefix.slice(r.length),t.node),s=new e(n.prefix.slice(r.length),n.node);return t.node.relocate(t.prefix.slice(r.length)),n.node.relocate(n.prefix.slice(r.length)),t.prefix=t.prefix.slice(r.length),n.prefix=n.prefix.slice(r.length),o.forks.set(i.prefix[0],i),o.forks.set(s.prefix[0],s),i.node.parent=o,s.node.parent=o,new e(r,o)}marshal(){if(!this.node.selfAddress)throw new Error("Fork#marshal node.selfAddress is not set");const e=[];if(e.push(new Uint8Array([this.node.type??this.node.determineType()])),e.push(xt(this.prefix.length)),e.push(this.prefix),this.prefix.length<30&&e.push(new Uint8Array(30-this.prefix.length)),e.push(this.node.selfAddress),this.node.metadata){const t=function(e,t,n){const r=e.length%t;if(0===r)return e;const o=new Uint8Array(e.length+t-r).fill(n);return o.set(e,0),o}(Pt.concat(new Uint8Array([0,0]),Hn.encode(JSON.stringify(this.node.metadata))),32,10);t.set(function(e,t){const n=new ArrayBuffer(2);return new DataView(n).setUint16(0,e,"LE"===t),new Uint8Array(n)}(t.length-2,"BE"),0),e.push(t)}return Pt.concat(...e)}static unmarshal(t,n){const r=Tt(t.read(1)),o=Tt(t.read(1)),i=t.read(o);o<30&&t.read(30-o);const s=t.read(n);let a;if(function(e,t){return(e&t)===t}(r,16)){const e=Rt(t.read(2),"BE");if(e>t.max())throw new Error("Fork#unmarshal not enough bytes for metadata");a=JSON.parse(Wn.decode(t.read(e)))}return new e(i,new qn({selfAddress:s,metadata:a,path:i,type:r,encrypt:64===n}))}};function Kn(e,t,n){return e/Math.pow(2,t-n)}function Xn(e){return 4096*2**e}var Yn=.9;function Qn(e){const t=e.match(/^([\d.]+)\s*(B|kB|MB|GB|TB|PB)$/);if(!t)throw new Error(`Invalid size format: ${e}`);return Math.ceil(parseFloat(t[1])*{B:1,kB:1e3,MB:1e6,GB:1e3**3,TB:1e3**4,PB:1e3**5}[t[2]])}var er=[[17,"0.00004089 GB"],[18,"0.00609 GB"],[19,"0.10249 GB"],[20,"0.62891 GB"],[21,"2.38 GB"],[22,"7.07 GB"],[23,"18.24 GB"],[24,"43.04 GB"],[25,"96.5 GB"],[26,"208.52 GB"],[27,"435.98 GB"],[28,"908.81 GB"],[29,"1870 GB"],[30,"3810 GB"],[31,"7730 GB"],[32,"15610 GB"],[33,"31430 GB"],[34,"63150 GB"]],tr=[[[17,"44.70 kB"],[18,"6.66 MB"],[19,"112.06 MB"],[20,"687.62 MB"],[21,"2.60 GB"],[22,"7.73 GB"],[23,"19.94 GB"],[24,"47.06 GB"],[25,"105.51 GB"],[26,"227.98 GB"],[27,"476.68 GB"],[28,"993.65 GB"],[29,"2.04 TB"],[30,"4.17 TB"],[31,"8.45 TB"],[32,"17.07 TB"],[33,"34.36 TB"],[34,"69.04 TB"],[35,"138.54 TB"],[36,"277.72 TB"],[37,"556.35 TB"],[38,"1.11 PB"],[39,"2.23 PB"],[40,"4.46 PB"],[41,"8.93 PB"]],[[17,"41.56 kB"],[18,"6.19 MB"],[19,"104.18 MB"],[20,"639.27 MB"],[21,"2.41 GB"],[22,"7.18 GB"],[23,"18.54 GB"],[24,"43.75 GB"],[25,"98.09 GB"],[26,"211.95 GB"],[27,"443.16 GB"],[28,"923.78 GB"],[29,"1.90 TB"],[30,"3.88 TB"],[31,"7.86 TB"],[32,"15.87 TB"],[33,"31.94 TB"],[34,"64.19 TB"],[35,"128.80 TB"],[36,"258.19 TB"],[37,"517.23 TB"],[38,"1.04 PB"],[39,"2.07 PB"],[40,"4.15 PB"],[41,"8.30 PB"]],[[17,"37.37 kB"],[18,"5.57 MB"],[19,"93.68 MB"],[20,"574.81 MB"],[21,"2.17 GB"],[22,"6.46 GB"],[23,"16.67 GB"],[24,"39.34 GB"],[25,"88.20 GB"],[26,"190.58 GB"],[27,"398.47 GB"],[28,"830.63 GB"],[29,"1.71 TB"],[30,"3.49 TB"],[31,"7.07 TB"],[32,"14.27 TB"],[33,"28.72 TB"],[34,"57.71 TB"],[35,"115.81 TB"],[36,"232.16 TB"],[37,"465.07 TB"],[38,"931.23 TB"],[39,"1.86 PB"],[40,"3.73 PB"],[41,"7.46 PB"]],[[17,"33.88 kB"],[18,"5.05 MB"],[19,"84.92 MB"],[20,"521.09 MB"],[21,"1.97 GB"],[22,"5.86 GB"],[23,"15.11 GB"],[24,"35.66 GB"],[25,"79.96 GB"],[26,"172.77 GB"],[27,"361.23 GB"],[28,"753.00 GB"],[29,"1.55 TB"],[30,"3.16 TB"],[31,"6.41 TB"],[32,"12.93 TB"],[33,"26.04 TB"],[34,"52.32 TB"],[35,"104.99 TB"],[36,"210.46 TB"],[37,"421.61 TB"],[38,"844.20 TB"],[39,"1.69 PB"],[40,"3.38 PB"],[41,"6.77 PB"]],[[17,"13.27 kB"],[18,"1.98 MB"],[19,"33.27 MB"],[20,"204.14 MB"],[21,"771.13 MB"],[22,"2.29 GB"],[23,"5.92 GB"],[24,"13.97 GB"],[25,"31.32 GB"],[26,"67.68 GB"],[27,"141.51 GB"],[28,"294.99 GB"],[29,"606.90 GB"],[30,"1.24 TB"],[31,"2.51 TB"],[32,"5.07 TB"],[33,"10.20 TB"],[34,"20.50 TB"],[35,"41.13 TB"],[36,"82.45 TB"],[37,"165.17 TB"],[38,"330.72 TB"],[39,"661.97 TB"],[40,"1.32 PB"],[41,"2.65 PB"]]],nr=[[[17,"44.35 kB"],[18,"6.61 MB"],[19,"111.18 MB"],[20,"682.21 MB"],[21,"2.58 GB"],[22,"7.67 GB"],[23,"19.78 GB"],[24,"46.69 GB"],[25,"104.68 GB"],[26,"226.19 GB"],[27,"472.93 GB"],[28,"985.83 GB"],[29,"2.03 TB"],[30,"4.14 TB"],[31,"8.39 TB"],[32,"16.93 TB"],[33,"34.09 TB"],[34,"68.50 TB"],[35,"137.45 TB"],[36,"275.53 TB"],[37,"551.97 TB"],[38,"1.11 PB"],[39,"2.21 PB"],[40,"4.43 PB"],[41,"8.86 PB"]],[[17,"40.89 kB"],[18,"6.09 MB"],[19,"102.49 MB"],[20,"628.91 MB"],[21,"2.38 GB"],[22,"7.07 GB"],[23,"18.24 GB"],[24,"43.04 GB"],[25,"96.50 GB"],[26,"208.52 GB"],[27,"435.98 GB"],[28,"908.81 GB"],[29,"1.87 TB"],[30,"3.81 TB"],[31,"7.73 TB"],[32,"15.61 TB"],[33,"31.43 TB"],[34,"63.15 TB"],[35,"126.71 TB"],[36,"254.01 TB"],[37,"508.85 TB"],[38,"1.02 PB"],[39,"2.04 PB"],[40,"4.08 PB"],[41,"8.17 PB"]],[[17,"36.73 kB"],[18,"5.47 MB"],[19,"92.07 MB"],[20,"564.95 MB"],[21,"2.13 GB"],[22,"6.35 GB"],[23,"16.38 GB"],[24,"38.66 GB"],[25,"86.69 GB"],[26,"187.31 GB"],[27,"391.64 GB"],[28,"816.39 GB"],[29,"1.68 TB"],[30,"3.43 TB"],[31,"6.94 TB"],[32,"14.02 TB"],[33,"28.23 TB"],[34,"56.72 TB"],[35,"113.82 TB"],[36,"228.18 TB"],[37,"457.10 TB"],[38,"915.26 TB"],[39,"1.83 PB"],[40,"3.67 PB"],[41,"7.34 PB"]],[[17,"33.26 kB"],[18,"4.96 MB"],[19,"83.38 MB"],[20,"511.65 MB"],[21,"1.93 GB"],[22,"5.75 GB"],[23,"14.84 GB"],[24,"35.02 GB"],[25,"78.51 GB"],[26,"169.64 GB"],[27,"354.69 GB"],[28,"739.37 GB"],[29,"1.52 TB"],[30,"3.10 TB"],[31,"6.29 TB"],[32,"12.70 TB"],[33,"25.57 TB"],[34,"51.37 TB"],[35,"103.08 TB"],[36,"206.65 TB"],[37,"413.98 TB"],[38,"828.91 TB"],[39,"1.66 PB"],[40,"3.32 PB"],[41,"6.64 PB"]],[[17,"13.17 kB"],[18,"1.96 MB"],[19,"33.01 MB"],[20,"202.53 MB"],[21,"765.05 MB"],[22,"2.28 GB"],[23,"5.87 GB"],[24,"13.86 GB"],[25,"31.08 GB"],[26,"67.15 GB"],[27,"140.40 GB"],[28,"292.67 GB"],[29,"602.12 GB"],[30,"1.23 TB"],[31,"2.49 TB"],[32,"5.03 TB"],[33,"10.12 TB"],[34,"20.34 TB"],[35,"40.80 TB"],[36,"81.80 TB"],[37,"163.87 TB"],[38,"328.11 TB"],[39,"656.76 TB"],[40,"1.31 PB"],[41,"2.63 PB"]]];function rr(e,t,n){if(e<17)return 0;if(void 0!==t&&void 0!==n){const r=(t?nr:tr)[n],o=r?.find((([t])=>t===e));if(o)return Qn(o[1])}else{const t=er.find((([t])=>t===e));if(t)return Qn(t[1])}return Math.ceil(Xn(e)*Yn)}function or(e,t){const n=new Map;for(let r=17;r<35;r++)n.set(r,rr(r,e,t));return n}function ir(e){return function(e,t,n,r){if(65!==e.length)throw new Error("invalid signature length");if(32!==t.length)throw new Error("invalid batch ID length");if(8!==n.length)throw new Error("invalid timestamp length");if(8!==r.length)throw new Error("invalid index length");return new Pt(Pt.concat(t,r,n,e))}(e.signature.toUint8Array(),e.batchId.toUint8Array(),e.timestamp,e.index)}var sr,ar=class e{signer;batchId;buckets;depth;maxSlot;constructor(e,t,n,r){if(!Number.isInteger(r)||r<=16)throw new Error(`Stamper#constructor depth must be an integer above 16, got ${r}`);this.signer=e,this.batchId=t,this.buckets=n,this.depth=r,this.maxSlot=2**(r-16)}static fromBlank(t,n,r){return new e(new en(t),new Nt(n),new Uint32Array(65536),r)}static fromState(t,n,r,o){return new e(new en(t),new Nt(n),r,o)}stamp(e,t){const n=Rt(e,"BE"),r=this.buckets[n];if(r>=this.maxSlot)throw new Error("Stamper#stamp bucket is full");return this.buckets[n]=r+1,function(e,t,n,r,o=Date.now()){const i=new en(e),s=new Nt(t),a=Rt(n,"BE"),c=Pt.concat(zt(a,"BE"),zt(r,"BE")),u=At(1000000n*BigInt(o),"BE"),l=i.sign(Pt.concat(n,s.toUint8Array(),c,u));return{batchId:s,index:c,issuer:i.publicKey().address(),signature:l,timestamp:u}}(this.signer,this.batchId,e,r,t)}getState(){return this.buckets}},cr=n(20);function ur(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,"_zod",{value:{def:r,constr:s,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);const o=s.prototype,i=Object.keys(o);for(let e=0;e<i.length;e++){const t=i[e];t in n||(n[t]=o[t].bind(n))}}const o=n?.Parent??Object;class i extends o{}function s(e){var t;const o=n?.Parent?new i:this;r(o,e),(t=o._zod).deferred??(t.deferred=[]);for(const n of o._zod.deferred)n();return o}return Object.defineProperty(i,"name",{value:e}),Object.defineProperty(s,"init",{value:r}),Object.defineProperty(s,Symbol.hasInstance,{value:t=>!!(n?.Parent&&t instanceof n.Parent)||t?._zod?.traits?.has(e)}),Object.defineProperty(s,"name",{value:e}),s}Symbol("zod_brand");class lr extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class fr extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}}(sr=globalThis).__zod_globalConfig??(sr.__zod_globalConfig={});const hr=globalThis.__zod_globalConfig;function dr(e){return e&&Object.assign(hr,e),hr}const pr=/^[cC][0-9a-z]{6,}$/,mr=/^[0-9a-z]+$/,gr=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,yr=/^[0-9a-vA-V]{20}$/,wr=/^[A-Za-z0-9]{27}$/,br=/^[a-zA-Z0-9_-]{21}$/,vr=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Br=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Er=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,xr=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;const Tr=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Rr=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,zr=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Ar=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,kr=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Sr=/^[A-Za-z0-9_-]*$/,Or=/^https?$/,$r=/^\+[1-9]\d{6,14}$/,Ir="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",_r=new RegExp(`^${Ir}$`);function Vr(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return"number"==typeof e.precision?-1===e.precision?`${t}`:0===e.precision?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}const Dr=/^-?\d+n?$/,Pr=/^-?\d+$/,Nr=/^-?\d+(?:\.\d+)?$/,Cr=/^(?:true|false)$/i,Fr=/^[^A-Z]*$/,Mr=/^[^a-z]*$/;function Ur(e){const t=Object.values(e).filter((e=>"number"==typeof e));return Object.entries(e).filter((([e,n])=>-1===t.indexOf(+e))).map((([e,t])=>t))}function Gr(e,t){return"bigint"==typeof t?t.toString():t}function Lr(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function jr(e){return null==e}function Zr(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}const qr=Symbol("evaluating");function Hr(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==qr)return void 0===r&&(r=qr,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function Wr(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Jr(...e){const t={};for(const n of e){const e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function Kr(e){return JSON.stringify(e)}const Xr="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Yr(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}const Qr=Lr((()=>{if(hr.jitless)return!1;if("undefined"!=typeof navigator&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}}));function eo(e){if(!1===Yr(e))return!1;const t=e.constructor;if(void 0===t)return!0;if("function"!=typeof t)return!0;const n=t.prototype;return!1!==Yr(n)&&!1!==Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")}function to(e){return eo(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const no=new Set(["string","number","symbol"]);function ro(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function oo(e,t,n){const r=new e._zod.constr(t??e._zod.def);return t&&!n?.parent||(r._zod.parent=e),r}function io(e){const t=e;if(!t)return{};if("string"==typeof t)return{error:()=>t};if(void 0!==t?.message){if(void 0!==t?.error)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,"string"==typeof t.error?{...t,error:()=>t.error}:t}const so={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function ao(e,t=0){if(!0===e.aborted)return!0;for(let n=t;n<e.issues.length;n++)if(!0!==e.issues[n]?.continue)return!0;return!1}function co(e,t=0){if(!0===e.aborted)return!0;for(let n=t;n<e.issues.length;n++)if(!1===e.issues[n]?.continue)return!0;return!1}function uo(e,t){return t.map((t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t}))}function lo(e){return"string"==typeof e?e:e?.message}function fo(e,t,n){const r=e.message?e.message:lo(e.inst?._zod.def?.error?.(e))??lo(t?.error?.(e))??lo(n.customError?.(e))??lo(n.localeError?.(e))??"Invalid input",{inst:o,continue:i,input:s,...a}=e;return a.path??(a.path=[]),a.message=r,t?.reportInput&&(a.input=s),a}function ho(e){return Array.isArray(e)?"array":"string"==typeof e?"string":"unknown"}function po(...e){const[t,n,r]=e;return"string"==typeof t?{message:t,code:"custom",input:n,inst:r}:{...t}}const mo=ur("$ZodCheck",((e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])})),go={number:"number",bigint:"bigint",object:"date"},yo=ur("$ZodCheckLessThan",((e,t)=>{mo.init(e,t);const n=go[typeof t.value];e._zod.onattach.push((e=>{const n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)})),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:"too_big",maximum:"object"==typeof t.value?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}})),wo=ur("$ZodCheckGreaterThan",((e,t)=>{mo.init(e,t);const n=go[typeof t.value];e._zod.onattach.push((e=>{const n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)})),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:"too_small",minimum:"object"==typeof t.value?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}})),bo=ur("$ZodCheckMultipleOf",((e,t)=>{mo.init(e,t),e._zod.onattach.push((e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)})),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");("bigint"==typeof n.value?n.value%t.value===BigInt(0):0===function(e,t){const n=e/t,r=Math.round(n),o=Number.EPSILON*Math.max(Math.abs(n),1);return Math.abs(n-r)<o?0:n-r}(n.value,t.value))||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}})),vo=ur("$ZodCheckNumberFormat",((e,t)=>{mo.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),r=n?"int":"number",[o,i]=so[t.format];e._zod.onattach.push((e=>{const r=e._zod.bag;r.format=t.format,r.minimum=o,r.maximum=i,n&&(r.pattern=Pr)})),e._zod.check=s=>{const a=s.value;if(n){if(!Number.isInteger(a))return void s.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});if(!Number.isSafeInteger(a))return void(a>0?s.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort}):s.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort}))}a<o&&s.issues.push({origin:"number",input:a,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),a>i&&s.issues.push({origin:"number",input:a,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}})),Bo=ur("$ZodCheckMaxLength",((e,t)=>{var n;mo.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!jr(t)&&void 0!==t.length}),e._zod.onattach.push((e=>{const n=e._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<n&&(e._zod.bag.maximum=t.maximum)})),e._zod.check=n=>{const r=n.value;if(r.length<=t.maximum)return;const o=ho(r);n.issues.push({origin:o,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}})),Eo=ur("$ZodCheckMinLength",((e,t)=>{var n;mo.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!jr(t)&&void 0!==t.length}),e._zod.onattach.push((e=>{const n=e._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>n&&(e._zod.bag.minimum=t.minimum)})),e._zod.check=n=>{const r=n.value;if(r.length>=t.minimum)return;const o=ho(r);n.issues.push({origin:o,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}})),xo=ur("$ZodCheckLengthEquals",((e,t)=>{var n;mo.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!jr(t)&&void 0!==t.length}),e._zod.onattach.push((e=>{const n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length})),e._zod.check=n=>{const r=n.value,o=r.length;if(o===t.length)return;const i=ho(r),s=o>t.length;n.issues.push({origin:i,...s?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}})),To=ur("$ZodCheckStringFormat",((e,t)=>{var n,r;mo.init(e,t),e._zod.onattach.push((e=>{const n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??(n.patterns=new Set),n.patterns.add(t.pattern))})),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:"string",code:"invalid_format",format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})})),Ro=ur("$ZodCheckRegex",((e,t)=>{To.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}})),zo=ur("$ZodCheckLowerCase",((e,t)=>{t.pattern??(t.pattern=Fr),To.init(e,t)})),Ao=ur("$ZodCheckUpperCase",((e,t)=>{t.pattern??(t.pattern=Mr),To.init(e,t)})),ko=ur("$ZodCheckIncludes",((e,t)=>{mo.init(e,t);const n=ro(t.includes),r=new RegExp("number"==typeof t.position?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push((e=>{const t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(r)})),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:n.value,inst:e,continue:!t.abort})}})),So=ur("$ZodCheckStartsWith",((e,t)=>{mo.init(e,t);const n=new RegExp(`^${ro(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push((e=>{const t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(n)})),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}})),Oo=ur("$ZodCheckEndsWith",((e,t)=>{mo.init(e,t);const n=new RegExp(`.*${ro(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push((e=>{const t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(n)})),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}));const $o=ur("$ZodCheckOverwrite",((e,t)=>{mo.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}));class Io{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if("function"==typeof e)return e(this,{execution:"sync"}),void e(this,{execution:"async"});const t=e.split("\n").filter((e=>e)),n=Math.min(...t.map((e=>e.length-e.trimStart().length))),r=t.map((e=>e.slice(n))).map((e=>" ".repeat(2*this.indent)+e));for(const o of r)this.content.push(o)}compile(){const e=Function,t=this?.args;return new e(...t,[...(this?.content??[""]).map((e=>` ${e}`))].join("\n"))}}const _o=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,Gr,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Vo=ur("$ZodError",_o),Do=ur("$ZodError",_o,{Parent:Error});const Po=e=>(t,n,r,o)=>{const i=r?{...r,async:!1}:{async:!1},s=t._zod.run({value:n,issues:[]},i);if(s instanceof Promise)throw new lr;if(s.issues.length){const t=new(o?.Err??e)(s.issues.map((e=>fo(e,i,dr()))));throw Xr(t,o?.callee),t}return s.value},No=Po(Do),Co=e=>async(t,n,r,o)=>{const i=r?{...r,async:!0}:{async:!0};let s=t._zod.run({value:n,issues:[]},i);if(s instanceof Promise&&(s=await s),s.issues.length){const t=new(o?.Err??e)(s.issues.map((e=>fo(e,i,dr()))));throw Xr(t,o?.callee),t}return s.value},Fo=Co(Do),Mo=e=>(t,n,r)=>{const o=r?{...r,async:!1}:{async:!1},i=t._zod.run({value:n,issues:[]},o);if(i instanceof Promise)throw new lr;return i.issues.length?{success:!1,error:new(e??Vo)(i.issues.map((e=>fo(e,o,dr()))))}:{success:!0,data:i.value}},Uo=Mo(Do),Go=e=>async(t,n,r)=>{const o=r?{...r,async:!0}:{async:!0};let i=t._zod.run({value:n,issues:[]},o);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map((e=>fo(e,o,dr()))))}:{success:!0,data:i.value}},Lo=Go(Do),jo=e=>(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return Po(e)(t,n,o)},Zo=e=>(t,n,r)=>Po(e)(t,n,r),qo=e=>async(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return Co(e)(t,n,o)},Ho=e=>async(t,n,r)=>Co(e)(t,n,r),Wo=e=>(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return Mo(e)(t,n,o)},Jo=e=>(t,n,r)=>Mo(e)(t,n,r),Ko=e=>async(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return Go(e)(t,n,o)},Xo=e=>async(t,n,r)=>Go(e)(t,n,r),Yo={major:4,minor:4,patch:3};const Qo=ur("$ZodType",((e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Yo;const r=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&r.unshift(e);for(const o of r)for(const t of o._zod.onattach)t(e);if(0===r.length)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push((()=>{e._zod.run=e._zod.parse}));else{const t=(e,t,n)=>{let r,o=ao(e);for(const i of t){if(i._zod.def.when){if(co(e))continue;if(!i._zod.def.when(e))continue}else if(o)continue;const t=e.issues.length,s=i._zod.check(e);if(s instanceof Promise&&!1===n?.async)throw new lr;if(r||s instanceof Promise)r=(r??Promise.resolve()).then((async()=>{await s;e.issues.length!==t&&(o||(o=ao(e,t)))}));else{if(e.issues.length===t)continue;o||(o=ao(e,t))}}return r?r.then((()=>e)):e},n=(n,o,i)=>{if(ao(n))return n.aborted=!0,n;const s=t(o,r,i);if(s instanceof Promise){if(!1===i.async)throw new lr;return s.then((t=>e._zod.parse(t,i)))}return e._zod.parse(s,i)};e._zod.run=(o,i)=>{if(i.skipChecks)return e._zod.parse(o,i);if("backward"===i.direction){const t=e._zod.parse({value:o.value,issues:[]},{...i,skipChecks:!0});return t instanceof Promise?t.then((e=>n(e,o,i))):n(t,o,i)}const s=e._zod.parse(o,i);if(s instanceof Promise){if(!1===i.async)throw new lr;return s.then((e=>t(e,r,i)))}return t(s,r,i)}}Hr(e,"~standard",(()=>({validate:t=>{try{const n=Uo(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch(n){return Lo(e,t).then((e=>e.success?{value:e.data}:{issues:e.error?.issues}))}},vendor:"zod",version:1})))})),ei=ur("$ZodString",((e,t)=>{var n;Qo.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??(n=e._zod.bag,new RegExp(`^${n?`[\\s\\S]{${n?.minimum??0},${n?.maximum??""}}`:"[\\s\\S]*"}$`)),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch(r){}return"string"==typeof n.value||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}})),ti=ur("$ZodStringFormat",((e,t)=>{To.init(e,t),ei.init(e,t)})),ni=ur("$ZodGUID",((e,t)=>{t.pattern??(t.pattern=Br),ti.init(e,t)})),ri=ur("$ZodUUID",((e,t)=>{if(t.version){const e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(void 0===e)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Er(e))}else t.pattern??(t.pattern=Er());ti.init(e,t)})),oi=ur("$ZodEmail",((e,t)=>{t.pattern??(t.pattern=xr),ti.init(e,t)})),ii=ur("$ZodURL",((e,t)=>{ti.init(e,t),e._zod.check=n=>{try{const r=n.value.trim();if(!t.normalize&&t.protocol?.source===Or.source&&!/^https?:\/\//i.test(r))return void n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});const o=new URL(r);return t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(o.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),void(t.normalize?n.value=o.href:n.value=r)}catch(r){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}})),si=ur("$ZodEmoji",((e,t)=>{t.pattern??(t.pattern=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),ti.init(e,t)})),ai=ur("$ZodNanoID",((e,t)=>{t.pattern??(t.pattern=br),ti.init(e,t)})),ci=ur("$ZodCUID",((e,t)=>{t.pattern??(t.pattern=pr),ti.init(e,t)})),ui=ur("$ZodCUID2",((e,t)=>{t.pattern??(t.pattern=mr),ti.init(e,t)})),li=ur("$ZodULID",((e,t)=>{t.pattern??(t.pattern=gr),ti.init(e,t)})),fi=ur("$ZodXID",((e,t)=>{t.pattern??(t.pattern=yr),ti.init(e,t)})),hi=ur("$ZodKSUID",((e,t)=>{t.pattern??(t.pattern=wr),ti.init(e,t)})),di=ur("$ZodISODateTime",((e,t)=>{t.pattern??(t.pattern=function(e){const t=Vr({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${t}(?:${n.join("|")})`;return new RegExp(`^${Ir}T(?:${r})$`)}(t)),ti.init(e,t)})),pi=ur("$ZodISODate",((e,t)=>{t.pattern??(t.pattern=_r),ti.init(e,t)})),mi=ur("$ZodISOTime",((e,t)=>{t.pattern??(t.pattern=new RegExp(`^${Vr(t)}$`)),ti.init(e,t)})),gi=ur("$ZodISODuration",((e,t)=>{t.pattern??(t.pattern=vr),ti.init(e,t)})),yi=ur("$ZodIPv4",((e,t)=>{t.pattern??(t.pattern=Tr),ti.init(e,t),e._zod.bag.format="ipv4"})),wi=ur("$ZodIPv6",((e,t)=>{t.pattern??(t.pattern=Rr),ti.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}})),bi=ur("$ZodCIDRv4",((e,t)=>{t.pattern??(t.pattern=zr),ti.init(e,t)})),vi=ur("$ZodCIDRv6",((e,t)=>{t.pattern??(t.pattern=Ar),ti.init(e,t),e._zod.check=n=>{const r=n.value.split("/");try{if(2!==r.length)throw new Error;const[e,t]=r;if(!t)throw new Error;const n=Number(t);if(`${n}`!==t)throw new Error;if(n<0||n>128)throw new Error;new URL(`http://[${e}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}}));function Bi(e){if(""===e)return!0;if(/\s/.test(e))return!1;if(e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}const Ei=ur("$ZodBase64",((e,t)=>{t.pattern??(t.pattern=kr),ti.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{Bi(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}}));const xi=ur("$ZodBase64URL",((e,t)=>{t.pattern??(t.pattern=Sr),ti.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{(function(e){if(!Sr.test(e))return!1;const t=e.replace(/[-_]/g,(e=>"-"===e?"+":"/"));return Bi(t.padEnd(4*Math.ceil(t.length/4),"="))})(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}})),Ti=ur("$ZodE164",((e,t)=>{t.pattern??(t.pattern=$r),ti.init(e,t)}));const Ri=ur("$ZodJWT",((e,t)=>{ti.init(e,t),e._zod.check=n=>{(function(e,t=null){try{const n=e.split(".");if(3!==n.length)return!1;const[r]=n;if(!r)return!1;const o=JSON.parse(atob(r));return!("typ"in o&&"JWT"!==o?.typ||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}})(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}})),zi=ur("$ZodNumber",((e,t)=>{Qo.init(e,t),e._zod.pattern=e._zod.bag.pattern??Nr,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch(s){}const o=n.value;if("number"==typeof o&&!Number.isNaN(o)&&Number.isFinite(o))return n;const i="number"==typeof o?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...i?{received:i}:{}}),n}})),Ai=ur("$ZodNumberFormat",((e,t)=>{vo.init(e,t),zi.init(e,t)})),ki=ur("$ZodBoolean",((e,t)=>{Qo.init(e,t),e._zod.pattern=Cr,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Boolean(n.value)}catch(i){}const o=n.value;return"boolean"==typeof o||n.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),n}})),Si=ur("$ZodBigInt",((e,t)=>{Qo.init(e,t),e._zod.pattern=Dr,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=BigInt(n.value)}catch(o){}return"bigint"==typeof n.value||n.issues.push({expected:"bigint",code:"invalid_type",input:n.value,inst:e}),n}})),Oi=ur("$ZodAny",((e,t)=>{Qo.init(e,t),e._zod.parse=e=>e})),$i=ur("$ZodUnknown",((e,t)=>{Qo.init(e,t),e._zod.parse=e=>e})),Ii=ur("$ZodNever",((e,t)=>{Qo.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:e}),t)}));function _i(e,t,n){e.issues.length&&t.issues.push(...uo(n,e.issues)),t.value[n]=e.value}const Vi=ur("$ZodArray",((e,t)=>{Qo.init(e,t),e._zod.parse=(n,r)=>{const o=n.value;if(!Array.isArray(o))return n.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),n;n.value=Array(o.length);const i=[];for(let e=0;e<o.length;e++){const s=o[e],a=t.element._zod.run({value:s,issues:[]},r);a instanceof Promise?i.push(a.then((t=>_i(t,n,e)))):_i(a,n,e)}return i.length?Promise.all(i).then((()=>n)):n}}));function Di(e,t,n,r,o,i){const s=n in r;if(e.issues.length){if(o&&i&&!s)return;t.issues.push(...uo(n,e.issues))}s||o?void 0===e.value?s&&(t.value[n]=void 0):t.value[n]=e.value:e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]})}function Pi(e){const t=Object.keys(e.shape);for(const o of t)if(!e.shape?.[o]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${o}": expected a Zod schema`);const n=(r=e.shape,Object.keys(r).filter((e=>"optional"===r[e]._zod.optin&&"optional"===r[e]._zod.optout)));var r;return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function Ni(e,t,n,r,o,i){const s=[],a=o.keySet,c=o.catchall._zod,u=c.def.type,l="optional"===c.optin,f="optional"===c.optout;for(const h in t){if("__proto__"===h)continue;if(a.has(h))continue;if("never"===u){s.push(h);continue}const o=c.run({value:t[h],issues:[]},r);o instanceof Promise?e.push(o.then((e=>Di(e,n,h,t,l,f)))):Di(o,n,h,t,l,f)}return s.length&&n.issues.push({code:"unrecognized_keys",keys:s,input:t,inst:i}),e.length?Promise.all(e).then((()=>n)):n}const Ci=ur("$ZodObject",((e,t)=>{Qo.init(e,t);const n=Object.getOwnPropertyDescriptor(t,"shape");if(!n?.get){const e=t.shape;Object.defineProperty(t,"shape",{get:()=>{const n={...e};return Object.defineProperty(t,"shape",{value:n}),n}})}const r=Lr((()=>Pi(t)));Hr(e._zod,"propValues",(()=>{const e=t.shape,n={};for(const t in e){const r=e[t]._zod;if(r.values){n[t]??(n[t]=new Set);for(const e of r.values)n[t].add(e)}}return n}));const o=Yr,i=t.catchall;let s;e._zod.parse=(t,n)=>{s??(s=r.value);const a=t.value;if(!o(a))return t.issues.push({expected:"object",code:"invalid_type",input:a,inst:e}),t;t.value={};const c=[],u=s.shape;for(const e of s.keys){const r=u[e],o="optional"===r._zod.optin,i="optional"===r._zod.optout,s=r._zod.run({value:a[e],issues:[]},n);s instanceof Promise?c.push(s.then((n=>Di(n,t,e,a,o,i)))):Di(s,t,e,a,o,i)}return i?Ni(c,a,t,n,r.value,e):c.length?Promise.all(c).then((()=>t)):t}})),Fi=ur("$ZodObjectJIT",((e,t)=>{Ci.init(e,t);const n=e._zod.parse,r=Lr((()=>Pi(t)));let o;const i=Yr,s=!hr.jitless,a=s&&Qr.value,c=t.catchall;let u;e._zod.parse=(l,f)=>{u??(u=r.value);const h=l.value;return i(h)?s&&a&&!1===f?.async&&!0!==f.jitless?(o||(o=(e=>{const t=new Io(["shape","payload","ctx"]),n=r.value,o=e=>{const t=Kr(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write("const input = payload.value;");const i=Object.create(null);let s=0;for(const r of n.keys)i[r]="key_"+s++;t.write("const newResult = {};");for(const r of n.keys){const n=i[r],s=Kr(r),a=e[r],c="optional"===a?._zod?.optin,u="optional"===a?._zod?.optout;t.write(`const ${n} = ${o(r)};`),c&&u?t.write(`\n if (${n}.issues.length) {\n if (${s} in input) {\n payload.issues = payload.issues.concat(${n}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${s}, ...iss.path] : [${s}]\n })));\n }\n }\n \n if (${n}.value === undefined) {\n if (${s} in input) {\n newResult[${s}] = undefined;\n }\n } else {\n newResult[${s}] = ${n}.value;\n }\n \n `):c?t.write(`\n if (${n}.issues.length) {\n payload.issues = payload.issues.concat(${n}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${s}, ...iss.path] : [${s}]\n })));\n }\n \n if (${n}.value === undefined) {\n if (${s} in input) {\n newResult[${s}] = undefined;\n }\n } else {\n newResult[${s}] = ${n}.value;\n }\n \n `):t.write(`\n const ${n}_present = ${s} in input;\n if (${n}.issues.length) {\n payload.issues = payload.issues.concat(${n}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${s}, ...iss.path] : [${s}]\n })));\n }\n if (!${n}_present && !${n}.issues.length) {\n payload.issues.push({\n code: "invalid_type",\n expected: "nonoptional",\n input: undefined,\n path: [${s}]\n });\n }\n\n if (${n}_present) {\n if (${n}.value === undefined) {\n newResult[${s}] = undefined;\n } else {\n newResult[${s}] = ${n}.value;\n }\n }\n\n `)}t.write("payload.value = newResult;"),t.write("return payload;");const a=t.compile();return(t,n)=>a(e,t,n)})(t.shape)),l=o(l,f),c?Ni([],h,l,f,u,e):l):n(l,f):(l.issues.push({expected:"object",code:"invalid_type",input:h,inst:e}),l)}}));function Mi(e,t,n,r){for(const i of e)if(0===i.issues.length)return t.value=i.value,t;const o=e.filter((e=>!ao(e)));return 1===o.length?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map((e=>e.issues.map((e=>fo(e,r,dr())))))}),t)}const Ui=ur("$ZodUnion",((e,t)=>{Qo.init(e,t),Hr(e._zod,"optin",(()=>t.options.some((e=>"optional"===e._zod.optin))?"optional":void 0)),Hr(e._zod,"optout",(()=>t.options.some((e=>"optional"===e._zod.optout))?"optional":void 0)),Hr(e._zod,"values",(()=>{if(t.options.every((e=>e._zod.values)))return new Set(t.options.flatMap((e=>Array.from(e._zod.values))))})),Hr(e._zod,"pattern",(()=>{if(t.options.every((e=>e._zod.pattern))){const e=t.options.map((e=>e._zod.pattern));return new RegExp(`^(${e.map((e=>Zr(e.source))).join("|")})$`)}}));const n=1===t.options.length?t.options[0]._zod.run:null;e._zod.parse=(r,o)=>{if(n)return n(r,o);let i=!1;const s=[];for(const e of t.options){const t=e._zod.run({value:r.value,issues:[]},o);if(t instanceof Promise)s.push(t),i=!0;else{if(0===t.issues.length)return t;s.push(t)}}return i?Promise.all(s).then((t=>Mi(t,r,e,o))):Mi(s,r,e,o)}}));const Gi=ur("$ZodIntersection",((e,t)=>{Qo.init(e,t),e._zod.parse=(e,n)=>{const r=e.value,o=t.left._zod.run({value:r,issues:[]},n),i=t.right._zod.run({value:r,issues:[]},n);return o instanceof Promise||i instanceof Promise?Promise.all([o,i]).then((([t,n])=>ji(e,t,n))):ji(e,o,i)}}));function Li(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(eo(e)&&eo(t)){const n=Object.keys(t),r=Object.keys(e).filter((e=>-1!==n.indexOf(e))),o={...e,...t};for(const i of r){const n=Li(e[i],t[i]);if(!n.valid)return{valid:!1,mergeErrorPath:[i,...n.mergeErrorPath]};o[i]=n.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let r=0;r<e.length;r++){const o=Li(e[r],t[r]);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function ji(e,t,n){const r=new Map;let o;for(const a of t.issues)if("unrecognized_keys"===a.code){o??(o=a);for(const e of a.keys)r.has(e)||r.set(e,{}),r.get(e).l=!0}else e.issues.push(a);for(const a of n.issues)if("unrecognized_keys"===a.code)for(const e of a.keys)r.has(e)||r.set(e,{}),r.get(e).r=!0;else e.issues.push(a);const i=[...r].filter((([,e])=>e.l&&e.r)).map((([e])=>e));if(i.length&&o&&e.issues.push({...o,keys:i}),ao(e))return e;const s=Li(t.value,n.value);if(!s.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(s.mergeErrorPath)}`);return e.value=s.data,e}const Zi=ur("$ZodTuple",((e,t)=>{Qo.init(e,t);const n=t.items;e._zod.parse=(r,o)=>{const i=r.value;if(!Array.isArray(i))return r.issues.push({input:i,inst:e,expected:"tuple",code:"invalid_type"}),r;r.value=[];const s=[],a=qi(n,"optin"),c=qi(n,"optout");if(!t.rest){if(i.length<a)return r.issues.push({code:"too_small",minimum:a,inclusive:!0,input:i,inst:e,origin:"array"}),r;i.length>n.length&&r.issues.push({code:"too_big",maximum:n.length,inclusive:!0,input:i,inst:e,origin:"array"})}const u=new Array(n.length);for(let e=0;e<n.length;e++){const t=n[e]._zod.run({value:i[e],issues:[]},o);t instanceof Promise?s.push(t.then((t=>{u[e]=t}))):u[e]=t}if(t.rest){let e=n.length-1;const a=i.slice(n.length);for(const n of a){e++;const i=t.rest._zod.run({value:n,issues:[]},o);i instanceof Promise?s.push(i.then((t=>Hi(t,r,e)))):Hi(i,r,e)}}return s.length?Promise.all(s).then((()=>Wi(u,r,n,i,c))):Wi(u,r,n,i,c)}}));function qi(e,t){for(let n=e.length-1;n>=0;n--)if("optional"!==e[n]._zod[t])return n+1;return 0}function Hi(e,t,n){e.issues.length&&t.issues.push(...uo(n,e.issues)),t.value[n]=e.value}function Wi(e,t,n,r,o){for(let i=0;i<n.length;i++){const n=e[i],s=i<r.length;if(n.issues.length){if(!s&&i>=o){t.value.length=i;break}t.issues.push(...uo(i,n.issues))}t.value[i]=n.value}for(let i=t.value.length-1;i>=r.length&&("optional"===n[i]._zod.optout&&void 0===t.value[i]);i--)t.value.length=i;return t}const Ji=ur("$ZodRecord",((e,t)=>{Qo.init(e,t),e._zod.parse=(n,r)=>{const o=n.value;if(!eo(o))return n.issues.push({expected:"record",code:"invalid_type",input:o,inst:e}),n;const i=[],s=t.keyType._zod.values;if(s){n.value={};const a=new Set;for(const u of s)if("string"==typeof u||"number"==typeof u||"symbol"==typeof u){a.add("number"==typeof u?u.toString():u);const s=t.keyType._zod.run({value:u,issues:[]},r);if(s instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(s.issues.length){n.issues.push({code:"invalid_key",origin:"record",issues:s.issues.map((e=>fo(e,r,dr()))),input:u,path:[u],inst:e});continue}const c=s.value,l=t.valueType._zod.run({value:o[u],issues:[]},r);l instanceof Promise?i.push(l.then((e=>{e.issues.length&&n.issues.push(...uo(u,e.issues)),n.value[c]=e.value}))):(l.issues.length&&n.issues.push(...uo(u,l.issues)),n.value[c]=l.value)}let c;for(const e in o)a.has(e)||(c=c??[],c.push(e));c&&c.length>0&&n.issues.push({code:"unrecognized_keys",input:o,inst:e,keys:c})}else{n.value={};for(const s of Reflect.ownKeys(o)){if("__proto__"===s)continue;if(!Object.prototype.propertyIsEnumerable.call(o,s))continue;let a=t.keyType._zod.run({value:s,issues:[]},r);if(a instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if("string"==typeof s&&Nr.test(s)&&a.issues.length){const e=t.keyType._zod.run({value:Number(s),issues:[]},r);if(e instanceof Promise)throw new Error("Async schemas not supported in object keys currently");0===e.issues.length&&(a=e)}if(a.issues.length){"loose"===t.mode?n.value[s]=o[s]:n.issues.push({code:"invalid_key",origin:"record",issues:a.issues.map((e=>fo(e,r,dr()))),input:s,path:[s],inst:e});continue}const c=t.valueType._zod.run({value:o[s],issues:[]},r);c instanceof Promise?i.push(c.then((e=>{e.issues.length&&n.issues.push(...uo(s,e.issues)),n.value[a.value]=e.value}))):(c.issues.length&&n.issues.push(...uo(s,c.issues)),n.value[a.value]=c.value)}}return i.length?Promise.all(i).then((()=>n)):n}}));const Ki=ur("$ZodEnum",((e,t)=>{Qo.init(e,t);const n=Ur(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter((e=>no.has(typeof e))).map((e=>"string"==typeof e?ro(e):e.toString())).join("|")})$`),e._zod.parse=(t,o)=>{const i=t.value;return r.has(i)||t.issues.push({code:"invalid_value",values:n,input:i,inst:e}),t}})),Xi=ur("$ZodLiteral",((e,t)=>{if(Qo.init(e,t),0===t.values.length)throw new Error("Cannot create literal schema with no valid values");const n=new Set(t.values);e._zod.values=n,e._zod.pattern=new RegExp(`^(${t.values.map((e=>"string"==typeof e?ro(e):e?ro(e.toString()):String(e))).join("|")})$`),e._zod.parse=(r,o)=>{const i=r.value;return n.has(i)||r.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),r}})),Yi=ur("$ZodTransform",((e,t)=>{Qo.init(e,t),e._zod.optin="optional",e._zod.parse=(n,r)=>{if("backward"===r.direction)throw new fr(e.constructor.name);const o=t.transform(n.value,n);if(r.async){return(o instanceof Promise?o:Promise.resolve(o)).then((e=>(n.value=e,n.fallback=!0,n)))}if(o instanceof Promise)throw new lr;return n.value=o,n.fallback=!0,n}}));function Qi(e,t){return void 0===t&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}const es=ur("$ZodOptional",((e,t)=>{Qo.init(e,t),e._zod.optin="optional",e._zod.optout="optional",Hr(e._zod,"values",(()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0)),Hr(e._zod,"pattern",(()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${Zr(e.source)})?$`):void 0})),e._zod.parse=(e,n)=>{if("optional"===t.innerType._zod.optin){const r=e.value,o=t.innerType._zod.run(e,n);return o instanceof Promise?o.then((e=>Qi(e,r))):Qi(o,r)}return void 0===e.value?e:t.innerType._zod.run(e,n)}})),ts=ur("$ZodExactOptional",((e,t)=>{es.init(e,t),Hr(e._zod,"values",(()=>t.innerType._zod.values)),Hr(e._zod,"pattern",(()=>t.innerType._zod.pattern)),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)})),ns=ur("$ZodNullable",((e,t)=>{Qo.init(e,t),Hr(e._zod,"optin",(()=>t.innerType._zod.optin)),Hr(e._zod,"optout",(()=>t.innerType._zod.optout)),Hr(e._zod,"pattern",(()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${Zr(e.source)}|null)$`):void 0})),Hr(e._zod,"values",(()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0)),e._zod.parse=(e,n)=>null===e.value?e:t.innerType._zod.run(e,n)})),rs=ur("$ZodDefault",((e,t)=>{Qo.init(e,t),e._zod.optin="optional",Hr(e._zod,"values",(()=>t.innerType._zod.values)),e._zod.parse=(e,n)=>{if("backward"===n.direction)return t.innerType._zod.run(e,n);if(void 0===e.value)return e.value=t.defaultValue,e;const r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then((e=>os(e,t))):os(r,t)}}));function os(e,t){return void 0===e.value&&(e.value=t.defaultValue),e}const is=ur("$ZodPrefault",((e,t)=>{Qo.init(e,t),e._zod.optin="optional",Hr(e._zod,"values",(()=>t.innerType._zod.values)),e._zod.parse=(e,n)=>("backward"===n.direction||void 0===e.value&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))})),ss=ur("$ZodNonOptional",((e,t)=>{Qo.init(e,t),Hr(e._zod,"values",(()=>{const e=t.innerType._zod.values;return e?new Set([...e].filter((e=>void 0!==e))):void 0})),e._zod.parse=(n,r)=>{const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then((t=>as(t,e))):as(o,e)}}));function as(e,t){return e.issues.length||void 0!==e.value||e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const cs=ur("$ZodCatch",((e,t)=>{Qo.init(e,t),e._zod.optin="optional",Hr(e._zod,"optout",(()=>t.innerType._zod.optout)),Hr(e._zod,"values",(()=>t.innerType._zod.values)),e._zod.parse=(e,n)=>{if("backward"===n.direction)return t.innerType._zod.run(e,n);const r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then((r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map((e=>fo(e,n,dr())))},input:e.value}),e.issues=[],e.fallback=!0),e))):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map((e=>fo(e,n,dr())))},input:e.value}),e.issues=[],e.fallback=!0),e)}})),us=ur("$ZodPipe",((e,t)=>{Qo.init(e,t),Hr(e._zod,"values",(()=>t.in._zod.values)),Hr(e._zod,"optin",(()=>t.in._zod.optin)),Hr(e._zod,"optout",(()=>t.out._zod.optout)),Hr(e._zod,"propValues",(()=>t.in._zod.propValues)),e._zod.parse=(e,n)=>{if("backward"===n.direction){const r=t.out._zod.run(e,n);return r instanceof Promise?r.then((e=>ls(e,t.in,n))):ls(r,t.in,n)}const r=t.in._zod.run(e,n);return r instanceof Promise?r.then((e=>ls(e,t.out,n))):ls(r,t.out,n)}}));function ls(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}const fs=ur("$ZodReadonly",((e,t)=>{Qo.init(e,t),Hr(e._zod,"propValues",(()=>t.innerType._zod.propValues)),Hr(e._zod,"values",(()=>t.innerType._zod.values)),Hr(e._zod,"optin",(()=>t.innerType?._zod?.optin)),Hr(e._zod,"optout",(()=>t.innerType?._zod?.optout)),e._zod.parse=(e,n)=>{if("backward"===n.direction)return t.innerType._zod.run(e,n);const r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(hs):hs(r)}}));function hs(e){return e.value=Object.freeze(e.value),e}const ds=ur("$ZodFunction",((e,t)=>(Qo.init(e,t),e._def=t,e._zod.def=t,e.implement=t=>{if("function"!=typeof t)throw new Error("implement() must be called with a function");return function(...n){const r=e._def.input?No(e._def.input,n):n,o=Reflect.apply(t,this,r);return e._def.output?No(e._def.output,o):o}},e.implementAsync=t=>{if("function"!=typeof t)throw new Error("implementAsync() must be called with a function");return async function(...n){const r=e._def.input?await Fo(e._def.input,n):n,o=await Reflect.apply(t,this,r);return e._def.output?await Fo(e._def.output,o):o}},e._zod.parse=(t,n)=>{if("function"!=typeof t.value)return t.issues.push({code:"invalid_type",expected:"function",input:t.value,inst:e}),t;const r=e._def.output&&"promise"===e._def.output._zod.def.type;return t.value=r?e.implementAsync(t.value):e.implement(t.value),t},e.input=(...t)=>{const n=e.constructor;return Array.isArray(t[0])?new n({type:"function",input:new Zi({type:"tuple",items:t[0],rest:t[1]}),output:e._def.output}):new n({type:"function",input:t[0],output:e._def.output})},e.output=t=>new(0,e.constructor)({type:"function",input:e._def.input,output:t}),e))),ps=ur("$ZodCustom",((e,t)=>{mo.init(e,t),Qo.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{const r=n.value,o=t.fn(r);if(o instanceof Promise)return o.then((t=>ms(t,n,r,e)));ms(o,n,r,e)}}));function ms(e,t,n,r){if(!e){const e={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(po(e))}}var gs;Symbol("ZodOutput"),Symbol("ZodInput");class ys{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){const n=t[0];return this._map.set(e,n),n&&"object"==typeof n&&"id"in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){const t=this._map.get(e);return t&&"object"==typeof t&&"id"in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){const t=e._zod.parent;if(t){const n={...this.get(t)??{}};delete n.id;const r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}(gs=globalThis).__zod_globalRegistry??(gs.__zod_globalRegistry=new ys);const ws=globalThis.__zod_globalRegistry;function bs(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...io(t)})}function vs(e,t){return new yo({check:"less_than",...io(t),value:e,inclusive:!1})}function Bs(e,t){return new yo({check:"less_than",...io(t),value:e,inclusive:!0})}function Es(e,t){return new wo({check:"greater_than",...io(t),value:e,inclusive:!1})}function xs(e,t){return new wo({check:"greater_than",...io(t),value:e,inclusive:!0})}function Ts(e,t){return new bo({check:"multiple_of",...io(t),value:e})}function Rs(e,t){return new Bo({check:"max_length",...io(t),maximum:e})}function zs(e,t){return new Eo({check:"min_length",...io(t),minimum:e})}function As(e,t){return new xo({check:"length_equals",...io(t),length:e})}function ks(e){return new $o({check:"overwrite",tx:e})}function Ss(e,t){const n=function(e,t){const n=new mo({check:"custom",...io(t)});return n._zod.check=e,n}((t=>(t.addIssue=e=>{if("string"==typeof e)t.issues.push(po(e,t.value,n._zod.def));else{const r=e;r.fatal&&(r.continue=!1),r.code??(r.code="custom"),r.input??(r.input=t.value),r.inst??(r.inst=n),r.continue??(r.continue=!n._zod.def.abort),t.issues.push(po(r))}},e(t.value,t))),t);return n}function Os(e){let t=e?.target??"draft-2020-12";return"draft-4"===t&&(t="draft-04"),"draft-7"===t&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??ws,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function $s(e,t,n={path:[],schemaPath:[]}){var r;const o=e._zod.def,i=t.seen.get(e);if(i){i.count++;return n.schemaPath.includes(e)&&(i.cycle=n.path),i.schema}const s={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,s);const a=e._zod.toJSONSchema?.();if(a)s.schema=a;else{const r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,s.schema,r);else{const n=s.schema,i=t.processors[o.type];if(!i)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);i(e,t,n,r)}const i=e._zod.parent;i&&(s.ref||(s.ref=i),$s(i,t,r),t.seen.get(i).isParent=!0)}const c=t.metadataRegistry.get(e);c&&Object.assign(s.schema,c),"input"===t.io&&Vs(e)&&(delete s.schema.examples,delete s.schema.default),"input"===t.io&&"_prefault"in s.schema&&((r=s.schema).default??(r.default=s.schema._prefault)),delete s.schema._prefault;return t.seen.get(e).schema}function Is(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=new Map;for(const i of e.seen.entries()){const t=e.metadataRegistry.get(i[0])?.id;if(t){const e=r.get(t);if(e&&e!==i[0])throw new Error(`Duplicate schema id "${t}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(t,i[0])}}const o=t=>{if(t[1].schema.$ref)return;const r=t[1],{ref:o,defId:i}=(t=>{const r="draft-2020-12"===e.target?"$defs":"definitions";if(e.external){const n=e.external.registry.get(t[0])?.id,o=e.external.uri??(e=>e);if(n)return{ref:o(n)};const i=t[1].defId??t[1].schema.id??"schema"+e.counter++;return t[1].defId=i,{defId:i,ref:`${o("__shared")}#/${r}/${i}`}}if(t[1]===n)return{ref:"#"};const o=`#/${r}/`,i=t[1].schema.id??"__schema"+e.counter++;return{defId:i,ref:o+i}})(t);r.def={...r.schema},i&&(r.defId=i);const s=r.schema;for(const e in s)delete s[e];s.$ref=o};if("throw"===e.cycles)for(const i of e.seen.entries()){const e=i[1];if(e.cycle)throw new Error(`Cycle detected: #/${e.cycle?.join("/")}/<root>\n\nSet the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const i of e.seen.entries()){const n=i[1];if(t===i[0]){o(i);continue}if(e.external){const n=e.external.registry.get(i[0])?.id;if(t!==i[0]&&n){o(i);continue}}const r=e.metadataRegistry.get(i[0])?.id;r?o(i):(n.cycle||n.count>1&&"ref"===e.reused)&&o(i)}}function _s(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=t=>{const n=e.seen.get(t);if(null===n.ref)return;const o=n.def??n.schema,i={...o},s=n.ref;if(n.ref=null,s){r(s);const n=e.seen.get(s),a=n.schema;!a.$ref||"draft-07"!==e.target&&"draft-04"!==e.target&&"openapi-3.0"!==e.target?Object.assign(o,a):(o.allOf=o.allOf??[],o.allOf.push(a)),Object.assign(o,i);if(t._zod.parent===s)for(const e in o)"$ref"!==e&&"allOf"!==e&&(e in i||delete o[e]);if(a.$ref&&n.def)for(const e in o)"$ref"!==e&&"allOf"!==e&&e in n.def&&JSON.stringify(o[e])===JSON.stringify(n.def[e])&&delete o[e]}const a=t._zod.parent;if(a&&a!==s){r(a);const t=e.seen.get(a);if(t?.schema.$ref&&(o.$ref=t.schema.$ref,t.def))for(const e in o)"$ref"!==e&&"allOf"!==e&&e in t.def&&JSON.stringify(o[e])===JSON.stringify(t.def[e])&&delete o[e]}e.override({zodSchema:t,jsonSchema:o,path:n.path??[]})};for(const c of[...e.seen.entries()].reverse())r(c[0]);const o={};if("draft-2020-12"===e.target?o.$schema="https://json-schema.org/draft/2020-12/schema":"draft-07"===e.target?o.$schema="http://json-schema.org/draft-07/schema#":"draft-04"===e.target?o.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const n=e.external.registry.get(t)?.id;if(!n)throw new Error("Schema is missing an `id` property");o.$id=e.external.uri(n)}Object.assign(o,n.def??n.schema);const i=e.metadataRegistry.get(t)?.id;void 0!==i&&o.id===i&&delete o.id;const s=e.external?.defs??{};for(const c of e.seen.entries()){const e=c[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,s[e.defId]=e.def)}e.external||Object.keys(s).length>0&&("draft-2020-12"===e.target?o.$defs=s:o.definitions=s);try{const n=JSON.parse(JSON.stringify(o));return Object.defineProperty(n,"~standard",{value:{...t["~standard"],jsonSchema:{input:Ds(t,"input",e.processors),output:Ds(t,"output",e.processors)}},enumerable:!1,writable:!1}),n}catch(a){throw new Error("Error converting schema to JSON.")}}function Vs(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const r=e._zod.def;if("transform"===r.type)return!0;if("array"===r.type)return Vs(r.element,n);if("set"===r.type)return Vs(r.valueType,n);if("lazy"===r.type)return Vs(r.getter(),n);if("promise"===r.type||"optional"===r.type||"nonoptional"===r.type||"nullable"===r.type||"readonly"===r.type||"default"===r.type||"prefault"===r.type)return Vs(r.innerType,n);if("intersection"===r.type)return Vs(r.left,n)||Vs(r.right,n);if("record"===r.type||"map"===r.type)return Vs(r.keyType,n)||Vs(r.valueType,n);if("pipe"===r.type)return!!e._zod.traits.has("$ZodCodec")||(Vs(r.in,n)||Vs(r.out,n));if("object"===r.type){for(const e in r.shape)if(Vs(r.shape[e],n))return!0;return!1}if("union"===r.type){for(const e of r.options)if(Vs(e,n))return!0;return!1}if("tuple"===r.type){for(const e of r.items)if(Vs(e,n))return!0;return!(!r.rest||!Vs(r.rest,n))}return!1}const Ds=(e,t,n={})=>r=>{const{libraryOptions:o,target:i}=r??{},s=Os({...o??{},target:i,io:t,processors:n});return $s(e,s),Is(s,e),_s(s,e)};const Ps={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Ns=(e,t,n,r)=>{const o=n;o.type="string";const{minimum:i,maximum:s,format:a,patterns:c,contentEncoding:u}=e._zod.bag;if("number"==typeof i&&(o.minLength=i),"number"==typeof s&&(o.maxLength=s),a&&(o.format=Ps[a]??a,""===o.format&&delete o.format,"time"===a&&delete o.format),u&&(o.contentEncoding=u),c&&c.size>0){const e=[...c];1===e.length?o.pattern=e[0].source:e.length>1&&(o.allOf=[...e.map((e=>({..."draft-07"===t.target||"draft-04"===t.target||"openapi-3.0"===t.target?{type:"string"}:{},pattern:e.source})))])}},Cs=(e,t,n,r)=>{const o=n,{minimum:i,maximum:s,format:a,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:l}=e._zod.bag;"string"==typeof a&&a.includes("int")?o.type="integer":o.type="number";const f="number"==typeof l&&l>=(i??Number.NEGATIVE_INFINITY),h="number"==typeof u&&u<=(s??Number.POSITIVE_INFINITY),d="draft-04"===t.target||"openapi-3.0"===t.target;f?d?(o.minimum=l,o.exclusiveMinimum=!0):o.exclusiveMinimum=l:"number"==typeof i&&(o.minimum=i),h?d?(o.maximum=u,o.exclusiveMaximum=!0):o.exclusiveMaximum=u:"number"==typeof s&&(o.maximum=s),"number"==typeof c&&(o.multipleOf=c)},Fs=(e,t,n,r)=>{n.type="boolean"},Ms=(e,t,n,r)=>{if("throw"===t.unrepresentable)throw new Error("BigInt cannot be represented in JSON Schema")},Us=(e,t,n,r)=>{n.not={}},Gs=(e,t,n,r)=>{const o=Ur(e._zod.def.entries);o.every((e=>"number"==typeof e))&&(n.type="number"),o.every((e=>"string"==typeof e))&&(n.type="string"),n.enum=o},Ls=(e,t,n,r)=>{const o=e._zod.def,i=[];for(const s of o.values)if(void 0===s){if("throw"===t.unrepresentable)throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if("bigint"==typeof s){if("throw"===t.unrepresentable)throw new Error("BigInt literals cannot be represented in JSON Schema");i.push(Number(s))}else i.push(s);if(0===i.length);else if(1===i.length){const e=i[0];n.type=null===e?"null":typeof e,"draft-04"===t.target||"openapi-3.0"===t.target?n.enum=[e]:n.const=e}else i.every((e=>"number"==typeof e))&&(n.type="number"),i.every((e=>"string"==typeof e))&&(n.type="string"),i.every((e=>"boolean"==typeof e))&&(n.type="boolean"),i.every((e=>null===e))&&(n.type="null"),n.enum=i},js=(e,t,n,r)=>{if("throw"===t.unrepresentable)throw new Error("Custom types cannot be represented in JSON Schema")},Zs=(e,t,n,r)=>{if("throw"===t.unrepresentable)throw new Error("Function types cannot be represented in JSON Schema")},qs=(e,t,n,r)=>{if("throw"===t.unrepresentable)throw new Error("Transforms cannot be represented in JSON Schema")},Hs=(e,t,n,r)=>{const o=n,i=e._zod.def,{minimum:s,maximum:a}=e._zod.bag;"number"==typeof s&&(o.minItems=s),"number"==typeof a&&(o.maxItems=a),o.type="array",o.items=$s(i.element,t,{...r,path:[...r.path,"items"]})},Ws=(e,t,n,r)=>{const o=n,i=e._zod.def;o.type="object",o.properties={};const s=i.shape;for(const u in s)o.properties[u]=$s(s[u],t,{...r,path:[...r.path,"properties",u]});const a=new Set(Object.keys(s)),c=new Set([...a].filter((e=>{const n=i.shape[e]._zod;return"input"===t.io?void 0===n.optin:void 0===n.optout})));c.size>0&&(o.required=Array.from(c)),"never"===i.catchall?._zod.def.type?o.additionalProperties=!1:i.catchall?i.catchall&&(o.additionalProperties=$s(i.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):"output"===t.io&&(o.additionalProperties=!1)},Js=(e,t,n,r)=>{const o=e._zod.def,i=!1===o.inclusive,s=o.options.map(((e,n)=>$s(e,t,{...r,path:[...r.path,i?"oneOf":"anyOf",n]})));i?n.oneOf=s:n.anyOf=s},Ks=(e,t,n,r)=>{const o=e._zod.def,i=$s(o.left,t,{...r,path:[...r.path,"allOf",0]}),s=$s(o.right,t,{...r,path:[...r.path,"allOf",1]}),a=e=>"allOf"in e&&1===Object.keys(e).length,c=[...a(i)?i.allOf:[i],...a(s)?s.allOf:[s]];n.allOf=c},Xs=(e,t,n,r)=>{const o=n,i=e._zod.def;o.type="array";const s="draft-2020-12"===t.target?"prefixItems":"items",a="draft-2020-12"===t.target||"openapi-3.0"===t.target?"items":"additionalItems",c=i.items.map(((e,n)=>$s(e,t,{...r,path:[...r.path,s,n]}))),u=i.rest?$s(i.rest,t,{...r,path:[...r.path,a,..."openapi-3.0"===t.target?[i.items.length]:[]]}):null;"draft-2020-12"===t.target?(o.prefixItems=c,u&&(o.items=u)):"openapi-3.0"===t.target?(o.items={anyOf:c},u&&o.items.anyOf.push(u),o.minItems=c.length,u||(o.maxItems=c.length)):(o.items=c,u&&(o.additionalItems=u));const{minimum:l,maximum:f}=e._zod.bag;"number"==typeof l&&(o.minItems=l),"number"==typeof f&&(o.maxItems=f)},Ys=(e,t,n,r)=>{const o=n,i=e._zod.def;o.type="object";const s=i.keyType,a=s._zod.bag,c=a?.patterns;if("loose"===i.mode&&c&&c.size>0){const e=$s(i.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});o.patternProperties={};for(const t of c)o.patternProperties[t.source]=e}else"draft-07"!==t.target&&"draft-2020-12"!==t.target||(o.propertyNames=$s(i.keyType,t,{...r,path:[...r.path,"propertyNames"]})),o.additionalProperties=$s(i.valueType,t,{...r,path:[...r.path,"additionalProperties"]});const u=s._zod.values;if(u){const e=[...u].filter((e=>"string"==typeof e||"number"==typeof e));e.length>0&&(o.required=e)}},Qs=(e,t,n,r)=>{const o=e._zod.def,i=$s(o.innerType,t,r),s=t.seen.get(e);"openapi-3.0"===t.target?(s.ref=o.innerType,n.nullable=!0):n.anyOf=[i,{type:"null"}]},ea=(e,t,n,r)=>{const o=e._zod.def;$s(o.innerType,t,r);t.seen.get(e).ref=o.innerType},ta=(e,t,n,r)=>{const o=e._zod.def;$s(o.innerType,t,r);t.seen.get(e).ref=o.innerType,n.default=JSON.parse(JSON.stringify(o.defaultValue))},na=(e,t,n,r)=>{const o=e._zod.def;$s(o.innerType,t,r);t.seen.get(e).ref=o.innerType,"input"===t.io&&(n._prefault=JSON.parse(JSON.stringify(o.defaultValue)))},ra=(e,t,n,r)=>{const o=e._zod.def;$s(o.innerType,t,r);let i;t.seen.get(e).ref=o.innerType;try{i=o.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=i},oa=(e,t,n,r)=>{const o=e._zod.def,i=o.in._zod.traits.has("$ZodTransform"),s="input"===t.io?i?o.out:o.in:o.out;$s(s,t,r);t.seen.get(e).ref=s},ia=(e,t,n,r)=>{const o=e._zod.def;$s(o.innerType,t,r);t.seen.get(e).ref=o.innerType,n.readOnly=!0},sa=(e,t,n,r)=>{const o=e._zod.def;$s(o.innerType,t,r);t.seen.get(e).ref=o.innerType};const aa=ur("ZodISODateTime",((e,t)=>{di.init(e,t),Da.init(e,t)}));function ca(e){return function(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...io(t)})}(aa,e)}const ua=ur("ZodISODate",((e,t)=>{pi.init(e,t),Da.init(e,t)}));function la(e){return function(e,t){return new e({type:"string",format:"date",check:"string_format",...io(t)})}(ua,e)}const fa=ur("ZodISOTime",((e,t)=>{mi.init(e,t),Da.init(e,t)}));function ha(e){return function(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...io(t)})}(fa,e)}const da=ur("ZodISODuration",((e,t)=>{gi.init(e,t),Da.init(e,t)}));function pa(e){return function(e,t){return new e({type:"string",format:"duration",check:"string_format",...io(t)})}(da,e)}const ma=(e,t)=>{Vo.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:t=>function(e,t=e=>e.message){const n={_errors:[]},r=(e,o=[])=>{for(const i of e.issues)if("invalid_union"===i.code&&i.errors.length)i.errors.map((e=>r({issues:e},[...o,...i.path])));else if("invalid_key"===i.code)r({issues:i.issues},[...o,...i.path]);else if("invalid_element"===i.code)r({issues:i.issues},[...o,...i.path]);else{const e=[...o,...i.path];if(0===e.length)n._errors.push(t(i));else{let r=n,o=0;for(;o<e.length;){const n=e[o];o===e.length-1?(r[n]=r[n]||{_errors:[]},r[n]._errors.push(t(i))):r[n]=r[n]||{_errors:[]},r=r[n],o++}}}};return r(e),n}(e,t)},flatten:{value:t=>function(e,t=e=>e.message){const n={},r=[];for(const o of e.issues)o.path.length>0?(n[o.path[0]]=n[o.path[0]]||[],n[o.path[0]].push(t(o))):r.push(t(o));return{formErrors:r,fieldErrors:n}}(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,Gr,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Gr,2)}},isEmpty:{get:()=>0===e.issues.length}})},ga=ur("ZodError",ma,{Parent:Error}),ya=Po(ga),wa=Co(ga),ba=Mo(ga),va=Go(ga),Ba=jo(ga),Ea=Zo(ga),xa=qo(ga),Ta=Ho(ga),Ra=Wo(ga),za=Jo(ga),Aa=Ko(ga),ka=Xo(ga);const Sa=new WeakMap;function Oa(e,t,n){const r=Object.getPrototypeOf(e);let o=Sa.get(r);if(o||(o=new Set,Sa.set(r,o)),!o.has(t)){o.add(t);for(const e in n){const t=n[e];Object.defineProperty(r,e,{configurable:!0,enumerable:!1,get(){const n=t.bind(this);return Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:n}),n},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:t})}})}}}const $a=ur("ZodType",((e,t)=>(Qo.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Ds(e,"input"),output:Ds(e,"output")}}),e.toJSONSchema=((e,t={})=>n=>{const r=Os({...n,processors:t});return $s(e,r),Is(r,e),_s(r,e)})(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>ya(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>ba(e,t,n),e.parseAsync=async(t,n)=>wa(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>va(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>Ba(e,t,n),e.decode=(t,n)=>Ea(e,t,n),e.encodeAsync=async(t,n)=>xa(e,t,n),e.decodeAsync=async(t,n)=>Ta(e,t,n),e.safeEncode=(t,n)=>Ra(e,t,n),e.safeDecode=(t,n)=>za(e,t,n),e.safeEncodeAsync=async(t,n)=>Aa(e,t,n),e.safeDecodeAsync=async(t,n)=>ka(e,t,n),Oa(e,"ZodType",{check(...e){const t=this.def;return this.clone(Jr(t,{checks:[...t.checks??[],...e.map((e=>"function"==typeof e?{_zod:{check:e,def:{check:"custom"},onattach:[]}}:e))]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return oo(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(function(e,t={}){return function(e,t,n){return new e({type:"custom",check:"custom",fn:t,...io(n)})}(jc,e,t)}(e,t))},superRefine(e,t){return this.check(function(e,t){return Ss(e,t)}(e,t))},overwrite(e){return this.check(ks(e))},optional(){return Ic(this)},exactOptional(){return new _c({type:"optional",innerType:this})},nullable(){return Dc(this)},nullish(){return Ic(Dc(this))},nonoptional(e){return function(e,t){return new Cc({type:"nonoptional",innerType:e,...io(t)})}(this,e)},array(){return gc(this)},or(e){return vc([this,e])},and(e){return new Bc({type:"intersection",left:this,right:e})},transform(e){return Uc(this,Oc(e))},default(e){return t=e,new Pc({type:"default",innerType:this,get defaultValue(){return"function"==typeof t?t():to(t)}});var t},prefault(e){return t=e,new Nc({type:"prefault",innerType:this,get defaultValue(){return"function"==typeof t?t():to(t)}});var t},catch(e){return new Fc({type:"catch",innerType:this,catchValue:"function"==typeof(t=e)?t:()=>t});var t},pipe(e){return Uc(this,e)},readonly(){return new Gc({type:"readonly",innerType:this})},describe(e){const t=this.clone();return ws.add(t,{description:e}),t},meta(...e){if(0===e.length)return ws.get(this);const t=this.clone();return ws.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e){return e(this)}}),Object.defineProperty(e,"description",{get:()=>ws.get(e)?.description,configurable:!0}),e))),Ia=ur("_ZodString",((e,t)=>{ei.init(e,t),$a.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ns(e,t,n);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,Oa(e,"_ZodString",{regex(...e){return this.check(function(e,t){return new Ro({check:"string_format",format:"regex",...io(t),pattern:e})}(...e))},includes(...e){return this.check(function(e,t){return new ko({check:"string_format",format:"includes",...io(t),includes:e})}(...e))},startsWith(...e){return this.check(function(e,t){return new So({check:"string_format",format:"starts_with",...io(t),prefix:e})}(...e))},endsWith(...e){return this.check(function(e,t){return new Oo({check:"string_format",format:"ends_with",...io(t),suffix:e})}(...e))},min(...e){return this.check(zs(...e))},max(...e){return this.check(Rs(...e))},length(...e){return this.check(As(...e))},nonempty(...e){return this.check(zs(1,...e))},lowercase(e){return this.check(function(e){return new zo({check:"string_format",format:"lowercase",...io(e)})}(e))},uppercase(e){return this.check(function(e){return new Ao({check:"string_format",format:"uppercase",...io(e)})}(e))},trim(){return this.check(ks((e=>e.trim())))},normalize(...e){return this.check(function(e){return ks((t=>t.normalize(e)))}(...e))},toLowerCase(){return this.check(ks((e=>e.toLowerCase())))},toUpperCase(){return this.check(ks((e=>e.toUpperCase())))},slugify(){return this.check(ks((e=>function(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}(e))))}})})),_a=ur("ZodString",((e,t)=>{ei.init(e,t),Ia.init(e,t),e.email=t=>e.check(function(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...io(t)})}(Pa,t)),e.url=t=>e.check(function(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...io(t)})}(Fa,t)),e.jwt=t=>e.check(function(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...io(t)})}(ec,t)),e.emoji=t=>e.check(function(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...io(t)})}(Ma,t)),e.guid=t=>e.check(bs(Na,t)),e.uuid=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...io(t)})}(Ca,t)),e.uuidv4=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...io(t)})}(Ca,t)),e.uuidv6=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...io(t)})}(Ca,t)),e.uuidv7=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...io(t)})}(Ca,t)),e.nanoid=t=>e.check(function(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...io(t)})}(Ua,t)),e.guid=t=>e.check(bs(Na,t)),e.cuid=t=>e.check(function(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...io(t)})}(Ga,t)),e.cuid2=t=>e.check(function(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...io(t)})}(La,t)),e.ulid=t=>e.check(function(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...io(t)})}(ja,t)),e.base64=t=>e.check(function(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...io(t)})}(Xa,t)),e.base64url=t=>e.check(function(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...io(t)})}(Ya,t)),e.xid=t=>e.check(function(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...io(t)})}(Za,t)),e.ksuid=t=>e.check(function(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...io(t)})}(qa,t)),e.ipv4=t=>e.check(function(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...io(t)})}(Ha,t)),e.ipv6=t=>e.check(function(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...io(t)})}(Wa,t)),e.cidrv4=t=>e.check(function(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...io(t)})}(Ja,t)),e.cidrv6=t=>e.check(function(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...io(t)})}(Ka,t)),e.e164=t=>e.check(function(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...io(t)})}(Qa,t)),e.datetime=t=>e.check(ca(t)),e.date=t=>e.check(la(t)),e.time=t=>e.check(ha(t)),e.duration=t=>e.check(pa(t))}));function Va(e){return function(e,t){return new e({type:"string",...io(t)})}(_a,e)}const Da=ur("ZodStringFormat",((e,t)=>{ti.init(e,t),Ia.init(e,t)})),Pa=ur("ZodEmail",((e,t)=>{oi.init(e,t),Da.init(e,t)}));const Na=ur("ZodGUID",((e,t)=>{ni.init(e,t),Da.init(e,t)}));const Ca=ur("ZodUUID",((e,t)=>{ri.init(e,t),Da.init(e,t)}));const Fa=ur("ZodURL",((e,t)=>{ii.init(e,t),Da.init(e,t)}));const Ma=ur("ZodEmoji",((e,t)=>{si.init(e,t),Da.init(e,t)}));const Ua=ur("ZodNanoID",((e,t)=>{ai.init(e,t),Da.init(e,t)}));const Ga=ur("ZodCUID",((e,t)=>{ci.init(e,t),Da.init(e,t)}));const La=ur("ZodCUID2",((e,t)=>{ui.init(e,t),Da.init(e,t)}));const ja=ur("ZodULID",((e,t)=>{li.init(e,t),Da.init(e,t)}));const Za=ur("ZodXID",((e,t)=>{fi.init(e,t),Da.init(e,t)}));const qa=ur("ZodKSUID",((e,t)=>{hi.init(e,t),Da.init(e,t)}));const Ha=ur("ZodIPv4",((e,t)=>{yi.init(e,t),Da.init(e,t)}));const Wa=ur("ZodIPv6",((e,t)=>{wi.init(e,t),Da.init(e,t)}));const Ja=ur("ZodCIDRv4",((e,t)=>{bi.init(e,t),Da.init(e,t)}));const Ka=ur("ZodCIDRv6",((e,t)=>{vi.init(e,t),Da.init(e,t)}));const Xa=ur("ZodBase64",((e,t)=>{Ei.init(e,t),Da.init(e,t)}));const Ya=ur("ZodBase64URL",((e,t)=>{xi.init(e,t),Da.init(e,t)}));const Qa=ur("ZodE164",((e,t)=>{Ti.init(e,t),Da.init(e,t)}));const ec=ur("ZodJWT",((e,t)=>{Ri.init(e,t),Da.init(e,t)}));const tc=ur("ZodNumber",((e,t)=>{zi.init(e,t),$a.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Cs(e,t,n),Oa(e,"ZodNumber",{gt(e,t){return this.check(Es(e,t))},gte(e,t){return this.check(xs(e,t))},min(e,t){return this.check(xs(e,t))},lt(e,t){return this.check(vs(e,t))},lte(e,t){return this.check(Bs(e,t))},max(e,t){return this.check(Bs(e,t))},int(e){return this.check(oc(e))},safe(e){return this.check(oc(e))},positive(e){return this.check(Es(0,e))},nonnegative(e){return this.check(xs(0,e))},negative(e){return this.check(vs(0,e))},nonpositive(e){return this.check(Bs(0,e))},multipleOf(e,t){return this.check(Ts(e,t))},step(e,t){return this.check(Ts(e,t))},finite(){return this}});const n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null}));function nc(e){return function(e,t){return new e({type:"number",checks:[],...io(t)})}(tc,e)}const rc=ur("ZodNumberFormat",((e,t)=>{Ai.init(e,t),tc.init(e,t)}));function oc(e){return function(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...io(t)})}(rc,e)}const ic=ur("ZodBoolean",((e,t)=>{ki.init(e,t),$a.init(e,t),e._zod.processJSONSchema=(e,t,n)=>Fs(0,0,t)}));function sc(e){return function(e,t){return new e({type:"boolean",...io(t)})}(ic,e)}const ac=ur("ZodBigInt",((e,t)=>{Si.init(e,t),$a.init(e,t),e._zod.processJSONSchema=(e,t,n)=>Ms(0,e),e.gte=(t,n)=>e.check(xs(t,n)),e.min=(t,n)=>e.check(xs(t,n)),e.gt=(t,n)=>e.check(Es(t,n)),e.gte=(t,n)=>e.check(xs(t,n)),e.min=(t,n)=>e.check(xs(t,n)),e.lt=(t,n)=>e.check(vs(t,n)),e.lte=(t,n)=>e.check(Bs(t,n)),e.max=(t,n)=>e.check(Bs(t,n)),e.positive=t=>e.check(Es(BigInt(0),t)),e.negative=t=>e.check(vs(BigInt(0),t)),e.nonpositive=t=>e.check(Bs(BigInt(0),t)),e.nonnegative=t=>e.check(xs(BigInt(0),t)),e.multipleOf=(t,n)=>e.check(Ts(t,n));const n=e._zod.bag;e.minValue=n.minimum??null,e.maxValue=n.maximum??null,e.format=n.format??null}));function cc(e){return function(e,t){return new e({type:"bigint",...io(t)})}(ac,e)}const uc=ur("ZodAny",((e,t)=>{Oi.init(e,t),$a.init(e,t),e._zod.processJSONSchema=(e,t,n)=>{}}));function lc(){return function(e){return new e({type:"any"})}(uc)}const fc=ur("ZodUnknown",((e,t)=>{$i.init(e,t),$a.init(e,t),e._zod.processJSONSchema=(e,t,n)=>{}}));function hc(){return function(e){return new e({type:"unknown"})}(fc)}const dc=ur("ZodNever",((e,t)=>{Ii.init(e,t),$a.init(e,t),e._zod.processJSONSchema=(e,t,n)=>Us(0,0,t)}));function pc(e){return function(e,t){return new e({type:"never",...io(t)})}(dc,e)}const mc=ur("ZodArray",((e,t)=>{Vi.init(e,t),$a.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Hs(e,t,n,r),e.element=t.element,Oa(e,"ZodArray",{min(e,t){return this.check(zs(e,t))},nonempty(e){return this.check(zs(1,e))},max(e,t){return this.check(Rs(e,t))},length(e,t){return this.check(As(e,t))},unwrap(){return this.element}})}));function gc(e,t){return function(e,t,n){return new e({type:"array",element:t,...io(n)})}(mc,e,t)}const yc=ur("ZodObject",((e,t)=>{Fi.init(e,t),$a.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ws(e,t,n,r),Hr(e,"shape",(()=>t.shape)),Oa(e,"ZodObject",{keyof(){return Ac(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:hc()})},loose(){return this.clone({...this._zod.def,catchall:hc()})},strict(){return this.clone({...this._zod.def,catchall:pc()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return function(e,t){if(!eo(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const n=e._zod.def.shape;for(const e in t)if(void 0!==Object.getOwnPropertyDescriptor(n,e))throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const r=Jr(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return Wr(this,"shape",n),n}});return oo(e,r)}(this,e)},safeExtend(e){return function(e,t){if(!eo(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=Jr(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return Wr(this,"shape",n),n}});return oo(e,n)}(this,e)},merge(e){return function(e,t){if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");const n=Jr(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t._zod.def.shape};return Wr(this,"shape",n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return oo(e,n)}(this,e)},pick(e){return function(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");return oo(e,Jr(e._zod.def,{get shape(){const e={};for(const r in t){if(!(r in n.shape))throw new Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return Wr(this,"shape",e),e},checks:[]}))}(this,e)},omit(e){return function(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const o=Jr(e._zod.def,{get shape(){const r={...e._zod.def.shape};for(const e in t){if(!(e in n.shape))throw new Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return Wr(this,"shape",r),r},checks:[]});return oo(e,o)}(this,e)},partial(...e){return function(e,t,n){const r=t._zod.def.checks;if(r&&r.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const o=Jr(t._zod.def,{get shape(){const r=t._zod.def.shape,o={...r};if(n)for(const t in n){if(!(t in r))throw new Error(`Unrecognized key: "${t}"`);n[t]&&(o[t]=e?new e({type:"optional",innerType:r[t]}):r[t])}else for(const t in r)o[t]=e?new e({type:"optional",innerType:r[t]}):r[t];return Wr(this,"shape",o),o},checks:[]});return oo(t,o)}($c,this,e[0])},required(...e){return function(e,t,n){const r=Jr(t._zod.def,{get shape(){const r=t._zod.def.shape,o={...r};if(n)for(const t in n){if(!(t in o))throw new Error(`Unrecognized key: "${t}"`);n[t]&&(o[t]=new e({type:"nonoptional",innerType:r[t]}))}else for(const t in r)o[t]=new e({type:"nonoptional",innerType:r[t]});return Wr(this,"shape",o),o}});return oo(t,r)}(Cc,this,e[0])}})}));function wc(e,t){const n={type:"object",shape:e??{},...io(t)};return new yc(n)}const bc=ur("ZodUnion",((e,t)=>{Ui.init(e,t),$a.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Js(e,t,n,r),e.options=t.options}));function vc(e,t){return new bc({type:"union",options:e,...io(t)})}const Bc=ur("ZodIntersection",((e,t)=>{Gi.init(e,t),$a.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ks(e,t,n,r)}));const Ec=ur("ZodTuple",((e,t)=>{Zi.init(e,t),$a.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Xs(e,t,n,r),e.rest=t=>e.clone({...e._zod.def,rest:t})}));function xc(e,t,n){const r=t instanceof Qo;return new Ec({type:"tuple",items:e,rest:r?t:null,...io(r?n:t)})}const Tc=ur("ZodRecord",((e,t)=>{Ji.init(e,t),$a.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ys(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType}));function Rc(e,t,n){return t&&t._zod?new Tc({type:"record",keyType:e,valueType:t,...io(n)}):new Tc({type:"record",keyType:Va(),valueType:e,...io(t)})}const zc=ur("ZodEnum",((e,t)=>{Ki.init(e,t),$a.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Gs(e,0,n),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{const o={};for(const i of e){if(!n.has(i))throw new Error(`Key ${i} not found in enum`);o[i]=t.entries[i]}return new zc({...t,checks:[],...io(r),entries:o})},e.exclude=(e,r)=>{const o={...t.entries};for(const t of e){if(!n.has(t))throw new Error(`Key ${t} not found in enum`);delete o[t]}return new zc({...t,checks:[],...io(r),entries:o})}}));function Ac(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map((e=>[e,e]))):e;return new zc({type:"enum",entries:n,...io(t)})}const kc=ur("ZodLiteral",((e,t)=>{Xi.init(e,t),$a.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ls(e,t,n),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})}));const Sc=ur("ZodTransform",((e,t)=>{Yi.init(e,t),$a.init(e,t),e._zod.processJSONSchema=(e,t,n)=>qs(0,e),e._zod.parse=(n,r)=>{if("backward"===r.direction)throw new fr(e.constructor.name);n.addIssue=r=>{if("string"==typeof r)n.issues.push(po(r,n.value,t));else{const t=r;t.fatal&&(t.continue=!1),t.code??(t.code="custom"),t.input??(t.input=n.value),t.inst??(t.inst=e),n.issues.push(po(t))}};const o=t.transform(n.value,n);return o instanceof Promise?o.then((e=>(n.value=e,n.fallback=!0,n))):(n.value=o,n.fallback=!0,n)}}));function Oc(e){return new Sc({type:"transform",transform:e})}const $c=ur("ZodOptional",((e,t)=>{es.init(e,t),$a.init(e,t),e._zod.processJSONSchema=(t,n,r)=>sa(e,t,0,r),e.unwrap=()=>e._zod.def.innerType}));function Ic(e){return new $c({type:"optional",innerType:e})}const _c=ur("ZodExactOptional",((e,t)=>{ts.init(e,t),$a.init(e,t),e._zod.processJSONSchema=(t,n,r)=>sa(e,t,0,r),e.unwrap=()=>e._zod.def.innerType}));const Vc=ur("ZodNullable",((e,t)=>{ns.init(e,t),$a.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Qs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType}));function Dc(e){return new Vc({type:"nullable",innerType:e})}const Pc=ur("ZodDefault",((e,t)=>{rs.init(e,t),$a.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ta(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap}));const Nc=ur("ZodPrefault",((e,t)=>{is.init(e,t),$a.init(e,t),e._zod.processJSONSchema=(t,n,r)=>na(e,t,n,r),e.unwrap=()=>e._zod.def.innerType}));const Cc=ur("ZodNonOptional",((e,t)=>{ss.init(e,t),$a.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ea(e,t,0,r),e.unwrap=()=>e._zod.def.innerType}));const Fc=ur("ZodCatch",((e,t)=>{cs.init(e,t),$a.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ra(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap}));const Mc=ur("ZodPipe",((e,t)=>{us.init(e,t),$a.init(e,t),e._zod.processJSONSchema=(t,n,r)=>oa(e,t,0,r),e.in=t.in,e.out=t.out}));function Uc(e,t){return new Mc({type:"pipe",in:e,out:t})}const Gc=ur("ZodReadonly",((e,t)=>{fs.init(e,t),$a.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ia(e,t,n,r),e.unwrap=()=>e._zod.def.innerType}));const Lc=ur("ZodFunction",((e,t)=>{ds.init(e,t),$a.init(e,t),e._zod.processJSONSchema=(e,t,n)=>Zs(0,e)}));const jc=ur("ZodCustom",((e,t)=>{ps.init(e,t),$a.init(e,t),e._zod.processJSONSchema=(e,t,n)=>js(0,e)}));const Zc=wc({issuer:Va().transform((e=>yt(e))),index:Va().transform((e=>yt(e))),timestamp:Va().transform((e=>yt(e))),signature:Va().transform((e=>yt(e)))});var qc=n(878);const Hc=n.n(qc)()("bee-js:http"),Wc={headers:{accept:"application/json, text/plain, */*"}};async function Jc(e,t){const n=t.data,r=cr.Rb.deepMerge3(Wc,{...t,data:void 0},e);if(r.data=n,e.signal&&(r.signal=e.signal),function(e){if(void 0===e.data)return;const t=e.data;if(null!==t&&"object"==typeof t&&t.constructor===Object||Array.isArray(t))e.body=JSON.stringify(t),e.headers={"content-type":"application/json",...e.headers};else{e.body=t,e.duplex="half";const n=t instanceof Blob&&t.type?t.type:"application/octet-stream";e.headers={"content-type":n,...e.headers}}}(r),r.params)for(const c of Object.keys(r.params))void 0===r.params[c]&&delete r.params[c];const o=function(e){let t=cr.DH.joinUrl([e.baseURL??"",e.url??""]);if(e.params){const n=new URLSearchParams(Object.entries(e.params).filter((([,e])=>void 0!==e)).map((([e,t])=>[e,String(t)]))).toString();n&&(t+=`?${n}`)}return t}(r),i=(r.method||"GET").toUpperCase();r.method=i,e.onRequest?.({method:i,url:cr.DH.joinUrl([r.baseURL??"",r.url??""]),headers:{...r.headers},params:r.params});let s=0;for(;s<1e5;)try{Hc(`${i} ${o}`,{headers:r.headers,params:r.params});const e=await fetch(o,r);return e.ok||await Kc(i,o,e),Yc(e,r.responseType)}catch(a){if(a instanceof ru)throw a;const t=a;if("TimeoutError"!==t.name||!e.endlesslyRetry)throw Xc(t,i,o);s++,await cr.iQ.sleepMillis(s<300?200:1e3)}throw Error("Max number of failed attempts reached")}async function Kc(e,t,n){const r=await async function(e){const t=await e.text().catch((()=>""));if(!t)return;try{return JSON.parse(t)}catch{return t}}(n),o="string"==typeof r?r:JSON.stringify(r),i=o?`${n.statusText}: ${o}`:n.statusText;throw new ru(e,t,i,r,n.status,n.statusText)}function Xc(e,t,n){if("AbortError"===e.name)return new ru(t,n,"Request aborted",void 0,void 0,"ERR_CANCELED");const r=e.cause,o=r?.message?`${e.message}: ${r.message}`:e.message;return new ru(t,n,o)}async function Yc(e,t="json"){let n;switch(t){case"arraybuffer":n=await e.arrayBuffer();break;case"text":n=await e.text();break;case"blob":n=await e.blob();break;case"stream":n=e.body;break;default:{const t=await e.text();n=t?JSON.parse(t):null}}return{data:n,status:e.status,statusText:e.statusText,headers:Object.fromEntries(e.headers.entries()),raw:e}}const Qc=wc({durationSeconds:nc()});const eu=wc({reference:Va().transform((e=>new nn(e)))});class tu extends Error{constructor(e){super(e),this.name="BeeError"}}class nu extends tu{constructor(e,t){super(e),this.value=t,this.name="BeeArgumentError"}}class ru extends tu{constructor(e,t,n,r,o,i){super(n),this.method=e,this.url=t,this.responseBody=r,this.status=o,this.statusText=i,this.name="BeeResponseError",this.response={status:o,data:r,statusText:i}}}class ou{static ZERO=new ou(0);constructor(e){this.seconds=Math.ceil(e),e<0&&(this.seconds=0)}static fromMilliseconds(e){return new ou(e/1e3)}static fromSeconds(e){return new ou(e)}static fromHours(e){return new ou(60*e*60)}static fromDays(e){return new ou(24*e*60*60)}static fromWeeks(e){return new ou(7*e*24*60*60)}static fromYears(e){return new ou(365*e*24*60*60)}static fromEndDate(e,t){return new ou((e.getTime()-(t??new Date).getTime())/1e3)}static parseFromString(e){return ou.fromSeconds(cr.AO.make(e)/1e3)}toSeconds(){return this.seconds}toHours(){return this.seconds/60/60}toDays(){return this.seconds/24/60/60}toWeeks(){return this.seconds/7/24/60/60}toYears(){return this.seconds/365/24/60/60}toEndDate(e){return new Date((e??new Date).getTime()+1e3*this.seconds)}represent(){return cr.AO.secondsToHumanTime(this.seconds)}isZero(){return 0===this.seconds}}class iu{constructor(e){if(this.bytes=Math.ceil(e),e<0)throw Error("Size must be at least 0")}static fromBytes(e){return new iu(e)}static fromKilobytes(e){return new iu(1e3*e)}static fromMegabytes(e){return new iu(1e3*e*1e3)}static fromGigabytes(e){return new iu(1e3*e*1e3*1e3)}static parseFromString(e){return iu.fromBytes(cr.FQ.makeStorage(e,1e3))}toBytes(){return this.bytes}toGigabytes(){return this.bytes/1e3/1e3/1e3}toFormattedString(){return cr.FQ.convertBytes(this.bytes,1e3)}represent(){return this.toFormattedString()}}class su{static DIGITS=16;constructor(e){this.state=e}static fromDecimalString(e){return new su(cr.ie.fromDecimalString(e,su.DIGITS))}static fromPLUR(e){return new su(new cr.ie(e,su.DIGITS))}static fromFloat(e){return new su(cr.ie.fromFloat(e,su.DIGITS))}toPLURString(){return this.state.toString()}toPLURBigInt(){return this.state.value}toDecimalString(){return this.state.toDecimalString()}toFloat(){return this.state.toFloat()}toSignificantDigits(e){return this.toDecimalString().slice(0,this.toDecimalString().indexOf(".")+e+1)}plus(e){return new su(this.state.add(e instanceof su?e.state:new cr.ie(e,su.DIGITS)))}minus(e){return new su(this.state.subtract(e instanceof su?e.state:new cr.ie(e,su.DIGITS)))}divide(e){return new su(this.state.divmod(e)[0])}gt(e){return 1===this.state.compare(e.state)}gte(e){return-1!==this.state.compare(e.state)}lt(e){return-1===this.state.compare(e.state)}lte(e){return 1!==this.state.compare(e.state)}eq(e){return 0===this.state.compare(e.state)}exchangeToDAI(e){return au.fromWei(this.state.exchange("*",new cr.ie(e.toWeiBigInt(),au.DIGITS),au.DIGITS).value)}}class au{static DIGITS=18;constructor(e){this.state=e}static fromDecimalString(e){return new au(cr.ie.fromDecimalString(e,au.DIGITS))}static fromWei(e){return new au(new cr.ie(e,au.DIGITS))}static fromFloat(e){return new au(cr.ie.fromFloat(e,au.DIGITS))}toWeiString(){return this.state.toString()}toWeiBigInt(){return this.state.value}toDecimalString(){return this.state.toDecimalString()}toSignificantDigits(e){return this.toDecimalString().slice(0,this.toDecimalString().indexOf(".")+e+1)}toFloat(){return this.state.toFloat()}plus(e){return new au(this.state.add(e instanceof au?e.state:new cr.ie(e,au.DIGITS)))}minus(e){return new au(this.state.subtract(e instanceof au?e.state:new cr.ie(e,au.DIGITS)))}divide(e){return new au(this.state.divmod(e)[0])}gt(e){return 1===this.state.compare(e.state)}gte(e){return-1!==this.state.compare(e.state)}lt(e){return-1===this.state.compare(e.state)}lte(e){return 1!==this.state.compare(e.state)}eq(e){return 0===this.state.compare(e.state)}exchangeToBZZ(e){return su.fromPLUR(this.state.exchange("/",new cr.ie(e.toWeiBigInt(),au.DIGITS),su.DIGITS).value)}}var cu=n(320);function uu(e){if("function"==typeof File&&e instanceof File)return!0;const t=e;return"object"==typeof t&&"string"==typeof t.name&&("function"==typeof t.stream||"function"==typeof t.arrayBuffer)}function lu(e){return function(e,t){return new e({type:"number",coerce:!0,checks:[],...io(t)})}(tc,e)}let fu=function(e){return e.FULL="full",e.LIGHT="light",e.ULTRA_LIGHT="ultra-light",e.DEV="dev",e}({});function hu(e){switch(e){case"full":return fu.FULL;case"light":return fu.LIGHT;case"ultra-light":return fu.ULTRA_LIGHT;case"dev":return fu.DEV;default:throw new Error(`Unknown Bee mode: ${e}`)}}const du=32,pu=128,mu=du*pu,gu=4,yu=17,wu=255,bu=1,vu=1e3;let Bu=function(e){return e[e.OFF=0]="OFF",e[e.MEDIUM=1]="MEDIUM",e[e.STRONG=2]="STRONG",e[e.INSANE=3]="INSANE",e[e.PARANOID=4]="PARANOID",e}({}),Eu=function(e){return e[e.NONE=0]="NONE",e[e.DATA=1]="DATA",e[e.PROX=2]="PROX",e[e.RACE=3]="RACE",e}({});const xu={ENCRYPTION_OFF:{[Bu.OFF]:[{theoreticalVolume:"536.87 MB",effectiveVolume:"44.70 kB",batchDepth:17,utilizationRate:"0.01%"},{theoreticalVolume:"1.07 GB",effectiveVolume:"6.66 MB",batchDepth:18,utilizationRate:"0.61%"},{theoreticalVolume:"2.15 GB",effectiveVolume:"112.06 MB",batchDepth:19,utilizationRate:"5.09%"},{theoreticalVolume:"4.29 GB",effectiveVolume:"687.62 MB",batchDepth:20,utilizationRate:"15.65%"},{theoreticalVolume:"8.59 GB",effectiveVolume:"2.60 GB",batchDepth:21,utilizationRate:"30.27%"},{theoreticalVolume:"17.18 GB",effectiveVolume:"7.73 GB",batchDepth:22,utilizationRate:"44.99%"},{theoreticalVolume:"34.36 GB",effectiveVolume:"19.94 GB",batchDepth:23,utilizationRate:"58.03%"},{theoreticalVolume:"68.72 GB",effectiveVolume:"47.06 GB",batchDepth:24,utilizationRate:"68.48%"},{theoreticalVolume:"137.44 GB",effectiveVolume:"105.51 GB",batchDepth:25,utilizationRate:"76.77%"},{theoreticalVolume:"274.88 GB",effectiveVolume:"227.98 GB",batchDepth:26,utilizationRate:"82.94%"},{theoreticalVolume:"549.76 GB",effectiveVolume:"476.68 GB",batchDepth:27,utilizationRate:"86.71%"},{theoreticalVolume:"1.10 TB",effectiveVolume:"993.65 GB",batchDepth:28,utilizationRate:"88.37%"},{theoreticalVolume:"2.20 TB",effectiveVolume:"2.04 TB",batchDepth:29,utilizationRate:"92.88%"},{theoreticalVolume:"4.40 TB",effectiveVolume:"4.17 TB",batchDepth:30,utilizationRate:"94.81%"},{theoreticalVolume:"8.80 TB",effectiveVolume:"8.45 TB",batchDepth:31,utilizationRate:"96.06%"},{theoreticalVolume:"17.59 TB",effectiveVolume:"17.07 TB",batchDepth:32,utilizationRate:"97.01%"},{theoreticalVolume:"35.18 TB",effectiveVolume:"34.36 TB",batchDepth:33,utilizationRate:"97.65%"},{theoreticalVolume:"70.37 TB",effectiveVolume:"69.04 TB",batchDepth:34,utilizationRate:"98.11%"},{theoreticalVolume:"140.74 TB",effectiveVolume:"138.54 TB",batchDepth:35,utilizationRate:"98.44%"},{theoreticalVolume:"281.47 TB",effectiveVolume:"277.72 TB",batchDepth:36,utilizationRate:"98.67%"},{theoreticalVolume:"562.95 TB",effectiveVolume:"556.35 TB",batchDepth:37,utilizationRate:"98.83%"},{theoreticalVolume:"1.13 PB",effectiveVolume:"1.11 PB",batchDepth:38,utilizationRate:"98.91%"},{theoreticalVolume:"2.25 PB",effectiveVolume:"2.23 PB",batchDepth:39,utilizationRate:"98.96%"},{theoreticalVolume:"4.50 PB",effectiveVolume:"4.46 PB",batchDepth:40,utilizationRate:"98.98%"},{theoreticalVolume:"9.01 PB",effectiveVolume:"8.93 PB",batchDepth:41,utilizationRate:"99.11%"}],[Bu.MEDIUM]:[{theoreticalVolume:"536.87 MB",effectiveVolume:"41.56 kB",batchDepth:17,utilizationRate:"0.01%"},{theoreticalVolume:"1.07 GB",effectiveVolume:"6.19 MB",batchDepth:18,utilizationRate:"0.57%"},{theoreticalVolume:"2.15 GB",effectiveVolume:"104.18 MB",batchDepth:19,utilizationRate:"4.73%"},{theoreticalVolume:"4.29 GB",effectiveVolume:"639.27 MB",batchDepth:20,utilizationRate:"14.54%"},{theoreticalVolume:"8.59 GB",effectiveVolume:"2.41 GB",batchDepth:21,utilizationRate:"28.11%"},{theoreticalVolume:"17.18 GB",effectiveVolume:"7.18 GB",batchDepth:22,utilizationRate:"41.79%"},{theoreticalVolume:"34.36 GB",effectiveVolume:"18.54 GB",batchDepth:23,utilizationRate:"53.95%"},{theoreticalVolume:"68.72 GB",effectiveVolume:"43.75 GB",batchDepth:24,utilizationRate:"63.66%"},{theoreticalVolume:"137.44 GB",effectiveVolume:"98.09 GB",batchDepth:25,utilizationRate:"71.37%"},{theoreticalVolume:"274.88 GB",effectiveVolume:"211.95 GB",batchDepth:26,utilizationRate:"77.11%"},{theoreticalVolume:"549.76 GB",effectiveVolume:"443.16 GB",batchDepth:27,utilizationRate:"80.61%"},{theoreticalVolume:"1.10 TB",effectiveVolume:"923.78 GB",batchDepth:28,utilizationRate:"82.16%"},{theoreticalVolume:"2.20 TB",effectiveVolume:"1.90 TB",batchDepth:29,utilizationRate:"86.30%"},{theoreticalVolume:"4.40 TB",effectiveVolume:"3.88 TB",batchDepth:30,utilizationRate:"88.14%"},{theoreticalVolume:"8.80 TB",effectiveVolume:"7.86 TB",batchDepth:31,utilizationRate:"89.26%"},{theoreticalVolume:"17.59 TB",effectiveVolume:"15.87 TB",batchDepth:32,utilizationRate:"90.21%"},{theoreticalVolume:"35.18 TB",effectiveVolume:"31.94 TB",batchDepth:33,utilizationRate:"90.77%"},{theoreticalVolume:"70.37 TB",effectiveVolume:"64.19 TB",batchDepth:34,utilizationRate:"91.22%"},{theoreticalVolume:"140.74 TB",effectiveVolume:"128.80 TB",batchDepth:35,utilizationRate:"91.52%"},{theoreticalVolume:"281.47 TB",effectiveVolume:"258.19 TB",batchDepth:36,utilizationRate:"91.73%"},{theoreticalVolume:"562.95 TB",effectiveVolume:"517.23 TB",batchDepth:37,utilizationRate:"91.88%"},{theoreticalVolume:"1.13 PB",effectiveVolume:"1.04 PB",batchDepth:38,utilizationRate:"91.95%"},{theoreticalVolume:"2.25 PB",effectiveVolume:"2.07 PB",batchDepth:39,utilizationRate:"92.00%"},{theoreticalVolume:"4.50 PB",effectiveVolume:"4.15 PB",batchDepth:40,utilizationRate:"92.15%"},{theoreticalVolume:"9.01 PB",effectiveVolume:"8.30 PB",batchDepth:41,utilizationRate:"92.14%"}],[Bu.STRONG]:[{theoreticalVolume:"536.87 MB",effectiveVolume:"37.37 kB",batchDepth:17,utilizationRate:"0.01%"},{theoreticalVolume:"1.07 GB",effectiveVolume:"5.57 MB",batchDepth:18,utilizationRate:"0.51%"},{theoreticalVolume:"2.15 GB",effectiveVolume:"93.68 MB",batchDepth:19,utilizationRate:"4.25%"},{theoreticalVolume:"4.29 GB",effectiveVolume:"574.81 MB",batchDepth:20,utilizationRate:"13.07%"},{theoreticalVolume:"8.59 GB",effectiveVolume:"2.17 GB",batchDepth:21,utilizationRate:"25.26%"},{theoreticalVolume:"17.18 GB",effectiveVolume:"6.46 GB",batchDepth:22,utilizationRate:"37.58%"},{theoreticalVolume:"34.36 GB",effectiveVolume:"16.67 GB",batchDepth:23,utilizationRate:"48.50%"},{theoreticalVolume:"68.72 GB",effectiveVolume:"39.34 GB",batchDepth:24,utilizationRate:"57.24%"},{theoreticalVolume:"137.44 GB",effectiveVolume:"88.20 GB",batchDepth:25,utilizationRate:"64.17%"},{theoreticalVolume:"274.88 GB",effectiveVolume:"190.58 GB",batchDepth:26,utilizationRate:"69.33%"},{theoreticalVolume:"549.76 GB",effectiveVolume:"398.47 GB",batchDepth:27,utilizationRate:"72.48%"},{theoreticalVolume:"1.10 TB",effectiveVolume:"830.63 GB",batchDepth:28,utilizationRate:"73.85%"},{theoreticalVolume:"2.20 TB",effectiveVolume:"1.71 TB",batchDepth:29,utilizationRate:"77.59%"},{theoreticalVolume:"4.40 TB",effectiveVolume:"3.49 TB",batchDepth:30,utilizationRate:"79.27%"},{theoreticalVolume:"8.80 TB",effectiveVolume:"7.07 TB",batchDepth:31,utilizationRate:"80.34%"},{theoreticalVolume:"17.59 TB",effectiveVolume:"14.27 TB",batchDepth:32,utilizationRate:"81.12%"},{theoreticalVolume:"35.18 TB",effectiveVolume:"28.72 TB",batchDepth:33,utilizationRate:"81.63%"},{theoreticalVolume:"70.37 TB",effectiveVolume:"57.71 TB",batchDepth:34,utilizationRate:"82.01%"},{theoreticalVolume:"140.74 TB",effectiveVolume:"115.81 TB",batchDepth:35,utilizationRate:"82.29%"},{theoreticalVolume:"281.47 TB",effectiveVolume:"232.16 TB",batchDepth:36,utilizationRate:"82.48%"},{theoreticalVolume:"562.95 TB",effectiveVolume:"465.07 TB",batchDepth:37,utilizationRate:"82.61%"},{theoreticalVolume:"1.13 PB",effectiveVolume:"931.23 TB",batchDepth:38,utilizationRate:"82.67%"},{theoreticalVolume:"2.25 PB",effectiveVolume:"1.86 PB",batchDepth:39,utilizationRate:"82.71%"},{theoreticalVolume:"4.50 PB",effectiveVolume:"3.73 PB",batchDepth:40,utilizationRate:"82.78%"},{theoreticalVolume:"9.01 PB",effectiveVolume:"7.46 PB",batchDepth:41,utilizationRate:"82.79%"}],[Bu.INSANE]:[{theoreticalVolume:"536.87 MB",effectiveVolume:"33.88 kB",batchDepth:17,utilizationRate:"0.01%"},{theoreticalVolume:"1.07 GB",effectiveVolume:"5.05 MB",batchDepth:18,utilizationRate:"0.46%"},{theoreticalVolume:"2.15 GB",effectiveVolume:"84.92 MB",batchDepth:19,utilizationRate:"3.86%"},{theoreticalVolume:"4.29 GB",effectiveVolume:"521.09 MB",batchDepth:20,utilizationRate:"11.85%"},{theoreticalVolume:"8.59 GB",effectiveVolume:"1.97 GB",batchDepth:21,utilizationRate:"22.90%"},{theoreticalVolume:"17.18 GB",effectiveVolume:"5.86 GB",batchDepth:22,utilizationRate:"34.09%"},{theoreticalVolume:"34.36 GB",effectiveVolume:"15.11 GB",batchDepth:23,utilizationRate:"43.97%"},{theoreticalVolume:"68.72 GB",effectiveVolume:"35.66 GB",batchDepth:24,utilizationRate:"51.90%"},{theoreticalVolume:"137.44 GB",effectiveVolume:"79.96 GB",batchDepth:25,utilizationRate:"58.18%"},{theoreticalVolume:"274.88 GB",effectiveVolume:"172.77 GB",batchDepth:26,utilizationRate:"62.85%"},{theoreticalVolume:"549.76 GB",effectiveVolume:"361.23 GB",batchDepth:27,utilizationRate:"65.70%"},{theoreticalVolume:"1.10 TB",effectiveVolume:"753.00 GB",batchDepth:28,utilizationRate:"66.95%"},{theoreticalVolume:"2.20 TB",effectiveVolume:"1.55 TB",batchDepth:29,utilizationRate:"70.38%"},{theoreticalVolume:"4.40 TB",effectiveVolume:"3.16 TB",batchDepth:30,utilizationRate:"71.92%"},{theoreticalVolume:"8.80 TB",effectiveVolume:"6.41 TB",batchDepth:31,utilizationRate:"72.85%"},{theoreticalVolume:"17.59 TB",effectiveVolume:"12.93 TB",batchDepth:32,utilizationRate:"73.53%"},{theoreticalVolume:"35.18 TB",effectiveVolume:"26.04 TB",batchDepth:33,utilizationRate:"74.01%"},{theoreticalVolume:"70.37 TB",effectiveVolume:"52.32 TB",batchDepth:34,utilizationRate:"74.35%"},{theoreticalVolume:"140.74 TB",effectiveVolume:"104.99 TB",batchDepth:35,utilizationRate:"74.60%"},{theoreticalVolume:"281.47 TB",effectiveVolume:"210.46 TB",batchDepth:36,utilizationRate:"74.77%"},{theoreticalVolume:"562.95 TB",effectiveVolume:"421.61 TB",batchDepth:37,utilizationRate:"74.89%"},{theoreticalVolume:"1.13 PB",effectiveVolume:"844.20 TB",batchDepth:38,utilizationRate:"74.94%"},{theoreticalVolume:"2.25 PB",effectiveVolume:"1.69 PB",batchDepth:39,utilizationRate:"74.98%"},{theoreticalVolume:"4.50 PB",effectiveVolume:"3.38 PB",batchDepth:40,utilizationRate:"75.03%"},{theoreticalVolume:"9.01 PB",effectiveVolume:"6.77 PB",batchDepth:41,utilizationRate:"75.10%"}],[Bu.PARANOID]:[{theoreticalVolume:"536.87 MB",effectiveVolume:"13.27 kB",batchDepth:17,utilizationRate:"0.00%"},{theoreticalVolume:"1.07 GB",effectiveVolume:"1.98 MB",batchDepth:18,utilizationRate:"0.18%"},{theoreticalVolume:"2.15 GB",effectiveVolume:"33.27 MB",batchDepth:19,utilizationRate:"1.51%"},{theoreticalVolume:"4.29 GB",effectiveVolume:"204.14 MB",batchDepth:20,utilizationRate:"4.64%"},{theoreticalVolume:"8.59 GB",effectiveVolume:"771.13 MB",batchDepth:21,utilizationRate:"8.75%"},{theoreticalVolume:"17.18 GB",effectiveVolume:"2.29 GB",batchDepth:22,utilizationRate:"13.34%"},{theoreticalVolume:"34.36 GB",effectiveVolume:"5.92 GB",batchDepth:23,utilizationRate:"17.22%"},{theoreticalVolume:"68.72 GB",effectiveVolume:"13.97 GB",batchDepth:24,utilizationRate:"20.33%"},{theoreticalVolume:"137.44 GB",effectiveVolume:"31.32 GB",batchDepth:25,utilizationRate:"22.79%"},{theoreticalVolume:"274.88 GB",effectiveVolume:"67.68 GB",batchDepth:26,utilizationRate:"24.62%"},{theoreticalVolume:"549.76 GB",effectiveVolume:"141.51 GB",batchDepth:27,utilizationRate:"25.74%"},{theoreticalVolume:"1.10 TB",effectiveVolume:"294.99 GB",batchDepth:28,utilizationRate:"26.23%"},{theoreticalVolume:"2.20 TB",effectiveVolume:"606.90 GB",batchDepth:29,utilizationRate:"27.56%"},{theoreticalVolume:"4.40 TB",effectiveVolume:"1.24 TB",batchDepth:30,utilizationRate:"28.15%"},{theoreticalVolume:"8.80 TB",effectiveVolume:"2.51 TB",batchDepth:31,utilizationRate:"28.54%"},{theoreticalVolume:"17.59 TB",effectiveVolume:"5.07 TB",batchDepth:32,utilizationRate:"28.82%"},{theoreticalVolume:"35.18 TB",effectiveVolume:"10.20 TB",batchDepth:33,utilizationRate:"28.99%"},{theoreticalVolume:"70.37 TB",effectiveVolume:"20.50 TB",batchDepth:34,utilizationRate:"29.13%"},{theoreticalVolume:"140.74 TB",effectiveVolume:"41.13 TB",batchDepth:35,utilizationRate:"29.22%"},{theoreticalVolume:"281.47 TB",effectiveVolume:"82.45 TB",batchDepth:36,utilizationRate:"29.29%"},{theoreticalVolume:"562.95 TB",effectiveVolume:"165.17 TB",batchDepth:37,utilizationRate:"29.34%"},{theoreticalVolume:"1.13 PB",effectiveVolume:"330.72 TB",batchDepth:38,utilizationRate:"29.37%"},{theoreticalVolume:"2.25 PB",effectiveVolume:"661.97 TB",batchDepth:39,utilizationRate:"29.39%"},{theoreticalVolume:"4.50 PB",effectiveVolume:"1.32 PB",batchDepth:40,utilizationRate:"29.41%"},{theoreticalVolume:"9.01 PB",effectiveVolume:"2.65 PB",batchDepth:41,utilizationRate:"29.43%"}]},ENCRYPTION_ON:{[Bu.OFF]:[{theoreticalVolume:"536.87 MB",effectiveVolume:"44.35 kB",batchDepth:17,utilizationRate:"0.01%"},{theoreticalVolume:"1.07 GB",effectiveVolume:"6.61 MB",batchDepth:18,utilizationRate:"0.60%"},{theoreticalVolume:"2.15 GB",effectiveVolume:"111.18 MB",batchDepth:19,utilizationRate:"5.05%"},{theoreticalVolume:"4.29 GB",effectiveVolume:"682.21 MB",batchDepth:20,utilizationRate:"15.52%"},{theoreticalVolume:"8.59 GB",effectiveVolume:"2.58 GB",batchDepth:21,utilizationRate:"30.04%"},{theoreticalVolume:"17.18 GB",effectiveVolume:"7.67 GB",batchDepth:22,utilizationRate:"44.62%"},{theoreticalVolume:"34.36 GB",effectiveVolume:"19.78 GB",batchDepth:23,utilizationRate:"57.56%"},{theoreticalVolume:"68.72 GB",effectiveVolume:"46.69 GB",batchDepth:24,utilizationRate:"67.93%"},{theoreticalVolume:"137.44 GB",effectiveVolume:"104.68 GB",batchDepth:25,utilizationRate:"76.16%"},{theoreticalVolume:"274.88 GB",effectiveVolume:"226.19 GB",batchDepth:26,utilizationRate:"82.29%"},{theoreticalVolume:"549.76 GB",effectiveVolume:"472.93 GB",batchDepth:27,utilizationRate:"86.02%"},{theoreticalVolume:"1.10 TB",effectiveVolume:"985.83 GB",batchDepth:28,utilizationRate:"87.66%"},{theoreticalVolume:"2.20 TB",effectiveVolume:"2.03 TB",batchDepth:29,utilizationRate:"92.25%"},{theoreticalVolume:"4.40 TB",effectiveVolume:"4.14 TB",batchDepth:30,utilizationRate:"94.21%"},{theoreticalVolume:"8.80 TB",effectiveVolume:"8.39 TB",batchDepth:31,utilizationRate:"95.37%"},{theoreticalVolume:"17.59 TB",effectiveVolume:"16.93 TB",batchDepth:32,utilizationRate:"96.22%"},{theoreticalVolume:"35.18 TB",effectiveVolume:"34.09 TB",batchDepth:33,utilizationRate:"96.88%"},{theoreticalVolume:"70.37 TB",effectiveVolume:"68.50 TB",batchDepth:34,utilizationRate:"97.34%"},{theoreticalVolume:"140.74 TB",effectiveVolume:"137.45 TB",batchDepth:35,utilizationRate:"97.67%"},{theoreticalVolume:"281.47 TB",effectiveVolume:"275.53 TB",batchDepth:36,utilizationRate:"97.89%"},{theoreticalVolume:"562.95 TB",effectiveVolume:"551.97 TB",batchDepth:37,utilizationRate:"98.05%"},{theoreticalVolume:"1.13 PB",effectiveVolume:"1.11 PB",batchDepth:38,utilizationRate:"98.13%"},{theoreticalVolume:"2.25 PB",effectiveVolume:"2.21 PB",batchDepth:39,utilizationRate:"98.18%"},{theoreticalVolume:"4.50 PB",effectiveVolume:"4.43 PB",batchDepth:40,utilizationRate:"98.36%"},{theoreticalVolume:"9.01 PB",effectiveVolume:"8.86 PB",batchDepth:41,utilizationRate:"98.37%"}],[Bu.MEDIUM]:[{theoreticalVolume:"536.87 MB",effectiveVolume:"40.89 kB",batchDepth:17,utilizationRate:"0.01%"},{theoreticalVolume:"1.07 GB",effectiveVolume:"6.09 MB",batchDepth:18,utilizationRate:"0.56%"},{theoreticalVolume:"2.15 GB",effectiveVolume:"102.49 MB",batchDepth:19,utilizationRate:"4.65%"},{theoreticalVolume:"4.29 GB",effectiveVolume:"628.91 MB",batchDepth:20,utilizationRate:"14.30%"},{theoreticalVolume:"8.59 GB",effectiveVolume:"2.38 GB",batchDepth:21,utilizationRate:"27.68%"},{theoreticalVolume:"17.18 GB",effectiveVolume:"7.07 GB",batchDepth:22,utilizationRate:"41.15%"},{theoreticalVolume:"34.36 GB",effectiveVolume:"18.24 GB",batchDepth:23,utilizationRate:"53.09%"},{theoreticalVolume:"68.72 GB",effectiveVolume:"43.04 GB",batchDepth:24,utilizationRate:"62.63%"},{theoreticalVolume:"137.44 GB",effectiveVolume:"96.50 GB",batchDepth:25,utilizationRate:"70.21%"},{theoreticalVolume:"274.88 GB",effectiveVolume:"208.52 GB",batchDepth:26,utilizationRate:"75.86%"},{theoreticalVolume:"549.76 GB",effectiveVolume:"435.98 GB",batchDepth:27,utilizationRate:"79.30%"},{theoreticalVolume:"1.10 TB",effectiveVolume:"908.81 GB",batchDepth:28,utilizationRate:"80.82%"},{theoreticalVolume:"2.20 TB",effectiveVolume:"1.87 TB",batchDepth:29,utilizationRate:"84.98%"},{theoreticalVolume:"4.40 TB",effectiveVolume:"3.81 TB",batchDepth:30,utilizationRate:"86.67%"},{theoreticalVolume:"8.80 TB",effectiveVolume:"7.73 TB",batchDepth:31,utilizationRate:"87.84%"},{theoreticalVolume:"17.59 TB",effectiveVolume:"15.61 TB",batchDepth:32,utilizationRate:"88.74%"},{theoreticalVolume:"35.18 TB",effectiveVolume:"31.43 TB",batchDepth:33,utilizationRate:"89.34%"},{theoreticalVolume:"70.37 TB",effectiveVolume:"63.15 TB",batchDepth:34,utilizationRate:"89.74%"},{theoreticalVolume:"140.74 TB",effectiveVolume:"126.71 TB",batchDepth:35,utilizationRate:"90.03%"},{theoreticalVolume:"281.47 TB",effectiveVolume:"254.01 TB",batchDepth:36,utilizationRate:"90.24%"},{theoreticalVolume:"562.95 TB",effectiveVolume:"508.85 TB",batchDepth:37,utilizationRate:"90.39%"},{theoreticalVolume:"1.13 PB",effectiveVolume:"1.02 PB",batchDepth:38,utilizationRate:"90.47%"},{theoreticalVolume:"2.25 PB",effectiveVolume:"2.04 PB",batchDepth:39,utilizationRate:"90.51%"},{theoreticalVolume:"4.50 PB",effectiveVolume:"4.08 PB",batchDepth:40,utilizationRate:"90.64%"},{theoreticalVolume:"9.01 PB",effectiveVolume:"8.17 PB",batchDepth:41,utilizationRate:"90.65%"}],[Bu.STRONG]:[{theoreticalVolume:"536.87 MB",effectiveVolume:"36.73 kB",batchDepth:17,utilizationRate:"0.01%"},{theoreticalVolume:"1.07 GB",effectiveVolume:"5.47 MB",batchDepth:18,utilizationRate:"0.50%"},{theoreticalVolume:"2.15 GB",effectiveVolume:"92.07 MB",batchDepth:19,utilizationRate:"4.18%"},{theoreticalVolume:"4.29 GB",effectiveVolume:"564.95 MB",batchDepth:20,utilizationRate:"12.85%"},{theoreticalVolume:"8.59 GB",effectiveVolume:"2.13 GB",batchDepth:21,utilizationRate:"24.86%"},{theoreticalVolume:"17.18 GB",effectiveVolume:"6.35 GB",batchDepth:22,utilizationRate:"36.97%"},{theoreticalVolume:"34.36 GB",effectiveVolume:"16.38 GB",batchDepth:23,utilizationRate:"47.67%"},{theoreticalVolume:"68.72 GB",effectiveVolume:"38.66 GB",batchDepth:24,utilizationRate:"56.26%"},{theoreticalVolume:"137.44 GB",effectiveVolume:"86.69 GB",batchDepth:25,utilizationRate:"63.07%"},{theoreticalVolume:"274.88 GB",effectiveVolume:"187.31 GB",batchDepth:26,utilizationRate:"68.14%"},{theoreticalVolume:"549.76 GB",effectiveVolume:"391.64 GB",batchDepth:27,utilizationRate:"71.24%"},{theoreticalVolume:"1.10 TB",effectiveVolume:"816.39 GB",batchDepth:28,utilizationRate:"72.59%"},{theoreticalVolume:"2.20 TB",effectiveVolume:"1.68 TB",batchDepth:29,utilizationRate:"76.34%"},{theoreticalVolume:"4.40 TB",effectiveVolume:"3.43 TB",batchDepth:30,utilizationRate:"77.89%"},{theoreticalVolume:"8.80 TB",effectiveVolume:"6.94 TB",batchDepth:31,utilizationRate:"78.86%"},{theoreticalVolume:"17.59 TB",effectiveVolume:"14.02 TB",batchDepth:32,utilizationRate:"79.71%"},{theoreticalVolume:"35.18 TB",effectiveVolume:"28.23 TB",batchDepth:33,utilizationRate:"80.23%"},{theoreticalVolume:"70.37 TB",effectiveVolume:"56.72 TB",batchDepth:34,utilizationRate:"80.60%"},{theoreticalVolume:"140.74 TB",effectiveVolume:"113.82 TB",batchDepth:35,utilizationRate:"80.88%"},{theoreticalVolume:"281.47 TB",effectiveVolume:"228.18 TB",batchDepth:36,utilizationRate:"81.06%"},{theoreticalVolume:"562.95 TB",effectiveVolume:"457.10 TB",batchDepth:37,utilizationRate:"81.20%"},{theoreticalVolume:"1.13 PB",effectiveVolume:"915.26 TB",batchDepth:38,utilizationRate:"81.26%"},{theoreticalVolume:"2.25 PB",effectiveVolume:"1.83 PB",batchDepth:39,utilizationRate:"81.30%"},{theoreticalVolume:"4.50 PB",effectiveVolume:"3.67 PB",batchDepth:40,utilizationRate:"81.43%"},{theoreticalVolume:"9.01 PB",effectiveVolume:"7.34 PB",batchDepth:41,utilizationRate:"81.45%"}],[Bu.INSANE]:[{theoreticalVolume:"536.87 MB",effectiveVolume:"33.26 kB",batchDepth:17,utilizationRate:"0.01%"},{theoreticalVolume:"1.07 GB",effectiveVolume:"4.96 MB",batchDepth:18,utilizationRate:"0.45%"},{theoreticalVolume:"2.15 GB",effectiveVolume:"83.38 MB",batchDepth:19,utilizationRate:"3.79%"},{theoreticalVolume:"4.29 GB",effectiveVolume:"511.65 MB",batchDepth:20,utilizationRate:"11.64%"},{theoreticalVolume:"8.59 GB",effectiveVolume:"1.93 GB",batchDepth:21,utilizationRate:"22.52%"},{theoreticalVolume:"17.18 GB",effectiveVolume:"5.75 GB",batchDepth:22,utilizationRate:"33.50%"},{theoreticalVolume:"34.36 GB",effectiveVolume:"14.84 GB",batchDepth:23,utilizationRate:"43.19%"},{theoreticalVolume:"68.72 GB",effectiveVolume:"35.02 GB",batchDepth:24,utilizationRate:"50.96%"},{theoreticalVolume:"137.44 GB",effectiveVolume:"78.51 GB",batchDepth:25,utilizationRate:"57.12%"},{theoreticalVolume:"274.88 GB",effectiveVolume:"169.64 GB",batchDepth:26,utilizationRate:"61.71%"},{theoreticalVolume:"549.76 GB",effectiveVolume:"354.69 GB",batchDepth:27,utilizationRate:"64.52%"},{theoreticalVolume:"1.10 TB",effectiveVolume:"739.37 GB",batchDepth:28,utilizationRate:"65.74%"},{theoreticalVolume:"2.20 TB",effectiveVolume:"1.52 TB",batchDepth:29,utilizationRate:"69.15%"},{theoreticalVolume:"4.40 TB",effectiveVolume:"3.10 TB",batchDepth:30,utilizationRate:"70.56%"},{theoreticalVolume:"8.80 TB",effectiveVolume:"6.29 TB",batchDepth:31,utilizationRate:"71.48%"},{theoreticalVolume:"17.59 TB",effectiveVolume:"12.70 TB",batchDepth:32,utilizationRate:"72.18%"},{theoreticalVolume:"35.18 TB",effectiveVolume:"25.57 TB",batchDepth:33,utilizationRate:"72.67%"},{theoreticalVolume:"70.37 TB",effectiveVolume:"51.37 TB",batchDepth:34,utilizationRate:"73.00%"},{theoreticalVolume:"140.74 TB",effectiveVolume:"103.08 TB",batchDepth:35,utilizationRate:"73.24%"},{theoreticalVolume:"281.47 TB",effectiveVolume:"206.65 TB",batchDepth:36,utilizationRate:"73.42%"},{theoreticalVolume:"562.95 TB",effectiveVolume:"413.98 TB",batchDepth:37,utilizationRate:"73.54%"},{theoreticalVolume:"1.13 PB",effectiveVolume:"828.91 TB",batchDepth:38,utilizationRate:"73.59%"},{theoreticalVolume:"2.25 PB",effectiveVolume:"1.66 PB",batchDepth:39,utilizationRate:"73.62%"},{theoreticalVolume:"4.50 PB",effectiveVolume:"3.32 PB",batchDepth:40,utilizationRate:"73.72%"},{theoreticalVolume:"9.01 PB",effectiveVolume:"6.64 PB",batchDepth:41,utilizationRate:"73.74%"}],[Bu.PARANOID]:[{theoreticalVolume:"536.87 MB",effectiveVolume:"13.17 kB",batchDepth:17,utilizationRate:"0.00%"},{theoreticalVolume:"1.07 GB",effectiveVolume:"1.96 MB",batchDepth:18,utilizationRate:"0.18%"},{theoreticalVolume:"2.15 GB",effectiveVolume:"33.01 MB",batchDepth:19,utilizationRate:"1.50%"},{theoreticalVolume:"4.29 GB",effectiveVolume:"202.53 MB",batchDepth:20,utilizationRate:"4.61%"},{theoreticalVolume:"8.59 GB",effectiveVolume:"765.05 MB",batchDepth:21,utilizationRate:"8.68%"},{theoreticalVolume:"17.18 GB",effectiveVolume:"2.28 GB",batchDepth:22,utilizationRate:"13.27%"},{theoreticalVolume:"34.36 GB",effectiveVolume:"5.87 GB",batchDepth:23,utilizationRate:"17.08%"},{theoreticalVolume:"68.72 GB",effectiveVolume:"13.86 GB",batchDepth:24,utilizationRate:"20.17%"},{theoreticalVolume:"137.44 GB",effectiveVolume:"31.08 GB",batchDepth:25,utilizationRate:"22.61%"},{theoreticalVolume:"274.88 GB",effectiveVolume:"67.15 GB",batchDepth:26,utilizationRate:"24.43%"},{theoreticalVolume:"549.76 GB",effectiveVolume:"140.40 GB",batchDepth:27,utilizationRate:"25.54%"},{theoreticalVolume:"1.10 TB",effectiveVolume:"292.67 GB",batchDepth:28,utilizationRate:"26.03%"},{theoreticalVolume:"2.20 TB",effectiveVolume:"602.12 GB",batchDepth:29,utilizationRate:"27.35%"},{theoreticalVolume:"4.40 TB",effectiveVolume:"1.23 TB",batchDepth:30,utilizationRate:"27.94%"},{theoreticalVolume:"8.80 TB",effectiveVolume:"2.49 TB",batchDepth:31,utilizationRate:"28.32%"},{theoreticalVolume:"17.59 TB",effectiveVolume:"5.03 TB",batchDepth:32,utilizationRate:"28.60%"},{theoreticalVolume:"35.18 TB",effectiveVolume:"10.12 TB",batchDepth:33,utilizationRate:"28.77%"},{theoreticalVolume:"70.37 TB",effectiveVolume:"20.34 TB",batchDepth:34,utilizationRate:"28.91%"},{theoreticalVolume:"140.74 TB",effectiveVolume:"40.80 TB",batchDepth:35,utilizationRate:"29.00%"},{theoreticalVolume:"281.47 TB",effectiveVolume:"81.80 TB",batchDepth:36,utilizationRate:"29.06%"},{theoreticalVolume:"562.95 TB",effectiveVolume:"163.87 TB",batchDepth:37,utilizationRate:"29.11%"},{theoreticalVolume:"1.13 PB",effectiveVolume:"328.11 TB",batchDepth:38,utilizationRate:"29.14%"},{theoreticalVolume:"2.25 PB",effectiveVolume:"656.76 TB",batchDepth:39,utilizationRate:"29.16%"},{theoreticalVolume:"4.50 PB",effectiveVolume:"1.31 PB",batchDepth:40,utilizationRate:"29.18%"},{theoreticalVolume:"9.01 PB",effectiveVolume:"2.63 PB",batchDepth:41,utilizationRate:"29.19%"}]}},Tu=(Va().regex(/^(?:0x)?[0-9a-fA-F]*$/i,"expected hex string").refine((e=>e.replace(/^0x/i,"").length%2==0),"expected even-length hex string"),lc().refine((e=>{return new Lc({type:"function",input:Array.isArray(t?.input)?xc(t?.input):t?.input??gc(hc()),output:t?.output??hc()}).safeParse(e).success;var t}),"expected a function")),Ru=lc().transform((e=>(cc().safeParse(e).success&&(e=String(e)),Va().regex(/^-?\d+$/,"expected integer string").parse(e)))),zu=lc().transform((e=>(cc().safeParse(e).success&&(e=String(e)),Va().regex(/^\d+$/,"expected non-negative integer string").parse(e)))),Au=wc({baseURL:Va().optional(),timeout:nc().int().min(0).optional(),headers:Rc(Va(),Va()).optional(),onRequest:Tu.optional(),httpAgent:hc().optional(),httpsAgent:hc().optional(),endlesslyRetry:sc().optional(),signal:lc().optional()}),ku=wc({redundancyStrategy:nc().int().optional(),fallback:sc().optional(),timeoutMs:nc().int().min(0).optional(),actPublisher:Ic(lc().transform((e=>new Jt(e)))),actHistoryAddress:Ic(lc().transform((e=>new nn(e)))),actTimestamp:lu().optional()}),Su=wc({act:sc().optional(),actHistoryAddress:Ic(lc().transform((e=>new nn(e)))),deferred:sc().optional(),encrypt:sc().optional(),pin:sc().optional(),tag:nc().int().min(0).optional()}),Ou=Su.extend({redundancyLevel:nc().int().min(0).optional()}),$u=Su.extend({size:nc().int().min(0).optional(),contentType:Va().optional(),redundancyLevel:nc().int().min(0).optional()}),Iu=Su.extend({errorDocument:Va().optional(),indexDocument:Va().optional(),redundancyLevel:nc().int().min(0).optional()}),_u=wc({uid:nc().int()}),Vu=lu().min(0),Du=wc({onMessage:Tu,onError:Tu,onClose:Tu}),Pu=wc({onMessage:Tu,onError:Tu,onClose:Tu}),Nu=wc({fields:gc(Ac(["address","recoveredPubKey","identifier","signature","wrappedAddress","span","payload"])).nonempty().optional(),cacheWrappedChunk:sc().optional()}),Cu=wc({gasPrice:Ru.optional(),immutableFlag:sc().optional(),label:Va().optional(),waitForUsable:sc().optional(),waitForUsableTimeout:nc().int().min(0).optional()}),Fu=wc({gasLimit:zu.optional(),gasPrice:zu.optional()}),Mu=wc({limit:nc().int().min(bu).max(vu).optional(),offset:nc().int().min(0).optional()});function Uu(e){return void 0!==cu.Readable&&e instanceof cu.Readable}function Gu(e,t){if("bigint"==typeof e&&(e=e.toString()),"string"!=typeof e||!/^-?\d+$/.test(e))throw new TypeError(`${t?.name??"value"} is not a valid integer string, got: ${e}`);if(void 0!==t?.min&&BigInt(e)<t.min)throw new RangeError(`${t?.name??"value"} must be >= ${t.min}, got: ${e}`);if(void 0!==t?.max&&BigInt(e)>t.max)throw new RangeError(`${t?.name??"value"} must be <= ${t.max}, got: ${e}`);return e}function Lu(e){if(!("string"==typeof e||e instanceof Uint8Array||e instanceof Blob||Uu(e)))throw new TypeError("Data must be either string, Uint8Array, Blob or Readable!")}function ju(e){if(null==e)throw new TypeError(`Expected number | Tag | string from tagUid, got: ${e}`);if(t=e,_u.safeParse(t).success)return e.uid;if("number"==typeof e||"string"==typeof e)return Vu.parse(e);var t;throw new TypeError(`Expected number | Tag | string from tagUid, got: ${e}`)}function Zu(e,t){return su.fromPLUR(2n**BigInt(e)*BigInt(t))}function qu(e,t,n){const r=BigInt(Gu(e));return ou.fromSeconds(Number(r*BigInt(n)/BigInt(t)))}function Hu(e,t,n){return BigInt(e.toSeconds())/BigInt(n)*BigInt(t)+1n}function Wu(e,t,n){return function(e,t,n){if(void 0!==t&&void 0!==n){const r=(t?nr:tr)[n],o=r?.find((([,t])=>e<=Qn(t)));if(o)return o[0]}else for(const[r,o]of er)if(e<=Qn(o))return r;return 35}(e.toBytes(),t,n)}function Ju(e){return ir(e)}function Ku(e,t,n){const r=function(e){return Number.isInteger(e)?e<1?1:e>3155695200?3155695200:e:1}(e.batchTTL),o=ou.fromSeconds(r),i=rr(e.depth,t,n),s=e.utilizationRatio??Kn(e.utilization,e.depth,e.bucketDepth);return{batchID:new Nt(e.batchID),utilization:e.utilization,usable:e.usable,label:e.label,depth:e.depth,amount:Gu(e.amount),bucketDepth:e.bucketDepth,blockNumber:e.blockNumber,immutableFlag:e.immutableFlag,usage:s,usageText:`${Math.round(100*s)}%`,size:iu.fromBytes(i),remainingSize:iu.fromBytes(Math.ceil(i*(1-s))),theoreticalSize:iu.fromBytes(Xn(e.depth)),duration:o,calculateSize(t,n){const r=rr(e.depth,t,n);return iu.fromBytes(r)},calculateRemainingSize(t,n){const r=rr(e.depth,t,n);return iu.fromBytes(Math.ceil(r*(1-this.usage)))}}}function Xu(e){return{batchID:e.batchID.toHex(),utilization:e.utilization,utilizationRatio:e.usage,usable:e.usable,label:e.label,depth:e.depth,amount:e.amount,bucketDepth:e.bucketDepth,blockNumber:e.blockNumber,immutableFlag:e.immutableFlag,batchTTL:e.duration.toSeconds()}}function Yu(e){return{name:function(e){if(!e)throw new tu("missing content-disposition header");const t=e.match(/filename\*?=['"]?(?:UTF-\d['"]*)?([^;\r\n"']*)['"]?;?/i);if(t&&t.length>0)return t[1];throw new tu("invalid content-disposition header")}(e["content-disposition"]),tagUid:function(e){if(!e)return;return parseInt(e,10)}(e["swarm-tag-uid"]),contentType:e["content-type"]||void 0}}function Qu(e,t){const n={};if(!function(e){if(!wc({}).safeParse(e).success)return!1;const t=e;return void 0!==t.issuer&&void 0!==t.index&&void 0!==t.signature&&void 0!==t.timestamp&&void 0!==t.batchId}(e)?e&&(e=new Nt(e),n["swarm-postage-batch-id"]=e.toHex()):n["swarm-postage-stamp"]=Ju(e).toHex(),!t)return n;const r=t;r.size&&(n["content-length"]=String(r.size)),r.contentType&&(n["content-type"]=String(r.contentType)),r.redundancyLevel&&(n["swarm-redundancy-level"]=String(r.redundancyLevel));const o=sc().safeParse(r.act);o.success&&(n["swarm-act"]=String(o.data));const i=sc().safeParse(r.pin);i.success&&(n["swarm-pin"]=String(i.data));const s=sc().safeParse(r.encrypt);s.success&&(n["swarm-encrypt"]=String(s.data)),r.tag&&(n["swarm-tag"]=String(r.tag));const a=sc().safeParse(r.deferred);a.success&&(n["swarm-deferred-upload"]=String(a.data)),r.redundancyStrategy&&(n["swarm-redundancy-strategy"]=String(r.redundancyStrategy));const c=sc().safeParse(r.fallback);return c.success&&(n["swarm-redundancy-fallback-mode"]=String(c.data)),r.timeoutMs&&(n["swarm-chunk-retrieval-timeout"]=String(r.timeoutMs)),r.indexDocument&&(n["swarm-index-document"]=String(r.indexDocument)),r.errorDocument&&(n["swarm-error-document"]=String(r.errorDocument)),r.actPublisher&&(n["swarm-act-publisher"]=new Jt(r.actPublisher).toCompressedHex()),r.actHistoryAddress&&(n["swarm-act-history-address"]=new nn(r.actHistoryAddress).toHex()),r.actTimestamp&&(n["swarm-act-timestamp"]=String(r.actTimestamp)),(r.actPublisher||r.actHistoryAddress||r.actTimestamp)&&(n["swarm-act"]="true"),r.gasPrice&&(n["gas-price"]=String(r.gasPrice)),r.gasLimit&&(n["gas-limit"]=String(r.gasLimit)),n}const el="chunks";async function tl(e,t,n){t=new nn(t);const r=await Jc(e,{responseType:"arraybuffer",url:`${el}/${t}`,headers:Qu(null,n)});return new Uint8Array(r.data)}function nl(e,t){try{return xn(e,t)}catch(n){throw new tu(n.message)}}async function rl(e,t,n,r){const o=Pt.concat(t.span.toUint8Array(),t.payload.toUint8Array());return async function(e,t,n,r,o,i,s){const a=await Jc(e,{method:"post",url:`soc/${t}/${n}`,data:o,headers:{"content-type":"application/octet-stream",...Qu(i,s)},responseType:"json",params:{sig:r.toHex()}});return{reference:eu.parse(a.data).reference,tagUid:a.headers["swarm-tag"]?ju(a.headers["swarm-tag"]):void 0,historyAddress:a.headers["swarm-act-history-address"]?cr.Xx.of(new nn(a.headers["swarm-act-history-address"])):cr.Xx.empty()}}(e,t.owner,t.identifier,t.signature,o,n,r)}async function ol(e,t,n,r,o,i){t=new en(t),r=new Zt(r);return rl(e,Tn(o).toSingleOwnerChunk(r,t),n,i)}async function il(e,t,n,r,o,i){t=new en(t),r=new Zt(r);return rl(e,o.toSingleOwnerChunk(r,t),n,i)}async function sl(e,t,n){const r=Bn(n=new Zt(n),t=new Ut(t));return nl(await tl(e,r.toHex()),r)}const al=wc({peer:Va(),balance:Va().transform((e=>su.fromPLUR(Gu(e,{name:"balance"}))))}),cl=wc({balances:gc(al)}),ul=al,ll="balances";const fl="consumed";class hl{constructor(e){this.context=e}async getAll(e){return async function(e){const t=await Jc(e,{url:ll,responseType:"json"});return cl.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async getPeer(e,t){const n=new qt(e);return async function(e,t){const n=await Jc(e,{url:`${ll}/${t}`,responseType:"json"});return ul.parse(n.data)}(this.context.getRequestOptionsForCall(t),n)}async getAllPastDueConsumption(e){return async function(e){const t=await Jc(e,{url:fl,responseType:"json"});return cl.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async getAllPastDueConsumptionForPeer(e,t){const n=new qt(e);return async function(e,t){const n=await Jc(e,{url:`${fl}/${t}`,responseType:"json"});return ul.parse(n.data)}(this.context.getRequestOptionsForCall(t),n)}}const dl=wc({beneficiary:Va().transform((e=>new Ut(e))),chequebook:Va().transform((e=>new Ut(e))),payout:Va().transform((e=>su.fromPLUR(Gu(e,{name:"payout"}))))}),pl=wc({recipient:Va(),lastPayout:Va().transform((e=>su.fromPLUR(Gu(e,{name:"lastPayout"})))),bounced:sc()}),ml=wc({chequebookAddress:Va().transform((e=>new Ut(e)))}),gl=wc({availableBalance:Va().transform((e=>su.fromPLUR(Gu(e,{name:"availableBalance"})))),totalBalance:Va().transform((e=>su.fromPLUR(Gu(e,{name:"totalBalance"}))))}),yl=wc({peer:Va(),uncashedAmount:Va().transform((e=>su.fromPLUR(Gu(e,{name:"uncashedAmount"})))),transactionHash:Va().nullish().transform((e=>e??null)),lastCashedCheque:dl.nullish().transform((e=>e??null)),result:pl.nullish().transform((e=>e??null))}),wl=wc({peer:Va(),lastreceived:dl.nullish().transform((e=>e??null)),lastsent:dl.nullish().transform((e=>e??null))}),bl=wc({lastcheques:gc(wc({peer:Va(),lastreceived:dl.nullish().transform((e=>e??null)),lastsent:dl.nullish().transform((e=>e??null))}))}),vl=wc({transactionHash:Va().transform((e=>new an(e)))}),Bl="chequebook";class El{constructor(e){this.context=e}async getAllLatest(e){return async function(e){const t=await Jc(e,{url:`${Bl}/cheque`,responseType:"json"});return bl.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async getAllLatestForPeer(e,t){const n=new qt(e);return async function(e,t){const n=await Jc(e,{url:`${Bl}/cheque/${t}`,responseType:"json"});return wl.parse(n.data)}(this.context.getRequestOptionsForCall(t),n)}async getLastCashoutAction(e,t){const n=new qt(e);return async function(e,t){const n=await Jc(e,{url:`${Bl}/cashout/${t}`,responseType:"json"});return yl.parse(n.data)}(this.context.getRequestOptionsForCall(t),n)}async cashoutLast(e,t,n){const r=new qt(e);return t&&(t=Fu.parse(t)),async function(e,t,n){const r=await Jc(e,{method:"post",url:`${Bl}/cashout/${t}`,responseType:"json",headers:Qu(null,n)});return vl.parse(r.data).transactionHash}(this.context.getRequestOptionsForCall(n),r,t)}}class xl{constructor(e){this.context=e}async getAddress(e){return async function(e){const t=await Jc(e,{url:`${Bl}/address`,responseType:"json"});return ml.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async getBalance(e){return async function(e){const t=await Jc(e,{url:`${Bl}/balance`,responseType:"json"});return gl.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async deposit(e,t,n){const r=e instanceof su?e.toPLURString():Gu(e,{min:1n,name:"amount"}),o=t?Gu(t,{min:0n,name:"gasPrice"}):void 0;return async function(e,t,n){const r={};n&&(r["gas-price"]=n);const o=await Jc(e,{method:"post",url:`${Bl}/deposit`,responseType:"json",params:{amount:t},headers:r});return vl.parse(o.data).transactionHash}(this.context.getRequestOptionsForCall(n),r,o)}async withdraw(e,t,n){const r=e instanceof su?e.toPLURString():Gu(e,{min:1n,name:"amount"}),o=t?Gu(t,{min:0n,name:"gasPrice"}):void 0;return async function(e,t,n){const r={};n&&(r["gas-price"]=n);const o=await Jc(e,{method:"post",url:`${Bl}/withdraw`,responseType:"json",params:{amount:t},headers:r});return vl.parse(o.data).transactionHash}(this.context.getRequestOptionsForCall(n),r,o)}}class Tl{constructor(e){this.context=e}async upload(e,t,n,r){const o="identifier"in t&&"signature"in t&&"owner"in t;if(t=t instanceof Uint8Array?t:t.data,n&&(n=Su.parse(n)),t.length<rn.LENGTH)throw new nu(`Chunk has to have size of at least ${rn.LENGTH}.`,t);if(!o&&t.length>mu+rn.LENGTH)throw new nu(`Content Addressed Chunk must not exceed ${mu+rn.LENGTH} bytes.`,t);if(o&&t.length>mu+rn.LENGTH+Qt.LENGTH+Zt.LENGTH)throw new nu(`Single Owner Chunk must not exceed ${mu+rn.LENGTH+Qt.LENGTH+Zt.LENGTH} bytes.`,t);return async function(e,t,n,r){const o=await Jc(e,{method:"post",url:`${el}`,data:t,headers:{"content-type":"application/octet-stream",...Qu(n,r)},responseType:"json"});return{reference:eu.parse(o.data).reference,tagUid:o.headers["swarm-tag"]?ju(o.headers["swarm-tag"]):void 0,historyAddress:o.headers["swarm-act-history-address"]?cr.Xx.of(new nn(o.headers["swarm-act-history-address"])):cr.Xx.empty()}}(this.context.getRequestOptionsForCall(r),t,e,n)}async download(e,t,n){const r=new nn(e);return t&&(t=ku.parse(t)),tl(this.context.getRequestOptionsForCall(n),r,t)}}var Rl=n(497),zl=n.n(Rl);async function Al(e,t,n,r,o){for(const s of e.forks.values()){const e=await Al(s.node,t,n,r,o);if(r?.act){let t;e.historyAddress.ifPresent((e=>t=e)),t&&(s.node.metadata||(s.node.metadata={}),s.node.metadata["swarm-act-history-address"]=t.toHex())}}const i=await t.data.upload(n,await e.marshal(),r,o);return e.selfAddress=i.reference.toUint8Array(),i}async function kl(e,t,n,r){for(const o of e.forks.values()){if(!o.node.selfAddress)throw Error("MantarayNode#loadRecursively fork.node.selfAddress is not set");let i=n;o.node.metadata&&o.node.metadata["swarm-act-history-address"]&&(i={...n,actHistoryAddress:o.node.metadata["swarm-act-history-address"]});const s=(await t.data.download(o.node.selfAddress,i,r)).toUint8Array();o.node.hydrate(s),o.node.path=o.prefix,o.node.parent=e,await kl(o.node,t,n,r)}}class Sl{constructor(e=new qn){this.core=e}get obfuscationKey(){return this.core.obfuscationKey}get selfAddress(){return this.core.selfAddress}get targetAddress(){return this.core.targetAddress}get metadata(){return this.core.metadata}get path(){return this.core.path}get forks(){return this.core.forks}get parent(){return this.core.parent}get type(){return this.core.type}get fullPath(){return this.core.fullPath}get fullPathString(){return this.core.fullPathString}getRootMetadata(){const e=this.core.find("/");return e&&e.metadata?cr.Xx.of(e.metadata):cr.Xx.empty()}getDocsMetadata(){const e=this.core.find("/");return e&&e.metadata?{indexDocument:e.metadata["website-index-document"]??null,errorDocument:e.metadata["website-error-document"]??null}:{indexDocument:null,errorDocument:null}}async resolveFeed(e,t){const n=this.core.find("/");if(!n||!n.metadata)return cr.Xx.empty();const r=n.metadata["swarm-feed-owner"],o=n.metadata["swarm-feed-topic"];return r&&o?cr.Xx.of(await e.feed.fetchLatestUpdate(o,r,t)):cr.Xx.empty()}async marshal(){return this.core.marshal()}static async unmarshal(e,t,n,r){t=new nn(t);const o=(await e.data.download(t,n,r)).toUint8Array();return this.unmarshalFromData(o,t.toUint8Array())}static unmarshalFromData(e,t){return new Sl(qn.unmarshalFromData(e,t))}addFork(e,t,n){this.core.addFork(e,t instanceof Pt?t.toUint8Array():t,n)}removeFork(e){this.core.removeFork(e)}async calculateSelfAddress(){return this.core.calculateSelfAddress()}async saveRecursively(e,t,n,r){return Al(this.core,e,t,n,r)}async loadRecursively(e,t,n){return kl(this.core,e,t,n)}find(e){return this.core.find(e)}findClosest(e,t){return this.core.findClosest(e,t)}collect(e=[]){return this.core.collect(e)}collectAndMap(){return this.core.collectAndMap()}determineType(){return this.core.determineType()}}var Ol=n(61),$l=n.n(Ol);async function Il(e){if("string"!=typeof e)throw new TypeError("dir has to be string!");if(""===e)throw new TypeError("dir must not be empty string!");return _l(e,"")}async function _l(e,t){const n=$l().join(e,t),r=await zl().promises.opendir(n);let o=[];for await(const i of r){const n=$l().join(e,t,i.name),r=$l().join(t,i.name);i.isFile()?o.push({path:r,size:(await zl().promises.stat(n)).size,fsPath:n}):i.isDirectory()&&(o=[...await _l(e,r),...o])}return o}async function Vl(e){if("string"!=typeof e)throw new TypeError("dir has to be string!");if(""===e)throw new TypeError("dir must not be empty string!");const t=await zl().promises.opendir(e);let n=0;for await(const r of t)if(r.isFile()){n+=(await zl().promises.stat($l().join(e,r.name))).size}else r.isDirectory()&&(n+=await Vl($l().join(e,r.name)));return n}const Dl={aac:"audio/aac",abw:"application/x-abiword",ai:"application/postscript",arc:"application/octet-stream",avi:"video/x-msvideo",azw:"application/vnd.amazon.ebook",bin:"application/octet-stream",bz:"application/x-bzip",bz2:"application/x-bzip2",csh:"application/x-csh",css:"text/css",csv:"text/csv",doc:"application/msword",dll:"application/octet-stream",dmg:"application/x-apple-diskimage",eot:"application/vnd.ms-fontobject",epub:"application/epub+zip",gif:"image/gif",htm:"text/html",html:"text/html",ico:"image/x-icon",ics:"text/calendar",jar:"application/java-archive",jpeg:"image/jpeg",jpg:"image/jpeg",js:"application/javascript",json:"application/json",mid:"audio/midi",midi:"audio/midi",mp2:"audio/mpeg",mp3:"audio/mpeg",mp4:"video/mp4",mpa:"video/mpeg",mpe:"video/mpeg",mpeg:"video/mpeg",mpkg:"application/vnd.apple.installer+xml",odp:"application/vnd.oasis.opendocument.presentation",ods:"application/vnd.oasis.opendocument.spreadsheet",odt:"application/vnd.oasis.opendocument.text",oga:"audio/ogg",ogv:"video/ogg",ogx:"application/ogg",otf:"font/otf",png:"image/png",pdf:"application/pdf",ppt:"application/vnd.ms-powerpoint",rar:"application/x-rar-compressed",rtf:"application/rtf",sh:"application/x-sh",svg:"image/svg+xml",swf:"application/x-shockwave-flash",tar:"application/x-tar",tif:"image/tiff",tiff:"image/tiff",ts:"application/typescript",ttf:"font/ttf",txt:"text/plain",vsd:"application/vnd.visio",wav:"audio/x-wav",weba:"audio/webm",webm:"video/webm",webp:"image/webp",woff:"font/woff",woff2:"font/woff2",xhtml:"application/xhtml+xml",xls:"application/vnd.ms-excel",xlsx:"application/vnd.ms-excel",xml:"application/xml",xul:"application/vnd.mozilla.xul+xml",zip:"application/zip","3gp":"video/3gpp","3gp2":"video/3gpp2","7z":"application/x-7z-compressed"};function Pl(e){return["text/html","text/css"].includes(e)?`${e}; charset=utf-8`:e}function Nl(e){if(!function(e){return!!Array.isArray(e)&&e.every((e=>"object"==typeof e&&e.path&&void 0!==e.size))}(e))throw new nu("invalid collection",e)}function Cl(e){if(e.webkitRelativePath&&""!==e.webkitRelativePath)return e.webkitRelativePath.replace(/.*?\//i,"");if(e.name)return e.name;throw new TypeError("file is not valid File object")}function Fl(e){return Array.from(e).map((e=>({path:Cl(e),size:e.size,file:e})))}function Ml(e){return Array.from(e).reduce(((e,t)=>e+t.size),0)}class Ul{output=new cu.PassThrough;currentFileSize=0;beginFile(e,t){const{name:n,prefix:r,longLink:o}=function(e){if(e.length<=100)return{name:e,prefix:"",longLink:!1};for(let r=e.length-1;r>=0;r--)if("/"===e[r]){const t=e.substring(r+1),n=e.substring(0,r);if(t.length<=100&&n.length<=155)return{name:t,prefix:n,longLink:!1}}const t=e.lastIndexOf("/"),n=(t>=0?e.substring(t+1):e).slice(0,100);return{name:n,prefix:"",longLink:!0}}(e);if(o){const t=Buffer.from(e+"\0");this.output.write(function(e){const t=Buffer.alloc(512,0);t.write("././@LongLink",0,100),t.write("0000644\0",100,8),t.write("0000000\0",108,8),t.write("0000000\0",116,8),t.write(e.toString(8).padStart(11,"0")+"\0",124,12),t.write("00000000000\0",136,12),t.write(" ",148,8),t.write("L",156,1),t.write("ustar\0\0",257,8);let n=0;for(let r=0;r<512;r++)n+=t[r];return t.write(n.toString(8).padStart(6,"0")+"\0 ",148,8),t}(t.length)),this.output.write(t);const n=t.length%512==0?0:512-t.length%512;n>0&&this.output.write(Buffer.alloc(n,0))}const i=function(e,t,n){const r=Buffer.alloc(512,0);r.write(e.slice(0,100).padEnd(100,"\0"),0,100),r.write("0000777\0",100,8),r.write("0001750\0",108,8),r.write("0001750\0",116,8),r.write(n.toString(8).padStart(11,"0")+"\0",124,12);const o=Math.floor((new Date).getTime()/1e3);r.write(o.toString(8).padStart(11,"0")+"\0",136,12),r.write(" ",148,8),r.write("0",156,1),r.write("ustar\0\0",257,8),t&&r.write(t.slice(0,155).padEnd(155,"\0"),345,155);let i=0;for(let s=0;s<512;s++)i+=r[s];return r.write(i.toString(8).padStart(6,"0")+"\0 ",148,8),r}(n,r,t);this.output.write(i),this.currentFileSize=0}async appendFile(e){return new Promise((t=>{this.output.write(e)?t():this.output.once("drain",(()=>{t()})),this.currentFileSize+=e.length}))}async endFile(){const e=this.currentFileSize%512==0?0:512-this.currentFileSize%512;e>0&&this.output.write(Buffer.alloc(e,0))}async end(){return new Promise((e=>{this.output.write(Buffer.alloc(1024,0)),this.output.end((()=>{e()}))}))}}async function Gl(e,t,n,r){const o=new Ul,i=Jc(e,{method:"post",url:"bzz",data:o.output,responseType:"json",headers:{"content-type":"application/x-tar","swarm-collection":"true",...Qu(n,r)}});await async function(e,t){for(const n of e)if(t.beginFile(n.path,n.size),n.fsPath){const e=(0,Rl.createReadStream)(n.fsPath);for await(const n of e)await t.appendFile(n);await t.endFile(),e.close()}else{if(!n.file)throw new Error("Invalid collection item");await t.appendFile(new Uint8Array(await n.file.arrayBuffer())),await t.endFile()}}(t,o),await o.end();return await i}const Ll="bzz";async function jl(e,t,n,r,o){Uu(t)&&!o?.contentType&&(o||(o={}),o.contentType="application/octet-stream");const i=await Jc(e,{method:"post",url:Ll,data:t,headers:Qu(n,o),params:{name:r},responseType:"json"});return{reference:eu.parse(i.data).reference,tagUid:i.headers["swarm-tag"]?ju(i.headers["swarm-tag"]):void 0,historyAddress:i.headers["swarm-act-history-address"]?cr.Xx.of(new nn(i.headers["swarm-act-history-address"])):cr.Xx.empty()}}async function Zl(e,t,n,r){Nl(t);const o=await Gl(e,t,n,r);return{reference:eu.parse(o.data).reference,tagUid:o.headers["swarm-tag"]?ju(o.headers["swarm-tag"]):void 0,historyAddress:o.headers["swarm-act-history-address"]?cr.Xx.of(new nn(o.headers["swarm-act-history-address"])):cr.Xx.empty()}}class ql{constructor(e){this.context=e}async upload(e,t,n,r){const o=new Nt(e);return Nl(t),n&&(n=Iu.parse(n)),Zl(this.context.getRequestOptionsForCall(r),t,o,n)}async uploadFromFileList(e,t,n,r){const o=new Nt(e);n&&(n=Iu.parse(n));const i=Fl(t);return Zl(this.context.getRequestOptionsForCall(r),i,o,n)}async uploadFromDirectory(e,t,n,r){const o=new Nt(e);n&&(n=Iu.parse(n));const i=await Il(t);return Zl(this.context.getRequestOptionsForCall(r),i,o,n)}async stream(e,t,n,r,o){new Nt(e);return async function(){throw new Error("Streaming files is not supported in Node.js")}(this.context.bee,0,0,0,0,this.context.getRequestOptionsForCall(o))}async streamFromDirectory(e,t,n,r,o){const i=new Nt(e);return async function(e,t,n,r,o,i){const s=new cr.O3(64,64);let a=0,c=0;n=new Nt(n);const u=await Il(t);for(const m of u)a+=(l=m.size,function e(t){return t<=1?t:t+e(Math.ceil(t/128))}(Math.ceil(l/4096)));var l;let f=!1;async function h(t){await e.chunk.upload(n,t.build(),o,i),r?.({total:a,processed:++c})}async function d(e){for(const{chunk:t}of e)await s.enqueue((async()=>h(t)));return[]}const p=new Sl;for(const m of u){if(!m.fsPath)throw Error("File does not have fsPath, which should never happen in node. Please report this issue.");const e=(0,Rl.createReadStream)(m.fsPath),t=new An(d);for await(const i of e)await t.append(i);const n=await t.finalize();await s.enqueue((async()=>h(n))),await s.drain();const{filename:r,extension:o}=cr.DH.parseFilename(m.path);p.addFork(m.path,n.hash(),{"Content-Type":Pl(Dl[o.toLowerCase()]||"application/octet-stream"),Filename:r}),"index.html"===m.path&&(f=!0)}if(f||o?.indexDocument||o?.errorDocument){const e={};o?.indexDocument?e["website-index-document"]=o.indexDocument:f&&(e["website-index-document"]="index.html"),o?.errorDocument&&(e["website-error-document"]=o.errorDocument),p.addFork("/",Kh,e)}return p.saveRecursively(e,n,o,i)}(this.context.bee,t,i,n,r,this.context.getRequestOptionsForCall(o))}async hashDirectory(e){return async function(e){const t=await Il(e),n=new Sl;for(const r of t){const e=new An(An.NOOP);if(!r.fsPath)throw Error("File does not have fsPath, which should never happen in node. Please report this issue.");const t=(0,Rl.createReadStream)(r.fsPath);for await(const n of t)await e.append(n);const o=await e.finalize(),{filename:i,extension:s}=cr.DH.parseFilename(r.path);n.addFork(r.path,o.hash(),{"Content-Type":Pl(Dl[s.toLowerCase()]||"application/octet-stream"),Filename:i})}return n.calculateSelfAddress()}(e)}}const Hl=wc({address:Va(),fullNode:sc()}),Wl=wc({population:nc(),connected:nc(),connectedPeers:gc(wc({address:Va()})).nullish().transform((e=>e??[])),disconnectedPeers:gc(wc({address:Va()})).nullish().transform((e=>e??[]))}),Jl=Rc(Va(),Wl),Kl=wc({overlay:Va().transform((e=>new qt(e))),underlay:gc(Va()),ethereum:Va().transform((e=>new Ut(e))),publicKey:Va().transform((e=>new Jt(e))),pssPublicKey:Va().transform((e=>new Jt(e)))}),Xl=wc({peers:gc(Hl)}),Yl=wc({peers:gc(Hl)}),Ql=wc({baseAddr:Va(),population:nc(),connected:nc(),timestamp:Va(),nnLowWatermark:nc(),depth:nc(),reachability:Va(),networkAvailability:Va(),bins:Jl}),ef=wc({overlay:Va(),proximity:nc(),beeMode:Va().transform(hu),reserveSize:nc(),reserveSizeWithinRadius:nc(),pullsyncRate:nc(),storageRadius:nc(),connectedPeers:nc(),neighborhoodSize:nc(),batchCommitment:nc(),isReachable:sc(),lastSyncedBlock:nc(),committedDepth:nc(),isWarmingUp:sc()}),tf=wc({apiVersion:Va(),version:Va(),status:(nf="ok",new kc({type:"literal",values:Array.isArray(nf)?nf:[nf],...io(rf)}))});var nf,rf;const of=wc({apiVersion:Va(),version:Va(),status:Ac(["ready","notReady"])}),sf=wc({beeMode:Va().transform(hu),chequebookEnabled:sc(),swapEnabled:sc()}),af=wc({gateway:sc()}),cf="peers";class uf{constructor(e){this.context=e}async checkConnection(e){return async function(e){await Jc(e,{url:"",responseType:"text"})}(this.context.getRequestOptionsForCall(e))}async isConnected(e){try{await this.checkConnection(e)}catch{return!1}return!0}async isGateway(e){try{return await async function(e){const t=await Jc(e,{url:"/gateway"});return af.parse(t.data).gateway}(this.context.getRequestOptionsForCall(e))}catch{return!1}}async getNodeAddresses(e){return async function(e){const t=await Jc(e,{url:"addresses",responseType:"json"});return Kl.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async getBlocklist(e){return async function(e){const t=await Jc(e,{url:"blocklist",responseType:"json"});return Yl.parse(t.data).peers}(this.context.getRequestOptionsForCall(e))}async getPeers(e){return async function(e){const t=await Jc(e,{url:cf,responseType:"json"});return Xl.parse(t.data).peers}(this.context.getRequestOptionsForCall(e))}async removePeer(e,t){const n=new qt(e);return async function(e,t){return(await Jc(e,{url:`${cf}/${t}`,responseType:"json",method:"DELETE"})).data}(this.context.getRequestOptionsForCall(t),n)}async getTopology(e){return async function(e){const t=await Jc(e,{url:"topology",responseType:"json"});return Ql.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async ping(e,t){const n=new qt(e);return async function(e,t){return(await Jc(e,{url:`pingpong/${t}`,responseType:"json",method:"POST"})).data}(this.context.getRequestOptionsForCall(t),n)}}const lf="bytes";async function ff(e,t,n,r){const o=await Jc(e,{url:lf,method:"post",responseType:"json",data:t,headers:{"content-type":"application/octet-stream",...Qu(n,r)}});return{reference:eu.parse(o.data).reference,tagUid:o.headers["swarm-tag"]?ju(o.headers["swarm-tag"]):void 0,historyAddress:o.headers["swarm-act-history-address"]?cr.Xx.of(new nn(o.headers["swarm-act-history-address"])):cr.Xx.empty()}}async function hf(e,t,n){n&&(n=ku.parse(n));const r=await Jc(e,{responseType:"arraybuffer",url:`${lf}/${t}`,headers:Qu(null,n)});return new Pt(r.data)}const df=wc({isRetrievable:sc()}),pf="stewardship";class mf{constructor(e){this.raw=e}toString(){const e=Va().safeParse(this.raw);return e.success&&e.data.includes(".eth")?e.data:new nn(this.raw).toHex()}}class gf{constructor(e){this.context=e}async upload(e,t,n,r){const o=new Nt(e);return Lu(t),n&&(n=Ou.parse(n)),ff(this.context.getRequestOptionsForCall(r),t,o,n)}async download(e,t,n){return t&&(t=ku.parse(t)),hf(this.context.getRequestOptionsForCall(n),new mf(e),t)}async downloadReadable(e,t,n){return t&&(t=ku.parse(t)),async function(e,t,n){return n&&(n=ku.parse(n)),(await Jc(e,{responseType:"stream",url:`${lf}/${t}`,headers:Qu(null,n)})).data}(this.context.getRequestOptionsForCall(n),new mf(e),t)}async probe(e,t){const n=new nn(e);return async function(e,t){const n=await Jc(e,{url:`${lf}/${t}`,method:"head",responseType:"json"});return{contentLength:parseInt(n.headers["content-length"])}}(this.context.getRequestOptionsForCall(t),n)}async isRetrievable(e,t){const n=new nn(e);return async function(e,t){const n=await Jc(e,{method:"get",responseType:"json",url:`${pf}/${t}`});return df.parse(n.data).isRetrievable}(this.context.getRequestOptionsForCall(t),n)}}const yf="feeds";function wf(e){const t=e["swarm-feed-index"],n=e["swarm-feed-index-next"];if(!t)throw new tu("Response did not contain expected swarm-feed-index!");if(!n)throw new tu("Response did not contain expected swarm-feed-index-next!");return{feedIndex:new Lt(t),feedIndexNext:new Lt(n)}}async function bf(e,t,n,r){const o=await Jc(e,{responseType:"arraybuffer",url:`${yf}/${t}/${n}`,params:{...r}});return{payload:new Pt(o.data),...wf(o.headers)}}async function vf(e,t,n){return wf((await Jc(e,{responseType:"arraybuffer",url:`${yf}/${t}/${n}`,params:{"Swarm-Only-Root-Chunk":!0}})).headers)}function Bf(e,t){return t="number"==typeof t?Lt.fromBigInt(BigInt(t)):t,new Zt(Ot(Pt.concat(e.toUint8Array(),t.toUint8Array())))}async function Ef(e,t,n){try{const r=await bf(e,t,n);if(!r.feedIndexNext)throw Error("Feed index next is not defined. This should happen when fetching an exact index.");return r.feedIndexNext}catch(r){if(r instanceof ru)return Lt.fromBigInt(0n);throw r}}async function xf(e,t,n,r,o,i){r=new nn(r);const s=Bf(n,i?.index??await Ef(e,t.publicKey().address(),n)),a=i?.at??Date.now()/1e3,c=At(BigInt(Math.floor(a)),"BE");return ol(e,t,o,s,Pt.concat(c,r.toUint8Array()),i)}async function Tf(e,t,n,r,o,i){const s=Bf(n,i?.index??await Ef(e,t.publicKey().address(),n));if(r.length>4096){const n=await ff(e,r,o,i);return il(e,t,o,s,Rn(await tl(e,n.reference)),i)}const a=Va().safeParse(r);return ol(e,t,o,s,a.success?Pt.fromUtf8(a.data).toUint8Array():r,i)}function Rf(e,t,n){const r=Bf(t,n);return new nn(Ot(Pt.concat(r.toUint8Array(),e.toUint8Array())))}async function zf(e,t,n,r,o=!1){const i=Rf(t,n,r="number"==typeof r?Lt.fromBigInt(BigInt(r)):r),s=nl(await tl(e,i.toHex()),i);let a=cr.Xx.empty();if(o){const e=Pt.fromSlice(s.payload.toUint8Array(),0,8);a=cr.Xx.of(Number(kt(e.toUint8Array(),"BE")))}return{timestamp:a,payload:new Pt(s.payload.offset(o?8:0))}}async function Af(e,t,n,r){const o=Rf(t,n,r="number"==typeof r?Lt.fromBigInt(BigInt(r)):r),i=nl(await tl(e,o),o);return Tn(i.payload,i.span)}function kf(e,t,n){const r=async r=>{if(void 0===r?.index)return bf(e,n,t);const o=await zf(e,n,t,r.index,r.hasTimestamp??!0),i="number"==typeof r.index?Lt.fromBigInt(BigInt(r.index)):r.index;return{payload:o.payload,feedIndex:i,feedIndexNext:i.next()}};return{download:r,downloadPayload:async r=>{if(void 0===r?.index)return bf(e,n,t);const o=await Af(e,n,t,r.index),i=o.span.toBigInt()<=4096n?o.payload:await hf(e,new mf(o.address)),s="number"==typeof r.index?Lt.fromBigInt(BigInt(r.index)):r.index;return{payload:i,feedIndex:s,feedIndexNext:s.next()}},downloadReference:async o=>{let i=o?.index;void 0===i&&(i=(await vf(e,n,t)).feedIndex);const s=await r({...o,index:i});return{reference:new nn(s.payload.toUint8Array()),feedIndex:s.feedIndex,feedIndexNext:s.feedIndexNext??s.feedIndex.next()}},owner:n,topic:t}}async function Sf(e,t,n,r,o,i){const s=function(e,t,n){const r=n.toBigInt(),o=[];for(let i=0n;i<=r;i++)o.push(Rf(e,t,Lt.fromBigInt(i)));return o}(t,n,r).map((async t=>async function(e,t,n,r){try{return await e.chunk.download(t,n,r),!0}catch(o){const e=cr.Rb.getDeep(o,"status");if(404===e||500===e)return!1;throw o}}(e,t,o,i)));return(await Promise.all(s)).every((e=>e))}class Of{constructor(e){this.context=e}makeReader(e,t,n){return kf(this.context.getRequestOptionsForCall(n),new sn(e),new Ut(t))}makeWriter(e,t,n){const r=t?new en(t):this.context.signer;if(!r)throw Error("No signer provided");return function(e,t,n){const r=async(r,o,i)=>xf(e,n,t,o,r,i);return{...kf(e,t,n.publicKey().address()),upload:r,uploadReference:r,uploadPayload:async(r,o,i)=>Tf(e,n,t,o,r,i)}}(this.context.getRequestOptionsForCall(n),new sn(e),r)}async createManifest(e,t,n,r,o){const i=new Nt(e),s=new sn(t),a=new Ut(n);return r&&(r=Su.parse(r)),async function(e,t,n,r,o){const i=await Jc(e,{method:"post",responseType:"json",url:`${yf}/${t}/${n}`,headers:Qu(r,o)});return eu.parse(i.data).reference}(this.context.getRequestOptionsForCall(o),a,s,i,r)}async fetchLatestUpdate(e,t,n){return bf(this.context.getRequestOptionsForCall(n),new Ut(t),new sn(e))}async isRetrievable(e,t,n,r,o){const i=new Ut(e),s=new sn(t);if(r&&(r=ku.parse(r)),!n)try{return await this.makeReader(s,i,o).download(),!0}catch(a){const e=cr.Rb.getDeep(a,"status");if(404===e||500===e)return!1;throw a}return Sf(this.context.bee,i,s,n,r,this.context.getRequestOptionsForCall(o))}}class $f{constructor(e){this.context=e}async upload(e,t,n,r,o){const i=new Nt(e);if(function(e){if(!("string"==typeof e||e instanceof Uint8Array||uu(e)||Uu(e)))throw new TypeError("Data must be either string, Readable, Uint8Array or File!")}(t),r&&(r=$u.parse(r)),n&&"string"!=typeof n)throw new TypeError("name has to be string or undefined!");if(uu(t)){const e=await async function(e){return e.arrayBuffer?e.arrayBuffer():new Promise((t=>{const n=new FileReader;n.onload=()=>t(n.result),n.readAsArrayBuffer(e)}))}(t),s=n??t.name,a=t.type,c={...r,contentType:a};return jl(this.context.getRequestOptionsForCall(o),e,i,s,c)}return jl(this.context.getRequestOptionsForCall(o),t,i,n,r)}async download(e,t="",n,r){return n&&(n=ku.parse(n)),async function(e,t,n="",r){const o=await Jc(e,{method:"GET",responseType:"arraybuffer",url:`${Ll}/${t}/${n}`,headers:Qu(null,r)});return{...Yu(o.headers),data:new Pt(o.data)}}(this.context.getRequestOptionsForCall(r),new mf(e),t,n)}async downloadReadable(e,t="",n,r){const o=new nn(e);return n&&(n=ku.parse(n)),async function(e,t,n="",r){t=new nn(t);const o=await Jc(e,{method:"GET",responseType:"stream",url:`${Ll}/${t}/${n}`,headers:Qu(null,r)});return{...Yu(o.headers),data:o.data}}(this.context.getRequestOptionsForCall(r),o,t,n)}}const If=gc(Va().transform((e=>new Jt(e)))),_f=wc({ref:Va().transform((e=>new nn(e))),historyref:Va().transform((e=>new nn(e)))}),Vf="grantee";class Df{constructor(e){this.context=e}async create(e,t,n){const r=new Nt(e),o=t.map((e=>new Jt(e)));return async function(e,t,n){const r=await Jc(e,{method:"post",url:Vf,data:{grantees:n.map((e=>e.toCompressedHex()))},headers:Qu(t),responseType:"json"}),o=_f.parse(r.data);return{status:r.status,statusText:r.statusText,ref:o.ref,historyref:o.historyref}}(this.context.getRequestOptionsForCall(n),r,o)}async get(e,t){const n=new nn(e);return async function(e,t){const n=await Jc(e,{method:"get",url:`${Vf}/${t}`,responseType:"json"});return{status:n.status,statusText:n.statusText,grantees:If.parse(n.data)}}(this.context.getRequestOptionsForCall(t),n)}async patch(e,t,n,r,o){const i=new Nt(e),s=new nn(t),a=new nn(n),c={add:r.add?.map((e=>new Jt(e)))??[],revoke:r.revoke?.map((e=>new Jt(e)))??[]};return async function(e,t,n,r,o){const i=await Jc(e,{method:"patch",url:`${Vf}/${n}`,data:{add:o.add.map((e=>e.toCompressedHex())),revoke:o.revoke.map((e=>e.toCompressedHex()))},headers:{...Qu(t),"swarm-act-history-address":r.toHex()},responseType:"json"}),s=_f.parse(i.data);return{status:i.status,statusText:i.statusText,ref:s.ref,historyref:s.historyref}}(this.context.getRequestOptionsForCall(o),i,s,a,c)}}var Pf=null;"undefined"!=typeof WebSocket?Pf=WebSocket:"undefined"!=typeof MozWebSocket?Pf=MozWebSocket:void 0!==n.g?Pf=n.g.WebSocket||n.g.MozWebSocket:"undefined"!=typeof window?Pf=window.WebSocket||window.MozWebSocket:"undefined"!=typeof self&&(Pf=self.WebSocket||self.MozWebSocket);const Nf=Pf;async function Cf(e){if("string"==typeof e)return(new TextEncoder).encode(e);if(e instanceof Buffer)return new Uint8Array(e);if(e instanceof ArrayBuffer)return new Uint8Array(e);if(t=e,Array.isArray(t)&&t.length>0&&t.every((e=>e instanceof Buffer)))return new Uint8Array(Buffer.concat(e));var t;throw new TypeError("unknown websocket data type")}class Ff{constructor(e){this.context=e}async pssSend(e,t,n,r,o,i){const s=new Nt(e);Lu(r);const a=o?new Jt(o):void 0;await async function(e,t,n,r,o,i){await Jc(e,{method:"post",url:`pss/send/${n}/${r}`,data:o,responseType:"json",params:{recipient:i},headers:Qu(t)})}(this.context.getRequestOptionsForCall(i),s,t,n,r,a)}pssSubscribe(e,t){t=Du.parse(t);const n=this.openWebSocket(`pss/subscribe/${e.toHex()}`),r={topic:e,cancel:this.makeCancel(n)};return n.onmessage=async e=>{const n=await Cf(e.data);n.length&&t.onMessage(new Pt(n),r)},n.onerror=e=>{this.isCancelled(n)||t.onError(new tu(e.message),r)},n.onclose=()=>{t.onClose(r)},r}async pssReceive(e,t=0){if("number"!=typeof t)throw new TypeError("timeoutMsc parameter has to be a number!");return new Promise(((n,r)=>{let o;const i=this.pssSubscribe(e,{onError:e=>{clearTimeout(o),i.cancel(),r(e.message)},onMessage:e=>{clearTimeout(o),i.cancel(),n(e)},onClose:()=>{clearTimeout(o),i.cancel()}});t>0&&(o=setTimeout((()=>{i.cancel(),r(new tu("pssReceive timeout"))}),t))}))}gsocMine(e,t,n=12){const r=new qt(e),o=new Zt(t);for(let i=0n;i<0xffffn;i++){const e=new en(mt(2867n+i,"BE")),t=Bn(o,e.publicKey().address());if(256-cr.yI.proximity(t.toUint8Array(),r.toUint8Array())<=256-n)return e}throw Error("Could not mine a valid signer")}async gsocSend(e,t,n,r,o,i){const s=new Nt(e),a=new en(t),c=new Zt(n),u=Tn(r).toSingleOwnerChunk(c,a);return rl(this.context.getRequestOptionsForCall(i),u,s,o)}gsocSubscribe(e,t,n,r){const o=new Ut(e),i=new Zt(t);n=Pu.parse(n);const{fields:s,cacheWrappedChunk:a}=Nu.parse(r??{}),c=new URLSearchParams;s&&c.set("swarm-soc-fields",s.join(",")),void 0!==a&&c.set("swarm-cache-wrapped-chunk",String(a));const u=Bn(i,o),l=c.toString()?`?${c.toString()}`:"",f=this.openWebSocket(`gsoc/subscribe/${u.toHex()}${l}`),h={address:o,cancel:this.makeCancel(f)};return f.onmessage=async e=>{const t=await Cf(e.data);t.length&&n.onMessage(new Pt(t),h)},f.onerror=e=>{this.isCancelled(f)||n.onError(new tu(e.message),h)},f.onclose=()=>{n.onClose(h)},h}openWebSocket(e){const t=this.context.url.replace(/^http/i,"ws");return"browser"===cr.iQ.whereAmI()?new Nf(`${t}/${e}`):new Nf(`${t}/${e}`,{headers:this.context.getRequestOptionsForCall().headers})}cancelled=new WeakSet;makeCancel(e){return()=>{this.cancelled.has(e)||(this.cancelled.add(e),e.terminate?e.terminate():e.close())}}isCancelled(e){return this.cancelled.has(e)}}const Mf=wc({references:gc(Va()).nullable()}),Uf="pins";class Gf{constructor(e){this.context=e}async add(e,t){const n=new nn(e);await async function(e,t){await Jc(e,{method:"post",responseType:"json",url:`${Uf}/${t}`})}(this.context.getRequestOptionsForCall(t),n)}async remove(e,t){const n=new nn(e);await async function(e,t){await Jc(e,{method:"delete",responseType:"json",url:`${Uf}/${t}`})}(this.context.getRequestOptionsForCall(t),n)}async getAll(e){return async function(e){const t=await Jc(e,{method:"get",responseType:"json",url:Uf}),{references:n}=Mf.parse(t.data);return(n??[]).map((e=>new nn(e)))}(this.context.getRequestOptionsForCall(e))}async get(e,t){const n=new nn(e);return async function(e,t){const n=await Jc(e,{method:"get",responseType:"json",url:`${Uf}/${t}`});return eu.parse(n.data)}(this.context.getRequestOptionsForCall(t),n)}async reuploadData(e,t,n){const r=new Nt(e),o=new nn(t);await async function(e,t,n){await Jc(e,{method:"put",url:`${pf}/${n}`,headers:{"swarm-postage-batch-id":t.toHex()}})}(this.context.getRequestOptionsForCall(n),r,o)}}function Lf(e,t){if(t<=0)throw new tu("Period length must be greater than zero!");return Math.floor(e/t)}function jf(e,t){const n=e.toUint8Array();return new sn(Ot(Pt.concat(n,At(BigInt(t),"BE"))))}async function Zf(e,t,n){try{return await vf(e,t,n),!0}catch(r){if(r instanceof ru)return!1;throw r}}async function qf(e,t,n){const{feedIndex:r}=await vf(e,t,n),o=await zf(e,t,n,r,!0);return{reference:new nn(o.payload.toUint8Array()),feedIndex:r,feedIndexNext:r.next()}}class Hf{constructor(e){this.context=e}makeWriter(e,t,n){return new Wf(this.context,e,t,n)}makeReader(e,t,n){return new Jf(this.context,e,t,n)}}class Wf{constructor(e,t,n,r){this.context=e,this.baseTopic=t,this.signer=n,this.periodLength=r}async uploadPayload(e,t,n){const r=this.context.getRequestOptionsForCall(),o=new Nt(e),{currentTopic:i,nextTopic:s,mirrorOptions:a}=this.currentAndNextTopics(n),[c]=await Promise.all([Tf(r,this.signer,i,t,o,n),Tf(r,this.signer,s,t,o,a)]);return c}async uploadReference(e,t,n){const r=this.context.getRequestOptionsForCall(),o=new Nt(e),{currentTopic:i,nextTopic:s,mirrorOptions:a}=this.currentAndNextTopics(n),[c]=await Promise.all([xf(r,this.signer,i,t,o,n),xf(r,this.signer,s,t,o,a)]);return c}async isCaughtUp(e){const t=this.context.getRequestOptionsForCall(),n=e??Lf(Date.now()/1e3,this.periodLength);return Zf(t,this.signer.publicKey().address(),jf(this.baseTopic,n))}async catchUp(e,t,n=1){const r=this.context.getRequestOptionsForCall(),o=new Nt(e),i=this.signer.publicKey().address(),s=t??Lf(Date.now()/1e3,this.periodLength),a=Math.max(0,s-1-n);let c=s-1;for(;c>=a&&!await Zf(r,i,jf(this.baseTopic,c));)c--;if(c<a)throw new tu(`No populated period found within ${n} periods to catch up from!`);if(c===s-1)return;const u=jf(this.baseTopic,c),{feedIndex:l}=await vf(r,i,u),f=await Af(r,i,u,l),h=Array.from({length:s-1-c},((e,t)=>c+1+t));await Promise.all(h.map((async e=>{const t=Bf(jf(this.baseTopic,e),0);return il(r,this.signer,o,t,f)})))}currentAndNextTopics(e){const t=Lf(Date.now()/1e3,this.periodLength);return{currentTopic:jf(this.baseTopic,t),nextTopic:jf(this.baseTopic,t+1),mirrorOptions:{...e,index:void 0}}}}class Jf{constructor(e,t,n,r){this.context=e,this.baseTopic=t,this.owner=n,this.periodLength=r}async downloadPayload(e){const t=this.context.getRequestOptionsForCall(),n=Lf(Date.now()/1e3,this.periodLength);try{return await bf(t,this.owner,jf(this.baseTopic,n),e)}catch(r){if(!(r instanceof ru))throw r;return bf(t,this.owner,jf(this.baseTopic,n-1),e)}}async downloadReference(){const e=this.context.getRequestOptionsForCall(),t=Lf(Date.now()/1e3,this.periodLength);try{return await qf(e,this.owner,jf(this.baseTopic,t))}catch(n){if(!(n instanceof ru))throw n;return qf(e,this.owner,jf(this.baseTopic,t-1))}}}const Kf=wc({peer:Va(),sent:Va().transform((e=>su.fromPLUR(Gu(e,{name:"sent"})))),received:Va().transform((e=>su.fromPLUR(Gu(e,{name:"received"}))))}),Xf=Kf,Yf=wc({totalSent:Va().transform((e=>su.fromPLUR(Gu(e,{name:"totalSent"})))),totalReceived:Va().transform((e=>su.fromPLUR(Gu(e,{name:"totalReceived"})))),settlements:gc(Kf)}),Qf="settlements";class eh{constructor(e){this.context=e}async get(e,t){const n=new qt(e);return async function(e,t){const n=await Jc(e,{url:`${Qf}/${t}`,responseType:"json"});return Xf.parse(n.data)}(this.context.getRequestOptionsForCall(t),n)}async getAll(e){return async function(e){const t=await Jc(e,{url:Qf,responseType:"json"});return Yf.parse(t.data)}(this.context.getRequestOptionsForCall(e))}}class th{constructor(e){this.context=e}makeReader(e,t){const n=new Ut(e);return{owner:n,download:sl.bind(null,this.context.getRequestOptionsForCall(t),n)}}makeWriter(e,t){const n=e?new en(e):this.context.signer;if(!n)throw Error("No signer provided");return{...this.makeReader(n.publicKey().address(),t),upload:ol.bind(null,this.context.getRequestOptionsForCall(t),n)}}}const nh=wc({stakedAmount:Va().transform((e=>su.fromPLUR(Gu(e,{name:"stakedAmount"})))),minimumDeposit:Va().nullish().transform((e=>e?su.fromPLUR(Gu(e,{name:"minimumDeposit"})):null))}),rh=wc({withdrawableAmount:Va().transform((e=>su.fromPLUR(Gu(e,{name:"withdrawableAmount"}))))}),oh=wc({txHash:Va().transform((e=>new an(e)))}),ih=wc({minimumGasFunds:Va().transform((e=>au.fromWei(Gu(e,{name:"minimumGasFunds"})))),hasSufficientFunds:sc(),isFrozen:sc(),isFullySynced:sc(),phase:Va(),round:nc(),lastWonRound:nc(),lastPlayedRound:nc(),lastFrozenRound:nc(),lastSelectedRound:nc(),lastSampleDurationSeconds:nc(),block:nc(),reward:Va().transform((e=>su.fromPLUR(Gu(e,{name:"reward"})))),fees:Va().transform((e=>au.fromWei(Gu(e,{name:"fees"})))),isHealthy:sc(),enabled:sc(),hasCommittedThisRound:sc(),hasRevealedThisRound:sc()}),sh=wc({enabled:sc()}),ah="stake";async function ch(e){const t=await Jc(e,{method:"get",responseType:"json",url:ah});return nh.parse(t.data)}const uh="redistributionstate";class lh{constructor(e){this.context=e}async get(e){const{stakedAmount:t}=await ch(this.context.getRequestOptionsForCall(e));return t}async getMinimumDeposit(e){const{minimumDeposit:t}=await ch(this.context.getRequestOptionsForCall(e));return t}async getWithdrawable(e){return async function(e){const t=await Jc(e,{method:"get",responseType:"json",url:`${ah}/withdrawable`});return rh.parse(t.data).withdrawableAmount}(this.context.getRequestOptionsForCall(e))}async deposit(e,t,n){const r=e instanceof su?e.toPLURString():Gu(e,{min:1n,name:"amount"});return t&&(t=Fu.parse(t)),async function(e,t,n){const r=await Jc(e,{method:"post",responseType:"json",url:`${ah}/${t}`,headers:Qu(null,n)});return oh.parse(r.data).txHash}(this.context.getRequestOptionsForCall(n),r,t)}async withdrawSurplus(e){return async function(e){const t=await Jc(e,{method:"delete",responseType:"json",url:`${ah}/withdrawable`});return oh.parse(t.data).txHash}(this.context.getRequestOptionsForCall(e))}async migrate(e){return async function(e){const t=await Jc(e,{method:"delete",responseType:"json",url:ah});return oh.parse(t.data).txHash}(this.context.getRequestOptionsForCall(e))}async getRedistributionState(e){return async function(e){const t=await Jc(e,{method:"get",responseType:"json",url:uh});return ih.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async setRedistributionEnabled(e,t){return async function(e,t){const n=await Jc(e,{method:"patch",responseType:"json",url:uh,data:{enabled:t}});return sh.parse(n.data).enabled}(this.context.getRequestOptionsForCall(t),sc().parse(e))}}const fh=wc({batchID:Va(),utilization:nc(),utilizationRatio:nc().optional(),usable:sc(),label:Va(),depth:nc(),amount:Va(),bucketDepth:nc(),blockNumber:nc(),immutableFlag:sc(),batchTTL:nc()}),hh=wc({batchID:Va().transform((e=>new Nt(e))),batchTTL:nc(),bucketDepth:nc(),depth:nc(),immutable:sc(),owner:Va().transform((e=>new Ut(e))),start:nc(),value:Va().transform((e=>Gu(e,{name:"value"})))}),dh=wc({batches:gc(hh)}),ph=wc({stamps:gc(fh)}),mh=fh,gh=wc({depth:nc(),bucketDepth:nc(),bucketUpperBound:nc(),buckets:gc(wc({bucketID:nc(),collisions:nc()}))}),yh=wc({batchID:Va().transform((e=>new Nt(e)))}),wh="stamps";const bh="batches";class vh{constructor(e){this.context=e}async create(e,t,n,r){const o=Gu(e,{min:0n,name:"amount"});if(n&&(n=Cu.parse(n)),t<yu||t>wu)throw new nu(`Depth has to be between ${yu}..${wu}`,t);const i=await this.context.bee.status.getChainState(),s=17280n*BigInt(i.currentPrice)+1n;if(BigInt(o)<s)throw new nu(`Amount has to be at least ${s} (1 day at current price ${i.currentPrice})`,o);const a=await async function(e,t,n,r,o,i){const s={};o&&(s["gas-price"]=o),void 0!==i&&(s.immutable=String(i));const a=await Jc(e,{method:"post",url:`${wh}/${t}/${n}`,responseType:"json",params:{label:r},headers:s});return yh.parse(a.data).batchID}(this.context.getRequestOptionsForCall(r),o,t,n?.label,n?.gasPrice?.toString(),n?.immutableFlag);return!1!==n?.waitForUsable&&await this.waitForUsable(a,n?.waitForUsableTimeout),a}async updateLabel(e,t,n){const r=new Nt(e);await async function(e,t,n){await Jc(e,{method:"patch",url:`${wh}/${t}`,responseType:"json",data:{label:n}})}(this.context.getRequestOptionsForCall(n),r,t)}async calculateTopUpForBZZ(e,t,n){const r=await this.context.bee.status.getChainState(n),o="gnosis"===this.context.network?5:15,i=t.toPLURBigInt()/2n**BigInt(e);return{amount:i,duration:qu(i,r.currentPrice,o)}}async topUp(e,t,n){const r=new Nt(e),o=Gu(t,{min:1n,name:"amount"});return async function(e,t,n){const r=await Jc(e,{method:"patch",url:`${wh}/topup/${t}/${n}`,responseType:"json"});return yh.parse(r.data).batchID}(this.context.getRequestOptionsForCall(n),r,o)}async dilute(e,t,n){const r=new Nt(e),o=nc().int().min(18).max(255).parse(t);return async function(e,t,n){const r=await Jc(e,{method:"patch",url:`${wh}/dilute/${t}/${n}`,responseType:"json"});return yh.parse(r.data).batchID}(this.context.getRequestOptionsForCall(n),r,o)}async get(e,t,n,r){const o=new Nt(e);return async function(e,t,n,r){const o=await Jc(e,{method:"get",url:`${wh}/${t}`,responseType:"json"});return Ku(mh.parse(o.data),n,r)}(this.context.getRequestOptionsForCall(t),o,n,r)}async getGlobal(e,t){const n=new Nt(e);return async function(e,t){const n=await Jc(e,{method:"get",url:`${bh}/${t}`,responseType:"json"});return hh.parse(n.data)}(this.context.getRequestOptionsForCall(t),n)}async getBuckets(e,t){const n=new Nt(e);return async function(e,t){const n=await Jc(e,{method:"get",url:`${wh}/${t}/buckets`,responseType:"json"});return gh.parse(n.data)}(this.context.getRequestOptionsForCall(t),n)}async getAll(e){return async function(e){const t=await Jc(e,{method:"get",url:wh,responseType:"json"});return ph.parse(t.data).stamps.map((e=>Ku(e)))}(this.context.getRequestOptionsForCall(e))}async getAllGlobal(e){return async function(e){const t=await Jc(e,{method:"get",url:bh,responseType:"json"});return dh.parse(t.data).batches}(this.context.getRequestOptionsForCall(e))}async waitForUsable(e,t=24e4){for(let n=0;n<t;n+=3e3){try{if((await this.get(e)).usable)return}catch{}await cr.iQ.sleepMillis(3e3)}throw new tu("Timeout on waiting for postage stamp to become usable")}}var Bh=n(359),Eh=n.n(Bh);const xh="2.8.3",Th=xh.split("-")[0],Rh="8.2.0",zh=wc({commitment:nc(),radius:nc(),storageRadius:nc(),reserveCapacityDoubling:nc()}),Ah=wc({block:nc(),chainTip:nc(),totalAmount:Va().transform((e=>Gu(e,{name:"totalAmount"}))),currentPrice:Va().transform(Number).transform((e=>{return t=e,Number.isInteger(t)?t<24e3?24e3:t:24e3;var t})),minimumValidityBlocks:nc().optional()}),kh=wc({bzzBalance:Va().transform((e=>su.fromPLUR(Gu(e,{name:"bzzBalance"})))),nativeTokenBalance:Va().transform((e=>au.fromWei(Gu(e,{name:"nativeTokenBalance"})))),chainID:nc(),chequebookContractAddress:Va(),walletAddress:Va()}),Sh=wc({transactionHash:Va().transform((e=>new an(e)))});class Oh{constructor(e){this.context=e}async get(e){return async function(e){const t=await Jc(e,{method:"get",url:"status",responseType:"json"});return ef.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async getHealth(e){return async function(e){const t=await Jc(e,{method:"get",url:"health",responseType:"json"});return tf.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async getReadiness(e){return async function(e){const t=await Jc(e,{method:"get",url:"readiness"});return of.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async getNodeInfo(e){return async function(e){const t=await Jc(e,{method:"get",url:"node",responseType:"json"});return sf.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async isSupportedExactVersion(e){const{version:t}=await this.getHealth(e);return t===xh}async isSupportedApiVersion(e){const{apiVersion:t}=await this.getHealth(e);return Eh()(t)===Eh()(Rh)}async getVersions(e){const{version:t,apiVersion:n}=await this.getHealth(e);return{supportedBeeVersion:xh,supportedBeeApiVersion:Rh,beeVersion:t,beeApiVersion:n}}async getReserveState(e){return async function(e){const t=await Jc(e,{method:"get",url:"reservestate",responseType:"json"});return zh.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async getChainState(e){return async function(e){const t=await Jc(e,{method:"get",url:"chainstate",responseType:"json"});return Ah.parse(t.data)}(this.context.getRequestOptionsForCall(e))}}class $h{constructor(e){this.context=e}get blockTime(){return"gnosis"===this.context.network?5:15}async buy(e,t,n,r,o,i){const s=Hu(t,(await this.context.bee.status.getChainState(r)).currentPrice,this.blockTime),a=Wu(e,o,i);return n&&(n=Cu.parse(n)),this.context.bee.stamp.create(s,a,n,r)}async getCost(e,t,n,r,o){const i=Hu(t,(await this.context.bee.status.getChainState(n)).currentPrice,this.blockTime);return Zu(Wu(e,r,o),i)}async extend(e,t,n,r,o,i){const s=await this.context.bee.stamp.get(e,r),a=Wu(t,o,i),c=await this.context.bee.status.getChainState(r),u=a-s.depth,l=u<=0?1n:2n**BigInt(u),f=Hu(n,c.currentPrice,this.blockTime),h=Hu(s.duration,c.currentPrice,this.blockTime),d=(n.isZero()?h*l:(h+f)*l)-h;let p;if(d>0n&&(p=await this.context.bee.stamp.topUp(s.batchID,d,r)),u>0)return this.context.bee.stamp.dilute(s.batchID,a,r);if(!p)throw new Error("Nothing to extend, both size and duration are already sufficient");return p}async extendSize(e,t,n,r,o){const i=await this.context.bee.status.getChainState(n),s=await this.context.bee.stamp.get(e,n),a=Wu(t,r,o),c=a-s.depth;if(c<=0)throw new nu("New depth has to be greater than the original depth",a);const u=Hu(s.duration,i.currentPrice,this.blockTime);return await this.context.bee.stamp.topUp(s.batchID,u*(2n**BigInt(c)-1n)+1n,n),this.context.bee.stamp.dilute(s.batchID,a,n)}async extendDuration(e,t,n){const r=await this.context.bee.stamp.get(e,n),o=Hu(t,(await this.context.bee.status.getChainState(n)).currentPrice,this.blockTime);return this.context.bee.stamp.topUp(r.batchID,o,n)}async getExtensionCost(e,t,n,r,o,i){const s=await this.context.bee.stamp.get(e,r),a=await this.context.bee.status.getChainState(r),c=n.isZero()?0n:Hu(n,a.currentPrice,this.blockTime),u=Wu(t,o,i),l=Hu(s.duration,a.currentPrice,this.blockTime),f=Zu(s.depth,l);return Zu(Math.max(s.depth,u),l+c).minus(f)}async getSizeExtensionCost(e,t,n,r,o){const i=await this.context.bee.stamp.get(e,n),s=await this.context.bee.status.getChainState(n),a=Wu(t,r,o);if(a-i.depth<=0)throw new nu("New depth has to be greater than the original depth",a);const c=Hu(i.duration,s.currentPrice,this.blockTime),u=Zu(i.depth,c);return Zu(a,c).minus(u)}async getDurationExtensionCost(e,t,n){const r=await this.context.bee.stamp.get(e,n),o=Hu(t,(await this.context.bee.status.getChainState(n)).currentPrice,this.blockTime);return Zu(r.depth,o)}async rename(e,t,n){return this.context.bee.stamp.updateLabel(e,t,n)}}const Ih=wc({address:Va().nullish().transform((e=>e??"")),seen:nc(),sent:nc(),split:nc(),startedAt:Va(),stored:nc(),synced:nc(),uid:nc()}),_h=wc({tags:gc(Ih)}),Vh="tags";class Dh{constructor(e){this.context=e}async create(e){return async function(e){const t=await Jc(e,{method:"post",url:Vh,responseType:"json"});return Ih.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async getAll(e,t){return e&&(e=Mu.parse(e)),async function(e,t){const n=await Jc(e,{url:Vh,params:{offset:t?.offset,limit:t?.limit},responseType:"json"});return _h.parse(n.data).tags}(this.context.getRequestOptionsForCall(t),e)}async get(e,t){const n=ju(e);return async function(e,t){const n=await Jc(e,{url:`${Vh}/${t}`,responseType:"json"});return Ih.parse(n.data)}(this.context.getRequestOptionsForCall(t),n)}async delete(e,t){const n=ju(e);await async function(e,t){await Jc(e,{method:"delete",url:`${Vh}/${t}`})}(this.context.getRequestOptionsForCall(t),n)}async update(e,t,n){const r=new nn(t),o=ju(e);await async function(e,t,n){await Jc(e,{method:"patch",url:`${Vh}/${t}`,data:{reference:n}})}(this.context.getRequestOptionsForCall(n),o,r)}}const Ph=wc({transactionHash:Va().transform((e=>new an(e))),to:Va(),nonce:nc(),gasPrice:Va().transform((e=>Gu(e,{name:"gasPrice"}))),gasLimit:nc(),data:Va(),created:Va(),description:Va(),value:Va().transform((e=>Gu(e,{name:"value"})))}),Nh=wc({pendingTransactions:gc(Ph)}),Ch=Ph,Fh=wc({transactionHash:Va().transform((e=>new an(e)))}),Mh="transactions";class Uh{constructor(e){this.context=e}async getAll(e){return async function(e){const t=await Jc(e,{url:Mh,responseType:"json"});return Nh.parse(t.data).pendingTransactions}(this.context.getRequestOptionsForCall(e))}async get(e,t){const n=new an(e);return async function(e,t){const n=await Jc(e,{url:`${Mh}/${t}`,responseType:"json"});return Ch.parse(n.data)}(this.context.getRequestOptionsForCall(t),n)}async rebroadcast(e,t){const n=new an(e);return async function(e,t){const n=await Jc(e,{method:"post",url:`${Mh}/${t}`,responseType:"json"});return Fh.parse(n.data).transactionHash}(this.context.getRequestOptionsForCall(t),n)}async cancel(e,t,n){const r=new an(e),o=t?Gu(t,{min:0n,name:"gasPrice"}):void 0;return async function(e,t,n){const r={};n&&(r["gas-price"]=n);const o=await Jc(e,{method:"delete",headers:r,url:`${Mh}/${t}`,responseType:"json"});return Fh.parse(o.data).transactionHash}(this.context.getRequestOptionsForCall(n),r,o)}}const Gh="wallet";class Lh{constructor(e){this.context=e}async getBalance(e){return async function(e){const t=await Jc(e,{method:"get",url:Gh,responseType:"json"});return kh.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async withdrawBZZ(e,t,n){const r=e instanceof su?e:su.fromPLUR(e),o=new Ut(t);return async function(e,t,n){const r=await Jc(e,{method:"post",url:`${Gh}/withdraw/bzz`,responseType:"json",params:{amount:t.toPLURString(),address:n.toHex()}});return Sh.parse(r.data).transactionHash}(this.context.getRequestOptionsForCall(n),r,o)}async withdrawDAI(e,t,n){const r=e instanceof au?e:au.fromWei(e),o=new Ut(t);return async function(e,t,n){const r=await Jc(e,{method:"post",url:`${Gh}/withdraw/nativetoken`,responseType:"json",params:{amount:t.toWeiString(),address:n.toHex()}});return Sh.parse(r.data).transactionHash}(this.context.getRequestOptionsForCall(n),r,o)}}const jh=["1","7","9","11","13","15","17","19","20","21","22","23","25","37","42","43","53","69","77","79","87","95","101","102","103","104","109","110","111","113","115","117","119","123","135","137","139","143","161","179","389","427","465","512","513","514","515","526","530","531","532","540","548","554","556","563","587","601","636","989","990","993","995","1719","1720","1723","2049","3659","4045","4190","5060","5061","6000","6566","6665","6666","6667","6668","6669","6679","6697","10080"];function Zh(e){if(!function(e){try{if("string"!=typeof e)return!1;const t=new URL(e);return"http:"===t.protocol||"https:"===t.protocol}catch(t){return!1}}(e))throw new nu("URL is not valid!",e);const t=new URL(e).port;if(t&&!function(e){if("string"!=typeof e)return!1;if(jh.includes(e))return!1;const t=parseInt(e,10);return t>0&&t<65536&&!isNaN(t)}(t))throw new nu("Port in URL is considered bad port and cannot be used!",t)}class qh{constructor(e,t){Zh(e),this.url=function(e){return e.endsWith("/")?e.slice(0,-1):e}(e),t?.signer&&(this.signer=new en(t.signer)),this.network=t?.network??"gnosis",this.requestOptions={baseURL:this.url,timeout:t?.timeout??0,headers:t?.headers,onRequest:t?.onRequest,httpAgent:t?.httpAgent,httpsAgent:t?.httpsAgent};const n={getRequestOptionsForCall:e=>this.getRequestOptionsForCall(e),url:this.url,signer:this.signer,network:this.network,bee:this};this.balance=new hl(n),this.settlement=new eh(n),this.transaction=new Uh(n),this.stake=new lh(n),this.connectivity=new uf(n),this.status=new Oh(n),this.wallet=new Lh(n),this.stamp=new vh(n),this.storage=new $h(n),this.chequebook=new xl(n),this.cheque=new El(n),this.tag=new Dh(n),this.pin=new Gf(n),this.grantee=new Df(n),this.messaging=new Ff(n),this.feed=new Of(n),this.soc=new th(n),this.data=new gf(n),this.chunk=new Tl(n),this.file=new $f(n),this.collection=new ql(n),this.rollingFeed=new Hf(n)}makeContentAddressedChunk(e,t){return Tn(e,t)}unmarshalContentAddressedChunk(e){return Rn(e)}makeSingleOwnerChunk(e,t,n,r,o){return function(e,t,n,r,o){return r=new Zt(r),o=new en(o),En({data:Pt.concat(t.toUint8Array(),n.toUint8Array()),span:t,payload:n,address:e},r,o.toBigInt())}(e,t,n,r,o)}calculateSingleOwnerChunkAddress(e,t){return Bn(e,t)}unmarshalSingleOwnerChunk(e,t){return nl(e,t)}async createEnvelope(e,t,n){return e=new Nt(e),t=new nn(t),async function(e,t,n){const r=await Jc(e,{method:"post",responseType:"json",url:`envelope/${n}`,headers:{"swarm-postage-batch-id":t.toHex()}}),o=Zc.parse(r.data);return{issuer:new Ut(o.issuer),index:o.index,timestamp:o.timestamp,signature:new Qt(o.signature),batchId:t}}(this.getRequestOptionsForCall(n),e,t)}async rchash(e,t,n,r){return async function(e,t,n,r){const o=await Jc(e,{responseType:"json",url:`rchash/${t}/${n}/${r}`});return Qc.parse(o.data).durationSeconds}(this.getRequestOptionsForCall(r),e,t,n)}getRequestOptionsForCall(e){return e&&(e=Au.parse(e)),e?cr.Rb.deepMerge2(this.requestOptions,e):this.requestOptions}}const Hh="https://api.gateway.ethswarm.org",Wh=new Nt("0000000000000000000000000000000000000000000000000000000000000000"),Jh=new sn("0000000000000000000000000000000000000000000000000000000000000000"),Kh=new Uint8Array(32),Xh=new Uint8Array(32),Yh=new Uint8Array(20);function Qh(e){return(e=new qt(e)).toHex().slice(0,gu)}})(),r})()));
|
|
2
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.BeeJs=t():e.BeeJs=t()}(this,(()=>(()=>{var e={20(e,t){"use strict";var n;async function r(e){return new Promise(((t,n)=>e.then(n,t)))}async function o(e){return new Promise((t=>setTimeout((()=>{t(!0)}),e)))}function i(e,t=Math.random){for(let n=e.length-1;n>0;n--){const r=Math.floor(t()*(n+1)),o=e[n];e[n]=e[r],e[r]=o}return e}function s(e,t,n=Math.random){return i(H(0,e.length-1),n).slice(0,t)}function a(e,t,n=Math.random){return Math.floor(n()*(t-e+1))+e}function c(e,t,n){return t>=e.x&&t<e.x+e.width&&n>=e.y&&n<e.y+e.height}function u(e,t=Math.random){return t()<e}function l(e,t=Math.random){return e[Math.floor(e.length*t())]}function f(e){if(!e.length)throw Error("Received empty array");return e[e.length-1]}function h(e,t,n){return n(t.reduce(((e,t)=>t(e)),e))}function d(e,t){if(null==e)return null;const n=t.split(".");let r=e;for(const o of n){if(null===r[o]||void 0===r[o])return null;r=r[o]}return r}function p(e,t,n){const r=t.split(/\.|\[/);let o=e;for(let i=0;i<r.length;i++){const e=r[i],t=i<r.length-1&&r[i+1].includes("]"),s=e.includes("]")?e.replace(/\[|\]/g,""):e;if(i===r.length-1)return o[s]=n,n;g(o[s])||(o[s]=t?[]:{}),o=o[s]}return n}function m(e,t){return Math.round(e/t)*t}function g(e,t=!0){return!(!e||t&&!b(e._readableState)||t&&e.constructor&&(e.constructor.isBuffer||"AbortController"==e.constructor.name||"AbortSignal"==e.constructor.name||"Uint8Array"==e.constructor.name||"ArrayBuffer"===e.constructor.name||"ReadableStream"===e.constructor.name))&&"object"==typeof e}function y(e){return g(e)&&!Array.isArray(e)}function w(e){return Array.isArray(e)&&0===e.length}function b(e){return void 0===e}function v(e){return"[object Function]"===Object.prototype.toString.call(e)||"[object AsyncFunction]"===Object.prototype.toString.call(e)}function B(e){return"[object String]"===Object.prototype.toString.call(e)}function E(e){return"number"==typeof e&&isFinite(e)}function x(e){return!0===e||!1===e}function T(e){return"[object Date]"===Object.prototype.toString.call(e)}function R(e){return!B(e)||0===e.trim().length}function O(e){return E(e)&&Number.isInteger(e)&&e>=1}function A(e){return B(e)&&null!==e.match(/^-?\d+$/)}function z(e){return B(e)&&null!==e.match(/^(0x)?[0-9a-f]+$/i)}t.DH=t.Or=t.Rb=t.AO=t.FQ=t.iQ=t.DO=t.o8=t.yI=t.O3=t.ie=t.Xx=void 0;const k="!@#$%^&*()_+-=[]{}|;:<>?,./".split(""),S="abcdefghijklmnopqrstuvwxyz",$=S+"ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890",_=$+"!@#$%^&*()_+-=[]{}|;:<>?,./",I=["—","\\","東","京","都","𝖆","𝖇","𝖈","👾","🙇","💁","🙅","ᚠ","ᛇ","ᚻ","ᛦ"],D="0123456789abcdef";function V(e,t){if(R(e))throw new TypeError(`Expected string${t?.name?` for ${t.name}`:""}, got: `+e);if(t&&(void 0!==t.min&&e.length<t.min||void 0!==t.max&&e.length>t.max))throw RangeError(`Expected string${t?.name?` for ${t.name}`:""} length in range: ${t.min??"-inf"}..${t.max??"inf"}; got: ${e.length}`);return e}function P(e,t){if(void 0!==t.min&&e<t.min||void 0!==t.max&&e>t.max)throw RangeError(`Expected value${t?.name?` for ${t.name}`:""} in range: ${t.min??"-inf"}..${t.max??"inf"}; got: ${e}`)}function C(e,t){if(E(e))return t&&P(e,t),e;if(!B(e)||!e.match(/^-?\d+(\.\d+)?$/))throw new TypeError(`Expected number${t?.name?` for ${t.name}`:""}, got: `+e);const n=parseFloat(e);return t&&P(n,t),n}function F(e,t){return Math.trunc(C(e,t))}function N(e,t){if(!y(e))throw new TypeError(`Expected object${t?.name?` for ${t.name}`:""}, got: `+e);return e}function M(e){return B(e)&&null!==e.match(/^https?:\/\/.+/)}function U(e){return"bigint"==typeof e}function G(e,t){if(!U(e))throw new TypeError(`Expected bigint${t?.name?` for ${t.name}`:""}, got: `+e);if(void 0!==t?.min&&e<t?.min||void 0!==t?.max&&e>t?.max)throw RangeError(`Expected value${t?.name?` for ${t.name}`:""} in range: ${t.min??"-inf"}..${t.max??"inf"}; got: ${e}`);return e}function L(e,t){for(const[n,r]of Object.entries(t))if(!r(e[n]))throw TypeError(`${n} in value does not exist or match shape`);for(const n of Object.keys(e))if(!t[n])throw TypeError(`${n} exists in value but not in shape`);return!0}function j(e,t){if(y(e)&&y(t))for(const n in t)y(t[n])?(e[n]||(e[n]={}),j(e[n],t[n])):Array.isArray(t[n])?e[n]=[...t[n]]:(null!==t[n]&&void 0!==t[n]||null===e[n]||void 0===e[n])&&(e[n]=t[n]);return e}function Z(e,t){const n={};for(const r of e)for(const e of Object.keys(r))n[e]?n[e]=t(n[e],r[e]):n[e]=r[e];return n}function q(e,t){Array.prototype.push.apply(e,t)}function H(e,t){const n=[];for(let r=e;r<=t;r++)n.push(r);return n}function W(e,t=()=>!1){return e.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"").split("").map((e=>/[a-z0-9]/.test(e)||t(e)?e:"-")).join("").replace(/-+/g,"-").replace(/^-|-$/g,"")}function K(e,t){if(0===t.length)return 0;const n=e.toLowerCase(),r=t.toLowerCase();return e===t?1e4:n.startsWith(r)?1e4-e.length:n.includes(r)?5e3-e.length:new RegExp(".*"+r.split("").join(".*")+".*").test(n)?1e3-e.length:0}const J={"&":"&",""":'"',"'":"'",">":">","<":"<"};function X(e,t){const n=e.indexOf(t);return-1===n?null:e.slice(0,n)}function Y(e,t){const n=e.indexOf(t);return-1===n?null:e.slice(n+t.length)}function Q(e,t){const n=e.lastIndexOf(t);return-1===n?null:e.slice(0,n)}function ee(e,t){const n=e.lastIndexOf(t);return-1===n?null:e.slice(n+t.length)}function te(e,t,n=!1){const r=n?e.lastIndexOf(t):e.indexOf(t);return-1===r?n?[null,e]:[e,null]:[e.slice(0,r),e.slice(r+t.length)]}function ne(e,t){let n=[e];for(const r of t)n=n.flatMap((e=>e.split(r)));return n.filter((e=>e))}function re(e){const t=f(e.split(/\\|\//g)),n=t.lastIndexOf(".",t.length-1);return n<=0?"":t.slice(n+1)}function oe(e){const t=f(e.split(/\\|\//g)),n=t.lastIndexOf(".",t.length-1);return n<=0?t:t.slice(0,n)}function ie(e){return e.split("\n").map((e=>e.trim().replace(/\s+/g," "))).filter((e=>e.length>0)).join("\n")}function se(e){return e.charAt(0).toUpperCase()+e.slice(1)}function ae(e){return e.charAt(0).toLowerCase()+e.slice(1)}function ce(e){if(!e)return!1;const t=e.charCodeAt(0);return t>=65&&t<=90||t>=97&&t<=122}function ue(e){if(!e)return!1;const t=e.charCodeAt(0);return t>=48&&t<=57}function le(e){return ce(e)||ue(e)}const fe=" \n\t\r.,?!:;\"'`(){}[]~@#$%^&*-+=|<>/\\".split("");function he(e){return fe.includes(e)}function de(e,t,n=0){const r=t.exec(e.slice(n));return r?{index:r.index,match:r[0]}:null}function pe(e,t,n=!0){if(!n)return t.every((t=>t instanceof RegExp?t.test(e):-1!==e.indexOf(t,0)));let r=0;for(const o of t)if(o instanceof RegExp){const t=de(e,o,r);if(!t)return!1;r=t.index+t.match.length}else{const t=e.indexOf(o,r);if(-1===t)return!1;r=t+o.length}return!0}function me(e,t,n=0){const r=[];let o=e.indexOf(t,n);for(;-1!==o;)r.push(o),o=e.indexOf(t,o+t.length);return r}function ge(e,t,n=0){let r=-1;for(const o of t){const t=e.indexOf(o,n);-1!==t&&(-1===r||t<r)&&(r=t)}return r}function ye(e,t=0){for(let n=t;n<e.length;n++)if(he(e[n]))return n;return-1}function we(e,t=0){for(let n=t;n<e.length;n++)if("#"===e[n]&&le(e[n+1]))return n;return-1}function be(e,t,n=0){return e.slice(0,n).lastIndexOf(t)}function ve(e,t=0,n="{",r="}"){let o=1;for(let i=t;i<e.length;i++)if(e.slice(i,i+r.length)===r){if(0==--o)return i}else e.slice(i,i+n.length)===n&&o++;return-1}function Be(e,t){const n=t.wordBoundary?ge(e,[`${t.opening} `,`${t.opening}\n`],t.start||0):e.indexOf(t.opening,t.start||0);if(-1===n)return null;const r=ve(e,n+t.opening.length,t.opening,t.closing);return-1===r?null:t.exclusive?e.slice(n+t.opening.length,r):e.slice(n,r+t.closing.length)}const Ee="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",xe="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";function Te(e,t){const n=t.length;let r=0,o=0;const i=[];for(let s=0;s<e.length;s++){const a=e[s];if("="===a)break;const c=t.indexOf(a);if(-1===c)throw new Error(`Invalid character: ${a}`);o=o<<Math.log2(n)|c,r+=Math.log2(n),r>=8&&(r-=8,i.push(o>>r&255))}return new Uint8Array(i)}function Re(e,t){const n=t.length;let r=0,o=0,i="";for(let s=0;s<e.length;s++)for(o=o<<8|e[s],r+=8;r>=Math.log2(n);)r-=Math.log2(n),i+=t[o>>r&n-1];return r>0&&(i+=t[o<<Math.log2(n)-r&n-1]),i.length%4!=0&&(i+="=".repeat(4-i.length%4)),i}function Oe(e,t,n){const r=[];for(const o of n)o!==t&&r.push(e.replace(t,o));return r}function Ae(e){const t=e.lastIndexOf(" ");if(-1===t)return{line:e,rest:""};return{line:e.slice(0,t),rest:e.slice(t+1)}}function ze(e){const t=e.reduce(((e,t)=>e.length<t.length?e:t));let n="";for(let r=0;r<t.length;r++){const o=t[r];if(!e.every((e=>e[r]===o)))break;n+=o}return n}function ke(e,t){return new RegExp(`\\b${t}\\b`).test(e)}function Se(e,t,n=[]){let r="";for(;t<e.length&&(le(e[t])||n.includes(e[t]));)r+=e[t++];return r}function $e(e,t,n,r="$",o=":"){if(""===n)return e;let i=e.indexOf(`${r}${t}`);for(;-1!==i;){if(e[i+t.length+1]===o)if(e[i+t.length+2]===o)e=e.replace(`${r}${t}${o}${o}`,n);else{const s=Se(e,i+t.length+2,["_"]);e=e.replace(`${r}${t}${o}${s}`,n)}else e=e.replace(`${r}${t}`,n);i=e.indexOf(`${r}${t}`,i+n.length)}return e}function _e(e,t="$",n=":"){let r=e.indexOf(t);for(;-1!==r;){const o=Se(e,r+1);if(e[r+o.length+1]===n)if(e[r+o.length+2]===n)e=e.replace(`${t}${o}${n}${n}`,"");else{const i=Se(e,r+o.length+2);e=e.replace(`${t}${o}${n}${i}`,i)}r=e.indexOf(t,r+1)}return e}function Ie(e,t=!0){const n=Object.entries(e).filter((([e,t])=>null!=t)).map((([e,t])=>`${e}=${encodeURIComponent(t)}`)).join("&");return n?(t?"?":"")+n:""}function De(e){return String(Math.floor(e)).padStart(2,"0")}function Ve(e){const t=Math.floor(e/36e5);e%=36e5;const n=Math.floor(e/6e4);e%=6e4;const r=Math.floor(e/1e3);return t?`${De(t)}:${De(n)}:${De(r)}`:`${De(n)}:${De(r)}`}function Pe(e){return Math.floor((T(e)?e.getTime():e)/864e5)}const Ce={today:(e,t)=>De(e)+":"+De(t),yesterday:()=>"Yesterday",monday:()=>"Mon",tuesday:()=>"Tue",wednesday:()=>"Wed",thursday:()=>"Thu",friday:()=>"Fri",saturday:()=>"Sat",sunday:()=>"Sun",weeks:e=>`${e}w`};const Fe={now:()=>"A few seconds",seconds:e=>`${e} seconds`,minutes:e=>`${e} minutes`,hours:e=>`${e} hours`,days:e=>`${e} days`,weeks:e=>`${e} weeks`};function Ne(e,n){const r=n?.now??Date.now(),o=n?.labels||Fe;let i=(r-(t.Or.isDate(e)?e.getTime():e))/1e3;return i<10?o.now():i<120?o.seconds(Math.floor(i)):(i/=60,i<120?o.minutes(Math.floor(i)):(i/=60,i<48?o.hours(Math.floor(i)):(i/=24,i<14?o.days(Math.floor(i)):(i/=7,o.weeks(Math.floor(i))))))}const Me={};const Ue={s:1e3,m:6e4,h:36e5,d:864e5};const Ge={0:"sunday",1:"monday",2:"tuesday",3:"wednesday",4:"thursday",5:"friday",6:"saturday"};function Le(e){return{zeroBasedIndex:e,day:Ge[e]}}function je(e){return Le(e.getDay())}const Ze={ms:1,milli:1,millis:1,millisecond:1,milliseconds:1,s:1e3,sec:1e3,second:1e3,seconds:1e3,m:6e4,min:6e4,minute:6e4,minutes:6e4,h:36e5,hour:36e5,hours:36e5,d:864e5,day:864e5,days:864e5,w:6048e5,week:6048e5,weeks:6048e5,month:2592e6,months:2592e6,y:31536e6,year:31536e6,years:31536e6};const qe={b:0,byte:0,bytes:0,kb:1,kilobyte:1,kilobytes:1,mb:2,megabyte:2,megabytes:2,gb:3,gigabyte:3,gigabytes:3,tb:4,terabyte:4,terabytes:4};const He=new Map;function We(e,t=!1){e=e.filter((e=>e)),t&&B(e[1])&&(e[1]="../"+e[1]);let n="";B(e[0])&&e[0].includes("://")&&(n=X(e[0],"://")??"",e[0]=Y(e[0],"://")??"");const r=e.map((e=>String(e))).flatMap((e=>e.split("/"))),o=[];for(let i=0;i<r.length;i++)"."!==r[i]&&(".."===r[i]?(!n||o.length>1)&&o.pop():o.push(r[i]));return(n?n+"://":"")+o.join("/").replaceAll(/\/{2,}/g,"/")}function Ke(e){const t=Object.keys(e).sort(((e,t)=>e.localeCompare(t))),n={};for(const r of t)n[r]=Xe(e[r]);return n}function Je(e){const t=[];return e.sort(((e,t)=>JSON.stringify(Xe(e)).localeCompare(JSON.stringify(Xe(t))))).forEach((e=>t.push(Xe(e)))),t}function Xe(e){return Array.isArray(e)?Je(e):g(e)?Ke(e):e}function Ye(e,t){return JSON.stringify(Xe(e))===JSON.stringify(Xe(t))}function Qe(e){const t=Object.keys(e);return t[Math.floor(Math.random()*t.length)]}const et=[1e3,1e6,1e9,1e12,1e15,1e18,1e21,1e24,1e27,1e30,1e9,1e16,1e18,1e18,1e18,1e33],tt=["thousand","million","billion","trillion","quadrillion","quintillion","sextillion","septillion","octillion","nonillion","gwei","bzz","btc","eth","dai","decillion"],nt=["K","M","B","T","Qa","Qi","Sx","Sp","O","N","gwei","bzz","eth","btc","dai","D"];function rt(e){const t=parseFloat(e);if(isNaN(t))throw Error("makeNumber got NaN for input");const n=e.replace(/^-?[0-9.]+/,"").trim(),r=nt.findIndex((e=>e.toLowerCase()===n.toLowerCase()));return-1===r?t:t*et[r]}function ot(e,t,n){return e<t?t:e>n?n:e}function it(e,t,n){return e+(n?"["+t+"]":(e.length?".":"")+t)}function st(e,t,n,r,o){if(!g(t))return t;for(const[i,s]of Object.entries(t)){const t=it(n,i,r);Array.isArray(s)?o?st(e,s,t,!0,o):e[t]=s.map((e=>st(Array.isArray(e)?[]:{},e,"",!1,o))):g(s)?st(e,s,t,!1,o):e[t]=s}return e}function at(e,t){const n={};for(const r of e){n[t(r)]=r}return n}function ct(e,t){const n=Math.ceil(e.length/t),r=[];for(let o=0;o<e.length;o+=n)r.push(e.slice(o,o+n));return r}function ut(e,t){const n=[],r=Math.ceil(e.length/t);for(let o=0;o<r;o++)n.push(e.slice(o*t,o*t+t));return n}function lt(e,t){return Object.fromEntries(Object.entries(e).sort(t))}function ft(e,t){const n=[];let r=[];return e.forEach(((o,i)=>{(0===i||!t(o,e[i-1]))&&(r=[],n.push(r)),r.push(o)})),n}function ht(e,t,n,r=100){if(e.map.has(t)){const n=e.keys.indexOf(t);e.keys.splice(n,1)}if(e.map.set(t,n),e.keys.push(t),e.keys.length>r){const t=e.keys.shift();t&&e.map.delete(t)}}class dt{constructor(e){this.value=e}static of(e){return new dt(e)}static empty(){return new dt(null)}map(e){return new dt(null!==this.value&&void 0!==this.value?e(this.value):null)}mapAsync(e){return null!==this.value&&void 0!==this.value?e(this.value).then((e=>dt.of(e))):Promise.resolve(dt.empty())}ifPresent(e){return null!==this.value&&void 0!==this.value&&e(this.value),this}ifPresentAsync(e){return null!==this.value&&void 0!==this.value?e(this.value).then((()=>this)):Promise.resolve(this)}ifAbsent(e){return(null===this.value||void 0===this.value)&&e(),this}ifAbsentAsync(e){return null===this.value||void 0===this.value?e().then((()=>this)):Promise.resolve(this)}getOrFallback(e){return this.value??e()}getOrFallbackAsync(e){return null!==this.value&&void 0!==this.value?Promise.resolve(this.value):e()}getOrThrow(){if(null===this.value||void 0===this.value)throw Error("Optional.value is empty");return this.value}}t.Xx=dt;class pt{constructor(e){this.value=e,this.children=[]}}function mt(e,t){if(Math.log2(e.length)%1!=0)throw new Error("Array length must be a power of 2");let n=[...e];for(;n.length>1;){const e=[];for(let r=0;r<n.length;r+=2){const o=n[r+1];e.push(t(n[r],o))}n=e}return n[0]}function gt(...e){const t=e.reduce(((e,t)=>e+t.length),0),n=new Uint8Array(t);let r=0;return e.forEach((e=>{n.set(e,r),r+=e.length})),n}function yt(e){return 137===e[0]&&80===e[1]&&78===e[2]&&71===e[3]}function wt(e){return 255===e[0]&&216===e[1]}function bt(e){return 87===e[8]&&69===e[9]&&66===e[10]&&80===e[11]}function vt(e,t){const n=new ArrayBuffer(8);return new DataView(n).setBigUint64(0,BigInt(e),"LE"===t),new Uint8Array(n)}function Bt(e,t){const n=new Uint8Array(32);let r=e;if("LE"===t){for(let e=0;e<32;e++)n[e]=Number(0xffn&r),r>>=8n;return n}for(let o=31;o>=0;o--)n[o]=Number(0xffn&r),r>>=8n;return n}function Et(e,t){let n=0n;if("LE"===t){for(let t=31;t>=0;t--)n=n<<8n|BigInt(e[t]);return n}for(let r=0;r<32;r++)n=n<<8n|BigInt(e[r]);return n}function xt(e,t){const n=[];for(let r=0;r<e.length;r+=t)n.push(e.subarray(r,r+t));return n}const Tt=[0,1,0,32898,2147483648,32906,2147483648,2147516416,0,32907,0,2147483649,2147483648,2147516545,2147483648,32777,0,138,0,136,0,2147516425,0,2147483658,0,2147516555,2147483648,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,0,32778,2147483648,2147483658,2147483648,2147516545,2147483648,32896,0,2147483649,2147483648,2147516424];function Rt(e){for(let t=0;t<24;t++){const n=e[0]^e[10]^e[20]^e[30]^e[40],r=e[1]^e[11]^e[21]^e[31]^e[41],o=e[2]^e[12]^e[22]^e[32]^e[42],i=e[3]^e[13]^e[23]^e[33]^e[43],s=e[4]^e[14]^e[24]^e[34]^e[44],a=e[5]^e[15]^e[25]^e[35]^e[45],c=e[6]^e[16]^e[26]^e[36]^e[46],u=e[7]^e[17]^e[27]^e[37]^e[47],l=e[8]^e[18]^e[28]^e[38]^e[48],f=e[9]^e[19]^e[29]^e[39]^e[49],h=l^(o<<1|i>>>31),d=f^(i<<1|o>>>31),p=n^(s<<1|a>>>31),m=r^(a<<1|s>>>31),g=o^(c<<1|u>>>31),y=i^(u<<1|c>>>31),w=s^(l<<1|f>>>31),b=a^(f<<1|l>>>31),v=c^(n<<1|r>>>31),B=u^(r<<1|n>>>31);e[0]^=h,e[1]^=d,e[2]^=p,e[3]^=m,e[4]^=g,e[5]^=y,e[6]^=w,e[7]^=b,e[8]^=v,e[9]^=B,e[10]^=h,e[11]^=d,e[12]^=p,e[13]^=m,e[14]^=g,e[15]^=y,e[16]^=w,e[17]^=b,e[18]^=v,e[19]^=B,e[20]^=h,e[21]^=d,e[22]^=p,e[23]^=m,e[24]^=g,e[25]^=y,e[26]^=w,e[27]^=b,e[28]^=v,e[29]^=B,e[30]^=h,e[31]^=d,e[32]^=p,e[33]^=m,e[34]^=g,e[35]^=y,e[36]^=w,e[37]^=b,e[38]^=v,e[39]^=B,e[40]^=h,e[41]^=d,e[42]^=p,e[43]^=m,e[44]^=g,e[45]^=y,e[46]^=w,e[47]^=b,e[48]^=v,e[49]^=B;const E=e[0],x=e[1],T=e[2]<<1|e[3]>>>31,R=e[3]<<1|e[2]>>>31,O=e[5]<<30|e[4]>>>2,A=e[4]<<30|e[5]>>>2,z=e[6]<<28|e[7]>>>4,k=e[7]<<28|e[6]>>>4,S=e[8]<<27|e[9]>>>5,$=e[9]<<27|e[8]>>>5,_=e[11]<<4|e[10]>>>28,I=e[10]<<4|e[11]>>>28,D=e[13]<<12|e[12]>>>20,V=e[12]<<12|e[13]>>>20,P=e[14]<<6|e[15]>>>26,C=e[15]<<6|e[14]>>>26,F=e[17]<<23|e[16]>>>9,N=e[16]<<23|e[17]>>>9,M=e[18]<<20|e[19]>>>12,U=e[19]<<20|e[18]>>>12,G=e[20]<<3|e[21]>>>29,L=e[21]<<3|e[20]>>>29,j=e[22]<<10|e[23]>>>22,Z=e[23]<<10|e[22]>>>22,q=e[25]<<11|e[24]>>>21,H=e[24]<<11|e[25]>>>21,W=e[26]<<25|e[27]>>>7,K=e[27]<<25|e[26]>>>7,J=e[29]<<7|e[28]>>>25,X=e[28]<<7|e[29]>>>25,Y=e[31]<<9|e[30]>>>23,Q=e[30]<<9|e[31]>>>23,ee=e[33]<<13|e[32]>>>19,te=e[32]<<13|e[33]>>>19,ne=e[34]<<15|e[35]>>>17,re=e[35]<<15|e[34]>>>17,oe=e[36]<<21|e[37]>>>11,ie=e[37]<<21|e[36]>>>11,se=e[38]<<8|e[39]>>>24,ae=e[39]<<8|e[38]>>>24,ce=e[40]<<18|e[41]>>>14,ue=e[41]<<18|e[40]>>>14,le=e[42]<<2|e[43]>>>30,fe=e[43]<<2|e[42]>>>30,he=e[45]<<29|e[44]>>>3,de=e[44]<<29|e[45]>>>3,pe=e[47]<<24|e[46]>>>8,me=e[46]<<24|e[47]>>>8,ge=e[48]<<14|e[49]>>>18,ye=e[49]<<14|e[48]>>>18;e[0]=E^~D&q,e[1]=x^~V&H,e[2]=D^~q&oe,e[3]=V^~H&ie,e[4]=q^~oe&ge,e[5]=H^~ie&ye,e[6]=oe^~ge&E,e[7]=ie^~ye&x,e[8]=ge^~E&D,e[9]=ye^~x&V,e[10]=z^~M&G,e[11]=k^~U&L,e[12]=M^~G&ee,e[13]=U^~L&te,e[14]=G^~ee&he,e[15]=L^~te&de,e[16]=ee^~he&z,e[17]=te^~de&k,e[18]=he^~z&M,e[19]=de^~k&U,e[20]=T^~P&W,e[21]=R^~C&K,e[22]=P^~W&se,e[23]=C^~K&ae,e[24]=W^~se&ce,e[25]=K^~ae&ue,e[26]=se^~ce&T,e[27]=ae^~ue&R,e[28]=ce^~T&P,e[29]=ue^~R&C,e[30]=S^~_&j,e[31]=$^~I&Z,e[32]=_^~j&ne,e[33]=I^~Z&re,e[34]=j^~ne&pe,e[35]=Z^~re&me,e[36]=ne^~pe&S,e[37]=re^~me&$,e[38]=pe^~S&_,e[39]=me^~$&I,e[40]=O^~F&J,e[41]=A^~N&X,e[42]=F^~J&Y,e[43]=N^~X&Q,e[44]=J^~Y&le,e[45]=X^~Q&fe,e[46]=Y^~le&O,e[47]=Q^~fe&A,e[48]=le^~O&F,e[49]=fe^~A&N,e[0]^=Tt[2*t],e[1]^=Tt[2*t+1]}}function Ot(e){const t=[];for(let n=0;n<e.length;n+=4)t.push(e[n]|e[n+1]<<8|e[n+2]<<16|e[n+3]<<24);return t}function At(e,t){if(!e.length){const e=new Uint8Array(136);return e[0]=t,e[135]=128,[Ot(e)]}const n=xt(e,136),r=n[n.length-1];if(r.length<136){const e=new Uint8Array(136);e.set(r),e[r.length]=t,e[135]|=128,n[n.length-1]=e}if(136===r.length){const e=new Uint8Array(136);e[0]=t,e[135]=128,n.push(e)}return n.map(Ot)}function zt(e,t){for(const n of t){for(let t=0;t<34;t+=2)e[t]^=n[t+1],e[t+1]^=n[t];Rt(e)}return e}function kt(e){return new Uint8Array([e[1],e[1]>>-24,e[1]>>-16,e[1]>>-8,e[0],e[0]>>8,e[0]>>16,e[0]>>24,e[3],e[3]>>-24,e[3]>>-16,e[3]>>-8,e[2],e[2]>>8,e[2]>>16,e[2]>>24,e[5],e[5]>>-24,e[5]>>-16,e[5]>>-8,e[4],e[4]>>8,e[4]>>16,e[4]>>24,e[7],e[7]>>-24,e[7]>>-16,e[7]>>-8,e[6],e[6]>>8,e[6]>>16,e[6]>>24])}function St(e){return kt(zt(new Array(50).fill(0),At(e,1)))}function $t(e,t,n=0){if(e.length>=t)return e;const r=new Uint8Array(t);return r.fill(n),r.set(e,t-e.length),r}function _t(e,t,n=0){if(e.length>=t)return e;const r=new Uint8Array(t);return r.fill(n),r.set(e,0),r}function It(e,t){return(e%t+t)%t}function Dt(e,t){It(e,t);let[n,r]=[0n,1n],[o,i]=[t,e];for(;0n!==i;){const e=o/i;[n,r]=[r,n-e*r],[o,i]=[i,o-e*i]}if(o>1n)throw new Error("a is not invertible");return n<0n&&t,n}function Vt(e,t){return 0n===It(e,t)?0n:t%4n===3n?function(e,t,n){let r=1n;for(It(e,n);t>0;)t%2n===1n&&It(r*e,n),It(e*e,n);return r}(e,(t+1n)/4n,t):null}const Pt=0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2fn,Ct=0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n,Ft=0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798n,Nt=0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8n;function Mt(e,t,n){if(0n===t)return[0n,0n];const r=It(3n*e*e*Dt(2n*t,n),n),o=It(r*r-2n*e,n);return[o,It(r*(e-o)-t,n)]}function Ut(e,t,n,r,o){if(0n===e&&0n===t)return[n,r];if(0n===n&&0n===r)return[e,t];if(e===n&&t===It(-r,o))return[0n,0n];if(e===n&&t===r)return Mt(e,t,o);const i=It((r-t)*Dt(n-e,o),o),s=It(i*i-e-n,o);return[s,It(i*(e-s)-t,o)]}function Gt(e,t,n,r){let o=[0n,0n],i=[e,t];const s=n.toString(2);for(const a of s)"0"===a?(Ut(o[0],o[1],i[0],i[1],r),Mt(o[0],o[1],r)):(Ut(o[0],o[1],i[0],i[1],r),Mt(i[0],i[1],r));return o}function Lt(e,t,n){if(t<=0n||t>=Ct)throw new Error("Invalid private key");if(n||It(Et(St(gt(St(Bt(t,"BE")),Bt(e,"BE"))),"BE"),Ct),n<=0n||n>=Ct)throw new Error("Invalid nonce");const r=It(e,Ct),o=Gt(Ft,Nt,n,Pt),i=It(o[0],Ct);let s=It((r+It(i,Ct)*t)*Dt(n,Ct),Ct);if(0n===i||0n===s)throw new Error("Invalid r or s value");let a=o[1]%2n===0n?27n:28n;return s>Ct/2n&&(27n===a?28n:27n),[i,s,a]}class jt{constructor(e){this.cursor=0,this.buffer=e}read(e){const t=this.buffer.subarray(this.cursor,this.cursor+e);return this.cursor+=e,t}max(){return this.buffer.length-this.cursor}}class Zt{constructor(e){this.buffer=e,this.cursor=0}write(e){const t=Math.min(this.max(),e.max());return this.buffer.set(e.read(t),this.cursor),this.cursor+=t,t}max(){return this.buffer.length-this.cursor}}class qt{constructor(e,t=0n){this.span=t,this.writer=new Zt(new Uint8Array(e))}build(){return gt(vt(this.span,"LE"),this.writer.buffer)}hash(){const e=mt(xt(this.writer.buffer,32),((e,t)=>qt.hashFunction(gt(e,t))));return qt.hashFunction(gt(vt(this.span,"LE"),e))}}qt.hashFunction=St;class Ht{constructor(e,t=4096){this.counters=[1],this.capacity=t,this.chunks=[new qt(t)],this.onChunk=e}static async root(e,t=4096){const r=new n(n.NOOP,t);return await r.append(e),r.finalize()}async append(e,t=0,n=0n){const r=new jt(e);for(;r.max()>0;){0===this.chunks[t].writer.max()&&await this.elevate(t);const e=this.chunks[t].writer.write(r);n?this.chunks[t].span+=n:this.chunks[0].span+=BigInt(e)}}async elevate(e){this.counters[e]=++this.counters[e]%(this.capacity/32),this.chunks[e+1]||(this.chunks.push(new qt(this.capacity)),this.counters.push(1)),await this.append(this.chunks[e].hash(),e+1,this.chunks[e].span),await this.onChunk(this.chunks[e]),this.chunks[e]=new qt(this.capacity)}async finalize(e=0){return this.chunks[e+1]?1===this.counters[e]?(await this.elevate(e+1),this.chunks[e+1]=this.chunks[e],this.finalize(e+1)):(await this.elevate(e),this.finalize(e+1)):(await this.onChunk(this.chunks[e]),this.chunks[e])}}n=Ht,Ht.NOOP=async e=>{};class Wt{constructor(e,t){if(t<0)throw Error("Scale must be non-negative");this.value=BigInt(e),this.scale=t}static cast(e){if(!e)throw Error("Cannot cast falsy value to FixedPointNumber");if(e instanceof Wt)return e;const t=G(e.value),n=C(e.scale);return new Wt(t,n)}static fromDecimalString(e,t){/e\-\d+$/i.test(e)&&(e=parseFloat(e).toFixed(t));let[n,r]=e.split(".");return r=(r||"").padEnd(t,"0").slice(0,t),new Wt(BigInt(n+r),t)}static fromFloat(e,t){return Wt.fromDecimalString(e.toString(),t)}add(e){return this.assertSameScale(e),new Wt(this.value+e.value,this.scale)}subtract(e){return this.assertSameScale(e),new Wt(this.value-e.value,this.scale)}multiply(e){return new Wt(this.value*e,this.scale)}divmod(e){if(0n===e)throw new Error("Division by zero is not allowed");const t=this.value/e,n=this.value%e;return[new Wt(t,this.scale),new Wt(n,this.scale)]}exchange(e,t,n){if("*"===e){const e=this.value*t.value/10n**BigInt(this.scale);return new Wt(e,n)}this.assertSameScale(t);const r=this.value*10n**BigInt(n)/t.value;return new Wt(r,n)}compare(e){return this.assertSameScale(e),this.value>e.value?1:this.value<e.value?-1:0}toDecimalString(){if(0===this.scale)return this.value.toString();const e=this.value.toString();return`${e.slice(0,-this.scale)||"0"}.${e.slice(-this.scale).padStart(this.scale,"0")}`}toString(){return this.value.toString()}toJSON(){return this.toString()}toFloat(){return parseFloat(this.toDecimalString())}assertSameScale(e){if(this.scale!==e.scale)throw new Error(`Scale mismatch: expected ${this.scale}, but got ${e.scale}`)}}function Kt(e,t,n,r){const o=e.findIndex((e=>e===`--${t}`||e.startsWith(`--${t}=`))),i=e[o];if(!i)return(n||{})[r||t||""]||null;if(i.includes("="))return i.split("=")[1];const s=e[o+1];return s&&!s.startsWith("-")?s:(n||{})[r||t||""]||null}function Jt(e,t,n,r){const o=Kt(e,t,n,r);if(!o)throw new Error(`Missing argument ${t}`);return o}function Xt(e,t){const n=e[t];e.splice(t,1),e.unshift(n)}function Yt(e,t){return{x:e.x+t.x,y:e.y+t.y}}function Qt(e,t){return{x:e.x*t,y:e.y*t}}function en(e,t,n){return{x:e.x+Math.cos(t)*n,y:e.y+Math.sin(t)*n}}function tn(e,t){return Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2)}function nn(e,t,n="row-first"){const r=[];if("column-first"===n)for(let o=0;o<e.length;o++)for(let n=0;n<e[0].length;n++)t(o,n)&&r.push({x:o,y:n});else for(let o=0;o<e[0].length;o++)for(let n=0;n<e.length;n++)t(n,o)&&r.push({x:n,y:o});return r}function rn(e,t,n){return!e[t-1]?.[n]}function on(e,t,n){return!e[t+1]?.[n]}function sn(e,t,n){return!e[t][n-1]}function an(e,t,n){return!e[t][n+1]}function cn(e,t,n){const r=[];return e[t][n]?function(e,t,n){return e[t+1]?.[n]&&e[t-1]?.[n]&&!e[t][n-1]&&!e[t][n+1]}(e,t,n)||function(e,t,n){return e[t][n+1]&&e[t][n-1]&&!e[t-1]?.[n]&&!e[t+1]?.[n]}(e,t,n)?[]:(!e[t-1]?.[n-1]&&rn(e,t,n)&&sn(e,t,n)&&r.push({x:t,y:n}),!e[t+1]?.[n-1]&&on(e,t,n)&&sn(e,t,n)&&r.push({x:t+1,y:n}),!e[t-1]?.[n+1]&&rn(e,t,n)&&an(e,t,n)&&r.push({x:t,y:n+1}),!e[t+1]?.[n+1]&&on(e,t,n)&&an(e,t,n)&&r.push({x:t+1,y:n+1}),r):(e[t-1]?.[n]&&e[t][n-1]&&r.push({x:t,y:n}),e[t+1]?.[n]&&e[t][n-1]&&r.push({x:t+1,y:n}),e[t-1]?.[n]&&e[t][n+1]&&r.push({x:t,y:n+1}),e[t+1]?.[n]&&e[t][n+1]&&r.push({x:t+1,y:n+1}),r)}function un(e,t){return t.map((t=>function(e,t){return Math.atan2(t.y-e.y,t.x-e.x)}(e,t))).sort(((e,t)=>e-t))}function ln(e,t,n,r){const o=(r.y-n.y)*(t.x-e.x)-(r.x-n.x)*(t.y-e.y);if(0===o)return null;let i=e.y-n.y,s=e.x-n.x;const a=(r.x-n.x)*i-(r.y-n.y)*s,c=(t.x-e.x)*i-(t.y-e.y)*s;return i>0&&i<1&&s>0&&s<1?{x:e.x+i*(t.x-e.x),y:e.y+i*(t.y-e.y)}:null}function fn(e,t,n){const r=[],o=en(e,n,1e4);for(const i of t){const t=ln(e,o,i.start,i.end);t&&r.push(t)}return r.length?r.reduce(((t,n)=>tn(e,n)<tn(e,t)?n:t)):null}t.ie=Wt;class hn{constructor(){this.subscribers=[]}subscribe(e){return this.subscribers.push(e),()=>{this.subscribers=this.subscribers.filter((t=>t!==e))}}publish(e){this.subscribers.forEach((t=>t(e)))}clear(){this.subscribers=[]}getSubscriberCount(){return this.subscribers.length}}t.O3=class{constructor(e,t){this.queue=[],this.running=0,this.onProcessed=new hn,this.onDrained=new hn,this.concurrency=e,this.capacity=t}process(){if(this.running>=this.concurrency)return;const e=this.queue.shift();e&&(this.running++,e().finally((()=>{this.running--,this.process(),this.onProcessed.publish(),0===this.running&&this.onDrained.publish()})))}enqueue(e){if(this.queue.length<this.capacity)return this.queue.push(e),this.process(),Promise.resolve();if(this.onProcessed.getSubscriberCount())throw Error("Queue capacity is full");return new Promise((t=>{this.onProcessed.subscribe((()=>{this.queue.length<this.capacity&&(this.queue.push(e),this.process(),this.onProcessed.clear(),t())}))}))}drain(){if(0===this.running)return Promise.resolve();if(this.onDrained.getSubscriberCount())throw Error("Already draining");return new Promise((e=>{this.onDrained.subscribe((()=>{this.onDrained.clear(),e()}))}))}};class dn{constructor(){this.forks=new Map}insert(e,t){if(0===e.length)return void(this.handler=t);const n=e[0];let r,o=n;if(n.startsWith(":")&&n.slice(1),!this.forks.has(o)){const e=new dn;r&&(e.variableName=r),this.forks.set(o,e)}this.forks.get(o).insert(e.slice(1),t)}async handle(e,t,n,r){if(0===e.length)return!!this.handler&&(await this.handler(t,n,r),!0);const o=e[0],i=this.forks.get(o);if(i)return i.handle(e.slice(1),t,n,r);const s=this.forks.get(":");if(s)return s.variableName&&r.set(s.variableName,decodeURIComponent(o)),s.handle(e.slice(1),t,n,r);const a=this.forks.get("*");return!!a&&(r.set("wildcard",e.join("/")),!!a.handler&&(await a.handler(t,n,r),!0))}}t.yI={hexToUint8Array:function(e){(e.startsWith("0x")||e.startsWith("0X"))&&(e=e.slice(2));const t=e.length/2,n=new Uint8Array(t);for(let r=0;r<t;r++){const t=parseInt(e.slice(2*r,2*r+2),16);n[r]=t}return n},uint8ArrayToHex:function(e){return Array.from(e).map((e=>e.toString(16).padStart(2,"0"))).join("")},binaryToUint8Array:function(e){const t=Math.ceil(e.length/8),n=new Uint8Array(t);for(let r=0;r<t;r++){const t=parseInt(e.slice(8*r,8*r+8),2);n[r]=t}return n},uint8ArrayToBinary:function(e){return Array.from(e).map((e=>e.toString(2).padStart(8,"0"))).join("")},base64ToUint8Array:function(e){return Te(e,Ee)},uint8ArrayToBase64:function(e){return Re(e,Ee)},base32ToUint8Array:function(e){return Te(e,xe)},uint8ArrayToBase32:function(e){return Re(e,xe)},log2Reduce:mt,partition:xt,concatBytes:gt,numberToUint8:function(e){return new Uint8Array([e])},uint8ToNumber:function(e){return e[0]},numberToUint16:function(e,t){const n=new ArrayBuffer(2);return new DataView(n).setUint16(0,e,"LE"===t),new Uint8Array(n)},uint16ToNumber:function(e,t){return new DataView(e.buffer).getUint16(e.byteOffset,"LE"===t)},numberToUint32:function(e,t){const n=new ArrayBuffer(4);return new DataView(n).setUint32(0,e,"LE"===t),new Uint8Array(n)},uint32ToNumber:function(e,t){return new DataView(e.buffer).getUint32(e.byteOffset,"LE"===t)},numberToUint64:vt,uint64ToNumber:function(e,t){return new DataView(e.buffer).getBigUint64(e.byteOffset,"LE"===t)},numberToUint256:Bt,uint256ToNumber:Et,sliceBytes:function(e,t){const n=[];let r=0;for(const o of t)n.push(e.subarray(r,r+o)),r+=o;return n},keccak256:St,sha3_256:function(e){return kt(zt(new Array(50).fill(0),At(e,6)))},proximity:function(e,t){const n=Math.min(e.length,t.length);for(let r=0;r<n;r++){const n=e[r]^t[r];for(let e=0;e<8;e++)if(n>>7-e&1)return 8*r+e}return 8*Math.min(e.length,t.length)},commonPrefix:function(e,t){const n=Math.min(e.length,t.length);for(let r=0;r<n;r++)if(e[r]!==t[r])return e.subarray(0,r);return e.subarray(0,n)},setBit:function(e,t,n,r){const o=Math.floor(t/8),i=t%8;1===n?e[o]|=1<<("BE"===r?7-i:i):e[o]&=~(1<<("BE"===r?7-i:i))},getBit:function(e,t,n){const r=t%8;return e[Math.floor(t/8)]>>("BE"===n?7-r:r)&1},indexOf:function(e,t,n=0){for(let r=n;r<e.length;r++)for(let n=0;n<t.length&&e[r+n]===t[n];n++)if(n===t.length-1)return r;return-1},equals:function(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0},padStart:$t,padStartToMultiple:function(e,t,n=0){const r=e.length%t;return 0===r?e:$t(e,e.length+t-r,n)},padEnd:_t,padEndToMultiple:function(e,t,n=0){const r=e.length%t;return 0===r?e:_t(e,e.length+t-r,n)},xorCypher:function(e,t){const n=new Uint8Array(e.length);for(let r=0;r<e.length;r++)n[r]=e[r]^t[r%t.length];return n},isUtf8:function(e){for(let t=0;t<e.length;t++){const n=e[t];if(!(n<128))if(192==(224&n)){if(t+1>=e.length||128!=(192&e[t+1]))return!1;t+=1}else if(224==(240&n)){if(t+2>=e.length||128!=(192&e[t+1])||128!=(192&e[t+2]))return!1;t+=2}else{if(240!=(248&n))return!1;if(t+3>=e.length||128!=(192&e[t+1])||128!=(192&e[t+2])||128!=(192&e[t+3]))return!1;t+=3}}return!0}},t.o8={intBetween:a,floatBetween:function(e,t,n=Math.random){return n()*(t-e)+e},chance:u,signed:function(){return 2*Math.random()-1},makeSeededRng:function(e){let t=e,n=3405648695,r=3735928559;return function(){return t+=n,n^=t<<7,t*=r,r^=t<<13,t^=n^r,(t>>>0)/4294967296}},point:function(e,t,n,r=Math.random){let o,i;do{o=a(0,e-1,r),i=a(0,t-1,r)}while(n&&c(n,o,i));return[o,i]},procs:function(e,t=Math.random){const n=Math.floor(e);return u(e-n,t)?n+1:n}},t.DO={countUnique:function(e,t,n,r,o){const i=t?e.map(t):e,s={};for(const c of i)s[c]=(s[c]||0)+1;const a=r?lt(s,o?(e,t)=>e[1]-t[1]:(e,t)=>t[1]-e[1]):s;return n?Object.keys(a):a},makeUnique:function(e,t){return Object.values(at(e,t))},splitBySize:function(e,t){const n=[];for(let r=0;r<e.length;r+=t)n.push(e.slice(r,r+t));return n},splitByCount:ct,index:at,indexCollection:function(e,t){const n={};for(const r of e){const e=t(r);n[e]||(n[e]=[]),n[e].push(r)}return n},onlyOrThrow:function(e){if(1===e.length)return e[0];throw Error(`Expected exactly one element, actual: ${e.length}`)},onlyOrNull:function(e){return 1===e.length?e[0]:null},firstOrThrow:function(e){if(!e.length)throw Error("Received empty array");return e[0]},firstOrNull:function(e){return e.length>0?e[0]:null},shuffle:i,initialize:function(e,t){const n=[];for(let r=0;r<e;r++)n.push(t(r));return n},initialize2D:function(e,t,n){const r=[];for(let o=0;o<e;o++){r.push([]);for(let e=0;e<t;e++)r[o].push(n)}return r},rotate2D:function(e){const t=[];for(let n=0;n<e[0].length;n++){t.push([]);for(let r=0;r<e.length;r++)t[n].push(e[r][n])}return t},containsShape:function(e,t,n,r){if(n<0||r<0||r+t[0].length>e[0].length||n+t.length>e.length)return!1;for(let o=0;o<t.length;o++)for(let i=0;i<t[o].length;i++)if(void 0!==t[o][i]&&e[n+o][r+i]!==t[o][i])return!1;return!0},glue:function(e,t){const n=[];for(let r=0;r<e.length;r++)n.push(e[r]),r<e.length-1&&(v(t)?n.push(t()):n.push(t));return n},pluck:function(e,t){return e.map((e=>e[t]))},pick:l,pickMany:function(e,t,n=Math.random){if(t>e.length)throw new Error(`Count (${t}) is greater than array length (${e.length})`);return s(e,t,n).map((t=>e[t]))},pickManyUnique:function(e,t,n,r=Math.random){if(t>e.length)throw new Error(`Count (${t}) is greater than array length (${e.length})`);const o=[];for(;o.length<t;){const t=l(e,r);o.some((e=>n(e,t)))||o.push(t)}return o},pickWeighted:function(e,t,n){if(void 0===n&&(n=Math.random()),e.length!==t.length)throw new Error("Array length mismatch");let r=t.reduce(((e,t)=>e+t),0);const o=n*r;for(let i=0;i<e.length-1;i++)if(r-=t[i],o>=r)return e[i];return f(e)},pickRandomIndices:s,pickGuaranteed:function(e,n,r,o,s,a=Math.random){const c=e.filter((e=>e!==n&&e!==r)),u=[];for(null!==n&&u.push(n);c.length&&u.length<o;){const e=t.o8.intBetween(0,c.length-1,a);s(c[e],u)&&u.push(c[e]),c.splice(e,1)}return i(u,a),{values:u,indexOfGuaranteed:null!==n?u.indexOf(n):-1}},last:f,pipe:h,makePipe:function(e,t){return n=>h(n,e,t)},sortWeighted:function(e,t,n=Math.random){const r=t.map((e=>n()*e)),o=[];for(let i=0;i<e.length;i++)o.push([e[i],r[i]]);return o.sort(((e,t)=>t[1]-e[1])).map((e=>e[0]))},pushAll:q,unshiftAll:function(e,t){Array.prototype.unshift.apply(e,t)},filterAndRemove:function(e,t){const n=[];for(let r=e.length-1;r>=0;r--)t(e[r])&&n.push(e.splice(r,1)[0]);return n},merge:function(e,t){const n=Object.keys(t);for(const r of n)Array.isArray(t[r])&&Array.isArray(e[r])&&q(e[r],t[r])},empty:function(e){return e.splice(0,e.length),e},pushToBucket:function(e,t,n){e[t]||(e[t]=[]),e[t].push(n)},unshiftAndLimit:function(e,t,n){for(e.unshift(t);e.length>n;)e.pop()},atRolling:function(e,t){let n=t%e.length;return n<0&&(n+=e.length),e[n]},group:ft,createOscillator:function(e){let t=0;return{next:()=>e[t++%e.length]}},organiseWithLimits:function(e,t,n,r,o){const i={};for(const s of Object.keys(t))i[s]=[];i[r]=[],o&&(e=e.sort(o));for(const s of e){const e=s[n],o=t[e]?e:r;i[o].length>=t[o]?i[r].push(s):i[o].push(s)}return i},tickPlaybook:function(e){if(0===e.length)return null;const t=e[0];return t.ttlMax?--t.ttl<=0&&e.shift():t.ttlMax=t.ttl,{progress:(t.ttlMax-t.ttl)/t.ttlMax,data:t.data}},getArgument:Kt,getBooleanArgument:function(e,t,n,r){const o=e.some((e=>e.endsWith("-"+t))),i=Kt(e,t,n,r);if(!i&&o)return!0;if(!i&&!o)return null;if(["true","1","yes","y","on"].includes(i.toLowerCase()))return!0;if(["false","0","no","n","off"].includes(i.toLowerCase()))return!1;throw Error(`Invalid boolean argument ${t}: ${i}`)},getNumberArgument:function(e,t,n,r){const o=Kt(e,t,n,r);if(!o)return null;try{return rt(o)}catch{throw new Error(`Invalid number argument ${t}: ${o}`)}},requireStringArgument:Jt,requireNumberArgument:function(e,t,n,r){const o=Jt(e,t,n,r);try{return rt(o)}catch{throw new Error(`Invalid argument ${t}: ${o}`)}},bringToFront:function(e,t){const n=[...e];return Xt(n,t),n},bringToFrontInPlace:Xt,findInstance:function(e,t){const n=e.find((e=>e instanceof t));return dt.of(n)},filterInstances:function(e,t){return e.filter((e=>e instanceof t))},interleave:function(e,t){const n=[],r=Math.max(e.length,t.length);for(let o=0;o<r;o++)e[o]&&n.push(e[o]),t[o]&&n.push(t[o]);return n},toggle:function(e,t){return e.includes(t)?e.filter((e=>e!==t)):[...e,t]},createHierarchy:function(e,t,n,r,o=!1){const i=new Map,s=[];e.forEach((e=>{const n=new pt(e);i.set(e[t],n)})),e.forEach((e=>{const r=i.get(e[t]);if(!r)return;const o=e[n];if(o){const e=i.get(o);e&&e.children.push(r)}else s.push(r)}));const a=e=>{e.children.sort(((e,t)=>{const n=e.value[r],i=t.value[r];return o?i-n:n-i})),e.children.forEach(a)};return s.forEach(a),s},multicall:function(e){return()=>e.forEach((e=>e()))},maxBy:function(e,t){return e.reduce(((e,n)=>t(e)>t(n)?e:n))},minBy:function(e,t){return e.reduce(((e,n)=>t(e)<t(n)?e:n))},allIndexOf:function(e,t){const n=[];return e.forEach(((e,r)=>{t(e)&&n.push(r)})),n}},t.iQ={sleepMillis:o,forever:async function(e,t,n){for(;;){try{await e()}catch(r){n&&n("Error in forever",r)}await o(t)}},scheduleMany:function(e,t){for(let n=0;n<e.length;n++){const r=e[n],o=t[n],i=Math.max(0,o.getTime()-Date.now());setTimeout(r,i)}},waitFor:async function(e,t){let n=t.requiredConsecutivePasses||1,r=0;for(let i=0;i<t.attempts;i++){try{if(await e()){if(r++,r>=n)return}else r=0}catch{r=0}i<t.attempts-1&&await o(t.waitMillis)}throw Error("Timed out waiting for predicate")},expandError:function(e,t){if(B(e))return e;const n=Object.keys(e);e.message&&!n.includes("message")&&n.push("message");const r=n.map((t=>`${t}: ${e[t]}`)).join("; ");return t&&e.stack?r+"\n"+e.stack:r},runAndSetInterval:function(e,t){e();const n=setInterval((()=>{e()}),t);return()=>clearInterval(n)},whereAmI:function(){const e=globalThis.process;return e?!0===e.browser?"browser":"node":"browser"},withRetries:async function(e,t,n,r,i,s){let a=null;for(let u=0;u<=t;u++)try{return await e()}catch(c){if(a=c,u===t)break;const e=n+u/(t-1)*(r-n);i&&i("Error in withRetries, retrying",{attempt:u+1,allowedFailures:t,delayMillis:e,error:c}),s&&s(),await o(e)}throw a}},t.FQ={make:rt,sum:function(e){return e.reduce(((e,t)=>e+t),0)},average:function(e){return e.reduce(((e,t)=>e+t),0)/e.length},median:function(e){const t=[...e].sort(((e,t)=>e-t)),n=Math.floor(t.length/2);return t.length%2==0?(t[n]+t[n-1])/2:t[n]},getDistanceFromMidpoint:function(e,t){return e-(t-1)/2},clamp:ot,range:H,interpolate:function(e,t,n){return e+(t-e)*n},createSequence:function(){let e=0;return{next:()=>e++}},increment:function(e,t,n){const r=e+t;return r>n?n:r},decrement:function(e,t,n){const r=e-t;return r<n?n:r},format:function(e,t){const n=t?.longForm??!1,r=t?.unit?` ${t.unit}`:"",o=n?tt:nt,i=t?.precision??1;if(e<et[0])return`${e}${r}`;for(let s=0;s<et.length-1;s++)if(e<et[s+1])return`${(e/et[s]).toFixed(i)}${n?" ":""}${o[s]}${r}`;return`${(e/et[et.length-1]).toFixed(i)}${n?" ":""}${o[et.length-1]}${r}`},fromDecimals:function(e,t,n){let r=e.length-t;if(r<=0)return"0."+"0".repeat(-r)+e+(n?" "+n:"");let o=e.substring(0,r);return""===o&&(o="0"),o+"."+e.substring(r)+(n?" "+n:"")},makeStorage:function(e,t=1024){const n=parseFloat(e);if(isNaN(n))throw Error("makeStorage got NaN for input");const r=e.replace(/^-?[0-9.]+/,"").trim().toLowerCase(),o=""===r?0:qe[r];if(null==o)throw Error(`Unknown unit: "${r}"`);return Math.ceil(n*t**o)},asMegabytes:function(e){return e/1024/1024},convertBytes:function(e,t=1024){return e>=t*t*t*t?(e/t/t/t/t).toFixed(3)+" TB":e>=t*t*t?(e/t/t/t).toFixed(3)+" GB":e>=t*t?(e/t/t).toFixed(3)+" MB":e>=t?(e/t).toFixed(3)+" KB":e+" B"},hexToRgb:function(e){const t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e.toLowerCase());if(!t)throw new Error("Invalid hex color: "+e);return[parseInt(t[1],16),parseInt(t[2],16),parseInt(t[3],16)]},rgbToHex:function(e){return"#"+e.map((e=>e.toString(16).padStart(2,"0"))).join("")},haversineDistanceToMeters:function(e,t,n,r){const o=e*Math.PI/180,i=n*Math.PI/180,s=(n-e)*Math.PI/180,a=(r-t)*Math.PI/180,c=Math.sin(s/2)*Math.sin(s/2)+Math.cos(o)*Math.cos(i)*Math.sin(a/2)*Math.sin(a/2);return 2*Math.atan2(Math.sqrt(c),Math.sqrt(1-c))*6371e3},roundToNearest:m,formatDistance:function(e){return e>1e3?(e/1e3).toFixed(0)+" km":e>=500?m(e,100)+" m":e>=100?m(e,50)+" m":m(e,10)+" m"},triangularNumber:function(e){return e*(e+1)/2},searchFloat:function(e){const t=e.match(/-?\d+(\.\d+)?/);if(!t)throw Error("No float found in "+e);return parseFloat(t[0])},binomialSample:function(e,t,n=Math.random){const r=e*t,o=Math.sqrt(e*t*(1-t)),i=(n()+n()+n()+n()+n()+n()-3)*Math.SQRT2,s=Math.round(r+o*i);return Math.max(0,Math.min(e,s))},toSignificantDigits:function(e,t){if(!e.includes("."))return e;if(0===parseFloat(e))return"0";const[n,r]=e.split("."),o=n.replace("-",""),i=o.length;if(i>=t)return n;if("0"!==o){const e=t-i,o=r.slice(0,e);return/[1-9]/.test(o)?`${n}.${o.replace(/0+$/,"")}`:n}const s=t+(r.match(/^0*/)?.[0].length??0);return`${n}.${r.slice(0,s)}`}},t.AO={getTimestamp:function(e,t){const n=new Date(t?.now||Date.now()),r=t?.labels||Ce,o=T(e)?e:new Date(e);if(Pe(n)===Pe(o))return r.today(o.getUTCHours(),o.getUTCMinutes(),o.getUTCHours()>12);if(Pe(n)-Pe(o)==1)return r.yesterday();const i=je(o);return Pe(n)-Pe(o)<7?r[i.day]():r.weeks(Math.round((n.getTime()-o.getTime())/6048e5))},getTimeDelta:Ne,secondsToHumanTime:function(e,t=Fe){return Ne(0,{now:1e3*e,labels:t})},countCycles:function(e,t,n){const r=(n?.now??Date.now())-e;return{cycles:Math.floor(r/t),remaining:t/(n?.precision??1)-Math.ceil(r%t/(n?.precision??1))}},isoDate:function(e){return(e||new Date).toISOString().slice(0,10)},throttle:function(e,t){return(!Me[e]||Date.now()>Me[e])&&(Me[e]=Date.now()+t,!0)},timeSince:function(e,t,n){return t=T(t)?t.getTime():t,((n=n?T(n)?n.getTime():n:Date.now())-t)/Ue[e]},dateTimeSlug:function(e){return(e||new Date).toISOString().slice(0,19).replace(/T|:/g,"-")},unixTimestamp:function(e){return Math.ceil((e||Date.now())/1e3)},fromUtcString:function(e){const t=new Date(e);return new Date(t.getTime()-6e4*t.getTimezoneOffset())},fromMillis:function(e){return new Date(e)},getProgress:function(e,t,n,r){r||(r=Date.now());const o=r-e,i=o/t,s=i*n;return{deltaMs:o,progress:t/n,baseTimeMs:i,totalTimeMs:s,remainingTimeMs:s-o}},humanizeTime:Ve,humanizeProgress:function(e){return`[${Math.floor(100*e.progress)}%] ${Ve(e.deltaMs)} out of ${Ve(e.totalTimeMs)} (${Ve(e.remainingTimeMs)} left) [${Math.round(e.baseTimeMs)} ms each]`},createTimeDigits:De,mapDayNumber:Le,getDayInfoFromDate:je,getDayInfoFromDateTimeString:function(e){return je(new Date(e))},seconds:function(e){return 1e3*e},minutes:function(e){return 6e4*e},hours:function(e){return 36e5*e},days:function(e){return 864e5*e},make:function(e){const t=parseFloat(e);if(isNaN(t))throw Error("makeDate got NaN for input");const n=e.replace(/^-?[0-9.]+/,"").trim().toLowerCase(),r=""===n?1:Ze[n];if(!r)throw Error(`Unknown unit: "${n}"`);return Math.ceil(t*r)},normalizeTime:function(e){let[t,n]=e.split(":");E(parseInt(t,10))||(t="0"),E(parseInt(n,10))||(n="0");let r=ot(F(t),0,23),o=ot(F(n),0,59);return`${De(r)}:${De(o)}`},absoluteDays:Pe},t.Rb={safeParse:function(e){try{return JSON.parse(e)}catch{return null}},deleteDeep:function(e,t){const n=Q(t,"."),r=ee(t,".");if(!n||!r)return;const o=d(e,n);o&&delete o[r]},getDeep:d,setDeep:p,incrementDeep:function(e,t,n=1){const r=d(e,t)||0;return p(e,t,r+n),r},ensureDeep:function(e,t,n){return d(e,t)||p(e,t,n)},replaceDeep:function(e,t,n){const r=d(e,t);if(!r)throw new Error("Key '"+t+"' does not exist.");return p(e,t,n),r},getFirstDeep:function(e,t,n){for(const r of t){const t=d(e,r);if(t)return t}if(n){const t=Object.values(e);if(t.length)return t[0]}return null},deepMergeInPlace:j,deepMerge2:function(e,t){const n={};return j(n,e),j(n,t),n},deepMerge3:function(e,t,n){const r={};return j(r,e),j(r,t),j(r,n),r},mapAllAsync:async function(e,t){const n=[];for(const r of e)n.push(await t(r));return n},cloneWithJson:function(e){return JSON.parse(JSON.stringify(e))},sortObject:Ke,sortArray:Je,sortAny:Xe,deepEquals:Ye,deepEqualsEvery:function(...e){for(let t=1;t<e.length;t++)if(!Ye(e[t-1],e[t]))return!1;return!0},runOn:function(e,t){return t(e),e},ifPresent:function(e,t){e&&t(e)},zip:Z,zipSum:function(e){return Z(e,((e,t)=>e+t))},removeEmptyArrays:function(e){for(const t of Object.keys(e))(w(e[t])||Array.isArray(e[t])&&e[t].every((e=>null==e)))&&delete e[t];return e},removeEmptyValues:function(e){for(const t of Object.entries(e))(null===t[1]||void 0===t[1]||B(t[1])&&R(t[1]))&&delete e[t[0]];return e},flatten:function(e,t=!1,n){return st({},e,n||"",!1,t)},unflatten:function e(t){if(!g(t))return t;const n=Array.isArray(t)?[]:{};for(const[r,o]of Object.entries(t))Array.isArray(o)?p(n,r,o.map((t=>e(t)))):p(n,r,o);return n},match:function(e,t,n){return t[e]?t[e]:n},sort:lt,map:function(e,t){const n={};for(const r of Object.entries(e))n[r[0]]=t(r[1]);return n},mapIterable:function(e,t){const n=[];let r=0;for(const o of e)n.push(t(o,r++));return n},filterKeys:function(e,t){const n={};for(const[r,o]of Object.entries(e))t(r)&&(n[r]=o);return n},filterValues:function(e,t){const n={};for(const[r,o]of Object.entries(e))t(o)&&(n[r]=o);return n},rethrow:async function(e,t){try{return await e()}catch{throw t}},setSomeOnObject:function(e,t,n){null!=n&&(e[t]=n)},setSomeDeep:function(e,t,n,r){const o=d(n,r);null!=o&&p(e,t,o)},flip:function(e){const t={};for(const[n,r]of Object.entries(e))t[r]=n;return t},getAllPermutations:function(e){const t=Object.keys(e),n=t.map((t=>e[t].length)),r=n.reduce(((e,t)=>e*t));let o=1;const i=[1];for(let a=0;a<n.length-1;a++)o*=n[a],i.push(o);const s=[];for(let a=0;a<r;a++){const n={};for(let r=0;r<t.length;r++){const o=e[t[r]],s=Math.floor(a/i[r])%o.length;n[t[r]]=o[s]}s.push(n)}return s},countTruthyValues:function(e){return Object.values(e).filter((e=>e)).length},transformToArray:function(e){const t=[],n=Object.keys(e),r=e[n[0]].length;for(let o=0;o<r;o++){const r={};for(const t of n)r[t]=e[t][o];t.push(r)}return t},setMulti:function(e,t,n){for(const r of e)r[t]=n},incrementMulti:function(e,t,n=1){for(const r of e)r[t]+=n},createBidirectionalMap:function(){return{map:new Map,keys:[]}},createTemporalBidirectionalMap:function(){return{map:new Map,keys:[]}},pushToBidirectionalMap:ht,unshiftToBidirectionalMap:function(e,t,n,r=100){if(e.map.has(t)){const n=e.keys.indexOf(t);e.keys.splice(n,1)}if(e.map.set(t,n),e.keys.unshift(t),e.keys.length>r){const t=e.keys.shift();t&&e.map.delete(t)}},addToTemporalBidirectionalMap:function(e,t,n,r,o=100){ht(e,t,{validUntil:Date.now()+r,data:n},o)},getFromTemporalBidirectionalMap:function(e,t){const n=e.map.get(t);return n&&n.validUntil>Date.now()?n.data:null},createStatefulToggle:function(e){let t;return n=>{const r=n===e&&t!==e;return t=n,r}},diffKeys:function(e,t){const n=Object.keys(e),r=Object.keys(t);return{uniqueToA:n.filter((e=>!r.includes(e))),uniqueToB:r.filter((e=>!n.includes(e)))}},pickRandomKey:Qe,mapRandomKey:function(e,t){const n=Qe(e);return e[n]=t(e[n]),n},fromObjectString:function(e){return e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=e.replace(/\r\n/g,"\n")).replace(/(\w+)\((.+)\)/g,((e,t,n)=>`${t}(${n.replaceAll(",",",")})`))).replace(/(,)(\s+})/g,"$2")).replace(/\.\.\..+?,/g,"")).replace(/({\s+)([a-zA-Z]\w+),/g,"$1$2: '$2',")).replace(/(,\s+)([a-zA-Z]\w+),/g,"$1$2: '$2',")).replace(/:(.+)\?(.+):/g,((e,t,n)=>`: (${t.trim()} && ${n.trim()}) ||`))).replace(/([a-zA-Z0-9]+)( ?: ?{)/g,'"$1"$2')).replace(/([a-zA-Z0-9]+) ?: ?(.+?)(,|\n|})/g,((e,t,n,r)=>`"${t}":"${n.trim()}"${r}`))).replace(/("'|'")/g,'"')).replaceAll(",",","),JSON.parse(e)},toQueryString:Ie,parseQueryString:function(e){const t={},n=e.split("&");for(const r of n){const[e,n]=r.split("=");e&&n&&(t[e]=decodeURIComponent(n))}return t},hasKey:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},selectMax:function(e,t){let n=null,r=-1/0;for(const[o,i]of Object.entries(e)){const e=t(i);e>r&&(r=e,n=o)}return n?[n,e[n]]:null},reposition:function(e,t,n,r){const o=e.find((e=>e[t]===n)),i=e.find((e=>e[t]===n+r));o&&i?(o[t]=n+r,i[t]=n):o&&(o[t]=n+r),e.sort(((e,n)=>C(e[t])-C(n[t]))),e.forEach(((e,n)=>e[t]=n+1))},unwrapSingleKey:function(e){const t=Object.keys(e);if(1===t.length)return e[t[0]];throw new Error("Expected object to have a single key")},parseKeyValues:function(e,t=":"){return Object.fromEntries(e.map((e=>te(e,t))).map((e=>e[0]&&e[1]?[ie(e[0]),ie(e[1])]:null)).filter((e=>e)))},errorMatches:function(e,t){if(!e)return!1;const n=e.message;return"string"==typeof n&&n.includes(t)}},t.Or={isFunction:v,isObject:g,isStrictlyObject:y,isEmptyArray:w,isEmptyObject:function(e){return y(e)&&0===Object.keys(e).length},isUndefined:b,isString:B,isNumber:E,isBoolean:x,isDate:T,isBlank:R,isId:O,isIntegerString:A,isHexString:z,isUrl:M,isBigint:U,isNullable:function(e,t){return null==t||e(t)},asString:V,asHexString:function(e,t){if(!z(e))throw new TypeError(`Expected hex string${t?.name?` for ${t.name}`:""}, got: `+e);if(t?.strictPrefix&&!e.startsWith("0x")&&!e.startsWith("0X"))throw new TypeError(`Expected hex string with 0x prefix${t?.name?` for ${t.name}`:""}, got: `+e);const n=e.replace(/^0x/i,"");if(n.length%2!=0&&!t?.uneven)throw RangeError(`Expected even number of hex digits${t?.name?` for ${t.name}`:""}; got: `+e);if(t&&t.byteLength&&n.length!==2*t.byteLength)throw RangeError(`Expected hex string${t?.name?` for ${t.name}`:""} of byte length ${t.byteLength}; got: `+n);return`0x${n}`},asSafeString:function(e,t){if(!V(e,t).split("").every((e=>"_"===e||le(e))))throw new TypeError(`Expected safe string${t?.name?` for ${t.name}`:""}, got: `+e);return e},asIntegerString:function(e,t){if(!A(e))throw new TypeError(`Expected integer string${t?.name?` for ${t.name}`:""}, got: `+e);const n=BigInt(e);if(t&&(t.min&&n<t.min||t.max&&n>t.max))throw RangeError(`Expected integer string${t?.name?` for ${t.name}`:""} in range: ${t.min??"-inf"}..${t.max??"inf"}; got: `+n);return e},asNumber:C,asFunction:function(e,t){if(!v(e))throw new TypeError(`Expected function${t?.name?` for ${t.name}`:""}, got: `+e);return e},asInteger:F,asBoolean:function(e,t){if("true"===e)return!0;if("false"===e)return!1;if(!x(e))throw new TypeError(`Expected boolean${t?.name?` for ${t.name}`:""}, got: `+e);return e},asDate:function(e,t){if(!T(e))throw new TypeError(`Expected date${t?.name?` for ${t.name}`:""}, got: `+e);return e},asNullableString:function(e){return R(e)?null:e},asEmptiableString:function(e,t){if(!B(e))throw new TypeError(`Expected string${t?.name?` for ${t.name}`:""}, got: `+e);return e},asId:function(e,t){if(O(e))return e;const n=parseInt(e,10);if(!O(n))throw new TypeError(`Expected id${t?.name?` for ${t.name}`:""}, got: `+e);return n},asTime:function(e,t){if(!B(e))throw new TypeError(`Expected time${t?.name?` for ${t.name}`:""}, got: `+e);const n=e.split(":");if(2!==n.length)throw new TypeError(`Expected time${t?.name?` for ${t.name}`:""}, got: `+e);const r=parseInt(n[0],10),o=parseInt(n[1],10);if(!E(r)||!E(o)||r<0||r>23||o<0||o>59)throw new TypeError(`Expected time, got${t?.name?` for ${t.name}`:""}: `+e);return`${String(r).padStart(2,"0")}:${String(o).padStart(2,"0")}`},asArray:function(e,t){if(!Array.isArray(e))throw new TypeError(`Expected array${t?.name?` for ${t.name}`:""}, got: `+e);return e},asObject:N,asNullableObject:function(e,t){return null===e?null:N(e,t)},asStringMap:function(e,t){const n=N(e,t);for(const r of Object.keys(n))if(!B(n[r]))throw new TypeError(`Expected string map${t?.name?` for ${t.name}`:""}, got: `+e);return n},asNumericDictionary:function(e,t){const n=N(e),r=Object.keys(n),o=Object.values(n);if(!r.every(B)||!o.every(E))throw new TypeError(`Expected numeric dictionary${t?.name?` for ${t.name}`:""}, got: `+e);return n},asUrl:function(e,t){if(!M(e))throw new TypeError(`Expected url${t?.name?` for ${t.name}`:""}, got: `+e);return e},asBigint:G,asEmptiable:function(e,t){return""===t?void 0:e(t)},asNullable:function(e,t){return null==t?null:e(t)},asOptional:function(e,t){return null==t?void 0:e(t)},enforceObjectShape:L,enforceArrayShape:function(e,t){return e.every((e=>L(e,t)))},isPng:yt,isJpg:wt,isWebp:bt,isImage:function(e){return yt(e)||wt(e)||bt(e)}},t.DH={tokenizeByCount:function(e,t){return ut(e,Math.ceil(e.length/t))},tokenizeByLength:ut,searchHex:function(e,t){const n=new RegExp(`[0-9a-f]{${t}}`,"i"),r=e.match(n);return r?r[0]:null},searchSubstring:function(e,t,n=k){const r=ne(e,n);for(const o of r)if(t(o))return o;return null},randomHex:function(e,t=Math.random){let n="";for(let r=0;r<e;r++)n+=D[Math.floor(16*t())];return n},randomLetter:function(e,t=Math.random){let n="";for(let r=0;r<e;r++)n+=S[Math.floor(26*t())];return n},randomAlphanumeric:function(e,t=Math.random){let n="";for(let r=0;r<e;r++)n+=$[Math.floor(62*t())];return n},randomRichAscii:function(e,t=Math.random){let n="";for(let r=0;r<e;r++)n+=_[Math.floor(89*t())];return n},randomUnicode:function(e,t=Math.random){let n="";for(let r=0;r<e;r++)n+=I[Math.floor(t()*I.length)];return n},includesAny:function(e,t){return t.some((t=>e.includes(t)))},slugify:W,normalForm:function(e){return W(e).replaceAll("-","")},enumify:function(e){return W(e).replace(/-/g,"_").toUpperCase()},escapeHtml:function(e){return e.replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")},decodeHtmlEntities:function(e){let t=e.replace(/&#(\d+);/g,((e,t)=>String.fromCharCode(t))).replace(/&#x(\d+);/g,((e,t)=>String.fromCharCode(parseInt(t,16))));for(const[n,r]of Object.entries(J))t=t.replaceAll(n,r);return t},after:Y,afterLast:ee,before:X,beforeLast:Q,betweenWide:function(e,t,n){const r=Q(e,n);return r?Y(r,t):null},betweenNarrow:function(e,t,n){const r=Y(e,t);return r?X(r,n):null},getPreLine:function(e){return e.replace(/ +/g," ").replace(/^ /gm,"")},containsWord:ke,containsWords:function(e,t,n){return"any"===n?t.some((t=>ke(e,t))):t.every((t=>ke(e,t)))},joinUrl:We,getFuzzyMatchScore:K,sortByFuzzyScore:function(e,t){return e.filter((e=>K(e,t))).sort(((e,n)=>K(n,t)-K(e,t)))},splitOnce:te,splitAll:ne,randomize:function(e,t=Math.random){return e.replace(/\{(.+?)\}/g,((e,n)=>l(n.split("|"),t)))},expand:function e(t){const n=t.match(/\{(.+?)\}/);if(!n||!n.index)return[t];const r=n[1].split(","),o=t.slice(0,n.index),i=t.slice(n.index+n[0].length);let s=[];for(const a of r){const t=e(o+a+i);s=s.concat(t)}return s},shrinkTrim:ie,capitalize:se,decapitalize:ae,csvEscape:function(e){return e.match(/"|,/)?`"${e.replace(/"/g,'""')}"`:e},parseCsv:function(e,t=",",n='"'){const r=[];let o="",i=!1;const s=e.split("");for(const a of s)a!==t||i?a!==n||(o||i)&&!i?o+=a:i=!i:(r.push(o),o="");return r.push(o),r},surroundInOut:function(e,t){return t+e.split("").join(t)+t},getExtension:re,getBasename:oe,normalizeEmail:function(e){let[t,n]=e.split("@");t=ie(t.replaceAll(".","").toLowerCase()).replaceAll(" ","");const[r]=t.split("+");if(!r||!n||-1===n.indexOf(".")||n.indexOf(".")===n.length-1)throw new Error("Invalid email");return n=ie(n.toLowerCase()).replaceAll(" ",""),`${r}@${n}`},normalizeFilename:function(e){const t=oe(e),n=re(e);return n?`${t}.${n}`:t},parseFilename:function(e){const t=oe(e),n=re(e);return{basename:t,extension:n,filename:n?`${t}.${n}`:t}},camelToTitle:function(e){return se(e.replace(/([A-Z])/g," $1"))},slugToTitle:function(e){return e.split("-").map(se).join(" ")},slugToCamel:function(e){return ae(e.split("-").map(se).join(""))},joinHumanly:function(e,t=", ",n=" and "){return e&&e.length?1===e.length?e[0]:2===e.length?`${e[0]}${n}${e[1]}`:`${e.slice(0,e.length-1).join(t)}${n}${e[e.length-1]}`:""},findWeightedPair:ve,extractBlock:Be,extractAllBlocks:function(e,t){const n=[];let r=t.wordBoundary?ge(e,[`${t.opening} `,`${t.opening}\n`],t.start||0):e.indexOf(t.opening,t.start||0);for(;;){if(-1===r)return n;const o=Be(e,{...t,start:r});if(!o)return n;n.push(o),r=t.wordBoundary?ge(e,[`${t.opening} `,`${t.opening}\n`],r+o.length):e.indexOf(t.opening,r+o.length)}},replaceBlocks:function(e,n,r){let o=0;for(;;){const i=t.DH.extractBlock(e,{...r,start:o});if(!i)return e;const s=n(i);o=e.indexOf(i,o)+s.length,e=e.replace(i,s)}},indexOfEarliest:ge,lastIndexOfBefore:be,parseHtmlAttributes:function(e){const t={},n=e.match(/([a-z\-]+)="([^"]+)"/g);if(n)for(const r of n){const[e,n]=te(r,"=");t[e]=n.slice(1,n.length-1)}return t},readNextWord:Se,readWordsAfterAll:function(e,t,n=[]){const r=me(e,t),o=[];for(const i of r)o.push(Se(e,i+t.length,n));return o},resolveVariables:function(e,t,n="$",r=":"){for(const o in t)e=$e(e,o,t[o],n,r);return e=_e(e)},resolveVariableWithDefaultSyntax:$e,resolveRemainingVariablesWithDefaults:_e,isLetter:ce,isDigit:ue,isLetterOrDigit:le,isValidObjectPathCharacter:function(e){return le(e)||"."===e||"["===e||"]"===e||"_"===e},insert:function(e,t,n,r,o){return e.slice(0,t)+r+e.slice(t,t+n)+o+e.slice(t+n)},indexOfRegex:de,allIndexOf:me,lineMatches:pe,linesMatchInOrder:function(e,t,n=!0){let r=0;for(const o of t){let t=!1;for(;!t&&r<e.length;)pe(e[r],o,n)&&(t=!0),r++;if(!t)return!1}return!0},represent:function e(t,n="json",r=0){if(t&&v(t.represent)){const e=t.represent();if(B(e))return"json"===n&&0===r?JSON.stringify(e):e}if(g(t,!1)){if(r>1)return"[object Object]";if("json"===n){if(Array.isArray(t)){const n=t.map((t=>e(t,"json",r+1)));return 0===r?JSON.stringify(n):n}const n={};t.message&&(n.message=e(t.message,"json",r+1));for(const[o,i]of Object.entries(t))n[o]=e(i,"json",r+1);return 0===r?JSON.stringify(n):n}if("key-value"===n){const n=Object.keys(t);return t.message&&!n.includes("message")&&n.unshift("message"),n.map((n=>`${n}=${JSON.stringify(e(t[n],"json",r+1))}`)).join(" ")}}return b(t)&&(t="undefined"),0===r?JSON.stringify(t):t},resolveMarkdownLinks:function(e,t){let n=e.indexOf("](");for(;-1!==n;){const r=be(e,"[",n),o=e.indexOf(")",n);if(-1!==r&&-1!==o){const[n,i]=e.slice(r+1,o).split("]("),s=t(n,i);e=e.slice(0,r)+s+e.slice(o+1)}n=e.indexOf("](",n+1)}return e},buildUrl:function(e,t,n){return We([e,t])+Ie(n||{})},isChinese:function(e){return/^[\u4E00-\u9FA5]+$/.test(e)},replaceBetweenStrings:function(e,t,n,r,o=!0){const i=e.indexOf(t),s=e.indexOf(n,i+t.length);if(-1===i||-1===s)throw Error("Start or end not found");return o?e.substring(0,i+t.length)+r+e.substring(s):e.substring(0,i)+r+e.substring(s+n.length)},describeMarkdown:function(e){let t="p";return e.startsWith("#")?(t="h1",e=e.slice(1).trim()):e.startsWith("-")&&(t="li",e=e.slice(1).trim()),{type:t,isCapitalized:e[0]===e[0].toUpperCase(),hasPunctuation:/[.?!]$/.test(e),endsWithColon:/:$/.test(e)}},isBalanced:function(e,t="(",n=")"){let r=0,o=0;for(;o<e.length;)if(e.startsWith(t,o)?(r++,o+=t.length):e.startsWith(n,o)?(r--,o+=n.length):o++,r<0)return!1;return t===n?r%2==0:0===r},textToFormat:function(e){let t=(e=e.normalize("NFD").replace(/[\u0300-\u036f]/g,"")).length;for(;(e=e.replace(/(\w+)[\s,']+\w+/g,"$1")).length!==t;)t=e.length;return e=(e=(e=e.replaceAll(/[A-Z][a-zA-Z0-9]*/g,"A")).replaceAll(/[a-z][a-zA-Z0-9]*/g,"a")).replaceAll(/[\u4E00-\u9FA5]+/g,"Z")},splitFormatting:function(e,t){const n=[];let r=0;for(;r<e.length;){const o=e.indexOf(t,r);if(-1===o){n.push({string:e.slice(r),symbol:null});break}const i=e.indexOf(t,o+t.length);if(o>r&&-1!==i&&n.push({string:e.slice(r,o),symbol:null}),-1===i){n.push({string:e.slice(r),symbol:null});break}n.push({string:e.slice(o+t.length,i),symbol:t}),r=i+t.length}return n},splitHashtags:function(e){const t=[];let n=0;for(;n<e.length;){const r=we(e,n);if(-1===r){t.push({string:e.slice(n),symbol:null});break}const o=ye(e,r+1);if(-1===o){t.push({string:e.slice(n,r),symbol:null}),t.push({string:e.slice(r+1),symbol:"#"});break}r>n&&t.push({string:e.slice(n,r),symbol:null}),t.push({string:e.slice(r+1,o),symbol:"#"}),n=o}return t},splitUrls:function(e){const t=[];let n=0;for(;n<e.length;){const r=ge(e,["http://","https://"],n);if(-1===r){t.push({string:e.slice(n),symbol:null});break}const o=ge(e,[" ","\n"],r);if(-1===o){r>n&&t.push({string:e.slice(n,r),symbol:null}),t.push({string:e.slice(r),symbol:"http"});break}r>n&&t.push({string:e.slice(n,r),symbol:null}),t.push({string:e.slice(r,o),symbol:"http"}),n=o}return t},route:function(e,t){const n=e.split("/").filter((e=>e)),r=t.split("/").filter((e=>e));if(n.length!==r.length)return null;const o={};for(let i=0;i<n.length;i++){const e=n[i];if(e.startsWith(":"))o[e.slice(1)]=r[i];else if(e!==r[i])return null}return o},explodeReplace:Oe,generateVariants:function(e,n,r,o=Math.random){const i=t.DO.shuffle(n.map((e=>({variants:t.DO.shuffle(e.variants.map((e=>e)),o),avoid:e.avoid}))),o),s=[];for(const t of i){const n=t.variants.filter((e=>e!==t.avoid)),o=n.find((t=>e.includes(t)));if(o&&(q(s,Oe(e,o,n)),s.length>=r))break}if(s.length<r)for(const t of i){const n=t.variants.find((t=>e.includes(t)));if(n&&(q(s,Oe(e,n,t.variants)),s.length>=r))break}return s.slice(0,r)},replaceWord:function(e,t,n,r=!1){const o=new RegExp(r?`(?<=\\s|^)${t}(?=\\s|$)`:`\\b${t}\\b`,"g");return e.replace(o,n)},replacePascalCaseWords:function(e,t){return e.replace(/\b[A-Z][a-zA-Z0-9]*\b/g,(e=>e.toUpperCase()===e?e:t(e)))},stripHtml:function(e){return e.replace(/<[^>]*>/g,"")},breakLine:Ae,measureTextWidth:function(e,t={}){return[...e].reduce(((e,n)=>e+(t[n]||1)),0)},toLines:function(e,t,n={}){const r=[];let o="",i=0;for(let s=0;s<e.length;s++){const a=e[s];if(o+=a,i+=n[a]||1,i>t){const{line:e,rest:t}=Ae(o);r.push(e),o=t,i=t.split("").map((e=>n[e]||1)).reduce(((e,t)=>e+t),0)}}return o&&r.push(o),r},levenshteinDistance:function(e,t){const n=[];for(let r=0;r<=e.length;r++)n[r]=[r];for(let r=0;r<=t.length;r++)n[0][r]=r;for(let r=1;r<=e.length;r++)for(let o=1;o<=t.length;o++){const i=e[r-1]===t[o-1]?0:1;n[r][o]=Math.min(n[r-1][o]+1,n[r][o-1]+1,n[r-1][o-1]+i)}return n[e.length][t.length]},findCommonPrefix:ze,findCommonDirectory:function(e){const t=ze(e),n=t.lastIndexOf("/");return-1===n?"":t.slice(0,n+1)}}},878(e,t,n){t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const n="color: "+this.color;t.splice(1,0,n,"color: inherit");let r=0,o=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(r++,"%c"===e&&(o=r))})),t.splice(o,0,n)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(n){}},t.load=function(){let e;try{e=t.storage.getItem("debug")||t.storage.getItem("DEBUG")}catch(n){}!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG);return e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let e;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[1],10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=n(945)(t);const{formatters:r}=e.exports;r.j=function(e){try{return JSON.stringify(e)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}},945(e,t,n){e.exports=function(e){function t(e){let n,o,i,s=null;function a(...e){if(!a.enabled)return;const r=a,o=Number(new Date),i=o-(n||o);r.diff=i,r.prev=n,r.curr=o,n=o,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let s=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((n,o)=>{if("%%"===n)return"%";s++;const i=t.formatters[o];if("function"==typeof i){const t=e[s];n=i.call(r,t),e.splice(s,1),s--}return n})),t.formatArgs.call(r,e);(r.log||t.log).apply(r,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=r,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==s?s:(o!==t.namespaces&&(o=t.namespaces,i=t.enabled(e)),i),set:e=>{s=e}}),"function"==typeof t.init&&t.init(a),a}function r(e,n){const r=t(this.namespace+(void 0===n?":":n)+e);return r.log=this.log,r}function o(e,t){let n=0,r=0,o=-1,i=0;for(;n<e.length;)if(r<t.length&&(t[r]===e[n]||"*"===t[r]))"*"===t[r]?(o=r,i=n,r++):(n++,r++);else{if(-1===o)return!1;r=o+1,i++,n=i}for(;r<t.length&&"*"===t[r];)r++;return r===t.length}return t.debug=t,t.default=t,t.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},t.disable=function(){const e=[...t.names,...t.skips.map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){t.save(e),t.namespaces=e,t.names=[],t.skips=[];const n=("string"==typeof e?e:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const r of n)"-"===r[0]?t.skips.push(r.slice(1)):t.names.push(r)},t.enabled=function(e){for(const n of t.skips)if(o(e,n))return!1;for(const n of t.names)if(o(e,n))return!0;return!1},t.humanize=n(192),t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach((n=>{t[n]=e[n]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let n=0;for(let t=0;t<e.length;t++)n=(n<<5)-n+e.charCodeAt(t),n|=0;return t.colors[Math.abs(n)%t.colors.length]},t.enable(t.load()),t}},192(e){var t=1e3,n=60*t,r=60*n,o=24*r,i=7*o,s=365.25*o;function a(e,t,n,r){var o=t>=1.5*n;return Math.round(e/n)+" "+r+(o?"s":"")}e.exports=function(e,c){c=c||{};var u=typeof e;if("string"===u&&e.length>0)return function(e){if((e=String(e)).length>100)return;var a=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!a)return;var c=parseFloat(a[1]);switch((a[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return c*s;case"weeks":case"week":case"w":return c*i;case"days":case"day":case"d":return c*o;case"hours":case"hour":case"hrs":case"hr":case"h":return c*r;case"minutes":case"minute":case"mins":case"min":case"m":return c*n;case"seconds":case"second":case"secs":case"sec":case"s":return c*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return c;default:return}}(e);if("number"===u&&isFinite(e))return c.long?function(e){var i=Math.abs(e);if(i>=o)return a(e,i,o,"day");if(i>=r)return a(e,i,r,"hour");if(i>=n)return a(e,i,n,"minute");if(i>=t)return a(e,i,t,"second");return e+" ms"}(e):function(e){var i=Math.abs(e);if(i>=o)return Math.round(e/o)+"d";if(i>=r)return Math.round(e/r)+"h";if(i>=n)return Math.round(e/n)+"m";if(i>=t)return Math.round(e/t)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},963(e,t,n){"use strict";const r=n(527),{MAX_LENGTH:o,MAX_SAFE_INTEGER:i}=n(197),{safeRe:s,t:a}=n(423),c=n(676),{compareIdentifiers:u}=n(956);class l{constructor(e,t){if(t=c(t),e instanceof l){if(e.loose===!!t.loose&&e.includePrerelease===!!t.includePrerelease)return e;e=e.version}else if("string"!=typeof e)throw new TypeError(`Invalid version. Must be a string. Got type "${typeof e}".`);if(e.length>o)throw new TypeError(`version is longer than ${o} characters`);r("SemVer",e,t),this.options=t,this.loose=!!t.loose,this.includePrerelease=!!t.includePrerelease;const n=e.trim().match(t.loose?s[a.LOOSE]:s[a.FULL]);if(!n)throw new TypeError(`Invalid Version: ${e}`);if(this.raw=e,this.major=+n[1],this.minor=+n[2],this.patch=+n[3],this.major>i||this.major<0)throw new TypeError("Invalid major version");if(this.minor>i||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>i||this.patch<0)throw new TypeError("Invalid patch version");n[4]?this.prerelease=n[4].split(".").map((e=>{if(/^[0-9]+$/.test(e)){const t=+e;if(t>=0&&t<i)return t}return e})):this.prerelease=[],this.build=n[5]?n[5].split("."):[],this.format()}format(){return this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length&&(this.version+=`-${this.prerelease.join(".")}`),this.version}toString(){return this.version}compare(e){if(r("SemVer.compare",this.version,this.options,e),!(e instanceof l)){if("string"==typeof e&&e===this.version)return 0;e=new l(e,this.options)}return e.version===this.version?0:this.compareMain(e)||this.comparePre(e)}compareMain(e){return e instanceof l||(e=new l(e,this.options)),this.major<e.major?-1:this.major>e.major?1:this.minor<e.minor?-1:this.minor>e.minor?1:this.patch<e.patch?-1:this.patch>e.patch?1:0}comparePre(e){if(e instanceof l||(e=new l(e,this.options)),this.prerelease.length&&!e.prerelease.length)return-1;if(!this.prerelease.length&&e.prerelease.length)return 1;if(!this.prerelease.length&&!e.prerelease.length)return 0;let t=0;do{const n=this.prerelease[t],o=e.prerelease[t];if(r("prerelease compare",t,n,o),void 0===n&&void 0===o)return 0;if(void 0===o)return 1;if(void 0===n)return-1;if(n!==o)return u(n,o)}while(++t)}compareBuild(e){e instanceof l||(e=new l(e,this.options));let t=0;do{const n=this.build[t],o=e.build[t];if(r("build compare",t,n,o),void 0===n&&void 0===o)return 0;if(void 0===o)return 1;if(void 0===n)return-1;if(n!==o)return u(n,o)}while(++t)}inc(e,t,n){if(e.startsWith("pre")){if(!t&&!1===n)throw new Error("invalid increment argument: identifier is empty");if(t){const e=`-${t}`.match(this.options.loose?s[a.PRERELEASELOOSE]:s[a.PRERELEASE]);if(!e||e[1]!==t)throw new Error(`invalid identifier: ${t}`)}}switch(e){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",t,n);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",t,n);break;case"prepatch":this.prerelease.length=0,this.inc("patch",t,n),this.inc("pre",t,n);break;case"prerelease":0===this.prerelease.length&&this.inc("patch",t,n),this.inc("pre",t,n);break;case"release":if(0===this.prerelease.length)throw new Error(`version ${this.raw} is not a prerelease`);this.prerelease.length=0;break;case"major":0===this.minor&&0===this.patch&&0!==this.prerelease.length||this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":0===this.patch&&0!==this.prerelease.length||this.minor++,this.patch=0,this.prerelease=[];break;case"patch":0===this.prerelease.length&&this.patch++,this.prerelease=[];break;case"pre":{const e=Number(n)?1:0;if(0===this.prerelease.length)this.prerelease=[e];else{let r=this.prerelease.length;for(;--r>=0;)"number"==typeof this.prerelease[r]&&(this.prerelease[r]++,r=-2);if(-1===r){if(t===this.prerelease.join(".")&&!1===n)throw new Error("invalid increment argument: identifier already exists");this.prerelease.push(e)}}if(t){let r=[t,e];if(!1===n&&(r=[t]),((e,t)=>{const n=t.split(".");if(n.length>e.length)return!1;for(let r=0;r<n.length;r++)if(0!==u(e[r],n[r]))return!1;return!0})(this.prerelease,t)){const e=this.prerelease[t.split(".").length];isNaN(e)&&(this.prerelease=r)}else this.prerelease=r}break}default:throw new Error(`invalid increment argument: ${e}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(".")}`),this}}e.exports=l},359(e,t,n){"use strict";const r=n(963);e.exports=(e,t)=>new r(e,t).major},197(e){"use strict";const t=Number.MAX_SAFE_INTEGER||9007199254740991;e.exports={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:16,MAX_SAFE_BUILD_LENGTH:250,MAX_SAFE_INTEGER:t,RELEASE_TYPES:["major","premajor","minor","preminor","patch","prepatch","prerelease"],SEMVER_SPEC_VERSION:"2.0.0",FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}},527(e){"use strict";const t="object"==typeof process&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...e)=>console.error("SEMVER",...e):()=>{};e.exports=t},956(e){"use strict";const t=/^[0-9]+$/,n=(e,n)=>{if("number"==typeof e&&"number"==typeof n)return e===n?0:e<n?-1:1;const r=t.test(e),o=t.test(n);return r&&o&&(e=+e,n=+n),e===n?0:r&&!o?-1:o&&!r?1:e<n?-1:1};e.exports={compareIdentifiers:n,rcompareIdentifiers:(e,t)=>n(t,e)}},676(e){"use strict";const t=Object.freeze({loose:!0}),n=Object.freeze({});e.exports=e=>e?"object"!=typeof e?t:e:n},423(e,t,n){"use strict";const{MAX_SAFE_COMPONENT_LENGTH:r,MAX_SAFE_BUILD_LENGTH:o,MAX_LENGTH:i}=n(197),s=n(527),a=(t=e.exports={}).re=[],c=t.safeRe=[],u=t.src=[],l=t.safeSrc=[],f=t.t={};let h=0;const d="[a-zA-Z0-9-]",p=[["\\s",1],["\\d",i],[d,o]],m=(e,t,n)=>{const r=(e=>{for(const[t,n]of p)e=e.split(`${t}*`).join(`${t}{0,${n}}`).split(`${t}+`).join(`${t}{1,${n}}`);return e})(t),o=h++;s(e,o,t),f[e]=o,u[o]=t,l[o]=r,a[o]=new RegExp(t,n?"g":void 0),c[o]=new RegExp(r,n?"g":void 0)};m("NUMERICIDENTIFIER","0|[1-9]\\d*"),m("NUMERICIDENTIFIERLOOSE","\\d+"),m("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${d}*`),m("MAINVERSION",`(${u[f.NUMERICIDENTIFIER]})\\.(${u[f.NUMERICIDENTIFIER]})\\.(${u[f.NUMERICIDENTIFIER]})`),m("MAINVERSIONLOOSE",`(${u[f.NUMERICIDENTIFIERLOOSE]})\\.(${u[f.NUMERICIDENTIFIERLOOSE]})\\.(${u[f.NUMERICIDENTIFIERLOOSE]})`),m("PRERELEASEIDENTIFIER",`(?:${u[f.NONNUMERICIDENTIFIER]}|${u[f.NUMERICIDENTIFIER]})`),m("PRERELEASEIDENTIFIERLOOSE",`(?:${u[f.NONNUMERICIDENTIFIER]}|${u[f.NUMERICIDENTIFIERLOOSE]})`),m("PRERELEASE",`(?:-(${u[f.PRERELEASEIDENTIFIER]}(?:\\.${u[f.PRERELEASEIDENTIFIER]})*))`),m("PRERELEASELOOSE",`(?:-?(${u[f.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${u[f.PRERELEASEIDENTIFIERLOOSE]})*))`),m("BUILDIDENTIFIER",`${d}+`),m("BUILD",`(?:\\+(${u[f.BUILDIDENTIFIER]}(?:\\.${u[f.BUILDIDENTIFIER]})*))`),m("FULLPLAIN",`v?${u[f.MAINVERSION]}${u[f.PRERELEASE]}?${u[f.BUILD]}?`),m("FULL",`^${u[f.FULLPLAIN]}$`),m("LOOSEPLAIN",`[v=\\s]*${u[f.MAINVERSIONLOOSE]}${u[f.PRERELEASELOOSE]}?${u[f.BUILD]}?`),m("LOOSE",`^${u[f.LOOSEPLAIN]}$`),m("GTLT","((?:<|>)?=?)"),m("XRANGEIDENTIFIERLOOSE",`${u[f.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),m("XRANGEIDENTIFIER",`${u[f.NUMERICIDENTIFIER]}|x|X|\\*`),m("XRANGEPLAIN",`[v=\\s]*(${u[f.XRANGEIDENTIFIER]})(?:\\.(${u[f.XRANGEIDENTIFIER]})(?:\\.(${u[f.XRANGEIDENTIFIER]})(?:${u[f.PRERELEASE]})?${u[f.BUILD]}?)?)?`),m("XRANGEPLAINLOOSE",`[v=\\s]*(${u[f.XRANGEIDENTIFIERLOOSE]})(?:\\.(${u[f.XRANGEIDENTIFIERLOOSE]})(?:\\.(${u[f.XRANGEIDENTIFIERLOOSE]})(?:${u[f.PRERELEASELOOSE]})?${u[f.BUILD]}?)?)?`),m("XRANGE",`^${u[f.GTLT]}\\s*${u[f.XRANGEPLAIN]}$`),m("XRANGELOOSE",`^${u[f.GTLT]}\\s*${u[f.XRANGEPLAINLOOSE]}$`),m("COERCEPLAIN",`(^|[^\\d])(\\d{1,${r}})(?:\\.(\\d{1,${r}}))?(?:\\.(\\d{1,${r}}))?`),m("COERCE",`${u[f.COERCEPLAIN]}(?:$|[^\\d])`),m("COERCEFULL",u[f.COERCEPLAIN]+`(?:${u[f.PRERELEASE]})?`+`(?:${u[f.BUILD]})?(?:$|[^\\d])`),m("COERCERTL",u[f.COERCE],!0),m("COERCERTLFULL",u[f.COERCEFULL],!0),m("LONETILDE","(?:~>?)"),m("TILDETRIM",`(\\s*)${u[f.LONETILDE]}\\s+`,!0),t.tildeTrimReplace="$1~",m("TILDE",`^${u[f.LONETILDE]}${u[f.XRANGEPLAIN]}$`),m("TILDELOOSE",`^${u[f.LONETILDE]}${u[f.XRANGEPLAINLOOSE]}$`),m("LONECARET","(?:\\^)"),m("CARETTRIM",`(\\s*)${u[f.LONECARET]}\\s+`,!0),t.caretTrimReplace="$1^",m("CARET",`^${u[f.LONECARET]}${u[f.XRANGEPLAIN]}$`),m("CARETLOOSE",`^${u[f.LONECARET]}${u[f.XRANGEPLAINLOOSE]}$`),m("COMPARATORLOOSE",`^${u[f.GTLT]}\\s*(${u[f.LOOSEPLAIN]})$|^$`),m("COMPARATOR",`^${u[f.GTLT]}\\s*(${u[f.FULLPLAIN]})$|^$`),m("COMPARATORTRIM",`(\\s*)${u[f.GTLT]}\\s*(${u[f.LOOSEPLAIN]}|${u[f.XRANGEPLAIN]})`,!0),t.comparatorTrimReplace="$1$2$3",m("HYPHENRANGE",`^\\s*(${u[f.XRANGEPLAIN]})\\s+-\\s+(${u[f.XRANGEPLAIN]})\\s*$`),m("HYPHENRANGELOOSE",`^\\s*(${u[f.XRANGEPLAINLOOSE]})\\s+-\\s+(${u[f.XRANGEPLAINLOOSE]})\\s*$`),m("STAR","(<|>)?=?\\s*\\*"),m("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$"),m("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")},497(){},61(){},320(){}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={exports:{}};return e[r](i,i.exports,n),i.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};return(()=>{"use strict";n.r(r),n.d(r,{BRANCHES:()=>Gl,BZZ:()=>Dl,BatchId:()=>Ct,Bee:()=>vp,BeeArgumentError:()=>Sl,BeeError:()=>kl,BeeModes:()=>Nl,BeeResponseError:()=>$l,Bytes:()=>Pt,CHUNK_SIZE:()=>Ll,ChunkBuilder:()=>On,ChunkSplitter:()=>An,DAI:()=>Vl,Duration:()=>_l,EthAddress:()=>Ut,FeedIndex:()=>Lt,Identifier:()=>Zt,MantarayNode:()=>oh,NULL_ADDRESS:()=>Tp,NULL_IDENTIFIER:()=>Rp,NULL_OWNER:()=>Op,NULL_STAMP:()=>Ep,NULL_TOPIC:()=>xp,PSS_TARGET_HEX_LENGTH_MAX:()=>jl,PeerAddress:()=>qt,PrivateKey:()=>en,PublicKey:()=>Kt,RedundancyLevel:()=>Kl,RedundancyStrategy:()=>Jl,Reference:()=>nn,RollingFeedReader:()=>xd,RollingFeedWriter:()=>Ed,SECTION_SIZE:()=>Ul,STAMPS_DEPTH_MAX:()=>ql,STAMPS_DEPTH_MIN:()=>Zl,SUPPORTED_BEE_VERSION:()=>Yd,SUPPORTED_BEE_VERSION_EXACT:()=>Xd,SWARM_GATEWAY_URL:()=>Bp,Signature:()=>Qt,Size:()=>Il,Span:()=>rn,Stamper:()=>sr,TAGS_LIMIT_MAX:()=>Wl,TAGS_LIMIT_MIN:()=>Hl,Topic:()=>sn,TransactionId:()=>an,Utils:()=>e,capacityBreakpoints:()=>Xl,toBeeMode:()=>Ml});var e={};n.r(e),n.d(e,{approximateOverheadForRedundancyLevel:()=>$n,convertEnvelopeToMarshaledStamp:()=>Tf,getAmountForDuration:()=>Ef,getCollectionSize:()=>mh,getDepthForSize:()=>xf,getFolderSize:()=>uh,getRedundancyStat:()=>Cn,getRedundancyStats:()=>Pn,getStampCost:()=>vf,getStampDuration:()=>Bf,getStampEffectiveBytes:()=>rr,getStampEffectiveBytesBreakpoints:()=>or,getStampTheoreticalBytes:()=>Xn,getStampUsage:()=>Jn,makeCollectionFromFileList:()=>ph,makeMaxTarget:()=>Ap,mapPostageBatch:()=>Rf,unmapPostageBatch:()=>Of});const t="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0;function o(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function i(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function s(e,...t){if(!o(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function a(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.createHasher");i(e.outputLen),i(e.blockLen)}function c(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function u(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function l(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function f(e,t){return e<<32-t|e>>>t}const h=(()=>"function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex)(),d=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function p(e){if(s(e),h)return e.toHex();let t="";for(let n=0;n<e.length;n++)t+=d[e[n]];return t}const m=48,g=57,y=65,w=70,b=97,v=102;function B(e){return e>=m&&e<=g?e-m:e>=y&&e<=w?e-(y-10):e>=b&&e<=v?e-(b-10):void 0}function E(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);if(h)return Uint8Array.fromHex(e);const t=e.length,n=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const r=new Uint8Array(n);for(let o=0,i=0;o<n;o++,i+=2){const t=B(e.charCodeAt(i)),n=B(e.charCodeAt(i+1));if(void 0===t||void 0===n){const t=e[i]+e[i+1];throw new Error('hex string expected, got non-hex character "'+t+'" at index '+i)}r[o]=16*t+n}return r}function x(e){if("string"!=typeof e)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(e))}function T(e){return"string"==typeof e&&(e=x(e)),s(e),e}function R(...e){let t=0;for(let r=0;r<e.length;r++){const n=e[r];s(n),t+=n.length}const n=new Uint8Array(t);for(let r=0,o=0;r<e.length;r++){const t=e[r];n.set(t,o),o+=t.length}return n}class O{}function A(e){const t=t=>e().update(T(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function z(e=32){if(t&&"function"==typeof t.getRandomValues)return t.getRandomValues(new Uint8Array(e));if(t&&"function"==typeof t.randomBytes)return Uint8Array.from(t.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}function k(e,t,n){return e&t^e&n^t&n}class S extends O{constructor(e,t,n,r){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.buffer=new Uint8Array(e),this.view=l(this.buffer)}update(e){c(this),s(e=T(e));const{view:t,buffer:n,blockLen:r}=this,o=e.length;for(let i=0;i<o;){const s=Math.min(r-this.pos,o-i);if(s!==r)n.set(e.subarray(i,i+s),this.pos),this.pos+=s,i+=s,this.pos===r&&(this.process(t,0),this.pos=0);else{const t=l(e);for(;r<=o-i;i+=r)this.process(t,i)}}return this.length+=e.length,this.roundClean(),this}digestInto(e){c(this),function(e,t){s(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}(e,this),this.finished=!0;const{buffer:t,view:n,blockLen:r,isLE:o}=this;let{pos:i}=this;t[i++]=128,u(this.buffer.subarray(i)),this.padOffset>r-i&&(this.process(n,0),i=0);for(let s=i;s<r;s++)t[s]=0;!function(e,t,n,r){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,n,r);const o=BigInt(32),i=BigInt(4294967295),s=Number(n>>o&i),a=Number(n&i),c=r?4:0,u=r?0:4;e.setUint32(t+c,s,r),e.setUint32(t+u,a,r)}(n,r-8,BigInt(8*this.length),o),this.process(n,0);const a=l(e),f=this.outputLen;if(f%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const h=f/4,d=this.get();if(h>d.length)throw new Error("_sha2: outputLen bigger than state");for(let s=0;s<h;s++)a.setUint32(4*s,d[s],o)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:n,length:r,finished:o,destroyed:i,pos:s}=this;return e.destroyed=i,e.finished=o,e.length=r,e.pos=s,r%t&&e.buffer.set(n),e}clone(){return this._cloneInto()}}const $=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);const _=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),I=new Uint32Array(64);class D extends S{constructor(e=32){super(64,e,8,!1),this.A=0|$[0],this.B=0|$[1],this.C=0|$[2],this.D=0|$[3],this.E=0|$[4],this.F=0|$[5],this.G=0|$[6],this.H=0|$[7]}get(){const{A:e,B:t,C:n,D:r,E:o,F:i,G:s,H:a}=this;return[e,t,n,r,o,i,s,a]}set(e,t,n,r,o,i,s,a){this.A=0|e,this.B=0|t,this.C=0|n,this.D=0|r,this.E=0|o,this.F=0|i,this.G=0|s,this.H=0|a}process(e,t){for(let f=0;f<16;f++,t+=4)I[f]=e.getUint32(t,!1);for(let h=16;h<64;h++){const e=I[h-15],t=I[h-2],n=f(e,7)^f(e,18)^e>>>3,r=f(t,17)^f(t,19)^t>>>10;I[h]=r+I[h-7]+n+I[h-16]|0}let{A:n,B:r,C:o,D:i,E:s,F:a,G:c,H:u}=this;for(let h=0;h<64;h++){const e=u+(f(s,6)^f(s,11)^f(s,25))+((l=s)&a^~l&c)+_[h]+I[h]|0,t=(f(n,2)^f(n,13)^f(n,22))+k(n,r,o)|0;u=c,c=a,a=s,s=i+e|0,i=o,o=r,r=n,n=e+t|0}var l;n=n+this.A|0,r=r+this.B|0,o=o+this.C|0,i=i+this.D|0,s=s+this.E|0,a=a+this.F|0,c=c+this.G|0,u=u+this.H|0,this.set(n,r,o,i,s,a,c,u)}roundClean(){u(I)}destroy(){this.set(0,0,0,0,0,0,0,0),u(this.buffer)}}const V=A((()=>new D));class P extends O{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,a(e);const n=T(t);if(this.iHash=e.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const r=this.blockLen,o=new Uint8Array(r);o.set(n.length>r?e.create().update(n).digest():n);for(let i=0;i<o.length;i++)o[i]^=54;this.iHash.update(o),this.oHash=e.create();for(let i=0;i<o.length;i++)o[i]^=106;this.oHash.update(o),u(o)}update(e){return c(this),this.iHash.update(e),this}digestInto(e){c(this),s(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:n,finished:r,destroyed:o,blockLen:i,outputLen:s}=this;return e.finished=r,e.destroyed=o,e.blockLen=i,e.outputLen=s,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const C=(e,t,n)=>new P(e,t).update(n).digest();C.create=(e,t)=>new P(e,t);const F=BigInt(0),N=BigInt(1);function M(e,t=""){if("boolean"!=typeof e){throw new Error((t&&`"${t}"`)+"expected boolean, got type="+typeof e)}return e}function U(e,t,n=""){const r=o(e),i=e?.length,s=void 0!==t;if(!r||s&&i!==t){throw new Error((n&&`"${n}" `)+"expected Uint8Array"+(s?` of length ${t}`:"")+", got "+(r?`length=${i}`:"type="+typeof e))}return e}function G(e){const t=e.toString(16);return 1&t.length?"0"+t:t}function L(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);return""===e?F:BigInt("0x"+e)}function j(e){return L(p(e))}function Z(e){return s(e),L(p(Uint8Array.from(e).reverse()))}function q(e,t){return E(e.toString(16).padStart(2*t,"0"))}function H(e,t){return q(e,t).reverse()}function W(e,t,n){let r;if("string"==typeof t)try{r=E(t)}catch(s){throw new Error(e+" must be hex string or Uint8Array, cause: "+s)}else{if(!o(t))throw new Error(e+" must be hex string or Uint8Array");r=Uint8Array.from(t)}const i=r.length;if("number"==typeof n&&i!==n)throw new Error(e+" of length "+n+" expected, got "+i);return r}const K=e=>"bigint"==typeof e&&F<=e;function J(e,t,n,r){if(!function(e,t,n){return K(e)&&K(t)&&K(n)&&t<=e&&e<n}(t,n,r))throw new Error("expected valid "+e+": "+n+" <= n < "+r+", got "+t)}function X(e){let t;for(t=0;e>F;e>>=N,t+=1);return t}const Y=e=>(N<<BigInt(e))-N;function Q(e,t,n={}){if(!e||"object"!=typeof e)throw new Error("expected valid options object");function r(t,n,r){const o=e[t];if(r&&void 0===o)return;const i=typeof o;if(i!==n||null===o)throw new Error(`param "${t}" is invalid: expected ${n}, got ${i}`)}Object.entries(t).forEach((([e,t])=>r(e,t,!1))),Object.entries(n).forEach((([e,t])=>r(e,t,!0)))}function ee(e){const t=new WeakMap;return(n,...r)=>{const o=t.get(n);if(void 0!==o)return o;const i=e(n,...r);return t.set(n,i),i}}const te=BigInt(0),ne=BigInt(1),re=BigInt(2),oe=BigInt(3),ie=BigInt(4),se=BigInt(5),ae=BigInt(7),ce=BigInt(8),ue=BigInt(9),le=BigInt(16);function fe(e,t){const n=e%t;return n>=te?n:t+n}function he(e,t,n){let r=e;for(;t-- >te;)r*=r,r%=n;return r}function de(e,t){if(e===te)throw new Error("invert: expected non-zero number");if(t<=te)throw new Error("invert: expected positive modulus, got "+t);let n=fe(e,t),r=t,o=te,i=ne,s=ne,a=te;for(;n!==te;){const e=r/n,t=r%n,c=o-s*e,u=i-a*e;r=n,n=t,o=s,i=a,s=c,a=u}if(r!==ne)throw new Error("invert: does not exist");return fe(o,t)}function pe(e,t,n){if(!e.eql(e.sqr(t),n))throw new Error("Cannot find square root")}function me(e,t){const n=(e.ORDER+ne)/ie,r=e.pow(t,n);return pe(e,r,t),r}function ge(e,t){const n=(e.ORDER-se)/ce,r=e.mul(t,re),o=e.pow(r,n),i=e.mul(t,o),s=e.mul(e.mul(i,re),o),a=e.mul(i,e.sub(s,e.ONE));return pe(e,a,t),a}function ye(e){if(e<oe)throw new Error("sqrt is not defined for small field");let t=e-ne,n=0;for(;t%re===te;)t/=re,n++;let r=re;const o=Te(e);for(;1===Ee(o,r);)if(r++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(1===n)return me;let i=o.pow(r,t);const s=(t+ne)/re;return function(e,r){if(e.is0(r))return r;if(1!==Ee(e,r))throw new Error("Cannot find square root");let o=n,a=e.mul(e.ONE,i),c=e.pow(r,t),u=e.pow(r,s);for(;!e.eql(c,e.ONE);){if(e.is0(c))return e.ZERO;let t=1,n=e.sqr(c);for(;!e.eql(n,e.ONE);)if(t++,n=e.sqr(n),t===o)throw new Error("Cannot find square root");const r=ne<<BigInt(o-t-1),i=e.pow(a,r);o=t,a=e.sqr(i),c=e.mul(c,a),u=e.mul(u,i)}return u}}function we(e){return e%ie===oe?me:e%ce===se?ge:e%le===ue?function(e){const t=Te(e),n=ye(e),r=n(t,t.neg(t.ONE)),o=n(t,r),i=n(t,t.neg(r)),s=(e+ae)/le;return(e,t)=>{let n=e.pow(t,s),a=e.mul(n,r);const c=e.mul(n,o),u=e.mul(n,i),l=e.eql(e.sqr(a),t),f=e.eql(e.sqr(c),t);n=e.cmov(n,a,l),a=e.cmov(u,c,f);const h=e.eql(e.sqr(a),t),d=e.cmov(n,a,h);return pe(e,d,t),d}}(e):ye(e)}const be=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function ve(e,t,n){if(n<te)throw new Error("invalid exponent, negatives unsupported");if(n===te)return e.ONE;if(n===ne)return t;let r=e.ONE,o=t;for(;n>te;)n&ne&&(r=e.mul(r,o)),o=e.sqr(o),n>>=ne;return r}function Be(e,t,n=!1){const r=new Array(t.length).fill(n?e.ZERO:void 0),o=t.reduce(((t,n,o)=>e.is0(n)?t:(r[o]=t,e.mul(t,n))),e.ONE),i=e.inv(o);return t.reduceRight(((t,n,o)=>e.is0(n)?t:(r[o]=e.mul(t,r[o]),e.mul(t,n))),i),r}function Ee(e,t){const n=(e.ORDER-ne)/re,r=e.pow(t,n),o=e.eql(r,e.ONE),i=e.eql(r,e.ZERO),s=e.eql(r,e.neg(e.ONE));if(!o&&!i&&!s)throw new Error("invalid Legendre symbol result");return o?1:i?0:-1}function xe(e,t){void 0!==t&&i(t);const n=void 0!==t?t:e.toString(2).length;return{nBitLength:n,nByteLength:Math.ceil(n/8)}}function Te(e,t,n=!1,r={}){if(e<=te)throw new Error("invalid field: expected ORDER > 0, got "+e);let o,i,s,a=!1;if("object"==typeof t&&null!=t){if(r.sqrt||n)throw new Error("cannot specify opts in two arguments");const e=t;e.BITS&&(o=e.BITS),e.sqrt&&(i=e.sqrt),"boolean"==typeof e.isLE&&(n=e.isLE),"boolean"==typeof e.modFromBytes&&(a=e.modFromBytes),s=e.allowedLengths}else"number"==typeof t&&(o=t),r.sqrt&&(i=r.sqrt);const{nBitLength:c,nByteLength:u}=xe(e,o);if(u>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let l;const f=Object.freeze({ORDER:e,isLE:n,BITS:c,BYTES:u,MASK:Y(c),ZERO:te,ONE:ne,allowedLengths:s,create:t=>fe(t,e),isValid:t=>{if("bigint"!=typeof t)throw new Error("invalid field element: expected bigint, got "+typeof t);return te<=t&&t<e},is0:e=>e===te,isValidNot0:e=>!f.is0(e)&&f.isValid(e),isOdd:e=>(e&ne)===ne,neg:t=>fe(-t,e),eql:(e,t)=>e===t,sqr:t=>fe(t*t,e),add:(t,n)=>fe(t+n,e),sub:(t,n)=>fe(t-n,e),mul:(t,n)=>fe(t*n,e),pow:(e,t)=>ve(f,e,t),div:(t,n)=>fe(t*de(n,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>de(t,e),sqrt:i||(t=>(l||(l=we(e)),l(f,t))),toBytes:e=>n?H(e,u):q(e,u),fromBytes:(t,r=!0)=>{if(s){if(!s.includes(t.length)||t.length>u)throw new Error("Field.fromBytes: expected "+s+" bytes, got "+t.length);const e=new Uint8Array(u);e.set(t,n?0:e.length-t.length),t=e}if(t.length!==u)throw new Error("Field.fromBytes: expected "+u+" bytes, got "+t.length);let o=n?Z(t):j(t);if(a&&(o=fe(o,e)),!r&&!f.isValid(o))throw new Error("invalid field element: outside of range 0..ORDER");return o},invertBatch:e=>Be(f,e),cmov:(e,t,n)=>n?t:e});return Object.freeze(f)}function Re(e){if("bigint"!=typeof e)throw new Error("field order must be bigint");const t=e.toString(2).length;return Math.ceil(t/8)}function Oe(e){const t=Re(e);return t+Math.ceil(t/2)}const Ae=BigInt(0),ze=BigInt(1);function ke(e,t){const n=t.negate();return e?n:t}function Se(e,t){const n=Be(e.Fp,t.map((e=>e.Z)));return t.map(((t,r)=>e.fromAffine(t.toAffine(n[r]))))}function $e(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function _e(e,t){$e(e,t);const n=2**e;return{windows:Math.ceil(t/e)+1,windowSize:2**(e-1),mask:Y(e),maxNumber:n,shiftBy:BigInt(e)}}function Ie(e,t,n){const{windowSize:r,mask:o,maxNumber:i,shiftBy:s}=n;let a=Number(e&o),c=e>>s;a>r&&(a-=i,c+=ze);const u=t*r;return{nextN:c,offset:u+Math.abs(a)-1,isZero:0===a,isNeg:a<0,isNegF:t%2!=0,offsetF:u}}function De(e,t){if(!Array.isArray(e))throw new Error("array expected");e.forEach(((e,n)=>{if(!(e instanceof t))throw new Error("invalid point at index "+n)}))}function Ve(e,t){if(!Array.isArray(e))throw new Error("array of scalars expected");e.forEach(((e,n)=>{if(!t.isValid(e))throw new Error("invalid scalar at index "+n)}))}const Pe=new WeakMap,Ce=new WeakMap;function Fe(e){return Ce.get(e)||1}function Ne(e){if(e!==Ae)throw new Error("invalid wNAF")}class Me{constructor(e,t){this.BASE=e.BASE,this.ZERO=e.ZERO,this.Fn=e.Fn,this.bits=t}_unsafeLadder(e,t,n=this.ZERO){let r=e;for(;t>Ae;)t&ze&&(n=n.add(r)),r=r.double(),t>>=ze;return n}precomputeWindow(e,t){const{windows:n,windowSize:r}=_e(t,this.bits),o=[];let i=e,s=i;for(let a=0;a<n;a++){s=i,o.push(s);for(let e=1;e<r;e++)s=s.add(i),o.push(s);i=s.double()}return o}wNAF(e,t,n){if(!this.Fn.isValid(n))throw new Error("invalid scalar");let r=this.ZERO,o=this.BASE;const i=_e(e,this.bits);for(let s=0;s<i.windows;s++){const{nextN:e,offset:a,isZero:c,isNeg:u,isNegF:l,offsetF:f}=Ie(n,s,i);n=e,c?o=o.add(ke(l,t[f])):r=r.add(ke(u,t[a]))}return Ne(n),{p:r,f:o}}wNAFUnsafe(e,t,n,r=this.ZERO){const o=_e(e,this.bits);for(let i=0;i<o.windows&&n!==Ae;i++){const{nextN:e,offset:s,isZero:a,isNeg:c}=Ie(n,i,o);if(n=e,!a){const e=t[s];r=r.add(c?e.negate():e)}}return Ne(n),r}getPrecomputes(e,t,n){let r=Pe.get(t);return r||(r=this.precomputeWindow(t,e),1!==e&&("function"==typeof n&&(r=n(r)),Pe.set(t,r))),r}cached(e,t,n){const r=Fe(e);return this.wNAF(r,this.getPrecomputes(r,e,n),t)}unsafe(e,t,n,r){const o=Fe(e);return 1===o?this._unsafeLadder(e,t,r):this.wNAFUnsafe(o,this.getPrecomputes(o,e,n),t,r)}createCache(e,t){$e(t,this.bits),Ce.set(e,t),Pe.delete(e)}hasCache(e){return 1!==Fe(e)}}function Ue(e,t,n){if(t){if(t.ORDER!==e)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return function(e){const t=be.reduce(((e,t)=>(e[t]="function",e)),{ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"});Q(e,t)}(t),t}return Te(e,{isLE:n})}const Ge=(e,t)=>(e+(e>=0?t:-t)/Ke)/t;function Le(e){if(!["compact","recovered","der"].includes(e))throw new Error('Signature format must be "compact", "recovered", or "der"');return e}function je(e,t){const n={};for(let r of Object.keys(t))n[r]=void 0===e[r]?t[r]:e[r];return M(n.lowS,"lowS"),M(n.prehash,"prehash"),void 0!==n.format&&Le(n.format),n}class Ze extends Error{constructor(e=""){super(e)}}const qe={Err:Ze,_tlv:{encode:(e,t)=>{const{Err:n}=qe;if(e<0||e>256)throw new n("tlv.encode: wrong tag");if(1&t.length)throw new n("tlv.encode: unpadded data");const r=t.length/2,o=G(r);if(o.length/2&128)throw new n("tlv.encode: long form length too big");const i=r>127?G(o.length/2|128):"";return G(e)+i+o+t},decode(e,t){const{Err:n}=qe;let r=0;if(e<0||e>256)throw new n("tlv.encode: wrong tag");if(t.length<2||t[r++]!==e)throw new n("tlv.decode: wrong tlv");const o=t[r++];let i=0;if(!!(128&o)){const e=127&o;if(!e)throw new n("tlv.decode(long): indefinite length not supported");if(e>4)throw new n("tlv.decode(long): byte length is too big");const s=t.subarray(r,r+e);if(s.length!==e)throw new n("tlv.decode: length bytes not complete");if(0===s[0])throw new n("tlv.decode(long): zero leftmost byte");for(const t of s)i=i<<8|t;if(r+=e,i<128)throw new n("tlv.decode(long): not minimal encoding")}else i=o;const s=t.subarray(r,r+i);if(s.length!==i)throw new n("tlv.decode: wrong value length");return{v:s,l:t.subarray(r+i)}}},_int:{encode(e){const{Err:t}=qe;if(e<He)throw new t("integer: negative integers are not allowed");let n=G(e);if(8&Number.parseInt(n[0],16)&&(n="00"+n),1&n.length)throw new t("unexpected DER parsing assertion: unpadded hex");return n},decode(e){const{Err:t}=qe;if(128&e[0])throw new t("invalid signature integer: negative");if(0===e[0]&&!(128&e[1]))throw new t("invalid signature integer: unnecessary leading zero");return j(e)}},toSig(e){const{Err:t,_int:n,_tlv:r}=qe,o=W("signature",e),{v:i,l:s}=r.decode(48,o);if(s.length)throw new t("invalid signature: left bytes after parsing");const{v:a,l:c}=r.decode(2,i),{v:u,l:l}=r.decode(2,c);if(l.length)throw new t("invalid signature: left bytes after parsing");return{r:n.decode(a),s:n.decode(u)}},hexFromSig(e){const{_tlv:t,_int:n}=qe,r=t.encode(2,n.encode(e.r))+t.encode(2,n.encode(e.s));return t.encode(48,r)}},He=BigInt(0),We=BigInt(1),Ke=BigInt(2),Je=BigInt(3),Xe=BigInt(4);function Ye(e,t){const{BYTES:n}=e;let r;if("bigint"==typeof t)r=t;else{let o=W("private key",t);try{r=e.fromBytes(o)}catch(Pc){throw new Error(`invalid private key: expected ui8a of size ${n}, got ${typeof t}`)}}if(!e.isValidNot0(r))throw new Error("invalid private key: out of range [1..N-1]");return r}function Qe(e,t={}){const n=function(e,t,n={},r){if(void 0===r&&(r="edwards"===e),!t||"object"!=typeof t)throw new Error(`expected valid ${e} CURVE object`);for(const a of["p","n","h"]){const e=t[a];if(!("bigint"==typeof e&&e>Ae))throw new Error(`CURVE.${a} must be positive bigint`)}const o=Ue(t.p,n.Fp,r),i=Ue(t.n,n.Fn,r),s=["Gx","Gy","a","weierstrass"===e?"b":"d"];for(const a of s)if(!o.isValid(t[a]))throw new Error(`CURVE.${a} must be valid field element of CURVE.Fp`);return{CURVE:t=Object.freeze(Object.assign({},t)),Fp:o,Fn:i}}("weierstrass",e,t),{Fp:r,Fn:o}=n;let i=n.CURVE;const{h:s,n:a}=i;Q(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",wrapPrivateKey:"boolean"});const{endo:c}=t;if(c&&(!r.is0(i.a)||"bigint"!=typeof c.beta||!Array.isArray(c.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');const u=tt(r,o);function l(){if(!r.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}const f=t.toBytes||function(e,t,n){const{x:o,y:i}=t.toAffine(),s=r.toBytes(o);if(M(n,"isCompressed"),n){l();return R(et(!r.isOdd(i)),s)}return R(Uint8Array.of(4),s,r.toBytes(i))},h=t.fromBytes||function(e){U(e,void 0,"Point");const{publicKey:t,publicKeyUncompressed:n}=u,o=e.length,i=e[0],s=e.subarray(1);if(o!==t||2!==i&&3!==i){if(o===n&&4===i){const e=r.BYTES,t=r.fromBytes(s.subarray(0,e)),n=r.fromBytes(s.subarray(e,2*e));if(!m(t,n))throw new Error("bad point: is not on curve");return{x:t,y:n}}throw new Error(`bad point: got length ${o}, expected compressed=${t} or uncompressed=${n}`)}{const e=r.fromBytes(s);if(!r.isValid(e))throw new Error("bad point: is not on curve, wrong x");const t=d(e);let n;try{n=r.sqrt(t)}catch(a){const e=a instanceof Error?": "+a.message:"";throw new Error("bad point: is not on curve, sqrt error"+e)}l();return!(1&~i)!==r.isOdd(n)&&(n=r.neg(n)),{x:e,y:n}}};function d(e){const t=r.sqr(e),n=r.mul(t,e);return r.add(r.add(n,r.mul(e,i.a)),i.b)}function m(e,t){const n=r.sqr(t),o=d(e);return r.eql(n,o)}if(!m(i.Gx,i.Gy))throw new Error("bad curve params: generator point");const g=r.mul(r.pow(i.a,Je),Xe),y=r.mul(r.sqr(i.b),BigInt(27));if(r.is0(r.add(g,y)))throw new Error("bad curve params: a or b");function w(e,t,n=!1){if(!r.isValid(t)||n&&r.is0(t))throw new Error(`bad point coordinate ${e}`);return t}function b(e){if(!(e instanceof T))throw new Error("ProjectivePoint expected")}function v(e){if(!c||!c.basises)throw new Error("no endo");return function(e,t,n){const[[r,o],[i,s]]=t,a=Ge(s*e,n),c=Ge(-o*e,n);let u=e-a*r-c*i,l=-a*o-c*s;const f=u<He,h=l<He;f&&(u=-u),h&&(l=-l);const d=Y(Math.ceil(X(n)/2))+We;if(u<He||u>=d||l<He||l>=d)throw new Error("splitScalar (endomorphism): failed, k="+e);return{k1neg:f,k1:u,k2neg:h,k2:l}}(e,c.basises,o.ORDER)}const B=ee(((e,t)=>{const{X:n,Y:o,Z:i}=e;if(r.eql(i,r.ONE))return{x:n,y:o};const s=e.is0();null==t&&(t=s?r.ONE:r.inv(i));const a=r.mul(n,t),c=r.mul(o,t),u=r.mul(i,t);if(s)return{x:r.ZERO,y:r.ZERO};if(!r.eql(u,r.ONE))throw new Error("invZ was invalid");return{x:a,y:c}})),E=ee((e=>{if(e.is0()){if(t.allowInfinityPoint&&!r.is0(e.Y))return;throw new Error("bad point: ZERO")}const{x:n,y:o}=e.toAffine();if(!r.isValid(n)||!r.isValid(o))throw new Error("bad point: x or y not field elements");if(!m(n,o))throw new Error("bad point: equation left != right");if(!e.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0}));function x(e,t,n,o,i){return n=new T(r.mul(n.X,e),n.Y,n.Z),t=ke(o,t),n=ke(i,n),t.add(n)}class T{constructor(e,t,n){this.X=w("x",e),this.Y=w("y",t,!0),this.Z=w("z",n),Object.freeze(this)}static CURVE(){return i}static fromAffine(e){const{x:t,y:n}=e||{};if(!e||!r.isValid(t)||!r.isValid(n))throw new Error("invalid affine point");if(e instanceof T)throw new Error("projective point not allowed");return r.is0(t)&&r.is0(n)?T.ZERO:new T(t,n,r.ONE)}static fromBytes(e){const t=T.fromAffine(h(U(e,void 0,"point")));return t.assertValidity(),t}static fromHex(e){return T.fromBytes(W("pointHex",e))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(e=8,t=!0){return A.createCache(this,e),t||this.multiply(Je),this}assertValidity(){E(this)}hasEvenY(){const{y:e}=this.toAffine();if(!r.isOdd)throw new Error("Field doesn't support isOdd");return!r.isOdd(e)}equals(e){b(e);const{X:t,Y:n,Z:o}=this,{X:i,Y:s,Z:a}=e,c=r.eql(r.mul(t,a),r.mul(i,o)),u=r.eql(r.mul(n,a),r.mul(s,o));return c&&u}negate(){return new T(this.X,r.neg(this.Y),this.Z)}double(){const{a:e,b:t}=i,n=r.mul(t,Je),{X:o,Y:s,Z:a}=this;let c=r.ZERO,u=r.ZERO,l=r.ZERO,f=r.mul(o,o),h=r.mul(s,s),d=r.mul(a,a),p=r.mul(o,s);return p=r.add(p,p),l=r.mul(o,a),l=r.add(l,l),c=r.mul(e,l),u=r.mul(n,d),u=r.add(c,u),c=r.sub(h,u),u=r.add(h,u),u=r.mul(c,u),c=r.mul(p,c),l=r.mul(n,l),d=r.mul(e,d),p=r.sub(f,d),p=r.mul(e,p),p=r.add(p,l),l=r.add(f,f),f=r.add(l,f),f=r.add(f,d),f=r.mul(f,p),u=r.add(u,f),d=r.mul(s,a),d=r.add(d,d),f=r.mul(d,p),c=r.sub(c,f),l=r.mul(d,h),l=r.add(l,l),l=r.add(l,l),new T(c,u,l)}add(e){b(e);const{X:t,Y:n,Z:o}=this,{X:s,Y:a,Z:c}=e;let u=r.ZERO,l=r.ZERO,f=r.ZERO;const h=i.a,d=r.mul(i.b,Je);let p=r.mul(t,s),m=r.mul(n,a),g=r.mul(o,c),y=r.add(t,n),w=r.add(s,a);y=r.mul(y,w),w=r.add(p,m),y=r.sub(y,w),w=r.add(t,o);let v=r.add(s,c);return w=r.mul(w,v),v=r.add(p,g),w=r.sub(w,v),v=r.add(n,o),u=r.add(a,c),v=r.mul(v,u),u=r.add(m,g),v=r.sub(v,u),f=r.mul(h,w),u=r.mul(d,g),f=r.add(u,f),u=r.sub(m,f),f=r.add(m,f),l=r.mul(u,f),m=r.add(p,p),m=r.add(m,p),g=r.mul(h,g),w=r.mul(d,w),m=r.add(m,g),g=r.sub(p,g),g=r.mul(h,g),w=r.add(w,g),p=r.mul(m,w),l=r.add(l,p),p=r.mul(v,w),u=r.mul(y,u),u=r.sub(u,p),p=r.mul(y,m),f=r.mul(v,f),f=r.add(f,p),new T(u,l,f)}subtract(e){return this.add(e.negate())}is0(){return this.equals(T.ZERO)}multiply(e){const{endo:n}=t;if(!o.isValidNot0(e))throw new Error("invalid scalar: out of range");let r,i;const s=e=>A.cached(this,e,(e=>Se(T,e)));if(n){const{k1neg:t,k1:o,k2neg:a,k2:c}=v(e),{p:u,f:l}=s(o),{p:f,f:h}=s(c);i=l.add(h),r=x(n.beta,u,f,t,a)}else{const{p:t,f:n}=s(e);r=t,i=n}return Se(T,[r,i])[0]}multiplyUnsafe(e){const{endo:n}=t,r=this;if(!o.isValid(e))throw new Error("invalid scalar: out of range");if(e===He||r.is0())return T.ZERO;if(e===We)return r;if(A.hasCache(this))return this.multiply(e);if(n){const{k1neg:t,k1:o,k2neg:i,k2:s}=v(e),{p1:a,p2:c}=function(e,t,n,r){let o=t,i=e.ZERO,s=e.ZERO;for(;n>Ae||r>Ae;)n&ze&&(i=i.add(o)),r&ze&&(s=s.add(o)),o=o.double(),n>>=ze,r>>=ze;return{p1:i,p2:s}}(T,r,o,s);return x(n.beta,a,c,t,i)}return A.unsafe(r,e)}multiplyAndAddUnsafe(e,t,n){const r=this.multiplyUnsafe(t).add(e.multiplyUnsafe(n));return r.is0()?void 0:r}toAffine(e){return B(this,e)}isTorsionFree(){const{isTorsionFree:e}=t;return s===We||(e?e(T,this):A.unsafe(this,a).is0())}clearCofactor(){const{clearCofactor:e}=t;return s===We?this:e?e(T,this):this.multiplyUnsafe(s)}isSmallOrder(){return this.multiplyUnsafe(s).is0()}toBytes(e=!0){return M(e,"isCompressed"),this.assertValidity(),f(T,this,e)}toHex(e=!0){return p(this.toBytes(e))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}get px(){return this.X}get py(){return this.X}get pz(){return this.Z}toRawBytes(e=!0){return this.toBytes(e)}_setWindowSize(e){this.precompute(e)}static normalizeZ(e){return Se(T,e)}static msm(e,t){return function(e,t,n,r){De(n,e),Ve(r,t);const o=n.length,i=r.length;if(o!==i)throw new Error("arrays of points and scalars must have equal length");const s=e.ZERO,a=X(BigInt(o));let c=1;a>12?c=a-3:a>4?c=a-2:a>0&&(c=2);const u=Y(c),l=new Array(Number(u)+1).fill(s);let f=s;for(let h=Math.floor((t.BITS-1)/c)*c;h>=0;h-=c){l.fill(s);for(let t=0;t<i;t++){const e=r[t],o=Number(e>>BigInt(h)&u);l[o]=l[o].add(n[t])}let e=s;for(let t=l.length-1,n=s;t>0;t--)n=n.add(l[t]),e=e.add(n);if(f=f.add(e),0!==h)for(let t=0;t<c;t++)f=f.double()}return f}(T,o,e,t)}static fromPrivateKey(e){return T.BASE.multiply(Ye(o,e))}}T.BASE=new T(i.Gx,i.Gy,r.ONE),T.ZERO=new T(r.ZERO,r.ONE,r.ZERO),T.Fp=r,T.Fn=o;const O=o.BITS,A=new Me(T,t.endo?Math.ceil(O/2):O);return T.BASE.precompute(8),T}function et(e){return Uint8Array.of(e?2:3)}function tt(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function nt(e,t={}){const{Fn:n}=e,r=t.randomBytes||z,o=Object.assign(tt(e.Fp,n),{seed:Oe(n.ORDER)});function i(e){try{return!!Ye(n,e)}catch(Pc){return!1}}function s(e=r(o.seed)){return function(e,t,n=!1){const r=e.length,o=Re(t),i=Oe(t);if(r<16||r<i||r>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+r);const s=fe(n?Z(e):j(e),t-ne)+ne;return n?H(s,o):q(s,o)}(U(e,o.seed,"seed"),n.ORDER)}function a(t,r=!0){return e.BASE.multiply(Ye(n,t)).toBytes(r)}function c(t){if("bigint"==typeof t)return!1;if(t instanceof e)return!0;const{secretKey:r,publicKey:i,publicKeyUncompressed:s}=o;if(n.allowedLengths||r===i)return;const a=W("key",t).length;return a===i||a===s}const u={isValidSecretKey:i,isValidPublicKey:function(t,n){const{publicKey:r,publicKeyUncompressed:i}=o;try{const o=t.length;return(!0!==n||o===r)&&((!1!==n||o===i)&&!!e.fromBytes(t))}catch(Pc){return!1}},randomSecretKey:s,isValidPrivateKey:i,randomPrivateKey:s,normPrivateKeyToScalar:e=>Ye(n,e),precompute:(t=8,n=e.BASE)=>n.precompute(t,!1)};return Object.freeze({getPublicKey:a,getSharedSecret:function(t,r,o=!0){if(!0===c(t))throw new Error("first arg must be private key");if(!1===c(r))throw new Error("second arg must be public key");const i=Ye(n,t);return e.fromHex(r).multiply(i).toBytes(o)},keygen:function(e){const t=s(e);return{secretKey:t,publicKey:a(t)}},Point:e,utils:u,lengths:o})}function rt(e,t,n={}){a(t),Q(n,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});const r=n.randomBytes||z,i=n.hmac||((e,...n)=>C(t,e,R(...n))),{Fp:s,Fn:c}=e,{ORDER:u,BITS:l}=c,{keygen:f,getPublicKey:h,getSharedSecret:d,utils:m,lengths:g}=nt(e,n),y={prehash:!1,lowS:"boolean"==typeof n.lowS&&n.lowS,format:void 0,extraEntropy:!1},w="compact";function b(e){return e>u>>We}function v(e,t){if(!c.isValidNot0(t))throw new Error(`invalid signature ${e}: out of range 1..Point.Fn.ORDER`);return t}class B{constructor(e,t,n){this.r=v("r",e),this.s=v("s",t),null!=n&&(this.recovery=n),Object.freeze(this)}static fromBytes(e,t=w){let n;if(function(e,t){Le(t);const n=g.signature;U(e,"compact"===t?n:"recovered"===t?n+1:void 0,`${t} signature`)}(e,t),"der"===t){const{r:t,s:n}=qe.toSig(U(e));return new B(t,n)}"recovered"===t&&(n=e[0],t="compact",e=e.subarray(1));const r=c.BYTES,o=e.subarray(0,r),i=e.subarray(r,2*r);return new B(c.fromBytes(o),c.fromBytes(i),n)}static fromHex(e,t){return this.fromBytes(E(e),t)}addRecoveryBit(e){return new B(this.r,this.s,e)}recoverPublicKey(t){const n=s.ORDER,{r:r,s:o,recovery:i}=this;if(null==i||![0,1,2,3].includes(i))throw new Error("recovery id invalid");if(u*Ke<n&&i>1)throw new Error("recovery id is ambiguous for h>1 curve");const a=2===i||3===i?r+u:r;if(!s.isValid(a))throw new Error("recovery id 2 or 3 invalid");const l=s.toBytes(a),f=e.fromBytes(R(et(!(1&i)),l)),h=c.inv(a),d=T(W("msgHash",t)),p=c.create(-d*h),m=c.create(o*h),g=e.BASE.multiplyUnsafe(p).add(f.multiplyUnsafe(m));if(g.is0())throw new Error("point at infinify");return g.assertValidity(),g}hasHighS(){return b(this.s)}toBytes(e=w){if(Le(e),"der"===e)return E(qe.hexFromSig(this));const t=c.toBytes(this.r),n=c.toBytes(this.s);if("recovered"===e){if(null==this.recovery)throw new Error("recovery bit must be present");return R(Uint8Array.of(this.recovery),t,n)}return R(t,n)}toHex(e){return p(this.toBytes(e))}assertValidity(){}static fromCompact(e){return B.fromBytes(W("sig",e),"compact")}static fromDER(e){return B.fromBytes(W("sig",e),"der")}normalizeS(){return this.hasHighS()?new B(this.r,c.neg(this.s),this.recovery):this}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return p(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return p(this.toBytes("compact"))}}const x=n.bits2int||function(e){if(e.length>8192)throw new Error("input is too large");const t=j(e),n=8*e.length-l;return n>0?t>>BigInt(n):t},T=n.bits2int_modN||function(e){return c.create(x(e))},O=Y(l);function A(e){return J("num < 2^"+l,e,He,O),c.toBytes(e)}function k(e,n){return U(e,void 0,"message"),n?U(t(e),void 0,"prehashed message"):e}return Object.freeze({keygen:f,getPublicKey:h,getSharedSecret:d,utils:m,lengths:g,Point:e,sign:function(n,o,s={}){n=W("message",n);const{seed:a,k2sig:u}=function(t,n,o){if(["recovered","canonical"].some((e=>e in o)))throw new Error("sign() legacy options not supported");const{lowS:i,prehash:s,extraEntropy:a}=je(o,y);t=k(t,s);const u=T(t),l=Ye(c,n),f=[A(l),A(u)];if(null!=a&&!1!==a){const e=!0===a?r(g.secretKey):a;f.push(W("extraEntropy",e))}const h=R(...f),d=u;return{seed:h,k2sig:function(t){const n=x(t);if(!c.isValidNot0(n))return;const r=c.inv(n),o=e.BASE.multiply(n).toAffine(),s=c.create(o.x);if(s===He)return;const a=c.create(r*c.create(d+s*l));if(a===He)return;let u=(o.x===s?0:2)|Number(o.y&We),f=a;return i&&b(a)&&(f=c.neg(a),u^=1),new B(s,f,u)}}}(n,o,s);return function(e,t,n){if("number"!=typeof e||e<2)throw new Error("hashLen must be a number");if("number"!=typeof t||t<2)throw new Error("qByteLen must be a number");if("function"!=typeof n)throw new Error("hmacFn must be a function");const r=e=>new Uint8Array(e),o=e=>Uint8Array.of(e);let i=r(e),s=r(e),a=0;const c=()=>{i.fill(1),s.fill(0),a=0},u=(...e)=>n(s,i,...e),l=(e=r(0))=>{s=u(o(0),e),i=u(),0!==e.length&&(s=u(o(1),e),i=u())},f=()=>{if(a++>=1e3)throw new Error("drbg: tried 1000 values");let e=0;const n=[];for(;e<t;){i=u();const t=i.slice();n.push(t),e+=i.length}return R(...n)};return(e,t)=>{let n;for(c(),l(e);!(n=t(f()));)l();return c(),n}}(t.outputLen,c.BYTES,i)(a,u)},verify:function(t,n,r,i={}){const{lowS:s,prehash:a,format:u}=je(i,y);if(r=W("publicKey",r),n=k(W("message",n),a),"strict"in i)throw new Error("options.strict was renamed to lowS");const l=void 0===u?function(e){let t;const n="string"==typeof e||o(e),r=!n&&null!==e&&"object"==typeof e&&"bigint"==typeof e.r&&"bigint"==typeof e.s;if(!n&&!r)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");if(r)t=new B(e.r,e.s);else if(n){try{t=B.fromBytes(W("sig",e),"der")}catch(i){if(!(i instanceof qe.Err))throw i}if(!t)try{t=B.fromBytes(W("sig",e),"compact")}catch(Pc){return!1}}return t||!1}(t):B.fromBytes(W("sig",t),u);if(!1===l)return!1;try{const t=e.fromBytes(r);if(s&&l.hasHighS())return!1;const{r:o,s:i}=l,a=T(n),u=c.inv(i),f=c.create(a*u),h=c.create(o*u),d=e.BASE.multiplyUnsafe(f).add(t.multiplyUnsafe(h));if(d.is0())return!1;return c.create(d.x)===o}catch(f){return!1}},recoverPublicKey:function(e,t,n={}){const{prehash:r}=je(n,y);return t=k(t,r),B.fromBytes(e,"recovered").recoverPublicKey(t).toBytes()},Signature:B,hash:t})}function ot(e){const t={a:e.a,b:e.b,p:e.Fp.ORDER,n:e.n,h:e.h,Gx:e.Gx,Gy:e.Gy},n=e.Fp;let r=e.allowedPrivateKeyLengths?Array.from(new Set(e.allowedPrivateKeyLengths.map((e=>Math.ceil(e/2))))):void 0;return{CURVE:t,curveOpts:{Fp:n,Fn:Te(t.n,{BITS:e.nBitLength,allowedLengths:r,modFromBytes:e.wrapPrivateKey}),allowInfinityPoint:e.allowInfinityPoint,endo:e.endo,isTorsionFree:e.isTorsionFree,clearCofactor:e.clearCofactor,fromBytes:e.fromBytes,toBytes:e.toBytes}}}function it(e){const{CURVE:t,curveOpts:n,hash:r,ecdsaOpts:o}=function(e){const{CURVE:t,curveOpts:n}=ot(e),r={hmac:e.hmac,randomBytes:e.randomBytes,lowS:e.lowS,bits2int:e.bits2int,bits2int_modN:e.bits2int_modN};return{CURVE:t,curveOpts:n,hash:e.hash,ecdsaOpts:r}}(e);return function(e,t){const n=t.Point;return Object.assign({},t,{ProjectivePoint:n,CURVE:Object.assign({},e,xe(n.Fn.ORDER,n.Fn.BITS))})}(e,rt(Qe(t,n),r,o))}const st={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},at={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]},ct=BigInt(2);const ut=Te(st.p,{sqrt:function(e){const t=st.p,n=BigInt(3),r=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),a=BigInt(44),c=BigInt(88),u=e*e*e%t,l=u*u*e%t,f=he(l,n,t)*l%t,h=he(f,n,t)*l%t,d=he(h,ct,t)*u%t,p=he(d,o,t)*d%t,m=he(p,i,t)*p%t,g=he(m,a,t)*m%t,y=he(g,c,t)*g%t,w=he(y,a,t)*m%t,b=he(w,n,t)*l%t,v=he(b,s,t)*p%t,B=he(v,r,t)*u%t,E=he(B,ct,t);if(!ut.eql(ut.sqr(E),e))throw new Error("Cannot find square root");return E}}),lt=function(e,t){const n=t=>it({...e,hash:t});return{...n(t),create:n}}({...st,Fp:ut,lowS:!0,endo:at},V);function ft(e,t){const n=[];for(let r=0;r<e.length;r+=t)n.push(e.subarray(r,r+t));return n}function ht(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function dt(e,t){const n=Math.min(e.length,t.length);for(let r=0;r<n;r++)if(e[r]!==t[r])return e.subarray(0,r);return e.subarray(0,n)}function pt(e){return Array.from(e).map((e=>e.toString(16).padStart(2,"0"))).join("")}function mt(e,t){const n=new Uint8Array(32);let r=e;if("LE"===t){for(let e=0;e<32;e++)n[e]=Number(0xffn&r),r>>=8n;return n}for(let o=31;o>=0;o--)n[o]=Number(0xffn&r),r>>=8n;return n}function gt(e,t){let n=0n;if("LE"===t){for(let t=31;t>=0;t--)n=n<<8n|BigInt(e[t]);return n}for(let r=0;r<32;r++)n=n<<8n|BigInt(e[r]);return n}function yt(e){const t=e.startsWith("0x")||e.startsWith("0X")?e.slice(2):e;if(t.length%2!=0||!/^[0-9a-fA-F]*$/.test(t))throw new Error(`hexToUint8Array: invalid hex string: ${e}`);const n=new Uint8Array(t.length/2);for(let r=0;r<n.length;r++)n[r]=parseInt(t.slice(2*r,2*r+2),16);return n}var wt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bt="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";function vt(e,t){const n=t.length;let r=0,o=0;const i=[];for(let s=0;s<e.length;s++){const a=e.charAt(s);if("="===a)break;const c=t.indexOf(a);if(-1===c)throw new Error(`Invalid character: ${a}`);o=o<<Math.log2(n)|c,r+=Math.log2(n),r>=8&&(r-=8,i.push(o>>r&255))}return new Uint8Array(i)}function Bt(e,t,n){const r=t.length;let o=0,i=0,s="";for(const a of e)for(i=i<<8|a,o+=8;o>=Math.log2(r);)o-=Math.log2(r),s+=t.charAt(i>>o&r-1);return o>0&&(s+=t.charAt(i<<Math.log2(r)-o&r-1)),s.length%n!=0&&(s+="=".repeat(n-s.length%n)),s}function Et(e){return Bt(e,bt,8)}function xt(e){return new Uint8Array([e])}function Tt(e){return e[0]}function Rt(e,t){return new DataView(e.buffer,e.byteOffset,e.byteLength).getUint16(0,"LE"===t)}function Ot(e,t){const n=new ArrayBuffer(4);return new DataView(n).setUint32(0,e,"LE"===t),new Uint8Array(n)}function At(e,t){const n=new ArrayBuffer(8);return new DataView(n).setBigUint64(0,e,"LE"===t),new Uint8Array(n)}function zt(e,t){return new DataView(e.buffer,e.byteOffset,e.byteLength).getBigUint64(0,"LE"===t)}var kt=[0,1,0,32898,2147483648,32906,2147483648,2147516416,0,32907,0,2147483649,2147483648,2147516545,2147483648,32777,0,138,0,136,0,2147516425,0,2147483658,0,2147516555,2147483648,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,0,32778,2147483648,2147483658,2147483648,2147516545,2147483648,32896,0,2147483649,2147483648,2147516424];function St(e){return t=function(e,t){for(const n of t){for(let t=0;t<34;t+=2)e[t]=e[t]^n[t+1],e[t+1]=e[t+1]^n[t];$t(e)}return e}(new Array(50).fill(0),function(e,t){if(!e.length){const e=new Uint8Array(136);return e[0]=t,e[135]=128,[_t(e)]}const n=ft(e,136),r=n[n.length-1];if(r.length<136){const e=new Uint8Array(136);e.set(r),e[r.length]=t,e[135]=128|e[135],n[n.length-1]=e}if(136===r.length){const e=new Uint8Array(136);e[0]=t,e[135]=128,n.push(e)}return n.map(_t)}(e,1)),new Uint8Array([t[1],t[1]>>-24,t[1]>>-16,t[1]>>-8,t[0],t[0]>>8,t[0]>>16,t[0]>>24,t[3],t[3]>>-24,t[3]>>-16,t[3]>>-8,t[2],t[2]>>8,t[2]>>16,t[2]>>24,t[5],t[5]>>-24,t[5]>>-16,t[5]>>-8,t[4],t[4]>>8,t[4]>>16,t[4]>>24,t[7],t[7]>>-24,t[7]>>-16,t[7]>>-8,t[6],t[6]>>8,t[6]>>16,t[6]>>24]);var t}function $t(e){for(let t=0;t<24;t++){const n=e[0]^e[10]^e[20]^e[30]^e[40],r=e[1]^e[11]^e[21]^e[31]^e[41],o=e[2]^e[12]^e[22]^e[32]^e[42],i=e[3]^e[13]^e[23]^e[33]^e[43],s=e[4]^e[14]^e[24]^e[34]^e[44],a=e[5]^e[15]^e[25]^e[35]^e[45],c=e[6]^e[16]^e[26]^e[36]^e[46],u=e[7]^e[17]^e[27]^e[37]^e[47],l=e[8]^e[18]^e[28]^e[38]^e[48],f=e[9]^e[19]^e[29]^e[39]^e[49],h=l^(o<<1|i>>>31),d=f^(i<<1|o>>>31),p=n^(s<<1|a>>>31),m=r^(a<<1|s>>>31),g=o^(c<<1|u>>>31),y=i^(u<<1|c>>>31),w=s^(l<<1|f>>>31),b=a^(f<<1|l>>>31),v=c^(n<<1|r>>>31),B=u^(r<<1|n>>>31);e[0]^=h,e[1]^=d,e[2]^=p,e[3]^=m,e[4]^=g,e[5]^=y,e[6]^=w,e[7]^=b,e[8]^=v,e[9]^=B,e[10]^=h,e[11]^=d,e[12]^=p,e[13]^=m,e[14]^=g,e[15]^=y,e[16]^=w,e[17]^=b,e[18]^=v,e[19]^=B,e[20]^=h,e[21]^=d,e[22]^=p,e[23]^=m,e[24]^=g,e[25]^=y,e[26]^=w,e[27]^=b,e[28]^=v,e[29]^=B,e[30]^=h,e[31]^=d,e[32]^=p,e[33]^=m,e[34]^=g,e[35]^=y,e[36]^=w,e[37]^=b,e[38]^=v,e[39]^=B,e[40]^=h,e[41]^=d,e[42]^=p,e[43]^=m,e[44]^=g,e[45]^=y,e[46]^=w,e[47]^=b,e[48]^=v,e[49]^=B;const E=e[0],x=e[1],T=e[2]<<1|e[3]>>>31,R=e[3]<<1|e[2]>>>31,O=e[5]<<30|e[4]>>>2,A=e[4]<<30|e[5]>>>2,z=e[6]<<28|e[7]>>>4,k=e[7]<<28|e[6]>>>4,S=e[8]<<27|e[9]>>>5,$=e[9]<<27|e[8]>>>5,_=e[11]<<4|e[10]>>>28,I=e[10]<<4|e[11]>>>28,D=e[13]<<12|e[12]>>>20,V=e[12]<<12|e[13]>>>20,P=e[14]<<6|e[15]>>>26,C=e[15]<<6|e[14]>>>26,F=e[17]<<23|e[16]>>>9,N=e[16]<<23|e[17]>>>9,M=e[18]<<20|e[19]>>>12,U=e[19]<<20|e[18]>>>12,G=e[20]<<3|e[21]>>>29,L=e[21]<<3|e[20]>>>29,j=e[22]<<10|e[23]>>>22,Z=e[23]<<10|e[22]>>>22,q=e[25]<<11|e[24]>>>21,H=e[24]<<11|e[25]>>>21,W=e[26]<<25|e[27]>>>7,K=e[27]<<25|e[26]>>>7,J=e[29]<<7|e[28]>>>25,X=e[28]<<7|e[29]>>>25,Y=e[31]<<9|e[30]>>>23,Q=e[30]<<9|e[31]>>>23,ee=e[33]<<13|e[32]>>>19,te=e[32]<<13|e[33]>>>19,ne=e[34]<<15|e[35]>>>17,re=e[35]<<15|e[34]>>>17,oe=e[36]<<21|e[37]>>>11,ie=e[37]<<21|e[36]>>>11,se=e[38]<<8|e[39]>>>24,ae=e[39]<<8|e[38]>>>24,ce=e[40]<<18|e[41]>>>14,ue=e[41]<<18|e[40]>>>14,le=e[42]<<2|e[43]>>>30,fe=e[43]<<2|e[42]>>>30,he=e[45]<<29|e[44]>>>3,de=e[44]<<29|e[45]>>>3,pe=e[47]<<24|e[46]>>>8,me=e[46]<<24|e[47]>>>8,ge=e[48]<<14|e[49]>>>18,ye=e[49]<<14|e[48]>>>18;e[0]=E^~D&q,e[1]=x^~V&H,e[2]=D^~q&oe,e[3]=V^~H&ie,e[4]=q^~oe&ge,e[5]=H^~ie&ye,e[6]=oe^~ge&E,e[7]=ie^~ye&x,e[8]=ge^~E&D,e[9]=ye^~x&V,e[10]=z^~M&G,e[11]=k^~U&L,e[12]=M^~G&ee,e[13]=U^~L&te,e[14]=G^~ee&he,e[15]=L^~te&de,e[16]=ee^~he&z,e[17]=te^~de&k,e[18]=he^~z&M,e[19]=de^~k&U,e[20]=T^~P&W,e[21]=R^~C&K,e[22]=P^~W&se,e[23]=C^~K&ae,e[24]=W^~se&ce,e[25]=K^~ae&ue,e[26]=se^~ce&T,e[27]=ae^~ue&R,e[28]=ce^~T&P,e[29]=ue^~R&C,e[30]=S^~_&j,e[31]=$^~I&Z,e[32]=_^~j&ne,e[33]=I^~Z&re,e[34]=j^~ne&pe,e[35]=Z^~re&me,e[36]=ne^~pe&S,e[37]=re^~me&$,e[38]=pe^~S&_,e[39]=me^~$&I,e[40]=O^~F&J,e[41]=A^~N&X,e[42]=F^~J&Y,e[43]=N^~X&Q,e[44]=J^~Y&le,e[45]=X^~Q&fe,e[46]=Y^~le&O,e[47]=Q^~fe&A,e[48]=le^~O&F,e[49]=fe^~A&N,e[0]^=kt[2*t],e[1]^=kt[2*t+1]}}function _t(e){const t=[];for(let n=0;n<e.length;n+=4)t.push(e[n]|e[n+1]<<8|e[n+2]<<16|e[n+3]<<24);return t}var It=new TextDecoder,Dt=new TextEncoder,Vt=/^(0x)?[0-9a-fA-F]*$/i;var Pt=class e{bytes;length;constructor(t,n){if(!t)throw new Error(`Bytes#constructor: constructor parameter is falsy: ${t}`);if(t instanceof e)this.bytes=t.bytes;else if("string"==typeof t){if(!Vt.test(t)||t.replace(/^0x/i,"").length%2!=0)throw new Error(`Bytes#constructor: invalid hex string: ${t}`);this.bytes=yt(t)}else if(t instanceof ArrayBuffer)this.bytes=new Uint8Array(t.slice(0));else if(t instanceof Uint8Array)this.bytes=t.slice();else{const e=t;if("object"!=typeof(r=e)||null===r||"function"!=typeof r.toHex)throw new Error("Bytes#constructor: unsupported type: "+typeof t);this.bytes=yt(e.toHex())}var r;if(this.length=this.bytes.length,void 0!==n)if(Array.isArray(n)){if(!n.includes(this.length))throw new Error(`Bytes#checkByteLength: bytes length is ${this.length} but expected ${n.join(" or ")}`)}else if(this.length!==n)throw new Error(`Bytes#checkByteLength: bytes length is ${this.length} but expected ${n}`)}static keccak256(t){return new e(St(new e(t).toUint8Array()))}static concat(...t){const n=t.map((t=>t instanceof e?t.toUint8Array():t)),r=n.reduce(((e,t)=>e+t.length),0),o=new Uint8Array(r);let i=0;for(const e of n)o.set(e,i),i+=e.length;return o}static fromUtf8(t){return new e(Dt.encode(t))}static fromSlice(t,n,r){return new e(void 0===r?t.slice(n):t.slice(n,n+r))}offset(e){return new Uint8Array(this.bytes.slice(e))}toUint8Array(){return new Uint8Array(this.bytes)}toHex(){return pt(this.bytes)}toBase64(){return Bt(this.bytes,wt,4)}toBase32(){return Et(this.bytes)}toString(){return this.toHex()}toUtf8(){return It.decode(this.bytes)}parsePayloadAsJson(){return JSON.parse(this.toUtf8())}toJSON(){return this.toHex()}equals(t){return this.toHex()===new e(t).toHex()}represent(){return this.toHex()}[Symbol.for("nodejs.util.inspect.custom")](){return this.represent()}},Ct=class extends Pt{static LENGTH=32;constructor(e){super(e,32)}},Ft=0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n;function Nt(e){if(e<=0n||e>=Ft)throw new Error("Invalid private key");const t=lt.Point.BASE.multiply(e);return[t.x,t.y]}function Mt(e){const t=new Uint8Array(20),n=St(Pt.concat(mt(e[0],"BE"),mt(e[1],"BE")));return t.set(n.subarray(12)),t}var Ut=class extends Pt{static LENGTH=20;constructor(e){super(e,20)}toChecksum(){return function(e){const t=pt(e),n=pt(St(Uint8Array.from(t,(e=>e.charCodeAt(0)))));let r="0x";for(let o=0;o<t.length;o++)r+=parseInt(n.charAt(o),16)>7?t.charAt(o).toUpperCase():t.charAt(o);return r}(this.bytes)}},Gt=new Uint8Array(8).fill(255,0,8),Lt=class e extends Pt{static LENGTH=8;static MINUS_ONE=new e(Gt);constructor(e){super(e,8)}static fromBigInt(t){return new e(At(t,"BE"))}toBigInt(){return zt(this.bytes,"BE")}next(){return pt(this.bytes)===pt(Gt)?e.fromBigInt(0n):e.fromBigInt(this.toBigInt()+1n)}},jt=new TextEncoder,Zt=class e extends Pt{static LENGTH=32;constructor(e){super(e,32)}static fromString(t){return new e(St(jt.encode(t)))}},qt=class extends Pt{static LENGTH=32;constructor(e){super(e,32)}};function Ht(e,t){const n=lt.sign(St(e),t,{prehash:!1}),r=0===n.recovery?27n:28n;return[n.r,n.s,r]}function Wt(e,t,n,r){const o=27n===r?0:1,i=new lt.Signature(t,n,o).recoverPublicKey(St(e));return[i.x,i.y]}var Kt=class extends Pt{static LENGTH=64;constructor(e){const t=new Pt(e);if(33===t.length){const[e,n]=function(e){if(33!==e.length||2!==e[0]&&3!==e[0])throw new Error("Invalid compressed public key");const t=lt.Point.fromBytes(e);return[t.x,t.y]}(t.toUint8Array());super(Pt.concat(mt(e,"BE"),mt(n,"BE")),64)}else super(e,64)}address(){const e=gt(this.bytes.slice(0,32),"BE"),t=gt(this.bytes.slice(32,64),"BE");return new Ut(Mt([e,t]))}toCompressedUint8Array(){const e=gt(this.bytes.slice(0,32),"BE"),t=gt(this.bytes.slice(32,64),"BE");return n=[e,t],lt.Point.fromAffine({x:n[0],y:n[1]}).toBytes(!0);var n}toCompressedHex(){return pt(this.toCompressedUint8Array())}},Jt=new TextEncoder,Xt=Jt.encode("Ethereum Signed Message:\n32");function Yt(e){const t=e instanceof Uint8Array?e:Jt.encode(e);return Pt.concat(Xt,St(t))}var Qt=class e extends Pt{static LENGTH=65;constructor(e){super(e,65)}static fromSlice(t,n){return new e(t.slice(n,n+e.LENGTH))}recoverPublicKey(e){const t=gt(this.bytes.slice(0,32),"BE"),n=gt(this.bytes.slice(32,64),"BE"),r=BigInt(this.bytes[64]),[o,i]=Wt(Yt(e),t,n,r);return new Kt(Pt.concat(mt(o,"BE"),mt(i,"BE")))}isValid(e,t){return this.recoverPublicKey(e).address().equals(t)}},en=class extends Pt{static LENGTH=32;constructor(e){super(e,32)}publicKey(){const[e,t]=Nt(this.toBigInt());return new Kt(Pt.concat(mt(e,"BE"),mt(t,"BE")))}sign(e){const[t,n,r]=Ht(Yt(e),this.toBigInt());return new Qt(Pt.concat(mt(t,"BE"),mt(n,"BE"),new Uint8Array([Number(r)])))}toBigInt(){return gt(this.bytes,"BE")}};function tn(e){const t=vt(e.toUpperCase().slice(1),bt);const n=t[1];if(250!==n&&251!==n)throw new Error("Unknown codec");return t.slice(-32)}var nn=class e extends Pt{static LENGTH=32;constructor(e){"string"==typeof e&&e.startsWith("bah5")?super(tn(e),32):super(e,[32,64])}toCid(t){if(this.length!==e.LENGTH)throw new Error(`Reference#toCid: only 32-byte references can be encoded as a CID, got ${this.length} bytes`);return`b${Et(Pt.concat(new Uint8Array([1]),new Uint8Array(["feed"===t?251:250]),new Uint8Array([1]),new Uint8Array([27]),new Uint8Array([32]))).replace(/=+$/,"")}${this.toBase32().replace(/=+$/,"")}`.toLowerCase()}static isValid(t){try{return new e(t),!0}catch{return!1}}},rn=class e extends Pt{static LENGTH=8;constructor(e){super(e,8)}static fromBigInt(t){return new e(At(t,"LE"))}toBigInt(){return zt(this.bytes,"LE")}static fromSlice(t,n){return new e(t.slice(n,n+e.LENGTH))}},on=new TextEncoder,sn=class e extends Pt{static LENGTH=32;constructor(e){super(e,32)}static fromString(t){return new e(St(on.encode(t)))}},an=class extends Pt{static LENGTH=32;constructor(e){super(e,32)}},cn=class{cursor=0;buffer;constructor(e){this.buffer=e}read(e){const t=this.buffer.subarray(this.cursor,this.cursor+e);return this.cursor+=e,t}max(){return this.buffer.length-this.cursor}},un=class{cursor=0;buffer;constructor(e){this.buffer=e}write(e){const t=Math.min(this.max(),e.max());return this.buffer.set(e.read(t),this.cursor),this.cursor+=t,t}max(){return this.buffer.length-this.cursor}};function ln(e,t,n){const r=new Uint8Array(n.length),o=new Uint8Array(36);o.set(e);for(let i=0,s=0;s<n.length;i++,s+=32){const e=t+i>>>0;o[32]=255&e,o[33]=e>>>8&255,o[34]=e>>>16&255,o[35]=e>>>24&255;const a=St(St(o)),c=Math.min(s+32,n.length);for(let t=s;t<c;t++)r[t]=n[t]^a[t-s]}return r}function fn(e,t){return ln(e,128,t)}function hn(e,t){return ln(e,0,t)}var dn=4096;function pn(e){const t=e.subarray(0,8),n=function(e){if(e.length>dn)throw new Error(`payload size ${e.length} exceeds maximum chunk payload size 4096`);const t=new Uint8Array(dn);t.set(e);let n=ft(t,32);for(;n.length>1;){const e=[];for(let t=0;t<n.length;t+=2)e.push(St(Pt.concat(n[t],n[t+1])));n=e}return n[0]}(e.subarray(8));return new nn(St(Pt.concat(t,n)))}yt("dc5b20847f43d67928f49cd4f85d696b5a7617b5");var mn=Zt.LENGTH,gn=Zt.LENGTH+65,yn=gn+rn.LENGTH,wn=(new TextEncoder).encode("Ethereum Signed Message:\n32");function bn(e,t){const n=St(Pt.concat(e,t));return Pt.concat(wn,n)}function vn(e,t,n){const[r,o,i]=Ht(bn(e,t),n);return Pt.concat(mt(r,"BE"),mt(o,"BE"),new Uint8Array([Number(i)]))}function Bn(e,t){const n=new Zt(e),r=new Ut(t);return new nn(St(Pt.concat(n.toUint8Array(),r.toUint8Array())))}function En(e,t,n){const r=new Zt(t),o=vn(r.toUint8Array(),e.address.toUint8Array(),n),i=new Ut(Mt(Nt(n))),s=Bn(r,i);return{data:Pt.concat(r.toUint8Array(),o,e.data),identifier:r,signature:new Qt(o),span:e.span,payload:e.payload,address:s,owner:i}}function xn(e,t){const n=e instanceof Pt?e.toUint8Array():e,r=new nn(t),o=new Zt(Pt.fromSlice(n,0,Zt.LENGTH)),i=n.slice(mn,mn+65),s=pn(n.slice(gn)),a=new Ut(function(e,t,n){const r=gt(n.subarray(0,32),"BE"),o=gt(n.subarray(32,64),"BE"),i=BigInt(n[64]);return Mt(Wt(bn(e,t),r,o,i))}(o.toUint8Array(),s.toUint8Array(),i)),c=Bn(o,a);if(!c.equals(r))throw new Error("SOC data does not match given address");const u=rn.fromSlice(n,gn),l=Pt.fromSlice(n,yn);return{data:n,identifier:o,signature:new Qt(i),span:u,payload:l,address:c,owner:a}}function Tn(e,t){if("string"==typeof e&&(e=Pt.fromUtf8(e)),e.length<1||e.length>4096)throw new RangeError(`payload size ${e.length} exceeds limits [1, 4096]`);const n=t?"bigint"==typeof t?rn.fromBigInt(t):t:rn.fromBigInt(BigInt(e.length)),r=new Pt(e),o=Pt.concat(n.toUint8Array(),r.toUint8Array()),i={data:o,span:n,payload:r,address:pn(o),toSingleOwnerChunk:(e,t)=>En(i,e,new en(t).toBigInt())};return i}function Rn(e){const t=new Pt(e);return Tn(t.toUint8Array().slice(rn.LENGTH),rn.fromSlice(t.toUint8Array(),0))}var On=class{span;writer;constructor(e=0n){this.span=e,this.writer=new un(new Uint8Array(4096))}build(){return Pt.concat(At(this.span,"LE"),this.writer.buffer)}hash(){return pn(this.build())}encryptedHash(e){e||(e=new Uint8Array(32),crypto.getRandomValues(e));const t=fn(e,At(this.span,"LE")),n=hn(e,this.writer.buffer);return{address:pn(Pt.concat(t,n)),key:e}}},An=class e{static NOOP=async e=>[];refSize;encrypted;maxShards;chunks;pending=[[]];onBatch;onIntermediateChunk;hasParity=[!1];promotedLeaf=[!1];pendingEntries=[];constructor(e,t,n=!1,r){this.encrypted=n,this.refSize=n?64:32,this.maxShards=t??4096/this.refSize,this.chunks=[new On],this.onBatch=e,this.onIntermediateChunk=r}static async root(t){const n=new e(e.NOOP);return await n.append(t),n.finalize()}static async encryptedRoot(t){const n=new e(e.NOOP,void 0,!0);await n.append(t);return(await n.finalize()).encryptedHash()}async append(e,t=0,n=0n){const r=new cn(e);for(;r.max()>0;){(0===this.chunks[t].writer.max()||n&&this.chunks[t].writer.max()<e.length)&&await this.elevate(t);const o=this.chunks[t].writer.write(r);n?this.chunks[t].span+=n:this.chunks[0].span+=BigInt(o)}}async elevate(e){this.pending[e]||(this.pending[e]=[]),await this.sealParities(e);const t=this.chunks[e].span;if(e>=1&&this.onIntermediateChunk&&!this.promotedLeaf[e]&&this.onIntermediateChunk(this.chunks[e],this.hasParity[e]??!1),this.hasParity[e]=!1,this.encrypted){const{address:n,key:r}=this.chunks[e].encryptedHash(),o=new Uint8Array(64);o.set(n.toUint8Array()),o.set(r,32),this.pending[e].push({entry:{chunk:this.chunks[e],key:r},ref:o,span:t})}else this.pending[e].push({entry:{chunk:this.chunks[e]},ref:this.chunks[e].hash().toUint8Array(),span:t});this.chunks[e]=new On,this.promotedLeaf[e]=!1,this.pending[e].length>=this.maxShards&&await this.flushBatch(e)}async sealParities(e){const t=this.pendingEntries[e];if(!t?.length)return;this.pendingEntries[e]=[];const n=await this.onBatch(t);if(n.length>0){this.hasParity[e]=!0;for(const{chunk:t}of n)this.chunks[e].writer.write(new cn(t.hash().toUint8Array()))}}async flushBatch(e){this.chunks[e+1]||(this.chunks.push(new On),this.pending.push([]),this.hasParity.push(!1),this.promotedLeaf.push(!1));const t=this.pending[e];this.pending[e]=[];for(const{ref:n,span:r}of t)await this.append(n,e+1,r);this.pendingEntries[e+1]||(this.pendingEntries[e+1]=[]),this.pendingEntries[e+1].push(...t.map((e=>e.entry))),t.length>=this.maxShards&&await this.sealParities(e+1)}async finalize(e=0){if(this.pending[e]?.length&&await this.flushBatch(e),!this.chunks[e+1])return await this.sealParities(e),e>=1&&this.onIntermediateChunk&&!this.promotedLeaf[e]&&this.onIntermediateChunk(this.chunks[e],this.hasParity[e]??!1),this.chunks[e];const t=this.chunks[e+1].writer;return 0===t.cursor||t.max()<this.refSize?(await this.elevate(e+1),await this.flushBatch(e+1),await this.sealParities(e),this.chunks[e+1]=this.chunks[e],this.hasParity[e+1]=this.hasParity[e]??!1,this.hasParity[e]=!1,this.promotedLeaf[e+1]=0===e||(this.promotedLeaf[e]??!1),this.finalize(e+1)):(await this.elevate(e),await this.flushBatch(e),this.finalize(e+1))}},zn=[[[],[]],[[95,69,47,29,15,6,2,1],[9,8,7,6,5,4,3,2]],[[105,96,87,78,70,62,54,47,40,33,27,21,16,11,7,4,2,1],[21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4]],[[93,88,83,78,74,69,64,60,55,51,46,42,38,34,30,27,23,20,17,14,11,9,6,4,3,2,1],[31,30,29,28,27,26,25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5]],[[37,36,35,34,33,32,31,30,29,28,27,26,25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1],[89,87,86,84,83,81,80,78,76,75,73,71,70,68,66,65,63,61,59,58,56,54,52,50,48,47,45,43,40,38,36,34,31,29,26,23,19]]],kn=[[[],[]],[[47,34,23,14,7,3,1],[9,8,7,6,5,4,3]],[[52,48,43,39,35,31,27,23,20,16,13,10,8,5,3,2,1],[21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5]],[[46,44,41,39,37,34,32,30,27,25,23,21,19,17,15,13,11,10,8,7,5,4,3,2,1],[31,30,29,28,27,26,25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,6]],[[18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1],[87,84,81,78,75,71,68,65,61,58,54,50,47,43,38,34,29,23]]];function Sn(e,t,n){return e<=0||e>4?0:function(e,t){const[n,r]=e;for(let o=0;o<n.length;o++)if(t>=n[o])return r[o];return 0}(n?kn[e]:zn[e],t)}function $n(e,t,n){return t<=0||e<=0?0:Sn(t,e,n)/e}var _n={label:"medium",value:1,errorTolerance:.01},In={label:"strong",value:2,errorTolerance:.05},Dn={label:"insane",value:3,errorTolerance:.1},Vn={label:"paranoid",value:4,errorTolerance:.5};function Pn(){return{medium:_n,strong:In,insane:Dn,paranoid:Vn}}function Cn(e){if("string"==typeof e)switch(e.toLowerCase()){case"medium":return _n;case"strong":return In;case"insane":return Dn;case"paranoid":return Vn;default:throw new Error(`Unknown redundancy level '${e}'`)}switch(e){case 1:return _n;case 2:return In;case 3:return Dn;case 4:return Vn;default:throw new Error(`Unknown redundancy level '${e}'`)}}function Fn(e,t){if(0===t.length)throw new Error("xorCypher: key must not be empty");const n=new Uint8Array(e.length);for(let r=0;r<e.length;r++)n[r]=e[r]^t[r%t.length];return n}new Uint8Array([0,0,1,25,2,50,26,198,3,223,51,238,27,104,199,75,4,100,224,14,52,141,239,129,28,193,105,248,200,8,76,113,5,138,101,47,225,36,15,33,53,147,142,218,240,18,130,69,29,181,194,125,106,39,249,185,201,154,9,120,77,228,114,166,6,191,139,98,102,221,48,253,226,152,37,179,16,145,34,136,54,208,148,206,143,150,219,189,241,210,19,92,131,56,70,64,30,66,182,163,195,72,126,110,107,58,40,84,250,133,186,61,202,94,155,159,10,21,121,43,78,212,229,172,115,243,167,87,7,112,192,247,140,128,99,13,103,74,222,237,49,197,254,24,227,165,153,119,38,184,180,124,17,68,146,217,35,32,137,46,55,63,209,91,149,188,207,205,144,135,151,178,220,252,190,97,242,86,211,171,20,42,93,158,132,60,57,83,71,109,65,162,31,45,67,216,183,123,164,118,196,23,73,236,127,12,111,246,108,161,59,82,41,157,85,170,251,96,134,177,187,204,62,90,203,89,95,176,156,169,160,81,11,245,22,235,122,117,44,215,79,174,213,233,230,231,173,232,116,214,244,234,168,80,88,175]),new Uint8Array([1,2,4,8,16,32,64,128,29,58,116,232,205,135,19,38,76,152,45,90,180,117,234,201,143,3,6,12,24,48,96,192,157,39,78,156,37,74,148,53,106,212,181,119,238,193,159,35,70,140,5,10,20,40,80,160,93,186,105,210,185,111,222,161,95,190,97,194,153,47,94,188,101,202,137,15,30,60,120,240,253,231,211,187,107,214,177,127,254,225,223,163,91,182,113,226,217,175,67,134,17,34,68,136,13,26,52,104,208,189,103,206,129,31,62,124,248,237,199,147,59,118,236,197,151,51,102,204,133,23,46,92,184,109,218,169,79,158,33,66,132,21,42,84,168,77,154,41,82,164,85,170,73,146,57,114,228,213,183,115,230,209,191,99,198,145,63,126,252,229,215,179,123,246,241,255,227,219,171,75,150,49,98,196,149,55,110,220,165,87,174,65,130,25,50,100,200,141,7,14,28,56,112,224,221,167,83,166,81,162,89,178,121,242,249,239,195,155,43,86,172,69,138,9,18,36,72,144,61,122,244,245,247,243,251,235,203,139,11,22,44,88,176,125,250,233,207,131,27,54,108,216,173,71,142]);var Nn=new TextEncoder,Mn=new TextDecoder,Un=new Uint8Array([47]),Gn=yt("5768b3b6a7db56d21d1abff40d41cebfc83448fed8d7e9b06ec0d3b073f28f7b");function Ln(e){return function(e,t,n=0){if(0===t.length)return Math.min(n,e.length);for(let r=n;r<e.length;r++)for(let n=0;n<t.length&&e[r+n]===t[n];n++)if(n===t.length-1)return r;return-1}(e,Un)>0}function jn(e,t){const n=Math.floor(t/8),r=t%8;e[n]=e[n]|1<<r}function Zn(e,t){const n=t%8;return 1==(e[Math.floor(t/8)]>>n&1)}var qn=class e{obfuscationKey;persisted=!1;loaded=!0;selfAddress=null;targetAddress=new Uint8Array(32);metadata=null;path=new Uint8Array(0);forks=new Map;parent=null;type=null;encrypt=!1;constructor(e){e?.encrypt&&(this.encrypt=!0),e?.targetAddress?this.targetAddress=e.targetAddress:this.encrypt&&(this.targetAddress=new Uint8Array(64)),e?.selfAddress&&(this.selfAddress=e.selfAddress),e?.metadata&&(this.metadata=e.metadata),this.obfuscationKey=e?.obfuscationKey??function(){const e=new Uint8Array(32);return crypto.getRandomValues(e),e}(),e?.path&&(this.path=e.path),e?.parent&&(this.parent=e.parent),this.type=e?.type??null}get fullPath(){return Pt.concat(this.parent?.fullPath??new Uint8Array(0),this.path)}get fullPathString(){return Mn.decode(this.fullPath)}async marshal(){for(const a of this.forks.values())a.node.selfAddress||(a.node.selfAddress=(await a.node.calculateSelfAddress()).toUint8Array());const e=!ht(this.targetAddress,new Uint8Array(this.targetAddress.length));let t=0;if(e)t=this.targetAddress.length;else for(const a of this.forks.values())if(a.node.selfAddress&&a.node.selfAddress.length>0){t=a.node.selfAddress.length;break}const n=new Uint8Array(32);n.set(Gn,0),n.set(xt(t),31);const r=e?this.targetAddress:new Uint8Array(t),o=new Uint8Array(32);for(const a of this.forks.keys())jn(o,a);const i=[];for(let a=0;a<256;a++)Zn(o,a)&&i.push(this.forks.get(a).marshal());const s=Fn(Pt.concat(n,r,o,...i),this.obfuscationKey);return Pt.concat(this.obfuscationKey,s)}hydrate(t){if(!this.selfAddress)throw new Error("MantarayNode#hydrate selfAddress is not set");const n=e.unmarshalFromData(t,this.selfAddress);this.targetAddress=n.targetAddress,this.obfuscationKey=n.obfuscationKey,this.encrypt=n.encrypt,this.forks=n.forks;for(const e of this.forks.values())e.node.parent=this;this.loaded=!0}static unmarshalFromData(t,n){if(t.length<64)throw new Error("MantarayNode#unmarshalFromData data too short");const r=t.subarray(0,32),o=Fn(t.subarray(32),r),i=new cn(o);if(!ht(i.read(31),Gn.slice(0,31)))throw new Error("MantarayNode#unmarshalFromData invalid version hash");const s=Tt(i.read(1)),a=i.read(s),c=new e({selfAddress:n,targetAddress:a,obfuscationKey:r,encrypt:64===s||64===n?.length});c.persisted=!0;const u=i.read(32),l=0===s?32:s;for(let e=0;e<256;e++)if(Zn(u,e)){const t=Kn.unmarshal(i,l);c.forks.set(e,t),t.node.parent=c,t.node.persisted=!0,t.node.loaded=!1}return c}addFork(t,n,r){this.selfAddress=null,this.type=null,t=t instanceof Uint8Array?t:Nn.encode(t);let o=this;for(;t.length;){const i=t.slice(0,30),s=0===(t=t.slice(30)).length,[a,c]=o.findClosest(i),u=i.slice(c.length);if(c.length&&(o=a),!u.length){s&&(o.assertSubtreeLoaded(),o.targetAddress=new nn(n).toUint8Array(),o.metadata=r??null,o.invalidate());continue}const l=new Kn(u,new e({targetAddress:s?new nn(n).toUint8Array():void 0,metadata:s?r:void 0,path:u,encrypt:this.encrypt}));o.assertSubtreeLoaded();const f=a.forks.get(u[0]);if(f){const e=Kn.split(l,f);o.forks.set(u[0],e),e.node.parent=o}else o.forks.set(u[0],l),l.node.parent=o;o.invalidate(),o=l.node}}relocate(e){this.path=e,this.loaded?this.type=null:null!==this.type&&(this.type=-9&this.type|(Ln(e)?8:0))}assertSubtreeLoaded(){if(!this.loaded)throw new Error(`MantarayNode: forks of "${this.fullPathString}" are not loaded - load the subtree before editing it`)}invalidate(){let e=this;for(;e;)e.selfAddress=null,e.type=null,e.persisted=!1,e=e.parent}removeFork(e){if(this.selfAddress=null,this.type=null,0===(e=e instanceof Uint8Array?e:Nn.encode(e)).length)throw new Error("MantarayNode#removeFork path cannot be empty");const t=this.find(e);if(!t)throw new Error("MantarayNode#removeFork fork not found");t.assertSubtreeLoaded();const[n,r]=this.findClosest(e.slice(0,e.length-1)),o=e.slice(r.length)[0],i=t.onlyChildFittingOneFork();i?(n.forks.delete(o),n.adopt(i,Pt.concat(t.path,i.prefix))):0===t.forks.size?n.forks.delete(o):t.clearEntry(),t.invalidate(),n.invalidate()}onlyChildFittingOneFork(){if(1!==this.forks.size)return;const e=[...this.forks.values()][0];return Pt.concat(this.path,e.prefix).length<=30?e:void 0}adopt(e,t){e.prefix=t,e.node.relocate(t),e.node.parent=this,this.forks.set(t[0],e)}clearEntry(){this.targetAddress=new Uint8Array(this.targetAddress.length),this.metadata=null}async calculateSelfAddress(){if(this.selfAddress)return new nn(this.selfAddress);if(this.encrypt)throw new Error("MantarayNode#calculateSelfAddress is not supported for encrypted nodes - use saveRecursively");return(await An.root(await this.marshal())).hash()}async saveRecursively(e){for(const r of this.forks.values())r.node.persisted||await r.node.saveRecursively(e);const t=new An((async t=>{for(const{chunk:n,key:r}of t)await e(n,r);return[]}),void 0,this.encrypt);await t.append(await this.marshal());const n=await t.finalize();if(this.encrypt){const{address:t,key:r}=n.encryptedHash();return await e(n,r),this.selfAddress=Pt.concat(t.toUint8Array(),r),this.persisted=!0,{reference:this.selfAddress,rootChunk:n,encryptionKey:r}}return await e(n),this.selfAddress=n.hash().toUint8Array(),this.persisted=!0,{reference:this.selfAddress,rootChunk:n}}find(e){const t=e instanceof Uint8Array?e:Nn.encode(e),[n,r]=this.findClosest(t);return r.length===t.length?n:null}findClosest(e,t=new Uint8Array){if(0===(e=e instanceof Uint8Array?e:Nn.encode(e)).length)return[this,t];const n=this.forks.get(e[0]);return n&&dt(n.prefix,e).length===n.prefix.length?n.node.findClosest(e.slice(n.prefix.length),Pt.concat(t,n.prefix)):[this,t]}collect(e=[]){for(const t of this.forks.values())ht(t.node.targetAddress,new Uint8Array(t.node.targetAddress.length))||e.push(t.node),t.node.collect(e);return e}collectAndMap(){const e={};for(const t of this.collect())e[t.fullPathString]=new nn(t.targetAddress).toHex();return e}determineType(){let e=0;const t=new Uint8Array(this.targetAddress.length);return ht(this.targetAddress,t)&&0!==this.forks.size||(e|=2),this.forks.size>0&&(e|=4),Ln(this.path)&&(e|=8),this.metadata&&(e|=16),e}},Hn=new TextEncoder,Wn=new TextDecoder;var Kn=class e{prefix;node;constructor(e,t){this.prefix=e,this.node=t}static split(t,n){const r=dt(t.prefix,n.prefix);if(r.length===t.prefix.length){const e=n.prefix.slice(r.length);return n.node.relocate(n.prefix.slice(r.length)),n.prefix=n.prefix.slice(r.length),n.node.parent=t.node,t.node.forks.set(e[0],n),t}if(r.length===n.prefix.length){const e=t.prefix.slice(r.length);return t.node.relocate(t.prefix.slice(r.length)),t.prefix=t.prefix.slice(r.length),t.node.parent=n.node,n.node.forks.set(e[0],t),n}const o=new qn({path:r,encrypt:t.node.encrypt}),i=new e(t.prefix.slice(r.length),t.node),s=new e(n.prefix.slice(r.length),n.node);return t.node.relocate(t.prefix.slice(r.length)),n.node.relocate(n.prefix.slice(r.length)),t.prefix=t.prefix.slice(r.length),n.prefix=n.prefix.slice(r.length),o.forks.set(i.prefix[0],i),o.forks.set(s.prefix[0],s),i.node.parent=o,s.node.parent=o,new e(r,o)}marshal(){if(!this.node.selfAddress)throw new Error("Fork#marshal node.selfAddress is not set");const e=[];if(e.push(new Uint8Array([this.node.type??this.node.determineType()])),e.push(xt(this.prefix.length)),e.push(this.prefix),this.prefix.length<30&&e.push(new Uint8Array(30-this.prefix.length)),e.push(this.node.selfAddress),this.node.metadata){const t=function(e,t,n){const r=e.length%t;if(0===r)return e;const o=new Uint8Array(e.length+t-r).fill(n);return o.set(e,0),o}(Pt.concat(new Uint8Array([0,0]),Hn.encode(JSON.stringify(this.node.metadata))),32,10);t.set(function(e,t){const n=new ArrayBuffer(2);return new DataView(n).setUint16(0,e,"LE"===t),new Uint8Array(n)}(t.length-2,"BE"),0),e.push(t)}return Pt.concat(...e)}static unmarshal(t,n){const r=Tt(t.read(1)),o=Tt(t.read(1)),i=t.read(o);o<30&&t.read(30-o);const s=t.read(n);let a;if(function(e,t){return(e&t)===t}(r,16)){const e=Rt(t.read(2),"BE");if(e>t.max())throw new Error("Fork#unmarshal not enough bytes for metadata");a=JSON.parse(Wn.decode(t.read(e)))}return new e(i,new qn({selfAddress:s,metadata:a,path:i,type:r,encrypt:64===n}))}};function Jn(e,t,n){return e/Math.pow(2,t-n)}function Xn(e){return 4096*2**e}var Yn=.9;function Qn(e){const t=e.match(/^([\d.]+)\s*(B|kB|MB|GB|TB|PB)$/);if(!t)throw new Error(`Invalid size format: ${e}`);return Math.ceil(parseFloat(t[1])*{B:1,kB:1e3,MB:1e6,GB:1e3**3,TB:1e3**4,PB:1e3**5}[t[2]])}var er=[[17,"0.00004089 GB"],[18,"0.00609 GB"],[19,"0.10249 GB"],[20,"0.62891 GB"],[21,"2.38 GB"],[22,"7.07 GB"],[23,"18.24 GB"],[24,"43.04 GB"],[25,"96.5 GB"],[26,"208.52 GB"],[27,"435.98 GB"],[28,"908.81 GB"],[29,"1870 GB"],[30,"3810 GB"],[31,"7730 GB"],[32,"15610 GB"],[33,"31430 GB"],[34,"63150 GB"]],tr=[[[17,"44.70 kB"],[18,"6.66 MB"],[19,"112.06 MB"],[20,"687.62 MB"],[21,"2.60 GB"],[22,"7.73 GB"],[23,"19.94 GB"],[24,"47.06 GB"],[25,"105.51 GB"],[26,"227.98 GB"],[27,"476.68 GB"],[28,"993.65 GB"],[29,"2.04 TB"],[30,"4.17 TB"],[31,"8.45 TB"],[32,"17.07 TB"],[33,"34.36 TB"],[34,"69.04 TB"],[35,"138.54 TB"],[36,"277.72 TB"],[37,"556.35 TB"],[38,"1.11 PB"],[39,"2.23 PB"],[40,"4.46 PB"],[41,"8.93 PB"]],[[17,"41.56 kB"],[18,"6.19 MB"],[19,"104.18 MB"],[20,"639.27 MB"],[21,"2.41 GB"],[22,"7.18 GB"],[23,"18.54 GB"],[24,"43.75 GB"],[25,"98.09 GB"],[26,"211.95 GB"],[27,"443.16 GB"],[28,"923.78 GB"],[29,"1.90 TB"],[30,"3.88 TB"],[31,"7.86 TB"],[32,"15.87 TB"],[33,"31.94 TB"],[34,"64.19 TB"],[35,"128.80 TB"],[36,"258.19 TB"],[37,"517.23 TB"],[38,"1.04 PB"],[39,"2.07 PB"],[40,"4.15 PB"],[41,"8.30 PB"]],[[17,"37.37 kB"],[18,"5.57 MB"],[19,"93.68 MB"],[20,"574.81 MB"],[21,"2.17 GB"],[22,"6.46 GB"],[23,"16.67 GB"],[24,"39.34 GB"],[25,"88.20 GB"],[26,"190.58 GB"],[27,"398.47 GB"],[28,"830.63 GB"],[29,"1.71 TB"],[30,"3.49 TB"],[31,"7.07 TB"],[32,"14.27 TB"],[33,"28.72 TB"],[34,"57.71 TB"],[35,"115.81 TB"],[36,"232.16 TB"],[37,"465.07 TB"],[38,"931.23 TB"],[39,"1.86 PB"],[40,"3.73 PB"],[41,"7.46 PB"]],[[17,"33.88 kB"],[18,"5.05 MB"],[19,"84.92 MB"],[20,"521.09 MB"],[21,"1.97 GB"],[22,"5.86 GB"],[23,"15.11 GB"],[24,"35.66 GB"],[25,"79.96 GB"],[26,"172.77 GB"],[27,"361.23 GB"],[28,"753.00 GB"],[29,"1.55 TB"],[30,"3.16 TB"],[31,"6.41 TB"],[32,"12.93 TB"],[33,"26.04 TB"],[34,"52.32 TB"],[35,"104.99 TB"],[36,"210.46 TB"],[37,"421.61 TB"],[38,"844.20 TB"],[39,"1.69 PB"],[40,"3.38 PB"],[41,"6.77 PB"]],[[17,"13.27 kB"],[18,"1.98 MB"],[19,"33.27 MB"],[20,"204.14 MB"],[21,"771.13 MB"],[22,"2.29 GB"],[23,"5.92 GB"],[24,"13.97 GB"],[25,"31.32 GB"],[26,"67.68 GB"],[27,"141.51 GB"],[28,"294.99 GB"],[29,"606.90 GB"],[30,"1.24 TB"],[31,"2.51 TB"],[32,"5.07 TB"],[33,"10.20 TB"],[34,"20.50 TB"],[35,"41.13 TB"],[36,"82.45 TB"],[37,"165.17 TB"],[38,"330.72 TB"],[39,"661.97 TB"],[40,"1.32 PB"],[41,"2.65 PB"]]],nr=[[[17,"44.35 kB"],[18,"6.61 MB"],[19,"111.18 MB"],[20,"682.21 MB"],[21,"2.58 GB"],[22,"7.67 GB"],[23,"19.78 GB"],[24,"46.69 GB"],[25,"104.68 GB"],[26,"226.19 GB"],[27,"472.93 GB"],[28,"985.83 GB"],[29,"2.03 TB"],[30,"4.14 TB"],[31,"8.39 TB"],[32,"16.93 TB"],[33,"34.09 TB"],[34,"68.50 TB"],[35,"137.45 TB"],[36,"275.53 TB"],[37,"551.97 TB"],[38,"1.11 PB"],[39,"2.21 PB"],[40,"4.43 PB"],[41,"8.86 PB"]],[[17,"40.89 kB"],[18,"6.09 MB"],[19,"102.49 MB"],[20,"628.91 MB"],[21,"2.38 GB"],[22,"7.07 GB"],[23,"18.24 GB"],[24,"43.04 GB"],[25,"96.50 GB"],[26,"208.52 GB"],[27,"435.98 GB"],[28,"908.81 GB"],[29,"1.87 TB"],[30,"3.81 TB"],[31,"7.73 TB"],[32,"15.61 TB"],[33,"31.43 TB"],[34,"63.15 TB"],[35,"126.71 TB"],[36,"254.01 TB"],[37,"508.85 TB"],[38,"1.02 PB"],[39,"2.04 PB"],[40,"4.08 PB"],[41,"8.17 PB"]],[[17,"36.73 kB"],[18,"5.47 MB"],[19,"92.07 MB"],[20,"564.95 MB"],[21,"2.13 GB"],[22,"6.35 GB"],[23,"16.38 GB"],[24,"38.66 GB"],[25,"86.69 GB"],[26,"187.31 GB"],[27,"391.64 GB"],[28,"816.39 GB"],[29,"1.68 TB"],[30,"3.43 TB"],[31,"6.94 TB"],[32,"14.02 TB"],[33,"28.23 TB"],[34,"56.72 TB"],[35,"113.82 TB"],[36,"228.18 TB"],[37,"457.10 TB"],[38,"915.26 TB"],[39,"1.83 PB"],[40,"3.67 PB"],[41,"7.34 PB"]],[[17,"33.26 kB"],[18,"4.96 MB"],[19,"83.38 MB"],[20,"511.65 MB"],[21,"1.93 GB"],[22,"5.75 GB"],[23,"14.84 GB"],[24,"35.02 GB"],[25,"78.51 GB"],[26,"169.64 GB"],[27,"354.69 GB"],[28,"739.37 GB"],[29,"1.52 TB"],[30,"3.10 TB"],[31,"6.29 TB"],[32,"12.70 TB"],[33,"25.57 TB"],[34,"51.37 TB"],[35,"103.08 TB"],[36,"206.65 TB"],[37,"413.98 TB"],[38,"828.91 TB"],[39,"1.66 PB"],[40,"3.32 PB"],[41,"6.64 PB"]],[[17,"13.17 kB"],[18,"1.96 MB"],[19,"33.01 MB"],[20,"202.53 MB"],[21,"765.05 MB"],[22,"2.28 GB"],[23,"5.87 GB"],[24,"13.86 GB"],[25,"31.08 GB"],[26,"67.15 GB"],[27,"140.40 GB"],[28,"292.67 GB"],[29,"602.12 GB"],[30,"1.23 TB"],[31,"2.49 TB"],[32,"5.03 TB"],[33,"10.12 TB"],[34,"20.34 TB"],[35,"40.80 TB"],[36,"81.80 TB"],[37,"163.87 TB"],[38,"328.11 TB"],[39,"656.76 TB"],[40,"1.31 PB"],[41,"2.63 PB"]]];function rr(e,t,n){if(e<17)return 0;if(void 0!==t&&void 0!==n){const r=(t?nr:tr)[n],o=r?.find((([t])=>t===e));if(o)return Qn(o[1])}else{const t=er.find((([t])=>t===e));if(t)return Qn(t[1])}return Math.ceil(Xn(e)*Yn)}function or(e,t){const n=new Map;for(let r=17;r<35;r++)n.set(r,rr(r,e,t));return n}function ir(e){return function(e,t,n,r){if(65!==e.length)throw new Error("invalid signature length");if(32!==t.length)throw new Error("invalid batch ID length");if(8!==n.length)throw new Error("invalid timestamp length");if(8!==r.length)throw new Error("invalid index length");return new Pt(Pt.concat(t,r,n,e))}(e.signature.toUint8Array(),e.batchId.toUint8Array(),e.timestamp,e.index)}var sr=class e{signer;batchId;buckets;depth;maxSlot;constructor(e,t,n,r){if(!Number.isInteger(r)||r<=16)throw new Error(`Stamper#constructor depth must be an integer above 16, got ${r}`);this.signer=e,this.batchId=t,this.buckets=n,this.depth=r,this.maxSlot=2**(r-16)}static fromBlank(t,n,r){return new e(new en(t),new Ct(n),new Uint32Array(65536),r)}static fromState(t,n,r,o){return new e(new en(t),new Ct(n),r,o)}stamp(e,t){const n=Rt(e,"BE"),r=this.buckets[n];if(r>=this.maxSlot)throw new Error("Stamper#stamp bucket is full");return this.buckets[n]=r+1,function(e,t,n,r,o=Date.now()){const i=new en(e),s=new Ct(t),a=Rt(n,"BE"),c=Pt.concat(Ot(a,"BE"),Ot(r,"BE")),u=At(1000000n*BigInt(o),"BE"),l=i.sign(Pt.concat(n,s.toUint8Array(),c,u));return{batchId:s,index:c,issuer:i.publicKey().address(),signature:l,timestamp:u}}(this.signer,this.batchId,e,r,t)}getState(){return this.buckets}},ar=n(20);function cr(e){const t=Object.values(e).filter((e=>"number"==typeof e));return Object.entries(e).filter((([e,n])=>-1===t.indexOf(+e))).map((([e,t])=>t))}function ur(e,t="|"){return e.map((e=>Sr(e))).join(t)}function lr(e,t){return"bigint"==typeof t?t.toString():t}class fr{constructor(e){this._getter=e,this._value=void 0}get value(){const e=this._getter;return void 0!==e&&(this._value=e(),this._getter=void 0),this._value}}function hr(e){return new fr(e)}function dr(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function pr(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function mr(e){const t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function gr(e){return mr(e._zod.def)??e._zod.def.shape}function yr(e,t,n){Object.defineProperty(e,t,{get(){const e=n();return pr(this,t,e),e},enumerable:!0,configurable:!0})}function wr(e,t,n){t in e?pr(e,t,n):e[t]=n}function br(e,t,n,r){const o=gr(t);for(const i of n){const n=Object.getOwnPropertyDescriptor(o,i);n.enumerable&&(n.get?yr(e,i,(()=>{const e=t._zod.def.shape[i];return r?r(e,i):e})):wr(e,i,r?r(n.value,i):n.value))}}function vr(...e){const t={};for(const n of e){const e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}const Br="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Er(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}const xr=hr((()=>{if(uo.jitless)return!1;if("undefined"!=typeof navigator&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}}));function Tr(e){if(!1===Er(e))return!1;const t=e.constructor;if(void 0===t)return!0;if("function"!=typeof t)return!0;const n=t.prototype;return!1!==Er(n)&&!1!==Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")}function Rr(e){return Tr(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const Or=new Set(["string","number","symbol"]);function Ar(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function zr(e,t,n){const r=new e._zod.constr(t??e._zod.def);return t&&!n?.parent||(r._zod.parent=e),r}function kr(e){const t=e;if(!t)return{};if("string"==typeof t)return{error:()=>t};if(void 0!==t?.message){if(void 0!==t?.error)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,"string"==typeof t.error?{...t,error:()=>t.error}:t}function Sr(e){return"bigint"==typeof e?e.toString()+"n":"string"==typeof e?`"${e}"`:`${e}`}const $r=(()=>({safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]}))(),_r={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function Ir(e,t){const n=gr(e),r=[];for(const o of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,o)?.enumerable)throw new Error(`Unrecognized key: "${String(o)}"`);t[o]&&r.push(o)}return r}function Dr(e,t){const n={};return br(n,e,Reflect.ownKeys(gr(e))),function(e,t){for(const n of Reflect.ownKeys(t)){const r=Object.getOwnPropertyDescriptor(t,n);r.enumerable&&(r.get?yr(e,n,(()=>t[n])):wr(e,n,r.value))}}(n,t),n}function Vr(e,t,n,r="partial"){const o=t._zod.def.checks;if(o&&o.length>0)throw new Error(`.${r}() cannot be used on object schemas containing refinements`);const i=n?new Set(Ir(t,n)):void 0,s={};return br(s,t,Reflect.ownKeys(gr(t)),e&&((t,n)=>i&&!i.has(n)?t:new e({type:"optional",innerType:t}))),zr(t,vr(t._zod.def,{shape:s,checks:[]}))}function Pr(e,t=0){if(!0===e.aborted)return!0;for(let n=t;n<e.issues.length;n++)if(!0!==e.issues[n]?.continue)return!0;return!1}function Cr(e,t=0){if(!0===e.aborted)return!0;for(let n=t;n<e.issues.length;n++)if(!1===e.issues[n]?.continue)return!0;return!1}function Fr(e,t){return t.map((t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t}))}function Nr(e){return"string"==typeof e?e:e?.message}function Mr(e){const t=[];for(const n of e??[]){const e=n._zod.def;if(!/_(length|size)$|_equals$/.test(e.check))break;const r=e.maximum??e.length??e.size;r>=0&&t.push([r,n])}return t}function Ur(e,t,n){var r;for(let o=t;o<e.length;o++)(r=e[o]).schema??(r.schema=n)}function Gr(e,t,n){var r;const o=e.inst?._zod?.traits;o?.has("$ZodType")&&(o.has("$ZodCheck")?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);const i=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,s=e.message?e.message:Nr(e.inst?._zod.def?.error?.(e))??Nr(i?.(e))??Nr(t?.error?.(e))??Nr(n.customError?.(e))??Nr(n.localeError?.(e))??"Invalid input",a={};for(const c of Object.keys(e))"inst"!==c&&"schema"!==c&&"continue"!==c&&"input"!==c&&"__proto__"!==c&&(a[c]=e[c]);return a.path??(a.path=[]),a.message=s,t?.reportInput&&(a.input=e.input),a}const Lr=/[\uD800-\uDBFF]/;function jr(e){const t=e.length;if(!Lr.test(e))return t;let n=t;for(let r=0;r<t-1;r++)55296==(64512&e.charCodeAt(r))&&56320==(64512&e.charCodeAt(r+1))&&(n--,r++);return n}function Zr(e){return Array.isArray(e)?"array":"string"==typeof e?"string":"unknown"}function qr(...e){const[t,n,r]=e;return"string"==typeof t?{message:t,code:"custom",input:n,inst:r}:{...t}}function Hr(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function Wr(e,t,n){return Hr(e,t,n,!1)}function Kr(e,t){for(const n in e){const r=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return Hr(this,n,r(this))},set(e){Hr(this,n,e)}})}return t}function Jr(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return null==this?n:Hr(this,t,n.bind(this))},set(e){Hr(this,t,e)}})}let Xr,Yr=!1;const Qr={configurable:!0,get(){Yr=!0}};function eo(e,t,n){const r=Object.getPrototypeOf(e._zod);t in r&&Xr!==e._zod?Xr=void 0:(Xr=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,Qr);const e=Yr;Yr=!1;try{const r=n(this);return Yr?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r}),Yr=Yr||e,r}catch(r){throw delete this[t],Yr=Yr||e,r}},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}}))}function to(e,t,n,r){const o=function(e,t){const n=Object.getPrototypeOf(e);return t in n?void 0:n}(e,t);o&&Object.defineProperty(o,t,{configurable:!0,get(){const e={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,e),e.value=n(this),Object.defineProperty(this,t,e),e.value},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:e})}})}function no(e){const t=()=>e;return t["~constantCatch"]=!0,t}var ro;const oo={value:void 0,enumerable:!1};let io="captureStackTrace"in Error?Error:null;function so(e,t,n,r){function o(e){this.def=e,this.constr=l,this.traits=new Set}o.prototype={};const i=n,s=i&&new WeakSet;function a(n,r){if(n._zod){if(n._zod.traits.has(e))return}else{oo.value=new o(r);try{Object.defineProperty(n,"_zod",oo)}finally{oo.value=void 0}}if(n._zod.traits.add(e),t(n,r),s){const e=Object.getPrototypeOf(n),t=n._zod.constr.prototype;let r=e;for(;r&&r!==t;)r=Object.getPrototypeOf(r);const o=r??e;s.has(o)||(s.add(o),function(e,t){for(const n in t){const r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):Jr(e,n,r.value)}}(o,i))}const a=l.prototype;for(const e in a)Object.prototype.hasOwnProperty.call(a,e)&&(e in n||(n[e]=a[e].bind(n)))}const c=r?.Parent??Object;class u extends c{}function l(e){const t=r?.Parent?function(e){const t=io;if(t){const n=t.stackTraceLimit;if("number"==typeof n){try{t.stackTraceLimit=0}catch{return io=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}(u):this;a(t,e);const n=t._zod.deferred;if(n){for(const e of n)e();t._zod.deferred=void 0}const o=globalThis.__zod_globalConfig?.postProcessor;return o&&o(t),t}return Object.defineProperty(u,"name",{value:e}),Object.defineProperty(l,"init",{value:a}),Object.defineProperty(l,Symbol.hasInstance,{value:t=>!!(r?.Parent&&t instanceof r.Parent)||t?._zod?.traits?.has(e)}),Object.defineProperty(l,"name",{value:e}),l}class ao extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class co extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}}(ro=globalThis).__zod_globalConfig??(ro.__zod_globalConfig={});const uo=globalThis.__zod_globalConfig;function lo(e){return e&&Object.assign(uo,e),uo}class fo extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform"),this.name="ZodCyclicError"}}const ho="~memo",po=[];function mo(e){return null!==e&&"object"==typeof e}function go(e){return e.map((e=>e.path?{...e,path:e.path.slice()}:{...e}))}const yo=new WeakMap;function wo(e,t,n){const r=yo.get(e);if(void 0!==r)return r?2:0;if(t.has(e))return 2;t.add(e);let o=0;const i=e=>{if(2!==o&&e?._zod){const r=wo(e,t,n);r>o&&(o=r)}},s=e=>{e>o&&(o=e)},a=e._zod.def,c=a.type;switch(c){case"object":{const e=mr(a);s(e?((e,r)=>{let o=0;for(const i of Reflect.ownKeys(e)){const s=Object.getOwnPropertyDescriptor(e,i);if(r&&!s.enumerable)continue;const a=s.get?1:s.value?._zod?wo(s.value,t,n):0;a>o&&(o=a)}return o})(e,!0):1),i(a.catchall);break}case"array":i(a.element);break;case"tuple":for(const e of a.items)i(e);i(a.rest);break;case"record":case"map":i(a.keyType),i(a.valueType);break;case"set":i(a.valueType);break;case"union":for(const e of a.options)i(e);break;case"intersection":i(a.left),i(a.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":i(a.innerType);break;case"pipe":i(a.in),i(a.out);break;case"function":i(a.input),i(a.output);break;case"lazy":{const r=a._cachedInner??(n?e._zod.innerType:void 0);s(r?wo(r,t,!1):1);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(const e in a){const t=Object.getOwnPropertyDescriptor(a,e);if(!t||t.get)continue;const n=t.value;if(n&&"object"==typeof n)if(n._zod)i(n);else if(Array.isArray(n))for(const e of n)i(e)}}return t.delete(e),function(e,t){1!==t&&yo.set(e,2===t);return t}(e,o)}let bo;const vo=[],Bo={alloc(e,t,n){const r=bo;if(!r)return n;bo=void 0;const o={value:n,issues:null};return r.set(t.value,o),vo.push(o),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push((()=>{const t=e._zod.parse,n=(e,n)=>{if("backward"!==n.direction&&function(e,t){const n=e[ho]?.backEdges;return void 0!==n&&mo(t)&&n.has(t)}(n,e.value))throw new fo;return t(e,n)};e._zod.parse=n,e._zod.run===t&&(e._zod.run=n)}))},attach(e){var t;let n,r,o,i=!1;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push((()=>{const t=e._zod.parse,s=(a,c)=>{if(void 0===n){const r=wo(e,new Set,!1);if(0===r)return e._zod.parse=t,e._zod.run===s&&(e._zod.run=t),t(a,c);2===r||i?n=!0:i=!0}const u=a.value;if(!mo(u))return t(a,c);let l,f=c[ho];f||(f={buckets:new WeakMap,backEdges:void 0},c[ho]=f),r===c?l=o:(l=function(e,t){let n=e.buckets.get(t);return n||(n=new WeakMap,e.buckets.set(t,n)),n}(f,e),r=c,o=l);const h=l.get(u);if(h)return a.value=h.value,h.issues?h.issues.length&&a.issues.push(...go(h.issues)):(a.memo=!0,f.backEdges??(f.backEdges=new WeakSet),f.backEdges.add(h.value)),a;bo=l;const d=vo.length,p=t(a,c);bo=void 0;const m=vo.length>d?vo.pop():void 0;return p instanceof Promise?p.then((e=>(m&&(m.issues=e.issues.length?go(e.issues):po),e))):(m&&(m.issues=p.issues.length?go(p.issues):po),p)};e._zod.parse=s,e._zod.run===t&&(e._zod.run=s)}))}};const Eo=/^[cC][0-9a-z]{6,}$/,xo=/^[0-9a-z]+$/,To=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,Ro=/^[0-9a-vA-V]{20}$/,Oo=/^[A-Za-z0-9]{27}$/,Ao=/^[a-zA-Z0-9_-]{21}$/;const zo=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,ko=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,So=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,$o=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;const _o=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Io=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,Do=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Vo=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Po=/^https?$/,Co=/^\+[1-9]\d{6,14}$/,Fo="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))";function No(e){return new RegExp(`^${e}$`)}const Mo=No(Fo);function Uo(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return"number"==typeof e.precision?-1===e.precision?`${t}`:0===e.precision?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}const Go=/^[\s\S]{0,}$/,Lo=/^-?\d+n?$/,jo=/^-?\d+$/,Zo=/^-?\d+(?:\.\d+)?$/,qo=/^(?:true|false)$/i,Ho=/^[^A-Z]*$/,Wo=/^[^a-z]*$/;const Ko=so("$ZodCheck",((e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])})),Jo=e=>{const t=e.value;return!(n=t,null==n||void 0===t.length);var n},Xo={number:"number",bigint:"bigint",object:"date"},Yo=so("$ZodCheckLessThan",((e,t)=>{Ko.init(e,t);const n=Xo[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:Xo[typeof r.value]??n,code:"too_big",maximum:"object"==typeof t.value?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}})),Qo=so("$ZodCheckGreaterThan",((e,t)=>{Ko.init(e,t);const n=Xo[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:Xo[typeof r.value]??n,code:"too_small",minimum:"object"==typeof t.value?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}})),ei=so("$ZodCheckMultipleOf",((e,t)=>{Ko.init(e,t),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");("bigint"==typeof n.value?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):0===function(e,t){const n=e/t,r=Math.round(n),o=4*Number.EPSILON*Math.max(Math.abs(n),1);return Math.abs(n-r)<o?0:n-r}(n.value,t.value))||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}})),ti=so("$ZodCheckNumberFormat",((e,t)=>{Ko.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),r=n?"int":"number",[o,i]=$r[t.format];e._zod.check=s=>{const a=s.value;if(n){if(!Number.isInteger(a))return void s.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});if(!Number.isSafeInteger(a))return void(a>0?s.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort}):s.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort}))}a<o&&s.issues.push({origin:"number",input:a,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),a>i&&s.issues.push({origin:"number",input:a,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}})),ni=so("$ZodCheckMaxLength",((e,t)=>{var n;Ko.init(e,t),(n=e._zod.def).when??(n.when=Jo),e._zod.check=n=>{const r=n.value,o=r.length;if(("string"==typeof r&&o>t.maximum?jr(r):o)<=t.maximum)return;const i=Zr(r);n.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}})),ri=so("$ZodCheckMinLength",((e,t)=>{var n;Ko.init(e,t),(n=e._zod.def).when??(n.when=Jo),e._zod.check=n=>{const r=n.value,o=r.length;if(("string"==typeof r&&o>=t.minimum&&o<2*t.minimum?jr(r):o)>=t.minimum)return;const i=Zr(r);n.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}})),oi=so("$ZodCheckLengthEquals",((e,t)=>{var n;Ko.init(e,t),(n=e._zod.def).when??(n.when=Jo),e._zod.check=n=>{const r=n.value,o=r.length,i="string"==typeof r&&o>=t.length&&o<=2*t.length?jr(r):o;if(i===t.length)return;const s=Zr(r),a=i>t.length;n.issues.push({origin:s,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}})),ii=so("$ZodCheckStringFormat",((e,t)=>{var n,r;Ko.init(e,t),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:"string",code:"invalid_format",format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})})),si=so("$ZodCheckRegex",((e,t)=>{ii.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}})),ai=so("$ZodCheckLowerCase",((e,t)=>{t.pattern??(t.pattern=Ho),ii.init(e,t)})),ci=so("$ZodCheckUpperCase",((e,t)=>{t.pattern??(t.pattern=Wo),ii.init(e,t)})),ui=so("$ZodCheckIncludes",((e,t)=>{Ko.init(e,t);const n=Ar(t.includes),r=new RegExp("number"==typeof t.position?`^.{${t.position},}${n}`:n);t.pattern=r,e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:n.value,inst:e,continue:!t.abort})}})),li=so("$ZodCheckStartsWith",((e,t)=>{Ko.init(e,t);const n=new RegExp(`^${Ar(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}})),fi=so("$ZodCheckEndsWith",((e,t)=>{Ko.init(e,t);const n=new RegExp(`.*${Ar(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}));const hi=so("$ZodCheckOverwrite",((e,t)=>{Ko.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}));class di{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{this.indent-=1}}write(e){if("function"==typeof e)return e(this,{execution:"sync"}),void e(this,{execution:"async"});const t=e.split("\n").filter((e=>e)),n=Math.min(...t.map((e=>e.length-e.trimStart().length))),r=t.map((e=>e.slice(n))).map((e=>" ".repeat(2*this.indent)+e));for(const o of r)this.content.push(o)}compile(){const e=Function,t=this?.content??[""];return new e(...Object.keys(this.closed),`return function (${this.args.join(", ")}) {\n${t.join("\n")}\n};`)(...Object.values(this.closed))}}const pi={get:function(){const e=this._zod;return e.message??(e.message=JSON.stringify(e.def,lr,2)),e.message},set:function(e){this._zod.message=e},enumerable:!0,configurable:!0},mi={value:void 0,enumerable:!1},gi=new WeakSet([Object.prototype,Error.prototype]),yi=(e,t)=>{e.name="$ZodError",mi.value=t,Object.defineProperty(e,"issues",mi),mi.value=void 0,Object.defineProperty(e,"message",pi);const n=Object.getPrototypeOf(e);gi.has(n)||(gi.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){const e=()=>this.message;return Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0})}}))},wi=so("$ZodError",yi),bi=so("$ZodError",yi,void 0,{Parent:Error});function vi(e,t){return{callee:t?.callee??e,Err:t?.Err}}const Bi=e=>{const t=(n,r,o,i)=>{const s=o?{...o,async:!1}:{async:!1},a=n._zod.run({value:r,issues:[]},s);if(a instanceof Promise)throw new ao;if(a.issues.length){const n=new(i?.Err??e)(a.issues.map((e=>Gr(e,s,lo()))));throw Br(n,i?.callee??t),n}return a.value};return t},Ei=Bi(bi),xi=e=>{const t=async(n,r,o,i)=>{const s=o?{...o,async:!0}:{async:!0};let a=n._zod.run({value:r,issues:[]},s);if(a instanceof Promise&&(a=await a),a.issues.length){const n=new(i?.Err??e)(a.issues.map((e=>Gr(e,s,lo()))));throw Br(n,i?.callee??t),n}return a.value};return t},Ti=xi(bi),Ri=e=>(t,n,r)=>{const o=r?{...r,async:!1}:{async:!1},i=t._zod.run({value:n,issues:[]},o);if(i instanceof Promise)throw new ao;return i.issues.length?Oi(e,i.issues,o):{success:!0,data:i.value}};function Oi(e,t,n){let r;return{success:!1,get error(){return r||(r=new e(t.map((e=>Gr(e,n,lo())))),t=void 0,n=void 0),r},set error(e){r=e,t=void 0,n=void 0}}}const Ai=e=>async(t,n,r)=>{const o=r?{...r,async:!0}:{async:!0};let i=t._zod.run({value:n,issues:[]},o);return i instanceof Promise&&(i=await i),i.issues.length?Oi(e,i.issues,o):{success:!0,data:i.value}},zi=Symbol.for("zod.compile.invalid"),ki=Symbol.for("zod.compile.fallback"),Si=(e,t,n)=>{const r=e._zod.bag.validator;if(void 0!==r){if(r(t)!==zi)return!0;if(!0===r.definite&&void 0===n)return!1}return function(e,t,n){const r=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},o=e._zod.bag.fallbackRun;let i;o?(r[ki]=!0,i=o({value:t,issues:[]},r)):i=e._zod.run({value:t,issues:[]},r);if(i instanceof Promise)throw new ao;return 0===i.issues.length}(e,t,n)};const $i=e=>{const t=Bi(e),n=(e,r,o,i)=>{const s=o?{...o,direction:"backward"}:{direction:"backward"};return t(e,r,s,vi(n,i))};return n},_i=e=>{const t=Bi(e),n=(e,r,o,i)=>t(e,r,o,vi(n,i));return n},Ii=e=>{const t=xi(e),n=async(e,r,o,i)=>{const s=o?{...o,direction:"backward"}:{direction:"backward"};return await t(e,r,s,vi(n,i))};return n},Di=e=>{const t=xi(e),n=async(e,r,o,i)=>await t(e,r,o,vi(n,i));return n},Vi=e=>(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return Ri(e)(t,n,o)},Pi=e=>(t,n,r)=>Ri(e)(t,n,r),Ci=e=>async(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return Ai(e)(t,n,o)},Fi=e=>async(t,n,r)=>Ai(e)(t,n,r),Ni={major:4,minor:6,patch:6};const Mi=so("$ZodType",((e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Ni;const r=e._zod.def.checks,o=e._zod.traits.has("$ZodCheck")?[e,...r??[]]:r?.length?[...r]:[];for(const i of o)for(const t of i._zod.onattach)t(e);if(0===o.length)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push((()=>{e._zod.run=e._zod.parse}));else{const t=(t,n,r)=>{if(t.memo)return t;let o,i=Pr(t);for(const s of n){if(s._zod.def.when){if(Cr(t))continue;if(!s._zod.def.when(t))continue}else if(i)continue;const n=t.issues.length,a=s._zod.check(t);if(a instanceof Promise&&!1===r?.async)throw new ao;if(o||a instanceof Promise)o=(o??Promise.resolve()).then((async()=>{await a;t.issues.length!==n&&(Ur(t.issues,n,e),i||(i=Pr(t,n)))}));else{if(t.issues.length===n)continue;Ur(t.issues,n,e),i||(i=Pr(t,n))}}return o?o.then((()=>t)):t},n=(n,r,i)=>{if(Pr(n))return n.aborted=!0,n;const s=t(r,o,i);if(s instanceof Promise){if(!1===i.async)throw new ao;return s.then((t=>e._zod.parse(t,i)))}return e._zod.parse(s,i)};e._zod.run=(r,i)=>{if(i.skipChecks)return e._zod.parse(r,i);if("backward"===i.direction){const t=e._zod.parse({value:r.value,issues:[]},{...i,skipChecks:!0});return t instanceof Promise?t.then((e=>n(e,r,i))):n(t,r,i)}const s=e._zod.parse(r,i);if(s instanceof Promise){if(!1===i.async)throw new ao;return s.then((e=>t(e,o,i)))}return t(s,o,i)}}}),{get"~standard"(){return Wr(this,"~standard",Gi(this))},set"~standard"(e){Hr(this,"~standard",e)}}),Ui=(e,t)=>e.issues.length?{issues:e.issues.map((e=>Gr(e,t,lo())))}:{value:e.value};function Gi(e){return{validate:t=>{const n={async:!1};try{const r=e._zod.run({value:t,issues:[]},n);if(!(r instanceof Promise))return Ui(r,n)}catch(r){}return async function(e,t){const n={async:!0};return Ui(await e._zod.run({value:t,issues:[]},n),n)}(e,t)},vendor:"zod",version:1}}const Li=so("$ZodString",((e,t)=>{Mi.init(e,t),e._zod.pattern=t.pattern??Go,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch(r){}return"string"==typeof n.value||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}})),ji=so("$ZodStringFormat",((e,t)=>{ii.init(e,t),Li.init(e,t)})),Zi=so("$ZodGUID",((e,t)=>{t.pattern??(t.pattern=ko),ji.init(e,t)})),qi=so("$ZodUUID",((e,t)=>{if(t.version){const e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(void 0===e)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=So(e))}else t.pattern??(t.pattern=So());ji.init(e,t)})),Hi=so("$ZodEmail",((e,t)=>{t.pattern??(t.pattern=$o),ji.init(e,t)}));function Wi(e){try{return"undefined"!=typeof URL&&"function"==typeof URL.canParse?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function Ki(e,t){return"normalize"in t||"hostname"in t||"protocol"in t?function(e,t){if(!t.normalize&&t.protocol?.source===Po.source&&!/^https?:\/\//i.test(e))return 1;try{if("undefined"!=typeof URL){const t=URL;if("function"==typeof t.parse)return t.parse(e)??2}return new URL(e)}catch{return 2}}(e,t):Wi(e)||2}const Ji=/[\t\n\r]/g;function Xi(e){return e.replace(Ji,"")}const Yi=so("$ZodURL",((e,t)=>{ji.init(e,t),e._zod.check=n=>{try{const r=n.value.trim(),o=Ki(r,t);return 1===o?void n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort}):2===o?void n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort}):!0===o?void(n.value=Xi(r)):(t.hostname&&!function(e,t){return t.lastIndex=0,t.test(e.hostname)}(o,t.hostname)&&n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort}),t.protocol&&!function(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}(o,t.protocol)&&n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort}),void(n.value=t.normalize?o.href:Xi(r)))}catch(r){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}})),Qi=so("$ZodEmoji",((e,t)=>{t.pattern??(t.pattern=new RegExp("^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$","u")),ji.init(e,t)})),es=so("$ZodNanoID",((e,t)=>{if(void 0!==t.length&&(!Number.isInteger(t.length)||t.length<1))throw new Error(`Invalid nanoid length: ${t.length}`);var n;t.pattern??(t.pattern=void 0===t.length?Ao:(n=t.length,new RegExp(`^[a-zA-Z0-9_-]{${n}}$`))),ji.init(e,t)})),ts=so("$ZodCUID",((e,t)=>{t.pattern??(t.pattern=Eo),ji.init(e,t)})),ns=so("$ZodCUID2",((e,t)=>{t.pattern??(t.pattern=xo),ji.init(e,t)})),rs=so("$ZodULID",((e,t)=>{t.pattern??(t.pattern=To),ji.init(e,t)})),os=so("$ZodXID",((e,t)=>{t.pattern??(t.pattern=Ro),ji.init(e,t)})),is=so("$ZodKSUID",((e,t)=>{t.pattern??(t.pattern=Oo),ji.init(e,t)})),ss=so("$ZodISODateTime",((e,t)=>{t.pattern??(t.pattern=function(e){const t=["Z"];e.offset&&t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const n=`${Uo({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,r=e.local?`${n}|${Uo({precision:e.precision})}`:n;return new RegExp(`^${Fo}T(?:${r})$`)}(t)),ji.init(e,t)})),as=so("$ZodISODate",((e,t)=>{t.pattern??(t.pattern=Mo),ji.init(e,t)})),cs=so("$ZodISOTime",((e,t)=>{t.pattern??(t.pattern=new RegExp(`^${Uo(t)}$`)),ji.init(e,t)})),us=so("$ZodISODuration",((e,t)=>{t.pattern??(t.pattern=zo),ji.init(e,t)})),ls=so("$ZodIPv4",((e,t)=>{t.pattern??(t.pattern=_o),ji.init(e,t)})),fs=/^[0-9a-fA-F:.]+$/;function hs(e){return!!fs.test(e)&&Wi(`http://[${e}]`)}const ds=so("$ZodIPv6",((e,t)=>{t.pattern??(t.pattern=Io),ji.init(e,t),e._zod.check=n=>{hs(n.value)||n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}})),ps=so("$ZodCIDRv4",((e,t)=>{t.pattern??(t.pattern=Do),ji.init(e,t)}));const ms=so("$ZodCIDRv6",((e,t)=>{t.pattern??(t.pattern=Vo),ji.init(e,t),e._zod.check=n=>{(function(e){const t=e.split("/");if(2!==t.length)return!1;const[n,r]=t;if(!r)return!1;const o=Number(r);return`${o}`===r&&!(o<0||o>128)&&hs(n)})(n.value)||n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}));function gs(e){if(""===e)return!0;if(/\s/.test(e))return!1;if(e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}const ys=/^[0-9a-zA-Z+/]*={0,2}$/,ws=so("$ZodBase64",((e,t)=>{t.pattern??(t.pattern=ys),ji.init(e,t),e._zod.check=n=>{gs(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}})),bs=/^[A-Za-z0-9_-]*$/;const vs=so("$ZodBase64URL",((e,t)=>{t.pattern??(t.pattern=bs),ji.init(e,t),e._zod.check=n=>{(function(e){if(!bs.test(e))return!1;const t=e.replace(/[-_]/g,(e=>"-"===e?"+":"/"));return gs(t.padEnd(4*Math.ceil(t.length/4),"="))})(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}})),Bs=so("$ZodE164",((e,t)=>{t.pattern??(t.pattern=Co),ji.init(e,t)}));const Es=so("$ZodJWT",((e,t)=>{ji.init(e,t),e._zod.check=n=>{(function(e,t=null){try{const n=e.split(".");if(3!==n.length)return!1;const[r]=n;if(!r)return!1;const o=JSON.parse(atob(r));return!("typ"in o&&"JWT"!==o?.typ||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}})(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}})),xs=so("$ZodNumber",((e,t)=>{Mi.init(e,t),e._zod.pattern=Zo,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch(s){}const o=n.value;if("number"==typeof o&&!Number.isNaN(o)&&Number.isFinite(o))return n;const i="number"==typeof o?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:String(o):void 0;return n.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...i?{received:i}:{}}),n}})),Ts=so("$ZodNumberFormat",((e,t)=>{ti.init(e,t),xs.init(e,t)})),Rs=so("$ZodBoolean",((e,t)=>{Mi.init(e,t),e._zod.pattern=qo,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Boolean(n.value)}catch(i){}const o=n.value;return"boolean"==typeof o||n.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),n}})),Os=so("$ZodBigInt",((e,t)=>{Mi.init(e,t),e._zod.pattern=Lo,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=BigInt(n.value)}catch(o){}return"bigint"==typeof n.value||n.issues.push({expected:"bigint",code:"invalid_type",input:n.value,inst:e}),n}})),As=so("$ZodAny",((e,t)=>{Mi.init(e,t),e._zod.parse=e=>e})),zs=so("$ZodUnknown",((e,t)=>{Mi.init(e,t),e._zod.parse=e=>e})),ks=so("$ZodNever",((e,t)=>{Mi.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:e}),t)}));function Ss(e,t){const n=Mr(e._zod.def.checks);if(!n.length)return;const r=Math.min(...n.map((e=>e[0]))),o=e._zod.parse;e._zod.parse=(n,i)=>{const s=t(n.value);if(s>r&&!i?.skipChecks&&"backward"!==i?.direction)for(const[t,r]of Mr(e._zod.def.checks))if(s>t&&r._zod.def.when(n)){const t=n.issues.length;return r._zod.check(n),n.issues[t].continue=!1,Ur(n.issues,t,e),n}return o(n,i)}}const $s=e=>Array.isArray(e)?e.length:-1;function _s(e,t,n){e.issues.length&&t.issues.push(...Fr(n,e.issues)),t.value[n]=e.value}const Is=so("$ZodArray",((e,t)=>{Mi.init(e,t);const n=uo.memoizer;n?.attach(e),e._zod.parse=(r,o)=>{const i=r.value;if(!Array.isArray(i))return r.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),r;r.value=n?n.alloc(e,r,Array(i.length),o):Array(i.length);const s=[],a=o?.abortEarly;for(let e=0;e<i.length;e++){const n=i[e],c=t.element._zod.run({value:n,issues:[]},o);if(c instanceof Promise)s.push(c.then((t=>_s(t,r,e))));else if(_s(c,r,e),a&&0!==c.issues.length&&Pr(c))break}return s.length?Promise.all(s).then((()=>r)):r},Ss(e,$s)}));function Ds(e,t,n,r,o,i){const s=n in r,a="optional"===i;if(s||!a||"optional"!==o){if(e.issues.length){if(void 0!==o&&a&&!s)return;t.issues.push(...Fr(n,e.issues))}s||void 0!==o?void 0===e.value?(s||"defaulted"===o&&!a)&&(t.value[n]=void 0):t.value[n]=e.value:e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]})}}const Vs=[];function Ps(e){const t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:Vs,o=r.length?[...t,...r]:t;for(const a of o)if(!e.shape?.[a]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${String(a)}": expected a Zod schema`);const i=(s=e.shape,Object.keys(s).filter((e=>void 0!==s[e]._zod.optin&&"optional"===s[e]._zod.optout)));var s;return{...e,allKeys:o,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(i)}}function Cs(e,t,n,r,o,i,s){const a=[],c=o.keySet,u=o.catchall._zod,l=u.def.type,f=u.optin,h=u.optout;let d=0;for(const p in t){if(s&&n.issues.length!==d){if(Pr(n,d))break;d=n.issues.length}if(c.has(p))continue;if("__proto__"===p){"never"===l&&a.push(p);continue}if("never"===l){a.push(p);continue}const o=u.run({value:t[p],issues:[]},r);o instanceof Promise?e.push(o.then((e=>Ds(e,n,p,t,f,h)))):Ds(o,n,p,t,f,h)}return a.length&&n.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:i,continue:!0}),e.length?Promise.all(e).then((()=>n)):n}const Fs=so("$ZodObject",((e,t)=>{Mi.init(e,t);const n=Object.getOwnPropertyDescriptor(t,"shape"),r=n?.get?n.get.raw:t.shape??{};if(r){const e=()=>{const n={...r};return Object.defineProperty(t,"shape",{value:n}),e.raw=n,n};e.raw=r,Object.defineProperty(t,"shape",{get:e})}const o=hr((()=>Ps(t)));eo(e,"propValues",(e=>{const t=e.def.shape,n={};for(const r in t){const e=t[r]._zod;if(e.values){Object.prototype.hasOwnProperty.call(n,r)||pr(n,r,new Set);for(const t of e.values)n[r].add(t);void 0!==e.optin&&n[r].add(void 0)}}return n}));const i=Er,s=t.catchall;let a;const c=uo.memoizer;c?.attach(e),e._zod.parse=(t,n)=>{a??(a=o.value);const r=t.value;if(!i(r))return t.issues.push({expected:"object",code:"invalid_type",input:r,inst:e}),t;t.value=c?c.alloc(e,t,{},n):{};const u=[],l=a.shape,f=n?.abortEarly;let h=t.issues.length;for(const e of a.allKeys){if(f&&t.issues.length!==h){if(Pr(t,h))break;h=t.issues.length}if("__proto__"===e)continue;const o=l[e],i=o._zod.optin,s=o._zod.optout,a=o._zod.run({value:r[e],issues:[]},n);a instanceof Promise?u.push(a.then((n=>Ds(n,t,e,r,i,s)))):Ds(a,t,e,r,i,s)}return s?Cs(u,r,t,n,o.value,e,!0===f):u.length?Promise.all(u).then((()=>t)):t}})),Ns=so("$ZodObjectJIT",((e,t)=>{Fs.init(e,t);const n=e._zod.parse,r=hr((()=>Ps(t))),o=uo.memoizer;let i;const s=Er,a=!uo.jitless,c=a&&xr.value,u=t.catchall;let l;e._zod.parse=(f,h)=>{l??(l=r.value);const d=f.value;return s(d)?a&&c&&!1===h?.async&&!0!==h.jitless?(i||(i=(t=>{const n=r.value,i=n.symbolKeys,s=new di(["payload","ctx"],{shape:t,inst:e,memo:o,syms:i}),a=e=>`shape[${e}]._zod.run({ value: input[${e}], issues: [] }, ctx)`,c=(e,t)=>`\n let ${e}_ab = false;\n for (let i = 0; i < ${e}.issues.length; i++) {\n const iss = ${e}.issues[i];\n iss.path = iss.path ? [${t}, ...iss.path] : [${t}];\n payload.issues.push(iss);\n if (iss.continue !== true) ${e}_ab = true;\n }\n if (${e}_ab && ctx && ctx.abortEarly) {\n payload.value = newResult;\n return payload;\n }`;s.write("const input = payload.value;");const u=Object.create(null);let l=0;for(const e of n.allKeys)u[e]="key_"+l++;s.write(o?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(const e of n.allKeys){if("__proto__"===e)continue;const n=u[e],r="symbol"==typeof e?`syms[${i.indexOf(e)}]`:(f=e,JSON.stringify(f)),o=`${r} in input`,l=t[e],h=l?._zod?.optin,d=void 0!==h,p="optional"===l?._zod?.optout;if(s.write(`const ${n} = ${a(r)};`),d&&p){const e="optional"===h?`${n}_present`:`${n}.value !== undefined || ${n}_present`;s.write(`\n const ${n}_present = ${o};\n if (!${n}.issues.length || ${n}_present) {\n if (${n}.issues.length) {${c(n,r)}\n }\n\n if (${e}) {\n newResult[${r}] = ${n}.value;\n }\n }\n\n `)}else d?(s.write(`\n if (${n}.issues.length) {${c(n,r)}\n }\n `),"defaulted"===h?s.write(`newResult[${r}] = ${n}.value;`):s.write(`\n if (${n}.value !== undefined || ${o}) {\n newResult[${r}] = ${n}.value;\n }\n `)):s.write(`\n const ${n}_present = ${o};\n if (${n}.issues.length) {${c(n,r)}\n }\n if (!${n}_present && !${n}.issues.length) {\n payload.issues.push({\n code: "invalid_type",\n expected: "nonoptional",\n input: undefined,\n path: [${r}]\n });\n if (ctx && ctx.abortEarly) {\n payload.value = newResult;\n return payload;\n }\n }\n\n if (${n}_present) {\n newResult[${r}] = ${n}.value;\n }\n\n `)}var f;return s.write("payload.value = newResult;"),s.write("return payload;"),s.compile()})(t.shape)),f=i(f,h),u?Cs([],d,f,h,l,e,!0===h?.abortEarly):f):n(f,h):(f.issues.push({expected:"object",code:"invalid_type",input:d,inst:e}),f)}}));function Ms(e,t,n,r){for(const i of e)if(0===i.issues.length)return t.value=i.value,t;const o=e.filter((e=>!Pr(e)));return 1===o.length?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map((e=>e.issues.map((e=>Gr(e,r,lo())))))}),t)}const Us=so("$ZodUnion",((e,t)=>{Mi.init(e,t),eo(e,"optin",(e=>e.def.options.some((e=>"defaulted"===e._zod.optin))?"defaulted":e.def.options.some((e=>void 0!==e._zod.optin))?"optional":void 0)),eo(e,"optout",(e=>e.def.options.some((e=>"optional"===e._zod.optout))?"optional":void 0)),eo(e,"values",(e=>{if(e.def.options.every((e=>e._zod.values)))return new Set(e.def.options.flatMap((e=>Array.from(e._zod.values))))})),eo(e,"pattern",(e=>{if(e.def.options.every((e=>e._zod.pattern))){const t=e.def.options.map((e=>e._zod.pattern));return new RegExp(`^(${t.map((e=>dr(e.source))).join("|")})$`)}}));const n=1===t.options.length?t.options[0]._zod.run:null;e._zod.parse=(r,o)=>{if(n)return n(r,o);let i=!1;const s=[];for(const e of t.options){const t=e._zod.run({value:r.value,issues:[]},o);if(t instanceof Promise)s.push(t),i=!0;else{if(0===t.issues.length)return t;s.push(t)}}return i?Promise.all(s).then((t=>Ms(t,r,e,o))):Ms(s,r,e,o)}}));const Gs=so("$ZodIntersection",((e,t)=>{Mi.init(e,t),e._zod.parse=(e,n)=>{const r=e.value,o=t.left._zod.run({value:r,issues:[]},n),i=t.right._zod.run({value:r,issues:[]},n);return o instanceof Promise||i instanceof Promise?Promise.all([o,i]).then((([t,n])=>js(e,t,n))):js(e,o,i)}}));function Ls(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Tr(e)&&Tr(t)){const n=Object.keys(t),r=Object.keys(e).filter((e=>-1!==n.indexOf(e))),o={...e,...t};Object.prototype.hasOwnProperty.call(o,"__proto__")&&delete o.__proto__;for(const i of r){if("__proto__"===i)continue;const n=Ls(e[i],t[i]);if(!n.valid)return{valid:!1,mergeErrorPath:[i,...n.mergeErrorPath]};o[i]=n.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let r=0;r<e.length;r++){const o=Ls(e[r],t[r]);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function js(e,t,n){const r=new Map;let o;const i=new Map,s=(e,t)=>{let n;if("unrecognized_keys"!==e.code||e.path?.length){if("invalid_key"!==e.code||"record"!==e.origin||1!==e.path?.length)return!1;{const t=String(e.path[0]);i.has(t)||i.set(t,e),n=[t]}}else o??(o=e),n=e.keys;for(const o of n)r.has(o)||r.set(o,{}),r.get(o)[t]=!0;return!0};for(const u of t.issues)s(u,"l")||e.issues.push(u);for(const u of n.issues)s(u,"r")||e.issues.push(u);const a=[...r].filter((([,e])=>e.l&&e.r)).map((([e])=>e));if(a.length){const t=o?a.filter((e=>o.keys.includes(e))):[];t.length&&e.issues.push({...o,keys:t});for(const n of a)!t.includes(n)&&i.has(n)&&e.issues.push(i.get(n))}const c=Ls(t.value,n.value);if(!c.valid){if(Pr(e))return e;throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}const Zs=so("$ZodTuple",((e,t)=>{Mi.init(e,t);const n=t.items,r=uo.memoizer;r?.attach(e),e._zod.parse=(o,i)=>{const s=o.value;if(!Array.isArray(s))return o.issues.push({input:s,inst:e,expected:"tuple",code:"invalid_type"}),o;o.value=r?r.alloc(e,o,[],i):[];const a=[],c=qs(n,"optin"),u=qs(n,"optout");if(!t.rest){if(s.length<c)return o.issues.push({code:"too_small",minimum:c,inclusive:!0,input:s,inst:e,origin:"array"}),o;s.length>n.length&&o.issues.push({code:"too_big",maximum:n.length,inclusive:!0,input:s,inst:e,origin:"array"})}const l=new Array(n.length),f=t.rest?i?.abortEarly:void 0;let h=!1;for(let e=0;e<n.length;e++){const t=n[e]._zod.run({value:s[e],issues:[]},i);t instanceof Promise?a.push(t.then((t=>{l[e]=t}))):(l[e]=t,f&&!h&&t.issues.length&&(h=Pr(t)))}if(t.rest&&!h){let e=n.length-1;const r=s.slice(n.length);let c=o.issues.length;for(const n of r){if(f&&o.issues.length!==c){if(Pr(o,c))break;c=o.issues.length}e++;const r=t.rest._zod.run({value:n,issues:[]},i);r instanceof Promise?a.push(r.then((t=>Hs(t,o,e)))):Hs(r,o,e)}}return a.length?Promise.all(a).then((()=>Ws(l,o,n,s,u))):Ws(l,o,n,s,u)}}));function qs(e,t){for(let n=e.length-1;n>=0;n--){if(!("optin"===t?void 0!==e[n]._zod.optin:"optional"===e[n]._zod.optout))return n+1}return 0}function Hs(e,t,n){e.issues.length&&t.issues.push(...Fr(n,e.issues)),t.value[n]=e.value}function Ws(e,t,n,r,o){for(let i=0;i<n.length;i++){const s=e[i],a=i<r.length;if(!a&&i>=o&&"optional"===n[i]._zod.optin){t.value.length=i;break}if(s.issues.length){if(!a&&i>=o){t.value.length=i;break}t.issues.push(...Fr(i,s.issues))}t.value[i]=s.value}for(let i=t.value.length-1;i>=r.length&&("optional"===n[i]._zod.optout&&void 0===t.value[i]);i--)t.value.length=i;return t}const Ks=so("$ZodRecord",((e,t)=>{Mi.init(e,t);const n=uo.memoizer;n?.attach(e),e._zod.parse=(r,o)=>{const i=r.value;if(!Tr(i))return r.issues.push({expected:"record",code:"invalid_type",input:i,inst:e}),r;const s=[],a=t.keyType._zod.values;if(a&&!t.partial){r.value=n?n.alloc(e,r,{},o):{};const c=new Set;for(const n of a)if("string"==typeof n||"number"==typeof n||"symbol"==typeof n){if(c.add("number"==typeof n?n.toString():n),"__proto__"===n)continue;const a=t.keyType._zod.run({value:n,issues:[]},o);if(a instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(a.issues.length){r.issues.push({code:"invalid_key",origin:"record",issues:a.issues.map((e=>Gr(e,o,lo()))),input:n,path:[n],inst:e});continue}const u=a.value;if("__proto__"===u)continue;const l=t.valueType._zod.run({value:i[n],issues:[]},o);l instanceof Promise?s.push(l.then((e=>{e.issues.length&&r.issues.push(...Fr(n,e.issues)),r.value[u]=e.value}))):(l.issues.length&&r.issues.push(...Fr(n,l.issues)),r.value[u]=l.value)}let u;for(const e in i)if(!c.has(e))if("loose"===t.mode){if("__proto__"===e)continue;r.value[e]=i[e]}else u=u??[],u.push(e);u&&u.length>0&&r.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:u,continue:!0})}else{let c;r.value=n?n.alloc(e,r,{},o):{};for(const n of Reflect.ownKeys(i)){if("__proto__"===n)continue;if(!Object.prototype.propertyIsEnumerable.call(i,n))continue;let u=t.keyType._zod.run({value:n,issues:[]},o);if(u instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if("string"==typeof n&&Zo.test(n)&&u.issues.length){const e=t.keyType._zod.run({value:Number(n),issues:[]},o);if(e instanceof Promise)throw new Error("Async schemas not supported in object keys currently");0===e.issues.length&&(u=e)}if(u.issues.length){"loose"===t.mode?r.value[n]=i[n]:a?(c=c??[],c.push(n)):r.issues.push({code:"invalid_key",origin:"record",issues:u.issues.map((e=>Gr(e,o,lo()))),input:n,path:[n],inst:e});continue}const l=u.value;if("__proto__"===l)continue;const f=t.valueType._zod.run({value:i[n],issues:[]},o);f instanceof Promise?s.push(f.then((e=>{e.issues.length&&r.issues.push(...Fr(n,e.issues)),r.value[l]=e.value}))):(f.issues.length&&r.issues.push(...Fr(n,f.issues)),r.value[l]=f.value)}c&&c.length>0&&r.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:c,continue:!0})}return s.length?Promise.all(s).then((()=>r)):r}}));const Js=so("$ZodEnum",((e,t)=>{Mi.init(e,t);const n=cr(t.entries),r=new Set(n);e._zod.values=r,eo(e,"pattern",(e=>{const t=cr(e.def.entries).filter((e=>Or.has(typeof e)));return new RegExp(t.length?`^(${t.map((e=>Ar(e.toString()))).join("|")})$`:"^[^\\s\\S]$")})),e._zod.parse=(t,o)=>{const i=t.value;return r.has(i)||t.issues.push({code:"invalid_value",values:n,input:i,inst:e}),t}})),Xs=so("$ZodLiteral",((e,t)=>{Mi.init(e,t);const n=new Set(t.values);e._zod.values=n,eo(e,"pattern",(e=>{const t=e.def.values;return new RegExp(t.length?`^(${t.map((e=>"string"==typeof e?Ar(e):e?Ar(e.toString()):String(e))).join("|")})$`:"^[^\\s\\S]$")})),e._zod.parse=(r,o)=>{const i=r.value;return n.has(i)||r.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),r}})),Ys=so("$ZodTransform",((e,t)=>{Mi.init(e,t),e._zod.optin="optional",uo.memoizer?.guard(e),e._zod.parse=(n,r)=>{if("backward"===r.direction)throw new co(e.constructor.name);const o=t.transform(n.value,n);if(r.async){return(o instanceof Promise?o:Promise.resolve(o)).then((e=>(n.value=e,n)))}if(o instanceof Promise)throw new ao;return n.value=o,n}}));function Qs(e,t){return e.value=t.issues.length?void 0:t.value,e}const ea=so("$ZodOptional",((e,t)=>{Mi.init(e,t),eo(e,"optin",(e=>"defaulted"===e.def.innerType._zod.optin?"defaulted":"optional")),e._zod.optout="optional",eo(e,"values",(e=>{const t=e.def.innerType._zod.values;return t?new Set([...t,void 0]):void 0})),eo(e,"pattern",(e=>{const t=e.def.innerType._zod.pattern;return t?new RegExp(`^(${dr(t.source)})?$`):void 0})),e._zod.parse=(e,n)=>{if(void 0===e.value){if("defaulted"!==t.innerType._zod.optin)return e;const r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then((t=>Qs(e,t))):Qs(e,r)}return t.innerType._zod.run(e,n)}})),ta=so("$ZodExactOptional",((e,t)=>{ea.init(e,t),eo(e,"values",(e=>e.def.innerType._zod.values)),eo(e,"pattern",(e=>e.def.innerType._zod.pattern)),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)})),na=so("$ZodNullable",((e,t)=>{Mi.init(e,t),eo(e,"optin",(e=>e.def.innerType._zod.optin)),eo(e,"optout",(e=>e.def.innerType._zod.optout)),eo(e,"pattern",(e=>{const t=e.def.innerType._zod.pattern;return t?new RegExp(`^(${dr(t.source)}|null)$`):void 0})),eo(e,"values",(e=>e.def.innerType._zod.values?new Set([...e.def.innerType._zod.values,null]):void 0)),e._zod.parse=(e,n)=>null===e.value?e:t.innerType._zod.run(e,n)})),ra=so("$ZodDefault",((e,t)=>{Mi.init(e,t),e._zod.optin="defaulted",eo(e,"values",(e=>e.def.innerType._zod.values)),e._zod.parse=(e,n)=>{if("backward"===n.direction)return t.innerType._zod.run(e,n);if(void 0===e.value)return e.value=t.defaultValue,e;const r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then((e=>oa(e,t))):oa(r,t)}}));function oa(e,t){return void 0===e.value&&(e.value=t.defaultValue),e}const ia=so("$ZodPrefault",((e,t)=>{Mi.init(e,t),e._zod.optin="defaulted",eo(e,"values",(e=>e.def.innerType._zod.values)),e._zod.parse=(e,n)=>("backward"===n.direction||void 0===e.value&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))})),sa=so("$ZodNonOptional",((e,t)=>{Mi.init(e,t),eo(e,"values",(e=>{const t=e.def.innerType._zod.values;return t?new Set([...t].filter((e=>void 0!==e))):void 0})),e._zod.parse=(n,r)=>{const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then((t=>aa(t,e))):aa(o,e)}}));function aa(e,t){return e.issues.length||void 0!==e.value||e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}function ca(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map((e=>Gr(e,r,lo())))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}const ua=so("$ZodCatch",((e,t)=>{Mi.init(e,t),eo(e,"optin",(e=>"defaulted"===e.def.innerType._zod.optin?"defaulted":"optional")),eo(e,"optout",(e=>e.def.innerType._zod.optout)),eo(e,"values",(e=>e.def.innerType._zod.values)),e._zod.parse=(e,n)=>{if("backward"===n.direction)return t.innerType._zod.run(e,n);const r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then((r=>ca(e,r,t,n))):ca(e,r,t,n)}})),la=so("$ZodPipe",((e,t)=>{Mi.init(e,t),eo(e,"values",(e=>e.def.in._zod.values)),eo(e,"optin",(e=>e.def.in._zod.optin)),eo(e,"optout",(e=>e.def.out._zod.optout)),eo(e,"propValues",(e=>e.def.in._zod.propValues)),e._zod.parse=(e,n)=>{if("backward"===n.direction){const r=t.out._zod.run(e,n);return r instanceof Promise?r.then((e=>fa(e,t.in,n))):fa(r,t.in,n)}const r=t.in._zod.run(e,n);return r instanceof Promise?r.then((e=>fa(e,t.out,n))):fa(r,t.out,n)}}));function fa(e,t,n){return e.issues.some((e=>"unrecognized_keys"!==e.code))?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const ha=so("$ZodReadonly",((e,t)=>{Mi.init(e,t),eo(e,"propValues",(e=>e.def.innerType._zod.propValues)),eo(e,"values",(e=>e.def.innerType._zod.values)),eo(e,"optin",(e=>e.def.innerType?._zod?.optin)),eo(e,"optout",(e=>e.def.innerType?._zod?.optout)),e._zod.parse=(e,n)=>{if("backward"===n.direction)return t.innerType._zod.run(e,n);const r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(da):da(r)}}));function da(e){return e.memo||(e.value=Object.freeze(e.value)),e}const pa=so("$ZodFunction",((e,t)=>(Mi.init(e,t),Object.defineProperty(e,"_def",{value:t}),e._zod.def=t,e.implement=t=>{if("function"!=typeof t)throw new Error("implement() must be called with a function");return Object.defineProperty((function(...n){const r=e._def.input?Ei(e._def.input,n):n,o=Reflect.apply(t,this,r);return e._def.output?Ei(e._def.output,o):o}),"_zod",{value:e._zod,enumerable:!1})},e.implementAsync=t=>{if("function"!=typeof t)throw new Error("implementAsync() must be called with a function");return Object.defineProperty((async function(...n){const r=e._def.input?await Ti(e._def.input,n):n,o=await Reflect.apply(t,this,r);return e._def.output?await Ti(e._def.output,o):o}),"_zod",{value:e._zod,enumerable:!1})},e._zod.parse=(t,n)=>{if("function"!=typeof t.value)return t.issues.push({code:"invalid_type",expected:"function",input:t.value,inst:e}),t;const r=e._def.output&&"promise"===e._def.output._zod.def.type;return t.value=r?e.implementAsync(t.value):e.implement(t.value),t},e.input=(...t)=>{const n=e.constructor;return Array.isArray(t[0])?new n({type:"function",input:new Zs({type:"tuple",items:t[0],rest:t[1]}),output:e._def.output}):new n({type:"function",input:t[0],output:e._def.output})},e.output=t=>new(0,e.constructor)({type:"function",input:e._def.input,output:t}),e))),ma=so("$ZodCustom",((e,t)=>{Ko.init(e,t),Mi.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{const r=n.value,o=t.fn(r);if(o instanceof Promise)return o.then((t=>ga(t,n,r,e)));ga(o,n,r,e)}}));function ga(e,t,n,r){if(!e){const e={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(qr(e))}}var ya;class wa{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){const n=t[0];return this._map.set(e,n),n&&"object"==typeof n&&"id"in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){const t=this._map.get(e);return t&&"object"==typeof t&&"id"in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){const t=e._zod.parent;if(t){const n={...this.get(t)??{}};delete n.id;const r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}(ya=globalThis).__zod_globalRegistry??(ya.__zod_globalRegistry=new wa);const ba=globalThis.__zod_globalRegistry;function va(e){return e.checks&&(e.checks=[...e.checks]),e}function Ba(e,t){return new Yo({check:"less_than",...kr(t),value:e,inclusive:!1})}function Ea(e,t){return new Yo({check:"less_than",...kr(t),value:e,inclusive:!0})}function xa(e,t){return new Qo({check:"greater_than",...kr(t),value:e,inclusive:!1})}function Ta(e,t){return new Qo({check:"greater_than",...kr(t),value:e,inclusive:!0})}function Ra(e,t){return new ei({check:"multiple_of",...kr(t),value:e})}function Oa(e,t){return new ni({check:"max_length",...kr(t),maximum:e})}function Aa(e,t){return new ri({check:"min_length",...kr(t),minimum:e})}function za(e,t){return new oi({check:"length_equals",...kr(t),length:e})}function ka(e){return new hi({check:"overwrite",tx:e})}function Sa(e,t){const n=function(e,t){const n=new Ko({check:"custom",...kr(t)});return n._zod.check=e,n}((t=>(t.addIssue=e=>{if("string"==typeof e)t.issues.push(qr(e,t.value,n._zod.def));else{const r=e;r.fatal&&(r.continue=!1),r.code??(r.code="custom"),"input"in r||(r.input=t.value),r.inst??(r.inst=n),r.continue??(r.continue=!n._zod.def.abort),t.issues.push(qr(r))}},e(t.value,t))),t);return n}function $a(e,...t){for(const n of t)for(const t of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,t)&&pr(e,t,n[t]);return e}function _a(e){let t=e?.target??"draft-2020-12";return"draft-4"===t&&(t="draft-04"),"draft-7"===t&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??ba,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??"ref",reused:e?.reused??"inline",intersections:[],deferred:[],external:e?.external??void 0}}function Ia(e,t,n,r,o){const i="function"==typeof t.unrepresentable?t.unrepresentable({zodSchema:e,path:r.path,message:o}):t.unrepresentable;if("any"===i)return!1;if(void 0===i||"throw"===i)throw new Error(o);return Object.assign(n,i),!0}function Da(e,t,n={path:[],schemaPath:[]}){var r;const o=e._zod.def,i=t.seen.get(e);if(i){i.count++;return n.schemaPath.includes(e)&&(i.cycle=n.path),i.schema}const s={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,s),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;const a=e._zod.toJSONSchema?.();if(a)s.schema=a;else{const r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,s.schema,r);else{const n=s.schema,i=t.processors[o.type];if(!i)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);i(e,t,n,r)}const i=e._zod.parent;i&&(s.ref||(s.ref=i),Da(i,t,r),t.seen.get(i).isParent=!0)}const c=t.metadataRegistry.get(e);c&&$a(s.schema,c),"input"===t.io&&ja(e)&&(delete s.schema.examples,delete s.schema.default),"input"===t.io&&"_prefault"in s.schema&&((r=s.schema).default??(r.default=s.schema._prefault)),delete s.schema._prefault;return t.seen.get(e).schema}function Va(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function Pa(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;const r=new Map;for(const i of e.seen.entries()){const t=e.metadataRegistry.get(i[0])?.id;if(t){const e=r.get(t);if(e&&e!==i[0])throw new Error(`Duplicate schema id "${t}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(t,i[0])}}const o=t=>{if(t[1].schema.$ref)return;const r=t[1],{ref:o,defId:i}=(t=>{const r="draft-2020-12"===e.target?"$defs":"definitions";if(e.external){const n=e.external.registry.get(t[0])?.id,o=e.external.uri??(e=>e);if(n)return{ref:o(n)};const i=t[1].defId??t[1].schema.id??"schema"+e.counter++;return t[1].defId=i,{defId:i,ref:`${o("__shared")}#/${r}/${Va(i)}`}}const o=`#/${r}/`;if(t[1]===n&&!t[1].schema.id)return{ref:"#"};const i=t[1].schema.id??"__schema"+e.counter++;return{defId:i,ref:o+Va(i)}})(t);r.def={...r.schema},i&&(r.defId=i);const s=r.schema;for(const e in s)delete s[e];s.$ref=o};if("throw"===e.cycles)for(const i of e.seen.entries()){const e=i[1];if(e.cycle)throw new Error(`Cycle detected: #/${e.cycle?.join("/")}/<root>\n\nSet the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const i of e.seen.entries()){const n=i[1];if(t===i[0]){o(i);continue}if(e.external){const n=e.external.registry.get(i[0])?.id;if(t!==i[0]&&n){o(i);continue}}const r=e.metadataRegistry.get(i[0])?.id;r?o(i):(n.cycle||n.count>1&&"ref"===e.reused)&&o(i)}e.external&&(e.sharedDefsExtractedFor=e.external)}function Ca(e){const t=e.anyOf;if(!Array.isArray(t)||0===t.length||void 0!==e.type)return;const n=[];for(const r of t){if(!r||"object"!=typeof r)return;Ca(r);const e=Object.keys(r);if(1!==e.length||"type"!==e[0])return;const t=r.type;for(const r of Array.isArray(t)?t:[t]){if("string"!=typeof r)return;n.includes(r)||n.push(r)}}delete e.anyOf,e.type=1===n.length?n[0]:n}const Fa=new Set(["type","properties","required","additionalProperties"]),Na=["oneOf","anyOf"];function Ma(e){const t=e.additionalProperties;return void 0===t||!1===t||"object"!=typeof t||null===t?null:Object.keys(t).length?t:null}function Ua(e){const t=[];for(const i of e){if("object"!=typeof i||"object"!==i.type)return null;for(const e in i)if(!Fa.has(e))return null;t.push(i)}const n={},r=new Set;for(const i of t){for(const e in i.properties){if(Object.prototype.hasOwnProperty.call(n,e))continue;const r=[];for(const n of t){const t=n.properties?.[e]??Ma(n);null!=t&&(r.some((e=>JSON.stringify(e)===JSON.stringify(t)))||r.push(t))}pr(n,e,1===r.length?r[0]:Ua(r)??{allOf:r})}for(const e of i.required??[])r.add(e)}const o={type:"object",properties:n};if(r.size&&(o.required=[...r]),t.every((e=>!1===e.additionalProperties)))o.additionalProperties=!1;else{const e=[];for(const n of t){const t=Ma(n);t&&!e.some((e=>JSON.stringify(e)===JSON.stringify(t)))&&e.push(t)}1===e.length?o.additionalProperties=e[0]:e.length>1&&(o.additionalProperties={allOf:e})}return o}function Ga(e){const t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(const o of Fa)if(o in e)return;const n=t.filter((e=>Na.some((t=>Array.isArray(e[t])))));let r=null;if(n.length){const e=n[0],o=Na.find((t=>Array.isArray(e[t])));if(1!==Object.keys(e).length)return;const i=t.filter((t=>t!==e)),s=e[o].map((e=>Ua([...i,e])));if(s.some((e=>!e)))return;r={[o]:s}}else r=Ua(t);r&&(delete e.allOf,$a(e,r))}function La(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=t=>{const n=e.seen.get(t);if(null===n.ref)return;const o=n.def??n.schema,i={...o},s=n.ref;if(n.ref=null,s){r(s);const n=e.seen.get(s),a=n.schema;!a.$ref||"draft-07"!==e.target&&"draft-04"!==e.target&&"openapi-3.0"!==e.target?$a(o,a):(o.allOf=o.allOf??[],o.allOf.push(a)),$a(o,i);if(t._zod.parent===s)for(const e in o)"$ref"!==e&&"allOf"!==e&&(e in i||delete o[e]);if(a.$ref&&n.def)for(const e in o)"$ref"!==e&&"allOf"!==e&&e in n.def&&JSON.stringify(o[e])===JSON.stringify(n.def[e])&&delete o[e]}const a=t._zod.parent;if(a&&a!==s){r(a);const t=e.seen.get(a);if(t?.schema.$ref&&(o.$ref=t.schema.$ref,t.def))for(const e in o)"$ref"!==e&&"allOf"!==e&&e in t.def&&JSON.stringify(o[e])===JSON.stringify(t.def[e])&&delete o[e]}e.override({zodSchema:t,jsonSchema:o,path:n.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(const t of[...e.seen.entries()].reverse())r(t[0]);if("openapi-3.0"!==e.target)for(const t of e.seen.entries())Ca(t[1].def??t[1].schema);for(const t of e.deferred)t();if(e.intersections.length){const t=new Map;for(const n of e.seen.values())for(const e of[n.schema,n.def]){const n=e?.allOf;if(!Array.isArray(n))continue;const r=t.get(n);r?r.push(e):t.set(n,[e])}for(const n of e.intersections)for(const e of t.get(n)??[])Ga(e)}}const o={};if("draft-2020-12"===e.target?o.$schema="https://json-schema.org/draft/2020-12/schema":"draft-07"===e.target?o.$schema="http://json-schema.org/draft-07/schema#":"draft-04"===e.target?o.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const n=e.external.registry.get(t)?.id;if(!n)throw new Error("Schema is missing an `id` property");o.$id=e.external.uri(n)}$a(o,n.defId?n.schema:n.def??n.schema);const i=e.metadataRegistry.get(t)?.id;void 0!==i&&o.id===i&&delete o.id;const s=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(const c of e.seen.entries()){const e=c[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,pr(s,e.defId,e.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(s).length>0&&("draft-2020-12"===e.target?o.$defs=s:o.definitions=s);try{const n=JSON.parse(JSON.stringify(o));return Object.defineProperty(n,"~standard",{value:{...t["~standard"],jsonSchema:{input:Za(t,"input",e.processors),output:Za(t,"output",e.processors)}},enumerable:!1,writable:!1}),n}catch(a){throw new Error("Error converting schema to JSON.")}}function ja(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const r=e._zod.def;if("transform"===r.type)return!0;if("array"===r.type)return ja(r.element,n);if("set"===r.type)return ja(r.valueType,n);if("lazy"===r.type)return ja(r.getter(),n);if("promise"===r.type||"optional"===r.type||"nonoptional"===r.type||"nullable"===r.type||"readonly"===r.type||"default"===r.type||"prefault"===r.type||"catch"===r.type)return ja(r.innerType,n);if("intersection"===r.type)return ja(r.left,n)||ja(r.right,n);if("record"===r.type||"map"===r.type)return ja(r.keyType,n)||ja(r.valueType,n);if("pipe"===r.type)return!!e._zod.traits.has("$ZodCodec")||(ja(r.in,n)||ja(r.out,n));if("object"===r.type){for(const e in r.shape)if(ja(r.shape[e],n))return!0;return!1}if("union"===r.type){for(const e of r.options)if(ja(e,n))return!0;return!1}if("tuple"===r.type){for(const e of r.items)if(ja(e,n))return!0;return!(!r.rest||!ja(r.rest,n))}return!1}const Za=(e,t,n={})=>r=>{const{libraryOptions:o,target:i}=r??{},s=_a({...o??{},target:i,io:t,processors:n});return Da(e,s),Pa(s,e),La(s,e)};const qa=(e,t,n)=>{(void 0===e[t]||n>e[t])&&(e[t]=n)},Ha=(e,t,n)=>{(void 0===e[t]||n<e[t])&&(e[t]=n)},Wa=(e,t)=>{qa(e,"minimum",t),Ha(e,"maximum",t)},Ka=(e,t)=>{e.multipleOf??(e.multipleOf=[]),e.multipleOf.includes(t)||e.multipleOf.push(t)},Ja=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},Xa=(e,t)=>{e.mime=e.mime?e.mime.filter((e=>t.includes(e))):[...t]},Ya=(e,t)=>{e.format=t,t.includes("int")&&(e.isInt=!0)},Qa=(e,t)=>qa(e,"minimum",t.minimum),ec=(e,t)=>Ha(e,"maximum",t.maximum),tc=e=>(t,n)=>{Ya(t,n.format);const[r,o]=e[n.format];qa(t,"minimum",r),Ha(t,"maximum",o)},nc={greater_than:(e,t)=>qa(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>Ha(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>Ka(e,t.value),number_format:tc($r),bigint_format:tc(_r),min_length:Qa,max_length:ec,length_equals:(e,t)=>Wa(e,t.length),min_size:Qa,max_size:ec,size_equals:(e,t)=>Wa(e,t.size),string_format:(e,t)=>{Ya(e,t.format),t.pattern&&Ja(e,t.pattern),"base64"!==t.format&&"base64url"!==t.format||(e.contentEncoding=t.format),(t.local||-1===t.precision)&&(e.laxFormat=!0)},mime_type:(e,t)=>Xa(e,t.mime)};function rc(e){const t={},n=e._zod.def,r=e._zod.traits.has("$ZodCheck")?[e,...n.checks??[]]:n.checks??[];for(const i of r)nc[i._zod.def.check]?.(t,i._zod.def);const o=e._zod.bag;void 0!==o.minimum&&qa(t,"minimum",o.minimum),void 0!==o.exclusiveMinimum&&qa(t,"exclusiveMinimum",o.exclusiveMinimum),void 0!==o.maximum&&Ha(t,"maximum",o.maximum),void 0!==o.exclusiveMaximum&&Ha(t,"exclusiveMaximum",o.exclusiveMaximum),void 0!==o.multipleOf&&Ka(t,o.multipleOf),void 0!==o.format&&(t.format??(t.format=o.format),o.format.includes("int")&&(t.isInt=!0)),o.mime&&Xa(t,o.mime);for(const i of o.patterns??[])Ja(t,i);return t}const oc={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},ic=new Map([[ys,/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/],[bs,/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/]]),sc=e=>ic.get(e)??e,ac=(e,t,n,r)=>{const o=n;o.type="string";const{minimum:i,maximum:s,format:a,patterns:c,contentEncoding:u,laxFormat:l}=rc(e);if("number"==typeof i&&(o.minLength=i),"number"==typeof s&&(o.maxLength=s),a&&(o.format=oc[a]??a,""===o.format&&delete o.format,("time"===a||l)&&delete o.format),u&&(o.contentEncoding=u),c&&c.size>0){const e=[...c].map(sc);1===e.length?o.pattern=e[0].source:e.length>1&&(o.allOf=[...e.map((e=>({..."draft-07"===t.target||"draft-04"===t.target||"openapi-3.0"===t.target?{type:"string"}:{},pattern:e.source})))])}},cc=(e,t,n,r)=>{const o=n,{minimum:i,maximum:s,multipleOf:a,exclusiveMaximum:c,exclusiveMinimum:u,isInt:l}=rc(e);o.type=l?"integer":"number";const f="number"==typeof u&&u>=(i??Number.NEGATIVE_INFINITY),h="number"==typeof c&&c<=(s??Number.POSITIVE_INFINITY),d="draft-04"===t.target||"openapi-3.0"===t.target;if(f?d?(o.minimum=u,o.exclusiveMinimum=!0):o.exclusiveMinimum=u:"number"==typeof i&&(o.minimum=i),h?d?(o.maximum=c,o.exclusiveMaximum=!0):o.exclusiveMaximum=c:"number"==typeof s&&(o.maximum=s),a){const n=new Set;for(const c of a)Number.isFinite(c)&&0!==c?n.add(Math.abs(c)):Ia(e,t,o,r,`A multipleOf divisor of ${c} cannot be represented in JSON Schema`);const[i,...s]=n;void 0!==i&&(o.multipleOf=i),s.length&&(o.allOf=[...o.allOf??[],...s.map((e=>({multipleOf:e})))])}},uc=(e,t,n,r)=>{n.type="boolean"},lc=(e,t,n,r)=>{Ia(e,t,n,r,"BigInt cannot be represented in JSON Schema")},fc=(e,t,n,r)=>{n.not={}},hc=(e,t,n,r)=>{const o=cr(e._zod.def.entries);0!==o.length?(o.every((e=>"number"==typeof e))&&(n.type="number"),o.every((e=>"string"==typeof e))&&(n.type="string"),n.enum=o):n.not={}},dc=(e,t,n,r)=>{const o=e._zod.def;if(0===o.values.length)return void(n.not={});const i=[];for(const s of o.values)if(void 0===s){if(Ia(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if("bigint"==typeof s){if(Ia(e,t,n,r,"BigInt literals cannot be represented in JSON Schema"))return;i.push(Number(s))}else i.push(s);if(0===i.length);else if(1===i.length){const e=i[0];n.type=null===e?"null":typeof e,"draft-04"===t.target||"openapi-3.0"===t.target?n.enum=[e]:n.const=e}else i.every((e=>"number"==typeof e))&&(n.type="number"),i.every((e=>"string"==typeof e))&&(n.type="string"),i.every((e=>"boolean"==typeof e))&&(n.type="boolean"),i.every((e=>null===e))&&(n.type="null"),n.enum=i},pc=(e,t,n,r)=>{Ia(e,t,n,r,"Custom types cannot be represented in JSON Schema")},mc=(e,t,n,r)=>{Ia(e,t,n,r,"Function types cannot be represented in JSON Schema")},gc=(e,t,n,r)=>{Ia(e,t,n,r,"Transforms cannot be represented in JSON Schema")},yc=(e,t,n,r)=>{const o=n,i=e._zod.def,{minimum:s,maximum:a}=rc(e);"number"==typeof s&&(o.minItems=s),"number"==typeof a&&(o.maxItems=a),o.type="array",o.items=Da(i.element,t,{...r,path:[...r.path,"items"]})};function wc(e){const t=e._zod.def;return"pipe"===t.type&&t.in._zod.traits.has("$ZodTransform")?wc(t.out):"catch"===t.type?wc(t.innerType):e._zod.optin}const bc=(e,t,n,r)=>{const o=n,i=e._zod.def,s=i.shape;if(Object.getOwnPropertySymbols(s).length&&Ia(e,t,o,r,"Symbol keys cannot be represented in JSON Schema"))return;o.type="object",o.properties={};for(const c in s)pr(o.properties,c,Da(s[c],t,{...r,path:[...r.path,"properties",c]}));const a=[];for(const c of Object.keys(s)){const e=i.shape[c];("input"===t.io?void 0===wc(e):void 0===e._zod.optout)&&a.push(c)}a.length>0&&(o.required=a),"never"===i.catchall?._zod.def.type?o.additionalProperties=!1:i.catchall?i.catchall&&(o.additionalProperties=Da(i.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):"output"===t.io&&(o.additionalProperties=!1)},vc=(e,t,n,r)=>{const o=e._zod.def,i=!1===o.inclusive,s=o.options.map(((e,n)=>Da(e,t,{...r,path:[...r.path,i?"oneOf":"anyOf",n]})));i?n.oneOf=s:n.anyOf=s},Bc=(e,t,n,r)=>{const o=e._zod.def,i=Da(o.left,t,{...r,path:[...r.path,"allOf",0]}),s=Da(o.right,t,{...r,path:[...r.path,"allOf",1]}),a=e=>"allOf"in e&&1===Object.keys(e).length,c=[...a(i)?i.allOf:[i],...a(s)?s.allOf:[s]];n.allOf=c,t.intersections.push(c)},Ec=(e,t,n,r)=>{const o=n,i=e._zod.def;o.type="array";const s="draft-2020-12"===t.target?"prefixItems":"items",a="draft-2020-12"===t.target||"openapi-3.0"===t.target?"items":"additionalItems",c=i.items.map(((e,n)=>Da(e,t,{...r,path:[...r.path,s,n]}))),u=i.rest?Da(i.rest,t,{...r,path:[...r.path,a,..."openapi-3.0"===t.target?[i.items.length]:[]]}):null;let l=i.items.length;for(;l>0;){const e=i.items[l-1];if(!("input"===t.io?void 0!==wc(e):"optional"===e._zod.optout))break;l--}const f=i.items.length,h=!i.rest;"draft-2020-12"===t.target?(o.prefixItems=c,h?o.items=!1:u&&(o.items=u),l>0&&(o.minItems=l),h&&(o.maxItems=f)):"openapi-3.0"===t.target?(o.items={anyOf:c},u&&o.items.anyOf.push(u),l>0&&(o.minItems=l),h&&(o.maxItems=f)):(o.items=c,h?o.additionalItems=!1:u&&(o.additionalItems=u),l>0&&(o.minItems=l),h&&(o.maxItems=f));const{minimum:d,maximum:p}=rc(e);"number"==typeof d&&(o.minItems=d),"number"==typeof p&&(o.maxItems=p)};function xc(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);const r=e.get(t)?.def;if(!r)return t;const o=xc(e,r,n);return o===r?t:o}for(const p of["anyOf","oneOf"]){const r=t[p];if(!Array.isArray(r))continue;const o=r.map((t=>xc(e,t,n)));o.some(((e,t)=>e!==r[t]))&&(t={...t,[p]:o})}const r=Array.isArray(t.type)?t.type:[t.type],o=!r.includes("string")&&r.some((e=>"number"===e||"integer"===e)),i=t.enum??(void 0!==t.const?[t.const]:void 0);if(!o&&!i?.some((e=>"number"==typeof e)))return t;const{minimum:s,maximum:a,exclusiveMinimum:c,exclusiveMaximum:u,multipleOf:l,format:f,id:h,...d}=t;return d.enum?d.enum=d.enum.map((e=>"number"==typeof e?String(e):e)):"number"==typeof d.const&&(d.const=String(d.const)),o?(d.type="string",i||(d.pattern=(r.includes("number")?Zo:jo).source),d):d}const Tc=new WeakMap;const Rc=(e,t,n,r)=>{const o=n,i=e._zod.def;o.type="object";const s=i.keyType,a=rc(s).patterns;if("loose"===i.mode&&a&&a.size>0){const e=Da(i.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});o.patternProperties={};for(const t of a)pr(o.patternProperties,sc(t).source,e)}else{if("draft-07"===t.target||"draft-2020-12"===t.target){o.propertyNames=Da(i.keyType,t,{...r,path:[...r.path,"propertyNames"]});let n=Tc.get(t);n||(n=[],Tc.set(t,n),t.deferred.push((()=>function(e){const t=new Map;for(const r of e.seen.values())r.def&&!t.has(r.schema)&&t.set(r.schema,r);const n=new Map;for(const r of Tc.get(e)??[]){const o=e.seen.get(r),i=(o?.def??o?.schema)?.propertyNames;if(!i||!0===i||n.has(i))continue;const s=xc(t,i,new Set);s!==i&&n.set(i,s)}if(n.size)for(const r of e.seen.values())for(const e of[r.schema,r.def]){const t=e&&n.get(e.propertyNames);t&&(e.propertyNames=t)}}(t)))),n.push(e)}o.additionalProperties=Da(i.valueType,t,{...r,path:[...r.path,"additionalProperties"]})}const c=s._zod.values,u="input"===t.io&&void 0!==wc(i.valueType);if(c&&!i.partial&&!u){const e=[...c].filter((e=>"string"==typeof e||"number"==typeof e));e.length>0&&(o.required=e.map(String))}},Oc=(e,t,n,r)=>{const o=e._zod.def,i=Da(o.innerType,t,r),s=t.seen.get(e);"openapi-3.0"===t.target?(s.ref=o.innerType,n.nullable=!0):n.anyOf=[i,{type:"null"}]},Ac=(e,t,n,r)=>{const o=e._zod.def;Da(o.innerType,t,r);t.seen.get(e).ref=o.innerType},zc=Symbol();function kc(e,t,n,r,o){let i=!1;const s=JSON.stringify(e,((e,t)=>"bigint"!=typeof t?t:(i=!0,null)));return i?(Ia(t,n,r,o,"BigInt defaults cannot be represented in JSON Schema"),zc):JSON.parse(s)}const Sc=(e,t,n,r)=>{const o=e._zod.def;Da(o.innerType,t,r);t.seen.get(e).ref=o.innerType;const i=kc(o.defaultValue,e,t,n,r);i!==zc&&(n.default=i)},$c=(e,t,n,r)=>{const o=e._zod.def;Da(o.innerType,t,r);if(t.seen.get(e).ref=o.innerType,"input"!==t.io)return;const i=kc(o.defaultValue,e,t,n,r);i!==zc&&(n._prefault=i)},_c=(e,t,n,r)=>{const o=e._zod.def;Da(o.innerType,t,r);let i;t.seen.get(e).ref=o.innerType;try{i=o.catchValue(void 0)}catch{return void Ia(e,t,n,r,"Dynamic catch values are not supported in JSON Schema")}n.default=i},Ic=(e,t,n,r)=>{const o=e._zod.def,i=o.in._zod.traits.has("$ZodTransform"),s="input"===t.io?i?o.out:o.in:o.out;Da(s,t,r);t.seen.get(e).ref=s},Dc=(e,t,n,r)=>{const o=e._zod.def;Da(o.innerType,t,r);t.seen.get(e).ref=o.innerType,n.readOnly=!0},Vc=(e,t,n,r)=>{const o=e._zod.def;Da(o.innerType,t,r);t.seen.get(e).ref=o.innerType};Object.defineProperty(Cc,"name",{value:"default",configurable:!0});const Pc=()=>{const e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function t(t){return e[t]??null}const n={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",currency_code:"currency code",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},r={nan:"NaN"};function o(e,t){return"number"!==e||"number"!=typeof t||Number.isFinite(t)?r[e]??e:String(t)}return e=>{switch(e.code){case"invalid_type":return`Invalid input: expected ${o(e.expected)}, received ${o(function(e){const t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(null===e)return"null";if(Array.isArray(e))return"array";const t=e;if(t&&Object.getPrototypeOf(t)!==Object.prototype&&"constructor"in t&&t.constructor)return t.constructor.name}}return t}(e.input),e.input)}`;case"invalid_value":return 1===e.values.length?`Invalid input: expected ${Sr(e.values[0])}`:`Invalid option: expected one of ${ur(e.values,"|")}`;case"too_big":{const n=e.exact?"exactly ":e.inclusive?"<=":"<",r=t(e.origin);return r?`Too big: expected ${e.origin??"value"} to have ${n}${e.maximum.toString()} ${r.unit??"elements"}`:`Too big: expected ${e.origin??"value"} to be ${n}${e.maximum.toString()}`}case"too_small":{const n=e.exact?"exactly ":e.inclusive?">=":">",r=t(e.origin);return r?`Too small: expected ${e.origin} to have ${n}${e.minimum.toString()} ${r.unit}`:`Too small: expected ${e.origin} to be ${n}${e.minimum.toString()}`}case"invalid_format":{const t=e;return"starts_with"===t.format?`Invalid string: must start with "${t.prefix}"`:"ends_with"===t.format?`Invalid string: must end with "${t.suffix}"`:"includes"===t.format?`Invalid string: must include "${t.includes}"`:"regex"===t.format?`Invalid string: must match pattern ${t.pattern}`:`Invalid ${n[t.format]??e.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${e.divisor}`;case"unrecognized_keys":return`Unrecognized key${e.keys.length>1?"s":""}: ${ur(e.keys,", ")}`;case"invalid_key":return`Invalid key in ${e.origin}`;case"invalid_union":if(e.options&&Array.isArray(e.options)&&e.options.length>0){return`Invalid discriminator value. Expected ${e.options.map((e=>`'${e}'`)).join(" | ")}`}return!1===e.inclusive?"Invalid input: more than one option matched":"Invalid input";case"invalid_element":return`Invalid value in ${e.origin}`;default:return"Invalid input"}}};function Cc(){return{localeError:Pc()}}const Fc=new WeakSet([Object.prototype,Error.prototype]);function Nc(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){const e=n(this);return Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0})}})}const Mc=(e,t)=>{wi.init(e,t),e.name="ZodError";const n=Object.getPrototypeOf(e);Fc.has(n)||(Fc.add(n),Nc(n,"format",(e=>t=>function(e,t=e=>e.message){const n={_errors:[]},r=(e,o=[])=>{for(const i of e.issues)if("invalid_union"===i.code&&i.errors.length)i.errors.map((e=>r({issues:e},[...o,...i.path])));else if("invalid_key"===i.code)r({issues:i.issues},[...o,...i.path]);else if("invalid_element"===i.code)r({issues:i.issues},[...o,...i.path]);else{const e=[...o,...i.path];if(0===e.length)n._errors.push(t(i));else{let r=n,o=0;for(;o<e.length;){const n=e[o],s=o===e.length-1;if("_errors"===n){s&&r._errors.push(t(i)),o++;continue}Object.prototype.hasOwnProperty.call(r,n)||Object.defineProperty(r,n,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});const a=r[n];s&&a._errors.push(t(i)),r=a,o++}}}};return r(e),n}(e,t))),Nc(n,"flatten",(e=>t=>function(e,t=e=>e.message){const n={},r=[];for(const a of e.issues)a.path.length>0?(o=n,i=a.path[0],s=()=>[],Object.prototype.hasOwnProperty.call(o,i)||("__proto__"===i?Object.defineProperty(o,i,{value:s(),writable:!0,enumerable:!0,configurable:!0}):o[i]=s()),o[i]).push(t(a)):r.push(t(a));var o,i,s;return{formErrors:r,fieldErrors:n}}(e,t))),Nc(n,"addIssue",(e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,lr,2)})),Nc(n,"addIssues",(e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,lr,2)})),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return 0===this.issues.length}}))},Uc=so("ZodError",Mc,void 0,{Parent:Error}),Gc=Bi(Uc),Lc=xi(Uc),jc=Ri(Uc),Zc=Ai(Uc),qc=$i(Uc),Hc=_i(Uc),Wc=Ii(Uc),Kc=Di(Uc),Jc=Vi(Uc),Xc=Pi(Uc),Yc=Ci(Uc),Qc=Fi(Uc);function eu(){uo.memoizer||lo({memoizer:Bo})}const tu=so("ZodType",((e,t)=>(uo.localeError||lo(Cc()),Mi.init(e,t),e.def=t,e.type=t.type,e)),{check(...e){const t=this.def;return this.clone(vr(t,{checks:[...t.checks??[],...e.map((e=>"function"==typeof e?{_zod:{check:e,def:{check:"custom"},onattach:[]}}:e))]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return zr(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(function(e,t={}){return function(e,t,n){return new e({type:"custom",check:"custom",fn:t,...kr(n)})}(wl,e,t)}(e,t))},superRefine(e,t){return this.check(function(e,t){return Sa(e,t)}(e,t))},overwrite(e){return this.check(ka(e))},optional(){return sl(this)},exactOptional(){return new al({type:"optional",innerType:this})},nullable(){return ul(this)},nullish(){return sl(ul(this))},nonoptional(e){return function(e,t){return new hl({type:"nonoptional",innerType:e,...kr(t)})}(this,e)},array(){return ju(this)},or(e){return Wu([this,e])},and(e){return new Ku({type:"intersection",left:this,right:e})},transform(e){return ml(this,ol(e))},default(e){return t=e,new ll({type:"default",innerType:this,get defaultValue(){return"function"==typeof t?t():Rr(t)}});var t},prefault(e){return t=e,new fl({type:"prefault",innerType:this,get defaultValue(){return"function"==typeof t?t():Rr(t)}});var t},catch(e){return new dl({type:"catch",innerType:this,catchValue:"function"==typeof(t=e)?t:no(t)});var t},pipe(e){return ml(this,e)},readonly(){return new gl({type:"readonly",innerType:this})},describe(e){const t=this.clone();return ba.add(t,{description:e}),t},meta(...e){if(0===e.length)return ba.get(this);const t=this.clone();return ba.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return 0===t.length?e(this):e(this,...t)},get"~standard"(){return Wr(this,"~standard",{...Gi(this),jsonSchema:{input:Za(this,"input"),output:Za(this,"output")}})},set"~standard"(e){Hr(this,"~standard",e)},parse:function e(t,n){return Gc(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await Lc(this,t,n,{callee:e})},safeParse(e,t){return jc(this,e,t)},async safeParseAsync(e,t){return Zc(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){Hr(this,"spa",e)},validate(e,t){return Si(this,e,t)},validateAsync(e,t){return(async(e,t,n)=>{const r=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0};let o=e._zod.run({value:t,issues:[]},r);return o instanceof Promise&&(o=await o),0===o.issues.length})(this,e,t)},encode:function e(t,n){return qc(this,t,n,{callee:e})},decode:function e(t,n){return Hc(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await Wc(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await Kc(this,t,n,{callee:e})},safeEncode(e,t){return Jc(this,e,t)},safeDecode(e,t){return Xc(this,e,t)},async safeEncodeAsync(e,t){return Yc(this,e,t)},async safeDecodeAsync(e,t){return Qc(this,e,t)},toJSONSchema(e){return((e,t={})=>n=>{const r=_a({...n,processors:t});return Da(e,r),Pa(r,e),La(r,e)})(this,{})(e)},get description(){return ba.get(this)?.description},get _def(){return this._zod.def}}),nu=so("_ZodString",((e,t)=>{Li.init(e,t),tu.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ac(e,t,n)}),Kr({format:e=>rc(e).format??null,minLength:e=>rc(e).minimum??null,maxLength:e=>rc(e).maximum??null},{regex(...e){return this.check(function(e,t){return new si({check:"string_format",format:"regex",...kr(t),pattern:e})}(...e))},includes(...e){return this.check(function(e,t){return new ui({check:"string_format",format:"includes",...kr(t),includes:e})}(...e))},startsWith(...e){return this.check(function(e,t){return new li({check:"string_format",format:"starts_with",...kr(t),prefix:e})}(...e))},endsWith(...e){return this.check(function(e,t){return new fi({check:"string_format",format:"ends_with",...kr(t),suffix:e})}(...e))},min(...e){return this.check(Aa(...e))},max(...e){return this.check(Oa(...e))},length(...e){return this.check(za(...e))},nonempty(...e){return this.check(Aa(1,...e))},lowercase(e){return this.check(function(e){return new ai({check:"string_format",format:"lowercase",...kr(e)})}(e))},uppercase(e){return this.check(function(e){return new ci({check:"string_format",format:"uppercase",...kr(e)})}(e))},trim(){return this.check(ka((e=>e.trim())))},normalize(...e){return this.check(function(e){return ka((t=>t.normalize(e)))}(...e))},toLowerCase(){return this.check(ka((e=>e.toLowerCase())))},toUpperCase(){return this.check(ka((e=>e.toUpperCase())))},slugify(){return this.check(ka((e=>function(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}(e))))}})),ru=so("ZodString",((e,t)=>{Li.init(e,t),nu.init(e,t)}),{email(e){return this.check(function(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...kr(t)})}(lu,e))},url(e){return this.check(function(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...kr(t)})}(du,e))},jwt(e){return this.check(function(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...kr(t)})}(zu,e))},emoji(e){return this.check(function(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...kr(t)})}(pu,e))},guid(e){return this.check(function(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...kr(t)})}(fu,e))},uuid(e){return this.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...kr(t)})}(hu,e))},uuidv4(e){return this.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...kr(t)})}(hu,e))},uuidv6(e){return this.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...kr(t)})}(hu,e))},uuidv7(e){return this.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...kr(t)})}(hu,e))},nanoid(e){return this.check(function(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...kr(t)})}(mu,e))},cuid(e){return this.check(function(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...kr(t)})}(gu,e))},cuid2(e){return this.check(function(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...kr(t)})}(yu,e))},ulid(e){return this.check(function(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...kr(t)})}(wu,e))},base64(e){return this.check(function(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...kr(t)})}(Ru,e))},base64url(e){return this.check(function(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...kr(t)})}(Ou,e))},xid(e){return this.check(function(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...kr(t)})}(bu,e))},ksuid(e){return this.check(function(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...kr(t)})}(vu,e))},ipv4(e){return this.check(function(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...kr(t)})}(Bu,e))},ipv6(e){return this.check(function(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...kr(t)})}(Eu,e))},cidrv4(e){return this.check(function(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...kr(t)})}(xu,e))},cidrv6(e){return this.check(function(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...kr(t)})}(Tu,e))},e164(e){return this.check(function(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...kr(t)})}(Au,e))},datetime(e){return this.check(function(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...kr(t)})}(su,e))},date(e){return this.check(function(e,t){return new e({type:"string",format:"date",check:"string_format",...kr(t)})}(au,e))},time(e){return this.check(function(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...kr(t)})}(cu,e))},duration(e){return this.check(function(e,t){return new e({type:"string",format:"duration",check:"string_format",...kr(t)})}(uu,e))}});function ou(e){return function(e,t){return new e(va({type:"string",...kr(t)}))}(ru,e)}const iu=so("ZodStringFormat",((e,t)=>{ji.init(e,t),nu.init(e,t)})),su=so("ZodISODateTime",((e,t)=>{ss.init(e,t),iu.init(e,t)})),au=so("ZodISODate",((e,t)=>{as.init(e,t),iu.init(e,t)})),cu=so("ZodISOTime",((e,t)=>{cs.init(e,t),iu.init(e,t)})),uu=so("ZodISODuration",((e,t)=>{us.init(e,t),iu.init(e,t)})),lu=so("ZodEmail",((e,t)=>{Hi.init(e,t),iu.init(e,t)}));const fu=so("ZodGUID",((e,t)=>{Zi.init(e,t),iu.init(e,t)}));const hu=so("ZodUUID",((e,t)=>{qi.init(e,t),iu.init(e,t)}));const du=so("ZodURL",((e,t)=>{Yi.init(e,t),iu.init(e,t)}));const pu=so("ZodEmoji",((e,t)=>{Qi.init(e,t),iu.init(e,t)}));const mu=so("ZodNanoID",((e,t)=>{es.init(e,t),iu.init(e,t)}));const gu=so("ZodCUID",((e,t)=>{ts.init(e,t),iu.init(e,t)}));const yu=so("ZodCUID2",((e,t)=>{ns.init(e,t),iu.init(e,t)}));const wu=so("ZodULID",((e,t)=>{rs.init(e,t),iu.init(e,t)}));const bu=so("ZodXID",((e,t)=>{os.init(e,t),iu.init(e,t)}));const vu=so("ZodKSUID",((e,t)=>{is.init(e,t),iu.init(e,t)}));const Bu=so("ZodIPv4",((e,t)=>{ls.init(e,t),iu.init(e,t)}));const Eu=so("ZodIPv6",((e,t)=>{ds.init(e,t),iu.init(e,t)}));const xu=so("ZodCIDRv4",((e,t)=>{ps.init(e,t),iu.init(e,t)}));const Tu=so("ZodCIDRv6",((e,t)=>{ms.init(e,t),iu.init(e,t)}));const Ru=so("ZodBase64",((e,t)=>{ws.init(e,t),iu.init(e,t)}));const Ou=so("ZodBase64URL",((e,t)=>{vs.init(e,t),iu.init(e,t)}));const Au=so("ZodE164",((e,t)=>{Bs.init(e,t),iu.init(e,t)}));const zu=so("ZodJWT",((e,t)=>{Es.init(e,t),iu.init(e,t)}));const ku=so("ZodNumber",((e,t)=>{xs.init(e,t),tu.init(e,t),e._zod.processJSONSchema=(t,n,r)=>cc(e,t,n,r),e.isFinite=!0}),Kr({minValue:e=>{const{minimum:t,exclusiveMinimum:n}=rc(e);return Math.max(t??Number.NEGATIVE_INFINITY,n??Number.NEGATIVE_INFINITY)},maxValue:e=>{const{maximum:t,exclusiveMaximum:n}=rc(e);return Math.min(t??Number.POSITIVE_INFINITY,n??Number.POSITIVE_INFINITY)},isInt:e=>{const{isInt:t,multipleOf:n}=rc(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>rc(e).format??null},{gt(e,t){return this.check(xa(e,t))},gte(e,t){return this.check(Ta(e,t))},min(e,t){return this.check(Ta(e,t))},lt(e,t){return this.check(Ba(e,t))},lte(e,t){return this.check(Ea(e,t))},max(e,t){return this.check(Ea(e,t))},int(e){return this.check(_u(e))},safe(e){return this.check(_u(e))},positive(e){return this.check(xa(0,e))},nonnegative(e){return this.check(Ta(0,e))},negative(e){return this.check(Ba(0,e))},nonpositive(e){return this.check(Ea(0,e))},multipleOf(e,t){return this.check(Ra(e,t))},step(e,t){return this.check(Ra(e,t))},finite(){return this}}));function Su(e){return function(e,t){return new e(va({type:"number",checks:[],...kr(t)}))}(ku,e)}const $u=so("ZodNumberFormat",((e,t)=>{Ts.init(e,t),ku.init(e,t)}));function _u(e){return function(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...kr(t)})}($u,e)}const Iu=so("ZodBoolean",((e,t)=>{Rs.init(e,t),tu.init(e,t),e._zod.processJSONSchema=(e,t,n)=>uc(0,0,t)}));function Du(e){return function(e,t){return new e({type:"boolean",...kr(t)})}(Iu,e)}const Vu=so("ZodBigInt",((e,t)=>{Os.init(e,t),tu.init(e,t),e._zod.processJSONSchema=(t,n,r)=>lc(e,t,n,r)}),Kr({minValue:e=>rc(e).minimum??null,maxValue:e=>rc(e).maximum??null,format:e=>rc(e).format??null},{gte(e,t){return this.check(Ta(e,t))},min(e,t){return this.check(Ta(e,t))},gt(e,t){return this.check(xa(e,t))},lt(e,t){return this.check(Ba(e,t))},lte(e,t){return this.check(Ea(e,t))},max(e,t){return this.check(Ea(e,t))},positive(e){return this.check(xa(BigInt(0),e))},negative(e){return this.check(Ba(BigInt(0),e))},nonpositive(e){return this.check(Ea(BigInt(0),e))},nonnegative(e){return this.check(Ta(BigInt(0),e))},multipleOf(e,t){return this.check(Ra(e,t))}}));function Pu(e){return function(e,t){return new e({type:"bigint",...kr(t)})}(Vu,e)}const Cu=so("ZodAny",((e,t)=>{As.init(e,t),tu.init(e,t),e._zod.processJSONSchema=(e,t,n)=>{}}));function Fu(){return function(e){return new e({type:"any"})}(Cu)}const Nu=so("ZodUnknown",((e,t)=>{zs.init(e,t),tu.init(e,t),e._zod.processJSONSchema=(e,t,n)=>{}}));function Mu(){return function(e){return new e({type:"unknown"})}(Nu)}const Uu=so("ZodNever",((e,t)=>{ks.init(e,t),tu.init(e,t),e._zod.processJSONSchema=(e,t,n)=>fc(0,0,t)}));function Gu(e){return function(e,t){return new e({type:"never",...kr(t)})}(Uu,e)}const Lu=so("ZodArray",((e,t)=>{eu(),Is.init(e,t),tu.init(e,t),e._zod.processJSONSchema=(t,n,r)=>yc(e,t,n,r),e.element=t.element}),{min(e,t){return this.check(Aa(e,t))},nonempty(e){return this.check(Aa(1,e))},max(e,t){return this.check(Oa(e,t))},length(e,t){return this.check(za(e,t))},unwrap(){return this.element}});function ju(e,t){return function(e,t,n){return new e({type:"array",element:t,...kr(n)})}(Lu,e,t)}const Zu=so("ZodObject",((e,t)=>{eu(),Ns.init(e,t),tu.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bc(e,t,n,r),to(e,"shape",(e=>e._zod.def.shape),!1)}),{keyof(){return tl(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(vr(this._zod.def,{catchall:e}))},passthrough(){return this.clone(vr(this._zod.def,{catchall:Mu()}))},loose(){return this.clone(vr(this._zod.def,{catchall:Mu()}))},strict(){return this.clone(vr(this._zod.def,{catchall:Gu()}))},strip(){return this.clone(vr(this._zod.def,{catchall:void 0}))},extend(e){return function(e,t){if(!Tr(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const n=gr(e);for(const e of Reflect.ownKeys(t))if(void 0!==Object.getOwnPropertyDescriptor(n,e))throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return zr(e,vr(e._zod.def,{shape:Dr(e,t)}))}(this,e)},safeExtend(e){return function(e,t){if(!Tr(t))throw new Error("Invalid input to safeExtend: expected a plain object");return zr(e,vr(e._zod.def,{shape:Dr(e,t)}))}(this,e)},merge(e){return function(e,t){if(!t?._zod?.def)throw new Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");const n={};return br(n,e,Reflect.ownKeys(gr(e))),br(n,t,Reflect.ownKeys(gr(t))),zr(e,vr(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}(this,e)},pick(e){return function(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const o={};return br(o,e,Ir(e,t)),zr(e,vr(n,{shape:o,checks:[]}))}(this,e)},omit(e){return function(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const o=new Set(Ir(e,t)),i={};return br(i,e,Reflect.ownKeys(gr(e)).filter((e=>!o.has(e)))),zr(e,vr(n,{shape:i,checks:[]}))}(this,e)},partial(...e){return Vr(il,this,e[0])},exactPartial(...e){return Vr(al,this,e[0],"exactPartial")},required(...e){return function(e,t,n){const r=n?new Set(Ir(t,n)):void 0,o={};return br(o,t,Reflect.ownKeys(gr(t)),((t,n)=>r&&!r.has(n)?t:new e({type:"nonoptional",innerType:t}))),zr(t,vr(t._zod.def,{shape:o}))}(hl,this,e[0])}});function qu(e,t){const n={type:"object",shape:e??{},...kr(t)};return new Zu(n)}const Hu=so("ZodUnion",((e,t)=>{Us.init(e,t),tu.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vc(e,t,n,r),e.options=t.options}));function Wu(e,t){return new Hu({type:"union",options:e,...kr(t)})}const Ku=so("ZodIntersection",((e,t)=>{Gs.init(e,t),tu.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Bc(e,t,n,r)}));const Ju=so("ZodTuple",((e,t)=>{eu(),Zs.init(e,t),tu.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ec(e,t,n,r)}),{rest(e){return this.clone({...this._zod.def,rest:e})},partial(){const e=this._zod.def;if(e.checks?.length)throw new Error(".partial() cannot be used on tuple schemas containing refinements");return this.clone({...e,items:e.items.map((e=>new il({type:"optional",innerType:e})))})}});function Xu(e,t,n){const r=t instanceof Mi;return new Ju({type:"tuple",items:e,rest:r?t:null,...kr(r?n:t)})}const Yu=so("ZodRecord",((e,t)=>{eu(),Ks.init(e,t),tu.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Rc(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType}));function Qu(e,t,n){return t&&t._zod?new Yu({type:"record",keyType:e,valueType:t,...kr(n)}):new Yu({type:"record",keyType:ou(),valueType:e,...kr(t)})}const el=so("ZodEnum",((e,t)=>{Js.init(e,t),tu.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hc(e,0,n),e.enum=t.entries,e.options=[...e._zod.values];const n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{const o={};for(const i of e){if(!n.has(i))throw new Error(`Key ${i} not found in enum`);o[i]=t.entries[i]}return new el({...t,checks:[],...kr(r),entries:o})},e.exclude=(e,r)=>{const o={...t.entries};for(const t of e){if(!n.has(t))throw new Error(`Key ${t} not found in enum`);delete o[t]}return new el({...t,checks:[],...kr(r),entries:o})}}));function tl(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map((e=>[e,e]))):e;return new el({type:"enum",entries:n,...kr(t)})}const nl=so("ZodLiteral",((e,t)=>{Xs.init(e,t),tu.init(e,t),e._zod.processJSONSchema=(t,n,r)=>dc(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})}));const rl=so("ZodTransform",((e,t)=>{eu(),Ys.init(e,t),tu.init(e,t),e._zod.processJSONSchema=(t,n,r)=>gc(e,t,n,r),e._zod.parse=(n,r)=>{if("backward"===r.direction)throw new co(e.constructor.name);n.addIssue=r=>{if("string"==typeof r)n.issues.push(qr(r,n.value,t));else{const t=r;t.fatal&&(t.continue=!1),t.code??(t.code="custom"),"input"in t||(t.input=n.value),t.inst??(t.inst=e),n.issues.push(qr(t))}};const o=t.transform(n.value,n);return o instanceof Promise?o.then((e=>(n.value=e,n))):(n.value=o,n)}}));function ol(e){return new rl({type:"transform",transform:e})}const il=so("ZodOptional",((e,t)=>{ea.init(e,t),tu.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Vc(e,t,0,r),e.unwrap=()=>e._zod.def.innerType}));function sl(e){return new il({type:"optional",innerType:e})}const al=so("ZodExactOptional",((e,t)=>{ta.init(e,t),tu.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Vc(e,t,0,r),e.unwrap=()=>e._zod.def.innerType}));const cl=so("ZodNullable",((e,t)=>{na.init(e,t),tu.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Oc(e,t,n,r),e.unwrap=()=>e._zod.def.innerType}));function ul(e){return new cl({type:"nullable",innerType:e})}const ll=so("ZodDefault",((e,t)=>{ra.init(e,t),tu.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Sc(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap}));const fl=so("ZodPrefault",((e,t)=>{ia.init(e,t),tu.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$c(e,t,n,r),e.unwrap=()=>e._zod.def.innerType}));const hl=so("ZodNonOptional",((e,t)=>{sa.init(e,t),tu.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ac(e,t,0,r),e.unwrap=()=>e._zod.def.innerType}));const dl=so("ZodCatch",((e,t)=>{ua.init(e,t),tu.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_c(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap}));const pl=so("ZodPipe",((e,t)=>{la.init(e,t),tu.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ic(e,t,0,r),e.in=t.in,e.out=t.out}));function ml(e,t){return new pl({type:"pipe",in:e,out:t})}const gl=so("ZodReadonly",((e,t)=>{ha.init(e,t),tu.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Dc(e,t,n,r),e.unwrap=()=>e._zod.def.innerType}));const yl=so("ZodFunction",((e,t)=>{pa.init(e,t),tu.init(e,t),e._zod.processJSONSchema=(t,n,r)=>mc(e,t,n,r)}));const wl=so("ZodCustom",((e,t)=>{ma.init(e,t),tu.init(e,t),e._zod.processJSONSchema=(t,n,r)=>pc(e,t,n,r)}));const bl=qu({issuer:ou().transform((e=>yt(e))),index:ou().transform((e=>yt(e))),timestamp:ou().transform((e=>yt(e))),signature:ou().transform((e=>yt(e)))});var vl=n(878);const Bl=n.n(vl)()("bee-js:http"),El={headers:{accept:"application/json, text/plain, */*"}};async function xl(e,t){const n=t.data,r=ar.Rb.deepMerge3(El,{...t,data:void 0},e);if(r.data=n,e.signal&&(r.signal=e.signal),function(e){if(void 0===e.data)return;const t=e.data;if(null!==t&&"object"==typeof t&&t.constructor===Object||Array.isArray(t))e.body=JSON.stringify(t),e.headers={"content-type":"application/json",...e.headers};else{e.body=t,e.duplex="half";const n=t instanceof Blob&&t.type?t.type:"application/octet-stream";e.headers={"content-type":n,...e.headers}}}(r),r.params)for(const c of Object.keys(r.params))void 0===r.params[c]&&delete r.params[c];const o=function(e){let t=ar.DH.joinUrl([e.baseURL??"",e.url??""]);if(e.params){const n=new URLSearchParams(Object.entries(e.params).filter((([,e])=>void 0!==e)).map((([e,t])=>[e,String(t)]))).toString();n&&(t+=`?${n}`)}return t}(r),i=(r.method||"GET").toUpperCase();r.method=i,e.onRequest?.({method:i,url:ar.DH.joinUrl([r.baseURL??"",r.url??""]),headers:{...r.headers},params:r.params});let s=0;for(;s<1e5;)try{Bl(`${i} ${o}`,{headers:r.headers,params:r.params});const e=await fetch(o,r);return e.ok||await Tl(i,o,e),Ol(e,r.responseType)}catch(a){if(a instanceof $l)throw a;const t=a;if("TimeoutError"!==t.name||!e.endlesslyRetry)throw Rl(t,i,o);s++,await ar.iQ.sleepMillis(s<300?200:1e3)}throw Error("Max number of failed attempts reached")}async function Tl(e,t,n){const r=await async function(e){const t=await e.text().catch((()=>""));if(!t)return;try{return JSON.parse(t)}catch{return t}}(n),o="string"==typeof r?r:JSON.stringify(r),i=o?`${n.statusText}: ${o}`:n.statusText;throw new $l(e,t,i,r,n.status,n.statusText)}function Rl(e,t,n){if("AbortError"===e.name)return new $l(t,n,"Request aborted",void 0,void 0,"ERR_CANCELED");const r=e.cause,o=r?.message?`${e.message}: ${r.message}`:e.message;return new $l(t,n,o)}async function Ol(e,t="json"){let n;switch(t){case"arraybuffer":n=await e.arrayBuffer();break;case"text":n=await e.text();break;case"blob":n=await e.blob();break;case"stream":n=e.body;break;default:{const t=await e.text();n=t?JSON.parse(t):null}}return{data:n,status:e.status,statusText:e.statusText,headers:Object.fromEntries(e.headers.entries()),raw:e}}const Al=qu({durationSeconds:Su()});const zl=qu({reference:ou().transform((e=>new nn(e)))});class kl extends Error{constructor(e){super(e),this.name="BeeError"}}class Sl extends kl{constructor(e,t){super(e),this.value=t,this.name="BeeArgumentError"}}class $l extends kl{constructor(e,t,n,r,o,i){super(n),this.method=e,this.url=t,this.responseBody=r,this.status=o,this.statusText=i,this.name="BeeResponseError",this.response={status:o,data:r,statusText:i}}}class _l{static ZERO=new _l(0);constructor(e){this.seconds=Math.ceil(e),e<0&&(this.seconds=0)}static fromMilliseconds(e){return new _l(e/1e3)}static fromSeconds(e){return new _l(e)}static fromHours(e){return new _l(60*e*60)}static fromDays(e){return new _l(24*e*60*60)}static fromWeeks(e){return new _l(7*e*24*60*60)}static fromYears(e){return new _l(365*e*24*60*60)}static fromEndDate(e,t){return new _l((e.getTime()-(t??new Date).getTime())/1e3)}static parseFromString(e){return _l.fromSeconds(ar.AO.make(e)/1e3)}toSeconds(){return this.seconds}toHours(){return this.seconds/60/60}toDays(){return this.seconds/24/60/60}toWeeks(){return this.seconds/7/24/60/60}toYears(){return this.seconds/365/24/60/60}toEndDate(e){return new Date((e??new Date).getTime()+1e3*this.seconds)}represent(){return ar.AO.secondsToHumanTime(this.seconds)}isZero(){return 0===this.seconds}}class Il{constructor(e){if(this.bytes=Math.ceil(e),e<0)throw Error("Size must be at least 0")}static fromBytes(e){return new Il(e)}static fromKilobytes(e){return new Il(1e3*e)}static fromMegabytes(e){return new Il(1e3*e*1e3)}static fromGigabytes(e){return new Il(1e3*e*1e3*1e3)}static parseFromString(e){return Il.fromBytes(ar.FQ.makeStorage(e,1e3))}toBytes(){return this.bytes}toGigabytes(){return this.bytes/1e3/1e3/1e3}toFormattedString(){return ar.FQ.convertBytes(this.bytes,1e3)}represent(){return this.toFormattedString()}}class Dl{static DIGITS=16;constructor(e){this.state=e}static fromDecimalString(e){return new Dl(ar.ie.fromDecimalString(e,Dl.DIGITS))}static fromPLUR(e){return new Dl(new ar.ie(e,Dl.DIGITS))}static fromFloat(e){return new Dl(ar.ie.fromFloat(e,Dl.DIGITS))}toPLURString(){return this.state.toString()}toPLURBigInt(){return this.state.value}toDecimalString(){return this.state.toDecimalString()}toFloat(){return this.state.toFloat()}toSignificantDigits(e){return this.toDecimalString().slice(0,this.toDecimalString().indexOf(".")+e+1)}plus(e){return new Dl(this.state.add(e instanceof Dl?e.state:new ar.ie(e,Dl.DIGITS)))}minus(e){return new Dl(this.state.subtract(e instanceof Dl?e.state:new ar.ie(e,Dl.DIGITS)))}divide(e){return new Dl(this.state.divmod(e)[0])}gt(e){return 1===this.state.compare(e.state)}gte(e){return-1!==this.state.compare(e.state)}lt(e){return-1===this.state.compare(e.state)}lte(e){return 1!==this.state.compare(e.state)}eq(e){return 0===this.state.compare(e.state)}exchangeToDAI(e){return Vl.fromWei(this.state.exchange("*",new ar.ie(e.toWeiBigInt(),Vl.DIGITS),Vl.DIGITS).value)}}class Vl{static DIGITS=18;constructor(e){this.state=e}static fromDecimalString(e){return new Vl(ar.ie.fromDecimalString(e,Vl.DIGITS))}static fromWei(e){return new Vl(new ar.ie(e,Vl.DIGITS))}static fromFloat(e){return new Vl(ar.ie.fromFloat(e,Vl.DIGITS))}toWeiString(){return this.state.toString()}toWeiBigInt(){return this.state.value}toDecimalString(){return this.state.toDecimalString()}toSignificantDigits(e){return this.toDecimalString().slice(0,this.toDecimalString().indexOf(".")+e+1)}toFloat(){return this.state.toFloat()}plus(e){return new Vl(this.state.add(e instanceof Vl?e.state:new ar.ie(e,Vl.DIGITS)))}minus(e){return new Vl(this.state.subtract(e instanceof Vl?e.state:new ar.ie(e,Vl.DIGITS)))}divide(e){return new Vl(this.state.divmod(e)[0])}gt(e){return 1===this.state.compare(e.state)}gte(e){return-1!==this.state.compare(e.state)}lt(e){return-1===this.state.compare(e.state)}lte(e){return 1!==this.state.compare(e.state)}eq(e){return 0===this.state.compare(e.state)}exchangeToBZZ(e){return Dl.fromPLUR(this.state.exchange("/",new ar.ie(e.toWeiBigInt(),Vl.DIGITS),Dl.DIGITS).value)}}var Pl=n(320);function Cl(e){if("function"==typeof File&&e instanceof File)return!0;const t=e;return"object"==typeof t&&"string"==typeof t.name&&("function"==typeof t.stream||"function"==typeof t.arrayBuffer)}function Fl(e){return function(e,t){return new e(va({type:"number",coerce:!0,checks:[],...kr(t)}))}(ku,e)}let Nl=function(e){return e.FULL="full",e.LIGHT="light",e.ULTRA_LIGHT="ultra-light",e.DEV="dev",e}({});function Ml(e){switch(e){case"full":return Nl.FULL;case"light":return Nl.LIGHT;case"ultra-light":return Nl.ULTRA_LIGHT;case"dev":return Nl.DEV;default:throw new Error(`Unknown Bee mode: ${e}`)}}const Ul=32,Gl=128,Ll=Ul*Gl,jl=4,Zl=17,ql=255,Hl=1,Wl=1e3;let Kl=function(e){return e[e.OFF=0]="OFF",e[e.MEDIUM=1]="MEDIUM",e[e.STRONG=2]="STRONG",e[e.INSANE=3]="INSANE",e[e.PARANOID=4]="PARANOID",e}({}),Jl=function(e){return e[e.NONE=0]="NONE",e[e.DATA=1]="DATA",e[e.PROX=2]="PROX",e[e.RACE=3]="RACE",e}({});const Xl={ENCRYPTION_OFF:{[Kl.OFF]:[{theoreticalVolume:"536.87 MB",effectiveVolume:"44.70 kB",batchDepth:17,utilizationRate:"0.01%"},{theoreticalVolume:"1.07 GB",effectiveVolume:"6.66 MB",batchDepth:18,utilizationRate:"0.61%"},{theoreticalVolume:"2.15 GB",effectiveVolume:"112.06 MB",batchDepth:19,utilizationRate:"5.09%"},{theoreticalVolume:"4.29 GB",effectiveVolume:"687.62 MB",batchDepth:20,utilizationRate:"15.65%"},{theoreticalVolume:"8.59 GB",effectiveVolume:"2.60 GB",batchDepth:21,utilizationRate:"30.27%"},{theoreticalVolume:"17.18 GB",effectiveVolume:"7.73 GB",batchDepth:22,utilizationRate:"44.99%"},{theoreticalVolume:"34.36 GB",effectiveVolume:"19.94 GB",batchDepth:23,utilizationRate:"58.03%"},{theoreticalVolume:"68.72 GB",effectiveVolume:"47.06 GB",batchDepth:24,utilizationRate:"68.48%"},{theoreticalVolume:"137.44 GB",effectiveVolume:"105.51 GB",batchDepth:25,utilizationRate:"76.77%"},{theoreticalVolume:"274.88 GB",effectiveVolume:"227.98 GB",batchDepth:26,utilizationRate:"82.94%"},{theoreticalVolume:"549.76 GB",effectiveVolume:"476.68 GB",batchDepth:27,utilizationRate:"86.71%"},{theoreticalVolume:"1.10 TB",effectiveVolume:"993.65 GB",batchDepth:28,utilizationRate:"88.37%"},{theoreticalVolume:"2.20 TB",effectiveVolume:"2.04 TB",batchDepth:29,utilizationRate:"92.88%"},{theoreticalVolume:"4.40 TB",effectiveVolume:"4.17 TB",batchDepth:30,utilizationRate:"94.81%"},{theoreticalVolume:"8.80 TB",effectiveVolume:"8.45 TB",batchDepth:31,utilizationRate:"96.06%"},{theoreticalVolume:"17.59 TB",effectiveVolume:"17.07 TB",batchDepth:32,utilizationRate:"97.01%"},{theoreticalVolume:"35.18 TB",effectiveVolume:"34.36 TB",batchDepth:33,utilizationRate:"97.65%"},{theoreticalVolume:"70.37 TB",effectiveVolume:"69.04 TB",batchDepth:34,utilizationRate:"98.11%"},{theoreticalVolume:"140.74 TB",effectiveVolume:"138.54 TB",batchDepth:35,utilizationRate:"98.44%"},{theoreticalVolume:"281.47 TB",effectiveVolume:"277.72 TB",batchDepth:36,utilizationRate:"98.67%"},{theoreticalVolume:"562.95 TB",effectiveVolume:"556.35 TB",batchDepth:37,utilizationRate:"98.83%"},{theoreticalVolume:"1.13 PB",effectiveVolume:"1.11 PB",batchDepth:38,utilizationRate:"98.91%"},{theoreticalVolume:"2.25 PB",effectiveVolume:"2.23 PB",batchDepth:39,utilizationRate:"98.96%"},{theoreticalVolume:"4.50 PB",effectiveVolume:"4.46 PB",batchDepth:40,utilizationRate:"98.98%"},{theoreticalVolume:"9.01 PB",effectiveVolume:"8.93 PB",batchDepth:41,utilizationRate:"99.11%"}],[Kl.MEDIUM]:[{theoreticalVolume:"536.87 MB",effectiveVolume:"41.56 kB",batchDepth:17,utilizationRate:"0.01%"},{theoreticalVolume:"1.07 GB",effectiveVolume:"6.19 MB",batchDepth:18,utilizationRate:"0.57%"},{theoreticalVolume:"2.15 GB",effectiveVolume:"104.18 MB",batchDepth:19,utilizationRate:"4.73%"},{theoreticalVolume:"4.29 GB",effectiveVolume:"639.27 MB",batchDepth:20,utilizationRate:"14.54%"},{theoreticalVolume:"8.59 GB",effectiveVolume:"2.41 GB",batchDepth:21,utilizationRate:"28.11%"},{theoreticalVolume:"17.18 GB",effectiveVolume:"7.18 GB",batchDepth:22,utilizationRate:"41.79%"},{theoreticalVolume:"34.36 GB",effectiveVolume:"18.54 GB",batchDepth:23,utilizationRate:"53.95%"},{theoreticalVolume:"68.72 GB",effectiveVolume:"43.75 GB",batchDepth:24,utilizationRate:"63.66%"},{theoreticalVolume:"137.44 GB",effectiveVolume:"98.09 GB",batchDepth:25,utilizationRate:"71.37%"},{theoreticalVolume:"274.88 GB",effectiveVolume:"211.95 GB",batchDepth:26,utilizationRate:"77.11%"},{theoreticalVolume:"549.76 GB",effectiveVolume:"443.16 GB",batchDepth:27,utilizationRate:"80.61%"},{theoreticalVolume:"1.10 TB",effectiveVolume:"923.78 GB",batchDepth:28,utilizationRate:"82.16%"},{theoreticalVolume:"2.20 TB",effectiveVolume:"1.90 TB",batchDepth:29,utilizationRate:"86.30%"},{theoreticalVolume:"4.40 TB",effectiveVolume:"3.88 TB",batchDepth:30,utilizationRate:"88.14%"},{theoreticalVolume:"8.80 TB",effectiveVolume:"7.86 TB",batchDepth:31,utilizationRate:"89.26%"},{theoreticalVolume:"17.59 TB",effectiveVolume:"15.87 TB",batchDepth:32,utilizationRate:"90.21%"},{theoreticalVolume:"35.18 TB",effectiveVolume:"31.94 TB",batchDepth:33,utilizationRate:"90.77%"},{theoreticalVolume:"70.37 TB",effectiveVolume:"64.19 TB",batchDepth:34,utilizationRate:"91.22%"},{theoreticalVolume:"140.74 TB",effectiveVolume:"128.80 TB",batchDepth:35,utilizationRate:"91.52%"},{theoreticalVolume:"281.47 TB",effectiveVolume:"258.19 TB",batchDepth:36,utilizationRate:"91.73%"},{theoreticalVolume:"562.95 TB",effectiveVolume:"517.23 TB",batchDepth:37,utilizationRate:"91.88%"},{theoreticalVolume:"1.13 PB",effectiveVolume:"1.04 PB",batchDepth:38,utilizationRate:"91.95%"},{theoreticalVolume:"2.25 PB",effectiveVolume:"2.07 PB",batchDepth:39,utilizationRate:"92.00%"},{theoreticalVolume:"4.50 PB",effectiveVolume:"4.15 PB",batchDepth:40,utilizationRate:"92.15%"},{theoreticalVolume:"9.01 PB",effectiveVolume:"8.30 PB",batchDepth:41,utilizationRate:"92.14%"}],[Kl.STRONG]:[{theoreticalVolume:"536.87 MB",effectiveVolume:"37.37 kB",batchDepth:17,utilizationRate:"0.01%"},{theoreticalVolume:"1.07 GB",effectiveVolume:"5.57 MB",batchDepth:18,utilizationRate:"0.51%"},{theoreticalVolume:"2.15 GB",effectiveVolume:"93.68 MB",batchDepth:19,utilizationRate:"4.25%"},{theoreticalVolume:"4.29 GB",effectiveVolume:"574.81 MB",batchDepth:20,utilizationRate:"13.07%"},{theoreticalVolume:"8.59 GB",effectiveVolume:"2.17 GB",batchDepth:21,utilizationRate:"25.26%"},{theoreticalVolume:"17.18 GB",effectiveVolume:"6.46 GB",batchDepth:22,utilizationRate:"37.58%"},{theoreticalVolume:"34.36 GB",effectiveVolume:"16.67 GB",batchDepth:23,utilizationRate:"48.50%"},{theoreticalVolume:"68.72 GB",effectiveVolume:"39.34 GB",batchDepth:24,utilizationRate:"57.24%"},{theoreticalVolume:"137.44 GB",effectiveVolume:"88.20 GB",batchDepth:25,utilizationRate:"64.17%"},{theoreticalVolume:"274.88 GB",effectiveVolume:"190.58 GB",batchDepth:26,utilizationRate:"69.33%"},{theoreticalVolume:"549.76 GB",effectiveVolume:"398.47 GB",batchDepth:27,utilizationRate:"72.48%"},{theoreticalVolume:"1.10 TB",effectiveVolume:"830.63 GB",batchDepth:28,utilizationRate:"73.85%"},{theoreticalVolume:"2.20 TB",effectiveVolume:"1.71 TB",batchDepth:29,utilizationRate:"77.59%"},{theoreticalVolume:"4.40 TB",effectiveVolume:"3.49 TB",batchDepth:30,utilizationRate:"79.27%"},{theoreticalVolume:"8.80 TB",effectiveVolume:"7.07 TB",batchDepth:31,utilizationRate:"80.34%"},{theoreticalVolume:"17.59 TB",effectiveVolume:"14.27 TB",batchDepth:32,utilizationRate:"81.12%"},{theoreticalVolume:"35.18 TB",effectiveVolume:"28.72 TB",batchDepth:33,utilizationRate:"81.63%"},{theoreticalVolume:"70.37 TB",effectiveVolume:"57.71 TB",batchDepth:34,utilizationRate:"82.01%"},{theoreticalVolume:"140.74 TB",effectiveVolume:"115.81 TB",batchDepth:35,utilizationRate:"82.29%"},{theoreticalVolume:"281.47 TB",effectiveVolume:"232.16 TB",batchDepth:36,utilizationRate:"82.48%"},{theoreticalVolume:"562.95 TB",effectiveVolume:"465.07 TB",batchDepth:37,utilizationRate:"82.61%"},{theoreticalVolume:"1.13 PB",effectiveVolume:"931.23 TB",batchDepth:38,utilizationRate:"82.67%"},{theoreticalVolume:"2.25 PB",effectiveVolume:"1.86 PB",batchDepth:39,utilizationRate:"82.71%"},{theoreticalVolume:"4.50 PB",effectiveVolume:"3.73 PB",batchDepth:40,utilizationRate:"82.78%"},{theoreticalVolume:"9.01 PB",effectiveVolume:"7.46 PB",batchDepth:41,utilizationRate:"82.79%"}],[Kl.INSANE]:[{theoreticalVolume:"536.87 MB",effectiveVolume:"33.88 kB",batchDepth:17,utilizationRate:"0.01%"},{theoreticalVolume:"1.07 GB",effectiveVolume:"5.05 MB",batchDepth:18,utilizationRate:"0.46%"},{theoreticalVolume:"2.15 GB",effectiveVolume:"84.92 MB",batchDepth:19,utilizationRate:"3.86%"},{theoreticalVolume:"4.29 GB",effectiveVolume:"521.09 MB",batchDepth:20,utilizationRate:"11.85%"},{theoreticalVolume:"8.59 GB",effectiveVolume:"1.97 GB",batchDepth:21,utilizationRate:"22.90%"},{theoreticalVolume:"17.18 GB",effectiveVolume:"5.86 GB",batchDepth:22,utilizationRate:"34.09%"},{theoreticalVolume:"34.36 GB",effectiveVolume:"15.11 GB",batchDepth:23,utilizationRate:"43.97%"},{theoreticalVolume:"68.72 GB",effectiveVolume:"35.66 GB",batchDepth:24,utilizationRate:"51.90%"},{theoreticalVolume:"137.44 GB",effectiveVolume:"79.96 GB",batchDepth:25,utilizationRate:"58.18%"},{theoreticalVolume:"274.88 GB",effectiveVolume:"172.77 GB",batchDepth:26,utilizationRate:"62.85%"},{theoreticalVolume:"549.76 GB",effectiveVolume:"361.23 GB",batchDepth:27,utilizationRate:"65.70%"},{theoreticalVolume:"1.10 TB",effectiveVolume:"753.00 GB",batchDepth:28,utilizationRate:"66.95%"},{theoreticalVolume:"2.20 TB",effectiveVolume:"1.55 TB",batchDepth:29,utilizationRate:"70.38%"},{theoreticalVolume:"4.40 TB",effectiveVolume:"3.16 TB",batchDepth:30,utilizationRate:"71.92%"},{theoreticalVolume:"8.80 TB",effectiveVolume:"6.41 TB",batchDepth:31,utilizationRate:"72.85%"},{theoreticalVolume:"17.59 TB",effectiveVolume:"12.93 TB",batchDepth:32,utilizationRate:"73.53%"},{theoreticalVolume:"35.18 TB",effectiveVolume:"26.04 TB",batchDepth:33,utilizationRate:"74.01%"},{theoreticalVolume:"70.37 TB",effectiveVolume:"52.32 TB",batchDepth:34,utilizationRate:"74.35%"},{theoreticalVolume:"140.74 TB",effectiveVolume:"104.99 TB",batchDepth:35,utilizationRate:"74.60%"},{theoreticalVolume:"281.47 TB",effectiveVolume:"210.46 TB",batchDepth:36,utilizationRate:"74.77%"},{theoreticalVolume:"562.95 TB",effectiveVolume:"421.61 TB",batchDepth:37,utilizationRate:"74.89%"},{theoreticalVolume:"1.13 PB",effectiveVolume:"844.20 TB",batchDepth:38,utilizationRate:"74.94%"},{theoreticalVolume:"2.25 PB",effectiveVolume:"1.69 PB",batchDepth:39,utilizationRate:"74.98%"},{theoreticalVolume:"4.50 PB",effectiveVolume:"3.38 PB",batchDepth:40,utilizationRate:"75.03%"},{theoreticalVolume:"9.01 PB",effectiveVolume:"6.77 PB",batchDepth:41,utilizationRate:"75.10%"}],[Kl.PARANOID]:[{theoreticalVolume:"536.87 MB",effectiveVolume:"13.27 kB",batchDepth:17,utilizationRate:"0.00%"},{theoreticalVolume:"1.07 GB",effectiveVolume:"1.98 MB",batchDepth:18,utilizationRate:"0.18%"},{theoreticalVolume:"2.15 GB",effectiveVolume:"33.27 MB",batchDepth:19,utilizationRate:"1.51%"},{theoreticalVolume:"4.29 GB",effectiveVolume:"204.14 MB",batchDepth:20,utilizationRate:"4.64%"},{theoreticalVolume:"8.59 GB",effectiveVolume:"771.13 MB",batchDepth:21,utilizationRate:"8.75%"},{theoreticalVolume:"17.18 GB",effectiveVolume:"2.29 GB",batchDepth:22,utilizationRate:"13.34%"},{theoreticalVolume:"34.36 GB",effectiveVolume:"5.92 GB",batchDepth:23,utilizationRate:"17.22%"},{theoreticalVolume:"68.72 GB",effectiveVolume:"13.97 GB",batchDepth:24,utilizationRate:"20.33%"},{theoreticalVolume:"137.44 GB",effectiveVolume:"31.32 GB",batchDepth:25,utilizationRate:"22.79%"},{theoreticalVolume:"274.88 GB",effectiveVolume:"67.68 GB",batchDepth:26,utilizationRate:"24.62%"},{theoreticalVolume:"549.76 GB",effectiveVolume:"141.51 GB",batchDepth:27,utilizationRate:"25.74%"},{theoreticalVolume:"1.10 TB",effectiveVolume:"294.99 GB",batchDepth:28,utilizationRate:"26.23%"},{theoreticalVolume:"2.20 TB",effectiveVolume:"606.90 GB",batchDepth:29,utilizationRate:"27.56%"},{theoreticalVolume:"4.40 TB",effectiveVolume:"1.24 TB",batchDepth:30,utilizationRate:"28.15%"},{theoreticalVolume:"8.80 TB",effectiveVolume:"2.51 TB",batchDepth:31,utilizationRate:"28.54%"},{theoreticalVolume:"17.59 TB",effectiveVolume:"5.07 TB",batchDepth:32,utilizationRate:"28.82%"},{theoreticalVolume:"35.18 TB",effectiveVolume:"10.20 TB",batchDepth:33,utilizationRate:"28.99%"},{theoreticalVolume:"70.37 TB",effectiveVolume:"20.50 TB",batchDepth:34,utilizationRate:"29.13%"},{theoreticalVolume:"140.74 TB",effectiveVolume:"41.13 TB",batchDepth:35,utilizationRate:"29.22%"},{theoreticalVolume:"281.47 TB",effectiveVolume:"82.45 TB",batchDepth:36,utilizationRate:"29.29%"},{theoreticalVolume:"562.95 TB",effectiveVolume:"165.17 TB",batchDepth:37,utilizationRate:"29.34%"},{theoreticalVolume:"1.13 PB",effectiveVolume:"330.72 TB",batchDepth:38,utilizationRate:"29.37%"},{theoreticalVolume:"2.25 PB",effectiveVolume:"661.97 TB",batchDepth:39,utilizationRate:"29.39%"},{theoreticalVolume:"4.50 PB",effectiveVolume:"1.32 PB",batchDepth:40,utilizationRate:"29.41%"},{theoreticalVolume:"9.01 PB",effectiveVolume:"2.65 PB",batchDepth:41,utilizationRate:"29.43%"}]},ENCRYPTION_ON:{[Kl.OFF]:[{theoreticalVolume:"536.87 MB",effectiveVolume:"44.35 kB",batchDepth:17,utilizationRate:"0.01%"},{theoreticalVolume:"1.07 GB",effectiveVolume:"6.61 MB",batchDepth:18,utilizationRate:"0.60%"},{theoreticalVolume:"2.15 GB",effectiveVolume:"111.18 MB",batchDepth:19,utilizationRate:"5.05%"},{theoreticalVolume:"4.29 GB",effectiveVolume:"682.21 MB",batchDepth:20,utilizationRate:"15.52%"},{theoreticalVolume:"8.59 GB",effectiveVolume:"2.58 GB",batchDepth:21,utilizationRate:"30.04%"},{theoreticalVolume:"17.18 GB",effectiveVolume:"7.67 GB",batchDepth:22,utilizationRate:"44.62%"},{theoreticalVolume:"34.36 GB",effectiveVolume:"19.78 GB",batchDepth:23,utilizationRate:"57.56%"},{theoreticalVolume:"68.72 GB",effectiveVolume:"46.69 GB",batchDepth:24,utilizationRate:"67.93%"},{theoreticalVolume:"137.44 GB",effectiveVolume:"104.68 GB",batchDepth:25,utilizationRate:"76.16%"},{theoreticalVolume:"274.88 GB",effectiveVolume:"226.19 GB",batchDepth:26,utilizationRate:"82.29%"},{theoreticalVolume:"549.76 GB",effectiveVolume:"472.93 GB",batchDepth:27,utilizationRate:"86.02%"},{theoreticalVolume:"1.10 TB",effectiveVolume:"985.83 GB",batchDepth:28,utilizationRate:"87.66%"},{theoreticalVolume:"2.20 TB",effectiveVolume:"2.03 TB",batchDepth:29,utilizationRate:"92.25%"},{theoreticalVolume:"4.40 TB",effectiveVolume:"4.14 TB",batchDepth:30,utilizationRate:"94.21%"},{theoreticalVolume:"8.80 TB",effectiveVolume:"8.39 TB",batchDepth:31,utilizationRate:"95.37%"},{theoreticalVolume:"17.59 TB",effectiveVolume:"16.93 TB",batchDepth:32,utilizationRate:"96.22%"},{theoreticalVolume:"35.18 TB",effectiveVolume:"34.09 TB",batchDepth:33,utilizationRate:"96.88%"},{theoreticalVolume:"70.37 TB",effectiveVolume:"68.50 TB",batchDepth:34,utilizationRate:"97.34%"},{theoreticalVolume:"140.74 TB",effectiveVolume:"137.45 TB",batchDepth:35,utilizationRate:"97.67%"},{theoreticalVolume:"281.47 TB",effectiveVolume:"275.53 TB",batchDepth:36,utilizationRate:"97.89%"},{theoreticalVolume:"562.95 TB",effectiveVolume:"551.97 TB",batchDepth:37,utilizationRate:"98.05%"},{theoreticalVolume:"1.13 PB",effectiveVolume:"1.11 PB",batchDepth:38,utilizationRate:"98.13%"},{theoreticalVolume:"2.25 PB",effectiveVolume:"2.21 PB",batchDepth:39,utilizationRate:"98.18%"},{theoreticalVolume:"4.50 PB",effectiveVolume:"4.43 PB",batchDepth:40,utilizationRate:"98.36%"},{theoreticalVolume:"9.01 PB",effectiveVolume:"8.86 PB",batchDepth:41,utilizationRate:"98.37%"}],[Kl.MEDIUM]:[{theoreticalVolume:"536.87 MB",effectiveVolume:"40.89 kB",batchDepth:17,utilizationRate:"0.01%"},{theoreticalVolume:"1.07 GB",effectiveVolume:"6.09 MB",batchDepth:18,utilizationRate:"0.56%"},{theoreticalVolume:"2.15 GB",effectiveVolume:"102.49 MB",batchDepth:19,utilizationRate:"4.65%"},{theoreticalVolume:"4.29 GB",effectiveVolume:"628.91 MB",batchDepth:20,utilizationRate:"14.30%"},{theoreticalVolume:"8.59 GB",effectiveVolume:"2.38 GB",batchDepth:21,utilizationRate:"27.68%"},{theoreticalVolume:"17.18 GB",effectiveVolume:"7.07 GB",batchDepth:22,utilizationRate:"41.15%"},{theoreticalVolume:"34.36 GB",effectiveVolume:"18.24 GB",batchDepth:23,utilizationRate:"53.09%"},{theoreticalVolume:"68.72 GB",effectiveVolume:"43.04 GB",batchDepth:24,utilizationRate:"62.63%"},{theoreticalVolume:"137.44 GB",effectiveVolume:"96.50 GB",batchDepth:25,utilizationRate:"70.21%"},{theoreticalVolume:"274.88 GB",effectiveVolume:"208.52 GB",batchDepth:26,utilizationRate:"75.86%"},{theoreticalVolume:"549.76 GB",effectiveVolume:"435.98 GB",batchDepth:27,utilizationRate:"79.30%"},{theoreticalVolume:"1.10 TB",effectiveVolume:"908.81 GB",batchDepth:28,utilizationRate:"80.82%"},{theoreticalVolume:"2.20 TB",effectiveVolume:"1.87 TB",batchDepth:29,utilizationRate:"84.98%"},{theoreticalVolume:"4.40 TB",effectiveVolume:"3.81 TB",batchDepth:30,utilizationRate:"86.67%"},{theoreticalVolume:"8.80 TB",effectiveVolume:"7.73 TB",batchDepth:31,utilizationRate:"87.84%"},{theoreticalVolume:"17.59 TB",effectiveVolume:"15.61 TB",batchDepth:32,utilizationRate:"88.74%"},{theoreticalVolume:"35.18 TB",effectiveVolume:"31.43 TB",batchDepth:33,utilizationRate:"89.34%"},{theoreticalVolume:"70.37 TB",effectiveVolume:"63.15 TB",batchDepth:34,utilizationRate:"89.74%"},{theoreticalVolume:"140.74 TB",effectiveVolume:"126.71 TB",batchDepth:35,utilizationRate:"90.03%"},{theoreticalVolume:"281.47 TB",effectiveVolume:"254.01 TB",batchDepth:36,utilizationRate:"90.24%"},{theoreticalVolume:"562.95 TB",effectiveVolume:"508.85 TB",batchDepth:37,utilizationRate:"90.39%"},{theoreticalVolume:"1.13 PB",effectiveVolume:"1.02 PB",batchDepth:38,utilizationRate:"90.47%"},{theoreticalVolume:"2.25 PB",effectiveVolume:"2.04 PB",batchDepth:39,utilizationRate:"90.51%"},{theoreticalVolume:"4.50 PB",effectiveVolume:"4.08 PB",batchDepth:40,utilizationRate:"90.64%"},{theoreticalVolume:"9.01 PB",effectiveVolume:"8.17 PB",batchDepth:41,utilizationRate:"90.65%"}],[Kl.STRONG]:[{theoreticalVolume:"536.87 MB",effectiveVolume:"36.73 kB",batchDepth:17,utilizationRate:"0.01%"},{theoreticalVolume:"1.07 GB",effectiveVolume:"5.47 MB",batchDepth:18,utilizationRate:"0.50%"},{theoreticalVolume:"2.15 GB",effectiveVolume:"92.07 MB",batchDepth:19,utilizationRate:"4.18%"},{theoreticalVolume:"4.29 GB",effectiveVolume:"564.95 MB",batchDepth:20,utilizationRate:"12.85%"},{theoreticalVolume:"8.59 GB",effectiveVolume:"2.13 GB",batchDepth:21,utilizationRate:"24.86%"},{theoreticalVolume:"17.18 GB",effectiveVolume:"6.35 GB",batchDepth:22,utilizationRate:"36.97%"},{theoreticalVolume:"34.36 GB",effectiveVolume:"16.38 GB",batchDepth:23,utilizationRate:"47.67%"},{theoreticalVolume:"68.72 GB",effectiveVolume:"38.66 GB",batchDepth:24,utilizationRate:"56.26%"},{theoreticalVolume:"137.44 GB",effectiveVolume:"86.69 GB",batchDepth:25,utilizationRate:"63.07%"},{theoreticalVolume:"274.88 GB",effectiveVolume:"187.31 GB",batchDepth:26,utilizationRate:"68.14%"},{theoreticalVolume:"549.76 GB",effectiveVolume:"391.64 GB",batchDepth:27,utilizationRate:"71.24%"},{theoreticalVolume:"1.10 TB",effectiveVolume:"816.39 GB",batchDepth:28,utilizationRate:"72.59%"},{theoreticalVolume:"2.20 TB",effectiveVolume:"1.68 TB",batchDepth:29,utilizationRate:"76.34%"},{theoreticalVolume:"4.40 TB",effectiveVolume:"3.43 TB",batchDepth:30,utilizationRate:"77.89%"},{theoreticalVolume:"8.80 TB",effectiveVolume:"6.94 TB",batchDepth:31,utilizationRate:"78.86%"},{theoreticalVolume:"17.59 TB",effectiveVolume:"14.02 TB",batchDepth:32,utilizationRate:"79.71%"},{theoreticalVolume:"35.18 TB",effectiveVolume:"28.23 TB",batchDepth:33,utilizationRate:"80.23%"},{theoreticalVolume:"70.37 TB",effectiveVolume:"56.72 TB",batchDepth:34,utilizationRate:"80.60%"},{theoreticalVolume:"140.74 TB",effectiveVolume:"113.82 TB",batchDepth:35,utilizationRate:"80.88%"},{theoreticalVolume:"281.47 TB",effectiveVolume:"228.18 TB",batchDepth:36,utilizationRate:"81.06%"},{theoreticalVolume:"562.95 TB",effectiveVolume:"457.10 TB",batchDepth:37,utilizationRate:"81.20%"},{theoreticalVolume:"1.13 PB",effectiveVolume:"915.26 TB",batchDepth:38,utilizationRate:"81.26%"},{theoreticalVolume:"2.25 PB",effectiveVolume:"1.83 PB",batchDepth:39,utilizationRate:"81.30%"},{theoreticalVolume:"4.50 PB",effectiveVolume:"3.67 PB",batchDepth:40,utilizationRate:"81.43%"},{theoreticalVolume:"9.01 PB",effectiveVolume:"7.34 PB",batchDepth:41,utilizationRate:"81.45%"}],[Kl.INSANE]:[{theoreticalVolume:"536.87 MB",effectiveVolume:"33.26 kB",batchDepth:17,utilizationRate:"0.01%"},{theoreticalVolume:"1.07 GB",effectiveVolume:"4.96 MB",batchDepth:18,utilizationRate:"0.45%"},{theoreticalVolume:"2.15 GB",effectiveVolume:"83.38 MB",batchDepth:19,utilizationRate:"3.79%"},{theoreticalVolume:"4.29 GB",effectiveVolume:"511.65 MB",batchDepth:20,utilizationRate:"11.64%"},{theoreticalVolume:"8.59 GB",effectiveVolume:"1.93 GB",batchDepth:21,utilizationRate:"22.52%"},{theoreticalVolume:"17.18 GB",effectiveVolume:"5.75 GB",batchDepth:22,utilizationRate:"33.50%"},{theoreticalVolume:"34.36 GB",effectiveVolume:"14.84 GB",batchDepth:23,utilizationRate:"43.19%"},{theoreticalVolume:"68.72 GB",effectiveVolume:"35.02 GB",batchDepth:24,utilizationRate:"50.96%"},{theoreticalVolume:"137.44 GB",effectiveVolume:"78.51 GB",batchDepth:25,utilizationRate:"57.12%"},{theoreticalVolume:"274.88 GB",effectiveVolume:"169.64 GB",batchDepth:26,utilizationRate:"61.71%"},{theoreticalVolume:"549.76 GB",effectiveVolume:"354.69 GB",batchDepth:27,utilizationRate:"64.52%"},{theoreticalVolume:"1.10 TB",effectiveVolume:"739.37 GB",batchDepth:28,utilizationRate:"65.74%"},{theoreticalVolume:"2.20 TB",effectiveVolume:"1.52 TB",batchDepth:29,utilizationRate:"69.15%"},{theoreticalVolume:"4.40 TB",effectiveVolume:"3.10 TB",batchDepth:30,utilizationRate:"70.56%"},{theoreticalVolume:"8.80 TB",effectiveVolume:"6.29 TB",batchDepth:31,utilizationRate:"71.48%"},{theoreticalVolume:"17.59 TB",effectiveVolume:"12.70 TB",batchDepth:32,utilizationRate:"72.18%"},{theoreticalVolume:"35.18 TB",effectiveVolume:"25.57 TB",batchDepth:33,utilizationRate:"72.67%"},{theoreticalVolume:"70.37 TB",effectiveVolume:"51.37 TB",batchDepth:34,utilizationRate:"73.00%"},{theoreticalVolume:"140.74 TB",effectiveVolume:"103.08 TB",batchDepth:35,utilizationRate:"73.24%"},{theoreticalVolume:"281.47 TB",effectiveVolume:"206.65 TB",batchDepth:36,utilizationRate:"73.42%"},{theoreticalVolume:"562.95 TB",effectiveVolume:"413.98 TB",batchDepth:37,utilizationRate:"73.54%"},{theoreticalVolume:"1.13 PB",effectiveVolume:"828.91 TB",batchDepth:38,utilizationRate:"73.59%"},{theoreticalVolume:"2.25 PB",effectiveVolume:"1.66 PB",batchDepth:39,utilizationRate:"73.62%"},{theoreticalVolume:"4.50 PB",effectiveVolume:"3.32 PB",batchDepth:40,utilizationRate:"73.72%"},{theoreticalVolume:"9.01 PB",effectiveVolume:"6.64 PB",batchDepth:41,utilizationRate:"73.74%"}],[Kl.PARANOID]:[{theoreticalVolume:"536.87 MB",effectiveVolume:"13.17 kB",batchDepth:17,utilizationRate:"0.00%"},{theoreticalVolume:"1.07 GB",effectiveVolume:"1.96 MB",batchDepth:18,utilizationRate:"0.18%"},{theoreticalVolume:"2.15 GB",effectiveVolume:"33.01 MB",batchDepth:19,utilizationRate:"1.50%"},{theoreticalVolume:"4.29 GB",effectiveVolume:"202.53 MB",batchDepth:20,utilizationRate:"4.61%"},{theoreticalVolume:"8.59 GB",effectiveVolume:"765.05 MB",batchDepth:21,utilizationRate:"8.68%"},{theoreticalVolume:"17.18 GB",effectiveVolume:"2.28 GB",batchDepth:22,utilizationRate:"13.27%"},{theoreticalVolume:"34.36 GB",effectiveVolume:"5.87 GB",batchDepth:23,utilizationRate:"17.08%"},{theoreticalVolume:"68.72 GB",effectiveVolume:"13.86 GB",batchDepth:24,utilizationRate:"20.17%"},{theoreticalVolume:"137.44 GB",effectiveVolume:"31.08 GB",batchDepth:25,utilizationRate:"22.61%"},{theoreticalVolume:"274.88 GB",effectiveVolume:"67.15 GB",batchDepth:26,utilizationRate:"24.43%"},{theoreticalVolume:"549.76 GB",effectiveVolume:"140.40 GB",batchDepth:27,utilizationRate:"25.54%"},{theoreticalVolume:"1.10 TB",effectiveVolume:"292.67 GB",batchDepth:28,utilizationRate:"26.03%"},{theoreticalVolume:"2.20 TB",effectiveVolume:"602.12 GB",batchDepth:29,utilizationRate:"27.35%"},{theoreticalVolume:"4.40 TB",effectiveVolume:"1.23 TB",batchDepth:30,utilizationRate:"27.94%"},{theoreticalVolume:"8.80 TB",effectiveVolume:"2.49 TB",batchDepth:31,utilizationRate:"28.32%"},{theoreticalVolume:"17.59 TB",effectiveVolume:"5.03 TB",batchDepth:32,utilizationRate:"28.60%"},{theoreticalVolume:"35.18 TB",effectiveVolume:"10.12 TB",batchDepth:33,utilizationRate:"28.77%"},{theoreticalVolume:"70.37 TB",effectiveVolume:"20.34 TB",batchDepth:34,utilizationRate:"28.91%"},{theoreticalVolume:"140.74 TB",effectiveVolume:"40.80 TB",batchDepth:35,utilizationRate:"29.00%"},{theoreticalVolume:"281.47 TB",effectiveVolume:"81.80 TB",batchDepth:36,utilizationRate:"29.06%"},{theoreticalVolume:"562.95 TB",effectiveVolume:"163.87 TB",batchDepth:37,utilizationRate:"29.11%"},{theoreticalVolume:"1.13 PB",effectiveVolume:"328.11 TB",batchDepth:38,utilizationRate:"29.14%"},{theoreticalVolume:"2.25 PB",effectiveVolume:"656.76 TB",batchDepth:39,utilizationRate:"29.16%"},{theoreticalVolume:"4.50 PB",effectiveVolume:"1.31 PB",batchDepth:40,utilizationRate:"29.18%"},{theoreticalVolume:"9.01 PB",effectiveVolume:"2.63 PB",batchDepth:41,utilizationRate:"29.19%"}]}},Yl=(ou().regex(/^(?:0x)?[0-9a-fA-F]*$/i,"expected hex string").refine((e=>e.replace(/^0x/i,"").length%2==0),"expected even-length hex string"),Fu().refine((e=>{return new yl({type:"function",input:Array.isArray(t?.input)?Xu(t?.input):t?.input??ju(Mu()),output:t?.output??Mu()}).safeParse(e).success;var t}),"expected a function")),Ql=Fu().transform((e=>(Pu().safeParse(e).success&&(e=String(e)),ou().regex(/^-?\d+$/,"expected integer string").parse(e)))),ef=Fu().transform((e=>(Pu().safeParse(e).success&&(e=String(e)),ou().regex(/^\d+$/,"expected non-negative integer string").parse(e)))),tf=qu({baseURL:ou().optional(),timeout:Su().int().min(0).optional(),headers:Qu(ou(),ou()).optional(),onRequest:Yl.optional(),httpAgent:Mu().optional(),httpsAgent:Mu().optional(),endlesslyRetry:Du().optional(),signal:Fu().optional()}),nf=qu({redundancyStrategy:Su().int().optional(),fallback:Du().optional(),timeoutMs:Su().int().min(0).optional(),actPublisher:sl(Fu().transform((e=>new Kt(e)))),actHistoryAddress:sl(Fu().transform((e=>new nn(e)))),actTimestamp:Fl().optional()}),rf=qu({act:Du().optional(),actHistoryAddress:sl(Fu().transform((e=>new nn(e)))),deferred:Du().optional(),encrypt:Du().optional(),pin:Du().optional(),tag:Su().int().min(0).optional()}),of=rf.extend({redundancyLevel:Su().int().min(0).optional()}),sf=rf.extend({size:Su().int().min(0).optional(),contentType:ou().optional(),redundancyLevel:Su().int().min(0).optional()}),af=rf.extend({errorDocument:ou().optional(),indexDocument:ou().optional(),redundancyLevel:Su().int().min(0).optional()}),cf=qu({uid:Su().int()}),uf=Fl().min(0),lf=qu({onMessage:Yl,onError:Yl,onClose:Yl}),ff=qu({onMessage:Yl,onError:Yl,onClose:Yl}),hf=qu({fields:ju(tl(["address","recoveredPubKey","identifier","signature","wrappedAddress","span","payload"])).nonempty().optional(),cacheWrappedChunk:Du().optional()}),df=qu({gasPrice:Ql.optional(),immutableFlag:Du().optional(),label:ou().optional(),waitForUsable:Du().optional(),waitForUsableTimeout:Su().int().min(0).optional()}),pf=qu({gasLimit:ef.optional(),gasPrice:ef.optional()}),mf=qu({limit:Su().int().min(Hl).max(Wl).optional(),offset:Su().int().min(0).optional()});function gf(e){return void 0!==Pl.Readable&&e instanceof Pl.Readable}function yf(e,t){if("bigint"==typeof e&&(e=e.toString()),"string"!=typeof e||!/^-?\d+$/.test(e))throw new TypeError(`${t?.name??"value"} is not a valid integer string, got: ${e}`);if(void 0!==t?.min&&BigInt(e)<t.min)throw new RangeError(`${t?.name??"value"} must be >= ${t.min}, got: ${e}`);if(void 0!==t?.max&&BigInt(e)>t.max)throw new RangeError(`${t?.name??"value"} must be <= ${t.max}, got: ${e}`);return e}function wf(e){if(!("string"==typeof e||e instanceof Uint8Array||e instanceof Blob||gf(e)))throw new TypeError("Data must be either string, Uint8Array, Blob or Readable!")}function bf(e){if(null==e)throw new TypeError(`Expected number | Tag | string from tagUid, got: ${e}`);if(t=e,cf.safeParse(t).success)return e.uid;if("number"==typeof e||"string"==typeof e)return uf.parse(e);var t;throw new TypeError(`Expected number | Tag | string from tagUid, got: ${e}`)}function vf(e,t){return Dl.fromPLUR(2n**BigInt(e)*BigInt(t))}function Bf(e,t,n){const r=BigInt(yf(e));return _l.fromSeconds(Number(r*BigInt(n)/BigInt(t)))}function Ef(e,t,n){return BigInt(e.toSeconds())/BigInt(n)*BigInt(t)+1n}function xf(e,t,n){return function(e,t,n){if(void 0!==t&&void 0!==n){const r=(t?nr:tr)[n],o=r?.find((([,t])=>e<=Qn(t)));if(o)return o[0]}else for(const[r,o]of er)if(e<=Qn(o))return r;return 35}(e.toBytes(),t,n)}function Tf(e){return ir(e)}function Rf(e,t,n){const r=function(e){return Number.isInteger(e)?e<1?1:e>3155695200?3155695200:e:1}(e.batchTTL),o=_l.fromSeconds(r),i=rr(e.depth,t,n),s=e.utilizationRatio??Jn(e.utilization,e.depth,e.bucketDepth);return{batchID:new Ct(e.batchID),utilization:e.utilization,usable:e.usable,label:e.label,depth:e.depth,amount:yf(e.amount),bucketDepth:e.bucketDepth,blockNumber:e.blockNumber,immutableFlag:e.immutableFlag,usage:s,usageText:`${Math.round(100*s)}%`,size:Il.fromBytes(i),remainingSize:Il.fromBytes(Math.ceil(i*(1-s))),theoreticalSize:Il.fromBytes(Xn(e.depth)),duration:o,calculateSize(t,n){const r=rr(e.depth,t,n);return Il.fromBytes(r)},calculateRemainingSize(t,n){const r=rr(e.depth,t,n);return Il.fromBytes(Math.ceil(r*(1-this.usage)))}}}function Of(e){return{batchID:e.batchID.toHex(),utilization:e.utilization,utilizationRatio:e.usage,usable:e.usable,label:e.label,depth:e.depth,amount:e.amount,bucketDepth:e.bucketDepth,blockNumber:e.blockNumber,immutableFlag:e.immutableFlag,batchTTL:e.duration.toSeconds()}}function Af(e){return{name:function(e){if(!e)throw new kl("missing content-disposition header");const t=e.match(/filename\*?=['"]?(?:UTF-\d['"]*)?([^;\r\n"']*)['"]?;?/i);if(t&&t.length>0)return t[1];throw new kl("invalid content-disposition header")}(e["content-disposition"]),tagUid:function(e){if(!e)return;return parseInt(e,10)}(e["swarm-tag-uid"]),contentType:e["content-type"]||void 0}}function zf(e,t){const n={};if(!function(e){if(!qu({}).safeParse(e).success)return!1;const t=e;return void 0!==t.issuer&&void 0!==t.index&&void 0!==t.signature&&void 0!==t.timestamp&&void 0!==t.batchId}(e)?e&&(e=new Ct(e),n["swarm-postage-batch-id"]=e.toHex()):n["swarm-postage-stamp"]=Tf(e).toHex(),!t)return n;const r=t;r.size&&(n["content-length"]=String(r.size)),r.contentType&&(n["content-type"]=String(r.contentType)),r.redundancyLevel&&(n["swarm-redundancy-level"]=String(r.redundancyLevel));const o=Du().safeParse(r.act);o.success&&(n["swarm-act"]=String(o.data));const i=Du().safeParse(r.pin);i.success&&(n["swarm-pin"]=String(i.data));const s=Du().safeParse(r.encrypt);s.success&&(n["swarm-encrypt"]=String(s.data)),r.tag&&(n["swarm-tag"]=String(r.tag));const a=Du().safeParse(r.deferred);a.success&&(n["swarm-deferred-upload"]=String(a.data)),r.redundancyStrategy&&(n["swarm-redundancy-strategy"]=String(r.redundancyStrategy));const c=Du().safeParse(r.fallback);return c.success&&(n["swarm-redundancy-fallback-mode"]=String(c.data)),r.timeoutMs&&(n["swarm-chunk-retrieval-timeout"]=String(r.timeoutMs)),r.indexDocument&&(n["swarm-index-document"]=String(r.indexDocument)),r.errorDocument&&(n["swarm-error-document"]=String(r.errorDocument)),r.actPublisher&&(n["swarm-act-publisher"]=new Kt(r.actPublisher).toCompressedHex()),r.actHistoryAddress&&(n["swarm-act-history-address"]=new nn(r.actHistoryAddress).toHex()),r.actTimestamp&&(n["swarm-act-timestamp"]=String(r.actTimestamp)),(r.actPublisher||r.actHistoryAddress||r.actTimestamp)&&(n["swarm-act"]="true"),r.gasPrice&&(n["gas-price"]=String(r.gasPrice)),r.gasLimit&&(n["gas-limit"]=String(r.gasLimit)),n}const kf="chunks";async function Sf(e,t,n){t=new nn(t);const r=await xl(e,{responseType:"arraybuffer",url:`${kf}/${t}`,headers:zf(null,n)});return new Uint8Array(r.data)}function $f(e,t){try{return xn(e,t)}catch(n){throw new kl(n.message)}}async function _f(e,t,n,r){const o=Pt.concat(t.span.toUint8Array(),t.payload.toUint8Array());return async function(e,t,n,r,o,i,s){const a=await xl(e,{method:"post",url:`soc/${t}/${n}`,data:o,headers:{"content-type":"application/octet-stream",...zf(i,s)},responseType:"json",params:{sig:r.toHex()}});return{reference:zl.parse(a.data).reference,tagUid:a.headers["swarm-tag"]?bf(a.headers["swarm-tag"]):void 0,historyAddress:a.headers["swarm-act-history-address"]?ar.Xx.of(new nn(a.headers["swarm-act-history-address"])):ar.Xx.empty()}}(e,t.owner,t.identifier,t.signature,o,n,r)}async function If(e,t,n,r,o,i){t=new en(t),r=new Zt(r);return _f(e,Tn(o).toSingleOwnerChunk(r,t),n,i)}async function Df(e,t,n,r,o,i){t=new en(t),r=new Zt(r);return _f(e,o.toSingleOwnerChunk(r,t),n,i)}async function Vf(e,t,n){const r=Bn(n=new Zt(n),t=new Ut(t));return $f(await Sf(e,r.toHex()),r)}const Pf=qu({peer:ou(),balance:ou().transform((e=>Dl.fromPLUR(yf(e,{name:"balance"}))))}),Cf=qu({balances:ju(Pf)}),Ff=Pf,Nf="balances";const Mf="consumed";class Uf{constructor(e){this.context=e}async getAll(e){return async function(e){const t=await xl(e,{url:Nf,responseType:"json"});return Cf.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async getPeer(e,t){const n=new qt(e);return async function(e,t){const n=await xl(e,{url:`${Nf}/${t}`,responseType:"json"});return Ff.parse(n.data)}(this.context.getRequestOptionsForCall(t),n)}async getAllPastDueConsumption(e){return async function(e){const t=await xl(e,{url:Mf,responseType:"json"});return Cf.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async getAllPastDueConsumptionForPeer(e,t){const n=new qt(e);return async function(e,t){const n=await xl(e,{url:`${Mf}/${t}`,responseType:"json"});return Ff.parse(n.data)}(this.context.getRequestOptionsForCall(t),n)}}const Gf=qu({beneficiary:ou().transform((e=>new Ut(e))),chequebook:ou().transform((e=>new Ut(e))),payout:ou().transform((e=>Dl.fromPLUR(yf(e,{name:"payout"}))))}),Lf=qu({recipient:ou(),lastPayout:ou().transform((e=>Dl.fromPLUR(yf(e,{name:"lastPayout"})))),bounced:Du()}),jf=qu({chequebookAddress:ou().transform((e=>new Ut(e)))}),Zf=qu({availableBalance:ou().transform((e=>Dl.fromPLUR(yf(e,{name:"availableBalance"})))),totalBalance:ou().transform((e=>Dl.fromPLUR(yf(e,{name:"totalBalance"}))))}),qf=qu({peer:ou(),uncashedAmount:ou().transform((e=>Dl.fromPLUR(yf(e,{name:"uncashedAmount"})))),transactionHash:ou().nullish().transform((e=>e??null)),lastCashedCheque:Gf.nullish().transform((e=>e??null)),result:Lf.nullish().transform((e=>e??null))}),Hf=qu({peer:ou(),lastreceived:Gf.nullish().transform((e=>e??null)),lastsent:Gf.nullish().transform((e=>e??null))}),Wf=qu({lastcheques:ju(qu({peer:ou(),lastreceived:Gf.nullish().transform((e=>e??null)),lastsent:Gf.nullish().transform((e=>e??null))}))}),Kf=qu({transactionHash:ou().transform((e=>new an(e)))}),Jf="chequebook";class Xf{constructor(e){this.context=e}async getAllLatest(e){return async function(e){const t=await xl(e,{url:`${Jf}/cheque`,responseType:"json"});return Wf.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async getAllLatestForPeer(e,t){const n=new qt(e);return async function(e,t){const n=await xl(e,{url:`${Jf}/cheque/${t}`,responseType:"json"});return Hf.parse(n.data)}(this.context.getRequestOptionsForCall(t),n)}async getLastCashoutAction(e,t){const n=new qt(e);return async function(e,t){const n=await xl(e,{url:`${Jf}/cashout/${t}`,responseType:"json"});return qf.parse(n.data)}(this.context.getRequestOptionsForCall(t),n)}async cashoutLast(e,t,n){const r=new qt(e);return t&&(t=pf.parse(t)),async function(e,t,n){const r=await xl(e,{method:"post",url:`${Jf}/cashout/${t}`,responseType:"json",headers:zf(null,n)});return Kf.parse(r.data).transactionHash}(this.context.getRequestOptionsForCall(n),r,t)}}class Yf{constructor(e){this.context=e}async getAddress(e){return async function(e){const t=await xl(e,{url:`${Jf}/address`,responseType:"json"});return jf.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async getBalance(e){return async function(e){const t=await xl(e,{url:`${Jf}/balance`,responseType:"json"});return Zf.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async deposit(e,t,n){const r=e instanceof Dl?e.toPLURString():yf(e,{min:1n,name:"amount"}),o=t?yf(t,{min:0n,name:"gasPrice"}):void 0;return async function(e,t,n){const r={};n&&(r["gas-price"]=n);const o=await xl(e,{method:"post",url:`${Jf}/deposit`,responseType:"json",params:{amount:t},headers:r});return Kf.parse(o.data).transactionHash}(this.context.getRequestOptionsForCall(n),r,o)}async withdraw(e,t,n){const r=e instanceof Dl?e.toPLURString():yf(e,{min:1n,name:"amount"}),o=t?yf(t,{min:0n,name:"gasPrice"}):void 0;return async function(e,t,n){const r={};n&&(r["gas-price"]=n);const o=await xl(e,{method:"post",url:`${Jf}/withdraw`,responseType:"json",params:{amount:t},headers:r});return Kf.parse(o.data).transactionHash}(this.context.getRequestOptionsForCall(n),r,o)}}class Qf{constructor(e){this.context=e}async upload(e,t,n,r){const o="identifier"in t&&"signature"in t&&"owner"in t;if(t=t instanceof Uint8Array?t:t.data,n&&(n=rf.parse(n)),t.length<rn.LENGTH)throw new Sl(`Chunk has to have size of at least ${rn.LENGTH}.`,t);if(!o&&t.length>Ll+rn.LENGTH)throw new Sl(`Content Addressed Chunk must not exceed ${Ll+rn.LENGTH} bytes.`,t);if(o&&t.length>Ll+rn.LENGTH+Qt.LENGTH+Zt.LENGTH)throw new Sl(`Single Owner Chunk must not exceed ${Ll+rn.LENGTH+Qt.LENGTH+Zt.LENGTH} bytes.`,t);return async function(e,t,n,r){const o=await xl(e,{method:"post",url:`${kf}`,data:t,headers:{"content-type":"application/octet-stream",...zf(n,r)},responseType:"json"});return{reference:zl.parse(o.data).reference,tagUid:o.headers["swarm-tag"]?bf(o.headers["swarm-tag"]):void 0,historyAddress:o.headers["swarm-act-history-address"]?ar.Xx.of(new nn(o.headers["swarm-act-history-address"])):ar.Xx.empty()}}(this.context.getRequestOptionsForCall(r),t,e,n)}async download(e,t,n){const r=new nn(e);return t&&(t=nf.parse(t)),Sf(this.context.getRequestOptionsForCall(n),r,t)}}var eh=n(497),th=n.n(eh);async function nh(e,t,n,r,o){for(const s of e.forks.values()){const e=await nh(s.node,t,n,r,o);if(r?.act){let t;e.historyAddress.ifPresent((e=>t=e)),t&&(s.node.metadata||(s.node.metadata={}),s.node.metadata["swarm-act-history-address"]=t.toHex())}}const i=await t.data.upload(n,await e.marshal(),r,o);return e.selfAddress=i.reference.toUint8Array(),i}async function rh(e,t,n,r){for(const o of e.forks.values()){if(!o.node.selfAddress)throw Error("MantarayNode#loadRecursively fork.node.selfAddress is not set");let i=n;o.node.metadata&&o.node.metadata["swarm-act-history-address"]&&(i={...n,actHistoryAddress:o.node.metadata["swarm-act-history-address"]});const s=(await t.data.download(o.node.selfAddress,i,r)).toUint8Array();o.node.hydrate(s),o.node.path=o.prefix,o.node.parent=e,await rh(o.node,t,n,r)}}class oh{constructor(e=new qn){this.core=e}get obfuscationKey(){return this.core.obfuscationKey}get selfAddress(){return this.core.selfAddress}get targetAddress(){return this.core.targetAddress}get metadata(){return this.core.metadata}get path(){return this.core.path}get forks(){return this.core.forks}get parent(){return this.core.parent}get type(){return this.core.type}get fullPath(){return this.core.fullPath}get fullPathString(){return this.core.fullPathString}getRootMetadata(){const e=this.core.find("/");return e&&e.metadata?ar.Xx.of(e.metadata):ar.Xx.empty()}getDocsMetadata(){const e=this.core.find("/");return e&&e.metadata?{indexDocument:e.metadata["website-index-document"]??null,errorDocument:e.metadata["website-error-document"]??null}:{indexDocument:null,errorDocument:null}}async resolveFeed(e,t){const n=this.core.find("/");if(!n||!n.metadata)return ar.Xx.empty();const r=n.metadata["swarm-feed-owner"],o=n.metadata["swarm-feed-topic"];return r&&o?ar.Xx.of(await e.feed.fetchLatestUpdate(o,r,t)):ar.Xx.empty()}async marshal(){return this.core.marshal()}static async unmarshal(e,t,n,r){t=new nn(t);const o=(await e.data.download(t,n,r)).toUint8Array();return this.unmarshalFromData(o,t.toUint8Array())}static unmarshalFromData(e,t){return new oh(qn.unmarshalFromData(e,t))}addFork(e,t,n){this.core.addFork(e,t instanceof Pt?t.toUint8Array():t,n)}removeFork(e){this.core.removeFork(e)}async calculateSelfAddress(){return this.core.calculateSelfAddress()}async saveRecursively(e,t,n,r){return nh(this.core,e,t,n,r)}async loadRecursively(e,t,n){return rh(this.core,e,t,n)}find(e){return this.core.find(e)}findClosest(e,t){return this.core.findClosest(e,t)}collect(e=[]){return this.core.collect(e)}collectAndMap(){return this.core.collectAndMap()}determineType(){return this.core.determineType()}}var ih=n(61),sh=n.n(ih);async function ah(e){if("string"!=typeof e)throw new TypeError("dir has to be string!");if(""===e)throw new TypeError("dir must not be empty string!");return ch(e,"")}async function ch(e,t){const n=sh().join(e,t),r=await th().promises.opendir(n);let o=[];for await(const i of r){const n=sh().join(e,t,i.name),r=sh().join(t,i.name);i.isFile()?o.push({path:r,size:(await th().promises.stat(n)).size,fsPath:n}):i.isDirectory()&&(o=[...await ch(e,r),...o])}return o}async function uh(e){if("string"!=typeof e)throw new TypeError("dir has to be string!");if(""===e)throw new TypeError("dir must not be empty string!");const t=await th().promises.opendir(e);let n=0;for await(const r of t)if(r.isFile()){n+=(await th().promises.stat(sh().join(e,r.name))).size}else r.isDirectory()&&(n+=await uh(sh().join(e,r.name)));return n}const lh={aac:"audio/aac",abw:"application/x-abiword",ai:"application/postscript",arc:"application/octet-stream",avi:"video/x-msvideo",azw:"application/vnd.amazon.ebook",bin:"application/octet-stream",bz:"application/x-bzip",bz2:"application/x-bzip2",csh:"application/x-csh",css:"text/css",csv:"text/csv",doc:"application/msword",dll:"application/octet-stream",dmg:"application/x-apple-diskimage",eot:"application/vnd.ms-fontobject",epub:"application/epub+zip",gif:"image/gif",htm:"text/html",html:"text/html",ico:"image/x-icon",ics:"text/calendar",jar:"application/java-archive",jpeg:"image/jpeg",jpg:"image/jpeg",js:"application/javascript",json:"application/json",mid:"audio/midi",midi:"audio/midi",mp2:"audio/mpeg",mp3:"audio/mpeg",mp4:"video/mp4",mpa:"video/mpeg",mpe:"video/mpeg",mpeg:"video/mpeg",mpkg:"application/vnd.apple.installer+xml",odp:"application/vnd.oasis.opendocument.presentation",ods:"application/vnd.oasis.opendocument.spreadsheet",odt:"application/vnd.oasis.opendocument.text",oga:"audio/ogg",ogv:"video/ogg",ogx:"application/ogg",otf:"font/otf",png:"image/png",pdf:"application/pdf",ppt:"application/vnd.ms-powerpoint",rar:"application/x-rar-compressed",rtf:"application/rtf",sh:"application/x-sh",svg:"image/svg+xml",swf:"application/x-shockwave-flash",tar:"application/x-tar",tif:"image/tiff",tiff:"image/tiff",ts:"application/typescript",ttf:"font/ttf",txt:"text/plain",vsd:"application/vnd.visio",wav:"audio/x-wav",weba:"audio/webm",webm:"video/webm",webp:"image/webp",woff:"font/woff",woff2:"font/woff2",xhtml:"application/xhtml+xml",xls:"application/vnd.ms-excel",xlsx:"application/vnd.ms-excel",xml:"application/xml",xul:"application/vnd.mozilla.xul+xml",zip:"application/zip","3gp":"video/3gpp","3gp2":"video/3gpp2","7z":"application/x-7z-compressed"};function fh(e){return["text/html","text/css"].includes(e)?`${e}; charset=utf-8`:e}function hh(e){if(!function(e){return!!Array.isArray(e)&&e.every((e=>"object"==typeof e&&e.path&&void 0!==e.size))}(e))throw new Sl("invalid collection",e)}function dh(e){if(e.webkitRelativePath&&""!==e.webkitRelativePath)return e.webkitRelativePath.replace(/.*?\//i,"");if(e.name)return e.name;throw new TypeError("file is not valid File object")}function ph(e){return Array.from(e).map((e=>({path:dh(e),size:e.size,file:e})))}function mh(e){return Array.from(e).reduce(((e,t)=>e+t.size),0)}class gh{output=new Pl.PassThrough;currentFileSize=0;beginFile(e,t){const{name:n,prefix:r,longLink:o}=function(e){if(e.length<=100)return{name:e,prefix:"",longLink:!1};for(let r=e.length-1;r>=0;r--)if("/"===e[r]){const t=e.substring(r+1),n=e.substring(0,r);if(t.length<=100&&n.length<=155)return{name:t,prefix:n,longLink:!1}}const t=e.lastIndexOf("/"),n=(t>=0?e.substring(t+1):e).slice(0,100);return{name:n,prefix:"",longLink:!0}}(e);if(o){const t=Buffer.from(e+"\0");this.output.write(function(e){const t=Buffer.alloc(512,0);t.write("././@LongLink",0,100),t.write("0000644\0",100,8),t.write("0000000\0",108,8),t.write("0000000\0",116,8),t.write(e.toString(8).padStart(11,"0")+"\0",124,12),t.write("00000000000\0",136,12),t.write(" ",148,8),t.write("L",156,1),t.write("ustar\0\0",257,8);let n=0;for(let r=0;r<512;r++)n+=t[r];return t.write(n.toString(8).padStart(6,"0")+"\0 ",148,8),t}(t.length)),this.output.write(t);const n=t.length%512==0?0:512-t.length%512;n>0&&this.output.write(Buffer.alloc(n,0))}const i=function(e,t,n){const r=Buffer.alloc(512,0);r.write(e.slice(0,100).padEnd(100,"\0"),0,100),r.write("0000777\0",100,8),r.write("0001750\0",108,8),r.write("0001750\0",116,8),r.write(n.toString(8).padStart(11,"0")+"\0",124,12);const o=Math.floor((new Date).getTime()/1e3);r.write(o.toString(8).padStart(11,"0")+"\0",136,12),r.write(" ",148,8),r.write("0",156,1),r.write("ustar\0\0",257,8),t&&r.write(t.slice(0,155).padEnd(155,"\0"),345,155);let i=0;for(let s=0;s<512;s++)i+=r[s];return r.write(i.toString(8).padStart(6,"0")+"\0 ",148,8),r}(n,r,t);this.output.write(i),this.currentFileSize=0}async appendFile(e){return new Promise((t=>{this.output.write(e)?t():this.output.once("drain",(()=>{t()})),this.currentFileSize+=e.length}))}async endFile(){const e=this.currentFileSize%512==0?0:512-this.currentFileSize%512;e>0&&this.output.write(Buffer.alloc(e,0))}async end(){return new Promise((e=>{this.output.write(Buffer.alloc(1024,0)),this.output.end((()=>{e()}))}))}}async function yh(e,t,n,r){const o=new gh,i=xl(e,{method:"post",url:"bzz",data:o.output,responseType:"json",headers:{"content-type":"application/x-tar","swarm-collection":"true",...zf(n,r)}});await async function(e,t){for(const n of e)if(t.beginFile(n.path,n.size),n.fsPath){const e=(0,eh.createReadStream)(n.fsPath);for await(const n of e)await t.appendFile(n);await t.endFile(),e.close()}else{if(!n.file)throw new Error("Invalid collection item");await t.appendFile(new Uint8Array(await n.file.arrayBuffer())),await t.endFile()}}(t,o),await o.end();return await i}const wh="bzz";async function bh(e,t,n,r,o){gf(t)&&!o?.contentType&&(o||(o={}),o.contentType="application/octet-stream");const i=await xl(e,{method:"post",url:wh,data:t,headers:zf(n,o),params:{name:r},responseType:"json"});return{reference:zl.parse(i.data).reference,tagUid:i.headers["swarm-tag"]?bf(i.headers["swarm-tag"]):void 0,historyAddress:i.headers["swarm-act-history-address"]?ar.Xx.of(new nn(i.headers["swarm-act-history-address"])):ar.Xx.empty()}}async function vh(e,t,n,r){hh(t);const o=await yh(e,t,n,r);return{reference:zl.parse(o.data).reference,tagUid:o.headers["swarm-tag"]?bf(o.headers["swarm-tag"]):void 0,historyAddress:o.headers["swarm-act-history-address"]?ar.Xx.of(new nn(o.headers["swarm-act-history-address"])):ar.Xx.empty()}}class Bh{constructor(e){this.context=e}async upload(e,t,n,r){const o=new Ct(e);return hh(t),n&&(n=af.parse(n)),vh(this.context.getRequestOptionsForCall(r),t,o,n)}async uploadFromFileList(e,t,n,r){const o=new Ct(e);n&&(n=af.parse(n));const i=ph(t);return vh(this.context.getRequestOptionsForCall(r),i,o,n)}async uploadFromDirectory(e,t,n,r){const o=new Ct(e);n&&(n=af.parse(n));const i=await ah(t);return vh(this.context.getRequestOptionsForCall(r),i,o,n)}async stream(e,t,n,r,o){new Ct(e);return async function(){throw new Error("Streaming files is not supported in Node.js")}(this.context.bee,0,0,0,0,this.context.getRequestOptionsForCall(o))}async streamFromDirectory(e,t,n,r,o){const i=new Ct(e);return async function(e,t,n,r,o,i){const s=new ar.O3(64,64);let a=0,c=0;n=new Ct(n);const u=await ah(t);for(const m of u)a+=(l=m.size,function e(t){return t<=1?t:t+e(Math.ceil(t/128))}(Math.ceil(l/4096)));var l;let f=!1;async function h(t){await e.chunk.upload(n,t.build(),o,i),r?.({total:a,processed:++c})}async function d(e){for(const{chunk:t}of e)await s.enqueue((async()=>h(t)));return[]}const p=new oh;for(const m of u){if(!m.fsPath)throw Error("File does not have fsPath, which should never happen in node. Please report this issue.");const e=(0,eh.createReadStream)(m.fsPath),t=new An(d);for await(const i of e)await t.append(i);const n=await t.finalize();await s.enqueue((async()=>h(n))),await s.drain();const{filename:r,extension:o}=ar.DH.parseFilename(m.path);p.addFork(m.path,n.hash(),{"Content-Type":fh(lh[o.toLowerCase()]||"application/octet-stream"),Filename:r}),"index.html"===m.path&&(f=!0)}if(f||o?.indexDocument||o?.errorDocument){const e={};o?.indexDocument?e["website-index-document"]=o.indexDocument:f&&(e["website-index-document"]="index.html"),o?.errorDocument&&(e["website-error-document"]=o.errorDocument),p.addFork("/",Tp,e)}return p.saveRecursively(e,n,o,i)}(this.context.bee,t,i,n,r,this.context.getRequestOptionsForCall(o))}async hashDirectory(e){return async function(e){const t=await ah(e),n=new oh;for(const r of t){const e=new An(An.NOOP);if(!r.fsPath)throw Error("File does not have fsPath, which should never happen in node. Please report this issue.");const t=(0,eh.createReadStream)(r.fsPath);for await(const n of t)await e.append(n);const o=await e.finalize(),{filename:i,extension:s}=ar.DH.parseFilename(r.path);n.addFork(r.path,o.hash(),{"Content-Type":fh(lh[s.toLowerCase()]||"application/octet-stream"),Filename:i})}return n.calculateSelfAddress()}(e)}}const Eh=qu({address:ou(),fullNode:Du()}),xh=qu({population:Su(),connected:Su(),connectedPeers:ju(qu({address:ou()})).nullish().transform((e=>e??[])),disconnectedPeers:ju(qu({address:ou()})).nullish().transform((e=>e??[]))}),Th=Qu(ou(),xh),Rh=qu({overlay:ou().transform((e=>new qt(e))),underlay:ju(ou()),ethereum:ou().transform((e=>new Ut(e))),publicKey:ou().transform((e=>new Kt(e))),pssPublicKey:ou().transform((e=>new Kt(e)))}),Oh=qu({peers:ju(Eh)}),Ah=qu({peers:ju(Eh)}),zh=qu({baseAddr:ou(),population:Su(),connected:Su(),timestamp:ou(),nnLowWatermark:Su(),depth:Su(),reachability:ou(),networkAvailability:ou(),bins:Th}),kh=qu({overlay:ou(),proximity:Su(),beeMode:ou().transform(Ml),reserveSize:Su(),reserveSizeWithinRadius:Su(),pullsyncRate:Su(),storageRadius:Su(),connectedPeers:Su(),neighborhoodSize:Su(),batchCommitment:Su(),isReachable:Du(),lastSyncedBlock:Su(),committedDepth:Su(),isWarmingUp:Du()}),Sh=qu({apiVersion:ou(),version:ou(),status:($h="ok",new nl({type:"literal",values:Array.isArray($h)?$h:[$h],...kr(_h)}))});var $h,_h;const Ih=qu({apiVersion:ou(),version:ou(),status:tl(["ready","notReady"])}),Dh=qu({beeMode:ou().transform(Ml),chequebookEnabled:Du(),swapEnabled:Du()}),Vh=qu({gateway:Du()}),Ph="peers";class Ch{constructor(e){this.context=e}async checkConnection(e){return async function(e){await xl(e,{url:"",responseType:"text"})}(this.context.getRequestOptionsForCall(e))}async isConnected(e){try{await this.checkConnection(e)}catch{return!1}return!0}async isGateway(e){try{return await async function(e){const t=await xl(e,{url:"/gateway"});return Vh.parse(t.data).gateway}(this.context.getRequestOptionsForCall(e))}catch{return!1}}async getNodeAddresses(e){return async function(e){const t=await xl(e,{url:"addresses",responseType:"json"});return Rh.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async getBlocklist(e){return async function(e){const t=await xl(e,{url:"blocklist",responseType:"json"});return Ah.parse(t.data).peers}(this.context.getRequestOptionsForCall(e))}async getPeers(e){return async function(e){const t=await xl(e,{url:Ph,responseType:"json"});return Oh.parse(t.data).peers}(this.context.getRequestOptionsForCall(e))}async removePeer(e,t){const n=new qt(e);return async function(e,t){return(await xl(e,{url:`${Ph}/${t}`,responseType:"json",method:"DELETE"})).data}(this.context.getRequestOptionsForCall(t),n)}async getTopology(e){return async function(e){const t=await xl(e,{url:"topology",responseType:"json"});return zh.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async ping(e,t){const n=new qt(e);return async function(e,t){return(await xl(e,{url:`pingpong/${t}`,responseType:"json",method:"POST"})).data}(this.context.getRequestOptionsForCall(t),n)}}const Fh="bytes";async function Nh(e,t,n,r){const o=await xl(e,{url:Fh,method:"post",responseType:"json",data:t,headers:{"content-type":"application/octet-stream",...zf(n,r)}});return{reference:zl.parse(o.data).reference,tagUid:o.headers["swarm-tag"]?bf(o.headers["swarm-tag"]):void 0,historyAddress:o.headers["swarm-act-history-address"]?ar.Xx.of(new nn(o.headers["swarm-act-history-address"])):ar.Xx.empty()}}async function Mh(e,t,n){n&&(n=nf.parse(n));const r=await xl(e,{responseType:"arraybuffer",url:`${Fh}/${t}`,headers:zf(null,n)});return new Pt(r.data)}const Uh=qu({isRetrievable:Du()}),Gh="stewardship";class Lh{constructor(e){this.raw=e}toString(){const e=ou().safeParse(this.raw);return e.success&&e.data.includes(".eth")?e.data:new nn(this.raw).toHex()}}class jh{constructor(e){this.context=e}async upload(e,t,n,r){const o=new Ct(e);return wf(t),n&&(n=of.parse(n)),Nh(this.context.getRequestOptionsForCall(r),t,o,n)}async download(e,t,n){return t&&(t=nf.parse(t)),Mh(this.context.getRequestOptionsForCall(n),new Lh(e),t)}async downloadReadable(e,t,n){return t&&(t=nf.parse(t)),async function(e,t,n){return n&&(n=nf.parse(n)),(await xl(e,{responseType:"stream",url:`${Fh}/${t}`,headers:zf(null,n)})).data}(this.context.getRequestOptionsForCall(n),new Lh(e),t)}async probe(e,t){const n=new nn(e);return async function(e,t){const n=await xl(e,{url:`${Fh}/${t}`,method:"head",responseType:"json"});return{contentLength:parseInt(n.headers["content-length"])}}(this.context.getRequestOptionsForCall(t),n)}async isRetrievable(e,t){const n=new nn(e);return async function(e,t){const n=await xl(e,{method:"get",responseType:"json",url:`${Gh}/${t}`});return Uh.parse(n.data).isRetrievable}(this.context.getRequestOptionsForCall(t),n)}}const Zh="feeds";function qh(e){const t=e["swarm-feed-index"],n=e["swarm-feed-index-next"];if(!t)throw new kl("Response did not contain expected swarm-feed-index!");if(!n)throw new kl("Response did not contain expected swarm-feed-index-next!");return{feedIndex:new Lt(t),feedIndexNext:new Lt(n)}}async function Hh(e,t,n,r){const o=await xl(e,{responseType:"arraybuffer",url:`${Zh}/${t}/${n}`,params:{...r}});return{payload:new Pt(o.data),...qh(o.headers)}}async function Wh(e,t,n){return qh((await xl(e,{responseType:"arraybuffer",url:`${Zh}/${t}/${n}`,params:{"Swarm-Only-Root-Chunk":!0}})).headers)}function Kh(e,t){return t="number"==typeof t?Lt.fromBigInt(BigInt(t)):t,new Zt(St(Pt.concat(e.toUint8Array(),t.toUint8Array())))}async function Jh(e,t,n){try{const r=await Hh(e,t,n);if(!r.feedIndexNext)throw Error("Feed index next is not defined. This should happen when fetching an exact index.");return r.feedIndexNext}catch(r){if(r instanceof $l)return Lt.fromBigInt(0n);throw r}}async function Xh(e,t,n,r,o,i){r=new nn(r);const s=Kh(n,i?.index??await Jh(e,t.publicKey().address(),n)),a=i?.at??Date.now()/1e3,c=At(BigInt(Math.floor(a)),"BE");return If(e,t,o,s,Pt.concat(c,r.toUint8Array()),i)}async function Yh(e,t,n,r,o,i){const s=Kh(n,i?.index??await Jh(e,t.publicKey().address(),n));if(r.length>4096){const n=await Nh(e,r,o,i);return Df(e,t,o,s,Rn(await Sf(e,n.reference)),i)}const a=ou().safeParse(r);return If(e,t,o,s,a.success?Pt.fromUtf8(a.data).toUint8Array():r,i)}function Qh(e,t,n){const r=Kh(t,n);return new nn(St(Pt.concat(r.toUint8Array(),e.toUint8Array())))}async function ed(e,t,n,r,o=!1){const i=Qh(t,n,r="number"==typeof r?Lt.fromBigInt(BigInt(r)):r),s=$f(await Sf(e,i.toHex()),i);let a=ar.Xx.empty();if(o){const e=Pt.fromSlice(s.payload.toUint8Array(),0,8);a=ar.Xx.of(Number(zt(e.toUint8Array(),"BE")))}return{timestamp:a,payload:new Pt(s.payload.offset(o?8:0))}}async function td(e,t,n,r){const o=Qh(t,n,r="number"==typeof r?Lt.fromBigInt(BigInt(r)):r),i=$f(await Sf(e,o),o);return Tn(i.payload,i.span)}function nd(e,t,n){const r=async r=>{if(void 0===r?.index)return Hh(e,n,t);const o=await ed(e,n,t,r.index,r.hasTimestamp??!0),i="number"==typeof r.index?Lt.fromBigInt(BigInt(r.index)):r.index;return{payload:o.payload,feedIndex:i,feedIndexNext:i.next()}};return{download:r,downloadPayload:async r=>{if(void 0===r?.index)return Hh(e,n,t);const o=await td(e,n,t,r.index),i=o.span.toBigInt()<=4096n?o.payload:await Mh(e,new Lh(o.address)),s="number"==typeof r.index?Lt.fromBigInt(BigInt(r.index)):r.index;return{payload:i,feedIndex:s,feedIndexNext:s.next()}},downloadReference:async o=>{let i=o?.index;void 0===i&&(i=(await Wh(e,n,t)).feedIndex);const s=await r({...o,index:i});return{reference:new nn(s.payload.toUint8Array()),feedIndex:s.feedIndex,feedIndexNext:s.feedIndexNext??s.feedIndex.next()}},owner:n,topic:t}}async function rd(e,t,n,r,o,i){const s=function(e,t,n){const r=n.toBigInt(),o=[];for(let i=0n;i<=r;i++)o.push(Qh(e,t,Lt.fromBigInt(i)));return o}(t,n,r).map((async t=>async function(e,t,n,r){try{return await e.chunk.download(t,n,r),!0}catch(o){const e=ar.Rb.getDeep(o,"status");if(404===e||500===e)return!1;throw o}}(e,t,o,i)));return(await Promise.all(s)).every((e=>e))}class od{constructor(e){this.context=e}makeReader(e,t,n){return nd(this.context.getRequestOptionsForCall(n),new sn(e),new Ut(t))}makeWriter(e,t,n){const r=t?new en(t):this.context.signer;if(!r)throw Error("No signer provided");return function(e,t,n){const r=async(r,o,i)=>Xh(e,n,t,o,r,i);return{...nd(e,t,n.publicKey().address()),upload:r,uploadReference:r,uploadPayload:async(r,o,i)=>Yh(e,n,t,o,r,i)}}(this.context.getRequestOptionsForCall(n),new sn(e),r)}async createManifest(e,t,n,r,o){const i=new Ct(e),s=new sn(t),a=new Ut(n);return r&&(r=rf.parse(r)),async function(e,t,n,r,o){const i=await xl(e,{method:"post",responseType:"json",url:`${Zh}/${t}/${n}`,headers:zf(r,o)});return zl.parse(i.data).reference}(this.context.getRequestOptionsForCall(o),a,s,i,r)}async fetchLatestUpdate(e,t,n){return Hh(this.context.getRequestOptionsForCall(n),new Ut(t),new sn(e))}async isRetrievable(e,t,n,r,o){const i=new Ut(e),s=new sn(t);if(r&&(r=nf.parse(r)),!n)try{return await this.makeReader(s,i,o).download(),!0}catch(a){const e=ar.Rb.getDeep(a,"status");if(404===e||500===e)return!1;throw a}return rd(this.context.bee,i,s,n,r,this.context.getRequestOptionsForCall(o))}}class id{constructor(e){this.context=e}async upload(e,t,n,r,o){const i=new Ct(e);if(function(e){if(!("string"==typeof e||e instanceof Uint8Array||Cl(e)||gf(e)))throw new TypeError("Data must be either string, Readable, Uint8Array or File!")}(t),r&&(r=sf.parse(r)),n&&"string"!=typeof n)throw new TypeError("name has to be string or undefined!");if(Cl(t)){const e=await async function(e){return e.arrayBuffer?e.arrayBuffer():new Promise((t=>{const n=new FileReader;n.onload=()=>t(n.result),n.readAsArrayBuffer(e)}))}(t),s=n??t.name,a=t.type,c={...r,contentType:a};return bh(this.context.getRequestOptionsForCall(o),e,i,s,c)}return bh(this.context.getRequestOptionsForCall(o),t,i,n,r)}async download(e,t="",n,r){return n&&(n=nf.parse(n)),async function(e,t,n="",r){const o=await xl(e,{method:"GET",responseType:"arraybuffer",url:`${wh}/${t}/${n}`,headers:zf(null,r)});return{...Af(o.headers),data:new Pt(o.data)}}(this.context.getRequestOptionsForCall(r),new Lh(e),t,n)}async downloadReadable(e,t="",n,r){const o=new nn(e);return n&&(n=nf.parse(n)),async function(e,t,n="",r){t=new nn(t);const o=await xl(e,{method:"GET",responseType:"stream",url:`${wh}/${t}/${n}`,headers:zf(null,r)});return{...Af(o.headers),data:o.data}}(this.context.getRequestOptionsForCall(r),o,t,n)}}const sd=ju(ou().transform((e=>new Kt(e)))),ad=qu({ref:ou().transform((e=>new nn(e))),historyref:ou().transform((e=>new nn(e)))}),cd="grantee";class ud{constructor(e){this.context=e}async create(e,t,n){const r=new Ct(e),o=t.map((e=>new Kt(e)));return async function(e,t,n){const r=await xl(e,{method:"post",url:cd,data:{grantees:n.map((e=>e.toCompressedHex()))},headers:zf(t),responseType:"json"}),o=ad.parse(r.data);return{status:r.status,statusText:r.statusText,ref:o.ref,historyref:o.historyref}}(this.context.getRequestOptionsForCall(n),r,o)}async get(e,t){const n=new nn(e);return async function(e,t){const n=await xl(e,{method:"get",url:`${cd}/${t}`,responseType:"json"});return{status:n.status,statusText:n.statusText,grantees:sd.parse(n.data)}}(this.context.getRequestOptionsForCall(t),n)}async patch(e,t,n,r,o){const i=new Ct(e),s=new nn(t),a=new nn(n),c={add:r.add?.map((e=>new Kt(e)))??[],revoke:r.revoke?.map((e=>new Kt(e)))??[]};return async function(e,t,n,r,o){const i=await xl(e,{method:"patch",url:`${cd}/${n}`,data:{add:o.add.map((e=>e.toCompressedHex())),revoke:o.revoke.map((e=>e.toCompressedHex()))},headers:{...zf(t),"swarm-act-history-address":r.toHex()},responseType:"json"}),s=ad.parse(i.data);return{status:i.status,statusText:i.statusText,ref:s.ref,historyref:s.historyref}}(this.context.getRequestOptionsForCall(o),i,s,a,c)}}var ld=null;"undefined"!=typeof WebSocket?ld=WebSocket:"undefined"!=typeof MozWebSocket?ld=MozWebSocket:void 0!==n.g?ld=n.g.WebSocket||n.g.MozWebSocket:"undefined"!=typeof window?ld=window.WebSocket||window.MozWebSocket:"undefined"!=typeof self&&(ld=self.WebSocket||self.MozWebSocket);const fd=ld;async function hd(e){if("string"==typeof e)return(new TextEncoder).encode(e);if(e instanceof Buffer)return new Uint8Array(e);if(e instanceof ArrayBuffer)return new Uint8Array(e);if(t=e,Array.isArray(t)&&t.length>0&&t.every((e=>e instanceof Buffer)))return new Uint8Array(Buffer.concat(e));var t;throw new TypeError("unknown websocket data type")}class dd{constructor(e){this.context=e}async pssSend(e,t,n,r,o,i){const s=new Ct(e);wf(r);const a=o?new Kt(o):void 0;await async function(e,t,n,r,o,i){await xl(e,{method:"post",url:`pss/send/${n}/${r}`,data:o,responseType:"json",params:{recipient:i},headers:zf(t)})}(this.context.getRequestOptionsForCall(i),s,t,n,r,a)}pssSubscribe(e,t){t=lf.parse(t);const n=this.openWebSocket(`pss/subscribe/${e.toHex()}`),r={topic:e,cancel:this.makeCancel(n)};return n.onmessage=async e=>{const n=await hd(e.data);n.length&&t.onMessage(new Pt(n),r)},n.onerror=e=>{this.isCancelled(n)||t.onError(new kl(e.message),r)},n.onclose=()=>{t.onClose(r)},r}async pssReceive(e,t=0){if("number"!=typeof t)throw new TypeError("timeoutMsc parameter has to be a number!");return new Promise(((n,r)=>{let o;const i=this.pssSubscribe(e,{onError:e=>{clearTimeout(o),i.cancel(),r(e.message)},onMessage:e=>{clearTimeout(o),i.cancel(),n(e)},onClose:()=>{clearTimeout(o),i.cancel()}});t>0&&(o=setTimeout((()=>{i.cancel(),r(new kl("pssReceive timeout"))}),t))}))}gsocMine(e,t,n=12){const r=new qt(e),o=new Zt(t);for(let i=0n;i<0xffffn;i++){const e=new en(mt(2867n+i,"BE")),t=Bn(o,e.publicKey().address());if(256-ar.yI.proximity(t.toUint8Array(),r.toUint8Array())<=256-n)return e}throw Error("Could not mine a valid signer")}async gsocSend(e,t,n,r,o,i){const s=new Ct(e),a=new en(t),c=new Zt(n),u=Tn(r).toSingleOwnerChunk(c,a);return _f(this.context.getRequestOptionsForCall(i),u,s,o)}gsocSubscribe(e,t,n,r){const o=new Ut(e),i=new Zt(t);n=ff.parse(n);const{fields:s,cacheWrappedChunk:a}=hf.parse(r??{}),c=new URLSearchParams;s&&c.set("swarm-soc-fields",s.join(",")),void 0!==a&&c.set("swarm-cache-wrapped-chunk",String(a));const u=Bn(i,o),l=c.toString()?`?${c.toString()}`:"",f=this.openWebSocket(`gsoc/subscribe/${u.toHex()}${l}`),h={address:o,cancel:this.makeCancel(f)};return f.onmessage=async e=>{const t=await hd(e.data);t.length&&n.onMessage(new Pt(t),h)},f.onerror=e=>{this.isCancelled(f)||n.onError(new kl(e.message),h)},f.onclose=()=>{n.onClose(h)},h}openWebSocket(e){const t=this.context.url.replace(/^http/i,"ws");return"browser"===ar.iQ.whereAmI()?new fd(`${t}/${e}`):new fd(`${t}/${e}`,{headers:this.context.getRequestOptionsForCall().headers})}cancelled=new WeakSet;makeCancel(e){return()=>{this.cancelled.has(e)||(this.cancelled.add(e),e.terminate?e.terminate():e.close())}}isCancelled(e){return this.cancelled.has(e)}}const pd=qu({references:ju(ou()).nullable()}),md="pins";class gd{constructor(e){this.context=e}async add(e,t){const n=new nn(e);await async function(e,t){await xl(e,{method:"post",responseType:"json",url:`${md}/${t}`})}(this.context.getRequestOptionsForCall(t),n)}async remove(e,t){const n=new nn(e);await async function(e,t){await xl(e,{method:"delete",responseType:"json",url:`${md}/${t}`})}(this.context.getRequestOptionsForCall(t),n)}async getAll(e){return async function(e){const t=await xl(e,{method:"get",responseType:"json",url:md}),{references:n}=pd.parse(t.data);return(n??[]).map((e=>new nn(e)))}(this.context.getRequestOptionsForCall(e))}async get(e,t){const n=new nn(e);return async function(e,t){const n=await xl(e,{method:"get",responseType:"json",url:`${md}/${t}`});return zl.parse(n.data)}(this.context.getRequestOptionsForCall(t),n)}async reuploadData(e,t,n){const r=new Ct(e),o=new nn(t);await async function(e,t,n){await xl(e,{method:"put",url:`${Gh}/${n}`,headers:{"swarm-postage-batch-id":t.toHex()}})}(this.context.getRequestOptionsForCall(n),r,o)}}function yd(e,t){if(t<=0)throw new kl("Period length must be greater than zero!");return Math.floor(e/t)}function wd(e,t){const n=e.toUint8Array();return new sn(St(Pt.concat(n,At(BigInt(t),"BE"))))}async function bd(e,t,n){try{return await Wh(e,t,n),!0}catch(r){if(r instanceof $l)return!1;throw r}}async function vd(e,t,n){const{feedIndex:r}=await Wh(e,t,n),o=await ed(e,t,n,r,!0);return{reference:new nn(o.payload.toUint8Array()),feedIndex:r,feedIndexNext:r.next()}}class Bd{constructor(e){this.context=e}makeWriter(e,t,n){return new Ed(this.context,e,t,n)}makeReader(e,t,n){return new xd(this.context,e,t,n)}}class Ed{constructor(e,t,n,r){this.context=e,this.baseTopic=t,this.signer=n,this.periodLength=r}async uploadPayload(e,t,n){const r=this.context.getRequestOptionsForCall(),o=new Ct(e),{currentTopic:i,nextTopic:s,mirrorOptions:a}=this.currentAndNextTopics(n),[c]=await Promise.all([Yh(r,this.signer,i,t,o,n),Yh(r,this.signer,s,t,o,a)]);return c}async uploadReference(e,t,n){const r=this.context.getRequestOptionsForCall(),o=new Ct(e),{currentTopic:i,nextTopic:s,mirrorOptions:a}=this.currentAndNextTopics(n),[c]=await Promise.all([Xh(r,this.signer,i,t,o,n),Xh(r,this.signer,s,t,o,a)]);return c}async isCaughtUp(e){const t=this.context.getRequestOptionsForCall(),n=e??yd(Date.now()/1e3,this.periodLength);return bd(t,this.signer.publicKey().address(),wd(this.baseTopic,n))}async catchUp(e,t,n=1){const r=this.context.getRequestOptionsForCall(),o=new Ct(e),i=this.signer.publicKey().address(),s=t??yd(Date.now()/1e3,this.periodLength),a=Math.max(0,s-1-n);let c=s-1;for(;c>=a&&!await bd(r,i,wd(this.baseTopic,c));)c--;if(c<a)throw new kl(`No populated period found within ${n} periods to catch up from!`);if(c===s-1)return;const u=wd(this.baseTopic,c),{feedIndex:l}=await Wh(r,i,u),f=await td(r,i,u,l),h=Array.from({length:s-1-c},((e,t)=>c+1+t));await Promise.all(h.map((async e=>{const t=Kh(wd(this.baseTopic,e),0);return Df(r,this.signer,o,t,f)})))}currentAndNextTopics(e){const t=yd(Date.now()/1e3,this.periodLength);return{currentTopic:wd(this.baseTopic,t),nextTopic:wd(this.baseTopic,t+1),mirrorOptions:{...e,index:void 0}}}}class xd{constructor(e,t,n,r){this.context=e,this.baseTopic=t,this.owner=n,this.periodLength=r}async downloadPayload(e){const t=this.context.getRequestOptionsForCall(),n=yd(Date.now()/1e3,this.periodLength);try{return await Hh(t,this.owner,wd(this.baseTopic,n),e)}catch(r){if(!(r instanceof $l))throw r;return Hh(t,this.owner,wd(this.baseTopic,n-1),e)}}async downloadReference(){const e=this.context.getRequestOptionsForCall(),t=yd(Date.now()/1e3,this.periodLength);try{return await vd(e,this.owner,wd(this.baseTopic,t))}catch(n){if(!(n instanceof $l))throw n;return vd(e,this.owner,wd(this.baseTopic,t-1))}}}const Td=qu({peer:ou(),sent:ou().transform((e=>Dl.fromPLUR(yf(e,{name:"sent"})))),received:ou().transform((e=>Dl.fromPLUR(yf(e,{name:"received"}))))}),Rd=Td,Od=qu({totalSent:ou().transform((e=>Dl.fromPLUR(yf(e,{name:"totalSent"})))),totalReceived:ou().transform((e=>Dl.fromPLUR(yf(e,{name:"totalReceived"})))),settlements:ju(Td)}),Ad="settlements";class zd{constructor(e){this.context=e}async get(e,t){const n=new qt(e);return async function(e,t){const n=await xl(e,{url:`${Ad}/${t}`,responseType:"json"});return Rd.parse(n.data)}(this.context.getRequestOptionsForCall(t),n)}async getAll(e){return async function(e){const t=await xl(e,{url:Ad,responseType:"json"});return Od.parse(t.data)}(this.context.getRequestOptionsForCall(e))}}class kd{constructor(e){this.context=e}makeReader(e,t){const n=new Ut(e);return{owner:n,download:Vf.bind(null,this.context.getRequestOptionsForCall(t),n)}}makeWriter(e,t){const n=e?new en(e):this.context.signer;if(!n)throw Error("No signer provided");return{...this.makeReader(n.publicKey().address(),t),upload:If.bind(null,this.context.getRequestOptionsForCall(t),n)}}}const Sd=qu({stakedAmount:ou().transform((e=>Dl.fromPLUR(yf(e,{name:"stakedAmount"})))),minimumDeposit:ou().nullish().transform((e=>e?Dl.fromPLUR(yf(e,{name:"minimumDeposit"})):null))}),$d=qu({withdrawableAmount:ou().transform((e=>Dl.fromPLUR(yf(e,{name:"withdrawableAmount"}))))}),_d=qu({txHash:ou().transform((e=>new an(e)))}),Id=qu({minimumGasFunds:ou().transform((e=>Vl.fromWei(yf(e,{name:"minimumGasFunds"})))),hasSufficientFunds:Du(),isFrozen:Du(),isFullySynced:Du(),phase:ou(),round:Su(),lastWonRound:Su(),lastPlayedRound:Su(),lastFrozenRound:Su(),lastSelectedRound:Su(),lastSampleDurationSeconds:Su(),block:Su(),reward:ou().transform((e=>Dl.fromPLUR(yf(e,{name:"reward"})))),fees:ou().transform((e=>Vl.fromWei(yf(e,{name:"fees"})))),isHealthy:Du(),enabled:Du(),hasCommittedThisRound:Du(),hasRevealedThisRound:Du()}),Dd=qu({enabled:Du()}),Vd="stake";async function Pd(e){const t=await xl(e,{method:"get",responseType:"json",url:Vd});return Sd.parse(t.data)}const Cd="redistributionstate";class Fd{constructor(e){this.context=e}async get(e){const{stakedAmount:t}=await Pd(this.context.getRequestOptionsForCall(e));return t}async getMinimumDeposit(e){const{minimumDeposit:t}=await Pd(this.context.getRequestOptionsForCall(e));return t}async getWithdrawable(e){return async function(e){const t=await xl(e,{method:"get",responseType:"json",url:`${Vd}/withdrawable`});return $d.parse(t.data).withdrawableAmount}(this.context.getRequestOptionsForCall(e))}async deposit(e,t,n){const r=e instanceof Dl?e.toPLURString():yf(e,{min:1n,name:"amount"});return t&&(t=pf.parse(t)),async function(e,t,n){const r=await xl(e,{method:"post",responseType:"json",url:`${Vd}/${t}`,headers:zf(null,n)});return _d.parse(r.data).txHash}(this.context.getRequestOptionsForCall(n),r,t)}async withdrawSurplus(e){return async function(e){const t=await xl(e,{method:"delete",responseType:"json",url:`${Vd}/withdrawable`});return _d.parse(t.data).txHash}(this.context.getRequestOptionsForCall(e))}async migrate(e){return async function(e){const t=await xl(e,{method:"delete",responseType:"json",url:Vd});return _d.parse(t.data).txHash}(this.context.getRequestOptionsForCall(e))}async getRedistributionState(e){return async function(e){const t=await xl(e,{method:"get",responseType:"json",url:Cd});return Id.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async setRedistributionEnabled(e,t){return async function(e,t){const n=await xl(e,{method:"patch",responseType:"json",url:Cd,data:{enabled:t}});return Dd.parse(n.data).enabled}(this.context.getRequestOptionsForCall(t),Du().parse(e))}}const Nd=qu({batchID:ou(),utilization:Su(),utilizationRatio:Su().optional(),usable:Du(),label:ou(),depth:Su(),amount:ou(),bucketDepth:Su(),blockNumber:Su(),immutableFlag:Du(),batchTTL:Su()}),Md=qu({batchID:ou().transform((e=>new Ct(e))),batchTTL:Su(),bucketDepth:Su(),depth:Su(),immutable:Du(),owner:ou().transform((e=>new Ut(e))),start:Su(),value:ou().transform((e=>yf(e,{name:"value"})))}),Ud=qu({batches:ju(Md)}),Gd=qu({stamps:ju(Nd)}),Ld=Nd,jd=qu({depth:Su(),bucketDepth:Su(),bucketUpperBound:Su(),buckets:ju(qu({bucketID:Su(),collisions:Su()}))}),Zd=qu({batchID:ou().transform((e=>new Ct(e)))}),qd="stamps";const Hd="batches";class Wd{constructor(e){this.context=e}async create(e,t,n,r){const o=yf(e,{min:0n,name:"amount"});if(n&&(n=df.parse(n)),t<Zl||t>ql)throw new Sl(`Depth has to be between ${Zl}..${ql}`,t);const i=await this.context.bee.status.getChainState(),s=17280n*BigInt(i.currentPrice)+1n;if(BigInt(o)<s)throw new Sl(`Amount has to be at least ${s} (1 day at current price ${i.currentPrice})`,o);const a=await async function(e,t,n,r,o,i){const s={};o&&(s["gas-price"]=o),void 0!==i&&(s.immutable=String(i));const a=await xl(e,{method:"post",url:`${qd}/${t}/${n}`,responseType:"json",params:{label:r},headers:s});return Zd.parse(a.data).batchID}(this.context.getRequestOptionsForCall(r),o,t,n?.label,n?.gasPrice?.toString(),n?.immutableFlag);return!1!==n?.waitForUsable&&await this.waitForUsable(a,n?.waitForUsableTimeout),a}async updateLabel(e,t,n){const r=new Ct(e);await async function(e,t,n){await xl(e,{method:"patch",url:`${qd}/${t}`,responseType:"json",data:{label:n}})}(this.context.getRequestOptionsForCall(n),r,t)}async calculateTopUpForBZZ(e,t,n){const r=await this.context.bee.status.getChainState(n),o="gnosis"===this.context.network?5:15,i=t.toPLURBigInt()/2n**BigInt(e);return{amount:i,duration:Bf(i,r.currentPrice,o)}}async topUp(e,t,n){const r=new Ct(e),o=yf(t,{min:1n,name:"amount"});return async function(e,t,n){const r=await xl(e,{method:"patch",url:`${qd}/topup/${t}/${n}`,responseType:"json"});return Zd.parse(r.data).batchID}(this.context.getRequestOptionsForCall(n),r,o)}async dilute(e,t,n){const r=new Ct(e),o=Su().int().min(18).max(255).parse(t);return async function(e,t,n){const r=await xl(e,{method:"patch",url:`${qd}/dilute/${t}/${n}`,responseType:"json"});return Zd.parse(r.data).batchID}(this.context.getRequestOptionsForCall(n),r,o)}async get(e,t,n,r){const o=new Ct(e);return async function(e,t,n,r){const o=await xl(e,{method:"get",url:`${qd}/${t}`,responseType:"json"});return Rf(Ld.parse(o.data),n,r)}(this.context.getRequestOptionsForCall(t),o,n,r)}async getGlobal(e,t){const n=new Ct(e);return async function(e,t){const n=await xl(e,{method:"get",url:`${Hd}/${t}`,responseType:"json"});return Md.parse(n.data)}(this.context.getRequestOptionsForCall(t),n)}async getBuckets(e,t){const n=new Ct(e);return async function(e,t){const n=await xl(e,{method:"get",url:`${qd}/${t}/buckets`,responseType:"json"});return jd.parse(n.data)}(this.context.getRequestOptionsForCall(t),n)}async getAll(e){return async function(e){const t=await xl(e,{method:"get",url:qd,responseType:"json"});return Gd.parse(t.data).stamps.map((e=>Rf(e)))}(this.context.getRequestOptionsForCall(e))}async getAllGlobal(e){return async function(e){const t=await xl(e,{method:"get",url:Hd,responseType:"json"});return Ud.parse(t.data).batches}(this.context.getRequestOptionsForCall(e))}async waitForUsable(e,t=24e4){for(let n=0;n<t;n+=3e3){try{if((await this.get(e)).usable)return}catch{}await ar.iQ.sleepMillis(3e3)}throw new kl("Timeout on waiting for postage stamp to become usable")}}var Kd=n(359),Jd=n.n(Kd);const Xd="2.8.3",Yd=Xd.split("-")[0],Qd="8.2.0",ep=qu({commitment:Su(),radius:Su(),storageRadius:Su(),reserveCapacityDoubling:Su()}),tp=qu({block:Su(),chainTip:Su(),totalAmount:ou().transform((e=>yf(e,{name:"totalAmount"}))),currentPrice:ou().transform(Number).transform((e=>{return t=e,Number.isInteger(t)?t<24e3?24e3:t:24e3;var t})),minimumValidityBlocks:Su().optional()}),np=qu({bzzBalance:ou().transform((e=>Dl.fromPLUR(yf(e,{name:"bzzBalance"})))),nativeTokenBalance:ou().transform((e=>Vl.fromWei(yf(e,{name:"nativeTokenBalance"})))),chainID:Su(),chequebookContractAddress:ou(),walletAddress:ou()}),rp=qu({transactionHash:ou().transform((e=>new an(e)))});class op{constructor(e){this.context=e}async get(e){return async function(e){const t=await xl(e,{method:"get",url:"status",responseType:"json"});return kh.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async getHealth(e){return async function(e){const t=await xl(e,{method:"get",url:"health",responseType:"json"});return Sh.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async getReadiness(e){return async function(e){const t=await xl(e,{method:"get",url:"readiness"});return Ih.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async getNodeInfo(e){return async function(e){const t=await xl(e,{method:"get",url:"node",responseType:"json"});return Dh.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async isSupportedExactVersion(e){const{version:t}=await this.getHealth(e);return t===Xd}async isSupportedApiVersion(e){const{apiVersion:t}=await this.getHealth(e);return Jd()(t)===Jd()(Qd)}async getVersions(e){const{version:t,apiVersion:n}=await this.getHealth(e);return{supportedBeeVersion:Xd,supportedBeeApiVersion:Qd,beeVersion:t,beeApiVersion:n}}async getReserveState(e){return async function(e){const t=await xl(e,{method:"get",url:"reservestate",responseType:"json"});return ep.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async getChainState(e){return async function(e){const t=await xl(e,{method:"get",url:"chainstate",responseType:"json"});return tp.parse(t.data)}(this.context.getRequestOptionsForCall(e))}}class ip{constructor(e){this.context=e}get blockTime(){return"gnosis"===this.context.network?5:15}async buy(e,t,n,r,o,i){const s=Ef(t,(await this.context.bee.status.getChainState(r)).currentPrice,this.blockTime),a=xf(e,o,i);return n&&(n=df.parse(n)),this.context.bee.stamp.create(s,a,n,r)}async getCost(e,t,n,r,o){const i=Ef(t,(await this.context.bee.status.getChainState(n)).currentPrice,this.blockTime);return vf(xf(e,r,o),i)}async extend(e,t,n,r,o,i){const s=await this.context.bee.stamp.get(e,r),a=xf(t,o,i),c=await this.context.bee.status.getChainState(r),u=a-s.depth,l=u<=0?1n:2n**BigInt(u),f=Ef(n,c.currentPrice,this.blockTime),h=Ef(s.duration,c.currentPrice,this.blockTime),d=(n.isZero()?h*l:(h+f)*l)-h;let p;if(d>0n&&(p=await this.context.bee.stamp.topUp(s.batchID,d,r)),u>0)return this.context.bee.stamp.dilute(s.batchID,a,r);if(!p)throw new Error("Nothing to extend, both size and duration are already sufficient");return p}async extendSize(e,t,n,r,o){const i=await this.context.bee.status.getChainState(n),s=await this.context.bee.stamp.get(e,n),a=xf(t,r,o),c=a-s.depth;if(c<=0)throw new Sl("New depth has to be greater than the original depth",a);const u=Ef(s.duration,i.currentPrice,this.blockTime);return await this.context.bee.stamp.topUp(s.batchID,u*(2n**BigInt(c)-1n)+1n,n),this.context.bee.stamp.dilute(s.batchID,a,n)}async extendDuration(e,t,n){const r=await this.context.bee.stamp.get(e,n),o=Ef(t,(await this.context.bee.status.getChainState(n)).currentPrice,this.blockTime);return this.context.bee.stamp.topUp(r.batchID,o,n)}async getExtensionCost(e,t,n,r,o,i){const s=await this.context.bee.stamp.get(e,r),a=await this.context.bee.status.getChainState(r),c=n.isZero()?0n:Ef(n,a.currentPrice,this.blockTime),u=xf(t,o,i),l=Ef(s.duration,a.currentPrice,this.blockTime),f=vf(s.depth,l);return vf(Math.max(s.depth,u),l+c).minus(f)}async getSizeExtensionCost(e,t,n,r,o){const i=await this.context.bee.stamp.get(e,n),s=await this.context.bee.status.getChainState(n),a=xf(t,r,o);if(a-i.depth<=0)throw new Sl("New depth has to be greater than the original depth",a);const c=Ef(i.duration,s.currentPrice,this.blockTime),u=vf(i.depth,c);return vf(a,c).minus(u)}async getDurationExtensionCost(e,t,n){const r=await this.context.bee.stamp.get(e,n),o=Ef(t,(await this.context.bee.status.getChainState(n)).currentPrice,this.blockTime);return vf(r.depth,o)}async rename(e,t,n){return this.context.bee.stamp.updateLabel(e,t,n)}}const sp=qu({address:ou().nullish().transform((e=>e??"")),seen:Su(),sent:Su(),split:Su(),startedAt:ou(),stored:Su(),synced:Su(),uid:Su()}),ap=qu({tags:ju(sp)}),cp="tags";class up{constructor(e){this.context=e}async create(e){return async function(e){const t=await xl(e,{method:"post",url:cp,responseType:"json"});return sp.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async getAll(e,t){return e&&(e=mf.parse(e)),async function(e,t){const n=await xl(e,{url:cp,params:{offset:t?.offset,limit:t?.limit},responseType:"json"});return ap.parse(n.data).tags}(this.context.getRequestOptionsForCall(t),e)}async get(e,t){const n=bf(e);return async function(e,t){const n=await xl(e,{url:`${cp}/${t}`,responseType:"json"});return sp.parse(n.data)}(this.context.getRequestOptionsForCall(t),n)}async delete(e,t){const n=bf(e);await async function(e,t){await xl(e,{method:"delete",url:`${cp}/${t}`})}(this.context.getRequestOptionsForCall(t),n)}async update(e,t,n){const r=new nn(t),o=bf(e);await async function(e,t,n){await xl(e,{method:"patch",url:`${cp}/${t}`,data:{reference:n}})}(this.context.getRequestOptionsForCall(n),o,r)}}const lp=qu({transactionHash:ou().transform((e=>new an(e))),to:ou(),nonce:Su(),gasPrice:ou().transform((e=>yf(e,{name:"gasPrice"}))),gasLimit:Su(),data:ou(),created:ou(),description:ou(),value:ou().transform((e=>yf(e,{name:"value"})))}),fp=qu({pendingTransactions:ju(lp)}),hp=lp,dp=qu({transactionHash:ou().transform((e=>new an(e)))}),pp="transactions";class mp{constructor(e){this.context=e}async getAll(e){return async function(e){const t=await xl(e,{url:pp,responseType:"json"});return fp.parse(t.data).pendingTransactions}(this.context.getRequestOptionsForCall(e))}async get(e,t){const n=new an(e);return async function(e,t){const n=await xl(e,{url:`${pp}/${t}`,responseType:"json"});return hp.parse(n.data)}(this.context.getRequestOptionsForCall(t),n)}async rebroadcast(e,t){const n=new an(e);return async function(e,t){const n=await xl(e,{method:"post",url:`${pp}/${t}`,responseType:"json"});return dp.parse(n.data).transactionHash}(this.context.getRequestOptionsForCall(t),n)}async cancel(e,t,n){const r=new an(e),o=t?yf(t,{min:0n,name:"gasPrice"}):void 0;return async function(e,t,n){const r={};n&&(r["gas-price"]=n);const o=await xl(e,{method:"delete",headers:r,url:`${pp}/${t}`,responseType:"json"});return dp.parse(o.data).transactionHash}(this.context.getRequestOptionsForCall(n),r,o)}}const gp="wallet";class yp{constructor(e){this.context=e}async getBalance(e){return async function(e){const t=await xl(e,{method:"get",url:gp,responseType:"json"});return np.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async withdrawBZZ(e,t,n){const r=e instanceof Dl?e:Dl.fromPLUR(e),o=new Ut(t);return async function(e,t,n){const r=await xl(e,{method:"post",url:`${gp}/withdraw/bzz`,responseType:"json",params:{amount:t.toPLURString(),address:n.toHex()}});return rp.parse(r.data).transactionHash}(this.context.getRequestOptionsForCall(n),r,o)}async withdrawDAI(e,t,n){const r=e instanceof Vl?e:Vl.fromWei(e),o=new Ut(t);return async function(e,t,n){const r=await xl(e,{method:"post",url:`${gp}/withdraw/nativetoken`,responseType:"json",params:{amount:t.toWeiString(),address:n.toHex()}});return rp.parse(r.data).transactionHash}(this.context.getRequestOptionsForCall(n),r,o)}}const wp=["1","7","9","11","13","15","17","19","20","21","22","23","25","37","42","43","53","69","77","79","87","95","101","102","103","104","109","110","111","113","115","117","119","123","135","137","139","143","161","179","389","427","465","512","513","514","515","526","530","531","532","540","548","554","556","563","587","601","636","989","990","993","995","1719","1720","1723","2049","3659","4045","4190","5060","5061","6000","6566","6665","6666","6667","6668","6669","6679","6697","10080"];function bp(e){if(!function(e){try{if("string"!=typeof e)return!1;const t=new URL(e);return"http:"===t.protocol||"https:"===t.protocol}catch(t){return!1}}(e))throw new Sl("URL is not valid!",e);const t=new URL(e).port;if(t&&!function(e){if("string"!=typeof e)return!1;if(wp.includes(e))return!1;const t=parseInt(e,10);return t>0&&t<65536&&!isNaN(t)}(t))throw new Sl("Port in URL is considered bad port and cannot be used!",t)}class vp{constructor(e,t){bp(e),this.url=function(e){return e.endsWith("/")?e.slice(0,-1):e}(e),t?.signer&&(this.signer=new en(t.signer)),this.network=t?.network??"gnosis",this.requestOptions={baseURL:this.url,timeout:t?.timeout??0,headers:t?.headers,onRequest:t?.onRequest,httpAgent:t?.httpAgent,httpsAgent:t?.httpsAgent};const n={getRequestOptionsForCall:e=>this.getRequestOptionsForCall(e),url:this.url,signer:this.signer,network:this.network,bee:this};this.balance=new Uf(n),this.settlement=new zd(n),this.transaction=new mp(n),this.stake=new Fd(n),this.connectivity=new Ch(n),this.status=new op(n),this.wallet=new yp(n),this.stamp=new Wd(n),this.storage=new ip(n),this.chequebook=new Yf(n),this.cheque=new Xf(n),this.tag=new up(n),this.pin=new gd(n),this.grantee=new ud(n),this.messaging=new dd(n),this.feed=new od(n),this.soc=new kd(n),this.data=new jh(n),this.chunk=new Qf(n),this.file=new id(n),this.collection=new Bh(n),this.rollingFeed=new Bd(n)}makeContentAddressedChunk(e,t){return Tn(e,t)}unmarshalContentAddressedChunk(e){return Rn(e)}makeSingleOwnerChunk(e,t,n,r,o){return function(e,t,n,r,o){return r=new Zt(r),o=new en(o),En({data:Pt.concat(t.toUint8Array(),n.toUint8Array()),span:t,payload:n,address:e},r,o.toBigInt())}(e,t,n,r,o)}calculateSingleOwnerChunkAddress(e,t){return Bn(e,t)}unmarshalSingleOwnerChunk(e,t){return $f(e,t)}async createEnvelope(e,t,n){return e=new Ct(e),t=new nn(t),async function(e,t,n){const r=await xl(e,{method:"post",responseType:"json",url:`envelope/${n}`,headers:{"swarm-postage-batch-id":t.toHex()}}),o=bl.parse(r.data);return{issuer:new Ut(o.issuer),index:o.index,timestamp:o.timestamp,signature:new Qt(o.signature),batchId:t}}(this.getRequestOptionsForCall(n),e,t)}async rchash(e,t,n,r){return async function(e,t,n,r){const o=await xl(e,{responseType:"json",url:`rchash/${t}/${n}/${r}`});return Al.parse(o.data).durationSeconds}(this.getRequestOptionsForCall(r),e,t,n)}getRequestOptionsForCall(e){return e&&(e=tf.parse(e)),e?ar.Rb.deepMerge2(this.requestOptions,e):this.requestOptions}}const Bp="https://api.gateway.ethswarm.org",Ep=new Ct("0000000000000000000000000000000000000000000000000000000000000000"),xp=new sn("0000000000000000000000000000000000000000000000000000000000000000"),Tp=new Uint8Array(32),Rp=new Uint8Array(32),Op=new Uint8Array(20);function Ap(e){return(e=new qt(e)).toHex().slice(0,jl)}})(),r})()));
|
|
3
3
|
//# sourceMappingURL=index.browser.min.js.map
|