@ethersphere/bee-js 13.0.0-upcoming.gf9d33e6 → 13.0.0

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 N(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 P(e,t){if(E(e))return t&&N(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&&N(n,t),n}function C(e,t){return Math.trunc(P(e,t))}function F(e,t){if(!y(e))throw new TypeError(`Expected object${t?.name?` for ${t.name}`:""}, got: `+e);return e}function G(e){return B(e)&&null!==e.match(/^https?:\/\/.+/)}function M(e){return"bigint"==typeof e}function U(e,t){if(!M(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={"&amp;":"&","&quot;":'"',"&apos;":"'","&gt;":">","&lt;":"<"};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 Ne(e){return Math.floor((T(e)?e.getTime():e)/864e5)}const Pe={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 Ge={};const Me={s:1e3,m:6e4,h:36e5,d:864e5};const Ue={0:"sunday",1:"monday",2:"tuesday",3:"wednesday",4:"thursday",5:"friday",6:"saturday"};function Le(e){return{zeroBasedIndex:e,day:Ue[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,N=e[14]<<6|e[15]>>>26,P=e[15]<<6|e[14]>>>26,C=e[17]<<23|e[16]>>>9,F=e[16]<<23|e[17]>>>9,G=e[18]<<20|e[19]>>>12,M=e[19]<<20|e[18]>>>12,U=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^~G&U,e[11]=S^~M&L,e[12]=G^~U&ee,e[13]=M^~L&te,e[14]=U^~ee&he,e[15]=L^~te&de,e[16]=ee^~he&k,e[17]=te^~de&S,e[18]=he^~k&G,e[19]=de^~S&M,e[20]=T^~N&W,e[21]=R^~P&J,e[22]=N^~W&se,e[23]=P^~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&N,e[29]=ue^~R&P,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 Nt=0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2fn,Pt=0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n,Ct=0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798n,Ft=0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8n;function Gt(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 Mt(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 Gt(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 Ut(e,t,n,r){let o=[0n,0n],i=[e,t];const s=n.toString(2);for(const a of s)"0"===a?(Mt(o[0],o[1],i[0],i[1],r),Gt(o[0],o[1],r)):(Mt(o[0],o[1],i[0],i[1],r),Gt(i[0],i[1],r));return o}function Lt(e,t,n){if(t<=0n||t>=Pt)throw new Error("Invalid private key");if(n||_t(Et(Ot(gt(Ot(Bt(t,"BE")),Bt(e,"BE"))),"BE"),Pt),n<=0n||n>=Pt)throw new Error("Invalid nonce");const r=_t(e,Pt),o=Ut(Ct,Ft,n,Nt),i=_t(o[0],Pt);let s=_t((r+_t(i,Pt)*t)*Vt(n,Pt),Pt);if(0n===i||0n===s)throw new Error("Invalid r or s value");let a=o[1]%2n===0n?27n:28n;return s>Pt/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=U(e.value),n=P(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||Pe,o=T(e)?e:new Date(e);if(Ne(n)===Ne(o))return r.today(o.getUTCHours(),o.getUTCMinutes(),o.getUTCHours()>12);if(Ne(n)-Ne(o)==1)return r.yesterday();const i=je(o);return Ne(n)-Ne(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(!Ge[e]||Date.now()>Ge[e])&&(Ge[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)/Me[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:Ne},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(",","&comma;")})`))).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("&comma;",","),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)=>P(e[t])-P(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:G,isBigint:M,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:P,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(!G(e))throw new TypeError(`Expected url${t?.name?` for ${t.name}`:""}, got: `+e);return e},asBigint:U,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,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")},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:()=>du,BZZ:()=>iu,BatchId:()=>Ct,Bee:()=>Ih,BeeArgumentError:()=>tu,BeeError:()=>eu,BeeModes:()=>lu,BeeResponseError:()=>nu,Bytes:()=>Pt,CHUNK_SIZE:()=>pu,ChunkBuilder:()=>An,ChunkSplitter:()=>kn,DAI:()=>su,Duration:()=>ru,EthAddress:()=>Ut,FeedIndex:()=>jt,Identifier:()=>qt,MantarayNode:()=>zl,NULL_ADDRESS:()=>Nh,NULL_IDENTIFIER:()=>Ph,NULL_OWNER:()=>Ch,NULL_STAMP:()=>Vh,NULL_TOPIC:()=>Dh,PSS_TARGET_HEX_LENGTH_MAX:()=>mu,PeerAddress:()=>Ht,PrivateKey:()=>tn,PublicKey:()=>Kt,RedundancyLevel:()=>vu,RedundancyStrategy:()=>Bu,Reference:()=>rn,SECTION_SIZE:()=>hu,STAMPS_DEPTH_MAX:()=>yu,STAMPS_DEPTH_MIN:()=>gu,SUPPORTED_BEE_VERSION:()=>lh,SUPPORTED_BEE_VERSION_EXACT:()=>uh,SWARM_GATEWAY_URL:()=>_h,Signature:()=>en,Size:()=>ou,Span:()=>on,Stamper:()=>ar,TAGS_LIMIT_MAX:()=>bu,TAGS_LIMIT_MIN:()=>wu,Topic:()=>an,TransactionId:()=>cn,Utils:()=>e,capacityBreakpoints:()=>Eu,toBeeMode:()=>fu});var e={};n.r(e),n.d(e,{approximateOverheadForRedundancyLevel:()=>In,convertEnvelopeToMarshaledStamp:()=>Hu,getAmountForDuration:()=>Zu,getCollectionSize:()=>Pl,getDepthForSize:()=>qu,getFolderSize:()=>$l,getRedundancyStat:()=>Cn,getRedundancyStats:()=>Pn,getStampCost:()=>Lu,getStampDuration:()=>ju,getStampEffectiveBytes:()=>rr,getStampEffectiveBytesBreakpoints:()=>or,getStampTheoreticalBytes:()=>Xn,getStampUsage:()=>Kn,makeCollectionFromFileList:()=>Nl,makeMaxTarget:()=>Fh,mapPostageBatch:()=>Wu,unmapPostageBatch:()=>Ju});var t=n(20);const o="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0;function i(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function s(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function a(e,...t){if(!i(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 c(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.createHasher");s(e.outputLen),s(e.blockLen)}function u(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 l(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function f(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function h(e,t){return e<<32-t|e>>>t}const d=(()=>"function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex)(),p=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function m(e){if(a(e),d)return e.toHex();let t="";for(let n=0;n<e.length;n++)t+=p[e[n]];return t}const g=48,y=57,w=65,b=70,v=97,B=102;function E(e){return e>=g&&e<=y?e-g:e>=w&&e<=b?e-(w-10):e>=v&&e<=B?e-(v-10):void 0}function x(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);if(d)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=E(e.charCodeAt(i)),n=E(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 T(e){if("string"!=typeof e)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(e))}function R(e){return"string"==typeof e&&(e=T(e)),a(e),e}function z(...e){let t=0;for(let r=0;r<e.length;r++){const n=e[r];a(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 A{}function k(e){const t=t=>e().update(R(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function S(e=32){if(o&&"function"==typeof o.getRandomValues)return o.getRandomValues(new Uint8Array(e));if(o&&"function"==typeof o.randomBytes)return Uint8Array.from(o.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}function O(e,t,n){return e&t^e&n^t&n}class $ extends A{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=f(this.buffer)}update(e){u(this),a(e=R(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=f(e);for(;r<=o-i;i+=r)this.process(t,i)}}return this.length+=e.length,this.roundClean(),this}digestInto(e){u(this),function(e,t){a(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,l(this.buffer.subarray(i)),this.padOffset>r-i&&(this.process(n,0),i=0);for(let a=i;a<r;a++)t[a]=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 s=f(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const h=c/4,d=this.get();if(h>d.length)throw new Error("_sha2: outputLen bigger than state");for(let a=0;a<h;a++)s.setUint32(4*a,d[a],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 I=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]),V=new Uint32Array(64);class D extends ${constructor(e=32){super(64,e,8,!1),this.A=0|I[0],this.B=0|I[1],this.C=0|I[2],this.D=0|I[3],this.E=0|I[4],this.F=0|I[5],this.G=0|I[6],this.H=0|I[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)V[f]=e.getUint32(t,!1);for(let f=16;f<64;f++){const e=V[f-15],t=V[f-2],n=h(e,7)^h(e,18)^e>>>3,r=h(t,17)^h(t,19)^t>>>10;V[f]=r+V[f-7]+n+V[f-16]|0}let{A:n,B:r,C:o,D:i,E:s,F:a,G:c,H:u}=this;for(let f=0;f<64;f++){const e=u+(h(s,6)^h(s,11)^h(s,25))+((l=s)&a^~l&c)+_[f]+V[f]|0,t=(h(n,2)^h(n,13)^h(n,22))+O(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(){l(V)}destroy(){this.set(0,0,0,0,0,0,0,0),l(this.buffer)}}const N=k((()=>new D));class P extends A{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,c(e);const n=R(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),l(o)}update(e){return u(this),this.iHash.update(e),this}digestInto(e){u(this),a(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),G=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=i(e),o=e?.length,s=void 0!==t;if(!r||s&&o!==t){throw new Error((n&&`"${n}" `)+"expected Uint8Array"+(s?` of length ${t}`:"")+", got "+(r?`length=${o}`:"type="+typeof e))}return e}function L(e){const t=e.toString(16);return 1&t.length?"0"+t:t}function j(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);return""===e?F:BigInt("0x"+e)}function Z(e){return j(m(e))}function q(e){return a(e),j(m(Uint8Array.from(e).reverse()))}function H(e,t){return x(e.toString(16).padStart(2*t,"0"))}function W(e,t){return H(e,t).reverse()}function J(e,t,n){let r;if("string"==typeof t)try{r=x(t)}catch(s){throw new Error(e+" must be hex string or Uint8Array, cause: "+s)}else{if(!i(t))throw new Error(e+" must be hex string or Uint8Array");r=Uint8Array.from(t)}const o=r.length;if("number"==typeof n&&o!==n)throw new Error(e+" of length "+n+" expected, got "+o);return r}const K=e=>"bigint"==typeof e&&F<=e;function X(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 Y(e){let t;for(t=0;e>F;e>>=G,t+=1);return t}const Q=e=>(G<<BigInt(e))-G;function ee(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 te(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 ne=BigInt(0),re=BigInt(1),oe=BigInt(2),ie=BigInt(3),se=BigInt(4),ae=BigInt(5),ce=BigInt(7),ue=BigInt(8),le=BigInt(9),fe=BigInt(16);function he(e,t){const n=e%t;return n>=ne?n:t+n}function de(e,t,n){let r=e;for(;t-- >ne;)r*=r,r%=n;return r}function pe(e,t){if(e===ne)throw new Error("invert: expected non-zero number");if(t<=ne)throw new Error("invert: expected positive modulus, got "+t);let n=he(e,t),r=t,o=ne,i=re,s=re,a=ne;for(;n!==ne;){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!==re)throw new Error("invert: does not exist");return he(o,t)}function me(e,t,n){if(!e.eql(e.sqr(t),n))throw new Error("Cannot find square root")}function ge(e,t){const n=(e.ORDER+re)/se,r=e.pow(t,n);return me(e,r,t),r}function ye(e,t){const n=(e.ORDER-ae)/ue,r=e.mul(t,oe),o=e.pow(r,n),i=e.mul(t,o),s=e.mul(e.mul(i,oe),o),a=e.mul(i,e.sub(s,e.ONE));return me(e,a,t),a}function we(e){if(e<ie)throw new Error("sqrt is not defined for small field");let t=e-re,n=0;for(;t%oe===ne;)t/=oe,n++;let r=oe;const o=Re(e);for(;1===xe(o,r);)if(r++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(1===n)return ge;let i=o.pow(r,t);const s=(t+re)/oe;return function(e,r){if(e.is0(r))return r;if(1!==xe(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=re<<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 be(e){return e%se===ie?ge:e%ue===ae?ye:e%fe===le?function(e){const t=Re(e),n=we(e),r=n(t,t.neg(t.ONE)),o=n(t,r),i=n(t,t.neg(r)),s=(e+ce)/fe;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 me(e,d,t),d}}(e):we(e)}const ve=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Be(e,t,n){if(n<ne)throw new Error("invalid exponent, negatives unsupported");if(n===ne)return e.ONE;if(n===re)return t;let r=e.ONE,o=t;for(;n>ne;)n&re&&(r=e.mul(r,o)),o=e.sqr(o),n>>=re;return r}function Ee(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 xe(e,t){const n=(e.ORDER-re)/oe,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 Te(e,t){void 0!==t&&s(t);const n=void 0!==t?t:e.toString(2).length;return{nBitLength:n,nByteLength:Math.ceil(n/8)}}function Re(e,t,n=!1,r={}){if(e<=ne)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}=Te(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:Q(c),ZERO:ne,ONE:re,allowedLengths:s,create:t=>he(t,e),isValid:t=>{if("bigint"!=typeof t)throw new Error("invalid field element: expected bigint, got "+typeof t);return ne<=t&&t<e},is0:e=>e===ne,isValidNot0:e=>!f.is0(e)&&f.isValid(e),isOdd:e=>(e&re)===re,neg:t=>he(-t,e),eql:(e,t)=>e===t,sqr:t=>he(t*t,e),add:(t,n)=>he(t+n,e),sub:(t,n)=>he(t-n,e),mul:(t,n)=>he(t*n,e),pow:(e,t)=>Be(f,e,t),div:(t,n)=>he(t*pe(n,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>pe(t,e),sqrt:i||(t=>(l||(l=be(e)),l(f,t))),toBytes:e=>n?W(e,u):H(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?q(t):Z(t);if(a&&(o=he(o,e)),!r&&!f.isValid(o))throw new Error("invalid field element: outside of range 0..ORDER");return o},invertBatch:e=>Ee(f,e),cmov:(e,t,n)=>n?t:e});return Object.freeze(f)}function ze(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 Ae(e){const t=ze(e);return t+Math.ceil(t/2)}const ke=BigInt(0),Se=BigInt(1);function Oe(e,t){const n=t.negate();return e?n:t}function $e(e,t){const n=Ee(e.Fp,t.map((e=>e.Z)));return t.map(((t,r)=>e.fromAffine(t.toAffine(n[r]))))}function Ie(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){Ie(e,t);const n=2**e;return{windows:Math.ceil(t/e)+1,windowSize:2**(e-1),mask:Q(e),maxNumber:n,shiftBy:BigInt(e)}}function Ve(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+=Se);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 Ne(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 Ge(e){if(e!==ke)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>ke;)t&Se&&(n=n.add(r)),r=r.double(),t>>=Se;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}=Ve(n,s,i);n=e,c?o=o.add(Oe(l,t[f])):r=r.add(Oe(u,t[a]))}return Ge(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!==ke;i++){const{nextN:e,offset:s,isZero:a,isNeg:c}=Ve(n,i,o);if(n=e,!a){const e=t[s];r=r.add(c?e.negate():e)}}return Ge(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){Ie(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=ve.reduce(((e,t)=>(e[t]="function",e)),{ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"});ee(e,t)}(t),t}return Re(e,{isLE:n})}const Le=(e,t)=>(e+(e>=0?t:-t)/Ke)/t;function je(e){if(!["compact","recovered","der"].includes(e))throw new Error('Signature format must be "compact", "recovered", or "der"');return e}function Ze(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&&je(n.format),n}class qe extends Error{constructor(e=""){super(e)}}const He={Err:qe,_tlv:{encode:(e,t)=>{const{Err:n}=He;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=L(r);if(o.length/2&128)throw new n("tlv.encode: long form length too big");const i=r>127?L(o.length/2|128):"";return L(e)+i+o+t},decode(e,t){const{Err:n}=He;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}=He;if(e<We)throw new t("integer: negative integers are not allowed");let n=L(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}=He;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 Z(e)}},toSig(e){const{Err:t,_int:n,_tlv:r}=He,o=J("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}=He,r=t.encode(2,n.encode(e.r))+t.encode(2,n.encode(e.s));return t.encode(48,r)}},We=BigInt(0),Je=BigInt(1),Ke=BigInt(2),Xe=BigInt(3),Ye=BigInt(4);function Qe(e,t){const{BYTES:n}=e;let r;if("bigint"==typeof t)r=t;else{let i=J("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 et(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>ke))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;ee(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=nt(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 z(tt(!r.isOdd(i)),s)}return z(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(!p(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 p(e,t){const n=r.sqr(t),o=d(e);return r.eql(n,o)}if(!p(i.Gx,i.Gy))throw new Error("bad curve params: generator point");const g=r.mul(r.pow(i.a,Xe),Ye),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=Le(s*e,n),c=Le(-o*e,n);let u=e-a*r-c*i,l=-a*o-c*s;const f=u<We,h=l<We;f&&(u=-u),h&&(l=-l);const d=Q(Math.ceil(Y(n)/2))+Je;if(u<We||u>=d||l<We||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=te(((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=te((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(!p(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=Oe(o,t),n=Oe(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(J("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(Xe),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,Xe),{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,Xe);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=>$e(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 $e(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===We||r.is0())return T.ZERO;if(e===Je)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>ke||r>ke;)n&Se&&(i=i.add(o)),r&Se&&(s=s.add(o)),o=o.double(),n>>=Se,r>>=Se;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===Je||(e?e(T,this):A.unsafe(this,a).is0())}clearCofactor(){const{clearCofactor:e}=t;return s===Je?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 m(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 $e(T,e)}static msm(e,t){return function(e,t,n,r){De(n,e),Ne(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=Y(BigInt(o));let c=1;a>12?c=a-3:a>4?c=a-2:a>0&&(c=2);const u=Q(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(Qe(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 R=o.BITS,A=new Me(T,t.endo?Math.ceil(R/2):R);return T.BASE.precompute(8),T}function tt(e){return Uint8Array.of(e?2:3)}function nt(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function rt(e,t={}){const{Fn:n}=e,r=t.randomBytes||S,o=Object.assign(nt(e.Fp,n),{seed:Ae(n.ORDER)});function i(e){try{return!!Qe(n,e)}catch(t){return!1}}function s(e=r(o.seed)){return function(e,t,n=!1){const r=e.length,o=ze(t),i=Ae(t);if(r<16||r<i||r>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+r);const s=he(n?q(e):Z(e),t-re)+re;return n?W(s,o):H(s,o)}(U(e,o.seed,"seed"),n.ORDER)}function a(t,r=!0){return e.BASE.multiply(Qe(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=J("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=>Qe(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=Qe(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 ot(e,t,n={}){c(t),ee(n,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});const r=n.randomBytes||S,o=n.hmac||((e,...n)=>C(t,e,z(...n))),{Fp:s,Fn:a}=e,{ORDER:u,BITS:l}=a,{keygen:f,getPublicKey:h,getSharedSecret:d,utils:p,lengths:g}=rt(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>>Je}function v(e,t){if(!a.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){je(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}=He.toSig(U(e));return new B(t,n)}"recovered"===t&&(n=e[0],t="compact",e=e.subarray(1));const r=a.BYTES,o=e.subarray(0,r),i=e.subarray(r,2*r);return new B(a.fromBytes(o),a.fromBytes(i),n)}static fromHex(e,t){return this.fromBytes(x(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 c=2===i||3===i?r+u:r;if(!s.isValid(c))throw new Error("recovery id 2 or 3 invalid");const l=s.toBytes(c),f=e.fromBytes(z(tt(!(1&i)),l)),h=a.inv(c),d=T(J("msgHash",t)),p=a.create(-d*h),m=a.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(je(e),"der"===e)return x(He.hexFromSig(this));const t=a.toBytes(this.r),n=a.toBytes(this.s);if("recovered"===e){if(null==this.recovery)throw new Error("recovery bit must be present");return z(Uint8Array.of(this.recovery),t,n)}return z(t,n)}toHex(e){return m(this.toBytes(e))}assertValidity(){}static fromCompact(e){return B.fromBytes(J("sig",e),"compact")}static fromDER(e){return B.fromBytes(J("sig",e),"der")}normalizeS(){return this.hasHighS()?new B(this.r,a.neg(this.s),this.recovery):this}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return m(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return m(this.toBytes("compact"))}}const E=n.bits2int||function(e){if(e.length>8192)throw new Error("input is too large");const t=Z(e),n=8*e.length-l;return n>0?t>>BigInt(n):t},T=n.bits2int_modN||function(e){return a.create(E(e))},R=Q(l);function A(e){return X("num < 2^"+l,e,We,R),a.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:p,lengths:g,Point:e,sign:function(n,i,s={}){n=J("message",n);const{seed:c,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:c}=Ze(o,y);t=k(t,s);const u=T(t),l=Qe(a,n),f=[A(l),A(u)];if(null!=c&&!1!==c){const e=!0===c?r(g.secretKey):c;f.push(J("extraEntropy",e))}const h=z(...f),d=u;return{seed:h,k2sig:function(t){const n=E(t);if(!a.isValidNot0(n))return;const r=a.inv(n),o=e.BASE.multiply(n).toAffine(),s=a.create(o.x);if(s===We)return;const c=a.create(r*a.create(d+s*l));if(c===We)return;let u=(o.x===s?0:2)|Number(o.y&Je),f=c;return i&&b(c)&&(f=a.neg(c),u^=1),new B(s,f,u)}}}(n,i,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 z(...n)};return(e,t)=>{let n;for(c(),l(e);!(n=t(f()));)l();return c(),n}}(t.outputLen,a.BYTES,o)(c,u)},verify:function(t,n,r,o={}){const{lowS:s,prehash:c,format:u}=Ze(o,y);if(r=J("publicKey",r),n=k(J("message",n),c),"strict"in o)throw new Error("options.strict was renamed to lowS");const l=void 0===u?function(e){let t;const n="string"==typeof e||i(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(J("sig",e),"der")}catch(o){if(!(o instanceof He.Err))throw o}if(!t)try{t=B.fromBytes(J("sig",e),"compact")}catch(s){return!1}}return t||!1}(t):B.fromBytes(J("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,c=T(n),u=a.inv(i),f=a.create(c*u),h=a.create(o*u),d=e.BASE.multiplyUnsafe(f).add(t.multiplyUnsafe(h));if(d.is0())return!1;return a.create(d.x)===o}catch(f){return!1}},recoverPublicKey:function(e,t,n={}){const{prehash:r}=Ze(n,y);return t=k(t,r),B.fromBytes(e,"recovered").recoverPublicKey(t).toBytes()},Signature:B,hash:t})}function it(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:Re(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 st(e){const{CURVE:t,curveOpts:n,hash:r,ecdsaOpts:o}=function(e){const{CURVE:t,curveOpts:n}=it(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,Te(n.Fn.ORDER,n.Fn.BITS))})}(e,ot(et(t,n),r,o))}const at={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},ct={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]},ut=BigInt(2);const lt=Re(at.p,{sqrt:function(e){const t=at.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=de(l,n,t)*l%t,h=de(f,n,t)*l%t,d=de(h,ut,t)*u%t,p=de(d,o,t)*d%t,m=de(p,i,t)*p%t,g=de(m,a,t)*m%t,y=de(g,c,t)*g%t,w=de(y,a,t)*m%t,b=de(w,n,t)*l%t,v=de(b,s,t)*p%t,B=de(v,r,t)*u%t,E=de(B,ut,t);if(!lt.eql(lt.sqr(E),e))throw new Error("Cannot find square root");return E}}),ft=function(e,t){const n=t=>st({...e,hash:t});return{...n(t),create:n}}({...at,Fp:lt,lowS:!0,endo:ct},N);function ht(e,t){const n=[];for(let r=0;r<e.length;r+=t)n.push(e.subarray(r,r+t));return n}function dt(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 pt(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 mt(e){return Array.from(e).map((e=>e.toString(16).padStart(2,"0"))).join("")}function gt(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 yt(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 wt(e){const t=e.startsWith("0x")||e.startsWith("0X")?e.slice(2):e,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 bt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",vt="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";function Bt(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 Et(e,t){const n=t.length;let r=0,o=0,i="";for(const s of e)for(o=o<<8|s,r+=8;r>=Math.log2(n);)r-=Math.log2(n),i+=t.charAt(o>>r&n-1);return r>0&&(i+=t.charAt(o<<Math.log2(n)-r&n-1)),i.length%4!=0&&(i+="=".repeat(4-i.length%4)),i}function xt(e){return Et(e,vt)}function Tt(e){return new Uint8Array([e])}function Rt(e){return e[0]}function zt(e,t){return new DataView(e.buffer,e.byteOffset,e.byteLength).getUint16(0,"LE"===t)}function At(e,t){const n=new ArrayBuffer(4);return new DataView(n).setUint32(0,e,"LE"===t),new Uint8Array(n)}function kt(e,t){const n=new ArrayBuffer(8);return new DataView(n).setBigUint64(0,e,"LE"===t),new Uint8Array(n)}function St(e,t){return new DataView(e.buffer,e.byteOffset,e.byteLength).getBigUint64(0,"LE"===t)}var Ot=[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 $t(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];It(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=ht(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 It(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,N=e[14]<<6|e[15]>>>26,P=e[15]<<6|e[14]>>>26,C=e[17]<<23|e[16]>>>9,F=e[16]<<23|e[17]>>>9,G=e[18]<<20|e[19]>>>12,M=e[19]<<20|e[18]>>>12,U=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^~G&U,e[11]=S^~M&L,e[12]=G^~U&ee,e[13]=M^~L&te,e[14]=U^~ee&he,e[15]=L^~te&de,e[16]=ee^~he&k,e[17]=te^~de&S,e[18]=he^~k&G,e[19]=de^~S&M,e[20]=T^~N&W,e[21]=R^~P&J,e[22]=N^~W&se,e[23]=P^~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&N,e[29]=ue^~R&P,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]^=Ot[2*t],e[1]^=Ot[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 Vt=new TextDecoder,Dt=new TextEncoder,Nt=/^(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(!Nt.test(t)||t.replace(/^0x/i,"").length%2!=0)throw new Error(`Bytes#constructor: invalid hex string: ${t}`);this.bytes=wt(t)}else if(t instanceof ArrayBuffer)this.bytes=new Uint8Array(t);else if(t instanceof Uint8Array)this.bytes=t;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=wt(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($t(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 mt(this.bytes)}toBase64(){return Et(this.bytes,bt)}toBase32(){return xt(this.bytes)}toString(){return this.toHex()}toUtf8(){return Vt.decode(this.bytes)}toJSON(){return JSON.parse(this.toUtf8())}equals(t){return this.toHex()===new e(t).toHex()}represent(){return this.toHex()}},Ct=class extends Pt{static LENGTH=32;constructor(e){super(e,32)}},Ft=0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n;function Gt(e){if(e<=0n||e>=Ft)throw new Error("Invalid private key");const t=ft.Point.BASE.multiply(e);return[t.x,t.y]}function Mt(e){const t=new Uint8Array(20),n=$t(Pt.concat(gt(e[0],"BE"),gt(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=mt(e),n=mt($t(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)}},Lt=new Uint8Array(8).fill(255,0,8),jt=class e extends Pt{static LENGTH=8;static MINUS_ONE=new e(Lt);constructor(e){super(e,8)}static fromBigInt(t){return new e(kt(t,"BE"))}toBigInt(){return St(this.bytes,"BE")}next(){return mt(this.bytes)===mt(Lt)?e.fromBigInt(0n):e.fromBigInt(this.toBigInt()+1n)}},Zt=new TextEncoder,qt=class e extends Pt{static LENGTH=32;constructor(e){super(e,32)}static fromString(t){return new e($t(Zt.encode(t)))}},Ht=class extends Pt{static LENGTH=32;constructor(e){super(e,32)}};function Wt(e,t){const n=ft.sign($t(e),t,{prehash:!1}),r=0===n.recovery?27n:28n;return[n.r,n.s,r]}function Jt(e,t,n,r){const o=27n===r?0:1,i=new ft.Signature(t,n,o).recoverPublicKey($t(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=ft.Point.fromBytes(e);return[t.x,t.y]}(t.toUint8Array());super(Pt.concat(gt(e,"BE"),gt(n,"BE")),64)}else super(e,64)}address(){const e=yt(this.bytes.slice(0,32),"BE"),t=yt(this.bytes.slice(32,64),"BE");return new Ut(Mt([e,t]))}toCompressedUint8Array(){const e=yt(this.bytes.slice(0,32),"BE"),t=yt(this.bytes.slice(32,64),"BE");return n=[e,t],ft.Point.fromAffine({x:n[0],y:n[1]}).toBytes(!0);var n}toCompressedHex(){return mt(this.toCompressedUint8Array())}},Xt=new TextEncoder,Yt=Xt.encode("Ethereum Signed Message:\n32");function Qt(e){const t=e instanceof Uint8Array?e:Xt.encode(e);return Pt.concat(Yt,$t(t))}var en=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=yt(this.bytes.slice(0,32),"BE"),n=yt(this.bytes.slice(32,64),"BE"),r=BigInt(this.bytes[64]),[o,i]=Jt(Qt(e),t,n,r);return new Kt(Pt.concat(gt(o,"BE"),gt(i,"BE")))}isValid(e,t){return this.recoverPublicKey(e).address().equals(t)}},tn=class extends Pt{static LENGTH=32;constructor(e){super(e,32)}publicKey(){const[e,t]=Gt(this.toBigInt());return new Kt(Pt.concat(gt(e,"BE"),gt(t,"BE")))}sign(e){const[t,n,r]=Wt(Qt(e),this.toBigInt());return new en(Pt.concat(gt(t,"BE"),gt(n,"BE"),new Uint8Array([Number(r)])))}toBigInt(){return yt(this.bytes,"BE")}};function nn(e){const t=Bt(e.toUpperCase().slice(1),vt);const n=t[1];if(250!==n&&251!==n)throw new Error("Unknown codec");return t.slice(-32)}var rn=class e extends Pt{static LENGTH=32;constructor(e){"string"==typeof e&&e.startsWith("bah5")?super(nn(e),32):super(e,[32,64])}toCid(e){return`b${xt(Pt.concat(new Uint8Array([1]),new Uint8Array(["feed"===e?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}}},on=class e extends Pt{static LENGTH=8;constructor(e){super(e,8)}static fromBigInt(t){return new e(kt(t,"LE"))}toBigInt(){return St(this.bytes,"LE")}static fromSlice(t,n){return new e(t.slice(n,n+e.LENGTH))}},sn=new TextEncoder,an=class e extends Pt{static LENGTH=32;constructor(e){super(e,32)}static fromString(t){return new e($t(sn.encode(t)))}},cn=class extends Pt{static LENGTH=32;constructor(e){super(e,32)}},un=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}},ln=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 fn(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=$t($t(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 hn(e,t){return fn(e,128,t)}function dn(e,t){return fn(e,0,t)}var pn=4096;function mn(e){const t=e.subarray(0,8),n=function(e){if(e.length>pn)throw new Error(`payload size ${e.length} exceeds maximum chunk payload size 4096`);const t=new Uint8Array(pn);t.set(e);let n=ht(t,32);for(;n.length>1;){const e=[];for(let t=0;t<n.length;t+=2)e.push($t(Pt.concat(n[t],n[t+1])));n=e}return n[0]}(e.subarray(8));return new rn($t(Pt.concat(t,n)))}wt("dc5b20847f43d67928f49cd4f85d696b5a7617b5");var gn=qt.LENGTH,yn=qt.LENGTH+65,wn=yn+on.LENGTH,bn=(new TextEncoder).encode("Ethereum Signed Message:\n32");function vn(e,t){const n=$t(Pt.concat(e,t));return Pt.concat(bn,n)}function Bn(e,t,n){const[r,o,i]=Wt(vn(e,t),n);return Pt.concat(gt(r,"BE"),gt(o,"BE"),new Uint8Array([Number(i)]))}function En(e,t){const n=new qt(e),r=new Ut(t);return new rn($t(Pt.concat(n.toUint8Array(),r.toUint8Array())))}function xn(e,t,n){const r=new qt(t),o=Bn(r.toUint8Array(),e.address.toUint8Array(),n),i=new Ut(Mt(Gt(n))),s=En(r,i);return{data:Pt.concat(r.toUint8Array(),o,e.data),identifier:r,signature:new en(o),span:e.span,payload:e.payload,address:s,owner:i}}function Tn(e,t){const n=e instanceof Pt?e.toUint8Array():e,r=new rn(t),o=new qt(Pt.fromSlice(n,0,qt.LENGTH)),i=n.slice(gn,gn+65),s=mn(n.slice(yn)),a=new Ut(function(e,t,n){const r=yt(n.subarray(0,32),"BE"),o=yt(n.subarray(32,64),"BE"),i=BigInt(n[64]);return Mt(Jt(vn(e,t),r,o,i))}(o.toUint8Array(),s.toUint8Array(),i)),c=En(o,a);if(!c.equals(r))throw new Error("SOC data does not match given address");const u=on.fromSlice(n,yn),l=Pt.fromSlice(n,wn);return{data:n,identifier:o,signature:new en(i),span:u,payload:l,address:c,owner:a}}function Rn(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?on.fromBigInt(t):t:on.fromBigInt(BigInt(e.length)),r=new Pt(e),o=Pt.concat(n.toUint8Array(),r.toUint8Array()),i={data:o,span:n,payload:r,address:mn(o),toSingleOwnerChunk:(e,t)=>xn(i,e,new tn(t).toBigInt())};return i}function zn(e){const t=new Pt(e);return Rn(t.toUint8Array().slice(on.LENGTH),on.fromSlice(t.toUint8Array(),0))}var An=class{span;writer;constructor(e=0n){this.span=e,this.writer=new ln(new Uint8Array(4096))}build(){return Pt.concat(kt(this.span,"LE"),this.writer.buffer)}hash(){return mn(this.build())}encryptedHash(e){e||(e=new Uint8Array(32),crypto.getRandomValues(e));const t=hn(e,kt(this.span,"LE")),n=dn(e,this.writer.buffer);return{address:mn(Pt.concat(t,n)),key:e}}},kn=class e{static NOOP=async e=>[];refSize;encrypted;maxShards;chunks;counters=[1];pending=[[]];onBatch;onIntermediateChunk;hasParity=[!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 An],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 un(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.counters[e]=(this.counters[e]+1)%(4096/this.refSize),this.pending[e]||(this.pending[e]=[]),await this.sealParities(e);const t=this.chunks[e].span;if(e>=1&&this.onIntermediateChunk&&(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 An,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 un(t.hash().toUint8Array()))}}async flushBatch(e){this.chunks[e+1]||(this.chunks.push(new An),this.counters.push(1),this.pending.push([]),this.hasParity.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){return this.pending[e]?.length&&await this.flushBatch(e),this.chunks[e+1]?1===this.counters[e]?(await this.elevate(e+1),await this.flushBatch(e+1),this.chunks[e+1]=this.chunks[e],this.finalize(e+1)):(await this.elevate(e),await this.flushBatch(e),this.finalize(e+1)):(await this.sealParities(e),e>=1&&this.onIntermediateChunk&&this.onIntermediateChunk(this.chunks[e],this.hasParity[e]??!1),this.chunks[e])}},Sn=[[[],[]],[[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]]],On=[[[],[]],[[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 $n(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?On[e]:Sn[e],t)}function In(e,t,n){return t<=0||e<=0?0:$n(t,e,n)/e}var _n={label:"medium",value:1,errorTolerance:.01},Vn={label:"strong",value:2,errorTolerance:.05},Dn={label:"insane",value:3,errorTolerance:.1},Nn={label:"paranoid",value:4,errorTolerance:.5};function Pn(){return{medium:_n,strong:Vn,insane:Dn,paranoid:Nn}}function Cn(e){if("string"==typeof e)switch(e.toLowerCase()){case"medium":return _n;case"strong":return Vn;case"insane":return Dn;case"paranoid":return Nn;default:throw new Error(`Unknown redundancy level '${e}'`)}switch(e){case 1:return _n;case 2:return Vn;case 3:return Dn;case 4:return Nn;default:throw new Error(`Unknown redundancy level '${e}'`)}}function Fn(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}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 Gn=new TextEncoder,Mn=new TextDecoder,Un=new Uint8Array([47]),Ln=wt("5768b3b6a7db56d21d1abff40d41cebfc83448fed8d7e9b06ec0d3b073f28f7b");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=new Uint8Array(32);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),e?.obfuscationKey&&(this.obfuscationKey=e.obfuscationKey),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());this.encrypt&&dt(this.obfuscationKey,new Uint8Array(32))&&(this.obfuscationKey=new Uint8Array(32),crypto.getRandomValues(this.obfuscationKey));const e=!dt(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(Ln,0),n.set(Tt(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)}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 un(o);if(!dt(i.read(31),Ln.slice(0,31)))throw new Error("MantarayNode#unmarshalFromData invalid version hash");const s=Rt(i.read(1)),a=i.read(s),c=new e({selfAddress:n,targetAddress:a,obfuscationKey:r}),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}return c}addFork(t,n,r){this.selfAddress=null,this.type=null,t=t instanceof Uint8Array?t:Gn.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)continue;const l=new Jn(u,new e({targetAddress:s?new rn(n).toUint8Array():void 0,metadata:s?r:void 0,path:u,encrypt:this.encrypt})),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.selfAddress=null,o.type=null,o=l.node}}removeFork(e){if(this.selfAddress=null,this.type=null,0===(e=e instanceof Uint8Array?e:Gn.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");const[n,r]=this.findClosest(e.slice(0,e.length-1));n.forks.delete(e.slice(r.length)[0]);for(const o of t.forks.values())n.addFork(Pt.concat(t.path,o.prefix),o.node.targetAddress,o.node.metadata)}async calculateSelfAddress(){if(this.selfAddress)return new rn(this.selfAddress);if(this.encrypt)throw new Error("MantarayNode#calculateSelfAddress is not supported for encrypted nodes - use saveRecursively");return(await kn.root(await this.marshal())).hash()}async saveRecursively(e){for(const r of this.forks.values())await r.node.saveRecursively(e);const t=new kn((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),{reference:this.selfAddress,rootChunk:n,encryptionKey:r}}return await e(n),this.selfAddress=n.hash().toUint8Array(),{reference:this.selfAddress,rootChunk:n}}find(e){const t=e instanceof Uint8Array?e:Gn.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:Gn.encode(e)).length)return[this,t];const n=this.forks.get(e[0]);return n&&pt(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())dt(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 rn(t.targetAddress).toHex();return e}determineType(){let e=0;const t=new Uint8Array(this.targetAddress.length);return dt(this.targetAddress,t)&&0!==this.forks.size||(e|=2),this.forks.size>0&&(e|=4),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}(this.path,Un)>0&&(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=pt(t.prefix,n.prefix);if(r.length===t.prefix.length){const e=n.prefix.slice(r.length);return n.node.path=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.path=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.path=t.prefix.slice(r.length),n.node.path=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(Tt(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=Rt(t.read(1)),o=Rt(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=zt(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}))}};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){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 tn(t),new Ct(n),new Uint32Array(65536),r)}static fromState(t,n,r,o){return new e(new tn(t),new Ct(n),r,o)}stamp(e,t){const n=zt(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 tn(e),s=new Ct(t),a=zt(n,"BE"),c=Pt.concat(At(a,"BE"),At(r,"BE")),u=kt(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}};function cr(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 ur extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class lr extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}}(sr=globalThis).__zod_globalConfig??(sr.__zod_globalConfig={});const fr=globalThis.__zod_globalConfig;function hr(e){return e&&Object.assign(fr,e),fr}const dr=/^[cC][0-9a-z]{6,}$/,pr=/^[0-9a-z]+$/,mr=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,gr=/^[0-9a-vA-V]{20}$/,yr=/^[A-Za-z0-9]{27}$/,wr=/^[a-zA-Z0-9_-]{21}$/,br=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,vr=/^([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})$/,Br=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)$/,Er=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;const xr=/^(?:(?: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])$/,Tr=/^(([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}|:))$/,Rr=/^((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])$/,zr=/^(([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])$/,Ar=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,kr=/^[A-Za-z0-9_-]*$/,Sr=/^https?$/,Or=/^\+[1-9]\d{6,14}$/,$r="(?:(?:\\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])))",Ir=new RegExp(`^${$r}$`);function _r(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 Vr=/^-?\d+n?$/,Dr=/^-?\d+$/,Nr=/^-?\d+(?:\.\d+)?$/,Pr=/^(?:true|false)$/i,Cr=/^[^A-Z]*$/,Fr=/^[^a-z]*$/;function Gr(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 Mr(e,t){return"bigint"==typeof t?t.toString():t}function Ur(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Lr(e){return null==e}function jr(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}const Zr=Symbol("evaluating");function qr(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Zr)return void 0===r&&(r=Zr,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function Hr(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Wr(...e){const t={};for(const n of e){const e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function Jr(e){return JSON.stringify(e)}const Kr="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Xr(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}const Yr=Ur((()=>{if(fr.jitless)return!1;if("undefined"!=typeof navigator&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}}));function Qr(e){if(!1===Xr(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!==Xr(n)&&!1!==Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")}function eo(e){return Qr(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const to=new Set(["string","number","symbol"]);function no(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ro(e,t,n){const r=new e._zod.constr(t??e._zod.def);return t&&!n?.parent||(r._zod.parent=e),r}function oo(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 io={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 so(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 ao(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 co(e,t){return t.map((t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t}))}function uo(e){return"string"==typeof e?e:e?.message}function lo(e,t,n){const r=e.message?e.message:uo(e.inst?._zod.def?.error?.(e))??uo(t?.error?.(e))??uo(n.customError?.(e))??uo(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 fo(e){return Array.isArray(e)?"array":"string"==typeof e?"string":"unknown"}function ho(...e){const[t,n,r]=e;return"string"==typeof t?{message:t,code:"custom",input:n,inst:r}:{...t}}const po=cr("$ZodCheck",((e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])})),mo={number:"number",bigint:"bigint",object:"date"},go=cr("$ZodCheckLessThan",((e,t)=>{po.init(e,t);const n=mo[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})}})),yo=cr("$ZodCheckGreaterThan",((e,t)=>{po.init(e,t);const n=mo[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})}})),wo=cr("$ZodCheckMultipleOf",((e,t)=>{po.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})}})),bo=cr("$ZodCheckNumberFormat",((e,t)=>{po.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),r=n?"int":"number",[o,i]=io[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=Dr)})),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})}})),vo=cr("$ZodCheckMaxLength",((e,t)=>{var n;po.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!Lr(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=fo(r);n.issues.push({origin:o,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}})),Bo=cr("$ZodCheckMinLength",((e,t)=>{var n;po.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!Lr(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=fo(r);n.issues.push({origin:o,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}})),Eo=cr("$ZodCheckLengthEquals",((e,t)=>{var n;po.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!Lr(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=fo(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})}})),xo=cr("$ZodCheckStringFormat",((e,t)=>{var n,r;po.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=()=>{})})),To=cr("$ZodCheckRegex",((e,t)=>{xo.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})}})),Ro=cr("$ZodCheckLowerCase",((e,t)=>{t.pattern??(t.pattern=Cr),xo.init(e,t)})),zo=cr("$ZodCheckUpperCase",((e,t)=>{t.pattern??(t.pattern=Fr),xo.init(e,t)})),Ao=cr("$ZodCheckIncludes",((e,t)=>{po.init(e,t);const n=no(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})}})),ko=cr("$ZodCheckStartsWith",((e,t)=>{po.init(e,t);const n=new RegExp(`^${no(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})}})),So=cr("$ZodCheckEndsWith",((e,t)=>{po.init(e,t);const n=new RegExp(`.*${no(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 Oo=cr("$ZodCheckOverwrite",((e,t)=>{po.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}));class $o{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 Io=(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,Mr,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},_o=cr("$ZodError",Io),Vo=cr("$ZodError",Io,{Parent:Error});const Do=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 ur;if(s.issues.length){const t=new(o?.Err??e)(s.issues.map((e=>lo(e,i,hr()))));throw Kr(t,o?.callee),t}return s.value},No=Do(Vo),Po=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=>lo(e,i,hr()))));throw Kr(t,o?.callee),t}return s.value},Co=Po(Vo),Fo=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 ur;return i.issues.length?{success:!1,error:new(e??_o)(i.issues.map((e=>lo(e,o,hr()))))}:{success:!0,data:i.value}},Go=Fo(Vo),Mo=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=>lo(e,o,hr()))))}:{success:!0,data:i.value}},Uo=Mo(Vo),Lo=e=>(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return Do(e)(t,n,o)},jo=e=>(t,n,r)=>Do(e)(t,n,r),Zo=e=>async(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return Po(e)(t,n,o)},qo=e=>async(t,n,r)=>Po(e)(t,n,r),Ho=e=>(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return Fo(e)(t,n,o)},Wo=e=>(t,n,r)=>Fo(e)(t,n,r),Jo=e=>async(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return Mo(e)(t,n,o)},Ko=e=>async(t,n,r)=>Mo(e)(t,n,r),Xo={major:4,minor:4,patch:3};const Yo=cr("$ZodType",((e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Xo;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=so(e);for(const i of t){if(i._zod.def.when){if(ao(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 ur;if(r||s instanceof Promise)r=(r??Promise.resolve()).then((async()=>{await s;e.issues.length!==t&&(o||(o=so(e,t)))}));else{if(e.issues.length===t)continue;o||(o=so(e,t))}}return r?r.then((()=>e)):e},n=(n,o,i)=>{if(so(n))return n.aborted=!0,n;const s=t(o,r,i);if(s instanceof Promise){if(!1===i.async)throw new ur;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 ur;return s.then((e=>t(e,r,i)))}return t(s,r,i)}}qr(e,"~standard",(()=>({validate:t=>{try{const n=Go(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch(n){return Uo(e,t).then((e=>e.success?{value:e.data}:{issues:e.error?.issues}))}},vendor:"zod",version:1})))})),Qo=cr("$ZodString",((e,t)=>{var n;Yo.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}})),ei=cr("$ZodStringFormat",((e,t)=>{xo.init(e,t),Qo.init(e,t)})),ti=cr("$ZodGUID",((e,t)=>{t.pattern??(t.pattern=vr),ei.init(e,t)})),ni=cr("$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=Br(e))}else t.pattern??(t.pattern=Br());ei.init(e,t)})),ri=cr("$ZodEmail",((e,t)=>{t.pattern??(t.pattern=Er),ei.init(e,t)})),oi=cr("$ZodURL",((e,t)=>{ei.init(e,t),e._zod.check=n=>{try{const r=n.value.trim();if(!t.normalize&&t.protocol?.source===Sr.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})}}})),ii=cr("$ZodEmoji",((e,t)=>{t.pattern??(t.pattern=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),ei.init(e,t)})),si=cr("$ZodNanoID",((e,t)=>{t.pattern??(t.pattern=wr),ei.init(e,t)})),ai=cr("$ZodCUID",((e,t)=>{t.pattern??(t.pattern=dr),ei.init(e,t)})),ci=cr("$ZodCUID2",((e,t)=>{t.pattern??(t.pattern=pr),ei.init(e,t)})),ui=cr("$ZodULID",((e,t)=>{t.pattern??(t.pattern=mr),ei.init(e,t)})),li=cr("$ZodXID",((e,t)=>{t.pattern??(t.pattern=gr),ei.init(e,t)})),fi=cr("$ZodKSUID",((e,t)=>{t.pattern??(t.pattern=yr),ei.init(e,t)})),hi=cr("$ZodISODateTime",((e,t)=>{t.pattern??(t.pattern=function(e){const t=_r({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(`^${$r}T(?:${r})$`)}(t)),ei.init(e,t)})),di=cr("$ZodISODate",((e,t)=>{t.pattern??(t.pattern=Ir),ei.init(e,t)})),pi=cr("$ZodISOTime",((e,t)=>{t.pattern??(t.pattern=new RegExp(`^${_r(t)}$`)),ei.init(e,t)})),mi=cr("$ZodISODuration",((e,t)=>{t.pattern??(t.pattern=br),ei.init(e,t)})),gi=cr("$ZodIPv4",((e,t)=>{t.pattern??(t.pattern=xr),ei.init(e,t),e._zod.bag.format="ipv4"})),yi=cr("$ZodIPv6",((e,t)=>{t.pattern??(t.pattern=Tr),ei.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})}}})),wi=cr("$ZodCIDRv4",((e,t)=>{t.pattern??(t.pattern=Rr),ei.init(e,t)})),bi=cr("$ZodCIDRv6",((e,t)=>{t.pattern??(t.pattern=zr),ei.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 vi(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 Bi=cr("$ZodBase64",((e,t)=>{t.pattern??(t.pattern=Ar),ei.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{vi(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}}));const Ei=cr("$ZodBase64URL",((e,t)=>{t.pattern??(t.pattern=kr),ei.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{(function(e){if(!kr.test(e))return!1;const t=e.replace(/[-_]/g,(e=>"-"===e?"+":"/"));return vi(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})}})),xi=cr("$ZodE164",((e,t)=>{t.pattern??(t.pattern=Or),ei.init(e,t)}));const Ti=cr("$ZodJWT",((e,t)=>{ei.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})}})),Ri=cr("$ZodNumber",((e,t)=>{Yo.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}})),zi=cr("$ZodNumberFormat",((e,t)=>{bo.init(e,t),Ri.init(e,t)})),Ai=cr("$ZodBoolean",((e,t)=>{Yo.init(e,t),e._zod.pattern=Pr,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}})),ki=cr("$ZodBigInt",((e,t)=>{Yo.init(e,t),e._zod.pattern=Vr,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}})),Si=cr("$ZodAny",((e,t)=>{Yo.init(e,t),e._zod.parse=e=>e})),Oi=cr("$ZodUnknown",((e,t)=>{Yo.init(e,t),e._zod.parse=e=>e})),$i=cr("$ZodNever",((e,t)=>{Yo.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:e}),t)}));function Ii(e,t,n){e.issues.length&&t.issues.push(...co(n,e.issues)),t.value[n]=e.value}const _i=cr("$ZodArray",((e,t)=>{Yo.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=>Ii(t,n,e)))):Ii(a,n,e)}return i.length?Promise.all(i).then((()=>n)):n}}));function Vi(e,t,n,r,o,i){const s=n in r;if(e.issues.length){if(o&&i&&!s)return;t.issues.push(...co(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 Di(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=>Vi(e,n,h,t,l,f)))):Vi(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 Pi=cr("$ZodObject",((e,t)=>{Yo.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=Ur((()=>Di(t)));qr(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=Xr,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=>Vi(n,t,e,a,o,i)))):Vi(s,t,e,a,o,i)}return i?Ni(c,a,t,n,r.value,e):c.length?Promise.all(c).then((()=>t)):t}})),Ci=cr("$ZodObjectJIT",((e,t)=>{Pi.init(e,t);const n=e._zod.parse,r=Ur((()=>Di(t)));let o;const i=Xr,s=!fr.jitless,a=s&&Yr.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 $o(["shape","payload","ctx"]),n=r.value,o=e=>{const t=Jr(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=Jr(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 Fi(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=>!so(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=>lo(e,r,hr())))))}),t)}const Gi=cr("$ZodUnion",((e,t)=>{Yo.init(e,t),qr(e._zod,"optin",(()=>t.options.some((e=>"optional"===e._zod.optin))?"optional":void 0)),qr(e._zod,"optout",(()=>t.options.some((e=>"optional"===e._zod.optout))?"optional":void 0)),qr(e._zod,"values",(()=>{if(t.options.every((e=>e._zod.values)))return new Set(t.options.flatMap((e=>Array.from(e._zod.values))))})),qr(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=>jr(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=>Fi(t,r,e,o))):Fi(s,r,e,o)}}));const Mi=cr("$ZodIntersection",((e,t)=>{Yo.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])=>Li(e,t,n))):Li(e,o,i)}}));function Ui(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(Qr(e)&&Qr(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=Ui(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=Ui(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 Li(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}),so(e))return e;const s=Ui(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 ji=cr("$ZodTuple",((e,t)=>{Yo.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=Zi(n,"optin"),c=Zi(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=>qi(t,r,e)))):qi(i,r,e)}}return s.length?Promise.all(s).then((()=>Hi(u,r,n,i,c))):Hi(u,r,n,i,c)}}));function Zi(e,t){for(let n=e.length-1;n>=0;n--)if("optional"!==e[n]._zod[t])return n+1;return 0}function qi(e,t,n){e.issues.length&&t.issues.push(...co(n,e.issues)),t.value[n]=e.value}function Hi(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(...co(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 Wi=cr("$ZodRecord",((e,t)=>{Yo.init(e,t),e._zod.parse=(n,r)=>{const o=n.value;if(!Qr(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=>lo(e,r,hr()))),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(...co(u,e.issues)),n.value[c]=e.value}))):(l.issues.length&&n.issues.push(...co(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=>lo(e,r,hr()))),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(...co(s,e.issues)),n.value[a.value]=e.value}))):(c.issues.length&&n.issues.push(...co(s,c.issues)),n.value[a.value]=c.value)}}return i.length?Promise.all(i).then((()=>n)):n}}));const Ji=cr("$ZodEnum",((e,t)=>{Yo.init(e,t);const n=Gr(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter((e=>to.has(typeof e))).map((e=>"string"==typeof e?no(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}})),Ki=cr("$ZodLiteral",((e,t)=>{if(Yo.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?no(e):e?no(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}})),Xi=cr("$ZodTransform",((e,t)=>{Yo.init(e,t),e._zod.optin="optional",e._zod.parse=(n,r)=>{if("backward"===r.direction)throw new lr(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 ur;return n.value=o,n.fallback=!0,n}}));function Yi(e,t){return void 0===t&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}const Qi=cr("$ZodOptional",((e,t)=>{Yo.init(e,t),e._zod.optin="optional",e._zod.optout="optional",qr(e._zod,"values",(()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0)),qr(e._zod,"pattern",(()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${jr(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=>Yi(e,r))):Yi(o,r)}return void 0===e.value?e:t.innerType._zod.run(e,n)}})),es=cr("$ZodExactOptional",((e,t)=>{Qi.init(e,t),qr(e._zod,"values",(()=>t.innerType._zod.values)),qr(e._zod,"pattern",(()=>t.innerType._zod.pattern)),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)})),ts=cr("$ZodNullable",((e,t)=>{Yo.init(e,t),qr(e._zod,"optin",(()=>t.innerType._zod.optin)),qr(e._zod,"optout",(()=>t.innerType._zod.optout)),qr(e._zod,"pattern",(()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${jr(e.source)}|null)$`):void 0})),qr(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)})),ns=cr("$ZodDefault",((e,t)=>{Yo.init(e,t),e._zod.optin="optional",qr(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=>rs(e,t))):rs(r,t)}}));function rs(e,t){return void 0===e.value&&(e.value=t.defaultValue),e}const os=cr("$ZodPrefault",((e,t)=>{Yo.init(e,t),e._zod.optin="optional",qr(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))})),is=cr("$ZodNonOptional",((e,t)=>{Yo.init(e,t),qr(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=>ss(t,e))):ss(o,e)}}));function ss(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 as=cr("$ZodCatch",((e,t)=>{Yo.init(e,t),e._zod.optin="optional",qr(e._zod,"optout",(()=>t.innerType._zod.optout)),qr(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=>lo(e,n,hr())))},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=>lo(e,n,hr())))},input:e.value}),e.issues=[],e.fallback=!0),e)}})),cs=cr("$ZodPipe",((e,t)=>{Yo.init(e,t),qr(e._zod,"values",(()=>t.in._zod.values)),qr(e._zod,"optin",(()=>t.in._zod.optin)),qr(e._zod,"optout",(()=>t.out._zod.optout)),qr(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=>us(e,t.in,n))):us(r,t.in,n)}const r=t.in._zod.run(e,n);return r instanceof Promise?r.then((e=>us(e,t.out,n))):us(r,t.out,n)}}));function us(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 ls=cr("$ZodReadonly",((e,t)=>{Yo.init(e,t),qr(e._zod,"propValues",(()=>t.innerType._zod.propValues)),qr(e._zod,"values",(()=>t.innerType._zod.values)),qr(e._zod,"optin",(()=>t.innerType?._zod?.optin)),qr(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(fs):fs(r)}}));function fs(e){return e.value=Object.freeze(e.value),e}const hs=cr("$ZodFunction",((e,t)=>(Yo.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 Co(e._def.input,n):n,o=await Reflect.apply(t,this,r);return e._def.output?await Co(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 ji({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))),ds=cr("$ZodCustom",((e,t)=>{po.init(e,t),Yo.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=>ps(t,n,r,e)));ps(o,n,r,e)}}));function ps(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(ho(e))}}var ms;Symbol("ZodOutput"),Symbol("ZodInput");class gs{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)}}(ms=globalThis).__zod_globalRegistry??(ms.__zod_globalRegistry=new gs);const ys=globalThis.__zod_globalRegistry;function ws(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...oo(t)})}function bs(e,t){return new go({check:"less_than",...oo(t),value:e,inclusive:!1})}function vs(e,t){return new go({check:"less_than",...oo(t),value:e,inclusive:!0})}function Bs(e,t){return new yo({check:"greater_than",...oo(t),value:e,inclusive:!1})}function Es(e,t){return new yo({check:"greater_than",...oo(t),value:e,inclusive:!0})}function xs(e,t){return new wo({check:"multiple_of",...oo(t),value:e})}function Ts(e,t){return new vo({check:"max_length",...oo(t),maximum:e})}function Rs(e,t){return new Bo({check:"min_length",...oo(t),minimum:e})}function zs(e,t){return new Eo({check:"length_equals",...oo(t),length:e})}function As(e){return new Oo({check:"overwrite",tx:e})}function ks(e,t){const n=function(e,t){const n=new po({check:"custom",...oo(t)});return n._zod.check=e,n}((t=>(t.addIssue=e=>{if("string"==typeof e)t.issues.push(ho(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(ho(r))}},e(t.value,t))),t);return n}function Ss(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??ys,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 Os(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),Os(i,t,r),t.seen.get(i).isParent=!0)}const c=t.metadataRegistry.get(e);c&&Object.assign(s.schema,c),"input"===t.io&&_s(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 $s(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 Is(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:Vs(t,"input",e.processors),output:Vs(t,"output",e.processors)}},enumerable:!1,writable:!1}),n}catch(a){throw new Error("Error converting schema to JSON.")}}function _s(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 _s(r.element,n);if("set"===r.type)return _s(r.valueType,n);if("lazy"===r.type)return _s(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 _s(r.innerType,n);if("intersection"===r.type)return _s(r.left,n)||_s(r.right,n);if("record"===r.type||"map"===r.type)return _s(r.keyType,n)||_s(r.valueType,n);if("pipe"===r.type)return!!e._zod.traits.has("$ZodCodec")||(_s(r.in,n)||_s(r.out,n));if("object"===r.type){for(const e in r.shape)if(_s(r.shape[e],n))return!0;return!1}if("union"===r.type){for(const e of r.options)if(_s(e,n))return!0;return!1}if("tuple"===r.type){for(const e of r.items)if(_s(e,n))return!0;return!(!r.rest||!_s(r.rest,n))}return!1}const Vs=(e,t,n={})=>r=>{const{libraryOptions:o,target:i}=r??{},s=Ss({...o??{},target:i,io:t,processors:n});return Os(e,s),$s(s,e),Is(s,e)};const Ds={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=Ds[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})))])}},Ps=(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)},Cs=(e,t,n,r)=>{n.type="boolean"},Fs=(e,t,n,r)=>{if("throw"===t.unrepresentable)throw new Error("BigInt cannot be represented in JSON Schema")},Gs=(e,t,n,r)=>{n.not={}},Ms=(e,t,n,r)=>{const o=Gr(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},Us=(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},Ls=(e,t,n,r)=>{if("throw"===t.unrepresentable)throw new Error("Custom types cannot be represented in JSON Schema")},js=(e,t,n,r)=>{if("throw"===t.unrepresentable)throw new Error("Function types cannot be represented in JSON Schema")},Zs=(e,t,n,r)=>{if("throw"===t.unrepresentable)throw new Error("Transforms cannot be represented in JSON Schema")},qs=(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=Os(i.element,t,{...r,path:[...r.path,"items"]})},Hs=(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]=Os(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=Os(i.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):"output"===t.io&&(o.additionalProperties=!1)},Ws=(e,t,n,r)=>{const o=e._zod.def,i=!1===o.inclusive,s=o.options.map(((e,n)=>Os(e,t,{...r,path:[...r.path,i?"oneOf":"anyOf",n]})));i?n.oneOf=s:n.anyOf=s},Js=(e,t,n,r)=>{const o=e._zod.def,i=Os(o.left,t,{...r,path:[...r.path,"allOf",0]}),s=Os(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},Ks=(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)=>Os(e,t,{...r,path:[...r.path,s,n]}))),u=i.rest?Os(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)},Xs=(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=Os(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=Os(i.keyType,t,{...r,path:[...r.path,"propertyNames"]})),o.additionalProperties=Os(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)}},Ys=(e,t,n,r)=>{const o=e._zod.def,i=Os(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"}]},Qs=(e,t,n,r)=>{const o=e._zod.def;Os(o.innerType,t,r);t.seen.get(e).ref=o.innerType},ea=(e,t,n,r)=>{const o=e._zod.def;Os(o.innerType,t,r);t.seen.get(e).ref=o.innerType,n.default=JSON.parse(JSON.stringify(o.defaultValue))},ta=(e,t,n,r)=>{const o=e._zod.def;Os(o.innerType,t,r);t.seen.get(e).ref=o.innerType,"input"===t.io&&(n._prefault=JSON.parse(JSON.stringify(o.defaultValue)))},na=(e,t,n,r)=>{const o=e._zod.def;Os(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},ra=(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;Os(s,t,r);t.seen.get(e).ref=s},oa=(e,t,n,r)=>{const o=e._zod.def;Os(o.innerType,t,r);t.seen.get(e).ref=o.innerType,n.readOnly=!0},ia=(e,t,n,r)=>{const o=e._zod.def;Os(o.innerType,t,r);t.seen.get(e).ref=o.innerType};const sa=cr("ZodISODateTime",((e,t)=>{hi.init(e,t),Va.init(e,t)}));function aa(e){return function(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...oo(t)})}(sa,e)}const ca=cr("ZodISODate",((e,t)=>{di.init(e,t),Va.init(e,t)}));function ua(e){return function(e,t){return new e({type:"string",format:"date",check:"string_format",...oo(t)})}(ca,e)}const la=cr("ZodISOTime",((e,t)=>{pi.init(e,t),Va.init(e,t)}));function fa(e){return function(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...oo(t)})}(la,e)}const ha=cr("ZodISODuration",((e,t)=>{mi.init(e,t),Va.init(e,t)}));function da(e){return function(e,t){return new e({type:"string",format:"duration",check:"string_format",...oo(t)})}(ha,e)}const pa=(e,t)=>{_o.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,Mr,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Mr,2)}},isEmpty:{get:()=>0===e.issues.length}})},ma=cr("ZodError",pa,{Parent:Error}),ga=Do(ma),ya=Po(ma),wa=Fo(ma),ba=Mo(ma),va=Lo(ma),Ba=jo(ma),Ea=Zo(ma),xa=qo(ma),Ta=Ho(ma),Ra=Wo(ma),za=Jo(ma),Aa=Ko(ma);const ka=new WeakMap;function Sa(e,t,n){const r=Object.getPrototypeOf(e);let o=ka.get(r);if(o||(o=new Set,ka.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 Oa=cr("ZodType",((e,t)=>(Yo.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Vs(e,"input"),output:Vs(e,"output")}}),e.toJSONSchema=((e,t={})=>n=>{const r=Ss({...n,processors:t});return Os(e,r),$s(r,e),Is(r,e)})(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>ga(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>wa(e,t,n),e.parseAsync=async(t,n)=>ya(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>ba(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>va(e,t,n),e.decode=(t,n)=>Ba(e,t,n),e.encodeAsync=async(t,n)=>Ea(e,t,n),e.decodeAsync=async(t,n)=>xa(e,t,n),e.safeEncode=(t,n)=>Ta(e,t,n),e.safeDecode=(t,n)=>Ra(e,t,n),e.safeEncodeAsync=async(t,n)=>za(e,t,n),e.safeDecodeAsync=async(t,n)=>Aa(e,t,n),Sa(e,"ZodType",{check(...e){const t=this.def;return this.clone(Wr(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 ro(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,...oo(n)})}(Lc,e,t)}(e,t))},superRefine(e,t){return this.check(function(e,t){return ks(e,t)}(e,t))},overwrite(e){return this.check(As(e))},optional(){return $c(this)},exactOptional(){return new Ic({type:"optional",innerType:this})},nullable(){return Vc(this)},nullish(){return $c(Vc(this))},nonoptional(e){return function(e,t){return new Pc({type:"nonoptional",innerType:e,...oo(t)})}(this,e)},array(){return mc(this)},or(e){return bc([this,e])},and(e){return new vc({type:"intersection",left:this,right:e})},transform(e){return Gc(this,Sc(e))},default(e){return t=e,new Dc({type:"default",innerType:this,get defaultValue(){return"function"==typeof t?t():eo(t)}});var t},prefault(e){return t=e,new Nc({type:"prefault",innerType:this,get defaultValue(){return"function"==typeof t?t():eo(t)}});var t},catch(e){return new Cc({type:"catch",innerType:this,catchValue:"function"==typeof(t=e)?t:()=>t});var t},pipe(e){return Gc(this,e)},readonly(){return new Mc({type:"readonly",innerType:this})},describe(e){const t=this.clone();return ys.add(t,{description:e}),t},meta(...e){if(0===e.length)return ys.get(this);const t=this.clone();return ys.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:()=>ys.get(e)?.description,configurable:!0}),e))),$a=cr("_ZodString",((e,t)=>{Qo.init(e,t),Oa.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,Sa(e,"_ZodString",{regex(...e){return this.check(function(e,t){return new To({check:"string_format",format:"regex",...oo(t),pattern:e})}(...e))},includes(...e){return this.check(function(e,t){return new Ao({check:"string_format",format:"includes",...oo(t),includes:e})}(...e))},startsWith(...e){return this.check(function(e,t){return new ko({check:"string_format",format:"starts_with",...oo(t),prefix:e})}(...e))},endsWith(...e){return this.check(function(e,t){return new So({check:"string_format",format:"ends_with",...oo(t),suffix:e})}(...e))},min(...e){return this.check(Rs(...e))},max(...e){return this.check(Ts(...e))},length(...e){return this.check(zs(...e))},nonempty(...e){return this.check(Rs(1,...e))},lowercase(e){return this.check(function(e){return new Ro({check:"string_format",format:"lowercase",...oo(e)})}(e))},uppercase(e){return this.check(function(e){return new zo({check:"string_format",format:"uppercase",...oo(e)})}(e))},trim(){return this.check(As((e=>e.trim())))},normalize(...e){return this.check(function(e){return As((t=>t.normalize(e)))}(...e))},toLowerCase(){return this.check(As((e=>e.toLowerCase())))},toUpperCase(){return this.check(As((e=>e.toUpperCase())))},slugify(){return this.check(As((e=>function(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}(e))))}})})),Ia=cr("ZodString",((e,t)=>{Qo.init(e,t),$a.init(e,t),e.email=t=>e.check(function(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...oo(t)})}(Da,t)),e.url=t=>e.check(function(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...oo(t)})}(Ca,t)),e.jwt=t=>e.check(function(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...oo(t)})}(Qa,t)),e.emoji=t=>e.check(function(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...oo(t)})}(Fa,t)),e.guid=t=>e.check(ws(Na,t)),e.uuid=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...oo(t)})}(Pa,t)),e.uuidv4=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...oo(t)})}(Pa,t)),e.uuidv6=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...oo(t)})}(Pa,t)),e.uuidv7=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...oo(t)})}(Pa,t)),e.nanoid=t=>e.check(function(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...oo(t)})}(Ga,t)),e.guid=t=>e.check(ws(Na,t)),e.cuid=t=>e.check(function(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...oo(t)})}(Ma,t)),e.cuid2=t=>e.check(function(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...oo(t)})}(Ua,t)),e.ulid=t=>e.check(function(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...oo(t)})}(La,t)),e.base64=t=>e.check(function(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...oo(t)})}(Ka,t)),e.base64url=t=>e.check(function(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...oo(t)})}(Xa,t)),e.xid=t=>e.check(function(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...oo(t)})}(ja,t)),e.ksuid=t=>e.check(function(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...oo(t)})}(Za,t)),e.ipv4=t=>e.check(function(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...oo(t)})}(qa,t)),e.ipv6=t=>e.check(function(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...oo(t)})}(Ha,t)),e.cidrv4=t=>e.check(function(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...oo(t)})}(Wa,t)),e.cidrv6=t=>e.check(function(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...oo(t)})}(Ja,t)),e.e164=t=>e.check(function(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...oo(t)})}(Ya,t)),e.datetime=t=>e.check(aa(t)),e.date=t=>e.check(ua(t)),e.time=t=>e.check(fa(t)),e.duration=t=>e.check(da(t))}));function _a(e){return function(e,t){return new e({type:"string",...oo(t)})}(Ia,e)}const Va=cr("ZodStringFormat",((e,t)=>{ei.init(e,t),$a.init(e,t)})),Da=cr("ZodEmail",((e,t)=>{ri.init(e,t),Va.init(e,t)}));const Na=cr("ZodGUID",((e,t)=>{ti.init(e,t),Va.init(e,t)}));const Pa=cr("ZodUUID",((e,t)=>{ni.init(e,t),Va.init(e,t)}));const Ca=cr("ZodURL",((e,t)=>{oi.init(e,t),Va.init(e,t)}));const Fa=cr("ZodEmoji",((e,t)=>{ii.init(e,t),Va.init(e,t)}));const Ga=cr("ZodNanoID",((e,t)=>{si.init(e,t),Va.init(e,t)}));const Ma=cr("ZodCUID",((e,t)=>{ai.init(e,t),Va.init(e,t)}));const Ua=cr("ZodCUID2",((e,t)=>{ci.init(e,t),Va.init(e,t)}));const La=cr("ZodULID",((e,t)=>{ui.init(e,t),Va.init(e,t)}));const ja=cr("ZodXID",((e,t)=>{li.init(e,t),Va.init(e,t)}));const Za=cr("ZodKSUID",((e,t)=>{fi.init(e,t),Va.init(e,t)}));const qa=cr("ZodIPv4",((e,t)=>{gi.init(e,t),Va.init(e,t)}));const Ha=cr("ZodIPv6",((e,t)=>{yi.init(e,t),Va.init(e,t)}));const Wa=cr("ZodCIDRv4",((e,t)=>{wi.init(e,t),Va.init(e,t)}));const Ja=cr("ZodCIDRv6",((e,t)=>{bi.init(e,t),Va.init(e,t)}));const Ka=cr("ZodBase64",((e,t)=>{Bi.init(e,t),Va.init(e,t)}));const Xa=cr("ZodBase64URL",((e,t)=>{Ei.init(e,t),Va.init(e,t)}));const Ya=cr("ZodE164",((e,t)=>{xi.init(e,t),Va.init(e,t)}));const Qa=cr("ZodJWT",((e,t)=>{Ti.init(e,t),Va.init(e,t)}));const ec=cr("ZodNumber",((e,t)=>{Ri.init(e,t),Oa.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ps(e,t,n),Sa(e,"ZodNumber",{gt(e,t){return this.check(Bs(e,t))},gte(e,t){return this.check(Es(e,t))},min(e,t){return this.check(Es(e,t))},lt(e,t){return this.check(bs(e,t))},lte(e,t){return this.check(vs(e,t))},max(e,t){return this.check(vs(e,t))},int(e){return this.check(rc(e))},safe(e){return this.check(rc(e))},positive(e){return this.check(Bs(0,e))},nonnegative(e){return this.check(Es(0,e))},negative(e){return this.check(bs(0,e))},nonpositive(e){return this.check(vs(0,e))},multipleOf(e,t){return this.check(xs(e,t))},step(e,t){return this.check(xs(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 tc(e){return function(e,t){return new e({type:"number",checks:[],...oo(t)})}(ec,e)}const nc=cr("ZodNumberFormat",((e,t)=>{zi.init(e,t),ec.init(e,t)}));function rc(e){return function(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...oo(t)})}(nc,e)}const oc=cr("ZodBoolean",((e,t)=>{Ai.init(e,t),Oa.init(e,t),e._zod.processJSONSchema=(e,t,n)=>Cs(0,0,t)}));function ic(e){return function(e,t){return new e({type:"boolean",...oo(t)})}(oc,e)}const sc=cr("ZodBigInt",((e,t)=>{ki.init(e,t),Oa.init(e,t),e._zod.processJSONSchema=(e,t,n)=>Fs(0,e),e.gte=(t,n)=>e.check(Es(t,n)),e.min=(t,n)=>e.check(Es(t,n)),e.gt=(t,n)=>e.check(Bs(t,n)),e.gte=(t,n)=>e.check(Es(t,n)),e.min=(t,n)=>e.check(Es(t,n)),e.lt=(t,n)=>e.check(bs(t,n)),e.lte=(t,n)=>e.check(vs(t,n)),e.max=(t,n)=>e.check(vs(t,n)),e.positive=t=>e.check(Bs(BigInt(0),t)),e.negative=t=>e.check(bs(BigInt(0),t)),e.nonpositive=t=>e.check(vs(BigInt(0),t)),e.nonnegative=t=>e.check(Es(BigInt(0),t)),e.multipleOf=(t,n)=>e.check(xs(t,n));const n=e._zod.bag;e.minValue=n.minimum??null,e.maxValue=n.maximum??null,e.format=n.format??null}));function ac(e){return function(e,t){return new e({type:"bigint",...oo(t)})}(sc,e)}const cc=cr("ZodAny",((e,t)=>{Si.init(e,t),Oa.init(e,t),e._zod.processJSONSchema=(e,t,n)=>{}}));function uc(){return function(e){return new e({type:"any"})}(cc)}const lc=cr("ZodUnknown",((e,t)=>{Oi.init(e,t),Oa.init(e,t),e._zod.processJSONSchema=(e,t,n)=>{}}));function fc(){return function(e){return new e({type:"unknown"})}(lc)}const hc=cr("ZodNever",((e,t)=>{$i.init(e,t),Oa.init(e,t),e._zod.processJSONSchema=(e,t,n)=>Gs(0,0,t)}));function dc(e){return function(e,t){return new e({type:"never",...oo(t)})}(hc,e)}const pc=cr("ZodArray",((e,t)=>{_i.init(e,t),Oa.init(e,t),e._zod.processJSONSchema=(t,n,r)=>qs(e,t,n,r),e.element=t.element,Sa(e,"ZodArray",{min(e,t){return this.check(Rs(e,t))},nonempty(e){return this.check(Rs(1,e))},max(e,t){return this.check(Ts(e,t))},length(e,t){return this.check(zs(e,t))},unwrap(){return this.element}})}));function mc(e,t){return function(e,t,n){return new e({type:"array",element:t,...oo(n)})}(pc,e,t)}const gc=cr("ZodObject",((e,t)=>{Ci.init(e,t),Oa.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Hs(e,t,n,r),qr(e,"shape",(()=>t.shape)),Sa(e,"ZodObject",{keyof(){return zc(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:fc()})},loose(){return this.clone({...this._zod.def,catchall:fc()})},strict(){return this.clone({...this._zod.def,catchall:dc()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return function(e,t){if(!Qr(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=Wr(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return Hr(this,"shape",n),n}});return ro(e,r)}(this,e)},safeExtend(e){return function(e,t){if(!Qr(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=Wr(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return Hr(this,"shape",n),n}});return ro(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=Wr(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t._zod.def.shape};return Hr(this,"shape",n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return ro(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 ro(e,Wr(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 Hr(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=Wr(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 Hr(this,"shape",r),r},checks:[]});return ro(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=Wr(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 Hr(this,"shape",o),o},checks:[]});return ro(t,o)}(Oc,this,e[0])},required(...e){return function(e,t,n){const r=Wr(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 Hr(this,"shape",o),o}});return ro(t,r)}(Pc,this,e[0])}})}));function yc(e,t){const n={type:"object",shape:e??{},...oo(t)};return new gc(n)}const wc=cr("ZodUnion",((e,t)=>{Gi.init(e,t),Oa.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ws(e,t,n,r),e.options=t.options}));function bc(e,t){return new wc({type:"union",options:e,...oo(t)})}const vc=cr("ZodIntersection",((e,t)=>{Mi.init(e,t),Oa.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Js(e,t,n,r)}));const Bc=cr("ZodTuple",((e,t)=>{ji.init(e,t),Oa.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ks(e,t,n,r),e.rest=t=>e.clone({...e._zod.def,rest:t})}));function Ec(e,t,n){const r=t instanceof Yo;return new Bc({type:"tuple",items:e,rest:r?t:null,...oo(r?n:t)})}const xc=cr("ZodRecord",((e,t)=>{Wi.init(e,t),Oa.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Xs(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType}));function Tc(e,t,n){return t&&t._zod?new xc({type:"record",keyType:e,valueType:t,...oo(n)}):new xc({type:"record",keyType:_a(),valueType:e,...oo(t)})}const Rc=cr("ZodEnum",((e,t)=>{Ji.init(e,t),Oa.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ms(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 Rc({...t,checks:[],...oo(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 Rc({...t,checks:[],...oo(r),entries:o})}}));function zc(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map((e=>[e,e]))):e;return new Rc({type:"enum",entries:n,...oo(t)})}const Ac=cr("ZodLiteral",((e,t)=>{Ki.init(e,t),Oa.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Us(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 kc=cr("ZodTransform",((e,t)=>{Xi.init(e,t),Oa.init(e,t),e._zod.processJSONSchema=(e,t,n)=>Zs(0,e),e._zod.parse=(n,r)=>{if("backward"===r.direction)throw new lr(e.constructor.name);n.addIssue=r=>{if("string"==typeof r)n.issues.push(ho(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(ho(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 Sc(e){return new kc({type:"transform",transform:e})}const Oc=cr("ZodOptional",((e,t)=>{Qi.init(e,t),Oa.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ia(e,t,0,r),e.unwrap=()=>e._zod.def.innerType}));function $c(e){return new Oc({type:"optional",innerType:e})}const Ic=cr("ZodExactOptional",((e,t)=>{es.init(e,t),Oa.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ia(e,t,0,r),e.unwrap=()=>e._zod.def.innerType}));const _c=cr("ZodNullable",((e,t)=>{ts.init(e,t),Oa.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ys(e,t,n,r),e.unwrap=()=>e._zod.def.innerType}));function Vc(e){return new _c({type:"nullable",innerType:e})}const Dc=cr("ZodDefault",((e,t)=>{ns.init(e,t),Oa.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ea(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap}));const Nc=cr("ZodPrefault",((e,t)=>{os.init(e,t),Oa.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ta(e,t,n,r),e.unwrap=()=>e._zod.def.innerType}));const Pc=cr("ZodNonOptional",((e,t)=>{is.init(e,t),Oa.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Qs(e,t,0,r),e.unwrap=()=>e._zod.def.innerType}));const Cc=cr("ZodCatch",((e,t)=>{as.init(e,t),Oa.init(e,t),e._zod.processJSONSchema=(t,n,r)=>na(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap}));const Fc=cr("ZodPipe",((e,t)=>{cs.init(e,t),Oa.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ra(e,t,0,r),e.in=t.in,e.out=t.out}));function Gc(e,t){return new Fc({type:"pipe",in:e,out:t})}const Mc=cr("ZodReadonly",((e,t)=>{ls.init(e,t),Oa.init(e,t),e._zod.processJSONSchema=(t,n,r)=>oa(e,t,n,r),e.unwrap=()=>e._zod.def.innerType}));const Uc=cr("ZodFunction",((e,t)=>{hs.init(e,t),Oa.init(e,t),e._zod.processJSONSchema=(e,t,n)=>js(0,e)}));const Lc=cr("ZodCustom",((e,t)=>{ds.init(e,t),Oa.init(e,t),e._zod.processJSONSchema=(e,t,n)=>Ls(0,e)}));const jc=yc({issuer:_a().transform((e=>wt(e))),index:_a().transform((e=>wt(e))),timestamp:_a().transform((e=>wt(e))),signature:_a().transform((e=>wt(e)))});var Zc=n(878);const qc=n.n(Zc)()("bee-js:http"),Hc={headers:{accept:"application/json, text/plain, */*"}};async function Wc(e,n){const r=t.Rb.deepMerge3(Hc,n,e);if(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 t of Object.keys(r.params))void 0===r.params[t]&&delete r.params[t];const o=function(e){let n=t.DH.joinUrl([e.baseURL??"",e.url??""]);if(e.params){const t=new URLSearchParams(Object.entries(e.params).filter((([,e])=>void 0!==e)).map((([e,t])=>[e,String(t)]))).toString();t&&(n+=`?${t}`)}return n}(r),i=(r.method||"GET").toUpperCase();r.method=i,e.onRequest?.({method:i,url:t.DH.joinUrl([r.baseURL??"",r.url??""]),headers:{...r.headers},params:r.params});let s=0;for(;s<1e5;)try{qc(`${i} ${o}`,{headers:r.headers,params:r.params});const e=await fetch(o,r);return e.ok||await Jc(i,o,e,r.responseType),Xc(e,r.responseType)}catch(a){if(a instanceof nu)throw a;const n=a;if("TimeoutError"!==n.name||!e.endlesslyRetry)throw Kc(n,i,o);s++,await t.iQ.sleepMillis(s<300?200:1e3)}throw Error("Max number of failed attempts reached")}async function Jc(e,t,n,r){const o=await Xc(n,r).catch((()=>({data:void 0}))),i="string"==typeof o.data?o.data:JSON.stringify(o.data),s=i&&"undefined"!==i?`${n.statusText}: ${i}`:n.statusText;throw new nu(e,t,s,o.data,n.status,n.statusText)}function Kc(e,t,n){if("AbortError"===e.name)return new nu(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 nu(t,n,o)}async function Xc(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 Yc=yc({durationSeconds:tc()});const Qc=yc({reference:_a().transform((e=>new rn(e)))});class eu extends Error{constructor(e){super(e)}}class tu extends eu{constructor(e,t){super(e),this.value=t}}class nu extends eu{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.response={status:o,data:r,statusText:i}}}class ru{static ZERO=new ru(0);constructor(e){this.seconds=Math.ceil(e),e<0&&(this.seconds=0)}static fromMilliseconds(e){return new ru(e/1e3)}static fromSeconds(e){return new ru(e)}static fromHours(e){return new ru(60*e*60)}static fromDays(e){return new ru(24*e*60*60)}static fromWeeks(e){return new ru(7*e*24*60*60)}static fromYears(e){return new ru(365*e*24*60*60)}static fromEndDate(e,t){return new ru((e.getTime()-(t??new Date).getTime())/1e3)}static parseFromString(e){return ru.fromSeconds(t.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 t.AO.secondsToHumanTime(this.seconds)}isZero(){return 0===this.seconds}}class ou{constructor(e){if(this.bytes=Math.ceil(e),e<0)throw Error("Size must be at least 0")}static fromBytes(e){return new ou(e)}static fromKilobytes(e){return new ou(1e3*e)}static fromMegabytes(e){return new ou(1e3*e*1e3)}static fromGigabytes(e){return new ou(1e3*e*1e3*1e3)}static parseFromString(e){return ou.fromBytes(t.FQ.makeStorage(e,1e3))}toBytes(){return this.bytes}toGigabytes(){return this.bytes/1e3/1e3/1e3}toFormattedString(){return t.FQ.convertBytes(this.bytes,1e3)}represent(){return this.toFormattedString()}}class iu{static DIGITS=16;constructor(e){this.state=e}static fromDecimalString(e){return new iu(t.ie.fromDecimalString(e,iu.DIGITS))}static fromPLUR(e){return new iu(new t.ie(e,iu.DIGITS))}static fromFloat(e){return new iu(t.ie.fromFloat(e,iu.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 iu(this.state.add(e instanceof iu?e.state:new t.ie(e,iu.DIGITS)))}minus(e){return new iu(this.state.subtract(e instanceof iu?e.state:new t.ie(e,iu.DIGITS)))}divide(e){return new iu(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 su.fromWei(this.state.exchange("*",new t.ie(e.toWeiBigInt(),su.DIGITS),su.DIGITS).value)}}class su{static DIGITS=18;constructor(e){this.state=e}static fromDecimalString(e){return new su(t.ie.fromDecimalString(e,su.DIGITS))}static fromWei(e){return new su(new t.ie(e,su.DIGITS))}static fromFloat(e){return new su(t.ie.fromFloat(e,su.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 su(this.state.add(e instanceof su?e.state:new t.ie(e,su.DIGITS)))}minus(e){return new su(this.state.subtract(e instanceof su?e.state:new t.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)}exchangeToBZZ(e){return iu.fromPLUR(this.state.exchange("/",new t.ie(e.toWeiBigInt(),su.DIGITS),iu.DIGITS).value)}}var au=n(320);function cu(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 uu(e){return function(e,t){return new e({type:"number",coerce:!0,checks:[],...oo(t)})}(ec,e)}let lu=function(e){return e.FULL="full",e.LIGHT="light",e.ULTRA_LIGHT="ultra-light",e.DEV="dev",e}({});function fu(e){switch(e){case"full":return lu.FULL;case"light":return lu.LIGHT;case"ultra-light":return lu.ULTRA_LIGHT;case"dev":return lu.DEV;default:throw new Error(`Unknown Bee mode: ${e}`)}}const hu=32,du=128,pu=hu*du,mu=4,gu=17,yu=255,wu=1,bu=1e3;let vu=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}({}),Bu=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 Eu={ENCRYPTION_OFF:{[vu.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%"}],[vu.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%"}],[vu.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%"}],[vu.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%"}],[vu.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:{[vu.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%"}],[vu.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%"}],[vu.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%"}],[vu.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%"}],[vu.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%"}]}},xu=(_a().regex(/^(?:0x)?[0-9a-fA-F]*$/i,"expected hex string").refine((e=>e.replace(/^0x/i,"").length%2==0),"expected even-length hex string"),uc().refine((e=>{return new Uc({type:"function",input:Array.isArray(t?.input)?Ec(t?.input):t?.input??mc(fc()),output:t?.output??fc()}).safeParse(e).success;var t}),"expected a function")),Tu=uc().transform((e=>(ac().safeParse(e).success&&(e=String(e)),_a().regex(/^-?\d+$/,"expected integer string").parse(e)))),Ru=uc().transform((e=>(ac().safeParse(e).success&&(e=String(e)),_a().regex(/^\d+$/,"expected non-negative integer string").parse(e)))),zu=yc({baseURL:_a().optional(),timeout:tc().int().min(0).optional(),headers:Tc(_a(),_a()).optional(),onRequest:xu.optional(),httpAgent:fc().optional(),httpsAgent:fc().optional(),endlesslyRetry:ic().optional(),signal:uc().optional()}),Au=yc({redundancyStrategy:tc().int().optional(),fallback:ic().optional(),timeoutMs:tc().int().min(0).optional(),actPublisher:$c(uc().transform((e=>new Kt(e)))),actHistoryAddress:$c(uc().transform((e=>new rn(e)))),actTimestamp:uu().optional()}),ku=yc({act:ic().optional(),actHistoryAddress:$c(uc().transform((e=>new rn(e)))),deferred:ic().optional(),encrypt:ic().optional(),pin:ic().optional(),tag:tc().int().min(0).optional()}),Su=ku.extend({redundancyLevel:tc().int().min(0).optional()}),Ou=ku.extend({size:tc().int().min(0).optional(),contentType:_a().optional(),redundancyLevel:tc().int().min(0).optional()}),$u=ku.extend({errorDocument:_a().optional(),indexDocument:_a().optional(),redundancyLevel:tc().int().min(0).optional()}),Iu=yc({uid:tc().int()}),_u=uu().min(0),Vu=yc({onMessage:xu,onError:xu,onClose:xu}),Du=yc({onMessage:xu,onError:xu,onClose:xu}),Nu=yc({gasPrice:Tu.optional(),immutableFlag:ic().optional(),label:_a().optional(),waitForUsable:ic().optional(),waitForUsableTimeout:tc().int().min(0).optional()}),Pu=yc({gasLimit:Ru.optional(),gasPrice:Ru.optional()}),Cu=yc({limit:tc().int().min(wu).max(bu).optional(),offset:tc().int().min(0).optional()});function Fu(e){return void 0!==au.Readable&&e instanceof au.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 Mu(e){if("string"!=typeof e&&!(e instanceof Uint8Array))throw new TypeError("Data must be either string or Uint8Array!")}function Uu(e){if(null==e)throw new TypeError(`Expected number | Tag | string from tagUid, got: ${e}`);if(t=e,Iu.safeParse(t).success)return e.uid;if("number"==typeof e||"string"==typeof e)return _u.parse(e);var t;throw new TypeError(`Expected number | Tag | string from tagUid, got: ${e}`)}function Lu(e,t){return iu.fromPLUR(2n**BigInt(e)*BigInt(t))}function ju(e,t,n){const r=BigInt(Gu(e));return ru.fromSeconds(Number(r*BigInt(n)/BigInt(t)))}function Zu(e,t,n){return BigInt(e.toSeconds())/BigInt(n)*BigInt(t)+1n}function qu(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 Hu(e){return ir(e)}function Wu(e,t,n){const r=function(e){return Number.isInteger(e)?e<1?1:e>3155695200?3155695200:e:1}(e.batchTTL),o=ru.fromSeconds(r),i=rr(e.depth,t,n),s=e.utilizationRatio??Kn(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:Gu(e.amount),bucketDepth:e.bucketDepth,blockNumber:e.blockNumber,immutableFlag:e.immutableFlag,usage:s,usageText:`${Math.round(100*s)}%`,size:ou.fromBytes(i),remainingSize:ou.fromBytes(Math.ceil(i*(1-s))),theoreticalSize:ou.fromBytes(Xn(e.depth)),duration:o,calculateSize(t,n){const r=rr(e.depth,t,n);return ou.fromBytes(r)},calculateRemainingSize(t,n){const r=rr(e.depth,t,n);return ou.fromBytes(Math.ceil(r*(1-this.usage)))}}}function Ju(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 Ku(e){return{name:function(e){if(!e)throw new eu("missing content-disposition header");const t=e.match(/filename\*?=['"]?(?:UTF-\d['"]*)?([^;\r\n"']*)['"]?;?/i);if(t&&t.length>0)return t[1];throw new eu("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 Xu(e,t){const n={};if(!function(e){if(!yc({}).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"]=Hu(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=ic().safeParse(r.act);o.success&&(n["swarm-act"]=String(o.data));const i=ic().safeParse(r.pin);i.success&&(n["swarm-pin"]=String(i.data));const s=ic().safeParse(r.encrypt);s.success&&(n["swarm-encrypt"]=String(s.data)),r.tag&&(n["swarm-tag"]=String(r.tag));const a=ic().safeParse(r.deferred);a.success&&(n["swarm-deferred-upload"]=String(a.data)),r.redundancyStrategy&&(n["swarm-redundancy-strategy"]=String(r.redundancyStrategy));const c=ic().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 rn(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 Yu="chunks";async function Qu(e,t,n){t=new rn(t);const r=await Wc(e,{responseType:"arraybuffer",url:`${Yu}/${t}`,headers:Xu(null,n)});return new Uint8Array(r.data)}function el(e,t){try{return Tn(e,t)}catch(n){throw new eu(n.message)}}async function tl(e,n,r,o){const i=Pt.concat(n.span.toUint8Array(),n.payload.toUint8Array());return async function(e,n,r,o,i,s,a){const c=await Wc(e,{method:"post",url:`soc/${n}/${r}`,data:i,headers:{"content-type":"application/octet-stream",...Xu(s,a)},responseType:"json",params:{sig:o.toHex()}});return{reference:Qc.parse(c.data).reference,tagUid:c.headers["swarm-tag"]?Uu(c.headers["swarm-tag"]):void 0,historyAddress:c.headers["swarm-act-history-address"]?t.Xx.of(new rn(c.headers["swarm-act-history-address"])):t.Xx.empty()}}(e,n.owner,n.identifier,n.signature,i,r,o)}async function nl(e,t,n,r,o,i){t=new tn(t),r=new qt(r);return tl(e,Rn(o).toSingleOwnerChunk(r,t),n,i)}async function rl(e,t,n){const r=En(n=new qt(n),t=new Ut(t));return el(await Qu(e,r.toHex()),r)}const ol=yc({peer:_a(),balance:_a().transform((e=>iu.fromPLUR(Gu(e,{name:"balance"}))))}),il=yc({balances:mc(ol)}),sl=ol,al="balances";const cl="consumed";class ul{constructor(e){this.context=e}async getAll(e){return async function(e){const t=await Wc(e,{url:al,responseType:"json"});return il.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async getPeer(e,t){const n=new Ht(e);return async function(e,t){const n=await Wc(e,{url:`${al}/${t}`,responseType:"json"});return sl.parse(n.data)}(this.context.getRequestOptionsForCall(t),n)}async getAllPastDueConsumption(e){return async function(e){const t=await Wc(e,{url:cl,responseType:"json"});return il.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async getAllPastDueConsumptionForPeer(e,t){const n=new Ht(e);return async function(e,t){const n=await Wc(e,{url:`${cl}/${t}`,responseType:"json"});return sl.parse(n.data)}(this.context.getRequestOptionsForCall(t),n)}}const ll=yc({beneficiary:_a().transform((e=>new Ut(e))),chequebook:_a().transform((e=>new Ut(e))),payout:_a().transform((e=>iu.fromPLUR(Gu(e,{name:"payout"}))))}),fl=yc({recipient:_a(),lastPayout:_a().transform((e=>iu.fromPLUR(Gu(e,{name:"lastPayout"})))),bounced:ic()}),hl=yc({chequebookAddress:_a().transform((e=>new Ut(e)))}),dl=yc({availableBalance:_a().transform((e=>iu.fromPLUR(Gu(e,{name:"availableBalance"})))),totalBalance:_a().transform((e=>iu.fromPLUR(Gu(e,{name:"totalBalance"}))))}),pl=yc({peer:_a(),uncashedAmount:_a().transform((e=>iu.fromPLUR(Gu(e,{name:"uncashedAmount"})))),transactionHash:_a().nullish().transform((e=>e??null)),lastCashedCheque:ll.nullish().transform((e=>e??null)),result:fl.nullish().transform((e=>e??null))}),ml=yc({peer:_a(),lastreceived:ll.nullish().transform((e=>e??null)),lastsent:ll.nullish().transform((e=>e??null))}),gl=yc({lastcheques:mc(yc({peer:_a(),lastreceived:ll.nullish().transform((e=>e??null)),lastsent:ll.nullish().transform((e=>e??null))}))}),yl=yc({transactionHash:_a().transform((e=>new cn(e)))}),wl="chequebook";class bl{constructor(e){this.context=e}async getAllLatest(e){return async function(e){const t=await Wc(e,{url:`${wl}/cheque`,responseType:"json"});return gl.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async getAllLatestForPeer(e,t){const n=new Ht(e);return async function(e,t){const n=await Wc(e,{url:`${wl}/cheque/${t}`,responseType:"json"});return ml.parse(n.data)}(this.context.getRequestOptionsForCall(t),n)}async getLastCashoutAction(e,t){const n=new Ht(e);return async function(e,t){const n=await Wc(e,{url:`${wl}/cashout/${t}`,responseType:"json"});return pl.parse(n.data)}(this.context.getRequestOptionsForCall(t),n)}async cashoutLast(e,t,n){const r=new Ht(e);return t&&(t=Pu.parse(t)),async function(e,t,n){const r=await Wc(e,{method:"post",url:`${wl}/cashout/${t}`,responseType:"json",headers:Xu(null,n)});return yl.parse(r.data).transactionHash}(this.context.getRequestOptionsForCall(n),r,t)}}class vl{constructor(e){this.context=e}async getAddress(e){return async function(e){const t=await Wc(e,{url:`${wl}/address`,responseType:"json"});return hl.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async getBalance(e){return async function(e){const t=await Wc(e,{url:`${wl}/balance`,responseType:"json"});return dl.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async deposit(e,t,n){const r=e instanceof iu?e.toPLURString():Gu(e,{min:1n,name:"amount"}),o=t?Gu(e,{min:0n,name:"gasPrice"}):void 0;return async function(e,t,n){const r={};n&&(r["gas-price"]=n);const o=await Wc(e,{method:"post",url:`${wl}/deposit`,responseType:"json",params:{amount:t},headers:r});return yl.parse(o.data).transactionHash}(this.context.getRequestOptionsForCall(n),r,o)}async withdraw(e,t,n){const r=e instanceof iu?e.toPLURString():Gu(e,{min:1n,name:"amount"}),o=t?Gu(e,{min:0n,name:"gasPrice"}):void 0;return async function(e,t,n){const r={};n&&(r["gas-price"]=n);const o=await Wc(e,{method:"post",url:`${wl}/withdraw`,responseType:"json",params:{amount:t},headers:r});return yl.parse(o.data).transactionHash}(this.context.getRequestOptionsForCall(n),r,o)}}class Bl{constructor(e){this.context=e}async upload(e,n,r,o){const i="identifier"in n&&"signature"in n&&"owner"in n;if(n=n instanceof Uint8Array?n:n.data,r&&(r=ku.parse(r)),n.length<on.LENGTH)throw new tu(`Chunk has to have size of at least ${on.LENGTH}.`,n);if(!i&&n.length>pu+on.LENGTH)throw new tu(`Content Addressed Chunk must not exceed ${pu+on.LENGTH} bytes.`,n);if(i&&n.length>pu+on.LENGTH+en.LENGTH+qt.LENGTH)throw new tu(`Single Owner Chunk must not exceed ${pu+on.LENGTH+en.LENGTH+qt.LENGTH} bytes.`,n);return async function(e,n,r,o){const i=await Wc(e,{method:"post",url:`${Yu}`,data:n,headers:{"content-type":"application/octet-stream",...Xu(r,o)},responseType:"json"});return{reference:Qc.parse(i.data).reference,tagUid:i.headers["swarm-tag"]?Uu(i.headers["swarm-tag"]):void 0,historyAddress:i.headers["swarm-act-history-address"]?t.Xx.of(new rn(i.headers["swarm-act-history-address"])):t.Xx.empty()}}(this.context.getRequestOptionsForCall(o),n,e,r)}async download(e,t,n){const r=new rn(e);return t&&(t=Au.parse(t)),Qu(this.context.getRequestOptionsForCall(n),r,t)}}var El=n(497),xl=n.n(El);async function Tl(e,t,n,r,o){for(const s of e.forks.values()){const e=await Tl(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 Rl(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(),a=qn.unmarshalFromData(s,o.node.selfAddress);o.node.targetAddress=a.targetAddress,o.node.forks=a.forks,o.node.path=o.prefix,o.node.parent=e,await Rl(o.node,t,n,r)}}class zl{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?t.Xx.of(e.metadata):t.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,n){const r=this.core.find("/");if(!r||!r.metadata)return t.Xx.empty();const o=r.metadata["swarm-feed-owner"],i=r.metadata["swarm-feed-topic"];return o&&i?t.Xx.of(await e.feed.fetchLatestUpdate(i,o,n)):t.Xx.empty()}async marshal(){return this.core.marshal()}static async unmarshal(e,t,n,r){t=new rn(t);const o=(await e.data.download(t,n,r)).toUint8Array();return this.unmarshalFromData(o,t.toUint8Array())}static unmarshalFromData(e,t){return new zl(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 Tl(this.core,e,t,n,r)}async loadRecursively(e,t,n){return Rl(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 Al=n(61),kl=n.n(Al);async function Sl(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 Ol(e,"")}async function Ol(e,t){const n=kl().join(e,t),r=await xl().promises.opendir(n);let o=[];for await(const i of r){const n=kl().join(e,t,i.name),r=kl().join(t,i.name);i.isFile()?o.push({path:r,size:(await xl().promises.stat(n)).size,fsPath:n}):i.isDirectory()&&(o=[...await Ol(e,r),...o])}return o}async function $l(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 xl().promises.opendir(e);let n=0;for await(const r of t)if(r.isFile()){n+=(await xl().promises.stat(kl().join(e,r.name))).size}else r.isDirectory()&&(n+=await $l(kl().join(e,r.name)));return n}const Il={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 _l(e){return["text/html","text/css"].includes(e)?`${e}; charset=utf-8`:e}function Vl(e){if(!function(e){return!!Array.isArray(e)&&e.every((e=>"object"==typeof e&&e.path&&void 0!==e.size))}(e))throw new tu("invalid collection",e)}function Dl(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 Nl(e){return Array.from(e).map((e=>({path:Dl(e),size:e.size,file:e})))}function Pl(e){return Array.from(e).reduce(((e,t)=>e+t.size),0)}class Cl{output=new au.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 Fl(e,t,n,r){const o=new Cl,i=Wc(e,{method:"post",url:"bzz",data:o.output,responseType:"json",headers:{"content-type":"application/x-tar","swarm-collection":"true",...Xu(n,r)}});await async function(e,t){for(const n of e)if(t.beginFile(n.path,n.size),n.fsPath){const e=(0,El.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 Gl="bzz";async function Ml(e,n,r,o,i){Fu(n)&&!i?.contentType&&(i||(i={}),i.contentType="application/octet-stream");const s=await Wc(e,{method:"post",url:Gl,data:n,headers:Xu(r,i),params:{name:o},responseType:"json"});return{reference:Qc.parse(s.data).reference,tagUid:s.headers["swarm-tag"]?Uu(s.headers["swarm-tag"]):void 0,historyAddress:s.headers["swarm-act-history-address"]?t.Xx.of(new rn(s.headers["swarm-act-history-address"])):t.Xx.empty()}}async function Ul(e,n,r,o){Vl(n);const i=await Fl(e,n,r,o);return{reference:Qc.parse(i.data).reference,tagUid:i.headers["swarm-tag"]?Uu(i.headers["swarm-tag"]):void 0,historyAddress:i.headers["swarm-act-history-address"]?t.Xx.of(new rn(i.headers["swarm-act-history-address"])):t.Xx.empty()}}class Ll{constructor(e){this.context=e}async upload(e,t,n,r){const o=new Ct(e);return Vl(t),n&&(n=$u.parse(n)),Ul(this.context.getRequestOptionsForCall(r),t,o,n)}async uploadFromFileList(e,t,n,r){const o=new Ct(e);n&&(n=$u.parse(n));const i=Nl(t);return Ul(this.context.getRequestOptionsForCall(r),i,o,n)}async uploadFromDirectory(e,t,n,r){const o=new Ct(e);n&&(n=$u.parse(n));const i=await Sl(t);return Ul(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,n,r,o,i){const s=new Ct(e);return async function(e,n,r,o,i,s){const a=new t.O3(64,64);let c=0,u=0;r=new Ct(r);const l=await Sl(n);for(const t of l)c+=(f=t.size,function e(t){return t<=1?t:t+e(Math.ceil(t/128))}(Math.ceil(f/4096)));var f;let h=!1;async function d(t){await e.chunk.upload(r,t.build(),i,s),o?.({total:c,processed:++u})}async function p(e){for(const{chunk:t}of e)await a.enqueue((async()=>d(t)));return[]}const m=new zl;for(const g of l){if(!g.fsPath)throw Error("File does not have fsPath, which should never happen in node. Please report this issue.");const e=(0,El.createReadStream)(g.fsPath),n=new kn(p);for await(const t of e)await n.append(t);const r=await n.finalize();await a.enqueue((async()=>d(r))),await a.drain();const{filename:o,extension:i}=t.DH.parseFilename(g.path);m.addFork(g.path,r.hash(),{"Content-Type":_l(Il[i.toLowerCase()]||"application/octet-stream"),Filename:o}),"index.html"===g.path&&(h=!0)}if(h||i?.indexDocument||i?.errorDocument){const e={};i?.indexDocument?e["website-index-document"]=i.indexDocument:h&&(e["website-index-document"]="index.html"),i?.errorDocument&&(e["website-error-document"]=i.errorDocument),m.addFork("/",Nh,e)}return m.saveRecursively(e,r,i,s)}(this.context.bee,n,s,r,o,this.context.getRequestOptionsForCall(i))}async hashDirectory(e){return async function(e){const n=await Sl(e),r=new zl;for(const o of n){const e=new kn(kn.NOOP);if(!o.fsPath)throw Error("File does not have fsPath, which should never happen in node. Please report this issue.");const n=(0,El.createReadStream)(o.fsPath);for await(const t of n)await e.append(t);const i=await e.finalize(),{filename:s,extension:a}=t.DH.parseFilename(o.path);r.addFork(o.path,i.hash(),{"Content-Type":_l(Il[a.toLowerCase()]||"application/octet-stream"),Filename:s})}return r.calculateSelfAddress()}(e)}}const jl=yc({address:_a(),fullNode:ic()}),Zl=yc({population:tc(),connected:tc(),connectedPeers:mc(yc({address:_a()})).nullish().transform((e=>e??[])),disconnectedPeers:mc(yc({address:_a()})).nullish().transform((e=>e??[]))}),ql=Tc(_a(),Zl),Hl=yc({overlay:_a().transform((e=>new Ht(e))),underlay:mc(_a()),ethereum:_a().transform((e=>new Ut(e))),publicKey:_a().transform((e=>new Kt(e))),pssPublicKey:_a().transform((e=>new Kt(e)))}),Wl=yc({peers:mc(jl)}),Jl=yc({peers:mc(jl)}),Kl=yc({baseAddr:_a(),population:tc(),connected:tc(),timestamp:_a(),nnLowWatermark:tc(),depth:tc(),reachability:_a(),networkAvailability:_a(),bins:ql}),Xl=yc({overlay:_a(),proximity:tc(),beeMode:_a().transform(fu),reserveSize:tc(),reserveSizeWithinRadius:tc(),pullsyncRate:tc(),storageRadius:tc(),connectedPeers:tc(),neighborhoodSize:tc(),batchCommitment:tc(),isReachable:ic(),lastSyncedBlock:tc(),committedDepth:tc(),isWarmingUp:ic()}),Yl=yc({apiVersion:_a(),version:_a(),status:(Ql="ok",new Ac({type:"literal",values:Array.isArray(Ql)?Ql:[Ql],...oo(ef)}))});var Ql,ef;const tf=yc({apiVersion:_a(),version:_a(),status:zc(["ready","notReady"])}),nf=yc({beeMode:_a().transform(fu),chequebookEnabled:ic(),swapEnabled:ic()}),rf=yc({gateway:ic()}),of="peers";class sf{constructor(e){this.context=e}async checkConnection(e){return async function(e){await Wc(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 Wc(e,{url:"/gateway"});return rf.parse(t.data).gateway}(this.context.getRequestOptionsForCall(e))}catch{return!1}}async getNodeAddresses(e){return async function(e){const t=await Wc(e,{url:"addresses",responseType:"json"});return Hl.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async getBlocklist(e){return async function(e){const t=await Wc(e,{url:"blocklist",responseType:"json"});return Jl.parse(t.data).peers}(this.context.getRequestOptionsForCall(e))}async getPeers(e){return async function(e){const t=await Wc(e,{url:of,responseType:"json"});return Wl.parse(t.data).peers}(this.context.getRequestOptionsForCall(e))}async removePeer(e,t){const n=new Ht(e);return async function(e,t){return(await Wc(e,{url:`${of}/${t}`,responseType:"json",method:"DELETE"})).data}(this.context.getRequestOptionsForCall(t),n)}async getTopology(e){return async function(e){const t=await Wc(e,{url:"topology",responseType:"json"});return Kl.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async ping(e,t){const n=new Ht(e);return async function(e,t){return(await Wc(e,{url:`pingpong/${t}`,responseType:"json",method:"POST"})).data}(this.context.getRequestOptionsForCall(t),n)}}class af{constructor(e){this.raw=e}toString(){const e=_a().safeParse(this.raw);return e.success&&e.data.includes(".eth")?e.data:new rn(this.raw).toHex()}}const cf="bytes";async function uf(e,n,r,o){const i=await Wc(e,{url:cf,method:"post",responseType:"json",data:n,headers:{"content-type":"application/octet-stream",...Xu(r,o)}});return{reference:Qc.parse(i.data).reference,tagUid:i.headers["swarm-tag"]?Uu(i.headers["swarm-tag"]):void 0,historyAddress:i.headers["swarm-act-history-address"]?t.Xx.of(new rn(i.headers["swarm-act-history-address"])):t.Xx.empty()}}async function lf(e,t,n){n&&(n=Au.parse(n));const r=await Wc(e,{responseType:"arraybuffer",url:`${cf}/${t}`,headers:Xu(null,n)});return new Pt(r.data)}const ff=yc({isRetrievable:ic()}),hf="stewardship";class df{constructor(e){this.context=e}async upload(e,t,n,r){const o=new Ct(e);return Mu(t),n&&(n=Su.parse(n)),uf(this.context.getRequestOptionsForCall(r),t,o,n)}async download(e,t,n){return t&&(t=Au.parse(t)),lf(this.context.getRequestOptionsForCall(n),new af(e),t)}async downloadReadable(e,t,n){return t&&(t=Au.parse(t)),async function(e,t,n){return n&&(n=Au.parse(n)),(await Wc(e,{responseType:"stream",url:`${cf}/${t}`,headers:Xu(null,n)})).data}(this.context.getRequestOptionsForCall(n),new af(e),t)}async probe(e,t){const n=new rn(e);return async function(e,t){const n=await Wc(e,{url:`${cf}/${t}`,method:"head",responseType:"json"});return{contentLength:parseInt(n.headers["content-length"])}}(this.context.getRequestOptionsForCall(t),n)}async isRetrievable(e,t){const n=new rn(e);return async function(e,t){const n=await Wc(e,{method:"get",responseType:"json",url:`${hf}/${t}`});return ff.parse(n.data).isRetrievable}(this.context.getRequestOptionsForCall(t),n)}}const pf="feeds";function mf(e){const t=e["swarm-feed-index"],n=e["swarm-feed-index-next"];if(!t)throw new eu("Response did not contain expected swarm-feed-index!");if(!n)throw new eu("Response did not contain expected swarm-feed-index-next!");return{feedIndex:new jt(t),feedIndexNext:new jt(n)}}async function gf(e,t,n,r){const o=await Wc(e,{responseType:"arraybuffer",url:`${pf}/${t}/${n}`,params:{...r}});return{payload:new Pt(o.data),...mf(o.headers)}}function yf(e,t){return t="number"==typeof t?jt.fromBigInt(BigInt(t)):t,new qt($t(Pt.concat(e.toUint8Array(),t.toUint8Array())))}async function wf(e,t,n){try{const r=await gf(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 nu)return jt.fromBigInt(0n);throw r}}async function bf(e,t,n,r,o,i){const s=yf(n,i?.index??await wf(e,t.publicKey().address(),n));if(r.length>4096){const n=await uf(e,r,o,i);return async function(e,t,n,r,o,i){return t=new tn(t),r=new qt(r),tl(e,o.toSingleOwnerChunk(r,t),n,i)}(e,t,o,s,zn(await Qu(e,n.reference)),i)}const a=_a().safeParse(r);return nl(e,t,o,s,a.success?Pt.fromUtf8(a.data).toUint8Array():r,i)}function vf(e,t,n){const r=yf(t,n);return new rn($t(Pt.concat(r.toUint8Array(),e.toUint8Array())))}async function Bf(e,n,r,o,i=!1){const s=vf(n,r,o="number"==typeof o?jt.fromBigInt(BigInt(o)):o),a=el(await Qu(e,s.toHex()),s);let c=t.Xx.empty();if(i){const e=Pt.fromSlice(a.payload.toUint8Array(),0,8);c=t.Xx.of(Number(St(e.toUint8Array(),"BE")))}return{timestamp:c,payload:new Pt(a.payload.offset(i?8:0))}}async function Ef(e,t,n,r){const o=vf(t,n,r="number"==typeof r?jt.fromBigInt(BigInt(r)):r),i=el(await Qu(e,o),o);return Rn(i.payload,i.span)}function xf(e,t,n){const r=async r=>{if(void 0===r?.index)return gf(e,n,t);const o=await Bf(e,n,t,r.index,r.hasTimestamp??!0),i="number"==typeof r.index?jt.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 gf(e,n,t);const o=await Ef(e,n,t,r.index),i=o.span.toBigInt()<=4096n?o.payload:await lf(e,new af(o.address)),s="number"==typeof r.index?jt.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 async function(e,t,n){return mf((await Wc(e,{responseType:"arraybuffer",url:`${pf}/${t}/${n}`,params:{"Swarm-Only-Root-Chunk":!0}})).headers)}(e,n,t)).feedIndex);const s=await r({...o,index:i});return{reference:new rn(s.payload.toUint8Array()),feedIndex:s.feedIndex,feedIndexNext:s.feedIndexNext??s.feedIndex.next()}},owner:n,topic:t}}function Tf(e,t,n){const r=async(r,o,i)=>async function(e,t,n,r,o,i){r=new rn(r);const s=yf(n,i?.index??await wf(e,t.publicKey().address(),n)),a=i?.at??Date.now()/1e3,c=kt(BigInt(Math.floor(a)),"BE");return nl(e,t,o,s,Pt.concat(c,r.toUint8Array()),i)}(e,n,t,o,r,i);return{...xf(e,t,n.publicKey().address()),upload:r,uploadReference:r,uploadPayload:async(r,o,i)=>bf(e,n,t,o,r,i)}}async function Rf(e,n,r,o,i,s){const a=function(e,t,n){const r=n.toBigInt(),o=[];for(let i=0n;i<=r;i++)o.push(vf(e,t,jt.fromBigInt(i)));return o}(n,r,o).map((async n=>async function(e,n,r,o){try{return await e.chunk.download(n,r,o),!0}catch(i){const e=t.Rb.getDeep(i,"status");if(404===e||500===e)return!1;throw i}}(e,n,i,s)));return(await Promise.all(a)).every((e=>e))}class zf{constructor(e){this.context=e}makeReader(e,t,n){return xf(this.context.getRequestOptionsForCall(n),new an(e),new Ut(t))}makeWriter(e,t,n){const r=t?new tn(t):this.context.signer;if(!r)throw Error("No signer provided");return Tf(this.context.getRequestOptionsForCall(n),new an(e),r)}async createManifest(e,t,n,r,o){const i=new Ct(e),s=new an(t),a=new Ut(n);return r&&(r=ku.parse(r)),async function(e,t,n,r,o){const i=await Wc(e,{method:"post",responseType:"json",url:`${pf}/${t}/${n}`,headers:Xu(r,o)});return Qc.parse(i.data).reference}(this.context.getRequestOptionsForCall(o),a,s,i,r)}async fetchLatestUpdate(e,t,n){return gf(this.context.getRequestOptionsForCall(n),new Ut(t),new an(e))}async isRetrievable(e,n,r,o,i){const s=new Ut(e),a=new an(n);if(o&&(o=Au.parse(o)),!r)try{return await this.makeReader(a,s,i).download(),!0}catch(c){const e=t.Rb.getDeep(c,"status");if(404===e||500===e)return!1;throw c}return Rf(this.context.bee,s,a,r,o,this.context.getRequestOptionsForCall(i))}}class Af{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||cu(e)||Fu(e)))throw new TypeError("Data must be either string, Readable, Uint8Array or File!")}(t),r&&(r=Ou.parse(r)),n&&"string"!=typeof n)throw new TypeError("name has to be string or undefined!");if(cu(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 Ml(this.context.getRequestOptionsForCall(o),e,i,s,c)}return Ml(this.context.getRequestOptionsForCall(o),t,i,n,r)}async download(e,t="",n,r){return n&&(n=Au.parse(n)),async function(e,t,n="",r){const o=await Wc(e,{method:"GET",responseType:"arraybuffer",url:`${Gl}/${t}/${n}`,headers:Xu(null,r)});return{...Ku(o.headers),data:new Pt(o.data)}}(this.context.getRequestOptionsForCall(r),new af(e),t,n)}async downloadReadable(e,t="",n,r){const o=new rn(e);return n&&(n=Au.parse(n)),async function(e,t,n="",r){t=new rn(t);const o=await Wc(e,{method:"GET",responseType:"stream",url:`${Gl}/${t}/${n}`,headers:Xu(null,r)});return{...Ku(o.headers),data:o.data}}(this.context.getRequestOptionsForCall(r),o,t,n)}}const kf=mc(_a().transform((e=>new Kt(e)))),Sf=yc({ref:_a().transform((e=>new rn(e))),historyref:_a().transform((e=>new rn(e)))}),Of="grantee";class $f{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 Wc(e,{method:"post",url:Of,data:{grantees:n.map((e=>e.toCompressedHex()))},headers:Xu(t),responseType:"json"}),o=Sf.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 rn(e);return async function(e,t){const n=await Wc(e,{method:"get",url:`${Of}/${t}`,responseType:"json"});return{status:n.status,statusText:n.statusText,grantees:kf.parse(n.data)}}(this.context.getRequestOptionsForCall(t),n)}async patch(e,t,n,r,o){const i=new Ct(e),s=new rn(t),a=new rn(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 Wc(e,{method:"patch",url:`${Of}/${n}`,data:{add:o.add.map((e=>e.toCompressedHex())),revoke:o.revoke.map((e=>e.toCompressedHex()))},headers:{...Xu(t),"swarm-act-history-address":r.toHex()},responseType:"json"}),s=Sf.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 If=null;"undefined"!=typeof WebSocket?If=WebSocket:"undefined"!=typeof MozWebSocket?If=MozWebSocket:void 0!==n.g?If=n.g.WebSocket||n.g.MozWebSocket:"undefined"!=typeof window?If=window.WebSocket||window.MozWebSocket:"undefined"!=typeof self&&(If=self.WebSocket||self.MozWebSocket);const _f=If;async function Vf(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 Df{constructor(e){this.context=e}async pssSend(e,t,n,r,o,i){const s=new Ct(e);Mu(r);const a=o?new Kt(o):void 0;await async function(e,t,n,r,o,i){await Wc(e,{method:"post",url:`pss/send/${n}/${r}`,data:o,responseType:"json",params:{recipient:i},headers:Xu(t)})}(this.context.getRequestOptionsForCall(i),s,t,n,r,a)}pssSubscribe(e,t){t=Vu.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 Vf(e.data);n.length&&t.onMessage(new Pt(n),r)},n.onerror=e=>{this.isCancelled(n)||t.onError(new eu(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 eu("pssReceive timeout"))}),t))}))}gsocMine(e,n,r=12){const o=new Ht(e),i=new qt(n);for(let s=0n;s<0xffffn;s++){const e=new tn(gt(2867n+s,"BE")),n=En(i,e.publicKey().address());if(256-t.yI.proximity(n.toUint8Array(),o.toUint8Array())<=256-r)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 tn(t),c=new qt(n),u=Rn(r).toSingleOwnerChunk(c,a);return tl(this.context.getRequestOptionsForCall(i),u,s,o)}gsocSubscribe(e,t,n){const r=new Ut(e),o=new qt(t);n=Du.parse(n);const i=En(o,r),s=this.openWebSocket(`gsoc/subscribe/${i.toHex()}`),a={address:r,cancel:this.makeCancel(s)};return s.onmessage=async e=>{const t=await Vf(e.data);t.length&&n.onMessage(new Pt(t),a)},s.onerror=e=>{this.isCancelled(s)||n.onError(new eu(e.message),a)},s.onclose=()=>{n.onClose(a)},a}openWebSocket(e){const n=this.context.url.replace(/^http/i,"ws");return"browser"===t.iQ.whereAmI()?new _f(`${n}/${e}`):new _f(`${n}/${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 Nf=yc({references:mc(_a()).nullable()}),Pf="pins";class Cf{constructor(e){this.context=e}async add(e,t){const n=new rn(e);await async function(e,t){await Wc(e,{method:"post",responseType:"json",url:`${Pf}/${t}`})}(this.context.getRequestOptionsForCall(t),n)}async remove(e,t){const n=new rn(e);await async function(e,t){await Wc(e,{method:"delete",responseType:"json",url:`${Pf}/${t}`})}(this.context.getRequestOptionsForCall(t),n)}async getAll(e){return async function(e){const t=await Wc(e,{method:"get",responseType:"json",url:Pf}),{references:n}=Nf.parse(t.data);return(n??[]).map((e=>new rn(e)))}(this.context.getRequestOptionsForCall(e))}async get(e,t){const n=new rn(e);return async function(e,t){const n=await Wc(e,{method:"get",responseType:"json",url:`${Pf}/${t}`});return Qc.parse(n.data)}(this.context.getRequestOptionsForCall(t),n)}async reuploadData(e,t,n){const r=new Ct(e),o=new rn(t);await async function(e,t,n){await Wc(e,{method:"put",url:`${hf}/${n}`,headers:{"swarm-postage-batch-id":t.toHex()}})}(this.context.getRequestOptionsForCall(n),r,o)}}const Ff=yc({peer:_a(),sent:_a().transform((e=>iu.fromPLUR(Gu(e,{name:"sent"})))),received:_a().transform((e=>iu.fromPLUR(Gu(e,{name:"received"}))))}),Gf=Ff,Mf=yc({totalSent:_a().transform((e=>iu.fromPLUR(Gu(e,{name:"totalSent"})))),totalReceived:_a().transform((e=>iu.fromPLUR(Gu(e,{name:"totalReceived"})))),settlements:mc(Ff)}),Uf="settlements";class Lf{constructor(e){this.context=e}async get(e,t){const n=new Ht(e);return async function(e,t){const n=await Wc(e,{url:`${Uf}/${t}`,responseType:"json"});return Gf.parse(n.data)}(this.context.getRequestOptionsForCall(t),n)}async getAll(e){return async function(e){const t=await Wc(e,{url:Uf,responseType:"json"});return Mf.parse(t.data)}(this.context.getRequestOptionsForCall(e))}}class jf{constructor(e){this.context=e}makeReader(e,t){const n=new Ut(e);return{owner:n,download:rl.bind(null,this.context.getRequestOptionsForCall(t),n)}}makeWriter(e,t){const n=e?new tn(e):this.context.signer;if(!n)throw Error("No signer provided");return{...this.makeReader(n.publicKey().address(),t),upload:nl.bind(null,this.context.getRequestOptionsForCall(t),n)}}}const Zf=yc({stakedAmount:_a().transform((e=>iu.fromPLUR(Gu(e,{name:"stakedAmount"}))))}),qf=yc({withdrawableAmount:_a().transform((e=>iu.fromPLUR(Gu(e,{name:"withdrawableAmount"}))))}),Hf=yc({txHash:_a().transform((e=>new cn(e)))}),Wf=yc({minimumGasFunds:_a().transform((e=>su.fromWei(Gu(e,{name:"minimumGasFunds"})))),hasSufficientFunds:ic(),isFrozen:ic(),isFullySynced:ic(),phase:_a(),round:tc(),lastWonRound:tc(),lastPlayedRound:tc(),lastFrozenRound:tc(),lastSelectedRound:tc(),lastSampleDurationSeconds:tc(),block:tc(),reward:_a().transform((e=>iu.fromPLUR(Gu(e,{name:"reward"})))),fees:_a().transform((e=>su.fromWei(Gu(e,{name:"fees"})))),isHealthy:ic()}),Jf="stake";class Kf{constructor(e){this.context=e}async get(e){return async function(e){const t=await Wc(e,{method:"get",responseType:"json",url:Jf});return Zf.parse(t.data).stakedAmount}(this.context.getRequestOptionsForCall(e))}async getWithdrawable(e){return async function(e){const t=await Wc(e,{method:"get",responseType:"json",url:`${Jf}/withdrawable`});return qf.parse(t.data).withdrawableAmount}(this.context.getRequestOptionsForCall(e))}async deposit(e,t,n){const r=e instanceof iu?e.toPLURString():Gu(e,{min:1n,name:"amount"});return t&&(t=Pu.parse(t)),async function(e,t,n){const r=await Wc(e,{method:"post",responseType:"json",url:`${Jf}/${t}`,headers:Xu(null,n)});return Hf.parse(r.data).txHash}(this.context.getRequestOptionsForCall(n),r,t)}async withdrawSurplus(e){return async function(e){const t=await Wc(e,{method:"delete",responseType:"json",url:`${Jf}/withdrawable`});return Hf.parse(t.data).txHash}(this.context.getRequestOptionsForCall(e))}async migrate(e){return async function(e){const t=await Wc(e,{method:"delete",responseType:"json",url:Jf});return Hf.parse(t.data).txHash}(this.context.getRequestOptionsForCall(e))}async getRedistributionState(e){return async function(e){const t=await Wc(e,{method:"get",responseType:"json",url:"redistributionstate"});return Wf.parse(t.data)}(this.context.getRequestOptionsForCall(e))}}const Xf=yc({batchID:_a(),utilization:tc(),utilizationRatio:tc().optional(),usable:ic(),label:_a(),depth:tc(),amount:_a(),bucketDepth:tc(),blockNumber:tc(),immutableFlag:ic(),batchTTL:tc()}),Yf=yc({batchID:_a().transform((e=>new Ct(e))),batchTTL:tc(),bucketDepth:tc(),depth:tc(),immutable:ic(),owner:_a().transform((e=>new Ut(e))),start:tc(),value:_a().transform((e=>Gu(e,{name:"value"})))}),Qf=yc({batches:mc(Yf)}),eh=yc({stamps:mc(Xf)}),th=Xf,nh=yc({depth:tc(),bucketDepth:tc(),bucketUpperBound:tc(),buckets:mc(yc({bucketID:tc(),collisions:tc()}))}),rh=yc({batchID:_a().transform((e=>new Ct(e)))}),oh="stamps";const ih="batches";class sh{constructor(e){this.context=e}async create(e,t,n,r){const o=Gu(e,{min:0n,name:"amount"});if(n&&(n=Nu.parse(n)),t<gu||t>yu)throw new tu(`Depth has to be between ${gu}..${yu}`,t);const i=await this.context.bee.status.getChainState(),s=17280n*BigInt(i.currentPrice)+1n;if(BigInt(o)<s)throw new tu(`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 Wc(e,{method:"post",url:`${oh}/${t}/${n}`,responseType:"json",params:{label:r},headers:s});return rh.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 Wc(e,{method:"patch",url:`${oh}/${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:ju(i,r.currentPrice,o)}}async topUp(e,t,n){const r=new Ct(e),o=Gu(t,{min:1n,name:"amount"});return async function(e,t,n){const r=await Wc(e,{method:"patch",url:`${oh}/topup/${t}/${n}`,responseType:"json"});return rh.parse(r.data).batchID}(this.context.getRequestOptionsForCall(n),r,o)}async dilute(e,t,n){const r=new Ct(e),o=tc().int().min(18).max(255).parse(t);return async function(e,t,n){const r=await Wc(e,{method:"patch",url:`${oh}/dilute/${t}/${n}`,responseType:"json"});return rh.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 Wc(e,{method:"get",url:`${oh}/${t}`,responseType:"json"});return Wu(th.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 Wc(e,{method:"get",url:`${ih}/${t}`,responseType:"json"});return Yf.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 Wc(e,{method:"get",url:`${oh}/${t}/buckets`,responseType:"json"});return nh.parse(n.data)}(this.context.getRequestOptionsForCall(t),n)}async getAll(e){return async function(e){const t=await Wc(e,{method:"get",url:oh,responseType:"json"});return eh.parse(t.data).stamps.map((e=>Wu(e)))}(this.context.getRequestOptionsForCall(e))}async getAllGlobal(e){return async function(e){const t=await Wc(e,{method:"get",url:ih,responseType:"json"});return Qf.parse(t.data).batches}(this.context.getRequestOptionsForCall(e))}async waitForUsable(e,n=24e4){for(let r=0;r<n;r+=3e3){try{if((await this.get(e)).usable)return}catch{}await t.iQ.sleepMillis(3e3)}throw new eu("Timeout on waiting for postage stamp to become usable")}}var ah=n(359),ch=n.n(ah);const uh="2.8.1-7cf53193",lh=uh.split("-")[0],fh="8.1.0",hh=yc({commitment:tc(),radius:tc(),storageRadius:tc(),reserveCapacityDoubling:tc()}),dh=yc({block:tc(),chainTip:tc(),totalAmount:_a().transform((e=>Gu(e,{name:"totalAmount"}))),currentPrice:_a().transform(Number).transform((e=>{return t=e,Number.isInteger(t)?t<24e3?24e3:t:24e3;var t})),minimumValidityBlocks:tc().optional()}),ph=yc({bzzBalance:_a().transform((e=>iu.fromPLUR(Gu(e,{name:"bzzBalance"})))),nativeTokenBalance:_a().transform((e=>su.fromWei(Gu(e,{name:"nativeTokenBalance"})))),chainID:tc(),chequebookContractAddress:_a(),walletAddress:_a()}),mh=yc({transactionHash:_a().transform((e=>new cn(e)))});class gh{constructor(e){this.context=e}async get(e){return async function(e){const t=await Wc(e,{method:"get",url:"status",responseType:"json"});return Xl.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async getHealth(e){return async function(e){const t=await Wc(e,{method:"get",url:"health",responseType:"json"});return Yl.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async getReadiness(e){return async function(e){const t=await Wc(e,{method:"get",url:"readiness"});return tf.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async getNodeInfo(e){return async function(e){const t=await Wc(e,{method:"get",url:"node",responseType:"json"});return nf.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async isSupportedExactVersion(e){const{version:t}=await this.getHealth(e);return t===uh}async isSupportedApiVersion(e){const{apiVersion:t}=await this.getHealth(e);return ch()(t)===ch()(fh)}async getVersions(e){const{version:t,apiVersion:n}=await this.getHealth(e);return{supportedBeeVersion:uh,supportedBeeApiVersion:fh,beeVersion:t,beeApiVersion:n}}async getReserveState(e){return async function(e){const t=await Wc(e,{method:"get",url:"reservestate",responseType:"json"});return hh.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async getChainState(e){return async function(e){const t=await Wc(e,{method:"get",url:"chainstate",responseType:"json"});return dh.parse(t.data)}(this.context.getRequestOptionsForCall(e))}}class yh{constructor(e){this.context=e}get blockTime(){return"gnosis"===this.context.network?5:15}async buy(e,t,n,r,o,i){const s=Zu(t,(await this.context.bee.status.getChainState(r)).currentPrice,this.blockTime),a=qu(e,o,i);return n&&(n=Nu.parse(n)),this.context.bee.stamp.create(s,a,n,r)}async getCost(e,t,n,r,o){const i=Zu(t,(await this.context.bee.status.getChainState(n)).currentPrice,this.blockTime);return Lu(qu(e,r,o),i)}async extend(e,t,n,r,o,i){const s=await this.context.bee.stamp.get(e,r),a=qu(t,o,i),c=await this.context.bee.status.getChainState(r),u=a-s.depth,l=u<=0?1n:2n**BigInt(u),f=Zu(n,c.currentPrice,this.blockTime),h=Zu(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=qu(t,r,o),c=a-s.depth;if(c<=0)throw new tu("New depth has to be greater than the original depth",a);const u=Zu(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=Zu(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:Zu(n,a.currentPrice,this.blockTime),u=qu(t,o,i),l=Zu(s.duration,a.currentPrice,this.blockTime),f=Lu(s.depth,l);return Lu(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=qu(t,r,o);if(a-i.depth<=0)throw new tu("New depth has to be greater than the original depth",a);const c=Zu(i.duration,s.currentPrice,this.blockTime),u=Lu(i.depth,c);return Lu(a,c).minus(u)}async getDurationExtensionCost(e,t,n){const r=await this.context.bee.stamp.get(e,n),o=Zu(t,(await this.context.bee.status.getChainState(n)).currentPrice,this.blockTime);return Lu(r.depth,o)}async rename(e,t,n){return this.context.bee.stamp.updateLabel(e,t,n)}}const wh=yc({address:_a().nullish().transform((e=>e??"")),seen:tc(),sent:tc(),split:tc(),startedAt:_a(),stored:tc(),synced:tc(),uid:tc()}),bh=yc({tags:mc(wh)}),vh="tags";class Bh{constructor(e){this.context=e}async create(e){return async function(e){const t=await Wc(e,{method:"post",url:vh,responseType:"json"});return wh.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async getAll(e,t){return e&&(e=Cu.parse(e)),async function(e,t){const n=await Wc(e,{url:vh,params:{offset:t?.offset,limit:t?.limit},responseType:"json"});return bh.parse(n.data).tags}(this.context.getRequestOptionsForCall(t),e)}async get(e,t){const n=Uu(e);return async function(e,t){const n=await Wc(e,{url:`${vh}/${t}`,responseType:"json"});return wh.parse(n.data)}(this.context.getRequestOptionsForCall(t),n)}async delete(e,t){const n=Uu(e);await async function(e,t){await Wc(e,{method:"delete",url:`${vh}/${t}`})}(this.context.getRequestOptionsForCall(t),n)}async update(e,t,n){const r=new rn(t),o=Uu(e);await async function(e,t,n){await Wc(e,{method:"patch",url:`${vh}/${t}`,data:{reference:n}})}(this.context.getRequestOptionsForCall(n),o,r)}}const Eh=yc({transactionHash:_a().transform((e=>new cn(e))),to:_a(),nonce:tc(),gasPrice:_a().transform((e=>Gu(e,{name:"gasPrice"}))),gasLimit:tc(),data:_a(),created:_a(),description:_a(),value:_a().transform((e=>Gu(e,{name:"value"})))}),xh=yc({pendingTransactions:mc(Eh)}),Th=Eh,Rh=yc({transactionHash:_a().transform((e=>new cn(e)))}),zh="transactions";class Ah{constructor(e){this.context=e}async getAll(e){return async function(e){const t=await Wc(e,{url:zh,responseType:"json"});return xh.parse(t.data).pendingTransactions}(this.context.getRequestOptionsForCall(e))}async get(e,t){const n=new cn(e);return async function(e,t){const n=await Wc(e,{url:`${zh}/${t}`,responseType:"json"});return Th.parse(n.data)}(this.context.getRequestOptionsForCall(t),n)}async rebroadcast(e,t){const n=new cn(e);return async function(e,t){const n=await Wc(e,{method:"post",url:`${zh}/${t}`,responseType:"json"});return Rh.parse(n.data).transactionHash}(this.context.getRequestOptionsForCall(t),n)}async cancel(e,t,n){const r=new cn(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 Wc(e,{method:"delete",headers:r,url:`${zh}/${t}`,responseType:"json"});return Rh.parse(o.data).transactionHash}(this.context.getRequestOptionsForCall(n),r,o)}}const kh="wallet";class Sh{constructor(e){this.context=e}async getBalance(e){return async function(e){const t=await Wc(e,{method:"get",url:kh,responseType:"json"});return ph.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async withdrawBZZ(e,t,n){const r=e instanceof iu?e:iu.fromPLUR(e),o=new Ut(t);return async function(e,t,n){const r=await Wc(e,{method:"post",url:`${kh}/withdraw/bzz`,responseType:"json",params:{amount:t.toPLURString(),address:n.toHex()}});return mh.parse(r.data).transactionHash}(this.context.getRequestOptionsForCall(n),r,o)}async withdrawDAI(e,t,n){const r=e instanceof su?e:su.fromWei(e),o=new Ut(t);return async function(e,t,n){const r=await Wc(e,{method:"post",url:`${kh}/withdraw/nativetoken`,responseType:"json",params:{amount:t.toWeiString(),address:n.toHex()}});return mh.parse(r.data).transactionHash}(this.context.getRequestOptionsForCall(n),r,o)}}const Oh=["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 $h(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 tu("URL is not valid!",e);const t=new URL(e).port;if(t&&!function(e){if("string"!=typeof e)return!1;if(Oh.includes(e))return!1;const t=parseInt(e,10);return t>0&&t<65536&&!isNaN(t)}(t))throw new tu("Port in URL is considered bad port and cannot be used!",t)}class Ih{constructor(e,t){$h(e),this.url=function(e){return e.endsWith("/")?e.slice(0,-1):e}(e),t?.signer&&(this.signer=new tn(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 ul(n),this.settlement=new Lf(n),this.transaction=new Ah(n),this.stake=new Kf(n),this.connectivity=new sf(n),this.status=new gh(n),this.wallet=new Sh(n),this.stamp=new sh(n),this.storage=new yh(n),this.chequebook=new vl(n),this.cheque=new bl(n),this.tag=new Bh(n),this.pin=new Cf(n),this.grantee=new $f(n),this.messaging=new Df(n),this.feed=new zf(n),this.soc=new jf(n),this.data=new df(n),this.chunk=new Bl(n),this.file=new Af(n),this.collection=new Ll(n)}makeContentAddressedChunk(e,t){return Rn(e,t)}unmarshalContentAddressedChunk(e){return zn(e)}makeSingleOwnerChunk(e,t,n,r,o){return function(e,t,n,r,o){return r=new qt(r),o=new tn(o),xn({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 En(e,t)}unmarshalSingleOwnerChunk(e,t){return el(e,t)}async createEnvelope(e,t,n){return e=new Ct(e),t=new rn(t),async function(e,t,n){const r=await Wc(e,{method:"post",responseType:"json",url:`envelope/${n}`,headers:{"swarm-postage-batch-id":t.toHex()}}),o=jc.parse(r.data);return{issuer:new Ut(o.issuer),index:o.index,timestamp:o.timestamp,signature:new en(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 Wc(e,{responseType:"json",url:`rchash/${t}/${n}/${r}`});return Yc.parse(o.data).durationSeconds}(this.getRequestOptionsForCall(r),e,t,n)}getRequestOptionsForCall(e){return e&&(e=zu.parse(e)),e?t.Rb.deepMerge2(this.requestOptions,e):this.requestOptions}}const _h="https://api.gateway.ethswarm.org",Vh=new Ct("0000000000000000000000000000000000000000000000000000000000000000"),Dh=new an("0000000000000000000000000000000000000000000000000000000000000000"),Nh=new Uint8Array(32),Ph=new Uint8Array(32),Ch=new Uint8Array(20);function Fh(e){return(e=new Ht(e)).toHex().slice(0,mu)}})(),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 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 N(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 P(e,t){if(E(e))return t&&N(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&&N(n,t),n}function C(e,t){return Math.trunc(P(e,t))}function F(e,t){if(!y(e))throw new TypeError(`Expected object${t?.name?` for ${t.name}`:""}, got: `+e);return e}function G(e){return B(e)&&null!==e.match(/^https?:\/\/.+/)}function M(e){return"bigint"==typeof e}function U(e,t){if(!M(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={"&amp;":"&","&quot;":'"',"&apos;":"'","&gt;":">","&lt;":"<"};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 Ne(e){return Math.floor((T(e)?e.getTime():e)/864e5)}const Pe={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 Ge={};const Me={s:1e3,m:6e4,h:36e5,d:864e5};const Ue={0:"sunday",1:"monday",2:"tuesday",3:"wednesday",4:"thursday",5:"friday",6:"saturday"};function Le(e){return{zeroBasedIndex:e,day:Ue[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,N=e[14]<<6|e[15]>>>26,P=e[15]<<6|e[14]>>>26,C=e[17]<<23|e[16]>>>9,F=e[16]<<23|e[17]>>>9,G=e[18]<<20|e[19]>>>12,M=e[19]<<20|e[18]>>>12,U=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^~G&U,e[11]=S^~M&L,e[12]=G^~U&ee,e[13]=M^~L&te,e[14]=U^~ee&he,e[15]=L^~te&de,e[16]=ee^~he&k,e[17]=te^~de&S,e[18]=he^~k&G,e[19]=de^~S&M,e[20]=T^~N&W,e[21]=R^~P&J,e[22]=N^~W&se,e[23]=P^~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&N,e[29]=ue^~R&P,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 Nt=0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2fn,Pt=0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n,Ct=0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798n,Ft=0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8n;function Gt(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 Mt(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 Gt(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 Ut(e,t,n,r){let o=[0n,0n],i=[e,t];const s=n.toString(2);for(const a of s)"0"===a?(Mt(o[0],o[1],i[0],i[1],r),Gt(o[0],o[1],r)):(Mt(o[0],o[1],i[0],i[1],r),Gt(i[0],i[1],r));return o}function Lt(e,t,n){if(t<=0n||t>=Pt)throw new Error("Invalid private key");if(n||_t(Et(Ot(gt(Ot(Bt(t,"BE")),Bt(e,"BE"))),"BE"),Pt),n<=0n||n>=Pt)throw new Error("Invalid nonce");const r=_t(e,Pt),o=Ut(Ct,Ft,n,Nt),i=_t(o[0],Pt);let s=_t((r+_t(i,Pt)*t)*Vt(n,Pt),Pt);if(0n===i||0n===s)throw new Error("Invalid r or s value");let a=o[1]%2n===0n?27n:28n;return s>Pt/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=U(e.value),n=P(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||Pe,o=T(e)?e:new Date(e);if(Ne(n)===Ne(o))return r.today(o.getUTCHours(),o.getUTCMinutes(),o.getUTCHours()>12);if(Ne(n)-Ne(o)==1)return r.yesterday();const i=je(o);return Ne(n)-Ne(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(!Ge[e]||Date.now()>Ge[e])&&(Ge[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)/Me[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:Ne},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(",","&comma;")})`))).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("&comma;",","),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)=>P(e[t])-P(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:G,isBigint:M,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:P,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(!G(e))throw new TypeError(`Expected url${t?.name?` for ${t.name}`:""}, got: `+e);return e},asBigint:U,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,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")},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:()=>du,BZZ:()=>iu,BatchId:()=>Ct,Bee:()=>Ih,BeeArgumentError:()=>tu,BeeError:()=>eu,BeeModes:()=>lu,BeeResponseError:()=>nu,Bytes:()=>Pt,CHUNK_SIZE:()=>pu,ChunkBuilder:()=>An,ChunkSplitter:()=>kn,DAI:()=>su,Duration:()=>ru,EthAddress:()=>Ut,FeedIndex:()=>jt,Identifier:()=>qt,MantarayNode:()=>zl,NULL_ADDRESS:()=>Nh,NULL_IDENTIFIER:()=>Ph,NULL_OWNER:()=>Ch,NULL_STAMP:()=>Vh,NULL_TOPIC:()=>Dh,PSS_TARGET_HEX_LENGTH_MAX:()=>mu,PeerAddress:()=>Ht,PrivateKey:()=>tn,PublicKey:()=>Kt,RedundancyLevel:()=>vu,RedundancyStrategy:()=>Bu,Reference:()=>rn,SECTION_SIZE:()=>hu,STAMPS_DEPTH_MAX:()=>yu,STAMPS_DEPTH_MIN:()=>gu,SUPPORTED_BEE_VERSION:()=>lh,SUPPORTED_BEE_VERSION_EXACT:()=>uh,SWARM_GATEWAY_URL:()=>_h,Signature:()=>en,Size:()=>ou,Span:()=>on,Stamper:()=>ar,TAGS_LIMIT_MAX:()=>bu,TAGS_LIMIT_MIN:()=>wu,Topic:()=>an,TransactionId:()=>cn,Utils:()=>e,capacityBreakpoints:()=>Eu,toBeeMode:()=>fu});var e={};n.r(e),n.d(e,{approximateOverheadForRedundancyLevel:()=>In,convertEnvelopeToMarshaledStamp:()=>Hu,getAmountForDuration:()=>Zu,getCollectionSize:()=>Pl,getDepthForSize:()=>qu,getFolderSize:()=>$l,getRedundancyStat:()=>Cn,getRedundancyStats:()=>Pn,getStampCost:()=>Lu,getStampDuration:()=>ju,getStampEffectiveBytes:()=>rr,getStampEffectiveBytesBreakpoints:()=>or,getStampTheoreticalBytes:()=>Xn,getStampUsage:()=>Kn,makeCollectionFromFileList:()=>Nl,makeMaxTarget:()=>Fh,mapPostageBatch:()=>Wu,unmapPostageBatch:()=>Ju});var t=n(20);const o="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0;function i(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function s(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function a(e,...t){if(!i(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 c(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.createHasher");s(e.outputLen),s(e.blockLen)}function u(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 l(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function f(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function h(e,t){return e<<32-t|e>>>t}const d=(()=>"function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex)(),p=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function m(e){if(a(e),d)return e.toHex();let t="";for(let n=0;n<e.length;n++)t+=p[e[n]];return t}const g=48,y=57,w=65,b=70,v=97,B=102;function E(e){return e>=g&&e<=y?e-g:e>=w&&e<=b?e-(w-10):e>=v&&e<=B?e-(v-10):void 0}function x(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);if(d)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=E(e.charCodeAt(i)),n=E(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 T(e){if("string"!=typeof e)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(e))}function R(e){return"string"==typeof e&&(e=T(e)),a(e),e}function z(...e){let t=0;for(let r=0;r<e.length;r++){const n=e[r];a(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 A{}function k(e){const t=t=>e().update(R(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function S(e=32){if(o&&"function"==typeof o.getRandomValues)return o.getRandomValues(new Uint8Array(e));if(o&&"function"==typeof o.randomBytes)return Uint8Array.from(o.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}function O(e,t,n){return e&t^e&n^t&n}class $ extends A{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=f(this.buffer)}update(e){u(this),a(e=R(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=f(e);for(;r<=o-i;i+=r)this.process(t,i)}}return this.length+=e.length,this.roundClean(),this}digestInto(e){u(this),function(e,t){a(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,l(this.buffer.subarray(i)),this.padOffset>r-i&&(this.process(n,0),i=0);for(let a=i;a<r;a++)t[a]=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 s=f(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const h=c/4,d=this.get();if(h>d.length)throw new Error("_sha2: outputLen bigger than state");for(let a=0;a<h;a++)s.setUint32(4*a,d[a],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 I=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]),V=new Uint32Array(64);class D extends ${constructor(e=32){super(64,e,8,!1),this.A=0|I[0],this.B=0|I[1],this.C=0|I[2],this.D=0|I[3],this.E=0|I[4],this.F=0|I[5],this.G=0|I[6],this.H=0|I[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)V[f]=e.getUint32(t,!1);for(let f=16;f<64;f++){const e=V[f-15],t=V[f-2],n=h(e,7)^h(e,18)^e>>>3,r=h(t,17)^h(t,19)^t>>>10;V[f]=r+V[f-7]+n+V[f-16]|0}let{A:n,B:r,C:o,D:i,E:s,F:a,G:c,H:u}=this;for(let f=0;f<64;f++){const e=u+(h(s,6)^h(s,11)^h(s,25))+((l=s)&a^~l&c)+_[f]+V[f]|0,t=(h(n,2)^h(n,13)^h(n,22))+O(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(){l(V)}destroy(){this.set(0,0,0,0,0,0,0,0),l(this.buffer)}}const N=k((()=>new D));class P extends A{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,c(e);const n=R(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),l(o)}update(e){return u(this),this.iHash.update(e),this}digestInto(e){u(this),a(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),G=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=i(e),o=e?.length,s=void 0!==t;if(!r||s&&o!==t){throw new Error((n&&`"${n}" `)+"expected Uint8Array"+(s?` of length ${t}`:"")+", got "+(r?`length=${o}`:"type="+typeof e))}return e}function L(e){const t=e.toString(16);return 1&t.length?"0"+t:t}function j(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);return""===e?F:BigInt("0x"+e)}function Z(e){return j(m(e))}function q(e){return a(e),j(m(Uint8Array.from(e).reverse()))}function H(e,t){return x(e.toString(16).padStart(2*t,"0"))}function W(e,t){return H(e,t).reverse()}function J(e,t,n){let r;if("string"==typeof t)try{r=x(t)}catch(s){throw new Error(e+" must be hex string or Uint8Array, cause: "+s)}else{if(!i(t))throw new Error(e+" must be hex string or Uint8Array");r=Uint8Array.from(t)}const o=r.length;if("number"==typeof n&&o!==n)throw new Error(e+" of length "+n+" expected, got "+o);return r}const K=e=>"bigint"==typeof e&&F<=e;function X(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 Y(e){let t;for(t=0;e>F;e>>=G,t+=1);return t}const Q=e=>(G<<BigInt(e))-G;function ee(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 te(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 ne=BigInt(0),re=BigInt(1),oe=BigInt(2),ie=BigInt(3),se=BigInt(4),ae=BigInt(5),ce=BigInt(7),ue=BigInt(8),le=BigInt(9),fe=BigInt(16);function he(e,t){const n=e%t;return n>=ne?n:t+n}function de(e,t,n){let r=e;for(;t-- >ne;)r*=r,r%=n;return r}function pe(e,t){if(e===ne)throw new Error("invert: expected non-zero number");if(t<=ne)throw new Error("invert: expected positive modulus, got "+t);let n=he(e,t),r=t,o=ne,i=re,s=re,a=ne;for(;n!==ne;){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!==re)throw new Error("invert: does not exist");return he(o,t)}function me(e,t,n){if(!e.eql(e.sqr(t),n))throw new Error("Cannot find square root")}function ge(e,t){const n=(e.ORDER+re)/se,r=e.pow(t,n);return me(e,r,t),r}function ye(e,t){const n=(e.ORDER-ae)/ue,r=e.mul(t,oe),o=e.pow(r,n),i=e.mul(t,o),s=e.mul(e.mul(i,oe),o),a=e.mul(i,e.sub(s,e.ONE));return me(e,a,t),a}function we(e){if(e<ie)throw new Error("sqrt is not defined for small field");let t=e-re,n=0;for(;t%oe===ne;)t/=oe,n++;let r=oe;const o=Re(e);for(;1===xe(o,r);)if(r++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(1===n)return ge;let i=o.pow(r,t);const s=(t+re)/oe;return function(e,r){if(e.is0(r))return r;if(1!==xe(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=re<<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 be(e){return e%se===ie?ge:e%ue===ae?ye:e%fe===le?function(e){const t=Re(e),n=we(e),r=n(t,t.neg(t.ONE)),o=n(t,r),i=n(t,t.neg(r)),s=(e+ce)/fe;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 me(e,d,t),d}}(e):we(e)}const ve=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Be(e,t,n){if(n<ne)throw new Error("invalid exponent, negatives unsupported");if(n===ne)return e.ONE;if(n===re)return t;let r=e.ONE,o=t;for(;n>ne;)n&re&&(r=e.mul(r,o)),o=e.sqr(o),n>>=re;return r}function Ee(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 xe(e,t){const n=(e.ORDER-re)/oe,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 Te(e,t){void 0!==t&&s(t);const n=void 0!==t?t:e.toString(2).length;return{nBitLength:n,nByteLength:Math.ceil(n/8)}}function Re(e,t,n=!1,r={}){if(e<=ne)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}=Te(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:Q(c),ZERO:ne,ONE:re,allowedLengths:s,create:t=>he(t,e),isValid:t=>{if("bigint"!=typeof t)throw new Error("invalid field element: expected bigint, got "+typeof t);return ne<=t&&t<e},is0:e=>e===ne,isValidNot0:e=>!f.is0(e)&&f.isValid(e),isOdd:e=>(e&re)===re,neg:t=>he(-t,e),eql:(e,t)=>e===t,sqr:t=>he(t*t,e),add:(t,n)=>he(t+n,e),sub:(t,n)=>he(t-n,e),mul:(t,n)=>he(t*n,e),pow:(e,t)=>Be(f,e,t),div:(t,n)=>he(t*pe(n,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>pe(t,e),sqrt:i||(t=>(l||(l=be(e)),l(f,t))),toBytes:e=>n?W(e,u):H(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?q(t):Z(t);if(a&&(o=he(o,e)),!r&&!f.isValid(o))throw new Error("invalid field element: outside of range 0..ORDER");return o},invertBatch:e=>Ee(f,e),cmov:(e,t,n)=>n?t:e});return Object.freeze(f)}function ze(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 Ae(e){const t=ze(e);return t+Math.ceil(t/2)}const ke=BigInt(0),Se=BigInt(1);function Oe(e,t){const n=t.negate();return e?n:t}function $e(e,t){const n=Ee(e.Fp,t.map((e=>e.Z)));return t.map(((t,r)=>e.fromAffine(t.toAffine(n[r]))))}function Ie(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){Ie(e,t);const n=2**e;return{windows:Math.ceil(t/e)+1,windowSize:2**(e-1),mask:Q(e),maxNumber:n,shiftBy:BigInt(e)}}function Ve(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+=Se);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 Ne(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 Ge(e){if(e!==ke)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>ke;)t&Se&&(n=n.add(r)),r=r.double(),t>>=Se;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}=Ve(n,s,i);n=e,c?o=o.add(Oe(l,t[f])):r=r.add(Oe(u,t[a]))}return Ge(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!==ke;i++){const{nextN:e,offset:s,isZero:a,isNeg:c}=Ve(n,i,o);if(n=e,!a){const e=t[s];r=r.add(c?e.negate():e)}}return Ge(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){Ie(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=ve.reduce(((e,t)=>(e[t]="function",e)),{ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"});ee(e,t)}(t),t}return Re(e,{isLE:n})}const Le=(e,t)=>(e+(e>=0?t:-t)/Ke)/t;function je(e){if(!["compact","recovered","der"].includes(e))throw new Error('Signature format must be "compact", "recovered", or "der"');return e}function Ze(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&&je(n.format),n}class qe extends Error{constructor(e=""){super(e)}}const He={Err:qe,_tlv:{encode:(e,t)=>{const{Err:n}=He;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=L(r);if(o.length/2&128)throw new n("tlv.encode: long form length too big");const i=r>127?L(o.length/2|128):"";return L(e)+i+o+t},decode(e,t){const{Err:n}=He;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}=He;if(e<We)throw new t("integer: negative integers are not allowed");let n=L(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}=He;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 Z(e)}},toSig(e){const{Err:t,_int:n,_tlv:r}=He,o=J("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}=He,r=t.encode(2,n.encode(e.r))+t.encode(2,n.encode(e.s));return t.encode(48,r)}},We=BigInt(0),Je=BigInt(1),Ke=BigInt(2),Xe=BigInt(3),Ye=BigInt(4);function Qe(e,t){const{BYTES:n}=e;let r;if("bigint"==typeof t)r=t;else{let i=J("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 et(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>ke))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;ee(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=nt(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 z(tt(!r.isOdd(i)),s)}return z(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(!p(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 p(e,t){const n=r.sqr(t),o=d(e);return r.eql(n,o)}if(!p(i.Gx,i.Gy))throw new Error("bad curve params: generator point");const g=r.mul(r.pow(i.a,Xe),Ye),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=Le(s*e,n),c=Le(-o*e,n);let u=e-a*r-c*i,l=-a*o-c*s;const f=u<We,h=l<We;f&&(u=-u),h&&(l=-l);const d=Q(Math.ceil(Y(n)/2))+Je;if(u<We||u>=d||l<We||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=te(((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=te((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(!p(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=Oe(o,t),n=Oe(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(J("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(Xe),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,Xe),{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,Xe);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=>$e(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 $e(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===We||r.is0())return T.ZERO;if(e===Je)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>ke||r>ke;)n&Se&&(i=i.add(o)),r&Se&&(s=s.add(o)),o=o.double(),n>>=Se,r>>=Se;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===Je||(e?e(T,this):A.unsafe(this,a).is0())}clearCofactor(){const{clearCofactor:e}=t;return s===Je?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 m(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 $e(T,e)}static msm(e,t){return function(e,t,n,r){De(n,e),Ne(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=Y(BigInt(o));let c=1;a>12?c=a-3:a>4?c=a-2:a>0&&(c=2);const u=Q(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(Qe(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 R=o.BITS,A=new Me(T,t.endo?Math.ceil(R/2):R);return T.BASE.precompute(8),T}function tt(e){return Uint8Array.of(e?2:3)}function nt(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function rt(e,t={}){const{Fn:n}=e,r=t.randomBytes||S,o=Object.assign(nt(e.Fp,n),{seed:Ae(n.ORDER)});function i(e){try{return!!Qe(n,e)}catch(t){return!1}}function s(e=r(o.seed)){return function(e,t,n=!1){const r=e.length,o=ze(t),i=Ae(t);if(r<16||r<i||r>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+r);const s=he(n?q(e):Z(e),t-re)+re;return n?W(s,o):H(s,o)}(U(e,o.seed,"seed"),n.ORDER)}function a(t,r=!0){return e.BASE.multiply(Qe(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=J("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=>Qe(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=Qe(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 ot(e,t,n={}){c(t),ee(n,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});const r=n.randomBytes||S,o=n.hmac||((e,...n)=>C(t,e,z(...n))),{Fp:s,Fn:a}=e,{ORDER:u,BITS:l}=a,{keygen:f,getPublicKey:h,getSharedSecret:d,utils:p,lengths:g}=rt(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>>Je}function v(e,t){if(!a.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){je(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}=He.toSig(U(e));return new B(t,n)}"recovered"===t&&(n=e[0],t="compact",e=e.subarray(1));const r=a.BYTES,o=e.subarray(0,r),i=e.subarray(r,2*r);return new B(a.fromBytes(o),a.fromBytes(i),n)}static fromHex(e,t){return this.fromBytes(x(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 c=2===i||3===i?r+u:r;if(!s.isValid(c))throw new Error("recovery id 2 or 3 invalid");const l=s.toBytes(c),f=e.fromBytes(z(tt(!(1&i)),l)),h=a.inv(c),d=T(J("msgHash",t)),p=a.create(-d*h),m=a.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(je(e),"der"===e)return x(He.hexFromSig(this));const t=a.toBytes(this.r),n=a.toBytes(this.s);if("recovered"===e){if(null==this.recovery)throw new Error("recovery bit must be present");return z(Uint8Array.of(this.recovery),t,n)}return z(t,n)}toHex(e){return m(this.toBytes(e))}assertValidity(){}static fromCompact(e){return B.fromBytes(J("sig",e),"compact")}static fromDER(e){return B.fromBytes(J("sig",e),"der")}normalizeS(){return this.hasHighS()?new B(this.r,a.neg(this.s),this.recovery):this}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return m(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return m(this.toBytes("compact"))}}const E=n.bits2int||function(e){if(e.length>8192)throw new Error("input is too large");const t=Z(e),n=8*e.length-l;return n>0?t>>BigInt(n):t},T=n.bits2int_modN||function(e){return a.create(E(e))},R=Q(l);function A(e){return X("num < 2^"+l,e,We,R),a.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:p,lengths:g,Point:e,sign:function(n,i,s={}){n=J("message",n);const{seed:c,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:c}=Ze(o,y);t=k(t,s);const u=T(t),l=Qe(a,n),f=[A(l),A(u)];if(null!=c&&!1!==c){const e=!0===c?r(g.secretKey):c;f.push(J("extraEntropy",e))}const h=z(...f),d=u;return{seed:h,k2sig:function(t){const n=E(t);if(!a.isValidNot0(n))return;const r=a.inv(n),o=e.BASE.multiply(n).toAffine(),s=a.create(o.x);if(s===We)return;const c=a.create(r*a.create(d+s*l));if(c===We)return;let u=(o.x===s?0:2)|Number(o.y&Je),f=c;return i&&b(c)&&(f=a.neg(c),u^=1),new B(s,f,u)}}}(n,i,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 z(...n)};return(e,t)=>{let n;for(c(),l(e);!(n=t(f()));)l();return c(),n}}(t.outputLen,a.BYTES,o)(c,u)},verify:function(t,n,r,o={}){const{lowS:s,prehash:c,format:u}=Ze(o,y);if(r=J("publicKey",r),n=k(J("message",n),c),"strict"in o)throw new Error("options.strict was renamed to lowS");const l=void 0===u?function(e){let t;const n="string"==typeof e||i(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(J("sig",e),"der")}catch(o){if(!(o instanceof He.Err))throw o}if(!t)try{t=B.fromBytes(J("sig",e),"compact")}catch(s){return!1}}return t||!1}(t):B.fromBytes(J("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,c=T(n),u=a.inv(i),f=a.create(c*u),h=a.create(o*u),d=e.BASE.multiplyUnsafe(f).add(t.multiplyUnsafe(h));if(d.is0())return!1;return a.create(d.x)===o}catch(f){return!1}},recoverPublicKey:function(e,t,n={}){const{prehash:r}=Ze(n,y);return t=k(t,r),B.fromBytes(e,"recovered").recoverPublicKey(t).toBytes()},Signature:B,hash:t})}function it(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:Re(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 st(e){const{CURVE:t,curveOpts:n,hash:r,ecdsaOpts:o}=function(e){const{CURVE:t,curveOpts:n}=it(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,Te(n.Fn.ORDER,n.Fn.BITS))})}(e,ot(et(t,n),r,o))}const at={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},ct={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]},ut=BigInt(2);const lt=Re(at.p,{sqrt:function(e){const t=at.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=de(l,n,t)*l%t,h=de(f,n,t)*l%t,d=de(h,ut,t)*u%t,p=de(d,o,t)*d%t,m=de(p,i,t)*p%t,g=de(m,a,t)*m%t,y=de(g,c,t)*g%t,w=de(y,a,t)*m%t,b=de(w,n,t)*l%t,v=de(b,s,t)*p%t,B=de(v,r,t)*u%t,E=de(B,ut,t);if(!lt.eql(lt.sqr(E),e))throw new Error("Cannot find square root");return E}}),ft=function(e,t){const n=t=>st({...e,hash:t});return{...n(t),create:n}}({...at,Fp:lt,lowS:!0,endo:ct},N);function ht(e,t){const n=[];for(let r=0;r<e.length;r+=t)n.push(e.subarray(r,r+t));return n}function dt(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 pt(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 mt(e){return Array.from(e).map((e=>e.toString(16).padStart(2,"0"))).join("")}function gt(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 yt(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 wt(e){const t=e.startsWith("0x")||e.startsWith("0X")?e.slice(2):e,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 bt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",vt="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";function Bt(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 Et(e,t){const n=t.length;let r=0,o=0,i="";for(const s of e)for(o=o<<8|s,r+=8;r>=Math.log2(n);)r-=Math.log2(n),i+=t.charAt(o>>r&n-1);return r>0&&(i+=t.charAt(o<<Math.log2(n)-r&n-1)),i.length%4!=0&&(i+="=".repeat(4-i.length%4)),i}function xt(e){return Et(e,vt)}function Tt(e){return new Uint8Array([e])}function Rt(e){return e[0]}function zt(e,t){return new DataView(e.buffer,e.byteOffset,e.byteLength).getUint16(0,"LE"===t)}function At(e,t){const n=new ArrayBuffer(4);return new DataView(n).setUint32(0,e,"LE"===t),new Uint8Array(n)}function kt(e,t){const n=new ArrayBuffer(8);return new DataView(n).setBigUint64(0,e,"LE"===t),new Uint8Array(n)}function St(e,t){return new DataView(e.buffer,e.byteOffset,e.byteLength).getBigUint64(0,"LE"===t)}var Ot=[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 $t(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];It(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=ht(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 It(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,N=e[14]<<6|e[15]>>>26,P=e[15]<<6|e[14]>>>26,C=e[17]<<23|e[16]>>>9,F=e[16]<<23|e[17]>>>9,G=e[18]<<20|e[19]>>>12,M=e[19]<<20|e[18]>>>12,U=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^~G&U,e[11]=S^~M&L,e[12]=G^~U&ee,e[13]=M^~L&te,e[14]=U^~ee&he,e[15]=L^~te&de,e[16]=ee^~he&k,e[17]=te^~de&S,e[18]=he^~k&G,e[19]=de^~S&M,e[20]=T^~N&W,e[21]=R^~P&J,e[22]=N^~W&se,e[23]=P^~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&N,e[29]=ue^~R&P,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]^=Ot[2*t],e[1]^=Ot[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 Vt=new TextDecoder,Dt=new TextEncoder,Nt=/^(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(!Nt.test(t)||t.replace(/^0x/i,"").length%2!=0)throw new Error(`Bytes#constructor: invalid hex string: ${t}`);this.bytes=wt(t)}else if(t instanceof ArrayBuffer)this.bytes=new Uint8Array(t);else if(t instanceof Uint8Array)this.bytes=t;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=wt(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($t(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 mt(this.bytes)}toBase64(){return Et(this.bytes,bt)}toBase32(){return xt(this.bytes)}toString(){return this.toHex()}toUtf8(){return Vt.decode(this.bytes)}toJSON(){return JSON.parse(this.toUtf8())}equals(t){return this.toHex()===new e(t).toHex()}represent(){return this.toHex()}},Ct=class extends Pt{static LENGTH=32;constructor(e){super(e,32)}},Ft=0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n;function Gt(e){if(e<=0n||e>=Ft)throw new Error("Invalid private key");const t=ft.Point.BASE.multiply(e);return[t.x,t.y]}function Mt(e){const t=new Uint8Array(20),n=$t(Pt.concat(gt(e[0],"BE"),gt(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=mt(e),n=mt($t(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)}},Lt=new Uint8Array(8).fill(255,0,8),jt=class e extends Pt{static LENGTH=8;static MINUS_ONE=new e(Lt);constructor(e){super(e,8)}static fromBigInt(t){return new e(kt(t,"BE"))}toBigInt(){return St(this.bytes,"BE")}next(){return mt(this.bytes)===mt(Lt)?e.fromBigInt(0n):e.fromBigInt(this.toBigInt()+1n)}},Zt=new TextEncoder,qt=class e extends Pt{static LENGTH=32;constructor(e){super(e,32)}static fromString(t){return new e($t(Zt.encode(t)))}},Ht=class extends Pt{static LENGTH=32;constructor(e){super(e,32)}};function Wt(e,t){const n=ft.sign($t(e),t,{prehash:!1}),r=0===n.recovery?27n:28n;return[n.r,n.s,r]}function Jt(e,t,n,r){const o=27n===r?0:1,i=new ft.Signature(t,n,o).recoverPublicKey($t(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=ft.Point.fromBytes(e);return[t.x,t.y]}(t.toUint8Array());super(Pt.concat(gt(e,"BE"),gt(n,"BE")),64)}else super(e,64)}address(){const e=yt(this.bytes.slice(0,32),"BE"),t=yt(this.bytes.slice(32,64),"BE");return new Ut(Mt([e,t]))}toCompressedUint8Array(){const e=yt(this.bytes.slice(0,32),"BE"),t=yt(this.bytes.slice(32,64),"BE");return n=[e,t],ft.Point.fromAffine({x:n[0],y:n[1]}).toBytes(!0);var n}toCompressedHex(){return mt(this.toCompressedUint8Array())}},Xt=new TextEncoder,Yt=Xt.encode("Ethereum Signed Message:\n32");function Qt(e){const t=e instanceof Uint8Array?e:Xt.encode(e);return Pt.concat(Yt,$t(t))}var en=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=yt(this.bytes.slice(0,32),"BE"),n=yt(this.bytes.slice(32,64),"BE"),r=BigInt(this.bytes[64]),[o,i]=Jt(Qt(e),t,n,r);return new Kt(Pt.concat(gt(o,"BE"),gt(i,"BE")))}isValid(e,t){return this.recoverPublicKey(e).address().equals(t)}},tn=class extends Pt{static LENGTH=32;constructor(e){super(e,32)}publicKey(){const[e,t]=Gt(this.toBigInt());return new Kt(Pt.concat(gt(e,"BE"),gt(t,"BE")))}sign(e){const[t,n,r]=Wt(Qt(e),this.toBigInt());return new en(Pt.concat(gt(t,"BE"),gt(n,"BE"),new Uint8Array([Number(r)])))}toBigInt(){return yt(this.bytes,"BE")}};function nn(e){const t=Bt(e.toUpperCase().slice(1),vt);const n=t[1];if(250!==n&&251!==n)throw new Error("Unknown codec");return t.slice(-32)}var rn=class e extends Pt{static LENGTH=32;constructor(e){"string"==typeof e&&e.startsWith("bah5")?super(nn(e),32):super(e,[32,64])}toCid(e){return`b${xt(Pt.concat(new Uint8Array([1]),new Uint8Array(["feed"===e?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}}},on=class e extends Pt{static LENGTH=8;constructor(e){super(e,8)}static fromBigInt(t){return new e(kt(t,"LE"))}toBigInt(){return St(this.bytes,"LE")}static fromSlice(t,n){return new e(t.slice(n,n+e.LENGTH))}},sn=new TextEncoder,an=class e extends Pt{static LENGTH=32;constructor(e){super(e,32)}static fromString(t){return new e($t(sn.encode(t)))}},cn=class extends Pt{static LENGTH=32;constructor(e){super(e,32)}},un=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}},ln=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 fn(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=$t($t(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 hn(e,t){return fn(e,128,t)}function dn(e,t){return fn(e,0,t)}var pn=4096;function mn(e){const t=e.subarray(0,8),n=function(e){if(e.length>pn)throw new Error(`payload size ${e.length} exceeds maximum chunk payload size 4096`);const t=new Uint8Array(pn);t.set(e);let n=ht(t,32);for(;n.length>1;){const e=[];for(let t=0;t<n.length;t+=2)e.push($t(Pt.concat(n[t],n[t+1])));n=e}return n[0]}(e.subarray(8));return new rn($t(Pt.concat(t,n)))}wt("dc5b20847f43d67928f49cd4f85d696b5a7617b5");var gn=qt.LENGTH,yn=qt.LENGTH+65,wn=yn+on.LENGTH,bn=(new TextEncoder).encode("Ethereum Signed Message:\n32");function vn(e,t){const n=$t(Pt.concat(e,t));return Pt.concat(bn,n)}function Bn(e,t,n){const[r,o,i]=Wt(vn(e,t),n);return Pt.concat(gt(r,"BE"),gt(o,"BE"),new Uint8Array([Number(i)]))}function En(e,t){const n=new qt(e),r=new Ut(t);return new rn($t(Pt.concat(n.toUint8Array(),r.toUint8Array())))}function xn(e,t,n){const r=new qt(t),o=Bn(r.toUint8Array(),e.address.toUint8Array(),n),i=new Ut(Mt(Gt(n))),s=En(r,i);return{data:Pt.concat(r.toUint8Array(),o,e.data),identifier:r,signature:new en(o),span:e.span,payload:e.payload,address:s,owner:i}}function Tn(e,t){const n=e instanceof Pt?e.toUint8Array():e,r=new rn(t),o=new qt(Pt.fromSlice(n,0,qt.LENGTH)),i=n.slice(gn,gn+65),s=mn(n.slice(yn)),a=new Ut(function(e,t,n){const r=yt(n.subarray(0,32),"BE"),o=yt(n.subarray(32,64),"BE"),i=BigInt(n[64]);return Mt(Jt(vn(e,t),r,o,i))}(o.toUint8Array(),s.toUint8Array(),i)),c=En(o,a);if(!c.equals(r))throw new Error("SOC data does not match given address");const u=on.fromSlice(n,yn),l=Pt.fromSlice(n,wn);return{data:n,identifier:o,signature:new en(i),span:u,payload:l,address:c,owner:a}}function Rn(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?on.fromBigInt(t):t:on.fromBigInt(BigInt(e.length)),r=new Pt(e),o=Pt.concat(n.toUint8Array(),r.toUint8Array()),i={data:o,span:n,payload:r,address:mn(o),toSingleOwnerChunk:(e,t)=>xn(i,e,new tn(t).toBigInt())};return i}function zn(e){const t=new Pt(e);return Rn(t.toUint8Array().slice(on.LENGTH),on.fromSlice(t.toUint8Array(),0))}var An=class{span;writer;constructor(e=0n){this.span=e,this.writer=new ln(new Uint8Array(4096))}build(){return Pt.concat(kt(this.span,"LE"),this.writer.buffer)}hash(){return mn(this.build())}encryptedHash(e){e||(e=new Uint8Array(32),crypto.getRandomValues(e));const t=hn(e,kt(this.span,"LE")),n=dn(e,this.writer.buffer);return{address:mn(Pt.concat(t,n)),key:e}}},kn=class e{static NOOP=async e=>[];refSize;encrypted;maxShards;chunks;counters=[1];pending=[[]];onBatch;onIntermediateChunk;hasParity=[!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 An],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 un(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.counters[e]=(this.counters[e]+1)%(4096/this.refSize),this.pending[e]||(this.pending[e]=[]),await this.sealParities(e);const t=this.chunks[e].span;if(e>=1&&this.onIntermediateChunk&&(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 An,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 un(t.hash().toUint8Array()))}}async flushBatch(e){this.chunks[e+1]||(this.chunks.push(new An),this.counters.push(1),this.pending.push([]),this.hasParity.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){return this.pending[e]?.length&&await this.flushBatch(e),this.chunks[e+1]?1===this.counters[e]?(await this.elevate(e+1),await this.flushBatch(e+1),this.chunks[e+1]=this.chunks[e],this.finalize(e+1)):(await this.elevate(e),await this.flushBatch(e),this.finalize(e+1)):(await this.sealParities(e),e>=1&&this.onIntermediateChunk&&this.onIntermediateChunk(this.chunks[e],this.hasParity[e]??!1),this.chunks[e])}},Sn=[[[],[]],[[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]]],On=[[[],[]],[[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 $n(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?On[e]:Sn[e],t)}function In(e,t,n){return t<=0||e<=0?0:$n(t,e,n)/e}var _n={label:"medium",value:1,errorTolerance:.01},Vn={label:"strong",value:2,errorTolerance:.05},Dn={label:"insane",value:3,errorTolerance:.1},Nn={label:"paranoid",value:4,errorTolerance:.5};function Pn(){return{medium:_n,strong:Vn,insane:Dn,paranoid:Nn}}function Cn(e){if("string"==typeof e)switch(e.toLowerCase()){case"medium":return _n;case"strong":return Vn;case"insane":return Dn;case"paranoid":return Nn;default:throw new Error(`Unknown redundancy level '${e}'`)}switch(e){case 1:return _n;case 2:return Vn;case 3:return Dn;case 4:return Nn;default:throw new Error(`Unknown redundancy level '${e}'`)}}function Fn(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}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 Gn=new TextEncoder,Mn=new TextDecoder,Un=new Uint8Array([47]),Ln=wt("5768b3b6a7db56d21d1abff40d41cebfc83448fed8d7e9b06ec0d3b073f28f7b");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=new Uint8Array(32);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),e?.obfuscationKey&&(this.obfuscationKey=e.obfuscationKey),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());this.encrypt&&dt(this.obfuscationKey,new Uint8Array(32))&&(this.obfuscationKey=new Uint8Array(32),crypto.getRandomValues(this.obfuscationKey));const e=!dt(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(Ln,0),n.set(Tt(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)}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 un(o);if(!dt(i.read(31),Ln.slice(0,31)))throw new Error("MantarayNode#unmarshalFromData invalid version hash");const s=Rt(i.read(1)),a=i.read(s),c=new e({selfAddress:n,targetAddress:a,obfuscationKey:r}),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}return c}addFork(t,n,r){this.selfAddress=null,this.type=null,t=t instanceof Uint8Array?t:Gn.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)continue;const l=new Jn(u,new e({targetAddress:s?new rn(n).toUint8Array():void 0,metadata:s?r:void 0,path:u,encrypt:this.encrypt})),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.selfAddress=null,o.type=null,o=l.node}}removeFork(e){if(this.selfAddress=null,this.type=null,0===(e=e instanceof Uint8Array?e:Gn.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");const[n,r]=this.findClosest(e.slice(0,e.length-1));n.forks.delete(e.slice(r.length)[0]);for(const o of t.forks.values())n.addFork(Pt.concat(t.path,o.prefix),o.node.targetAddress,o.node.metadata)}async calculateSelfAddress(){if(this.selfAddress)return new rn(this.selfAddress);if(this.encrypt)throw new Error("MantarayNode#calculateSelfAddress is not supported for encrypted nodes - use saveRecursively");return(await kn.root(await this.marshal())).hash()}async saveRecursively(e){for(const r of this.forks.values())await r.node.saveRecursively(e);const t=new kn((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),{reference:this.selfAddress,rootChunk:n,encryptionKey:r}}return await e(n),this.selfAddress=n.hash().toUint8Array(),{reference:this.selfAddress,rootChunk:n}}find(e){const t=e instanceof Uint8Array?e:Gn.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:Gn.encode(e)).length)return[this,t];const n=this.forks.get(e[0]);return n&&pt(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())dt(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 rn(t.targetAddress).toHex();return e}determineType(){let e=0;const t=new Uint8Array(this.targetAddress.length);return dt(this.targetAddress,t)&&0!==this.forks.size||(e|=2),this.forks.size>0&&(e|=4),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}(this.path,Un)>0&&(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=pt(t.prefix,n.prefix);if(r.length===t.prefix.length){const e=n.prefix.slice(r.length);return n.node.path=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.path=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.path=t.prefix.slice(r.length),n.node.path=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(Tt(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=Rt(t.read(1)),o=Rt(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=zt(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}))}};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){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 tn(t),new Ct(n),new Uint32Array(65536),r)}static fromState(t,n,r,o){return new e(new tn(t),new Ct(n),r,o)}stamp(e,t){const n=zt(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 tn(e),s=new Ct(t),a=zt(n,"BE"),c=Pt.concat(At(a,"BE"),At(r,"BE")),u=kt(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}};function cr(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 ur extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class lr extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}}(sr=globalThis).__zod_globalConfig??(sr.__zod_globalConfig={});const fr=globalThis.__zod_globalConfig;function hr(e){return e&&Object.assign(fr,e),fr}const dr=/^[cC][0-9a-z]{6,}$/,pr=/^[0-9a-z]+$/,mr=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,gr=/^[0-9a-vA-V]{20}$/,yr=/^[A-Za-z0-9]{27}$/,wr=/^[a-zA-Z0-9_-]{21}$/,br=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,vr=/^([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})$/,Br=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)$/,Er=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;const xr=/^(?:(?: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])$/,Tr=/^(([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}|:))$/,Rr=/^((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])$/,zr=/^(([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])$/,Ar=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,kr=/^[A-Za-z0-9_-]*$/,Sr=/^https?$/,Or=/^\+[1-9]\d{6,14}$/,$r="(?:(?:\\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])))",Ir=new RegExp(`^${$r}$`);function _r(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 Vr=/^-?\d+n?$/,Dr=/^-?\d+$/,Nr=/^-?\d+(?:\.\d+)?$/,Pr=/^(?:true|false)$/i,Cr=/^[^A-Z]*$/,Fr=/^[^a-z]*$/;function Gr(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 Mr(e,t){return"bigint"==typeof t?t.toString():t}function Ur(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Lr(e){return null==e}function jr(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}const Zr=Symbol("evaluating");function qr(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Zr)return void 0===r&&(r=Zr,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function Hr(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Wr(...e){const t={};for(const n of e){const e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function Jr(e){return JSON.stringify(e)}const Kr="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Xr(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}const Yr=Ur((()=>{if(fr.jitless)return!1;if("undefined"!=typeof navigator&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}}));function Qr(e){if(!1===Xr(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!==Xr(n)&&!1!==Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")}function eo(e){return Qr(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const to=new Set(["string","number","symbol"]);function no(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ro(e,t,n){const r=new e._zod.constr(t??e._zod.def);return t&&!n?.parent||(r._zod.parent=e),r}function oo(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 io={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 so(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 ao(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 co(e,t){return t.map((t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t}))}function uo(e){return"string"==typeof e?e:e?.message}function lo(e,t,n){const r=e.message?e.message:uo(e.inst?._zod.def?.error?.(e))??uo(t?.error?.(e))??uo(n.customError?.(e))??uo(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 fo(e){return Array.isArray(e)?"array":"string"==typeof e?"string":"unknown"}function ho(...e){const[t,n,r]=e;return"string"==typeof t?{message:t,code:"custom",input:n,inst:r}:{...t}}const po=cr("$ZodCheck",((e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])})),mo={number:"number",bigint:"bigint",object:"date"},go=cr("$ZodCheckLessThan",((e,t)=>{po.init(e,t);const n=mo[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})}})),yo=cr("$ZodCheckGreaterThan",((e,t)=>{po.init(e,t);const n=mo[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})}})),wo=cr("$ZodCheckMultipleOf",((e,t)=>{po.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})}})),bo=cr("$ZodCheckNumberFormat",((e,t)=>{po.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),r=n?"int":"number",[o,i]=io[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=Dr)})),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})}})),vo=cr("$ZodCheckMaxLength",((e,t)=>{var n;po.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!Lr(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=fo(r);n.issues.push({origin:o,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}})),Bo=cr("$ZodCheckMinLength",((e,t)=>{var n;po.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!Lr(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=fo(r);n.issues.push({origin:o,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}})),Eo=cr("$ZodCheckLengthEquals",((e,t)=>{var n;po.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!Lr(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=fo(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})}})),xo=cr("$ZodCheckStringFormat",((e,t)=>{var n,r;po.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=()=>{})})),To=cr("$ZodCheckRegex",((e,t)=>{xo.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})}})),Ro=cr("$ZodCheckLowerCase",((e,t)=>{t.pattern??(t.pattern=Cr),xo.init(e,t)})),zo=cr("$ZodCheckUpperCase",((e,t)=>{t.pattern??(t.pattern=Fr),xo.init(e,t)})),Ao=cr("$ZodCheckIncludes",((e,t)=>{po.init(e,t);const n=no(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})}})),ko=cr("$ZodCheckStartsWith",((e,t)=>{po.init(e,t);const n=new RegExp(`^${no(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})}})),So=cr("$ZodCheckEndsWith",((e,t)=>{po.init(e,t);const n=new RegExp(`.*${no(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 Oo=cr("$ZodCheckOverwrite",((e,t)=>{po.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}));class $o{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 Io=(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,Mr,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},_o=cr("$ZodError",Io),Vo=cr("$ZodError",Io,{Parent:Error});const Do=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 ur;if(s.issues.length){const t=new(o?.Err??e)(s.issues.map((e=>lo(e,i,hr()))));throw Kr(t,o?.callee),t}return s.value},No=Do(Vo),Po=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=>lo(e,i,hr()))));throw Kr(t,o?.callee),t}return s.value},Co=Po(Vo),Fo=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 ur;return i.issues.length?{success:!1,error:new(e??_o)(i.issues.map((e=>lo(e,o,hr()))))}:{success:!0,data:i.value}},Go=Fo(Vo),Mo=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=>lo(e,o,hr()))))}:{success:!0,data:i.value}},Uo=Mo(Vo),Lo=e=>(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return Do(e)(t,n,o)},jo=e=>(t,n,r)=>Do(e)(t,n,r),Zo=e=>async(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return Po(e)(t,n,o)},qo=e=>async(t,n,r)=>Po(e)(t,n,r),Ho=e=>(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return Fo(e)(t,n,o)},Wo=e=>(t,n,r)=>Fo(e)(t,n,r),Jo=e=>async(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return Mo(e)(t,n,o)},Ko=e=>async(t,n,r)=>Mo(e)(t,n,r),Xo={major:4,minor:4,patch:3};const Yo=cr("$ZodType",((e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Xo;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=so(e);for(const i of t){if(i._zod.def.when){if(ao(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 ur;if(r||s instanceof Promise)r=(r??Promise.resolve()).then((async()=>{await s;e.issues.length!==t&&(o||(o=so(e,t)))}));else{if(e.issues.length===t)continue;o||(o=so(e,t))}}return r?r.then((()=>e)):e},n=(n,o,i)=>{if(so(n))return n.aborted=!0,n;const s=t(o,r,i);if(s instanceof Promise){if(!1===i.async)throw new ur;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 ur;return s.then((e=>t(e,r,i)))}return t(s,r,i)}}qr(e,"~standard",(()=>({validate:t=>{try{const n=Go(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch(n){return Uo(e,t).then((e=>e.success?{value:e.data}:{issues:e.error?.issues}))}},vendor:"zod",version:1})))})),Qo=cr("$ZodString",((e,t)=>{var n;Yo.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}})),ei=cr("$ZodStringFormat",((e,t)=>{xo.init(e,t),Qo.init(e,t)})),ti=cr("$ZodGUID",((e,t)=>{t.pattern??(t.pattern=vr),ei.init(e,t)})),ni=cr("$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=Br(e))}else t.pattern??(t.pattern=Br());ei.init(e,t)})),ri=cr("$ZodEmail",((e,t)=>{t.pattern??(t.pattern=Er),ei.init(e,t)})),oi=cr("$ZodURL",((e,t)=>{ei.init(e,t),e._zod.check=n=>{try{const r=n.value.trim();if(!t.normalize&&t.protocol?.source===Sr.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})}}})),ii=cr("$ZodEmoji",((e,t)=>{t.pattern??(t.pattern=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),ei.init(e,t)})),si=cr("$ZodNanoID",((e,t)=>{t.pattern??(t.pattern=wr),ei.init(e,t)})),ai=cr("$ZodCUID",((e,t)=>{t.pattern??(t.pattern=dr),ei.init(e,t)})),ci=cr("$ZodCUID2",((e,t)=>{t.pattern??(t.pattern=pr),ei.init(e,t)})),ui=cr("$ZodULID",((e,t)=>{t.pattern??(t.pattern=mr),ei.init(e,t)})),li=cr("$ZodXID",((e,t)=>{t.pattern??(t.pattern=gr),ei.init(e,t)})),fi=cr("$ZodKSUID",((e,t)=>{t.pattern??(t.pattern=yr),ei.init(e,t)})),hi=cr("$ZodISODateTime",((e,t)=>{t.pattern??(t.pattern=function(e){const t=_r({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(`^${$r}T(?:${r})$`)}(t)),ei.init(e,t)})),di=cr("$ZodISODate",((e,t)=>{t.pattern??(t.pattern=Ir),ei.init(e,t)})),pi=cr("$ZodISOTime",((e,t)=>{t.pattern??(t.pattern=new RegExp(`^${_r(t)}$`)),ei.init(e,t)})),mi=cr("$ZodISODuration",((e,t)=>{t.pattern??(t.pattern=br),ei.init(e,t)})),gi=cr("$ZodIPv4",((e,t)=>{t.pattern??(t.pattern=xr),ei.init(e,t),e._zod.bag.format="ipv4"})),yi=cr("$ZodIPv6",((e,t)=>{t.pattern??(t.pattern=Tr),ei.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})}}})),wi=cr("$ZodCIDRv4",((e,t)=>{t.pattern??(t.pattern=Rr),ei.init(e,t)})),bi=cr("$ZodCIDRv6",((e,t)=>{t.pattern??(t.pattern=zr),ei.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 vi(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 Bi=cr("$ZodBase64",((e,t)=>{t.pattern??(t.pattern=Ar),ei.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{vi(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}}));const Ei=cr("$ZodBase64URL",((e,t)=>{t.pattern??(t.pattern=kr),ei.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{(function(e){if(!kr.test(e))return!1;const t=e.replace(/[-_]/g,(e=>"-"===e?"+":"/"));return vi(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})}})),xi=cr("$ZodE164",((e,t)=>{t.pattern??(t.pattern=Or),ei.init(e,t)}));const Ti=cr("$ZodJWT",((e,t)=>{ei.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})}})),Ri=cr("$ZodNumber",((e,t)=>{Yo.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}})),zi=cr("$ZodNumberFormat",((e,t)=>{bo.init(e,t),Ri.init(e,t)})),Ai=cr("$ZodBoolean",((e,t)=>{Yo.init(e,t),e._zod.pattern=Pr,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}})),ki=cr("$ZodBigInt",((e,t)=>{Yo.init(e,t),e._zod.pattern=Vr,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}})),Si=cr("$ZodAny",((e,t)=>{Yo.init(e,t),e._zod.parse=e=>e})),Oi=cr("$ZodUnknown",((e,t)=>{Yo.init(e,t),e._zod.parse=e=>e})),$i=cr("$ZodNever",((e,t)=>{Yo.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:e}),t)}));function Ii(e,t,n){e.issues.length&&t.issues.push(...co(n,e.issues)),t.value[n]=e.value}const _i=cr("$ZodArray",((e,t)=>{Yo.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=>Ii(t,n,e)))):Ii(a,n,e)}return i.length?Promise.all(i).then((()=>n)):n}}));function Vi(e,t,n,r,o,i){const s=n in r;if(e.issues.length){if(o&&i&&!s)return;t.issues.push(...co(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 Di(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=>Vi(e,n,h,t,l,f)))):Vi(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 Pi=cr("$ZodObject",((e,t)=>{Yo.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=Ur((()=>Di(t)));qr(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=Xr,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=>Vi(n,t,e,a,o,i)))):Vi(s,t,e,a,o,i)}return i?Ni(c,a,t,n,r.value,e):c.length?Promise.all(c).then((()=>t)):t}})),Ci=cr("$ZodObjectJIT",((e,t)=>{Pi.init(e,t);const n=e._zod.parse,r=Ur((()=>Di(t)));let o;const i=Xr,s=!fr.jitless,a=s&&Yr.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 $o(["shape","payload","ctx"]),n=r.value,o=e=>{const t=Jr(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=Jr(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 Fi(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=>!so(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=>lo(e,r,hr())))))}),t)}const Gi=cr("$ZodUnion",((e,t)=>{Yo.init(e,t),qr(e._zod,"optin",(()=>t.options.some((e=>"optional"===e._zod.optin))?"optional":void 0)),qr(e._zod,"optout",(()=>t.options.some((e=>"optional"===e._zod.optout))?"optional":void 0)),qr(e._zod,"values",(()=>{if(t.options.every((e=>e._zod.values)))return new Set(t.options.flatMap((e=>Array.from(e._zod.values))))})),qr(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=>jr(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=>Fi(t,r,e,o))):Fi(s,r,e,o)}}));const Mi=cr("$ZodIntersection",((e,t)=>{Yo.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])=>Li(e,t,n))):Li(e,o,i)}}));function Ui(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(Qr(e)&&Qr(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=Ui(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=Ui(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 Li(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}),so(e))return e;const s=Ui(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 ji=cr("$ZodTuple",((e,t)=>{Yo.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=Zi(n,"optin"),c=Zi(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=>qi(t,r,e)))):qi(i,r,e)}}return s.length?Promise.all(s).then((()=>Hi(u,r,n,i,c))):Hi(u,r,n,i,c)}}));function Zi(e,t){for(let n=e.length-1;n>=0;n--)if("optional"!==e[n]._zod[t])return n+1;return 0}function qi(e,t,n){e.issues.length&&t.issues.push(...co(n,e.issues)),t.value[n]=e.value}function Hi(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(...co(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 Wi=cr("$ZodRecord",((e,t)=>{Yo.init(e,t),e._zod.parse=(n,r)=>{const o=n.value;if(!Qr(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=>lo(e,r,hr()))),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(...co(u,e.issues)),n.value[c]=e.value}))):(l.issues.length&&n.issues.push(...co(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=>lo(e,r,hr()))),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(...co(s,e.issues)),n.value[a.value]=e.value}))):(c.issues.length&&n.issues.push(...co(s,c.issues)),n.value[a.value]=c.value)}}return i.length?Promise.all(i).then((()=>n)):n}}));const Ji=cr("$ZodEnum",((e,t)=>{Yo.init(e,t);const n=Gr(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter((e=>to.has(typeof e))).map((e=>"string"==typeof e?no(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}})),Ki=cr("$ZodLiteral",((e,t)=>{if(Yo.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?no(e):e?no(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}})),Xi=cr("$ZodTransform",((e,t)=>{Yo.init(e,t),e._zod.optin="optional",e._zod.parse=(n,r)=>{if("backward"===r.direction)throw new lr(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 ur;return n.value=o,n.fallback=!0,n}}));function Yi(e,t){return void 0===t&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}const Qi=cr("$ZodOptional",((e,t)=>{Yo.init(e,t),e._zod.optin="optional",e._zod.optout="optional",qr(e._zod,"values",(()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0)),qr(e._zod,"pattern",(()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${jr(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=>Yi(e,r))):Yi(o,r)}return void 0===e.value?e:t.innerType._zod.run(e,n)}})),es=cr("$ZodExactOptional",((e,t)=>{Qi.init(e,t),qr(e._zod,"values",(()=>t.innerType._zod.values)),qr(e._zod,"pattern",(()=>t.innerType._zod.pattern)),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)})),ts=cr("$ZodNullable",((e,t)=>{Yo.init(e,t),qr(e._zod,"optin",(()=>t.innerType._zod.optin)),qr(e._zod,"optout",(()=>t.innerType._zod.optout)),qr(e._zod,"pattern",(()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${jr(e.source)}|null)$`):void 0})),qr(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)})),ns=cr("$ZodDefault",((e,t)=>{Yo.init(e,t),e._zod.optin="optional",qr(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=>rs(e,t))):rs(r,t)}}));function rs(e,t){return void 0===e.value&&(e.value=t.defaultValue),e}const os=cr("$ZodPrefault",((e,t)=>{Yo.init(e,t),e._zod.optin="optional",qr(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))})),is=cr("$ZodNonOptional",((e,t)=>{Yo.init(e,t),qr(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=>ss(t,e))):ss(o,e)}}));function ss(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 as=cr("$ZodCatch",((e,t)=>{Yo.init(e,t),e._zod.optin="optional",qr(e._zod,"optout",(()=>t.innerType._zod.optout)),qr(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=>lo(e,n,hr())))},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=>lo(e,n,hr())))},input:e.value}),e.issues=[],e.fallback=!0),e)}})),cs=cr("$ZodPipe",((e,t)=>{Yo.init(e,t),qr(e._zod,"values",(()=>t.in._zod.values)),qr(e._zod,"optin",(()=>t.in._zod.optin)),qr(e._zod,"optout",(()=>t.out._zod.optout)),qr(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=>us(e,t.in,n))):us(r,t.in,n)}const r=t.in._zod.run(e,n);return r instanceof Promise?r.then((e=>us(e,t.out,n))):us(r,t.out,n)}}));function us(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 ls=cr("$ZodReadonly",((e,t)=>{Yo.init(e,t),qr(e._zod,"propValues",(()=>t.innerType._zod.propValues)),qr(e._zod,"values",(()=>t.innerType._zod.values)),qr(e._zod,"optin",(()=>t.innerType?._zod?.optin)),qr(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(fs):fs(r)}}));function fs(e){return e.value=Object.freeze(e.value),e}const hs=cr("$ZodFunction",((e,t)=>(Yo.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 Co(e._def.input,n):n,o=await Reflect.apply(t,this,r);return e._def.output?await Co(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 ji({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))),ds=cr("$ZodCustom",((e,t)=>{po.init(e,t),Yo.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=>ps(t,n,r,e)));ps(o,n,r,e)}}));function ps(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(ho(e))}}var ms;Symbol("ZodOutput"),Symbol("ZodInput");class gs{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)}}(ms=globalThis).__zod_globalRegistry??(ms.__zod_globalRegistry=new gs);const ys=globalThis.__zod_globalRegistry;function ws(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...oo(t)})}function bs(e,t){return new go({check:"less_than",...oo(t),value:e,inclusive:!1})}function vs(e,t){return new go({check:"less_than",...oo(t),value:e,inclusive:!0})}function Bs(e,t){return new yo({check:"greater_than",...oo(t),value:e,inclusive:!1})}function Es(e,t){return new yo({check:"greater_than",...oo(t),value:e,inclusive:!0})}function xs(e,t){return new wo({check:"multiple_of",...oo(t),value:e})}function Ts(e,t){return new vo({check:"max_length",...oo(t),maximum:e})}function Rs(e,t){return new Bo({check:"min_length",...oo(t),minimum:e})}function zs(e,t){return new Eo({check:"length_equals",...oo(t),length:e})}function As(e){return new Oo({check:"overwrite",tx:e})}function ks(e,t){const n=function(e,t){const n=new po({check:"custom",...oo(t)});return n._zod.check=e,n}((t=>(t.addIssue=e=>{if("string"==typeof e)t.issues.push(ho(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(ho(r))}},e(t.value,t))),t);return n}function Ss(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??ys,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 Os(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),Os(i,t,r),t.seen.get(i).isParent=!0)}const c=t.metadataRegistry.get(e);c&&Object.assign(s.schema,c),"input"===t.io&&_s(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 $s(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 Is(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:Vs(t,"input",e.processors),output:Vs(t,"output",e.processors)}},enumerable:!1,writable:!1}),n}catch(a){throw new Error("Error converting schema to JSON.")}}function _s(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 _s(r.element,n);if("set"===r.type)return _s(r.valueType,n);if("lazy"===r.type)return _s(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 _s(r.innerType,n);if("intersection"===r.type)return _s(r.left,n)||_s(r.right,n);if("record"===r.type||"map"===r.type)return _s(r.keyType,n)||_s(r.valueType,n);if("pipe"===r.type)return!!e._zod.traits.has("$ZodCodec")||(_s(r.in,n)||_s(r.out,n));if("object"===r.type){for(const e in r.shape)if(_s(r.shape[e],n))return!0;return!1}if("union"===r.type){for(const e of r.options)if(_s(e,n))return!0;return!1}if("tuple"===r.type){for(const e of r.items)if(_s(e,n))return!0;return!(!r.rest||!_s(r.rest,n))}return!1}const Vs=(e,t,n={})=>r=>{const{libraryOptions:o,target:i}=r??{},s=Ss({...o??{},target:i,io:t,processors:n});return Os(e,s),$s(s,e),Is(s,e)};const Ds={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=Ds[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})))])}},Ps=(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)},Cs=(e,t,n,r)=>{n.type="boolean"},Fs=(e,t,n,r)=>{if("throw"===t.unrepresentable)throw new Error("BigInt cannot be represented in JSON Schema")},Gs=(e,t,n,r)=>{n.not={}},Ms=(e,t,n,r)=>{const o=Gr(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},Us=(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},Ls=(e,t,n,r)=>{if("throw"===t.unrepresentable)throw new Error("Custom types cannot be represented in JSON Schema")},js=(e,t,n,r)=>{if("throw"===t.unrepresentable)throw new Error("Function types cannot be represented in JSON Schema")},Zs=(e,t,n,r)=>{if("throw"===t.unrepresentable)throw new Error("Transforms cannot be represented in JSON Schema")},qs=(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=Os(i.element,t,{...r,path:[...r.path,"items"]})},Hs=(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]=Os(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=Os(i.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):"output"===t.io&&(o.additionalProperties=!1)},Ws=(e,t,n,r)=>{const o=e._zod.def,i=!1===o.inclusive,s=o.options.map(((e,n)=>Os(e,t,{...r,path:[...r.path,i?"oneOf":"anyOf",n]})));i?n.oneOf=s:n.anyOf=s},Js=(e,t,n,r)=>{const o=e._zod.def,i=Os(o.left,t,{...r,path:[...r.path,"allOf",0]}),s=Os(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},Ks=(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)=>Os(e,t,{...r,path:[...r.path,s,n]}))),u=i.rest?Os(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)},Xs=(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=Os(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=Os(i.keyType,t,{...r,path:[...r.path,"propertyNames"]})),o.additionalProperties=Os(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)}},Ys=(e,t,n,r)=>{const o=e._zod.def,i=Os(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"}]},Qs=(e,t,n,r)=>{const o=e._zod.def;Os(o.innerType,t,r);t.seen.get(e).ref=o.innerType},ea=(e,t,n,r)=>{const o=e._zod.def;Os(o.innerType,t,r);t.seen.get(e).ref=o.innerType,n.default=JSON.parse(JSON.stringify(o.defaultValue))},ta=(e,t,n,r)=>{const o=e._zod.def;Os(o.innerType,t,r);t.seen.get(e).ref=o.innerType,"input"===t.io&&(n._prefault=JSON.parse(JSON.stringify(o.defaultValue)))},na=(e,t,n,r)=>{const o=e._zod.def;Os(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},ra=(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;Os(s,t,r);t.seen.get(e).ref=s},oa=(e,t,n,r)=>{const o=e._zod.def;Os(o.innerType,t,r);t.seen.get(e).ref=o.innerType,n.readOnly=!0},ia=(e,t,n,r)=>{const o=e._zod.def;Os(o.innerType,t,r);t.seen.get(e).ref=o.innerType};const sa=cr("ZodISODateTime",((e,t)=>{hi.init(e,t),Va.init(e,t)}));function aa(e){return function(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...oo(t)})}(sa,e)}const ca=cr("ZodISODate",((e,t)=>{di.init(e,t),Va.init(e,t)}));function ua(e){return function(e,t){return new e({type:"string",format:"date",check:"string_format",...oo(t)})}(ca,e)}const la=cr("ZodISOTime",((e,t)=>{pi.init(e,t),Va.init(e,t)}));function fa(e){return function(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...oo(t)})}(la,e)}const ha=cr("ZodISODuration",((e,t)=>{mi.init(e,t),Va.init(e,t)}));function da(e){return function(e,t){return new e({type:"string",format:"duration",check:"string_format",...oo(t)})}(ha,e)}const pa=(e,t)=>{_o.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,Mr,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Mr,2)}},isEmpty:{get:()=>0===e.issues.length}})},ma=cr("ZodError",pa,{Parent:Error}),ga=Do(ma),ya=Po(ma),wa=Fo(ma),ba=Mo(ma),va=Lo(ma),Ba=jo(ma),Ea=Zo(ma),xa=qo(ma),Ta=Ho(ma),Ra=Wo(ma),za=Jo(ma),Aa=Ko(ma);const ka=new WeakMap;function Sa(e,t,n){const r=Object.getPrototypeOf(e);let o=ka.get(r);if(o||(o=new Set,ka.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 Oa=cr("ZodType",((e,t)=>(Yo.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Vs(e,"input"),output:Vs(e,"output")}}),e.toJSONSchema=((e,t={})=>n=>{const r=Ss({...n,processors:t});return Os(e,r),$s(r,e),Is(r,e)})(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>ga(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>wa(e,t,n),e.parseAsync=async(t,n)=>ya(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>ba(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>va(e,t,n),e.decode=(t,n)=>Ba(e,t,n),e.encodeAsync=async(t,n)=>Ea(e,t,n),e.decodeAsync=async(t,n)=>xa(e,t,n),e.safeEncode=(t,n)=>Ta(e,t,n),e.safeDecode=(t,n)=>Ra(e,t,n),e.safeEncodeAsync=async(t,n)=>za(e,t,n),e.safeDecodeAsync=async(t,n)=>Aa(e,t,n),Sa(e,"ZodType",{check(...e){const t=this.def;return this.clone(Wr(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 ro(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,...oo(n)})}(Lc,e,t)}(e,t))},superRefine(e,t){return this.check(function(e,t){return ks(e,t)}(e,t))},overwrite(e){return this.check(As(e))},optional(){return $c(this)},exactOptional(){return new Ic({type:"optional",innerType:this})},nullable(){return Vc(this)},nullish(){return $c(Vc(this))},nonoptional(e){return function(e,t){return new Pc({type:"nonoptional",innerType:e,...oo(t)})}(this,e)},array(){return mc(this)},or(e){return bc([this,e])},and(e){return new vc({type:"intersection",left:this,right:e})},transform(e){return Gc(this,Sc(e))},default(e){return t=e,new Dc({type:"default",innerType:this,get defaultValue(){return"function"==typeof t?t():eo(t)}});var t},prefault(e){return t=e,new Nc({type:"prefault",innerType:this,get defaultValue(){return"function"==typeof t?t():eo(t)}});var t},catch(e){return new Cc({type:"catch",innerType:this,catchValue:"function"==typeof(t=e)?t:()=>t});var t},pipe(e){return Gc(this,e)},readonly(){return new Mc({type:"readonly",innerType:this})},describe(e){const t=this.clone();return ys.add(t,{description:e}),t},meta(...e){if(0===e.length)return ys.get(this);const t=this.clone();return ys.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:()=>ys.get(e)?.description,configurable:!0}),e))),$a=cr("_ZodString",((e,t)=>{Qo.init(e,t),Oa.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,Sa(e,"_ZodString",{regex(...e){return this.check(function(e,t){return new To({check:"string_format",format:"regex",...oo(t),pattern:e})}(...e))},includes(...e){return this.check(function(e,t){return new Ao({check:"string_format",format:"includes",...oo(t),includes:e})}(...e))},startsWith(...e){return this.check(function(e,t){return new ko({check:"string_format",format:"starts_with",...oo(t),prefix:e})}(...e))},endsWith(...e){return this.check(function(e,t){return new So({check:"string_format",format:"ends_with",...oo(t),suffix:e})}(...e))},min(...e){return this.check(Rs(...e))},max(...e){return this.check(Ts(...e))},length(...e){return this.check(zs(...e))},nonempty(...e){return this.check(Rs(1,...e))},lowercase(e){return this.check(function(e){return new Ro({check:"string_format",format:"lowercase",...oo(e)})}(e))},uppercase(e){return this.check(function(e){return new zo({check:"string_format",format:"uppercase",...oo(e)})}(e))},trim(){return this.check(As((e=>e.trim())))},normalize(...e){return this.check(function(e){return As((t=>t.normalize(e)))}(...e))},toLowerCase(){return this.check(As((e=>e.toLowerCase())))},toUpperCase(){return this.check(As((e=>e.toUpperCase())))},slugify(){return this.check(As((e=>function(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}(e))))}})})),Ia=cr("ZodString",((e,t)=>{Qo.init(e,t),$a.init(e,t),e.email=t=>e.check(function(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...oo(t)})}(Da,t)),e.url=t=>e.check(function(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...oo(t)})}(Ca,t)),e.jwt=t=>e.check(function(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...oo(t)})}(Qa,t)),e.emoji=t=>e.check(function(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...oo(t)})}(Fa,t)),e.guid=t=>e.check(ws(Na,t)),e.uuid=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...oo(t)})}(Pa,t)),e.uuidv4=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...oo(t)})}(Pa,t)),e.uuidv6=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...oo(t)})}(Pa,t)),e.uuidv7=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...oo(t)})}(Pa,t)),e.nanoid=t=>e.check(function(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...oo(t)})}(Ga,t)),e.guid=t=>e.check(ws(Na,t)),e.cuid=t=>e.check(function(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...oo(t)})}(Ma,t)),e.cuid2=t=>e.check(function(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...oo(t)})}(Ua,t)),e.ulid=t=>e.check(function(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...oo(t)})}(La,t)),e.base64=t=>e.check(function(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...oo(t)})}(Ka,t)),e.base64url=t=>e.check(function(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...oo(t)})}(Xa,t)),e.xid=t=>e.check(function(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...oo(t)})}(ja,t)),e.ksuid=t=>e.check(function(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...oo(t)})}(Za,t)),e.ipv4=t=>e.check(function(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...oo(t)})}(qa,t)),e.ipv6=t=>e.check(function(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...oo(t)})}(Ha,t)),e.cidrv4=t=>e.check(function(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...oo(t)})}(Wa,t)),e.cidrv6=t=>e.check(function(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...oo(t)})}(Ja,t)),e.e164=t=>e.check(function(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...oo(t)})}(Ya,t)),e.datetime=t=>e.check(aa(t)),e.date=t=>e.check(ua(t)),e.time=t=>e.check(fa(t)),e.duration=t=>e.check(da(t))}));function _a(e){return function(e,t){return new e({type:"string",...oo(t)})}(Ia,e)}const Va=cr("ZodStringFormat",((e,t)=>{ei.init(e,t),$a.init(e,t)})),Da=cr("ZodEmail",((e,t)=>{ri.init(e,t),Va.init(e,t)}));const Na=cr("ZodGUID",((e,t)=>{ti.init(e,t),Va.init(e,t)}));const Pa=cr("ZodUUID",((e,t)=>{ni.init(e,t),Va.init(e,t)}));const Ca=cr("ZodURL",((e,t)=>{oi.init(e,t),Va.init(e,t)}));const Fa=cr("ZodEmoji",((e,t)=>{ii.init(e,t),Va.init(e,t)}));const Ga=cr("ZodNanoID",((e,t)=>{si.init(e,t),Va.init(e,t)}));const Ma=cr("ZodCUID",((e,t)=>{ai.init(e,t),Va.init(e,t)}));const Ua=cr("ZodCUID2",((e,t)=>{ci.init(e,t),Va.init(e,t)}));const La=cr("ZodULID",((e,t)=>{ui.init(e,t),Va.init(e,t)}));const ja=cr("ZodXID",((e,t)=>{li.init(e,t),Va.init(e,t)}));const Za=cr("ZodKSUID",((e,t)=>{fi.init(e,t),Va.init(e,t)}));const qa=cr("ZodIPv4",((e,t)=>{gi.init(e,t),Va.init(e,t)}));const Ha=cr("ZodIPv6",((e,t)=>{yi.init(e,t),Va.init(e,t)}));const Wa=cr("ZodCIDRv4",((e,t)=>{wi.init(e,t),Va.init(e,t)}));const Ja=cr("ZodCIDRv6",((e,t)=>{bi.init(e,t),Va.init(e,t)}));const Ka=cr("ZodBase64",((e,t)=>{Bi.init(e,t),Va.init(e,t)}));const Xa=cr("ZodBase64URL",((e,t)=>{Ei.init(e,t),Va.init(e,t)}));const Ya=cr("ZodE164",((e,t)=>{xi.init(e,t),Va.init(e,t)}));const Qa=cr("ZodJWT",((e,t)=>{Ti.init(e,t),Va.init(e,t)}));const ec=cr("ZodNumber",((e,t)=>{Ri.init(e,t),Oa.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ps(e,t,n),Sa(e,"ZodNumber",{gt(e,t){return this.check(Bs(e,t))},gte(e,t){return this.check(Es(e,t))},min(e,t){return this.check(Es(e,t))},lt(e,t){return this.check(bs(e,t))},lte(e,t){return this.check(vs(e,t))},max(e,t){return this.check(vs(e,t))},int(e){return this.check(rc(e))},safe(e){return this.check(rc(e))},positive(e){return this.check(Bs(0,e))},nonnegative(e){return this.check(Es(0,e))},negative(e){return this.check(bs(0,e))},nonpositive(e){return this.check(vs(0,e))},multipleOf(e,t){return this.check(xs(e,t))},step(e,t){return this.check(xs(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 tc(e){return function(e,t){return new e({type:"number",checks:[],...oo(t)})}(ec,e)}const nc=cr("ZodNumberFormat",((e,t)=>{zi.init(e,t),ec.init(e,t)}));function rc(e){return function(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...oo(t)})}(nc,e)}const oc=cr("ZodBoolean",((e,t)=>{Ai.init(e,t),Oa.init(e,t),e._zod.processJSONSchema=(e,t,n)=>Cs(0,0,t)}));function ic(e){return function(e,t){return new e({type:"boolean",...oo(t)})}(oc,e)}const sc=cr("ZodBigInt",((e,t)=>{ki.init(e,t),Oa.init(e,t),e._zod.processJSONSchema=(e,t,n)=>Fs(0,e),e.gte=(t,n)=>e.check(Es(t,n)),e.min=(t,n)=>e.check(Es(t,n)),e.gt=(t,n)=>e.check(Bs(t,n)),e.gte=(t,n)=>e.check(Es(t,n)),e.min=(t,n)=>e.check(Es(t,n)),e.lt=(t,n)=>e.check(bs(t,n)),e.lte=(t,n)=>e.check(vs(t,n)),e.max=(t,n)=>e.check(vs(t,n)),e.positive=t=>e.check(Bs(BigInt(0),t)),e.negative=t=>e.check(bs(BigInt(0),t)),e.nonpositive=t=>e.check(vs(BigInt(0),t)),e.nonnegative=t=>e.check(Es(BigInt(0),t)),e.multipleOf=(t,n)=>e.check(xs(t,n));const n=e._zod.bag;e.minValue=n.minimum??null,e.maxValue=n.maximum??null,e.format=n.format??null}));function ac(e){return function(e,t){return new e({type:"bigint",...oo(t)})}(sc,e)}const cc=cr("ZodAny",((e,t)=>{Si.init(e,t),Oa.init(e,t),e._zod.processJSONSchema=(e,t,n)=>{}}));function uc(){return function(e){return new e({type:"any"})}(cc)}const lc=cr("ZodUnknown",((e,t)=>{Oi.init(e,t),Oa.init(e,t),e._zod.processJSONSchema=(e,t,n)=>{}}));function fc(){return function(e){return new e({type:"unknown"})}(lc)}const hc=cr("ZodNever",((e,t)=>{$i.init(e,t),Oa.init(e,t),e._zod.processJSONSchema=(e,t,n)=>Gs(0,0,t)}));function dc(e){return function(e,t){return new e({type:"never",...oo(t)})}(hc,e)}const pc=cr("ZodArray",((e,t)=>{_i.init(e,t),Oa.init(e,t),e._zod.processJSONSchema=(t,n,r)=>qs(e,t,n,r),e.element=t.element,Sa(e,"ZodArray",{min(e,t){return this.check(Rs(e,t))},nonempty(e){return this.check(Rs(1,e))},max(e,t){return this.check(Ts(e,t))},length(e,t){return this.check(zs(e,t))},unwrap(){return this.element}})}));function mc(e,t){return function(e,t,n){return new e({type:"array",element:t,...oo(n)})}(pc,e,t)}const gc=cr("ZodObject",((e,t)=>{Ci.init(e,t),Oa.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Hs(e,t,n,r),qr(e,"shape",(()=>t.shape)),Sa(e,"ZodObject",{keyof(){return zc(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:fc()})},loose(){return this.clone({...this._zod.def,catchall:fc()})},strict(){return this.clone({...this._zod.def,catchall:dc()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return function(e,t){if(!Qr(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=Wr(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return Hr(this,"shape",n),n}});return ro(e,r)}(this,e)},safeExtend(e){return function(e,t){if(!Qr(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=Wr(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return Hr(this,"shape",n),n}});return ro(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=Wr(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t._zod.def.shape};return Hr(this,"shape",n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return ro(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 ro(e,Wr(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 Hr(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=Wr(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 Hr(this,"shape",r),r},checks:[]});return ro(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=Wr(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 Hr(this,"shape",o),o},checks:[]});return ro(t,o)}(Oc,this,e[0])},required(...e){return function(e,t,n){const r=Wr(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 Hr(this,"shape",o),o}});return ro(t,r)}(Pc,this,e[0])}})}));function yc(e,t){const n={type:"object",shape:e??{},...oo(t)};return new gc(n)}const wc=cr("ZodUnion",((e,t)=>{Gi.init(e,t),Oa.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ws(e,t,n,r),e.options=t.options}));function bc(e,t){return new wc({type:"union",options:e,...oo(t)})}const vc=cr("ZodIntersection",((e,t)=>{Mi.init(e,t),Oa.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Js(e,t,n,r)}));const Bc=cr("ZodTuple",((e,t)=>{ji.init(e,t),Oa.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ks(e,t,n,r),e.rest=t=>e.clone({...e._zod.def,rest:t})}));function Ec(e,t,n){const r=t instanceof Yo;return new Bc({type:"tuple",items:e,rest:r?t:null,...oo(r?n:t)})}const xc=cr("ZodRecord",((e,t)=>{Wi.init(e,t),Oa.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Xs(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType}));function Tc(e,t,n){return t&&t._zod?new xc({type:"record",keyType:e,valueType:t,...oo(n)}):new xc({type:"record",keyType:_a(),valueType:e,...oo(t)})}const Rc=cr("ZodEnum",((e,t)=>{Ji.init(e,t),Oa.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ms(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 Rc({...t,checks:[],...oo(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 Rc({...t,checks:[],...oo(r),entries:o})}}));function zc(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map((e=>[e,e]))):e;return new Rc({type:"enum",entries:n,...oo(t)})}const Ac=cr("ZodLiteral",((e,t)=>{Ki.init(e,t),Oa.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Us(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 kc=cr("ZodTransform",((e,t)=>{Xi.init(e,t),Oa.init(e,t),e._zod.processJSONSchema=(e,t,n)=>Zs(0,e),e._zod.parse=(n,r)=>{if("backward"===r.direction)throw new lr(e.constructor.name);n.addIssue=r=>{if("string"==typeof r)n.issues.push(ho(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(ho(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 Sc(e){return new kc({type:"transform",transform:e})}const Oc=cr("ZodOptional",((e,t)=>{Qi.init(e,t),Oa.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ia(e,t,0,r),e.unwrap=()=>e._zod.def.innerType}));function $c(e){return new Oc({type:"optional",innerType:e})}const Ic=cr("ZodExactOptional",((e,t)=>{es.init(e,t),Oa.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ia(e,t,0,r),e.unwrap=()=>e._zod.def.innerType}));const _c=cr("ZodNullable",((e,t)=>{ts.init(e,t),Oa.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ys(e,t,n,r),e.unwrap=()=>e._zod.def.innerType}));function Vc(e){return new _c({type:"nullable",innerType:e})}const Dc=cr("ZodDefault",((e,t)=>{ns.init(e,t),Oa.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ea(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap}));const Nc=cr("ZodPrefault",((e,t)=>{os.init(e,t),Oa.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ta(e,t,n,r),e.unwrap=()=>e._zod.def.innerType}));const Pc=cr("ZodNonOptional",((e,t)=>{is.init(e,t),Oa.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Qs(e,t,0,r),e.unwrap=()=>e._zod.def.innerType}));const Cc=cr("ZodCatch",((e,t)=>{as.init(e,t),Oa.init(e,t),e._zod.processJSONSchema=(t,n,r)=>na(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap}));const Fc=cr("ZodPipe",((e,t)=>{cs.init(e,t),Oa.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ra(e,t,0,r),e.in=t.in,e.out=t.out}));function Gc(e,t){return new Fc({type:"pipe",in:e,out:t})}const Mc=cr("ZodReadonly",((e,t)=>{ls.init(e,t),Oa.init(e,t),e._zod.processJSONSchema=(t,n,r)=>oa(e,t,n,r),e.unwrap=()=>e._zod.def.innerType}));const Uc=cr("ZodFunction",((e,t)=>{hs.init(e,t),Oa.init(e,t),e._zod.processJSONSchema=(e,t,n)=>js(0,e)}));const Lc=cr("ZodCustom",((e,t)=>{ds.init(e,t),Oa.init(e,t),e._zod.processJSONSchema=(e,t,n)=>Ls(0,e)}));const jc=yc({issuer:_a().transform((e=>wt(e))),index:_a().transform((e=>wt(e))),timestamp:_a().transform((e=>wt(e))),signature:_a().transform((e=>wt(e)))});var Zc=n(878);const qc=n.n(Zc)()("bee-js:http"),Hc={headers:{accept:"application/json, text/plain, */*"}};async function Wc(e,n){const r=n.data,o=t.Rb.deepMerge3(Hc,{...n,data:void 0},e);if(o.data=r,e.signal&&(o.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}}}(o),o.params)for(const t of Object.keys(o.params))void 0===o.params[t]&&delete o.params[t];const i=function(e){let n=t.DH.joinUrl([e.baseURL??"",e.url??""]);if(e.params){const t=new URLSearchParams(Object.entries(e.params).filter((([,e])=>void 0!==e)).map((([e,t])=>[e,String(t)]))).toString();t&&(n+=`?${t}`)}return n}(o),s=(o.method||"GET").toUpperCase();o.method=s,e.onRequest?.({method:s,url:t.DH.joinUrl([o.baseURL??"",o.url??""]),headers:{...o.headers},params:o.params});let a=0;for(;a<1e5;)try{qc(`${s} ${i}`,{headers:o.headers,params:o.params});const e=await fetch(i,o);return e.ok||await Jc(s,i,e,o.responseType),Xc(e,o.responseType)}catch(c){if(c instanceof nu)throw c;const n=c;if("TimeoutError"!==n.name||!e.endlesslyRetry)throw Kc(n,s,i);a++,await t.iQ.sleepMillis(a<300?200:1e3)}throw Error("Max number of failed attempts reached")}async function Jc(e,t,n,r){const o=await Xc(n,r).catch((()=>({data:void 0}))),i="string"==typeof o.data?o.data:JSON.stringify(o.data),s=i&&"undefined"!==i?`${n.statusText}: ${i}`:n.statusText;throw new nu(e,t,s,o.data,n.status,n.statusText)}function Kc(e,t,n){if("AbortError"===e.name)return new nu(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 nu(t,n,o)}async function Xc(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 Yc=yc({durationSeconds:tc()});const Qc=yc({reference:_a().transform((e=>new rn(e)))});class eu extends Error{constructor(e){super(e)}}class tu extends eu{constructor(e,t){super(e),this.value=t}}class nu extends eu{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.response={status:o,data:r,statusText:i}}}class ru{static ZERO=new ru(0);constructor(e){this.seconds=Math.ceil(e),e<0&&(this.seconds=0)}static fromMilliseconds(e){return new ru(e/1e3)}static fromSeconds(e){return new ru(e)}static fromHours(e){return new ru(60*e*60)}static fromDays(e){return new ru(24*e*60*60)}static fromWeeks(e){return new ru(7*e*24*60*60)}static fromYears(e){return new ru(365*e*24*60*60)}static fromEndDate(e,t){return new ru((e.getTime()-(t??new Date).getTime())/1e3)}static parseFromString(e){return ru.fromSeconds(t.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 t.AO.secondsToHumanTime(this.seconds)}isZero(){return 0===this.seconds}}class ou{constructor(e){if(this.bytes=Math.ceil(e),e<0)throw Error("Size must be at least 0")}static fromBytes(e){return new ou(e)}static fromKilobytes(e){return new ou(1e3*e)}static fromMegabytes(e){return new ou(1e3*e*1e3)}static fromGigabytes(e){return new ou(1e3*e*1e3*1e3)}static parseFromString(e){return ou.fromBytes(t.FQ.makeStorage(e,1e3))}toBytes(){return this.bytes}toGigabytes(){return this.bytes/1e3/1e3/1e3}toFormattedString(){return t.FQ.convertBytes(this.bytes,1e3)}represent(){return this.toFormattedString()}}class iu{static DIGITS=16;constructor(e){this.state=e}static fromDecimalString(e){return new iu(t.ie.fromDecimalString(e,iu.DIGITS))}static fromPLUR(e){return new iu(new t.ie(e,iu.DIGITS))}static fromFloat(e){return new iu(t.ie.fromFloat(e,iu.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 iu(this.state.add(e instanceof iu?e.state:new t.ie(e,iu.DIGITS)))}minus(e){return new iu(this.state.subtract(e instanceof iu?e.state:new t.ie(e,iu.DIGITS)))}divide(e){return new iu(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 su.fromWei(this.state.exchange("*",new t.ie(e.toWeiBigInt(),su.DIGITS),su.DIGITS).value)}}class su{static DIGITS=18;constructor(e){this.state=e}static fromDecimalString(e){return new su(t.ie.fromDecimalString(e,su.DIGITS))}static fromWei(e){return new su(new t.ie(e,su.DIGITS))}static fromFloat(e){return new su(t.ie.fromFloat(e,su.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 su(this.state.add(e instanceof su?e.state:new t.ie(e,su.DIGITS)))}minus(e){return new su(this.state.subtract(e instanceof su?e.state:new t.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)}exchangeToBZZ(e){return iu.fromPLUR(this.state.exchange("/",new t.ie(e.toWeiBigInt(),su.DIGITS),iu.DIGITS).value)}}var au=n(320);function cu(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 uu(e){return function(e,t){return new e({type:"number",coerce:!0,checks:[],...oo(t)})}(ec,e)}let lu=function(e){return e.FULL="full",e.LIGHT="light",e.ULTRA_LIGHT="ultra-light",e.DEV="dev",e}({});function fu(e){switch(e){case"full":return lu.FULL;case"light":return lu.LIGHT;case"ultra-light":return lu.ULTRA_LIGHT;case"dev":return lu.DEV;default:throw new Error(`Unknown Bee mode: ${e}`)}}const hu=32,du=128,pu=hu*du,mu=4,gu=17,yu=255,wu=1,bu=1e3;let vu=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}({}),Bu=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 Eu={ENCRYPTION_OFF:{[vu.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%"}],[vu.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%"}],[vu.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%"}],[vu.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%"}],[vu.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:{[vu.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%"}],[vu.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%"}],[vu.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%"}],[vu.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%"}],[vu.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%"}]}},xu=(_a().regex(/^(?:0x)?[0-9a-fA-F]*$/i,"expected hex string").refine((e=>e.replace(/^0x/i,"").length%2==0),"expected even-length hex string"),uc().refine((e=>{return new Uc({type:"function",input:Array.isArray(t?.input)?Ec(t?.input):t?.input??mc(fc()),output:t?.output??fc()}).safeParse(e).success;var t}),"expected a function")),Tu=uc().transform((e=>(ac().safeParse(e).success&&(e=String(e)),_a().regex(/^-?\d+$/,"expected integer string").parse(e)))),Ru=uc().transform((e=>(ac().safeParse(e).success&&(e=String(e)),_a().regex(/^\d+$/,"expected non-negative integer string").parse(e)))),zu=yc({baseURL:_a().optional(),timeout:tc().int().min(0).optional(),headers:Tc(_a(),_a()).optional(),onRequest:xu.optional(),httpAgent:fc().optional(),httpsAgent:fc().optional(),endlesslyRetry:ic().optional(),signal:uc().optional()}),Au=yc({redundancyStrategy:tc().int().optional(),fallback:ic().optional(),timeoutMs:tc().int().min(0).optional(),actPublisher:$c(uc().transform((e=>new Kt(e)))),actHistoryAddress:$c(uc().transform((e=>new rn(e)))),actTimestamp:uu().optional()}),ku=yc({act:ic().optional(),actHistoryAddress:$c(uc().transform((e=>new rn(e)))),deferred:ic().optional(),encrypt:ic().optional(),pin:ic().optional(),tag:tc().int().min(0).optional()}),Su=ku.extend({redundancyLevel:tc().int().min(0).optional()}),Ou=ku.extend({size:tc().int().min(0).optional(),contentType:_a().optional(),redundancyLevel:tc().int().min(0).optional()}),$u=ku.extend({errorDocument:_a().optional(),indexDocument:_a().optional(),redundancyLevel:tc().int().min(0).optional()}),Iu=yc({uid:tc().int()}),_u=uu().min(0),Vu=yc({onMessage:xu,onError:xu,onClose:xu}),Du=yc({onMessage:xu,onError:xu,onClose:xu}),Nu=yc({gasPrice:Tu.optional(),immutableFlag:ic().optional(),label:_a().optional(),waitForUsable:ic().optional(),waitForUsableTimeout:tc().int().min(0).optional()}),Pu=yc({gasLimit:Ru.optional(),gasPrice:Ru.optional()}),Cu=yc({limit:tc().int().min(wu).max(bu).optional(),offset:tc().int().min(0).optional()});function Fu(e){return void 0!==au.Readable&&e instanceof au.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 Mu(e){if(!("string"==typeof e||e instanceof Uint8Array||e instanceof Blob||Fu(e)))throw new TypeError("Data must be either string, Uint8Array, Blob or Readable!")}function Uu(e){if(null==e)throw new TypeError(`Expected number | Tag | string from tagUid, got: ${e}`);if(t=e,Iu.safeParse(t).success)return e.uid;if("number"==typeof e||"string"==typeof e)return _u.parse(e);var t;throw new TypeError(`Expected number | Tag | string from tagUid, got: ${e}`)}function Lu(e,t){return iu.fromPLUR(2n**BigInt(e)*BigInt(t))}function ju(e,t,n){const r=BigInt(Gu(e));return ru.fromSeconds(Number(r*BigInt(n)/BigInt(t)))}function Zu(e,t,n){return BigInt(e.toSeconds())/BigInt(n)*BigInt(t)+1n}function qu(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 Hu(e){return ir(e)}function Wu(e,t,n){const r=function(e){return Number.isInteger(e)?e<1?1:e>3155695200?3155695200:e:1}(e.batchTTL),o=ru.fromSeconds(r),i=rr(e.depth,t,n),s=e.utilizationRatio??Kn(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:Gu(e.amount),bucketDepth:e.bucketDepth,blockNumber:e.blockNumber,immutableFlag:e.immutableFlag,usage:s,usageText:`${Math.round(100*s)}%`,size:ou.fromBytes(i),remainingSize:ou.fromBytes(Math.ceil(i*(1-s))),theoreticalSize:ou.fromBytes(Xn(e.depth)),duration:o,calculateSize(t,n){const r=rr(e.depth,t,n);return ou.fromBytes(r)},calculateRemainingSize(t,n){const r=rr(e.depth,t,n);return ou.fromBytes(Math.ceil(r*(1-this.usage)))}}}function Ju(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 Ku(e){return{name:function(e){if(!e)throw new eu("missing content-disposition header");const t=e.match(/filename\*?=['"]?(?:UTF-\d['"]*)?([^;\r\n"']*)['"]?;?/i);if(t&&t.length>0)return t[1];throw new eu("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 Xu(e,t){const n={};if(!function(e){if(!yc({}).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"]=Hu(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=ic().safeParse(r.act);o.success&&(n["swarm-act"]=String(o.data));const i=ic().safeParse(r.pin);i.success&&(n["swarm-pin"]=String(i.data));const s=ic().safeParse(r.encrypt);s.success&&(n["swarm-encrypt"]=String(s.data)),r.tag&&(n["swarm-tag"]=String(r.tag));const a=ic().safeParse(r.deferred);a.success&&(n["swarm-deferred-upload"]=String(a.data)),r.redundancyStrategy&&(n["swarm-redundancy-strategy"]=String(r.redundancyStrategy));const c=ic().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 rn(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 Yu="chunks";async function Qu(e,t,n){t=new rn(t);const r=await Wc(e,{responseType:"arraybuffer",url:`${Yu}/${t}`,headers:Xu(null,n)});return new Uint8Array(r.data)}function el(e,t){try{return Tn(e,t)}catch(n){throw new eu(n.message)}}async function tl(e,n,r,o){const i=Pt.concat(n.span.toUint8Array(),n.payload.toUint8Array());return async function(e,n,r,o,i,s,a){const c=await Wc(e,{method:"post",url:`soc/${n}/${r}`,data:i,headers:{"content-type":"application/octet-stream",...Xu(s,a)},responseType:"json",params:{sig:o.toHex()}});return{reference:Qc.parse(c.data).reference,tagUid:c.headers["swarm-tag"]?Uu(c.headers["swarm-tag"]):void 0,historyAddress:c.headers["swarm-act-history-address"]?t.Xx.of(new rn(c.headers["swarm-act-history-address"])):t.Xx.empty()}}(e,n.owner,n.identifier,n.signature,i,r,o)}async function nl(e,t,n,r,o,i){t=new tn(t),r=new qt(r);return tl(e,Rn(o).toSingleOwnerChunk(r,t),n,i)}async function rl(e,t,n){const r=En(n=new qt(n),t=new Ut(t));return el(await Qu(e,r.toHex()),r)}const ol=yc({peer:_a(),balance:_a().transform((e=>iu.fromPLUR(Gu(e,{name:"balance"}))))}),il=yc({balances:mc(ol)}),sl=ol,al="balances";const cl="consumed";class ul{constructor(e){this.context=e}async getAll(e){return async function(e){const t=await Wc(e,{url:al,responseType:"json"});return il.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async getPeer(e,t){const n=new Ht(e);return async function(e,t){const n=await Wc(e,{url:`${al}/${t}`,responseType:"json"});return sl.parse(n.data)}(this.context.getRequestOptionsForCall(t),n)}async getAllPastDueConsumption(e){return async function(e){const t=await Wc(e,{url:cl,responseType:"json"});return il.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async getAllPastDueConsumptionForPeer(e,t){const n=new Ht(e);return async function(e,t){const n=await Wc(e,{url:`${cl}/${t}`,responseType:"json"});return sl.parse(n.data)}(this.context.getRequestOptionsForCall(t),n)}}const ll=yc({beneficiary:_a().transform((e=>new Ut(e))),chequebook:_a().transform((e=>new Ut(e))),payout:_a().transform((e=>iu.fromPLUR(Gu(e,{name:"payout"}))))}),fl=yc({recipient:_a(),lastPayout:_a().transform((e=>iu.fromPLUR(Gu(e,{name:"lastPayout"})))),bounced:ic()}),hl=yc({chequebookAddress:_a().transform((e=>new Ut(e)))}),dl=yc({availableBalance:_a().transform((e=>iu.fromPLUR(Gu(e,{name:"availableBalance"})))),totalBalance:_a().transform((e=>iu.fromPLUR(Gu(e,{name:"totalBalance"}))))}),pl=yc({peer:_a(),uncashedAmount:_a().transform((e=>iu.fromPLUR(Gu(e,{name:"uncashedAmount"})))),transactionHash:_a().nullish().transform((e=>e??null)),lastCashedCheque:ll.nullish().transform((e=>e??null)),result:fl.nullish().transform((e=>e??null))}),ml=yc({peer:_a(),lastreceived:ll.nullish().transform((e=>e??null)),lastsent:ll.nullish().transform((e=>e??null))}),gl=yc({lastcheques:mc(yc({peer:_a(),lastreceived:ll.nullish().transform((e=>e??null)),lastsent:ll.nullish().transform((e=>e??null))}))}),yl=yc({transactionHash:_a().transform((e=>new cn(e)))}),wl="chequebook";class bl{constructor(e){this.context=e}async getAllLatest(e){return async function(e){const t=await Wc(e,{url:`${wl}/cheque`,responseType:"json"});return gl.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async getAllLatestForPeer(e,t){const n=new Ht(e);return async function(e,t){const n=await Wc(e,{url:`${wl}/cheque/${t}`,responseType:"json"});return ml.parse(n.data)}(this.context.getRequestOptionsForCall(t),n)}async getLastCashoutAction(e,t){const n=new Ht(e);return async function(e,t){const n=await Wc(e,{url:`${wl}/cashout/${t}`,responseType:"json"});return pl.parse(n.data)}(this.context.getRequestOptionsForCall(t),n)}async cashoutLast(e,t,n){const r=new Ht(e);return t&&(t=Pu.parse(t)),async function(e,t,n){const r=await Wc(e,{method:"post",url:`${wl}/cashout/${t}`,responseType:"json",headers:Xu(null,n)});return yl.parse(r.data).transactionHash}(this.context.getRequestOptionsForCall(n),r,t)}}class vl{constructor(e){this.context=e}async getAddress(e){return async function(e){const t=await Wc(e,{url:`${wl}/address`,responseType:"json"});return hl.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async getBalance(e){return async function(e){const t=await Wc(e,{url:`${wl}/balance`,responseType:"json"});return dl.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async deposit(e,t,n){const r=e instanceof iu?e.toPLURString():Gu(e,{min:1n,name:"amount"}),o=t?Gu(e,{min:0n,name:"gasPrice"}):void 0;return async function(e,t,n){const r={};n&&(r["gas-price"]=n);const o=await Wc(e,{method:"post",url:`${wl}/deposit`,responseType:"json",params:{amount:t},headers:r});return yl.parse(o.data).transactionHash}(this.context.getRequestOptionsForCall(n),r,o)}async withdraw(e,t,n){const r=e instanceof iu?e.toPLURString():Gu(e,{min:1n,name:"amount"}),o=t?Gu(e,{min:0n,name:"gasPrice"}):void 0;return async function(e,t,n){const r={};n&&(r["gas-price"]=n);const o=await Wc(e,{method:"post",url:`${wl}/withdraw`,responseType:"json",params:{amount:t},headers:r});return yl.parse(o.data).transactionHash}(this.context.getRequestOptionsForCall(n),r,o)}}class Bl{constructor(e){this.context=e}async upload(e,n,r,o){const i="identifier"in n&&"signature"in n&&"owner"in n;if(n=n instanceof Uint8Array?n:n.data,r&&(r=ku.parse(r)),n.length<on.LENGTH)throw new tu(`Chunk has to have size of at least ${on.LENGTH}.`,n);if(!i&&n.length>pu+on.LENGTH)throw new tu(`Content Addressed Chunk must not exceed ${pu+on.LENGTH} bytes.`,n);if(i&&n.length>pu+on.LENGTH+en.LENGTH+qt.LENGTH)throw new tu(`Single Owner Chunk must not exceed ${pu+on.LENGTH+en.LENGTH+qt.LENGTH} bytes.`,n);return async function(e,n,r,o){const i=await Wc(e,{method:"post",url:`${Yu}`,data:n,headers:{"content-type":"application/octet-stream",...Xu(r,o)},responseType:"json"});return{reference:Qc.parse(i.data).reference,tagUid:i.headers["swarm-tag"]?Uu(i.headers["swarm-tag"]):void 0,historyAddress:i.headers["swarm-act-history-address"]?t.Xx.of(new rn(i.headers["swarm-act-history-address"])):t.Xx.empty()}}(this.context.getRequestOptionsForCall(o),n,e,r)}async download(e,t,n){const r=new rn(e);return t&&(t=Au.parse(t)),Qu(this.context.getRequestOptionsForCall(n),r,t)}}var El=n(497),xl=n.n(El);async function Tl(e,t,n,r,o){for(const s of e.forks.values()){const e=await Tl(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 Rl(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(),a=qn.unmarshalFromData(s,o.node.selfAddress);o.node.targetAddress=a.targetAddress,o.node.forks=a.forks,o.node.path=o.prefix,o.node.parent=e,await Rl(o.node,t,n,r)}}class zl{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?t.Xx.of(e.metadata):t.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,n){const r=this.core.find("/");if(!r||!r.metadata)return t.Xx.empty();const o=r.metadata["swarm-feed-owner"],i=r.metadata["swarm-feed-topic"];return o&&i?t.Xx.of(await e.feed.fetchLatestUpdate(i,o,n)):t.Xx.empty()}async marshal(){return this.core.marshal()}static async unmarshal(e,t,n,r){t=new rn(t);const o=(await e.data.download(t,n,r)).toUint8Array();return this.unmarshalFromData(o,t.toUint8Array())}static unmarshalFromData(e,t){return new zl(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 Tl(this.core,e,t,n,r)}async loadRecursively(e,t,n){return Rl(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 Al=n(61),kl=n.n(Al);async function Sl(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 Ol(e,"")}async function Ol(e,t){const n=kl().join(e,t),r=await xl().promises.opendir(n);let o=[];for await(const i of r){const n=kl().join(e,t,i.name),r=kl().join(t,i.name);i.isFile()?o.push({path:r,size:(await xl().promises.stat(n)).size,fsPath:n}):i.isDirectory()&&(o=[...await Ol(e,r),...o])}return o}async function $l(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 xl().promises.opendir(e);let n=0;for await(const r of t)if(r.isFile()){n+=(await xl().promises.stat(kl().join(e,r.name))).size}else r.isDirectory()&&(n+=await $l(kl().join(e,r.name)));return n}const Il={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 _l(e){return["text/html","text/css"].includes(e)?`${e}; charset=utf-8`:e}function Vl(e){if(!function(e){return!!Array.isArray(e)&&e.every((e=>"object"==typeof e&&e.path&&void 0!==e.size))}(e))throw new tu("invalid collection",e)}function Dl(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 Nl(e){return Array.from(e).map((e=>({path:Dl(e),size:e.size,file:e})))}function Pl(e){return Array.from(e).reduce(((e,t)=>e+t.size),0)}class Cl{output=new au.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 Fl(e,t,n,r){const o=new Cl,i=Wc(e,{method:"post",url:"bzz",data:o.output,responseType:"json",headers:{"content-type":"application/x-tar","swarm-collection":"true",...Xu(n,r)}});await async function(e,t){for(const n of e)if(t.beginFile(n.path,n.size),n.fsPath){const e=(0,El.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 Gl="bzz";async function Ml(e,n,r,o,i){Fu(n)&&!i?.contentType&&(i||(i={}),i.contentType="application/octet-stream");const s=await Wc(e,{method:"post",url:Gl,data:n,headers:Xu(r,i),params:{name:o},responseType:"json"});return{reference:Qc.parse(s.data).reference,tagUid:s.headers["swarm-tag"]?Uu(s.headers["swarm-tag"]):void 0,historyAddress:s.headers["swarm-act-history-address"]?t.Xx.of(new rn(s.headers["swarm-act-history-address"])):t.Xx.empty()}}async function Ul(e,n,r,o){Vl(n);const i=await Fl(e,n,r,o);return{reference:Qc.parse(i.data).reference,tagUid:i.headers["swarm-tag"]?Uu(i.headers["swarm-tag"]):void 0,historyAddress:i.headers["swarm-act-history-address"]?t.Xx.of(new rn(i.headers["swarm-act-history-address"])):t.Xx.empty()}}class Ll{constructor(e){this.context=e}async upload(e,t,n,r){const o=new Ct(e);return Vl(t),n&&(n=$u.parse(n)),Ul(this.context.getRequestOptionsForCall(r),t,o,n)}async uploadFromFileList(e,t,n,r){const o=new Ct(e);n&&(n=$u.parse(n));const i=Nl(t);return Ul(this.context.getRequestOptionsForCall(r),i,o,n)}async uploadFromDirectory(e,t,n,r){const o=new Ct(e);n&&(n=$u.parse(n));const i=await Sl(t);return Ul(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,n,r,o,i){const s=new Ct(e);return async function(e,n,r,o,i,s){const a=new t.O3(64,64);let c=0,u=0;r=new Ct(r);const l=await Sl(n);for(const t of l)c+=(f=t.size,function e(t){return t<=1?t:t+e(Math.ceil(t/128))}(Math.ceil(f/4096)));var f;let h=!1;async function d(t){await e.chunk.upload(r,t.build(),i,s),o?.({total:c,processed:++u})}async function p(e){for(const{chunk:t}of e)await a.enqueue((async()=>d(t)));return[]}const m=new zl;for(const g of l){if(!g.fsPath)throw Error("File does not have fsPath, which should never happen in node. Please report this issue.");const e=(0,El.createReadStream)(g.fsPath),n=new kn(p);for await(const t of e)await n.append(t);const r=await n.finalize();await a.enqueue((async()=>d(r))),await a.drain();const{filename:o,extension:i}=t.DH.parseFilename(g.path);m.addFork(g.path,r.hash(),{"Content-Type":_l(Il[i.toLowerCase()]||"application/octet-stream"),Filename:o}),"index.html"===g.path&&(h=!0)}if(h||i?.indexDocument||i?.errorDocument){const e={};i?.indexDocument?e["website-index-document"]=i.indexDocument:h&&(e["website-index-document"]="index.html"),i?.errorDocument&&(e["website-error-document"]=i.errorDocument),m.addFork("/",Nh,e)}return m.saveRecursively(e,r,i,s)}(this.context.bee,n,s,r,o,this.context.getRequestOptionsForCall(i))}async hashDirectory(e){return async function(e){const n=await Sl(e),r=new zl;for(const o of n){const e=new kn(kn.NOOP);if(!o.fsPath)throw Error("File does not have fsPath, which should never happen in node. Please report this issue.");const n=(0,El.createReadStream)(o.fsPath);for await(const t of n)await e.append(t);const i=await e.finalize(),{filename:s,extension:a}=t.DH.parseFilename(o.path);r.addFork(o.path,i.hash(),{"Content-Type":_l(Il[a.toLowerCase()]||"application/octet-stream"),Filename:s})}return r.calculateSelfAddress()}(e)}}const jl=yc({address:_a(),fullNode:ic()}),Zl=yc({population:tc(),connected:tc(),connectedPeers:mc(yc({address:_a()})).nullish().transform((e=>e??[])),disconnectedPeers:mc(yc({address:_a()})).nullish().transform((e=>e??[]))}),ql=Tc(_a(),Zl),Hl=yc({overlay:_a().transform((e=>new Ht(e))),underlay:mc(_a()),ethereum:_a().transform((e=>new Ut(e))),publicKey:_a().transform((e=>new Kt(e))),pssPublicKey:_a().transform((e=>new Kt(e)))}),Wl=yc({peers:mc(jl)}),Jl=yc({peers:mc(jl)}),Kl=yc({baseAddr:_a(),population:tc(),connected:tc(),timestamp:_a(),nnLowWatermark:tc(),depth:tc(),reachability:_a(),networkAvailability:_a(),bins:ql}),Xl=yc({overlay:_a(),proximity:tc(),beeMode:_a().transform(fu),reserveSize:tc(),reserveSizeWithinRadius:tc(),pullsyncRate:tc(),storageRadius:tc(),connectedPeers:tc(),neighborhoodSize:tc(),batchCommitment:tc(),isReachable:ic(),lastSyncedBlock:tc(),committedDepth:tc(),isWarmingUp:ic()}),Yl=yc({apiVersion:_a(),version:_a(),status:(Ql="ok",new Ac({type:"literal",values:Array.isArray(Ql)?Ql:[Ql],...oo(ef)}))});var Ql,ef;const tf=yc({apiVersion:_a(),version:_a(),status:zc(["ready","notReady"])}),nf=yc({beeMode:_a().transform(fu),chequebookEnabled:ic(),swapEnabled:ic()}),rf=yc({gateway:ic()}),of="peers";class sf{constructor(e){this.context=e}async checkConnection(e){return async function(e){await Wc(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 Wc(e,{url:"/gateway"});return rf.parse(t.data).gateway}(this.context.getRequestOptionsForCall(e))}catch{return!1}}async getNodeAddresses(e){return async function(e){const t=await Wc(e,{url:"addresses",responseType:"json"});return Hl.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async getBlocklist(e){return async function(e){const t=await Wc(e,{url:"blocklist",responseType:"json"});return Jl.parse(t.data).peers}(this.context.getRequestOptionsForCall(e))}async getPeers(e){return async function(e){const t=await Wc(e,{url:of,responseType:"json"});return Wl.parse(t.data).peers}(this.context.getRequestOptionsForCall(e))}async removePeer(e,t){const n=new Ht(e);return async function(e,t){return(await Wc(e,{url:`${of}/${t}`,responseType:"json",method:"DELETE"})).data}(this.context.getRequestOptionsForCall(t),n)}async getTopology(e){return async function(e){const t=await Wc(e,{url:"topology",responseType:"json"});return Kl.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async ping(e,t){const n=new Ht(e);return async function(e,t){return(await Wc(e,{url:`pingpong/${t}`,responseType:"json",method:"POST"})).data}(this.context.getRequestOptionsForCall(t),n)}}const af="bytes";async function cf(e,n,r,o){const i=await Wc(e,{url:af,method:"post",responseType:"json",data:n,headers:{"content-type":"application/octet-stream",...Xu(r,o)}});return{reference:Qc.parse(i.data).reference,tagUid:i.headers["swarm-tag"]?Uu(i.headers["swarm-tag"]):void 0,historyAddress:i.headers["swarm-act-history-address"]?t.Xx.of(new rn(i.headers["swarm-act-history-address"])):t.Xx.empty()}}async function uf(e,t,n){n&&(n=Au.parse(n));const r=await Wc(e,{responseType:"arraybuffer",url:`${af}/${t}`,headers:Xu(null,n)});return new Pt(r.data)}const lf=yc({isRetrievable:ic()}),ff="stewardship";class hf{constructor(e){this.raw=e}toString(){const e=_a().safeParse(this.raw);return e.success&&e.data.includes(".eth")?e.data:new rn(this.raw).toHex()}}class df{constructor(e){this.context=e}async upload(e,t,n,r){const o=new Ct(e);return Mu(t),n&&(n=Su.parse(n)),cf(this.context.getRequestOptionsForCall(r),t,o,n)}async download(e,t,n){return t&&(t=Au.parse(t)),uf(this.context.getRequestOptionsForCall(n),new hf(e),t)}async downloadReadable(e,t,n){return t&&(t=Au.parse(t)),async function(e,t,n){return n&&(n=Au.parse(n)),(await Wc(e,{responseType:"stream",url:`${af}/${t}`,headers:Xu(null,n)})).data}(this.context.getRequestOptionsForCall(n),new hf(e),t)}async probe(e,t){const n=new rn(e);return async function(e,t){const n=await Wc(e,{url:`${af}/${t}`,method:"head",responseType:"json"});return{contentLength:parseInt(n.headers["content-length"])}}(this.context.getRequestOptionsForCall(t),n)}async isRetrievable(e,t){const n=new rn(e);return async function(e,t){const n=await Wc(e,{method:"get",responseType:"json",url:`${ff}/${t}`});return lf.parse(n.data).isRetrievable}(this.context.getRequestOptionsForCall(t),n)}}const pf="feeds";function mf(e){const t=e["swarm-feed-index"],n=e["swarm-feed-index-next"];if(!t)throw new eu("Response did not contain expected swarm-feed-index!");if(!n)throw new eu("Response did not contain expected swarm-feed-index-next!");return{feedIndex:new jt(t),feedIndexNext:new jt(n)}}async function gf(e,t,n,r){const o=await Wc(e,{responseType:"arraybuffer",url:`${pf}/${t}/${n}`,params:{...r}});return{payload:new Pt(o.data),...mf(o.headers)}}function yf(e,t){return t="number"==typeof t?jt.fromBigInt(BigInt(t)):t,new qt($t(Pt.concat(e.toUint8Array(),t.toUint8Array())))}async function wf(e,t,n){try{const r=await gf(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 nu)return jt.fromBigInt(0n);throw r}}async function bf(e,t,n,r,o,i){const s=yf(n,i?.index??await wf(e,t.publicKey().address(),n));if(r.length>4096){const n=await cf(e,r,o,i);return async function(e,t,n,r,o,i){return t=new tn(t),r=new qt(r),tl(e,o.toSingleOwnerChunk(r,t),n,i)}(e,t,o,s,zn(await Qu(e,n.reference)),i)}const a=_a().safeParse(r);return nl(e,t,o,s,a.success?Pt.fromUtf8(a.data).toUint8Array():r,i)}function vf(e,t,n){const r=yf(t,n);return new rn($t(Pt.concat(r.toUint8Array(),e.toUint8Array())))}async function Bf(e,n,r,o,i=!1){const s=vf(n,r,o="number"==typeof o?jt.fromBigInt(BigInt(o)):o),a=el(await Qu(e,s.toHex()),s);let c=t.Xx.empty();if(i){const e=Pt.fromSlice(a.payload.toUint8Array(),0,8);c=t.Xx.of(Number(St(e.toUint8Array(),"BE")))}return{timestamp:c,payload:new Pt(a.payload.offset(i?8:0))}}async function Ef(e,t,n,r){const o=vf(t,n,r="number"==typeof r?jt.fromBigInt(BigInt(r)):r),i=el(await Qu(e,o),o);return Rn(i.payload,i.span)}function xf(e,t,n){const r=async r=>{if(void 0===r?.index)return gf(e,n,t);const o=await Bf(e,n,t,r.index,r.hasTimestamp??!0),i="number"==typeof r.index?jt.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 gf(e,n,t);const o=await Ef(e,n,t,r.index),i=o.span.toBigInt()<=4096n?o.payload:await uf(e,new hf(o.address)),s="number"==typeof r.index?jt.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 async function(e,t,n){return mf((await Wc(e,{responseType:"arraybuffer",url:`${pf}/${t}/${n}`,params:{"Swarm-Only-Root-Chunk":!0}})).headers)}(e,n,t)).feedIndex);const s=await r({...o,index:i});return{reference:new rn(s.payload.toUint8Array()),feedIndex:s.feedIndex,feedIndexNext:s.feedIndexNext??s.feedIndex.next()}},owner:n,topic:t}}function Tf(e,t,n){const r=async(r,o,i)=>async function(e,t,n,r,o,i){r=new rn(r);const s=yf(n,i?.index??await wf(e,t.publicKey().address(),n)),a=i?.at??Date.now()/1e3,c=kt(BigInt(Math.floor(a)),"BE");return nl(e,t,o,s,Pt.concat(c,r.toUint8Array()),i)}(e,n,t,o,r,i);return{...xf(e,t,n.publicKey().address()),upload:r,uploadReference:r,uploadPayload:async(r,o,i)=>bf(e,n,t,o,r,i)}}async function Rf(e,n,r,o,i,s){const a=function(e,t,n){const r=n.toBigInt(),o=[];for(let i=0n;i<=r;i++)o.push(vf(e,t,jt.fromBigInt(i)));return o}(n,r,o).map((async n=>async function(e,n,r,o){try{return await e.chunk.download(n,r,o),!0}catch(i){const e=t.Rb.getDeep(i,"status");if(404===e||500===e)return!1;throw i}}(e,n,i,s)));return(await Promise.all(a)).every((e=>e))}class zf{constructor(e){this.context=e}makeReader(e,t,n){return xf(this.context.getRequestOptionsForCall(n),new an(e),new Ut(t))}makeWriter(e,t,n){const r=t?new tn(t):this.context.signer;if(!r)throw Error("No signer provided");return Tf(this.context.getRequestOptionsForCall(n),new an(e),r)}async createManifest(e,t,n,r,o){const i=new Ct(e),s=new an(t),a=new Ut(n);return r&&(r=ku.parse(r)),async function(e,t,n,r,o){const i=await Wc(e,{method:"post",responseType:"json",url:`${pf}/${t}/${n}`,headers:Xu(r,o)});return Qc.parse(i.data).reference}(this.context.getRequestOptionsForCall(o),a,s,i,r)}async fetchLatestUpdate(e,t,n){return gf(this.context.getRequestOptionsForCall(n),new Ut(t),new an(e))}async isRetrievable(e,n,r,o,i){const s=new Ut(e),a=new an(n);if(o&&(o=Au.parse(o)),!r)try{return await this.makeReader(a,s,i).download(),!0}catch(c){const e=t.Rb.getDeep(c,"status");if(404===e||500===e)return!1;throw c}return Rf(this.context.bee,s,a,r,o,this.context.getRequestOptionsForCall(i))}}class Af{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||cu(e)||Fu(e)))throw new TypeError("Data must be either string, Readable, Uint8Array or File!")}(t),r&&(r=Ou.parse(r)),n&&"string"!=typeof n)throw new TypeError("name has to be string or undefined!");if(cu(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 Ml(this.context.getRequestOptionsForCall(o),e,i,s,c)}return Ml(this.context.getRequestOptionsForCall(o),t,i,n,r)}async download(e,t="",n,r){return n&&(n=Au.parse(n)),async function(e,t,n="",r){const o=await Wc(e,{method:"GET",responseType:"arraybuffer",url:`${Gl}/${t}/${n}`,headers:Xu(null,r)});return{...Ku(o.headers),data:new Pt(o.data)}}(this.context.getRequestOptionsForCall(r),new hf(e),t,n)}async downloadReadable(e,t="",n,r){const o=new rn(e);return n&&(n=Au.parse(n)),async function(e,t,n="",r){t=new rn(t);const o=await Wc(e,{method:"GET",responseType:"stream",url:`${Gl}/${t}/${n}`,headers:Xu(null,r)});return{...Ku(o.headers),data:o.data}}(this.context.getRequestOptionsForCall(r),o,t,n)}}const kf=mc(_a().transform((e=>new Kt(e)))),Sf=yc({ref:_a().transform((e=>new rn(e))),historyref:_a().transform((e=>new rn(e)))}),Of="grantee";class $f{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 Wc(e,{method:"post",url:Of,data:{grantees:n.map((e=>e.toCompressedHex()))},headers:Xu(t),responseType:"json"}),o=Sf.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 rn(e);return async function(e,t){const n=await Wc(e,{method:"get",url:`${Of}/${t}`,responseType:"json"});return{status:n.status,statusText:n.statusText,grantees:kf.parse(n.data)}}(this.context.getRequestOptionsForCall(t),n)}async patch(e,t,n,r,o){const i=new Ct(e),s=new rn(t),a=new rn(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 Wc(e,{method:"patch",url:`${Of}/${n}`,data:{add:o.add.map((e=>e.toCompressedHex())),revoke:o.revoke.map((e=>e.toCompressedHex()))},headers:{...Xu(t),"swarm-act-history-address":r.toHex()},responseType:"json"}),s=Sf.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 If=null;"undefined"!=typeof WebSocket?If=WebSocket:"undefined"!=typeof MozWebSocket?If=MozWebSocket:void 0!==n.g?If=n.g.WebSocket||n.g.MozWebSocket:"undefined"!=typeof window?If=window.WebSocket||window.MozWebSocket:"undefined"!=typeof self&&(If=self.WebSocket||self.MozWebSocket);const _f=If;async function Vf(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 Df{constructor(e){this.context=e}async pssSend(e,t,n,r,o,i){const s=new Ct(e);Mu(r);const a=o?new Kt(o):void 0;await async function(e,t,n,r,o,i){await Wc(e,{method:"post",url:`pss/send/${n}/${r}`,data:o,responseType:"json",params:{recipient:i},headers:Xu(t)})}(this.context.getRequestOptionsForCall(i),s,t,n,r,a)}pssSubscribe(e,t){t=Vu.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 Vf(e.data);n.length&&t.onMessage(new Pt(n),r)},n.onerror=e=>{this.isCancelled(n)||t.onError(new eu(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 eu("pssReceive timeout"))}),t))}))}gsocMine(e,n,r=12){const o=new Ht(e),i=new qt(n);for(let s=0n;s<0xffffn;s++){const e=new tn(gt(2867n+s,"BE")),n=En(i,e.publicKey().address());if(256-t.yI.proximity(n.toUint8Array(),o.toUint8Array())<=256-r)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 tn(t),c=new qt(n),u=Rn(r).toSingleOwnerChunk(c,a);return tl(this.context.getRequestOptionsForCall(i),u,s,o)}gsocSubscribe(e,t,n){const r=new Ut(e),o=new qt(t);n=Du.parse(n);const i=En(o,r),s=this.openWebSocket(`gsoc/subscribe/${i.toHex()}`),a={address:r,cancel:this.makeCancel(s)};return s.onmessage=async e=>{const t=await Vf(e.data);t.length&&n.onMessage(new Pt(t),a)},s.onerror=e=>{this.isCancelled(s)||n.onError(new eu(e.message),a)},s.onclose=()=>{n.onClose(a)},a}openWebSocket(e){const n=this.context.url.replace(/^http/i,"ws");return"browser"===t.iQ.whereAmI()?new _f(`${n}/${e}`):new _f(`${n}/${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 Nf=yc({references:mc(_a()).nullable()}),Pf="pins";class Cf{constructor(e){this.context=e}async add(e,t){const n=new rn(e);await async function(e,t){await Wc(e,{method:"post",responseType:"json",url:`${Pf}/${t}`})}(this.context.getRequestOptionsForCall(t),n)}async remove(e,t){const n=new rn(e);await async function(e,t){await Wc(e,{method:"delete",responseType:"json",url:`${Pf}/${t}`})}(this.context.getRequestOptionsForCall(t),n)}async getAll(e){return async function(e){const t=await Wc(e,{method:"get",responseType:"json",url:Pf}),{references:n}=Nf.parse(t.data);return(n??[]).map((e=>new rn(e)))}(this.context.getRequestOptionsForCall(e))}async get(e,t){const n=new rn(e);return async function(e,t){const n=await Wc(e,{method:"get",responseType:"json",url:`${Pf}/${t}`});return Qc.parse(n.data)}(this.context.getRequestOptionsForCall(t),n)}async reuploadData(e,t,n){const r=new Ct(e),o=new rn(t);await async function(e,t,n){await Wc(e,{method:"put",url:`${ff}/${n}`,headers:{"swarm-postage-batch-id":t.toHex()}})}(this.context.getRequestOptionsForCall(n),r,o)}}const Ff=yc({peer:_a(),sent:_a().transform((e=>iu.fromPLUR(Gu(e,{name:"sent"})))),received:_a().transform((e=>iu.fromPLUR(Gu(e,{name:"received"}))))}),Gf=Ff,Mf=yc({totalSent:_a().transform((e=>iu.fromPLUR(Gu(e,{name:"totalSent"})))),totalReceived:_a().transform((e=>iu.fromPLUR(Gu(e,{name:"totalReceived"})))),settlements:mc(Ff)}),Uf="settlements";class Lf{constructor(e){this.context=e}async get(e,t){const n=new Ht(e);return async function(e,t){const n=await Wc(e,{url:`${Uf}/${t}`,responseType:"json"});return Gf.parse(n.data)}(this.context.getRequestOptionsForCall(t),n)}async getAll(e){return async function(e){const t=await Wc(e,{url:Uf,responseType:"json"});return Mf.parse(t.data)}(this.context.getRequestOptionsForCall(e))}}class jf{constructor(e){this.context=e}makeReader(e,t){const n=new Ut(e);return{owner:n,download:rl.bind(null,this.context.getRequestOptionsForCall(t),n)}}makeWriter(e,t){const n=e?new tn(e):this.context.signer;if(!n)throw Error("No signer provided");return{...this.makeReader(n.publicKey().address(),t),upload:nl.bind(null,this.context.getRequestOptionsForCall(t),n)}}}const Zf=yc({stakedAmount:_a().transform((e=>iu.fromPLUR(Gu(e,{name:"stakedAmount"}))))}),qf=yc({withdrawableAmount:_a().transform((e=>iu.fromPLUR(Gu(e,{name:"withdrawableAmount"}))))}),Hf=yc({txHash:_a().transform((e=>new cn(e)))}),Wf=yc({minimumGasFunds:_a().transform((e=>su.fromWei(Gu(e,{name:"minimumGasFunds"})))),hasSufficientFunds:ic(),isFrozen:ic(),isFullySynced:ic(),phase:_a(),round:tc(),lastWonRound:tc(),lastPlayedRound:tc(),lastFrozenRound:tc(),lastSelectedRound:tc(),lastSampleDurationSeconds:tc(),block:tc(),reward:_a().transform((e=>iu.fromPLUR(Gu(e,{name:"reward"})))),fees:_a().transform((e=>su.fromWei(Gu(e,{name:"fees"})))),isHealthy:ic()}),Jf="stake";class Kf{constructor(e){this.context=e}async get(e){return async function(e){const t=await Wc(e,{method:"get",responseType:"json",url:Jf});return Zf.parse(t.data).stakedAmount}(this.context.getRequestOptionsForCall(e))}async getWithdrawable(e){return async function(e){const t=await Wc(e,{method:"get",responseType:"json",url:`${Jf}/withdrawable`});return qf.parse(t.data).withdrawableAmount}(this.context.getRequestOptionsForCall(e))}async deposit(e,t,n){const r=e instanceof iu?e.toPLURString():Gu(e,{min:1n,name:"amount"});return t&&(t=Pu.parse(t)),async function(e,t,n){const r=await Wc(e,{method:"post",responseType:"json",url:`${Jf}/${t}`,headers:Xu(null,n)});return Hf.parse(r.data).txHash}(this.context.getRequestOptionsForCall(n),r,t)}async withdrawSurplus(e){return async function(e){const t=await Wc(e,{method:"delete",responseType:"json",url:`${Jf}/withdrawable`});return Hf.parse(t.data).txHash}(this.context.getRequestOptionsForCall(e))}async migrate(e){return async function(e){const t=await Wc(e,{method:"delete",responseType:"json",url:Jf});return Hf.parse(t.data).txHash}(this.context.getRequestOptionsForCall(e))}async getRedistributionState(e){return async function(e){const t=await Wc(e,{method:"get",responseType:"json",url:"redistributionstate"});return Wf.parse(t.data)}(this.context.getRequestOptionsForCall(e))}}const Xf=yc({batchID:_a(),utilization:tc(),utilizationRatio:tc().optional(),usable:ic(),label:_a(),depth:tc(),amount:_a(),bucketDepth:tc(),blockNumber:tc(),immutableFlag:ic(),batchTTL:tc()}),Yf=yc({batchID:_a().transform((e=>new Ct(e))),batchTTL:tc(),bucketDepth:tc(),depth:tc(),immutable:ic(),owner:_a().transform((e=>new Ut(e))),start:tc(),value:_a().transform((e=>Gu(e,{name:"value"})))}),Qf=yc({batches:mc(Yf)}),eh=yc({stamps:mc(Xf)}),th=Xf,nh=yc({depth:tc(),bucketDepth:tc(),bucketUpperBound:tc(),buckets:mc(yc({bucketID:tc(),collisions:tc()}))}),rh=yc({batchID:_a().transform((e=>new Ct(e)))}),oh="stamps";const ih="batches";class sh{constructor(e){this.context=e}async create(e,t,n,r){const o=Gu(e,{min:0n,name:"amount"});if(n&&(n=Nu.parse(n)),t<gu||t>yu)throw new tu(`Depth has to be between ${gu}..${yu}`,t);const i=await this.context.bee.status.getChainState(),s=17280n*BigInt(i.currentPrice)+1n;if(BigInt(o)<s)throw new tu(`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 Wc(e,{method:"post",url:`${oh}/${t}/${n}`,responseType:"json",params:{label:r},headers:s});return rh.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 Wc(e,{method:"patch",url:`${oh}/${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:ju(i,r.currentPrice,o)}}async topUp(e,t,n){const r=new Ct(e),o=Gu(t,{min:1n,name:"amount"});return async function(e,t,n){const r=await Wc(e,{method:"patch",url:`${oh}/topup/${t}/${n}`,responseType:"json"});return rh.parse(r.data).batchID}(this.context.getRequestOptionsForCall(n),r,o)}async dilute(e,t,n){const r=new Ct(e),o=tc().int().min(18).max(255).parse(t);return async function(e,t,n){const r=await Wc(e,{method:"patch",url:`${oh}/dilute/${t}/${n}`,responseType:"json"});return rh.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 Wc(e,{method:"get",url:`${oh}/${t}`,responseType:"json"});return Wu(th.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 Wc(e,{method:"get",url:`${ih}/${t}`,responseType:"json"});return Yf.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 Wc(e,{method:"get",url:`${oh}/${t}/buckets`,responseType:"json"});return nh.parse(n.data)}(this.context.getRequestOptionsForCall(t),n)}async getAll(e){return async function(e){const t=await Wc(e,{method:"get",url:oh,responseType:"json"});return eh.parse(t.data).stamps.map((e=>Wu(e)))}(this.context.getRequestOptionsForCall(e))}async getAllGlobal(e){return async function(e){const t=await Wc(e,{method:"get",url:ih,responseType:"json"});return Qf.parse(t.data).batches}(this.context.getRequestOptionsForCall(e))}async waitForUsable(e,n=24e4){for(let r=0;r<n;r+=3e3){try{if((await this.get(e)).usable)return}catch{}await t.iQ.sleepMillis(3e3)}throw new eu("Timeout on waiting for postage stamp to become usable")}}var ah=n(359),ch=n.n(ah);const uh="2.8.1-7cf53193",lh=uh.split("-")[0],fh="8.1.0",hh=yc({commitment:tc(),radius:tc(),storageRadius:tc(),reserveCapacityDoubling:tc()}),dh=yc({block:tc(),chainTip:tc(),totalAmount:_a().transform((e=>Gu(e,{name:"totalAmount"}))),currentPrice:_a().transform(Number).transform((e=>{return t=e,Number.isInteger(t)?t<24e3?24e3:t:24e3;var t})),minimumValidityBlocks:tc().optional()}),ph=yc({bzzBalance:_a().transform((e=>iu.fromPLUR(Gu(e,{name:"bzzBalance"})))),nativeTokenBalance:_a().transform((e=>su.fromWei(Gu(e,{name:"nativeTokenBalance"})))),chainID:tc(),chequebookContractAddress:_a(),walletAddress:_a()}),mh=yc({transactionHash:_a().transform((e=>new cn(e)))});class gh{constructor(e){this.context=e}async get(e){return async function(e){const t=await Wc(e,{method:"get",url:"status",responseType:"json"});return Xl.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async getHealth(e){return async function(e){const t=await Wc(e,{method:"get",url:"health",responseType:"json"});return Yl.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async getReadiness(e){return async function(e){const t=await Wc(e,{method:"get",url:"readiness"});return tf.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async getNodeInfo(e){return async function(e){const t=await Wc(e,{method:"get",url:"node",responseType:"json"});return nf.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async isSupportedExactVersion(e){const{version:t}=await this.getHealth(e);return t===uh}async isSupportedApiVersion(e){const{apiVersion:t}=await this.getHealth(e);return ch()(t)===ch()(fh)}async getVersions(e){const{version:t,apiVersion:n}=await this.getHealth(e);return{supportedBeeVersion:uh,supportedBeeApiVersion:fh,beeVersion:t,beeApiVersion:n}}async getReserveState(e){return async function(e){const t=await Wc(e,{method:"get",url:"reservestate",responseType:"json"});return hh.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async getChainState(e){return async function(e){const t=await Wc(e,{method:"get",url:"chainstate",responseType:"json"});return dh.parse(t.data)}(this.context.getRequestOptionsForCall(e))}}class yh{constructor(e){this.context=e}get blockTime(){return"gnosis"===this.context.network?5:15}async buy(e,t,n,r,o,i){const s=Zu(t,(await this.context.bee.status.getChainState(r)).currentPrice,this.blockTime),a=qu(e,o,i);return n&&(n=Nu.parse(n)),this.context.bee.stamp.create(s,a,n,r)}async getCost(e,t,n,r,o){const i=Zu(t,(await this.context.bee.status.getChainState(n)).currentPrice,this.blockTime);return Lu(qu(e,r,o),i)}async extend(e,t,n,r,o,i){const s=await this.context.bee.stamp.get(e,r),a=qu(t,o,i),c=await this.context.bee.status.getChainState(r),u=a-s.depth,l=u<=0?1n:2n**BigInt(u),f=Zu(n,c.currentPrice,this.blockTime),h=Zu(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=qu(t,r,o),c=a-s.depth;if(c<=0)throw new tu("New depth has to be greater than the original depth",a);const u=Zu(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=Zu(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:Zu(n,a.currentPrice,this.blockTime),u=qu(t,o,i),l=Zu(s.duration,a.currentPrice,this.blockTime),f=Lu(s.depth,l);return Lu(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=qu(t,r,o);if(a-i.depth<=0)throw new tu("New depth has to be greater than the original depth",a);const c=Zu(i.duration,s.currentPrice,this.blockTime),u=Lu(i.depth,c);return Lu(a,c).minus(u)}async getDurationExtensionCost(e,t,n){const r=await this.context.bee.stamp.get(e,n),o=Zu(t,(await this.context.bee.status.getChainState(n)).currentPrice,this.blockTime);return Lu(r.depth,o)}async rename(e,t,n){return this.context.bee.stamp.updateLabel(e,t,n)}}const wh=yc({address:_a().nullish().transform((e=>e??"")),seen:tc(),sent:tc(),split:tc(),startedAt:_a(),stored:tc(),synced:tc(),uid:tc()}),bh=yc({tags:mc(wh)}),vh="tags";class Bh{constructor(e){this.context=e}async create(e){return async function(e){const t=await Wc(e,{method:"post",url:vh,responseType:"json"});return wh.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async getAll(e,t){return e&&(e=Cu.parse(e)),async function(e,t){const n=await Wc(e,{url:vh,params:{offset:t?.offset,limit:t?.limit},responseType:"json"});return bh.parse(n.data).tags}(this.context.getRequestOptionsForCall(t),e)}async get(e,t){const n=Uu(e);return async function(e,t){const n=await Wc(e,{url:`${vh}/${t}`,responseType:"json"});return wh.parse(n.data)}(this.context.getRequestOptionsForCall(t),n)}async delete(e,t){const n=Uu(e);await async function(e,t){await Wc(e,{method:"delete",url:`${vh}/${t}`})}(this.context.getRequestOptionsForCall(t),n)}async update(e,t,n){const r=new rn(t),o=Uu(e);await async function(e,t,n){await Wc(e,{method:"patch",url:`${vh}/${t}`,data:{reference:n}})}(this.context.getRequestOptionsForCall(n),o,r)}}const Eh=yc({transactionHash:_a().transform((e=>new cn(e))),to:_a(),nonce:tc(),gasPrice:_a().transform((e=>Gu(e,{name:"gasPrice"}))),gasLimit:tc(),data:_a(),created:_a(),description:_a(),value:_a().transform((e=>Gu(e,{name:"value"})))}),xh=yc({pendingTransactions:mc(Eh)}),Th=Eh,Rh=yc({transactionHash:_a().transform((e=>new cn(e)))}),zh="transactions";class Ah{constructor(e){this.context=e}async getAll(e){return async function(e){const t=await Wc(e,{url:zh,responseType:"json"});return xh.parse(t.data).pendingTransactions}(this.context.getRequestOptionsForCall(e))}async get(e,t){const n=new cn(e);return async function(e,t){const n=await Wc(e,{url:`${zh}/${t}`,responseType:"json"});return Th.parse(n.data)}(this.context.getRequestOptionsForCall(t),n)}async rebroadcast(e,t){const n=new cn(e);return async function(e,t){const n=await Wc(e,{method:"post",url:`${zh}/${t}`,responseType:"json"});return Rh.parse(n.data).transactionHash}(this.context.getRequestOptionsForCall(t),n)}async cancel(e,t,n){const r=new cn(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 Wc(e,{method:"delete",headers:r,url:`${zh}/${t}`,responseType:"json"});return Rh.parse(o.data).transactionHash}(this.context.getRequestOptionsForCall(n),r,o)}}const kh="wallet";class Sh{constructor(e){this.context=e}async getBalance(e){return async function(e){const t=await Wc(e,{method:"get",url:kh,responseType:"json"});return ph.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async withdrawBZZ(e,t,n){const r=e instanceof iu?e:iu.fromPLUR(e),o=new Ut(t);return async function(e,t,n){const r=await Wc(e,{method:"post",url:`${kh}/withdraw/bzz`,responseType:"json",params:{amount:t.toPLURString(),address:n.toHex()}});return mh.parse(r.data).transactionHash}(this.context.getRequestOptionsForCall(n),r,o)}async withdrawDAI(e,t,n){const r=e instanceof su?e:su.fromWei(e),o=new Ut(t);return async function(e,t,n){const r=await Wc(e,{method:"post",url:`${kh}/withdraw/nativetoken`,responseType:"json",params:{amount:t.toWeiString(),address:n.toHex()}});return mh.parse(r.data).transactionHash}(this.context.getRequestOptionsForCall(n),r,o)}}const Oh=["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 $h(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 tu("URL is not valid!",e);const t=new URL(e).port;if(t&&!function(e){if("string"!=typeof e)return!1;if(Oh.includes(e))return!1;const t=parseInt(e,10);return t>0&&t<65536&&!isNaN(t)}(t))throw new tu("Port in URL is considered bad port and cannot be used!",t)}class Ih{constructor(e,t){$h(e),this.url=function(e){return e.endsWith("/")?e.slice(0,-1):e}(e),t?.signer&&(this.signer=new tn(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 ul(n),this.settlement=new Lf(n),this.transaction=new Ah(n),this.stake=new Kf(n),this.connectivity=new sf(n),this.status=new gh(n),this.wallet=new Sh(n),this.stamp=new sh(n),this.storage=new yh(n),this.chequebook=new vl(n),this.cheque=new bl(n),this.tag=new Bh(n),this.pin=new Cf(n),this.grantee=new $f(n),this.messaging=new Df(n),this.feed=new zf(n),this.soc=new jf(n),this.data=new df(n),this.chunk=new Bl(n),this.file=new Af(n),this.collection=new Ll(n)}makeContentAddressedChunk(e,t){return Rn(e,t)}unmarshalContentAddressedChunk(e){return zn(e)}makeSingleOwnerChunk(e,t,n,r,o){return function(e,t,n,r,o){return r=new qt(r),o=new tn(o),xn({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 En(e,t)}unmarshalSingleOwnerChunk(e,t){return el(e,t)}async createEnvelope(e,t,n){return e=new Ct(e),t=new rn(t),async function(e,t,n){const r=await Wc(e,{method:"post",responseType:"json",url:`envelope/${n}`,headers:{"swarm-postage-batch-id":t.toHex()}}),o=jc.parse(r.data);return{issuer:new Ut(o.issuer),index:o.index,timestamp:o.timestamp,signature:new en(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 Wc(e,{responseType:"json",url:`rchash/${t}/${n}/${r}`});return Yc.parse(o.data).durationSeconds}(this.getRequestOptionsForCall(r),e,t,n)}getRequestOptionsForCall(e){return e&&(e=zu.parse(e)),e?t.Rb.deepMerge2(this.requestOptions,e):this.requestOptions}}const _h="https://api.gateway.ethswarm.org",Vh=new Ct("0000000000000000000000000000000000000000000000000000000000000000"),Dh=new an("0000000000000000000000000000000000000000000000000000000000000000"),Nh=new Uint8Array(32),Ph=new Uint8Array(32),Ch=new Uint8Array(20);function Fh(e){return(e=new Ht(e)).toHex().slice(0,mu)}})(),r})()));
3
3
  //# sourceMappingURL=index.browser.min.js.map