@solarpunkltd/swarm-id 0.9.0 → 0.10.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,23 +1,23 @@
1
- class e extends Error{constructor(e,t,n={}){super(t,void 0===n.cause?void 0:{cause:n.cause}),this.name="SwarmIdError",this.code=e,void 0!==n.reason&&(this.reason=n.reason),void 0!==n.status&&(this.status=n.status),void 0!==n.beeMessage&&(this.beeMessage=n.beeMessage),void 0!==n.url&&(this.url=n.url)}toWire(){return{error:this.message,code:this.code,...void 0!==this.reason&&{reason:this.reason},...void 0!==this.status&&{status:this.status},...void 0!==this.beeMessage&&{beeMessage:this.beeMessage},...void 0!==this.url&&{url:this.url}}}static fromWire(t){const{error:n,code:r,...o}=t;return new e(r,n,o)}}function t(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 e of o._zod.deferred)e();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}let n=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},r=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}};const o={};function i(e){return o}function s(e,t){return"bigint"==typeof t?t.toString():t}function a(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function c(e){return null==e}function u(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}const l=Symbol("evaluating");function f(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==l)return void 0===r&&(r=l,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function d(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function h(...e){const t={};for(const n of e){const e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function p(e){return JSON.stringify(e)}const m="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function g(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}const y=a(()=>{if("undefined"!=typeof navigator&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function w(e){if(!1===g(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!==g(n)&&!1!==Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")}function b(e){return w(e)?{...e}:Array.isArray(e)?[...e]:e}const v=new Set(["string","number","symbol"]);function E(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function _(e,t,n){const r=new e._zod.constr(t??e._zod.def);return t&&!n?.parent||(r._zod.parent=e),r}function x(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 k={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 A(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 I(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function $(e){return"string"==typeof e?e:e?.message}function B(e,t,n){const r={...e,path:e.path??[]};if(!e.message){const o=$(e.inst?._zod.def?.error?.(e))??$(t?.error?.(e))??$(n.customError?.(e))??$(n.localeError?.(e))??"Invalid input";r.message=o}return delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function z(e){return Array.isArray(e)?"array":"string"==typeof e?"string":"unknown"}function S(...e){const[t,n,r]=e;return"string"==typeof t?{message:t,code:"custom",input:n,inst:r}:{...t}}const O=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,s,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},T=t("$ZodError",O),N=t("$ZodError",O,{Parent:Error});const R=e=>(t,r,o,s)=>{const a=o?Object.assign(o,{async:!1}):{async:!1},c=t._zod.run({value:r,issues:[]},a);if(c instanceof Promise)throw new n;if(c.issues.length){const t=new(s?.Err??e)(c.issues.map(e=>B(e,a,i())));throw m(t,s?.callee),t}return c.value},U=e=>async(t,n,r,o)=>{const s=r?Object.assign(r,{async:!0}):{async:!0};let a=t._zod.run({value:n,issues:[]},s);if(a instanceof Promise&&(a=await a),a.issues.length){const t=new(o?.Err??e)(a.issues.map(e=>B(e,s,i())));throw m(t,o?.callee),t}return a.value},P=e=>(t,r,o)=>{const s=o?{...o,async:!1}:{async:!1},a=t._zod.run({value:r,issues:[]},s);if(a instanceof Promise)throw new n;return a.issues.length?{success:!1,error:new(e??T)(a.issues.map(e=>B(e,s,i())))}:{success:!0,data:a.value}},F=P(N),C=e=>async(t,n,r)=>{const o=r?Object.assign(r,{async:!0}):{async:!0};let s=t._zod.run({value:n,issues:[]},o);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new e(s.issues.map(e=>B(e,o,i())))}:{success:!0,data:s.value}},L=C(N),M=e=>(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return R(e)(t,n,o)},D=e=>(t,n,r)=>R(e)(t,n,r),Z=e=>async(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return U(e)(t,n,o)},j=e=>async(t,n,r)=>U(e)(t,n,r),q=e=>(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return P(e)(t,n,o)},G=e=>(t,n,r)=>P(e)(t,n,r),H=e=>async(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return C(e)(t,n,o)},V=e=>async(t,n,r)=>C(e)(t,n,r),K=/^[cC][^\s-]{8,}$/,W=/^[0-9a-z]+$/,J=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,X=/^[0-9a-vA-V]{20}$/,Y=/^[A-Za-z0-9]{27}$/,Q=/^[a-zA-Z0-9_-]{21}$/,ee=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,te=/^([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})$/,ne=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)$/,re=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;const oe=/^(?:(?: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])$/,ie=/^(([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}|:))$/,se=/^((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])$/,ae=/^(([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])$/,ce=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,ue=/^[A-Za-z0-9_-]*$/,le=/^\+(?:[0-9]){6,14}[0-9]$/,fe="(?:(?:\\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])))",de=new RegExp(`^${fe}$`);function he(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 pe=/^-?\d+$/,me=/^-?\d+(?:\.\d+)?/,ge=/^(?:true|false)$/i,ye=/^undefined$/i,we=/^[^A-Z]*$/,be=/^[^a-z]*$/,ve=t("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Ee={number:"number",bigint:"bigint",object:"date"},_e=t("$ZodCheckLessThan",(e,t)=>{ve.init(e,t);const n=Ee[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:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),xe=t("$ZodCheckGreaterThan",(e,t)=>{ve.init(e,t);const n=Ee[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:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),ke=t("$ZodCheckMultipleOf",(e,t)=>{ve.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.toString().split(".")[1]||"").length,r=t.toString();let o=(r.split(".")[1]||"").length;if(0===o&&/\d?e-\d?/.test(r)){const e=r.match(/\d?e-(\d?)/);e?.[1]&&(o=Number.parseInt(e[1]))}const i=n>o?n:o;return Number.parseInt(e.toFixed(i).replace(".",""))%Number.parseInt(t.toFixed(i).replace(".",""))/10**i}(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})}}),Ae=t("$ZodCheckNumberFormat",(e,t)=>{ve.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),r=n?"int":"number",[o,i]=k[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=pe)}),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,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,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,inst:e})}}),Ie=t("$ZodCheckMaxLength",(e,t)=>{var n;ve.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!c(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=z(r);n.issues.push({origin:o,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),$e=t("$ZodCheckMinLength",(e,t)=>{var n;ve.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!c(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=z(r);n.issues.push({origin:o,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Be=t("$ZodCheckLengthEquals",(e,t)=>{var n;ve.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!c(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=z(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})}}),ze=t("$ZodCheckStringFormat",(e,t)=>{var n,r;ve.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=()=>{})}),Se=t("$ZodCheckRegex",(e,t)=>{ze.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})}}),Oe=t("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=we),ze.init(e,t)}),Te=t("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=be),ze.init(e,t)}),Ne=t("$ZodCheckIncludes",(e,t)=>{ve.init(e,t);const n=E(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})}}),Re=t("$ZodCheckStartsWith",(e,t)=>{ve.init(e,t);const n=new RegExp(`^${E(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})}}),Ue=t("$ZodCheckEndsWith",(e,t)=>{ve.init(e,t);const n=new RegExp(`.*${E(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})}}),Pe=t("$ZodCheckOverwrite",(e,t)=>{ve.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});let Fe=class{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 e of r)this.content.push(e)}compile(){const e=Function,t=this?.args;return new e(...t,[...(this?.content??[""]).map(e=>` ${e}`)].join("\n"))}};const Ce={major:4,minor:1,patch:13},Le=t("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Ce;const o=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&o.unshift(e);for(const t of o)for(const n of t._zod.onattach)n(e);if(0===o.length)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const t=(e,t,r)=>{let o,i=A(e);for(const s of t){if(s._zod.def.when){if(!s._zod.def.when(e))continue}else if(i)continue;const t=e.issues.length,a=s._zod.check(e);if(a instanceof Promise&&!1===r?.async)throw new n;if(o||a instanceof Promise)o=(o??Promise.resolve()).then(async()=>{await a;e.issues.length!==t&&(i||(i=A(e,t)))});else{if(e.issues.length===t)continue;i||(i=A(e,t))}}return o?o.then(()=>e):e},r=(r,i,s)=>{if(A(r))return r.aborted=!0,r;const a=t(i,o,s);if(a instanceof Promise){if(!1===s.async)throw new n;return a.then(t=>e._zod.parse(t,s))}return e._zod.parse(a,s)};e._zod.run=(i,s)=>{if(s.skipChecks)return e._zod.parse(i,s);if("backward"===s.direction){const t=e._zod.parse({value:i.value,issues:[]},{...s,skipChecks:!0});return t instanceof Promise?t.then(e=>r(e,i,s)):r(t,i,s)}const a=e._zod.parse(i,s);if(a instanceof Promise){if(!1===s.async)throw new n;return a.then(e=>t(e,o,s))}return t(a,o,s)}}e["~standard"]={validate:t=>{try{const n=F(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch(n){return L(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:"zod",version:1}}),Me=t("$ZodString",(e,t)=>{var n;Le.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}}),De=t("$ZodStringFormat",(e,t)=>{ze.init(e,t),Me.init(e,t)}),Ze=t("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=te),De.init(e,t)}),je=t("$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=ne(e))}else t.pattern??(t.pattern=ne());De.init(e,t)}),qe=t("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=re),De.init(e,t)}),Ge=t("$ZodURL",(e,t)=>{De.init(e,t),e._zod.check=n=>{try{const r=n.value.trim(),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})}}}),He=t("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),De.init(e,t)}),Ve=t("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Q),De.init(e,t)}),Ke=t("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=K),De.init(e,t)}),We=t("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=W),De.init(e,t)}),Je=t("$ZodULID",(e,t)=>{t.pattern??(t.pattern=J),De.init(e,t)}),Xe=t("$ZodXID",(e,t)=>{t.pattern??(t.pattern=X),De.init(e,t)}),Ye=t("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Y),De.init(e,t)}),Qe=t("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=function(e){const t=he({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(`^${fe}T(?:${r})$`)}(t)),De.init(e,t)}),et=t("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=de),De.init(e,t)}),tt=t("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=new RegExp(`^${he(t)}$`)),De.init(e,t)}),nt=t("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=ee),De.init(e,t)}),rt=t("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=oe),De.init(e,t),e._zod.bag.format="ipv4"}),ot=t("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=ie),De.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})}}}),it=t("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=se),De.init(e,t)}),st=t("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=ae),De.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 at(e){if(""===e)return!0;if(e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}const ct=t("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=ce),De.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{at(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});const ut=t("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=ue),De.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{(function(e){if(!ue.test(e))return!1;const t=e.replace(/[-_]/g,e=>"-"===e?"+":"/");return at(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})}}),lt=t("$ZodE164",(e,t)=>{t.pattern??(t.pattern=le),De.init(e,t)});const ft=t("$ZodJWT",(e,t)=>{De.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})}}),dt=t("$ZodNumber",(e,t)=>{Le.init(e,t),e._zod.pattern=e._zod.bag.pattern??me,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch(e){}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}}),ht=t("$ZodNumberFormat",(e,t)=>{Ae.init(e,t),dt.init(e,t)}),pt=t("$ZodBoolean",(e,t)=>{Le.init(e,t),e._zod.pattern=ge,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Boolean(n.value)}catch(e){}const o=n.value;return"boolean"==typeof o||n.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),n}}),mt=t("$ZodUndefined",(e,t)=>{Le.init(e,t),e._zod.pattern=ye,e._zod.values=new Set([void 0]),e._zod.optin="optional",e._zod.optout="optional",e._zod.parse=(t,n)=>{const r=t.value;return void 0===r||t.issues.push({expected:"undefined",code:"invalid_type",input:r,inst:e}),t}}),gt=t("$ZodUnknown",(e,t)=>{Le.init(e,t),e._zod.parse=e=>e}),yt=t("$ZodNever",(e,t)=>{Le.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:e}),t)});function wt(e,t,n){e.issues.length&&t.issues.push(...I(n,e.issues)),t.value[n]=e.value}const bt=t("$ZodArray",(e,t)=>{Le.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=>wt(t,n,e))):wt(a,n,e)}return i.length?Promise.all(i).then(()=>n):n}});function vt(e,t,n,r){e.issues.length&&t.issues.push(...I(n,e.issues)),void 0===e.value?n in r&&(t.value[n]=void 0):t.value[n]=e.value}function Et(e){const t=Object.keys(e.shape);for(const n of t)if(!e.shape?.[n]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${n}": 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 _t(e,t,n,r,o,i){const s=[],a=o.keySet,c=o.catchall._zod,u=c.def.type;for(const o in t){if(a.has(o))continue;if("never"===u){s.push(o);continue}const i=c.run({value:t[o],issues:[]},r);i instanceof Promise?e.push(i.then(e=>vt(e,n,o,t))):vt(i,n,o,t)}return s.length&&n.issues.push({code:"unrecognized_keys",keys:s,input:t,inst:i}),e.length?Promise.all(e).then(()=>n):n}const xt=t("$ZodObject",(e,t)=>{Le.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=a(()=>Et(t));f(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=g,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]._zod.run({value:a[e],issues:[]},n);r instanceof Promise?c.push(r.then(n=>vt(n,t,e,a))):vt(r,t,e,a)}return i?_t(c,a,t,n,r.value,e):c.length?Promise.all(c).then(()=>t):t}}),kt=t("$ZodObjectJIT",(e,t)=>{xt.init(e,t);const n=e._zod.parse,r=a(()=>Et(t));let i;const s=g,c=!o.jitless,u=c&&y.value,l=t.catchall;let f;e._zod.parse=(o,a)=>{f??(f=r.value);const d=o.value;return s(d)?c&&u&&!1===a?.async&&!0!==a.jitless?(i||(i=(e=>{const t=new Fe(["shape","payload","ctx"]),n=r.value,o=e=>{const t=p(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 e of n.keys)i[e]="key_"+s++;t.write("const newResult = {};");for(const e of n.keys){const n=i[e],r=p(e);t.write(`const ${n} = ${o(e)};`),t.write(`\n if (${n}.issues.length) {\n payload.issues = payload.issues.concat(${n}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${r}, ...iss.path] : [${r}]\n })));\n }\n \n \n if (${n}.value === undefined) {\n if (${r} in input) {\n newResult[${r}] = undefined;\n }\n } else {\n newResult[${r}] = ${n}.value;\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)),o=i(o,a),l?_t([],d,o,a,f,e):o):n(o,a):(o.issues.push({expected:"object",code:"invalid_type",input:d,inst:e}),o)}});function At(e,t,n,r){for(const n of e)if(0===n.issues.length)return t.value=n.value,t;const o=e.filter(e=>!A(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=>B(e,r,i())))}),t)}const It=t("$ZodUnion",(e,t)=>{Le.init(e,t),f(e._zod,"optin",()=>t.options.some(e=>"optional"===e._zod.optin)?"optional":void 0),f(e._zod,"optout",()=>t.options.some(e=>"optional"===e._zod.optout)?"optional":void 0),f(e._zod,"values",()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),f(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=>u(e.source)).join("|")})$`)}});const n=1===t.options.length,r=t.options[0]._zod.run;e._zod.parse=(o,i)=>{if(n)return r(o,i);let s=!1;const a=[];for(const e of t.options){const t=e._zod.run({value:o.value,issues:[]},i);if(t instanceof Promise)a.push(t),s=!0;else{if(0===t.issues.length)return t;a.push(t)}}return s?Promise.all(a).then(t=>At(t,o,e,i)):At(a,o,e,i)}}),$t=t("$ZodDiscriminatedUnion",(e,t)=>{It.init(e,t);const n=e._zod.parse;f(e._zod,"propValues",()=>{const e={};for(const n of t.options){const r=n._zod.propValues;if(!r||0===Object.keys(r).length)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(const[t,n]of Object.entries(r)){e[t]||(e[t]=new Set);for(const r of n)e[t].add(r)}}return e});const r=a(()=>{const e=t.options,n=new Map;for(const r of e){const e=r._zod.propValues?.[t.discriminator];if(!e||0===e.size)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(const t of e){if(n.has(t))throw new Error(`Duplicate discriminator value "${String(t)}"`);n.set(t,r)}}return n});e._zod.parse=(o,i)=>{const s=o.value;if(!g(s))return o.issues.push({code:"invalid_type",expected:"object",input:s,inst:e}),o;const a=r.value.get(s?.[t.discriminator]);return a?a._zod.run(o,i):t.unionFallback?n(o,i):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,input:s,path:[t.discriminator],inst:e}),o)}}),Bt=t("$ZodIntersection",(e,t)=>{Le.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])=>St(e,t,n)):St(e,o,i)}});function zt(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(w(e)&&w(t)){const n=Object.keys(t),r=Object.keys(e).filter(e=>-1!==n.indexOf(e)),o={...e,...t};for(const n of r){const r=zt(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};o[n]=r.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=zt(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 St(e,t,n){if(t.issues.length&&e.issues.push(...t.issues),n.issues.length&&e.issues.push(...n.issues),A(e))return e;const r=zt(t.value,n.value);if(!r.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(r.mergeErrorPath)}`);return e.value=r.data,e}const Ot=t("$ZodRecord",(e,t)=>{Le.init(e,t),e._zod.parse=(n,r)=>{const o=n.value;if(!w(o))return n.issues.push({expected:"record",code:"invalid_type",input:o,inst:e}),n;const s=[],a=t.keyType._zod.values;if(a){n.value={};const i=new Set;for(const e of a)if("string"==typeof e||"number"==typeof e||"symbol"==typeof e){i.add("number"==typeof e?e.toString():e);const a=t.valueType._zod.run({value:o[e],issues:[]},r);a instanceof Promise?s.push(a.then(t=>{t.issues.length&&n.issues.push(...I(e,t.issues)),n.value[e]=t.value})):(a.issues.length&&n.issues.push(...I(e,a.issues)),n.value[e]=a.value)}let c;for(const e in o)i.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 a of Reflect.ownKeys(o)){if("__proto__"===a)continue;const c=t.keyType._zod.run({value:a,issues:[]},r);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(c.issues.length){n.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(e=>B(e,r,i())),input:a,path:[a],inst:e}),n.value[c.value]=c.value;continue}const u=t.valueType._zod.run({value:o[a],issues:[]},r);u instanceof Promise?s.push(u.then(e=>{e.issues.length&&n.issues.push(...I(a,e.issues)),n.value[c.value]=e.value})):(u.issues.length&&n.issues.push(...I(a,u.issues)),n.value[c.value]=u.value)}}return s.length?Promise.all(s).then(()=>n):n}}),Tt=t("$ZodEnum",(e,t)=>{Le.init(e,t);const n=function(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)}(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter(e=>v.has(typeof e)).map(e=>"string"==typeof e?E(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}}),Nt=t("$ZodLiteral",(e,t)=>{if(Le.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?E(e):e?E(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}}),Rt=t("$ZodTransform",(e,t)=>{Le.init(e,t),e._zod.parse=(o,i)=>{if("backward"===i.direction)throw new r(e.constructor.name);const s=t.transform(o.value,o);if(i.async){return(s instanceof Promise?s:Promise.resolve(s)).then(e=>(o.value=e,o))}if(s instanceof Promise)throw new n;return o.value=s,o}});function Ut(e,t){return e.issues.length&&void 0===t?{issues:[],value:void 0}:e}const Pt=t("$ZodOptional",(e,t)=>{Le.init(e,t),e._zod.optin="optional",e._zod.optout="optional",f(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),f(e._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${u(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if("optional"===t.innerType._zod.optin){const r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(t=>Ut(t,e.value)):Ut(r,e.value)}return void 0===e.value?e:t.innerType._zod.run(e,n)}}),Ft=t("$ZodNullable",(e,t)=>{Le.init(e,t),f(e._zod,"optin",()=>t.innerType._zod.optin),f(e._zod,"optout",()=>t.innerType._zod.optout),f(e._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${u(e.source)}|null)$`):void 0}),f(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)}),Ct=t("$ZodDefault",(e,t)=>{Le.init(e,t),e._zod.optin="optional",f(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=>Lt(e,t)):Lt(r,t)}});function Lt(e,t){return void 0===e.value&&(e.value=t.defaultValue),e}const Mt=t("$ZodPrefault",(e,t)=>{Le.init(e,t),e._zod.optin="optional",f(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))}),Dt=t("$ZodNonOptional",(e,t)=>{Le.init(e,t),f(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=>Zt(t,e)):Zt(o,e)}});function Zt(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 jt=t("$ZodCatch",(e,t)=>{Le.init(e,t),f(e._zod,"optin",()=>t.innerType._zod.optin),f(e._zod,"optout",()=>t.innerType._zod.optout),f(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=>B(e,n,i()))},input:e.value}),e.issues=[]),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>B(e,n,i()))},input:e.value}),e.issues=[]),e)}}),qt=t("$ZodPipe",(e,t)=>{Le.init(e,t),f(e._zod,"values",()=>t.in._zod.values),f(e._zod,"optin",()=>t.in._zod.optin),f(e._zod,"optout",()=>t.out._zod.optout),f(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=>Gt(e,t.in,n)):Gt(r,t.in,n)}const r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Gt(e,t.out,n)):Gt(r,t.out,n)}});function Gt(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const Ht=t("$ZodReadonly",(e,t)=>{Le.init(e,t),f(e._zod,"propValues",()=>t.innerType._zod.propValues),f(e._zod,"values",()=>t.innerType._zod.values),f(e._zod,"optin",()=>t.innerType?._zod?.optin),f(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(Vt):Vt(r)}});function Vt(e){return e.value=Object.freeze(e.value),e}const Kt=t("$ZodCustom",(e,t)=>{ve.init(e,t),Le.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=>Wt(t,n,r,e));Wt(o,n,r,e)}});function Wt(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(S(e))}}var Jt;let Xt=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){const n=t[0];if(this._map.set(e,n),n&&"object"==typeof n&&"id"in n){if(this._idmap.has(n.id))throw new Error(`ID ${n.id} already exists in the registry`);this._idmap.set(n.id,e)}return 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)}};(Jt=globalThis).__zod_globalRegistry??(Jt.__zod_globalRegistry=new Xt);const Yt=globalThis.__zod_globalRegistry;function Qt(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...x(t)})}function en(e,t){return new _e({check:"less_than",...x(t),value:e,inclusive:!1})}function tn(e,t){return new _e({check:"less_than",...x(t),value:e,inclusive:!0})}function nn(e,t){return new xe({check:"greater_than",...x(t),value:e,inclusive:!1})}function rn(e,t){return new xe({check:"greater_than",...x(t),value:e,inclusive:!0})}function on(e,t){return new ke({check:"multiple_of",...x(t),value:e})}function sn(e,t){return new Ie({check:"max_length",...x(t),maximum:e})}function an(e,t){return new $e({check:"min_length",...x(t),minimum:e})}function cn(e,t){return new Be({check:"length_equals",...x(t),length:e})}function un(e){return new Pe({check:"overwrite",tx:e})}function ln(e){const t=function(e,t){const n=new ve({check:"custom",...x(t)});return n._zod.check=e,n}(n=>(n.addIssue=e=>{if("string"==typeof e)n.issues.push(S(e,n.value,t._zod.def));else{const r=e;r.fatal&&(r.continue=!1),r.code??(r.code="custom"),r.input??(r.input=n.value),r.inst??(r.inst=t),r.continue??(r.continue=!t._zod.def.abort),n.issues.push(S(r))}},e(n.value,n)));return t}const fn=t("ZodISODateTime",(e,t)=>{Qe.init(e,t),Cn.init(e,t)});function dn(e){return function(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...x(t)})}(fn,e)}const hn=t("ZodISODate",(e,t)=>{et.init(e,t),Cn.init(e,t)});function pn(e){return function(e,t){return new e({type:"string",format:"date",check:"string_format",...x(t)})}(hn,e)}const mn=t("ZodISOTime",(e,t)=>{tt.init(e,t),Cn.init(e,t)});function gn(e){return function(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...x(t)})}(mn,e)}const yn=t("ZodISODuration",(e,t)=>{nt.init(e,t),Cn.init(e,t)});function wn(e){return function(e,t){return new e({type:"string",format:"duration",check:"string_format",...x(t)})}(yn,e)}const bn=(e,t)=>{T.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:t=>function(e,t=e=>e.message){const n={_errors:[]},r=e=>{for(const o of e.issues)if("invalid_union"===o.code&&o.errors.length)o.errors.map(e=>r({issues:e}));else if("invalid_key"===o.code)r({issues:o.issues});else if("invalid_element"===o.code)r({issues:o.issues});else if(0===o.path.length)n._errors.push(t(o));else{let e=n,r=0;for(;r<o.path.length;){const n=o.path[r];r===o.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(o))):e[n]=e[n]||{_errors:[]},e=e[n],r++}}};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,s,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,s,2)}},isEmpty:{get:()=>0===e.issues.length}})},vn=t("ZodError",bn),En=t("ZodError",bn,{Parent:Error}),_n=R(En),xn=U(En),kn=P(En),An=C(En),In=M(En),$n=D(En),Bn=Z(En),zn=j(En),Sn=q(En),On=G(En),Tn=H(En),Nn=V(En),Rn=t("ZodType",(e,t)=>(Le.init(e,t),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(h(t,{checks:[...t.checks??[],...n.map(e=>"function"==typeof e?{_zod:{check:e,def:{check:"custom"},onattach:[]}}:e)]})),e.clone=(t,n)=>_(e,t,n),e.brand=()=>e,e.register=(t,n)=>(t.add(e,n),e),e.parse=(t,n)=>_n(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>kn(e,t,n),e.parseAsync=async(t,n)=>xn(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>An(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>In(e,t,n),e.decode=(t,n)=>$n(e,t,n),e.encodeAsync=async(t,n)=>Bn(e,t,n),e.decodeAsync=async(t,n)=>zn(e,t,n),e.safeEncode=(t,n)=>Sn(e,t,n),e.safeDecode=(t,n)=>On(e,t,n),e.safeEncodeAsync=async(t,n)=>Tn(e,t,n),e.safeDecodeAsync=async(t,n)=>Nn(e,t,n),e.refine=(t,n)=>e.check(function(e,t={}){return function(e,t,n){return new e({type:"custom",check:"custom",fn:t,...x(n)})}(qr,e,t)}(t,n)),e.superRefine=t=>e.check(ln(t)),e.overwrite=t=>e.check(un(t)),e.optional=()=>Rr(e),e.nullable=()=>Pr(e),e.nullish=()=>Rr(Pr(e)),e.nonoptional=t=>function(e,t){return new Lr({type:"nonoptional",innerType:e,...x(t)})}(e,t),e.array=()=>gr(e),e.or=t=>Er([e,t]),e.and=t=>new kr({type:"intersection",left:e,right:t}),e.transform=t=>Zr(e,Tr(t)),e.default=t=>{return n=t,new Fr({type:"default",innerType:e,get defaultValue(){return"function"==typeof n?n():b(n)}});var n},e.prefault=t=>{return n=t,new Cr({type:"prefault",innerType:e,get defaultValue(){return"function"==typeof n?n():b(n)}});var n},e.catch=t=>{return new Mr({type:"catch",innerType:e,catchValue:"function"==typeof(n=t)?n:()=>n});var n},e.pipe=t=>Zr(e,t),e.readonly=()=>new jr({type:"readonly",innerType:e}),e.describe=t=>{const n=e.clone();return Yt.add(n,{description:t}),n},Object.defineProperty(e,"description",{get:()=>Yt.get(e)?.description,configurable:!0}),e.meta=(...t)=>{if(0===t.length)return Yt.get(e);const n=e.clone();return Yt.add(n,t[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),Un=t("_ZodString",(e,t)=>{Me.init(e,t),Rn.init(e,t);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...t)=>e.check(function(e,t){return new Se({check:"string_format",format:"regex",...x(t),pattern:e})}(...t)),e.includes=(...t)=>e.check(function(e,t){return new Ne({check:"string_format",format:"includes",...x(t),includes:e})}(...t)),e.startsWith=(...t)=>e.check(function(e,t){return new Re({check:"string_format",format:"starts_with",...x(t),prefix:e})}(...t)),e.endsWith=(...t)=>e.check(function(e,t){return new Ue({check:"string_format",format:"ends_with",...x(t),suffix:e})}(...t)),e.min=(...t)=>e.check(an(...t)),e.max=(...t)=>e.check(sn(...t)),e.length=(...t)=>e.check(cn(...t)),e.nonempty=(...t)=>e.check(an(1,...t)),e.lowercase=t=>e.check(function(e){return new Oe({check:"string_format",format:"lowercase",...x(e)})}(t)),e.uppercase=t=>e.check(function(e){return new Te({check:"string_format",format:"uppercase",...x(e)})}(t)),e.trim=()=>e.check(un(e=>e.trim())),e.normalize=(...t)=>e.check(function(e){return un(t=>t.normalize(e))}(...t)),e.toLowerCase=()=>e.check(un(e=>e.toLowerCase())),e.toUpperCase=()=>e.check(un(e=>e.toUpperCase())),e.slugify=()=>e.check(un(e=>function(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}(e)))}),Pn=t("ZodString",(e,t)=>{Me.init(e,t),Un.init(e,t),e.email=t=>e.check(function(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...x(t)})}(Ln,t)),e.url=t=>e.check(function(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...x(t)})}(Zn,t)),e.jwt=t=>e.check(function(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...x(t)})}(rr,t)),e.emoji=t=>e.check(function(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...x(t)})}(jn,t)),e.guid=t=>e.check(Qt(Mn,t)),e.uuid=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...x(t)})}(Dn,t)),e.uuidv4=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...x(t)})}(Dn,t)),e.uuidv6=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...x(t)})}(Dn,t)),e.uuidv7=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...x(t)})}(Dn,t)),e.nanoid=t=>e.check(function(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...x(t)})}(qn,t)),e.guid=t=>e.check(Qt(Mn,t)),e.cuid=t=>e.check(function(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...x(t)})}(Gn,t)),e.cuid2=t=>e.check(function(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...x(t)})}(Hn,t)),e.ulid=t=>e.check(function(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...x(t)})}(Vn,t)),e.base64=t=>e.check(function(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...x(t)})}(er,t)),e.base64url=t=>e.check(function(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...x(t)})}(tr,t)),e.xid=t=>e.check(function(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...x(t)})}(Kn,t)),e.ksuid=t=>e.check(function(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...x(t)})}(Wn,t)),e.ipv4=t=>e.check(function(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...x(t)})}(Jn,t)),e.ipv6=t=>e.check(function(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...x(t)})}(Xn,t)),e.cidrv4=t=>e.check(function(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...x(t)})}(Yn,t)),e.cidrv6=t=>e.check(function(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...x(t)})}(Qn,t)),e.e164=t=>e.check(function(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...x(t)})}(nr,t)),e.datetime=t=>e.check(dn(t)),e.date=t=>e.check(pn(t)),e.time=t=>e.check(gn(t)),e.duration=t=>e.check(wn(t))});function Fn(e){return function(e,t){return new e({type:"string",...x(t)})}(Pn,e)}const Cn=t("ZodStringFormat",(e,t)=>{De.init(e,t),Un.init(e,t)}),Ln=t("ZodEmail",(e,t)=>{qe.init(e,t),Cn.init(e,t)}),Mn=t("ZodGUID",(e,t)=>{Ze.init(e,t),Cn.init(e,t)}),Dn=t("ZodUUID",(e,t)=>{je.init(e,t),Cn.init(e,t)}),Zn=t("ZodURL",(e,t)=>{Ge.init(e,t),Cn.init(e,t)}),jn=t("ZodEmoji",(e,t)=>{He.init(e,t),Cn.init(e,t)}),qn=t("ZodNanoID",(e,t)=>{Ve.init(e,t),Cn.init(e,t)}),Gn=t("ZodCUID",(e,t)=>{Ke.init(e,t),Cn.init(e,t)}),Hn=t("ZodCUID2",(e,t)=>{We.init(e,t),Cn.init(e,t)}),Vn=t("ZodULID",(e,t)=>{Je.init(e,t),Cn.init(e,t)}),Kn=t("ZodXID",(e,t)=>{Xe.init(e,t),Cn.init(e,t)}),Wn=t("ZodKSUID",(e,t)=>{Ye.init(e,t),Cn.init(e,t)}),Jn=t("ZodIPv4",(e,t)=>{rt.init(e,t),Cn.init(e,t)}),Xn=t("ZodIPv6",(e,t)=>{ot.init(e,t),Cn.init(e,t)}),Yn=t("ZodCIDRv4",(e,t)=>{it.init(e,t),Cn.init(e,t)}),Qn=t("ZodCIDRv6",(e,t)=>{st.init(e,t),Cn.init(e,t)}),er=t("ZodBase64",(e,t)=>{ct.init(e,t),Cn.init(e,t)}),tr=t("ZodBase64URL",(e,t)=>{ut.init(e,t),Cn.init(e,t)}),nr=t("ZodE164",(e,t)=>{lt.init(e,t),Cn.init(e,t)}),rr=t("ZodJWT",(e,t)=>{ft.init(e,t),Cn.init(e,t)}),or=t("ZodNumber",(e,t)=>{dt.init(e,t),Rn.init(e,t),e.gt=(t,n)=>e.check(nn(t,n)),e.gte=(t,n)=>e.check(rn(t,n)),e.min=(t,n)=>e.check(rn(t,n)),e.lt=(t,n)=>e.check(en(t,n)),e.lte=(t,n)=>e.check(tn(t,n)),e.max=(t,n)=>e.check(tn(t,n)),e.int=t=>e.check(ar(t)),e.safe=t=>e.check(ar(t)),e.positive=t=>e.check(nn(0,t)),e.nonnegative=t=>e.check(rn(0,t)),e.negative=t=>e.check(en(0,t)),e.nonpositive=t=>e.check(tn(0,t)),e.multipleOf=(t,n)=>e.check(on(t,n)),e.step=(t,n)=>e.check(on(t,n)),e.finite=()=>e;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 ir(e){return function(e,t){return new e({type:"number",checks:[],...x(t)})}(or,e)}const sr=t("ZodNumberFormat",(e,t)=>{ht.init(e,t),or.init(e,t)});function ar(e){return function(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...x(t)})}(sr,e)}const cr=t("ZodBoolean",(e,t)=>{pt.init(e,t),Rn.init(e,t)});function ur(e){return function(e,t){return new e({type:"boolean",...x(t)})}(cr,e)}const lr=t("ZodUndefined",(e,t)=>{mt.init(e,t),Rn.init(e,t)});const fr=t("ZodUnknown",(e,t)=>{gt.init(e,t),Rn.init(e,t)});function dr(){return new fr({type:"unknown"})}const hr=t("ZodNever",(e,t)=>{yt.init(e,t),Rn.init(e,t)});function pr(e){return function(e,t){return new e({type:"never",...x(t)})}(hr,e)}const mr=t("ZodArray",(e,t)=>{bt.init(e,t),Rn.init(e,t),e.element=t.element,e.min=(t,n)=>e.check(an(t,n)),e.nonempty=t=>e.check(an(1,t)),e.max=(t,n)=>e.check(sn(t,n)),e.length=(t,n)=>e.check(cn(t,n)),e.unwrap=()=>e.element});function gr(e,t){return function(e,t,n){return new e({type:"array",element:t,...x(n)})}(mr,e,t)}const yr=t("ZodObject",(e,t)=>{kt.init(e,t),Rn.init(e,t),f(e,"shape",()=>t.shape),e.keyof=()=>Br(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:dr()}),e.loose=()=>e.clone({...e._zod.def,catchall:dr()}),e.strict=()=>e.clone({...e._zod.def,catchall:pr()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>function(e,t){if(!w(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0)throw new Error("Object schemas containing refinements cannot be extended. Use `.safeExtend()` instead.");const r=h(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return d(this,"shape",n),n},checks:[]});return _(e,r)}(e,t),e.safeExtend=t=>function(e,t){if(!w(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n={...e._zod.def,get shape(){const n={...e._zod.def.shape,...t};return d(this,"shape",n),n},checks:e._zod.def.checks};return _(e,n)}(e,t),e.merge=t=>function(e,t){const n=h(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t._zod.def.shape};return d(this,"shape",n),n},get catchall(){return t._zod.def.catchall},checks:[]});return _(e,n)}(e,t),e.pick=t=>function(e,t){const n=e._zod.def;return _(e,h(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 d(this,"shape",e),e},checks:[]}))}(e,t),e.omit=t=>function(e,t){const n=e._zod.def,r=h(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 d(this,"shape",r),r},checks:[]});return _(e,r)}(e,t),e.partial=(...t)=>function(e,t,n){const r=h(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 d(this,"shape",o),o},checks:[]});return _(t,r)}(Nr,e,t[0]),e.required=(...t)=>function(e,t,n){const r=h(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 d(this,"shape",o),o},checks:[]});return _(t,r)}(Lr,e,t[0])});function wr(e,t){const n={type:"object",shape:e??{},...x(t)};return new yr(n)}function br(e,t){return new yr({type:"object",shape:e,catchall:pr(),...x(t)})}const vr=t("ZodUnion",(e,t)=>{It.init(e,t),Rn.init(e,t),e.options=t.options});function Er(e,t){return new vr({type:"union",options:e,...x(t)})}const _r=t("ZodDiscriminatedUnion",(e,t)=>{vr.init(e,t),$t.init(e,t)});function xr(e,t,n){return new _r({type:"union",options:t,discriminator:e,...x(n)})}const kr=t("ZodIntersection",(e,t)=>{Bt.init(e,t),Rn.init(e,t)});const Ar=t("ZodRecord",(e,t)=>{Ot.init(e,t),Rn.init(e,t),e.keyType=t.keyType,e.valueType=t.valueType});function Ir(e,t,n){return new Ar({type:"record",keyType:e,valueType:t,...x(n)})}const $r=t("ZodEnum",(e,t)=>{Tt.init(e,t),Rn.init(e,t),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 r of e){if(!n.has(r))throw new Error(`Key ${r} not found in enum`);o[r]=t.entries[r]}return new $r({...t,checks:[],...x(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 $r({...t,checks:[],...x(r),entries:o})}});function Br(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new $r({type:"enum",entries:n,...x(t)})}const zr=t("ZodLiteral",(e,t)=>{Nt.init(e,t),Rn.init(e,t),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]}})});function Sr(e,t){return new zr({type:"literal",values:Array.isArray(e)?e:[e],...x(t)})}const Or=t("ZodTransform",(e,t)=>{Rt.init(e,t),Rn.init(e,t),e._zod.parse=(n,o)=>{if("backward"===o.direction)throw new r(e.constructor.name);n.addIssue=r=>{if("string"==typeof r)n.issues.push(S(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(S(t))}};const i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function Tr(e){return new Or({type:"transform",transform:e})}const Nr=t("ZodOptional",(e,t)=>{Pt.init(e,t),Rn.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Rr(e){return new Nr({type:"optional",innerType:e})}const Ur=t("ZodNullable",(e,t)=>{Ft.init(e,t),Rn.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Pr(e){return new Ur({type:"nullable",innerType:e})}const Fr=t("ZodDefault",(e,t)=>{Ct.init(e,t),Rn.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});const Cr=t("ZodPrefault",(e,t)=>{Mt.init(e,t),Rn.init(e,t),e.unwrap=()=>e._zod.def.innerType});const Lr=t("ZodNonOptional",(e,t)=>{Dt.init(e,t),Rn.init(e,t),e.unwrap=()=>e._zod.def.innerType});const Mr=t("ZodCatch",(e,t)=>{jt.init(e,t),Rn.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});const Dr=t("ZodPipe",(e,t)=>{qt.init(e,t),Rn.init(e,t),e.in=t.in,e.out=t.out});function Zr(e,t){return new Dr({type:"pipe",in:e,out:t})}const jr=t("ZodReadonly",(e,t)=>{Ht.init(e,t),Rn.init(e,t),e.unwrap=()=>e._zod.def.innerType});const qr=t("ZodCustom",(e,t)=>{Kt.init(e,t),Rn.init(e,t)});function Gr(e,t={error:`Input not instance of ${e.name}`}){const n=new qr({type:"custom",check:"custom",fn:t=>t instanceof e,abort:!0,...x(t)});return n._zod.bag.Class=e,n}function Hr(e,t){return Zr(Tr(e),t)}function Vr(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Kr,Wr={};var Jr=(Kr||(Kr=1,function(e){var t;async function n(e){return new Promise((t,n)=>e.then(n,t))}async function r(e){return new Promise(t=>setTimeout(()=>{t(!0)},e))}function o(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 i(e,t,n=Math.random){return o(H(0,e.length-1),n).slice(0,t)}function s(e,t,n=Math.random){return Math.floor(n()*(t-e+1))+e}function a(e,t,n){return t>=e.x&&t<e.x+e.width&&n>=e.y&&n<e.y+e.height}function c(e,t=Math.random){return t()<e}function u(e,t=Math.random){return e[Math.floor(e.length*t())]}function l(e){if(!e.length)throw Error("Received empty array");return e[e.length-1]}function f(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 e of n){if(null===r[e]||void 0===r[e])return null;r=r[e]}return r}function h(e,t,n){const r=t.split(/\.|\[/);let o=e;for(let e=0;e<r.length;e++){const t=r[e],i=e<r.length-1&&r[e+1].includes("]"),s=t.includes("]")?t.replace(/\[|\]/g,""):t;if(e===r.length-1)return o[s]=n,n;m(o[s])||(o[s]=i?[]:{}),o=o[s]}return n}function p(e,t){return Math.round(e/t)*t}function m(e,t=!0){return!(!e||t&&!w(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 g(e){return m(e)&&!Array.isArray(e)}function y(e){return Array.isArray(e)&&0===e.length}function w(e){return void 0===e}function b(e){return"[object Function]"===Object.prototype.toString.call(e)||"[object AsyncFunction]"===Object.prototype.toString.call(e)}function v(e){return"[object String]"===Object.prototype.toString.call(e)}function E(e){return"number"==typeof e&&isFinite(e)}function _(e){return!0===e||!1===e}function x(e){return"[object Date]"===Object.prototype.toString.call(e)}function k(e){return!v(e)||0===e.trim().length}function A(e){return E(e)&&Number.isInteger(e)&&e>=1}function I(e){return v(e)&&null!==e.match(/^-?\d+$/)}function $(e){return v(e)&&null!==e.match(/^(0x)?[0-9a-f]+$/i)}Object.defineProperty(e,"__esModule",{value:!0}),e.Vector=e.Cache=e.Assertions=e.Strings=e.Types=e.Objects=e.Dates=e.Promises=e.Numbers=e.System=e.Arrays=e.Random=e.Elliptic=e.Binary=e.Lock=e.Solver=e.RollingValueProvider=e.TrieRouter=e.AsyncQueue=e.PubSubChannel=e.FixedPointNumber=e.MerkleTree=e.Chunk=e.Uint8ArrayWriter=e.Uint8ArrayReader=e.AsyncLazy=e.Lazy=e.Optional=void 0;const B="!@#$%^&*()_+-=[]{}|;:<>?,./".split(""),z="abcdefghijklmnopqrstuvwxyz",S=z+"ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890",O=S+"!@#$%^&*()_+-=[]{}|;:<>?,./",T=["—","\\","東","京","都","𝖆","𝖇","𝖈","👾","🙇","💁","🙅","ᚠ","ᛇ","ᚻ","ᛦ"],N="0123456789abcdef";function R(e,t){if(k(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 U(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&&U(e,t),e;if(!v(e)||!e.match(/^-?\d+(\.\d+)?$/))throw new TypeError(`Expected number${t?.name?` for ${t.name}`:""}, got: `+e);const n=parseFloat(e);return t&&U(n,t),n}function F(e,t){return Math.trunc(P(e,t))}function C(e,t){if(!g(e))throw new TypeError(`Expected object${t?.name?` for ${t.name}`:""}, got: `+e);return e}function L(e){return v(e)&&null!==e.match(/^https?:\/\/.+/)}function M(e){return"bigint"==typeof e}function D(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 Z(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(g(e)&&g(t))for(const n in t)g(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 q(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 G(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 V(e,t=()=>!1){return e.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"").split("").map(e=>/[a-z0-9]/.test(e)||t(e)?e:"-").join("").replace(/-+/g,"-").replace(/^-|-$/g,"")}function K(e,t){if(0===t.length)return 0;const n=e.toLowerCase(),r=t.toLowerCase();return e===t?1e4:n.startsWith(r)?1e4-e.length:n.includes(r)?5e3-e.length:new RegExp(".*"+r.split("").join(".*")+".*").test(n)?1e3-e.length:0}const W={"&amp;":"&","&quot;":'"',"&apos;":"'","&gt;":">","&lt;":"<"};function J(e,t){const n=e.indexOf(t);return-1===n?null:e.slice(0,n)}function X(e,t){const n=e.indexOf(t);return-1===n?null:e.slice(n+t.length)}function Y(e,t){const n=e.lastIndexOf(t);return-1===n?null:e.slice(0,n)}function Q(e,t){const n=e.lastIndexOf(t);return-1===n?null:e.slice(n+t.length)}function ee(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 te(e,t){let n=[e];for(const e of t)n=n.flatMap(t=>t.split(e));return n.filter(e=>e)}function ne(e){const t=l(e.split(/\\|\//g)),n=t.lastIndexOf(".",t.length-1);return n<=0?"":t.slice(n+1)}function re(e){const t=l(e.split(/\\|\//g)),n=t.lastIndexOf(".",t.length-1);return n<=0?t:t.slice(0,n)}function oe(e){return e.split("\n").map(e=>e.trim().replace(/\s+/g," ")).filter(e=>e.length>0).join("\n")}function ie(e){return e.charAt(0).toUpperCase()+e.slice(1)}function se(e){return e.charAt(0).toLowerCase()+e.slice(1)}function ae(e){if(!e)return!1;const t=e.charCodeAt(0);return t>=65&&t<=90||t>=97&&t<=122}function ce(e){if(!e)return!1;const t=e.charCodeAt(0);return t>=48&&t<=57}function ue(e){return ae(e)||ce(e)}const le=" \n\t\r.,?!:;\"'`(){}[]~@#$%^&*-+=|<>/\\".split("");function fe(e){return le.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 he(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 n of t)if(n instanceof RegExp){const t=de(e,n,r);if(!t)return!1;r=t.index+t.match.length}else{const t=e.indexOf(n,r);if(-1===t)return!1;r=t+n.length}return!0}function pe(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 me(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 ge(e,t=0){for(let n=t;n<e.length;n++)if(fe(e[n]))return n;return-1}function ye(e,t=0){for(let n=t;n<e.length;n++)if("#"===e[n]&&ue(e[n+1]))return n;return-1}function we(e,t,n=0){return e.slice(0,n).lastIndexOf(t)}function be(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 ve(e,t){const n=t.wordBoundary?me(e,[`${t.opening} `,`${t.opening}\n`],t.start||0):e.indexOf(t.opening,t.start||0);if(-1===n)return null;const r=be(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+/",_e="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";function xe(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 ke(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 Ae(e,t,n){const r=[];for(const o of n)o!==t&&r.push(e.replace(t,o));return r}function Ie(e){const t=e.lastIndexOf(" ");return-1===t?{line:e,rest:""}:{line:e.slice(0,t),rest:e.slice(t+1)}}function $e(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 Be(e,t){return new RegExp(`\\b${t}\\b`).test(e)}function ze(e,t,n=[]){let r="";for(;t<e.length&&(ue(e[t])||n.includes(e[t]));)r+=e[t++];return r}function Se(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=ze(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 Oe(e,t="$",n=":"){let r=e.indexOf(t);for(;-1!==r;){const o=ze(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=ze(e,r+o.length+2);e=e.replace(`${t}${o}${n}${i}`,i)}r=e.indexOf(t,r+1)}return e}function Te(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 Ne(e){return String(Math.floor(e)).padStart(2,"0")}function Re(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?`${Ne(t)}:${Ne(n)}:${Ne(r)}`:`${Ne(n)}:${Ne(r)}`}function Ue(e){return Math.floor((x(e)?e.getTime():e)/864e5)}const Pe={today:(e,t)=>Ne(e)+":"+Ne(t),yesterday:()=>"Yesterday",monday:()=>"Mon",tuesday:()=>"Tue",wednesday:()=>"Wed",thursday:()=>"Thu",friday:()=>"Fri",saturday:()=>"Sat",sunday:()=>"Sun",weeks:e=>`${e}w`},Fe={now:()=>"A few seconds",seconds:e=>`${e} seconds`,minutes:e=>`${e} minutes`,hours:e=>`${e} hours`,days:e=>`${e} days`,weeks:e=>`${e} weeks`};function Ce(t,n){const r=n?.now??Date.now(),o=n?.labels||Fe;let i=(r-(e.Types.isDate(t)?t.getTime():t))/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 Le={},Me={s:1e3,m:6e4,h:36e5,d:864e5},De={0:"sunday",1:"monday",2:"tuesday",3:"wednesday",4:"thursday",5:"friday",6:"saturday"};function Ze(e){return{zeroBasedIndex:e,day:De[e]}}function je(e){return Ze(e.getDay())}const qe={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},Ge={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},He=new Map;function Ve(e,t=!1){e=e.filter(e=>e),t&&v(e[1])&&(e[1]="../"+e[1]);let n="";v(e[0])&&e[0].includes("://")&&(n=J(e[0],"://")??"",e[0]=X(e[0],"://")??"");const r=e.map(e=>String(e)).flatMap(e=>e.split("/")),o=[];for(let e=0;e<r.length;e++)"."!==r[e]&&(".."===r[e]?(!n||o.length>1)&&o.pop():o.push(r[e]));return(n?n+"://":"")+o.join("/").replaceAll(/\/{2,}/g,"/")}function Ke(e){const t=Object.keys(e).sort((e,t)=>e.localeCompare(t)),n={};for(const r of t)n[r]=Je(e[r]);return n}function We(e){const t=[];return e.sort((e,t)=>JSON.stringify(Je(e)).localeCompare(JSON.stringify(Je(t)))).forEach(e=>t.push(Je(e))),t}function Je(e){return Array.isArray(e)?We(e):m(e)?Ke(e):e}function Xe(e,t){return JSON.stringify(Je(e))===JSON.stringify(Je(t))}function Ye(e){const t=Object.keys(e);return t[Math.floor(Math.random()*t.length)]}const Qe=[1e3,1e6,1e9,1e12,1e15,1e18,1e21,1e24,1e27,1e30,1e9,1e16,1e18,1e18,1e18,1e33],et=["thousand","million","billion","trillion","quadrillion","quintillion","sextillion","septillion","octillion","nonillion","gwei","bzz","btc","eth","dai","decillion"],tt=["K","M","B","T","Qa","Qi","Sx","Sp","O","N","gwei","bzz","eth","btc","dai","D"];function nt(e){const t=parseFloat(e);if(isNaN(t))throw Error("makeNumber got NaN for input");const n=e.replace(/^-?[0-9.]+/,"").trim(),r=tt.findIndex(e=>e.toLowerCase()===n.toLowerCase());return-1===r?t:t*Qe[r]}function rt(e,t,n){return e<t?t:e>n?n:e}function ot(e,t,n){return e+(n?"["+t+"]":(e.length?".":"")+t)}function it(e,t,n,r,o){if(!m(t))return t;for(const[i,s]of Object.entries(t)){const t=ot(n,i,r);Array.isArray(s)?o?it(e,s,t,!0,o):e[t]=s.map(e=>it(Array.isArray(e)?[]:{},e,"",!1,o)):m(s)?it(e,s,t,!1,o):e[t]=s}return e}function st(e,t){const n={};for(const r of e)n[t(r)]=r;return n}function at(e,t){const n=Math.ceil(e.length/t),r=[];for(let t=0;t<e.length;t+=n)r.push(e.slice(t,t+n));return r}function ct(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 ut(e,t){return Object.fromEntries(Object.entries(e).sort(t))}function lt(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 ft(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}}e.Optional=dt,e.Lazy=class{constructor(e){this.supplier=e,this.value=null}get(){return this.value||(this.value=this.supplier()),this.value}},e.AsyncLazy=class{constructor(e){this.supplier=e,this.value=null}async get(){return this.value||(this.value=await this.supplier()),this.value}};class ht{constructor(e){this.value=e,this.children=[]}}function pt(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 mt(...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 gt(e){return 137===e[0]&&80===e[1]&&78===e[2]&&71===e[3]}function yt(e){return 255===e[0]&&216===e[1]}function wt(e){return 87===e[8]&&69===e[9]&&66===e[10]&&80===e[11]}function bt(e,t){const n=new ArrayBuffer(8);return new DataView(n).setBigUint64(0,BigInt(e),"LE"===t),new Uint8Array(n)}function vt(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 e=31;e>=0;e--)n[e]=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 t=0;t<32;t++)n=n<<8n|BigInt(e[t]);return n}function _t(e,t){const n=[];for(let r=0;r<e.length;r+=t)n.push(e.subarray(r,r+t));return n}const xt=[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 kt(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],d=l^(o<<1|i>>>31),h=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),E=u^(r<<1|n>>>31);e[0]^=d,e[1]^=h,e[2]^=p,e[3]^=m,e[4]^=g,e[5]^=y,e[6]^=w,e[7]^=b,e[8]^=v,e[9]^=E,e[10]^=d,e[11]^=h,e[12]^=p,e[13]^=m,e[14]^=g,e[15]^=y,e[16]^=w,e[17]^=b,e[18]^=v,e[19]^=E,e[20]^=d,e[21]^=h,e[22]^=p,e[23]^=m,e[24]^=g,e[25]^=y,e[26]^=w,e[27]^=b,e[28]^=v,e[29]^=E,e[30]^=d,e[31]^=h,e[32]^=p,e[33]^=m,e[34]^=g,e[35]^=y,e[36]^=w,e[37]^=b,e[38]^=v,e[39]^=E,e[40]^=d,e[41]^=h,e[42]^=p,e[43]^=m,e[44]^=g,e[45]^=y,e[46]^=w,e[47]^=b,e[48]^=v,e[49]^=E;const _=e[0],x=e[1],k=e[2]<<1|e[3]>>>31,A=e[3]<<1|e[2]>>>31,I=e[5]<<30|e[4]>>>2,$=e[4]<<30|e[5]>>>2,B=e[6]<<28|e[7]>>>4,z=e[7]<<28|e[6]>>>4,S=e[8]<<27|e[9]>>>5,O=e[9]<<27|e[8]>>>5,T=e[11]<<4|e[10]>>>28,N=e[10]<<4|e[11]>>>28,R=e[13]<<12|e[12]>>>20,U=e[12]<<12|e[13]>>>20,P=e[14]<<6|e[15]>>>26,F=e[15]<<6|e[14]>>>26,C=e[17]<<23|e[16]>>>9,L=e[16]<<23|e[17]>>>9,M=e[18]<<20|e[19]>>>12,D=e[19]<<20|e[18]>>>12,Z=e[20]<<3|e[21]>>>29,j=e[21]<<3|e[20]>>>29,q=e[22]<<10|e[23]>>>22,G=e[23]<<10|e[22]>>>22,H=e[25]<<11|e[24]>>>21,V=e[24]<<11|e[25]>>>21,K=e[26]<<25|e[27]>>>7,W=e[27]<<25|e[26]>>>7,J=e[29]<<7|e[28]>>>25,X=e[28]<<7|e[29]>>>25,Y=e[31]<<9|e[30]>>>23,Q=e[30]<<9|e[31]>>>23,ee=e[33]<<13|e[32]>>>19,te=e[32]<<13|e[33]>>>19,ne=e[34]<<15|e[35]>>>17,re=e[35]<<15|e[34]>>>17,oe=e[36]<<21|e[37]>>>11,ie=e[37]<<21|e[36]>>>11,se=e[38]<<8|e[39]>>>24,ae=e[39]<<8|e[38]>>>24,ce=e[40]<<18|e[41]>>>14,ue=e[41]<<18|e[40]>>>14,le=e[42]<<2|e[43]>>>30,fe=e[43]<<2|e[42]>>>30,de=e[45]<<29|e[44]>>>3,he=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]=_^~R&H,e[1]=x^~U&V,e[2]=R^~H&oe,e[3]=U^~V&ie,e[4]=H^~oe&ge,e[5]=V^~ie&ye,e[6]=oe^~ge&_,e[7]=ie^~ye&x,e[8]=ge^~_&R,e[9]=ye^~x&U,e[10]=B^~M&Z,e[11]=z^~D&j,e[12]=M^~Z&ee,e[13]=D^~j&te,e[14]=Z^~ee&de,e[15]=j^~te&he,e[16]=ee^~de&B,e[17]=te^~he&z,e[18]=de^~B&M,e[19]=he^~z&D,e[20]=k^~P&K,e[21]=A^~F&W,e[22]=P^~K&se,e[23]=F^~W&ae,e[24]=K^~se&ce,e[25]=W^~ae&ue,e[26]=se^~ce&k,e[27]=ae^~ue&A,e[28]=ce^~k&P,e[29]=ue^~A&F,e[30]=S^~T&q,e[31]=O^~N&G,e[32]=T^~q&ne,e[33]=N^~G&re,e[34]=q^~ne&pe,e[35]=G^~re&me,e[36]=ne^~pe&S,e[37]=re^~me&O,e[38]=pe^~S&T,e[39]=me^~O&N,e[40]=I^~C&J,e[41]=$^~L&X,e[42]=C^~J&Y,e[43]=L^~X&Q,e[44]=J^~Y&le,e[45]=X^~Q&fe,e[46]=Y^~le&I,e[47]=Q^~fe&$,e[48]=le^~I&C,e[49]=fe^~$&L,e[0]^=xt[2*t],e[1]^=xt[2*t+1]}}function At(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 It(e,t){if(!e.length){const e=new Uint8Array(136);return e[0]=t,e[135]=128,[At(e)]}const n=_t(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(At)}function $t(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];kt(e)}return e}function Bt(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 zt(e){return Bt($t(new Array(50).fill(0),It(e,1)))}function St(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 Ot(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 Tt(e,t){return(e%t+t)%t}function Nt(e,t){e=Tt(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&&(n+=t),n}function Rt(e,t){return 0n===Tt(e,t)?0n:t%4n==3n?function(e,t,n){let r=1n;for(e=Tt(e,n);t>0;)t%2n==1n&&(r=Tt(r*e,n)),e=Tt(e*e,n),t/=2n;return r}(e,(t+1n)/4n,t):null}const Ut=0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2fn,Pt=0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n,Ft=0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798n,Ct=0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8n;function Lt(e,t,n){if(0n===t)return[0n,0n];const r=Tt(3n*e*e*Nt(2n*t,n),n),o=Tt(r*r-2n*e,n);return[o,Tt(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===Tt(-r,o))return[0n,0n];if(e===n&&t===r)return Lt(e,t,o);const i=Tt((r-t)*Nt(n-e,o),o),s=Tt(i*i-e-n,o);return[s,Tt(i*(e-s)-t,o)]}function Dt(e,t,n,r){let o=[0n,0n],i=[e,t];const s=n.toString(2);for(const e of s)"0"===e?(i=Mt(o[0],o[1],i[0],i[1],r),o=Lt(o[0],o[1],r)):(o=Mt(o[0],o[1],i[0],i[1],r),i=Lt(i[0],i[1],r));return o}function Zt(e,t,n){if(t<=0n||t>=Pt)throw new Error("Invalid private key");if(n||(n=Tt(Et(zt(mt(zt(vt(t,"BE")),vt(e,"BE"))),"BE"),Pt)),n<=0n||n>=Pt)throw new Error("Invalid nonce");const r=Tt(e,Pt),o=Dt(Ft,Ct,n,Ut),i=Tt(o[0],Pt);let s=Tt((r+Tt(i,Pt)*t)*Nt(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&&(s=Pt-s,a=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}}e.Uint8ArrayReader=jt;class qt{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}}e.Uint8ArrayWriter=qt;class Gt{constructor(e,t=0n){this.span=t,this.writer=new qt(new Uint8Array(e))}build(){return mt(bt(this.span,"LE"),this.writer.buffer)}hash(){const e=pt(_t(this.writer.buffer,32),(e,t)=>Gt.hashFunction(mt(e,t)));return Gt.hashFunction(mt(bt(this.span,"LE"),e))}}e.Chunk=Gt,Gt.hashFunction=zt;class Ht{constructor(e,t=4096){this.counters=[1],this.capacity=t,this.chunks=[new Gt(t)],this.onChunk=e}static async root(e,n=4096){const r=new t(t.NOOP,n);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 Gt(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 Gt(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])}}e.MerkleTree=Ht,t=Ht,Ht.NOOP=async e=>{};class Vt{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 Vt)return e;const t=D(e.value),n=P(e.scale);return new Vt(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 Vt(BigInt(n+r),t)}static fromFloat(e,t){return Vt.fromDecimalString(e.toString(),t)}add(e){return this.assertSameScale(e),new Vt(this.value+e.value,this.scale)}subtract(e){return this.assertSameScale(e),new Vt(this.value-e.value,this.scale)}multiply(e){return new Vt(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 Vt(t,this.scale),new Vt(n,this.scale)]}exchange(e,t,n){if("*"===e){const e=this.value*t.value/10n**BigInt(this.scale);return new Vt(e,n)}this.assertSameScale(t);const r=this.value*10n**BigInt(n)/t.value;return new Vt(r,n)}compare(e){return this.assertSameScale(e),this.value>e.value?1:this.value<e.value?-1:0}toDecimalString(){if(0===this.scale)return this.value.toString();const e=this.value.toString();return`${e.slice(0,-this.scale)||"0"}.${e.slice(-this.scale).padStart(this.scale,"0")}`}toString(){return this.value.toString()}toJSON(){return this.toString()}toFloat(){return parseFloat(this.toDecimalString())}assertSameScale(e){if(this.scale!==e.scale)throw new Error(`Scale mismatch: expected ${this.scale}, but got ${e.scale}`)}}function Kt(e,t,n,r){const o=e.findIndex(e=>e===`--${t}`||e.startsWith(`--${t}=`)),i=e[o];if(!i)return(n||{})[r||t||""]||null;if(i.includes("="))return i.split("=")[1];const s=e[o+1];return s&&!s.startsWith("-")?s:(n||{})[r||t||""]||null}function Wt(e,t,n,r){const o=Kt(e,t,n,r);if(!o)throw new Error(`Missing argument ${t}`);return o}function Jt(e,t){const n=e[t];e.splice(t,1),e.unshift(n)}function Xt(e,t){return{x:e.x+t.x,y:e.y+t.y}}function Yt(e,t){return{x:e.x*t,y:e.y*t}}function Qt(e,t,n){return{x:e.x+Math.cos(t)*n,y:e.y+Math.sin(t)*n}}function en(e,t){return Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2)}function tn(e,t,n="row-first"){const r=[];if("column-first"===n)for(let n=0;n<e.length;n++)for(let o=0;o<e[0].length;o++)t(n,o)&&r.push({x:n,y:o});else for(let n=0;n<e[0].length;n++)for(let o=0;o<e.length;o++)t(o,n)&&r.push({x:o,y:n});return r}function nn(e,t,n){return!e[t-1]?.[n]}function rn(e,t,n){return!e[t+1]?.[n]}function on(e,t,n){return!e[t][n-1]}function sn(e,t,n){return!e[t][n+1]}function an(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]&&nn(e,t,n)&&on(e,t,n)&&r.push({x:t,y:n}),!e[t+1]?.[n-1]&&rn(e,t,n)&&on(e,t,n)&&r.push({x:t+1,y:n}),!e[t-1]?.[n+1]&&nn(e,t,n)&&sn(e,t,n)&&r.push({x:t,y:n+1}),!e[t+1]?.[n+1]&&rn(e,t,n)&&sn(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 cn(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 un(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=a/o,s=c/o,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 ln(e,t,n){const r=[],o=Qt(e,n,1e4);for(const n of t){const t=un(e,o,n.start,n.end);t&&r.push(t)}return r.length?r.reduce((t,n)=>en(e,n)<en(e,t)?n:t):null}e.FixedPointNumber=Vt;class fn{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}}e.PubSubChannel=fn,e.AsyncQueue=class{constructor(e,t){this.queue=[],this.running=0,this.onProcessed=new fn,this.onDrained=new fn,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(":")&&(o=":",r=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))}}e.TrieRouter=dn,e.RollingValueProvider=class{constructor(e){this.index=0,this.values=e}current(){return this.values[this.index]}next(){return this.index=(this.index+1)%this.values.length,this.values[this.index]}},e.Solver=class{constructor(){this.status="pending",this.steps=[],this.onStatusChange=async()=>{},this.onStepChange=async()=>{},this.onFinish=async()=>{},this.onError=async()=>{},this.context=new Map}getStatus(){return this.status}createInitialState(){return Object.fromEntries(this.steps.map(e=>[e.name,"pending"]))}setHooks(e){e.onStatusChange&&(this.onStatusChange=e.onStatusChange),e.onStepChange&&(this.onStepChange=e.onStepChange),e.onFinish&&(this.onFinish=e.onFinish),e.onError&&(this.onError=e.onError)}addStep(e){if(this.steps.find(t=>t.name===e.name))throw Error(`Step with name ${e.name} already exists`);this.steps.push(e)}async execute(){if("pending"!==this.status)throw Error(`Cannot execute solver in status ${this.status}`);this.status="in-progress",await this.onStatusChange(this.status);let e=this.createInitialState();for(const t of this.steps)try{if(t.transientSkipStepName){const n=e[t.transientSkipStepName];if("skipped"===n||"failed"===n){e={...e,[t.name]:"skipped"},await this.onStepChange(e);continue}}if(t.precondition&&!await t.precondition(this.context)){e={...e,[t.name]:"skipped"},await this.onStepChange(e);continue}e={...e,[t.name]:"in-progress"},await this.onStepChange(e);for(let e=0;"retry"===await t.action(this.context,e);e++);e={...e,[t.name]:"completed"},await this.onStepChange(e)}catch(n){throw e={...e,[t.name]:"failed"},this.status="failed",await this.onStatusChange(this.status),await this.onStepChange(e),await this.onError(n),n}return this.status="completed",await this.onStatusChange(this.status),await this.onFinish(),this.context}},e.Lock=class{constructor(e){this.queryFunction=e.queryFunction,this.lockFunction=e.lockFunction,this.unlockFunction=e.unlockFunction,this.timeoutMillis=e.timeoutMillis}async couldLock(){const e=await this.queryFunction();try{const t=F(e);if(Date.now()<t+this.timeoutMillis)return new Date(t+this.timeoutMillis)}catch{}return await this.lockFunction(Date.now().toString()),!0}async unlock(){await this.unlockFunction()}},e.Binary={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 xe(e,Ee)},uint8ArrayToBase64:function(e){return ke(e,Ee)},base32ToUint8Array:function(e){return xe(e,_e)},uint8ArrayToBase32:function(e){return ke(e,_e)},log2Reduce:pt,partition:_t,concatBytes:mt,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:bt,uint64ToNumber:function(e,t){return new DataView(e.buffer).getBigUint64(e.byteOffset,"LE"===t)},numberToUint256:vt,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:zt,sha3_256:function(e){return Bt($t(new Array(50).fill(0),It(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:St,padStartToMultiple:function(e,t,n=0){const r=e.length%t;return 0===r?e:St(e,e.length+t-r,n)},padEnd:Ot,padEndToMultiple:function(e,t,n=0){const r=e.length%t;return 0===r?e:Ot(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}},e.Elliptic={privateKeyToPublicKey:function(e){if(e<=0n||e>=Pt)throw new Error("Invalid private key");return Dt(Ft,Ct,e,Ut)},compressPublicKey:function(e){const t=e[1]%2n==0n?2:3;return new Uint8Array([t,...vt(e[0],"BE")])},publicKeyFromCompressed:function(e){if(33!==e.length||2!==e[0]&&3!==e[0])throw new Error("Invalid compressed public key");const t=Et(e.slice(1),"BE"),n=Rt(Tt(t**3n+7n,Ut),Ut);if(!n)throw Error("Invalid x: does not correspond to a valid curve point");const r=Tt(-n,Ut),o=n%2n==0n;return[t,2===e[0]?o?n:r:o?r:n]},publicKeyToAddress:function(e){const t=new Uint8Array(20),n=zt(mt(vt(e[0],"BE"),vt(e[1],"BE")));return t.set(n.subarray(12)),t},signMessage:function(e,t,n){return Zt(Et(zt(e),"BE"),t,n)},signHash:Zt,verifySignature:function(e,t,n,r){const o=Tt(Et(zt(e),"BE"),Pt),i=Nt(r,Pt),s=Tt(o*i,Pt),a=Tt(n*i,Pt),c=Dt(Ft,Ct,s,Ut),u=Dt(t[0],t[1],a,Ut);return n===Tt(Mt(c[0],c[1],u[0],u[1],Ut)[0],Pt)},recoverPublicKey:function(e,t,n,r){const o=Rt(Tt(t**3n+7n,Ut),Ut);if(!o)throw new Error("Invalid r: does not correspond to a valid curve point");const i=o%2n==(27n===r?0n:1n)?o:Ut-o,s=Tt(Et(zt(e),"BE"),Pt),a=Dt(t,i,n,Ut),c=Dt(Ft,Ct,s,Ut),u=Mt(a[0],a[1],c[0],Tt(-c[1],Ut),Ut);return Dt(u[0],u[1],Nt(t,Pt),Ut)},checksumEncode:function(t){const n=e.Binary.uint8ArrayToHex(t),r=e.Binary.uint8ArrayToHex(e.Binary.keccak256(new Uint8Array([...n].map(e=>e.charCodeAt(0)))));let o="0x";for(let e=0;e<n.length;e++)parseInt(r[e],16)>7?o+=n[e].toUpperCase():o+=n[e];return o}},e.Random={intBetween:s,floatBetween:function(e,t,n=Math.random){return n()*(t-e)+e},chance:c,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=s(0,e-1,r),i=s(0,t-1,r)}while(n&&a(n,o,i));return[o,i]},procs:function(e,t=Math.random){const n=Math.floor(e);return c(e-n,t)?n+1:n}},e.Arrays={countUnique:function(e,t,n,r,o){const i=t?e.map(t):e,s={};for(const e of i)s[e]=(s[e]||0)+1;const a=r?ut(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(st(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:at,index:st,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:o,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&&(b(t)?n.push(t()):n.push(t));return n},pluck:function(e,t){return e.map(e=>e[t])},pick:u,pickMany:function(e,t,n=Math.random){if(t>e.length)throw new Error(`Count (${t}) is greater than array length (${e.length})`);return i(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=u(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 n=0;n<e.length-1;n++)if(r-=t[n],o>=r)return e[n];return l(e)},pickRandomIndices:i,pickGuaranteed:function(t,n,r,i,s,a=Math.random){const c=t.filter(e=>e!==n&&e!==r),u=[];for(null!==n&&u.push(n);c.length&&u.length<i;){const t=e.Random.intBetween(0,c.length-1,a);s(c[t],u)&&u.push(c[t]),c.splice(t,1)}return o(u,a),{values:u,indexOfGuaranteed:null!==n?u.indexOf(n):-1}},last:l,pipe:f,makePipe:function(e,t){return n=>f(n,e,t)},sortWeighted:function(e,t,n=Math.random){const r=t.map(e=>n()*e),o=[];for(let t=0;t<e.length;t++)o.push([e[t],r[t]]);return o.sort((e,t)=>t[1]-e[1]).map(e=>e[0])},pushAll:G,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])&&G(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:lt,createOscillator:function(e){let t=0;return{next:()=>e[t++%e.length]}},organiseWithLimits:function(e,t,n,r,o){const i={};for(const e of Object.keys(t))i[e]=[];i[r]=[],o&&(e=e.sort(o));for(const o of e){const e=o[n],s=t[e]?e:r;i[s].length>=t[s]?i[r].push(o):i[s].push(o)}return i},tickPlaybook:function(e){if(0===e.length)return null;const t=e[0];return t.ttlMax?--t.ttl<=0&&e.shift():t.ttlMax=t.ttl,{progress:(t.ttlMax-t.ttl)/t.ttlMax,data:t.data}},getArgument:Kt,getBooleanArgument:function(e,t,n,r){const o=e.some(e=>e.endsWith("-"+t)),i=Kt(e,t,n,r);if(!i&&o)return!0;if(!i&&!o)return null;if(["true","1","yes","y","on"].includes(i.toLowerCase()))return!0;if(["false","0","no","n","off"].includes(i.toLowerCase()))return!1;throw Error(`Invalid boolean argument ${t}: ${i}`)},getNumberArgument:function(e,t,n,r){const o=Kt(e,t,n,r);if(!o)return null;try{return nt(o)}catch{throw new Error(`Invalid number argument ${t}: ${o}`)}},requireStringArgument:Wt,requireNumberArgument:function(e,t,n,r){const o=Wt(e,t,n,r);try{return nt(o)}catch{throw new Error(`Invalid argument ${t}: ${o}`)}},bringToFront:function(e,t){const n=[...e];return Jt(n,t),n},bringToFrontInPlace:Jt,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 ht(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}},e.System={sleepMillis:r,forever:async function(e,t,n){for(;;){try{await e()}catch(e){n&&n("Error in forever",e)}await r(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,o=0;for(let i=0;i<t.attempts;i++){try{if(await e()){if(o++,o>=n)return}else o=0}catch{o=0}i<t.attempts-1&&await r(t.waitMillis)}throw Error("Timed out waiting for predicate")},expandError:function(e,t){if(v(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,o,i,s){let a=null;for(let c=0;c<=t;c++)try{return await e()}catch(e){if(a=e,c===t)break;const u=n+c/(t-1)*(o-n);i&&i("Error in withRetries, retrying",{attempt:c+1,allowedFailures:t,delayMillis:u,error:e}),s&&s(),await r(u)}throw a}},e.Numbers={make:nt,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:rt,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?et:tt,i=t?.precision??1;if(e<Qe[0])return`${e}${r}`;for(let t=0;t<Qe.length-1;t++)if(e<Qe[t+1])return`${(e/Qe[t]).toFixed(i)}${n?" ":""}${o[t]}${r}`;return`${(e/Qe[Qe.length-1]).toFixed(i)}${n?" ":""}${o[Qe.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:Ge[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:p,formatDistance:function(e){return e>1e3?(e/1e3).toFixed(0)+" km":e>=500?p(e,100)+" m":e>=100?p(e,50)+" m":p(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)}`}},e.Promises={raceFulfilled:async function(e){return n(Promise.all(e.map(n)))},invert:n,runInParallelBatches:async function(e,t=1){const n=at(e,t),r=[],o=n.map(async e=>{for(const t of e)r.push(await t())});return await Promise.all(o),r}},e.Dates={getTimestamp:function(e,t){const n=new Date(t?.now||Date.now()),r=t?.labels||Pe,o=x(e)?e:new Date(e);if(Ue(n)===Ue(o))return r.today(o.getUTCHours(),o.getUTCMinutes(),o.getUTCHours()>12);if(Ue(n)-Ue(o)===1)return r.yesterday();const i=je(o);return Ue(n)-Ue(o)<7?r[i.day]():r.weeks(Math.round((n.getTime()-o.getTime())/6048e5))},getTimeDelta:Ce,secondsToHumanTime:function(e,t=Fe){return Ce(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(!Le[e]||Date.now()>Le[e])&&(Le[e]=Date.now()+t,!0)},timeSince:function(e,t,n){return t=x(t)?t.getTime():t,((n=n?x(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:Re,humanizeProgress:function(e){return`[${Math.floor(100*e.progress)}%] ${Re(e.deltaMs)} out of ${Re(e.totalTimeMs)} (${Re(e.remainingTimeMs)} left) [${Math.round(e.baseTimeMs)} ms each]`},createTimeDigits:Ne,mapDayNumber:Ze,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:qe[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=rt(F(t),0,23),o=rt(F(n),0,59);return`${Ne(r)}:${Ne(o)}`},absoluteDays:Ue},e.Objects={safeParse:function(e){try{return JSON.parse(e)}catch{return null}},deleteDeep:function(e,t){const n=Y(t,"."),r=Q(t,".");if(!n||!r)return;const o=d(e,n);o&&delete o[r]},getDeep:d,setDeep:h,incrementDeep:function(e,t,n=1){const r=d(e,t)||0;return h(e,t,r+n),r},ensureDeep:function(e,t,n){return d(e,t)||h(e,t,n)},replaceDeep:function(e,t,n){const r=d(e,t);if(!r)throw new Error("Key '"+t+"' does not exist.");return h(e,t,n),r},getFirstDeep:function(e,t,n){for(const n of t){const t=d(e,n);if(t)return t}if(n){const t=Object.values(e);if(t.length)return t[0]}return null},deepMergeInPlace:j,deepMerge2:function(e,t){const n={};return j(n,e),j(n,t),n},deepMerge3:function(e,t,n){const r={};return j(r,e),j(r,t),j(r,n),r},mapAllAsync:async function(e,t){const n=[];for(const r of e)n.push(await t(r));return n},cloneWithJson:function(e){return JSON.parse(JSON.stringify(e))},sortObject:Ke,sortArray:We,sortAny:Je,deepEquals:Xe,deepEqualsEvery:function(...e){for(let t=1;t<e.length;t++)if(!Xe(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:q,zipSum:function(e){return q(e,(e,t)=>e+t)},removeEmptyArrays:function(e){for(const t of Object.keys(e))(y(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]||v(t[1])&&k(t[1]))&&delete e[t[0]];return e},flatten:function(e,t=!1,n){return it({},e,n||"",!1,t)},unflatten:function e(t){if(!m(t))return t;const n=Array.isArray(t)?[]:{};for(const[r,o]of Object.entries(t))Array.isArray(o)?h(n,r,o.map(t=>e(t))):h(n,r,o);return n},match:function(e,t,n){return t[e]?t[e]:n},sort:ut,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&&h(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 e=0;e<n.length-1;e++)o*=n[e],i.push(o);const s=[];for(let n=0;n<r;n++){const r={};for(let o=0;o<t.length;o++){const s=e[t[o]],a=Math.floor(n/i[o])%s.length;r[t[o]]=s[a]}s.push(r)}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:ft,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){ft(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:Ye,mapRandomKey:function(e,t){const n=Ye(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:Te,parseQueryString:function(e){const t={},n=e.split("&");for(const e of n){const[n,r]=e.split("=");n&&r&&(t[n]=decodeURIComponent(r))}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=>ee(e,t)).map(e=>e[0]&&e[1]?[oe(e[0]),oe(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)}},e.Types={isFunction:b,isObject:m,isStrictlyObject:g,isEmptyArray:y,isEmptyObject:function(e){return g(e)&&0===Object.keys(e).length},isUndefined:w,isString:v,isNumber:E,isBoolean:_,isDate:x,isBlank:k,isId:A,isIntegerString:I,isHexString:$,isUrl:L,isBigint:M,isNullable:function(e,t){return null==t||e(t)},asString:R,asHexString:function(e,t){if(!$(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(!R(e,t).split("").every(e=>"_"===e||ue(e)))throw new TypeError(`Expected safe string${t?.name?` for ${t.name}`:""}, got: `+e);return e},asIntegerString:function(e,t){if(!I(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(!b(e))throw new TypeError(`Expected function${t?.name?` for ${t.name}`:""}, got: `+e);return e},asInteger:F,asBoolean:function(e,t){if("true"===e)return!0;if("false"===e)return!1;if(!_(e))throw new TypeError(`Expected boolean${t?.name?` for ${t.name}`:""}, got: `+e);return e},asDate:function(e,t){if(!x(e))throw new TypeError(`Expected date${t?.name?` for ${t.name}`:""}, got: `+e);return e},asNullableString:function(e){return k(e)?null:e},asEmptiableString:function(e,t){if(!v(e))throw new TypeError(`Expected string${t?.name?` for ${t.name}`:""}, got: `+e);return e},asId:function(e,t){if(A(e))return e;const n=parseInt(e,10);if(!A(n))throw new TypeError(`Expected id${t?.name?` for ${t.name}`:""}, got: `+e);return n},asTime:function(e,t){if(!v(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:C,asNullableObject:function(e,t){return null===e?null:C(e,t)},asStringMap:function(e,t){const n=C(e,t);for(const r of Object.keys(n))if(!v(n[r]))throw new TypeError(`Expected string map${t?.name?` for ${t.name}`:""}, got: `+e);return n},asNumericDictionary:function(e,t){const n=C(e),r=Object.keys(n),o=Object.values(n);if(!r.every(v)||!o.every(E))throw new TypeError(`Expected numeric dictionary${t?.name?` for ${t.name}`:""}, got: `+e);return n},asUrl:function(e,t){if(!L(e))throw new TypeError(`Expected url${t?.name?` for ${t.name}`:""}, got: `+e);return e},asBigint:D,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:Z,enforceArrayShape:function(e,t){return e.every(e=>Z(e,t))},isPng:gt,isJpg:yt,isWebp:wt,isImage:function(e){return gt(e)||yt(e)||wt(e)}},e.Strings={tokenizeByCount:function(e,t){return ct(e,Math.ceil(e.length/t))},tokenizeByLength:ct,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=B){const r=te(e,n);for(const e of r)if(t(e))return e;return null},randomHex:function(e,t=Math.random){let n="";for(let r=0;r<e;r++)n+=N[Math.floor(16*t())];return n},randomLetter:function(e,t=Math.random){let n="";for(let r=0;r<e;r++)n+=z[Math.floor(26*t())];return n},randomAlphanumeric:function(e,t=Math.random){let n="";for(let r=0;r<e;r++)n+=S[Math.floor(62*t())];return n},randomRichAscii:function(e,t=Math.random){let n="";for(let r=0;r<e;r++)n+=O[Math.floor(89*t())];return n},randomUnicode:function(e,t=Math.random){let n="";for(let r=0;r<e;r++)n+=T[Math.floor(t()*T.length)];return n},includesAny:function(e,t){return t.some(t=>e.includes(t))},slugify:V,normalForm:function(e){return V(e).replaceAll("-","")},enumify:function(e){return V(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[e,n]of Object.entries(W))t=t.replaceAll(e,n);return t},after:X,afterLast:Q,before:J,beforeLast:Y,betweenWide:function(e,t,n){const r=Y(e,n);return r?X(r,t):null},betweenNarrow:function(e,t,n){const r=X(e,t);return r?J(r,n):null},getPreLine:function(e){return e.replace(/ +/g," ").replace(/^ /gm,"")},containsWord:Be,containsWords:function(e,t,n){return"any"===n?t.some(t=>Be(e,t)):t.every(t=>Be(e,t))},joinUrl:Ve,getFuzzyMatchScore:K,sortByFuzzyScore:function(e,t){return e.filter(e=>K(e,t)).sort((e,n)=>K(n,t)-K(e,t))},splitOnce:ee,splitAll:te,randomize:function(e,t=Math.random){return e.replace(/\{(.+?)\}/g,(e,n)=>u(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 t of r){const n=e(o+t+i);s=s.concat(n)}return s},shrinkTrim:oe,capitalize:ie,decapitalize:se,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 e of s)e!==t||i?e!==n||(o||i)&&!i?o+=e:i=!i:(r.push(o),o="");return r.push(o),r},surroundInOut:function(e,t){return t+e.split("").join(t)+t},getExtension:ne,getBasename:re,normalizeEmail:function(e){let[t,n]=e.split("@");t=oe(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=oe(n.toLowerCase()).replaceAll(" ",""),`${r}@${n}`},normalizeFilename:function(e){const t=re(e),n=ne(e);return n?`${t}.${n}`:t},parseFilename:function(e){const t=re(e),n=ne(e);return{basename:t,extension:n,filename:n?`${t}.${n}`:t}},camelToTitle:function(e){return ie(e.replace(/([A-Z])/g," $1"))},slugToTitle:function(e){return e.split("-").map(ie).join(" ")},slugToCamel:function(e){return se(e.split("-").map(ie).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:be,extractBlock:ve,extractAllBlocks:function(e,t){const n=[];let r=t.wordBoundary?me(e,[`${t.opening} `,`${t.opening}\n`],t.start||0):e.indexOf(t.opening,t.start||0);for(;;){if(-1===r)return n;const o=ve(e,{...t,start:r});if(!o)return n;n.push(o),r=t.wordBoundary?me(e,[`${t.opening} `,`${t.opening}\n`],r+o.length):e.indexOf(t.opening,r+o.length)}},replaceBlocks:function(t,n,r){let o=0;for(;;){const i=e.Strings.extractBlock(t,{...r,start:o});if(!i)return t;const s=n(i);o=t.indexOf(i,o)+s.length,t=t.replace(i,s)}},indexOfEarliest:me,lastIndexOfBefore:we,parseHtmlAttributes:function(e){const t={},n=e.match(/([a-z\-]+)="([^"]+)"/g);if(n)for(const e of n){const[n,r]=ee(e,"=");t[n]=r.slice(1,r.length-1)}return t},readNextWord:ze,readWordsAfterAll:function(e,t,n=[]){const r=pe(e,t),o=[];for(const i of r)o.push(ze(e,i+t.length,n));return o},resolveVariables:function(e,t,n="$",r=":"){for(const o in t)e=Se(e,o,t[o],n,r);return e=Oe(e)},resolveVariableWithDefaultSyntax:Se,resolveRemainingVariablesWithDefaults:Oe,isLetter:ae,isDigit:ce,isLetterOrDigit:ue,isValidObjectPathCharacter:function(e){return ue(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:pe,lineMatches:he,linesMatchInOrder:function(e,t,n=!0){let r=0;for(const o of t){let t=!1;for(;!t&&r<e.length;)he(e[r],o,n)&&(t=!0),r++;if(!t)return!1}return!0},represent:function e(t,n="json",r=0){if(t&&b(t.represent)){const e=t.represent();if(v(e))return"json"===n&&0===r?JSON.stringify(e):e}if(m(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 w(t)&&(t="undefined"),0===r?JSON.stringify(t):t},resolveMarkdownLinks:function(e,t){let n=e.indexOf("](");for(;-1!==n;){const r=we(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 Ve([e,t])+Te(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=ye(e,n);if(-1===r){t.push({string:e.slice(n),symbol:null});break}const o=ge(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=me(e,["http://","https://"],n);if(-1===r){t.push({string:e.slice(n),symbol:null});break}const o=me(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 e=0;e<n.length;e++){const t=n[e];if(t.startsWith(":"))o[t.slice(1)]=r[e];else if(t!==r[e])return null}return o},explodeReplace:Ae,generateVariants:function(t,n,r,o=Math.random){const i=e.Arrays.shuffle(n.map(t=>({variants:e.Arrays.shuffle(t.variants.map(e=>e),o),avoid:t.avoid})),o),s=[];for(const e of i){const n=e.variants.filter(t=>t!==e.avoid),o=n.find(e=>t.includes(e));if(o&&(G(s,Ae(t,o,n)),s.length>=r))break}if(s.length<r)for(const e of i){const n=e.variants.find(e=>t.includes(e));if(n&&(G(s,Ae(t,n,e.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:Ie,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}=Ie(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 t=0;t<=e.length;t++)n[t]=[t];for(let e=0;e<=t.length;e++)n[0][e]=e;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:$e,findCommonDirectory:function(e){const t=$e(e),n=t.lastIndexOf("/");return-1===n?"":t.slice(0,n+1)}},e.Assertions={asEqual:function(e,t){if(e!==t)throw Error(`Expected [${e}] to equal [${t}]`);return[e,t]},asTrue:function(e){if(!0!==e)throw Error(`Expected [true], got: [${e}]`);return e},asTruthy:function(e){if(!e)throw Error(`Expected truthy value, got: [${e}]`);return e},asFalse:function(e){if(!1!==e)throw Error(`Expected [false], got: [${e}]`);return e},asFalsy:function(e){if(e)throw Error(`Expected falsy value, got: [${e}]`);return e},asEither:function(e,t){if(!t.includes(e))throw Error(`Expected any of [${t.join(", ")}], got: [${e}]`);return e}},e.Cache={get:async function(e,t,n,r){const o=Date.now(),i=He.get(e);if(i&&i.validUntil>o)return i.value;r?.onMiss?.();try{const r=await n();return He.set(e,{value:r,validUntil:o+t}),r}catch(e){throw r?.onFailure?.(e),e}},getDeferred:function(e,t,n,r){const o=Date.now(),i=He.get(e);if(i&&i.validUntil>o)return i.value;r?.onMiss?.();const s=n();return He.set(e,{value:s,validUntil:o+t}),s.catch(t=>{He.delete(e),r?.onFailure?.(t)}),s},delete:function(e){He.delete(e)},deleteExpired:function(){const e=Date.now();for(const[t,n]of He.entries())n.validUntil<=e&&He.delete(t)},size:function(){return He.size},clear:function(){He.clear()}},e.Vector={addPoint:Xt,subtractPoint:function(e,t){return{x:e.x-t.x,y:e.y-t.y}},multiplyPoint:Yt,normalizePoint:function(e){const t=Math.sqrt(e.x*e.x+e.y*e.y);return{x:e.x/t,y:e.y/t}},pushPoint:Qt,filterCoordinates:tn,findCorners:function(e,t,n,r){const o=[{x:0,y:0},{x:n,y:0},{x:0,y:r},{x:n,y:r}];for(let t=0;t<e.length;t++)for(let n=0;n<e[0].length;n++){const r=an(e,t,n);for(const e of r)o.some(t=>t.x===e.x&&t.y===e.y)||o.push(e)}return o.map(e=>({x:e.x*t,y:e.y*t}))},findLines:function(e,t){const n=tn(e,(t,n)=>0===e[t][n]&&0!==e[t][n+1],"row-first").map(e=>({...e,dx:1,dy:0})),r=tn(e,(t,n)=>0===e[t][n]&&0!==e[t][n-1],"row-first").map(e=>({...e,dx:1,dy:0})),o=tn(e,(t,n)=>0===e[t][n]&&0!==e[t-1]?.[n],"column-first").map(e=>({...e,dx:0,dy:1})),i=tn(e,(t,n)=>0===e[t][n]&&0!==e[t+1]?.[n],"column-first").map(e=>({...e,dx:0,dy:1}));return n.forEach(e=>e.y++),i.forEach(e=>e.x++),[...lt([...o,...i],(e,t)=>e.x===t.x&&e.y-1===t.y),...lt([...r,...n],(e,t)=>e.y===t.y&&e.x-1===t.x)].map(e=>({start:e[0],end:l(e)})).map(e=>({start:Yt(e.start,t),end:Yt(Xt(e.end,{x:e.start.dx,y:e.start.dy}),t)}))},raycast:ln,raycastCircle:function(e,t,n){const r=cn(e,n),o=[];for(const n of r){const r=ln(e,t,n-.001),i=ln(e,t,n+.001);r&&o.push(r),i&&o.push(i)}return o},getLineIntersectionPoint:un}}(Wr)),Wr);const Xr="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0;
2
- /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Yr(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function Qr(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function eo(e,...t){if(!Yr(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 to(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.createHasher");Qr(e.outputLen),Qr(e.blockLen)}function no(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 ro(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function oo(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function io(e,t){return e<<32-t|e>>>t}const so=(()=>"function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex)(),ao=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function co(e){if(eo(e),so)return e.toHex();let t="";for(let n=0;n<e.length;n++)t+=ao[e[n]];return t}const uo=48,lo=57,fo=65,ho=70,po=97,mo=102;function go(e){return e>=uo&&e<=lo?e-uo:e>=fo&&e<=ho?e-(fo-10):e>=po&&e<=mo?e-(po-10):void 0}function yo(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);if(so)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 t=0,o=0;t<n;t++,o+=2){const n=go(e.charCodeAt(o)),i=go(e.charCodeAt(o+1));if(void 0===n||void 0===i){const t=e[o]+e[o+1];throw new Error('hex string expected, got non-hex character "'+t+'" at index '+o)}r[t]=16*n+i}return r}function wo(e){return"string"==typeof e&&(e=function(e){if("string"!=typeof e)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(e))}(e)),eo(e),e}function bo(...e){let t=0;for(let n=0;n<e.length;n++){const r=e[n];eo(r),t+=r.length}const n=new Uint8Array(t);for(let t=0,r=0;t<e.length;t++){const o=e[t];n.set(o,r),r+=o.length}return n}let vo=class{};function Eo(e){const t=t=>e().update(wo(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function _o(e=32){if(Xr&&"function"==typeof Xr.getRandomValues)return Xr.getRandomValues(new Uint8Array(e));if(Xr&&"function"==typeof Xr.randomBytes)return Uint8Array.from(Xr.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}function xo(e,t,n){return e&t^~e&n}function ko(e,t,n){return e&t^e&n^t&n}class Ao extends vo{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=oo(this.buffer)}update(e){no(this),eo(e=wo(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){const t=oo(e);for(;r<=o-i;i+=r)this.process(t,i);continue}n.set(e.subarray(i,i+s),this.pos),this.pos+=s,i+=s,this.pos===r&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){no(this),function(e,t){eo(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,ro(this.buffer.subarray(i)),this.padOffset>r-i&&(this.process(n,0),i=0);for(let e=i;e<r;e++)t[e]=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=oo(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=a/4,u=this.get();if(c>u.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e<c;e++)s.setUint32(4*e,u[e],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 Io=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),$o=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]),Bo=new Uint32Array(64);let zo=class extends Ao{constructor(e=32){super(64,e,8,!1),this.A=0|Io[0],this.B=0|Io[1],this.C=0|Io[2],this.D=0|Io[3],this.E=0|Io[4],this.F=0|Io[5],this.G=0|Io[6],this.H=0|Io[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 n=0;n<16;n++,t+=4)Bo[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=Bo[e-15],n=Bo[e-2],r=io(t,7)^io(t,18)^t>>>3,o=io(n,17)^io(n,19)^n>>>10;Bo[e]=o+Bo[e-7]+r+Bo[e-16]|0}let{A:n,B:r,C:o,D:i,E:s,F:a,G:c,H:u}=this;for(let e=0;e<64;e++){const t=u+(io(s,6)^io(s,11)^io(s,25))+xo(s,a,c)+$o[e]+Bo[e]|0,l=(io(n,2)^io(n,13)^io(n,22))+ko(n,r,o)|0;u=c,c=a,a=s,s=i+t|0,i=o,o=r,r=n,n=t+l|0}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(){ro(Bo)}destroy(){this.set(0,0,0,0,0,0,0,0),ro(this.buffer)}};const So=Eo(()=>new zo);let Oo=class extends vo{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,to(e);const n=wo(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 e=0;e<o.length;e++)o[e]^=54;this.iHash.update(o),this.oHash=e.create();for(let e=0;e<o.length;e++)o[e]^=106;this.oHash.update(o),ro(o)}update(e){return no(this),this.iHash.update(e),this}digestInto(e){no(this),eo(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 To=(e,t,n)=>new Oo(e,t).update(n).digest();To.create=(e,t)=>new Oo(e,t);
1
+ class e extends Error{constructor(e,t,n={}){super(t,void 0===n.cause?void 0:{cause:n.cause}),this.name="SwarmIdError",this.code=e,void 0!==n.reason&&(this.reason=n.reason),void 0!==n.status&&(this.status=n.status),void 0!==n.beeMessage&&(this.beeMessage=n.beeMessage),void 0!==n.url&&(this.url=n.url)}toWire(){return{error:this.message,code:this.code,...void 0!==this.reason&&{reason:this.reason},...void 0!==this.status&&{status:this.status},...void 0!==this.beeMessage&&{beeMessage:this.beeMessage},...void 0!==this.url&&{url:this.url}}}static fromWire(t){const{error:n,code:r,...o}=t;return new e(r,n,o)}}function t(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 e of o._zod.deferred)e();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}let n=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},r=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}};const o={};function i(e){return o}function s(e,t){return"bigint"==typeof t?t.toString():t}function a(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function c(e){return null==e}function u(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}const l=Symbol("evaluating");function f(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==l)return void 0===r&&(r=l,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function d(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function h(...e){const t={};for(const n of e){const e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function p(e){return JSON.stringify(e)}const m="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function g(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}const y=a(()=>{if("undefined"!=typeof navigator&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function w(e){if(!1===g(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!==g(n)&&!1!==Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")}function b(e){return w(e)?{...e}:Array.isArray(e)?[...e]:e}const v=new Set(["string","number","symbol"]);function E(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function x(e,t,n){const r=new e._zod.constr(t??e._zod.def);return t&&!n?.parent||(r._zod.parent=e),r}function _(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 k={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 A(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 I(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function $(e){return"string"==typeof e?e:e?.message}function B(e,t,n){const r={...e,path:e.path??[]};if(!e.message){const o=$(e.inst?._zod.def?.error?.(e))??$(t?.error?.(e))??$(n.customError?.(e))??$(n.localeError?.(e))??"Invalid input";r.message=o}return delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function S(e){return Array.isArray(e)?"array":"string"==typeof e?"string":"unknown"}function z(...e){const[t,n,r]=e;return"string"==typeof t?{message:t,code:"custom",input:n,inst:r}:{...t}}const O=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,s,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},T=t("$ZodError",O),N=t("$ZodError",O,{Parent:Error});const R=e=>(t,r,o,s)=>{const a=o?Object.assign(o,{async:!1}):{async:!1},c=t._zod.run({value:r,issues:[]},a);if(c instanceof Promise)throw new n;if(c.issues.length){const t=new(s?.Err??e)(c.issues.map(e=>B(e,a,i())));throw m(t,s?.callee),t}return c.value},U=e=>async(t,n,r,o)=>{const s=r?Object.assign(r,{async:!0}):{async:!0};let a=t._zod.run({value:n,issues:[]},s);if(a instanceof Promise&&(a=await a),a.issues.length){const t=new(o?.Err??e)(a.issues.map(e=>B(e,s,i())));throw m(t,o?.callee),t}return a.value},P=e=>(t,r,o)=>{const s=o?{...o,async:!1}:{async:!1},a=t._zod.run({value:r,issues:[]},s);if(a instanceof Promise)throw new n;return a.issues.length?{success:!1,error:new(e??T)(a.issues.map(e=>B(e,s,i())))}:{success:!0,data:a.value}},F=P(N),C=e=>async(t,n,r)=>{const o=r?Object.assign(r,{async:!0}):{async:!0};let s=t._zod.run({value:n,issues:[]},o);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new e(s.issues.map(e=>B(e,o,i())))}:{success:!0,data:s.value}},L=C(N),M=e=>(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return R(e)(t,n,o)},D=e=>(t,n,r)=>R(e)(t,n,r),Z=e=>async(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return U(e)(t,n,o)},j=e=>async(t,n,r)=>U(e)(t,n,r),q=e=>(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return P(e)(t,n,o)},G=e=>(t,n,r)=>P(e)(t,n,r),H=e=>async(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return C(e)(t,n,o)},V=e=>async(t,n,r)=>C(e)(t,n,r),K=/^[cC][^\s-]{8,}$/,W=/^[0-9a-z]+$/,J=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,X=/^[0-9a-vA-V]{20}$/,Y=/^[A-Za-z0-9]{27}$/,Q=/^[a-zA-Z0-9_-]{21}$/,ee=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,te=/^([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})$/,ne=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)$/,re=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;const oe=/^(?:(?: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])$/,ie=/^(([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}|:))$/,se=/^((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])$/,ae=/^(([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])$/,ce=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,ue=/^[A-Za-z0-9_-]*$/,le=/^\+(?:[0-9]){6,14}[0-9]$/,fe="(?:(?:\\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])))",de=new RegExp(`^${fe}$`);function he(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 pe=/^-?\d+$/,me=/^-?\d+(?:\.\d+)?/,ge=/^(?:true|false)$/i,ye=/^undefined$/i,we=/^[^A-Z]*$/,be=/^[^a-z]*$/,ve=t("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Ee={number:"number",bigint:"bigint",object:"date"},xe=t("$ZodCheckLessThan",(e,t)=>{ve.init(e,t);const n=Ee[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:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),_e=t("$ZodCheckGreaterThan",(e,t)=>{ve.init(e,t);const n=Ee[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:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),ke=t("$ZodCheckMultipleOf",(e,t)=>{ve.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.toString().split(".")[1]||"").length,r=t.toString();let o=(r.split(".")[1]||"").length;if(0===o&&/\d?e-\d?/.test(r)){const e=r.match(/\d?e-(\d?)/);e?.[1]&&(o=Number.parseInt(e[1]))}const i=n>o?n:o;return Number.parseInt(e.toFixed(i).replace(".",""))%Number.parseInt(t.toFixed(i).replace(".",""))/10**i}(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})}}),Ae=t("$ZodCheckNumberFormat",(e,t)=>{ve.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),r=n?"int":"number",[o,i]=k[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=pe)}),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,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,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,inst:e})}}),Ie=t("$ZodCheckMaxLength",(e,t)=>{var n;ve.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!c(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=S(r);n.issues.push({origin:o,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),$e=t("$ZodCheckMinLength",(e,t)=>{var n;ve.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!c(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=S(r);n.issues.push({origin:o,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Be=t("$ZodCheckLengthEquals",(e,t)=>{var n;ve.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!c(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=S(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})}}),Se=t("$ZodCheckStringFormat",(e,t)=>{var n,r;ve.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=()=>{})}),ze=t("$ZodCheckRegex",(e,t)=>{Se.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})}}),Oe=t("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=we),Se.init(e,t)}),Te=t("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=be),Se.init(e,t)}),Ne=t("$ZodCheckIncludes",(e,t)=>{ve.init(e,t);const n=E(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})}}),Re=t("$ZodCheckStartsWith",(e,t)=>{ve.init(e,t);const n=new RegExp(`^${E(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})}}),Ue=t("$ZodCheckEndsWith",(e,t)=>{ve.init(e,t);const n=new RegExp(`.*${E(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})}}),Pe=t("$ZodCheckOverwrite",(e,t)=>{ve.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});let Fe=class{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 e of r)this.content.push(e)}compile(){const e=Function,t=this?.args;return new e(...t,[...(this?.content??[""]).map(e=>` ${e}`)].join("\n"))}};const Ce={major:4,minor:1,patch:13},Le=t("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Ce;const o=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&o.unshift(e);for(const t of o)for(const n of t._zod.onattach)n(e);if(0===o.length)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const t=(e,t,r)=>{let o,i=A(e);for(const s of t){if(s._zod.def.when){if(!s._zod.def.when(e))continue}else if(i)continue;const t=e.issues.length,a=s._zod.check(e);if(a instanceof Promise&&!1===r?.async)throw new n;if(o||a instanceof Promise)o=(o??Promise.resolve()).then(async()=>{await a;e.issues.length!==t&&(i||(i=A(e,t)))});else{if(e.issues.length===t)continue;i||(i=A(e,t))}}return o?o.then(()=>e):e},r=(r,i,s)=>{if(A(r))return r.aborted=!0,r;const a=t(i,o,s);if(a instanceof Promise){if(!1===s.async)throw new n;return a.then(t=>e._zod.parse(t,s))}return e._zod.parse(a,s)};e._zod.run=(i,s)=>{if(s.skipChecks)return e._zod.parse(i,s);if("backward"===s.direction){const t=e._zod.parse({value:i.value,issues:[]},{...s,skipChecks:!0});return t instanceof Promise?t.then(e=>r(e,i,s)):r(t,i,s)}const a=e._zod.parse(i,s);if(a instanceof Promise){if(!1===s.async)throw new n;return a.then(e=>t(e,o,s))}return t(a,o,s)}}e["~standard"]={validate:t=>{try{const n=F(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch(n){return L(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:"zod",version:1}}),Me=t("$ZodString",(e,t)=>{var n;Le.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}}),De=t("$ZodStringFormat",(e,t)=>{Se.init(e,t),Me.init(e,t)}),Ze=t("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=te),De.init(e,t)}),je=t("$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=ne(e))}else t.pattern??(t.pattern=ne());De.init(e,t)}),qe=t("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=re),De.init(e,t)}),Ge=t("$ZodURL",(e,t)=>{De.init(e,t),e._zod.check=n=>{try{const r=n.value.trim(),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})}}}),He=t("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),De.init(e,t)}),Ve=t("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Q),De.init(e,t)}),Ke=t("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=K),De.init(e,t)}),We=t("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=W),De.init(e,t)}),Je=t("$ZodULID",(e,t)=>{t.pattern??(t.pattern=J),De.init(e,t)}),Xe=t("$ZodXID",(e,t)=>{t.pattern??(t.pattern=X),De.init(e,t)}),Ye=t("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Y),De.init(e,t)}),Qe=t("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=function(e){const t=he({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(`^${fe}T(?:${r})$`)}(t)),De.init(e,t)}),et=t("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=de),De.init(e,t)}),tt=t("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=new RegExp(`^${he(t)}$`)),De.init(e,t)}),nt=t("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=ee),De.init(e,t)}),rt=t("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=oe),De.init(e,t),e._zod.bag.format="ipv4"}),ot=t("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=ie),De.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})}}}),it=t("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=se),De.init(e,t)}),st=t("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=ae),De.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 at(e){if(""===e)return!0;if(e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}const ct=t("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=ce),De.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{at(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});const ut=t("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=ue),De.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{(function(e){if(!ue.test(e))return!1;const t=e.replace(/[-_]/g,e=>"-"===e?"+":"/");return at(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})}}),lt=t("$ZodE164",(e,t)=>{t.pattern??(t.pattern=le),De.init(e,t)});const ft=t("$ZodJWT",(e,t)=>{De.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})}}),dt=t("$ZodNumber",(e,t)=>{Le.init(e,t),e._zod.pattern=e._zod.bag.pattern??me,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch(e){}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}}),ht=t("$ZodNumberFormat",(e,t)=>{Ae.init(e,t),dt.init(e,t)}),pt=t("$ZodBoolean",(e,t)=>{Le.init(e,t),e._zod.pattern=ge,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Boolean(n.value)}catch(e){}const o=n.value;return"boolean"==typeof o||n.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),n}}),mt=t("$ZodUndefined",(e,t)=>{Le.init(e,t),e._zod.pattern=ye,e._zod.values=new Set([void 0]),e._zod.optin="optional",e._zod.optout="optional",e._zod.parse=(t,n)=>{const r=t.value;return void 0===r||t.issues.push({expected:"undefined",code:"invalid_type",input:r,inst:e}),t}}),gt=t("$ZodUnknown",(e,t)=>{Le.init(e,t),e._zod.parse=e=>e}),yt=t("$ZodNever",(e,t)=>{Le.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:e}),t)});function wt(e,t,n){e.issues.length&&t.issues.push(...I(n,e.issues)),t.value[n]=e.value}const bt=t("$ZodArray",(e,t)=>{Le.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=>wt(t,n,e))):wt(a,n,e)}return i.length?Promise.all(i).then(()=>n):n}});function vt(e,t,n,r){e.issues.length&&t.issues.push(...I(n,e.issues)),void 0===e.value?n in r&&(t.value[n]=void 0):t.value[n]=e.value}function Et(e){const t=Object.keys(e.shape);for(const n of t)if(!e.shape?.[n]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${n}": 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 xt(e,t,n,r,o,i){const s=[],a=o.keySet,c=o.catchall._zod,u=c.def.type;for(const o in t){if(a.has(o))continue;if("never"===u){s.push(o);continue}const i=c.run({value:t[o],issues:[]},r);i instanceof Promise?e.push(i.then(e=>vt(e,n,o,t))):vt(i,n,o,t)}return s.length&&n.issues.push({code:"unrecognized_keys",keys:s,input:t,inst:i}),e.length?Promise.all(e).then(()=>n):n}const _t=t("$ZodObject",(e,t)=>{Le.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=a(()=>Et(t));f(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=g,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]._zod.run({value:a[e],issues:[]},n);r instanceof Promise?c.push(r.then(n=>vt(n,t,e,a))):vt(r,t,e,a)}return i?xt(c,a,t,n,r.value,e):c.length?Promise.all(c).then(()=>t):t}}),kt=t("$ZodObjectJIT",(e,t)=>{_t.init(e,t);const n=e._zod.parse,r=a(()=>Et(t));let i;const s=g,c=!o.jitless,u=c&&y.value,l=t.catchall;let f;e._zod.parse=(o,a)=>{f??(f=r.value);const d=o.value;return s(d)?c&&u&&!1===a?.async&&!0!==a.jitless?(i||(i=(e=>{const t=new Fe(["shape","payload","ctx"]),n=r.value,o=e=>{const t=p(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 e of n.keys)i[e]="key_"+s++;t.write("const newResult = {};");for(const e of n.keys){const n=i[e],r=p(e);t.write(`const ${n} = ${o(e)};`),t.write(`\n if (${n}.issues.length) {\n payload.issues = payload.issues.concat(${n}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${r}, ...iss.path] : [${r}]\n })));\n }\n \n \n if (${n}.value === undefined) {\n if (${r} in input) {\n newResult[${r}] = undefined;\n }\n } else {\n newResult[${r}] = ${n}.value;\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)),o=i(o,a),l?xt([],d,o,a,f,e):o):n(o,a):(o.issues.push({expected:"object",code:"invalid_type",input:d,inst:e}),o)}});function At(e,t,n,r){for(const n of e)if(0===n.issues.length)return t.value=n.value,t;const o=e.filter(e=>!A(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=>B(e,r,i())))}),t)}const It=t("$ZodUnion",(e,t)=>{Le.init(e,t),f(e._zod,"optin",()=>t.options.some(e=>"optional"===e._zod.optin)?"optional":void 0),f(e._zod,"optout",()=>t.options.some(e=>"optional"===e._zod.optout)?"optional":void 0),f(e._zod,"values",()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),f(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=>u(e.source)).join("|")})$`)}});const n=1===t.options.length,r=t.options[0]._zod.run;e._zod.parse=(o,i)=>{if(n)return r(o,i);let s=!1;const a=[];for(const e of t.options){const t=e._zod.run({value:o.value,issues:[]},i);if(t instanceof Promise)a.push(t),s=!0;else{if(0===t.issues.length)return t;a.push(t)}}return s?Promise.all(a).then(t=>At(t,o,e,i)):At(a,o,e,i)}}),$t=t("$ZodDiscriminatedUnion",(e,t)=>{It.init(e,t);const n=e._zod.parse;f(e._zod,"propValues",()=>{const e={};for(const n of t.options){const r=n._zod.propValues;if(!r||0===Object.keys(r).length)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(const[t,n]of Object.entries(r)){e[t]||(e[t]=new Set);for(const r of n)e[t].add(r)}}return e});const r=a(()=>{const e=t.options,n=new Map;for(const r of e){const e=r._zod.propValues?.[t.discriminator];if(!e||0===e.size)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(const t of e){if(n.has(t))throw new Error(`Duplicate discriminator value "${String(t)}"`);n.set(t,r)}}return n});e._zod.parse=(o,i)=>{const s=o.value;if(!g(s))return o.issues.push({code:"invalid_type",expected:"object",input:s,inst:e}),o;const a=r.value.get(s?.[t.discriminator]);return a?a._zod.run(o,i):t.unionFallback?n(o,i):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,input:s,path:[t.discriminator],inst:e}),o)}}),Bt=t("$ZodIntersection",(e,t)=>{Le.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])=>zt(e,t,n)):zt(e,o,i)}});function St(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(w(e)&&w(t)){const n=Object.keys(t),r=Object.keys(e).filter(e=>-1!==n.indexOf(e)),o={...e,...t};for(const n of r){const r=St(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};o[n]=r.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=St(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 zt(e,t,n){if(t.issues.length&&e.issues.push(...t.issues),n.issues.length&&e.issues.push(...n.issues),A(e))return e;const r=St(t.value,n.value);if(!r.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(r.mergeErrorPath)}`);return e.value=r.data,e}const Ot=t("$ZodRecord",(e,t)=>{Le.init(e,t),e._zod.parse=(n,r)=>{const o=n.value;if(!w(o))return n.issues.push({expected:"record",code:"invalid_type",input:o,inst:e}),n;const s=[],a=t.keyType._zod.values;if(a){n.value={};const i=new Set;for(const e of a)if("string"==typeof e||"number"==typeof e||"symbol"==typeof e){i.add("number"==typeof e?e.toString():e);const a=t.valueType._zod.run({value:o[e],issues:[]},r);a instanceof Promise?s.push(a.then(t=>{t.issues.length&&n.issues.push(...I(e,t.issues)),n.value[e]=t.value})):(a.issues.length&&n.issues.push(...I(e,a.issues)),n.value[e]=a.value)}let c;for(const e in o)i.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 a of Reflect.ownKeys(o)){if("__proto__"===a)continue;const c=t.keyType._zod.run({value:a,issues:[]},r);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(c.issues.length){n.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(e=>B(e,r,i())),input:a,path:[a],inst:e}),n.value[c.value]=c.value;continue}const u=t.valueType._zod.run({value:o[a],issues:[]},r);u instanceof Promise?s.push(u.then(e=>{e.issues.length&&n.issues.push(...I(a,e.issues)),n.value[c.value]=e.value})):(u.issues.length&&n.issues.push(...I(a,u.issues)),n.value[c.value]=u.value)}}return s.length?Promise.all(s).then(()=>n):n}}),Tt=t("$ZodEnum",(e,t)=>{Le.init(e,t);const n=function(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)}(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter(e=>v.has(typeof e)).map(e=>"string"==typeof e?E(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}}),Nt=t("$ZodLiteral",(e,t)=>{if(Le.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?E(e):e?E(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}}),Rt=t("$ZodTransform",(e,t)=>{Le.init(e,t),e._zod.parse=(o,i)=>{if("backward"===i.direction)throw new r(e.constructor.name);const s=t.transform(o.value,o);if(i.async){return(s instanceof Promise?s:Promise.resolve(s)).then(e=>(o.value=e,o))}if(s instanceof Promise)throw new n;return o.value=s,o}});function Ut(e,t){return e.issues.length&&void 0===t?{issues:[],value:void 0}:e}const Pt=t("$ZodOptional",(e,t)=>{Le.init(e,t),e._zod.optin="optional",e._zod.optout="optional",f(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),f(e._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${u(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if("optional"===t.innerType._zod.optin){const r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(t=>Ut(t,e.value)):Ut(r,e.value)}return void 0===e.value?e:t.innerType._zod.run(e,n)}}),Ft=t("$ZodNullable",(e,t)=>{Le.init(e,t),f(e._zod,"optin",()=>t.innerType._zod.optin),f(e._zod,"optout",()=>t.innerType._zod.optout),f(e._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${u(e.source)}|null)$`):void 0}),f(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)}),Ct=t("$ZodDefault",(e,t)=>{Le.init(e,t),e._zod.optin="optional",f(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=>Lt(e,t)):Lt(r,t)}});function Lt(e,t){return void 0===e.value&&(e.value=t.defaultValue),e}const Mt=t("$ZodPrefault",(e,t)=>{Le.init(e,t),e._zod.optin="optional",f(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))}),Dt=t("$ZodNonOptional",(e,t)=>{Le.init(e,t),f(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=>Zt(t,e)):Zt(o,e)}});function Zt(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 jt=t("$ZodCatch",(e,t)=>{Le.init(e,t),f(e._zod,"optin",()=>t.innerType._zod.optin),f(e._zod,"optout",()=>t.innerType._zod.optout),f(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=>B(e,n,i()))},input:e.value}),e.issues=[]),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>B(e,n,i()))},input:e.value}),e.issues=[]),e)}}),qt=t("$ZodPipe",(e,t)=>{Le.init(e,t),f(e._zod,"values",()=>t.in._zod.values),f(e._zod,"optin",()=>t.in._zod.optin),f(e._zod,"optout",()=>t.out._zod.optout),f(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=>Gt(e,t.in,n)):Gt(r,t.in,n)}const r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Gt(e,t.out,n)):Gt(r,t.out,n)}});function Gt(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const Ht=t("$ZodReadonly",(e,t)=>{Le.init(e,t),f(e._zod,"propValues",()=>t.innerType._zod.propValues),f(e._zod,"values",()=>t.innerType._zod.values),f(e._zod,"optin",()=>t.innerType?._zod?.optin),f(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(Vt):Vt(r)}});function Vt(e){return e.value=Object.freeze(e.value),e}const Kt=t("$ZodCustom",(e,t)=>{ve.init(e,t),Le.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=>Wt(t,n,r,e));Wt(o,n,r,e)}});function Wt(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(z(e))}}var Jt;let Xt=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){const n=t[0];if(this._map.set(e,n),n&&"object"==typeof n&&"id"in n){if(this._idmap.has(n.id))throw new Error(`ID ${n.id} already exists in the registry`);this._idmap.set(n.id,e)}return 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)}};(Jt=globalThis).__zod_globalRegistry??(Jt.__zod_globalRegistry=new Xt);const Yt=globalThis.__zod_globalRegistry;function Qt(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,..._(t)})}function en(e,t){return new xe({check:"less_than",..._(t),value:e,inclusive:!1})}function tn(e,t){return new xe({check:"less_than",..._(t),value:e,inclusive:!0})}function nn(e,t){return new _e({check:"greater_than",..._(t),value:e,inclusive:!1})}function rn(e,t){return new _e({check:"greater_than",..._(t),value:e,inclusive:!0})}function on(e,t){return new ke({check:"multiple_of",..._(t),value:e})}function sn(e,t){return new Ie({check:"max_length",..._(t),maximum:e})}function an(e,t){return new $e({check:"min_length",..._(t),minimum:e})}function cn(e,t){return new Be({check:"length_equals",..._(t),length:e})}function un(e){return new Pe({check:"overwrite",tx:e})}function ln(e){const t=function(e,t){const n=new ve({check:"custom",..._(t)});return n._zod.check=e,n}(n=>(n.addIssue=e=>{if("string"==typeof e)n.issues.push(z(e,n.value,t._zod.def));else{const r=e;r.fatal&&(r.continue=!1),r.code??(r.code="custom"),r.input??(r.input=n.value),r.inst??(r.inst=t),r.continue??(r.continue=!t._zod.def.abort),n.issues.push(z(r))}},e(n.value,n)));return t}const fn=t("ZodISODateTime",(e,t)=>{Qe.init(e,t),Cn.init(e,t)});function dn(e){return function(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,..._(t)})}(fn,e)}const hn=t("ZodISODate",(e,t)=>{et.init(e,t),Cn.init(e,t)});function pn(e){return function(e,t){return new e({type:"string",format:"date",check:"string_format",..._(t)})}(hn,e)}const mn=t("ZodISOTime",(e,t)=>{tt.init(e,t),Cn.init(e,t)});function gn(e){return function(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,..._(t)})}(mn,e)}const yn=t("ZodISODuration",(e,t)=>{nt.init(e,t),Cn.init(e,t)});function wn(e){return function(e,t){return new e({type:"string",format:"duration",check:"string_format",..._(t)})}(yn,e)}const bn=(e,t)=>{T.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:t=>function(e,t=e=>e.message){const n={_errors:[]},r=e=>{for(const o of e.issues)if("invalid_union"===o.code&&o.errors.length)o.errors.map(e=>r({issues:e}));else if("invalid_key"===o.code)r({issues:o.issues});else if("invalid_element"===o.code)r({issues:o.issues});else if(0===o.path.length)n._errors.push(t(o));else{let e=n,r=0;for(;r<o.path.length;){const n=o.path[r];r===o.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(o))):e[n]=e[n]||{_errors:[]},e=e[n],r++}}};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,s,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,s,2)}},isEmpty:{get:()=>0===e.issues.length}})},vn=t("ZodError",bn),En=t("ZodError",bn,{Parent:Error}),xn=R(En),_n=U(En),kn=P(En),An=C(En),In=M(En),$n=D(En),Bn=Z(En),Sn=j(En),zn=q(En),On=G(En),Tn=H(En),Nn=V(En),Rn=t("ZodType",(e,t)=>(Le.init(e,t),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(h(t,{checks:[...t.checks??[],...n.map(e=>"function"==typeof e?{_zod:{check:e,def:{check:"custom"},onattach:[]}}:e)]})),e.clone=(t,n)=>x(e,t,n),e.brand=()=>e,e.register=(t,n)=>(t.add(e,n),e),e.parse=(t,n)=>xn(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>kn(e,t,n),e.parseAsync=async(t,n)=>_n(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>An(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>In(e,t,n),e.decode=(t,n)=>$n(e,t,n),e.encodeAsync=async(t,n)=>Bn(e,t,n),e.decodeAsync=async(t,n)=>Sn(e,t,n),e.safeEncode=(t,n)=>zn(e,t,n),e.safeDecode=(t,n)=>On(e,t,n),e.safeEncodeAsync=async(t,n)=>Tn(e,t,n),e.safeDecodeAsync=async(t,n)=>Nn(e,t,n),e.refine=(t,n)=>e.check(function(e,t={}){return function(e,t,n){return new e({type:"custom",check:"custom",fn:t,..._(n)})}(qr,e,t)}(t,n)),e.superRefine=t=>e.check(ln(t)),e.overwrite=t=>e.check(un(t)),e.optional=()=>Rr(e),e.nullable=()=>Pr(e),e.nullish=()=>Rr(Pr(e)),e.nonoptional=t=>function(e,t){return new Lr({type:"nonoptional",innerType:e,..._(t)})}(e,t),e.array=()=>gr(e),e.or=t=>Er([e,t]),e.and=t=>new kr({type:"intersection",left:e,right:t}),e.transform=t=>Zr(e,Tr(t)),e.default=t=>{return n=t,new Fr({type:"default",innerType:e,get defaultValue(){return"function"==typeof n?n():b(n)}});var n},e.prefault=t=>{return n=t,new Cr({type:"prefault",innerType:e,get defaultValue(){return"function"==typeof n?n():b(n)}});var n},e.catch=t=>{return new Mr({type:"catch",innerType:e,catchValue:"function"==typeof(n=t)?n:()=>n});var n},e.pipe=t=>Zr(e,t),e.readonly=()=>new jr({type:"readonly",innerType:e}),e.describe=t=>{const n=e.clone();return Yt.add(n,{description:t}),n},Object.defineProperty(e,"description",{get:()=>Yt.get(e)?.description,configurable:!0}),e.meta=(...t)=>{if(0===t.length)return Yt.get(e);const n=e.clone();return Yt.add(n,t[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),Un=t("_ZodString",(e,t)=>{Me.init(e,t),Rn.init(e,t);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...t)=>e.check(function(e,t){return new ze({check:"string_format",format:"regex",..._(t),pattern:e})}(...t)),e.includes=(...t)=>e.check(function(e,t){return new Ne({check:"string_format",format:"includes",..._(t),includes:e})}(...t)),e.startsWith=(...t)=>e.check(function(e,t){return new Re({check:"string_format",format:"starts_with",..._(t),prefix:e})}(...t)),e.endsWith=(...t)=>e.check(function(e,t){return new Ue({check:"string_format",format:"ends_with",..._(t),suffix:e})}(...t)),e.min=(...t)=>e.check(an(...t)),e.max=(...t)=>e.check(sn(...t)),e.length=(...t)=>e.check(cn(...t)),e.nonempty=(...t)=>e.check(an(1,...t)),e.lowercase=t=>e.check(function(e){return new Oe({check:"string_format",format:"lowercase",..._(e)})}(t)),e.uppercase=t=>e.check(function(e){return new Te({check:"string_format",format:"uppercase",..._(e)})}(t)),e.trim=()=>e.check(un(e=>e.trim())),e.normalize=(...t)=>e.check(function(e){return un(t=>t.normalize(e))}(...t)),e.toLowerCase=()=>e.check(un(e=>e.toLowerCase())),e.toUpperCase=()=>e.check(un(e=>e.toUpperCase())),e.slugify=()=>e.check(un(e=>function(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}(e)))}),Pn=t("ZodString",(e,t)=>{Me.init(e,t),Un.init(e,t),e.email=t=>e.check(function(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,..._(t)})}(Ln,t)),e.url=t=>e.check(function(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,..._(t)})}(Zn,t)),e.jwt=t=>e.check(function(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,..._(t)})}(rr,t)),e.emoji=t=>e.check(function(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,..._(t)})}(jn,t)),e.guid=t=>e.check(Qt(Mn,t)),e.uuid=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,..._(t)})}(Dn,t)),e.uuidv4=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",..._(t)})}(Dn,t)),e.uuidv6=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",..._(t)})}(Dn,t)),e.uuidv7=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",..._(t)})}(Dn,t)),e.nanoid=t=>e.check(function(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,..._(t)})}(qn,t)),e.guid=t=>e.check(Qt(Mn,t)),e.cuid=t=>e.check(function(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,..._(t)})}(Gn,t)),e.cuid2=t=>e.check(function(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,..._(t)})}(Hn,t)),e.ulid=t=>e.check(function(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,..._(t)})}(Vn,t)),e.base64=t=>e.check(function(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,..._(t)})}(er,t)),e.base64url=t=>e.check(function(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,..._(t)})}(tr,t)),e.xid=t=>e.check(function(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,..._(t)})}(Kn,t)),e.ksuid=t=>e.check(function(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,..._(t)})}(Wn,t)),e.ipv4=t=>e.check(function(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,..._(t)})}(Jn,t)),e.ipv6=t=>e.check(function(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,..._(t)})}(Xn,t)),e.cidrv4=t=>e.check(function(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,..._(t)})}(Yn,t)),e.cidrv6=t=>e.check(function(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,..._(t)})}(Qn,t)),e.e164=t=>e.check(function(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,..._(t)})}(nr,t)),e.datetime=t=>e.check(dn(t)),e.date=t=>e.check(pn(t)),e.time=t=>e.check(gn(t)),e.duration=t=>e.check(wn(t))});function Fn(e){return function(e,t){return new e({type:"string",..._(t)})}(Pn,e)}const Cn=t("ZodStringFormat",(e,t)=>{De.init(e,t),Un.init(e,t)}),Ln=t("ZodEmail",(e,t)=>{qe.init(e,t),Cn.init(e,t)}),Mn=t("ZodGUID",(e,t)=>{Ze.init(e,t),Cn.init(e,t)}),Dn=t("ZodUUID",(e,t)=>{je.init(e,t),Cn.init(e,t)}),Zn=t("ZodURL",(e,t)=>{Ge.init(e,t),Cn.init(e,t)}),jn=t("ZodEmoji",(e,t)=>{He.init(e,t),Cn.init(e,t)}),qn=t("ZodNanoID",(e,t)=>{Ve.init(e,t),Cn.init(e,t)}),Gn=t("ZodCUID",(e,t)=>{Ke.init(e,t),Cn.init(e,t)}),Hn=t("ZodCUID2",(e,t)=>{We.init(e,t),Cn.init(e,t)}),Vn=t("ZodULID",(e,t)=>{Je.init(e,t),Cn.init(e,t)}),Kn=t("ZodXID",(e,t)=>{Xe.init(e,t),Cn.init(e,t)}),Wn=t("ZodKSUID",(e,t)=>{Ye.init(e,t),Cn.init(e,t)}),Jn=t("ZodIPv4",(e,t)=>{rt.init(e,t),Cn.init(e,t)}),Xn=t("ZodIPv6",(e,t)=>{ot.init(e,t),Cn.init(e,t)}),Yn=t("ZodCIDRv4",(e,t)=>{it.init(e,t),Cn.init(e,t)}),Qn=t("ZodCIDRv6",(e,t)=>{st.init(e,t),Cn.init(e,t)}),er=t("ZodBase64",(e,t)=>{ct.init(e,t),Cn.init(e,t)}),tr=t("ZodBase64URL",(e,t)=>{ut.init(e,t),Cn.init(e,t)}),nr=t("ZodE164",(e,t)=>{lt.init(e,t),Cn.init(e,t)}),rr=t("ZodJWT",(e,t)=>{ft.init(e,t),Cn.init(e,t)}),or=t("ZodNumber",(e,t)=>{dt.init(e,t),Rn.init(e,t),e.gt=(t,n)=>e.check(nn(t,n)),e.gte=(t,n)=>e.check(rn(t,n)),e.min=(t,n)=>e.check(rn(t,n)),e.lt=(t,n)=>e.check(en(t,n)),e.lte=(t,n)=>e.check(tn(t,n)),e.max=(t,n)=>e.check(tn(t,n)),e.int=t=>e.check(ar(t)),e.safe=t=>e.check(ar(t)),e.positive=t=>e.check(nn(0,t)),e.nonnegative=t=>e.check(rn(0,t)),e.negative=t=>e.check(en(0,t)),e.nonpositive=t=>e.check(tn(0,t)),e.multipleOf=(t,n)=>e.check(on(t,n)),e.step=(t,n)=>e.check(on(t,n)),e.finite=()=>e;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 ir(e){return function(e,t){return new e({type:"number",checks:[],..._(t)})}(or,e)}const sr=t("ZodNumberFormat",(e,t)=>{ht.init(e,t),or.init(e,t)});function ar(e){return function(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",..._(t)})}(sr,e)}const cr=t("ZodBoolean",(e,t)=>{pt.init(e,t),Rn.init(e,t)});function ur(e){return function(e,t){return new e({type:"boolean",..._(t)})}(cr,e)}const lr=t("ZodUndefined",(e,t)=>{mt.init(e,t),Rn.init(e,t)});const fr=t("ZodUnknown",(e,t)=>{gt.init(e,t),Rn.init(e,t)});function dr(){return new fr({type:"unknown"})}const hr=t("ZodNever",(e,t)=>{yt.init(e,t),Rn.init(e,t)});function pr(e){return function(e,t){return new e({type:"never",..._(t)})}(hr,e)}const mr=t("ZodArray",(e,t)=>{bt.init(e,t),Rn.init(e,t),e.element=t.element,e.min=(t,n)=>e.check(an(t,n)),e.nonempty=t=>e.check(an(1,t)),e.max=(t,n)=>e.check(sn(t,n)),e.length=(t,n)=>e.check(cn(t,n)),e.unwrap=()=>e.element});function gr(e,t){return function(e,t,n){return new e({type:"array",element:t,..._(n)})}(mr,e,t)}const yr=t("ZodObject",(e,t)=>{kt.init(e,t),Rn.init(e,t),f(e,"shape",()=>t.shape),e.keyof=()=>Br(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:dr()}),e.loose=()=>e.clone({...e._zod.def,catchall:dr()}),e.strict=()=>e.clone({...e._zod.def,catchall:pr()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>function(e,t){if(!w(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0)throw new Error("Object schemas containing refinements cannot be extended. Use `.safeExtend()` instead.");const r=h(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return d(this,"shape",n),n},checks:[]});return x(e,r)}(e,t),e.safeExtend=t=>function(e,t){if(!w(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n={...e._zod.def,get shape(){const n={...e._zod.def.shape,...t};return d(this,"shape",n),n},checks:e._zod.def.checks};return x(e,n)}(e,t),e.merge=t=>function(e,t){const n=h(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t._zod.def.shape};return d(this,"shape",n),n},get catchall(){return t._zod.def.catchall},checks:[]});return x(e,n)}(e,t),e.pick=t=>function(e,t){const n=e._zod.def;return x(e,h(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 d(this,"shape",e),e},checks:[]}))}(e,t),e.omit=t=>function(e,t){const n=e._zod.def,r=h(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 d(this,"shape",r),r},checks:[]});return x(e,r)}(e,t),e.partial=(...t)=>function(e,t,n){const r=h(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 d(this,"shape",o),o},checks:[]});return x(t,r)}(Nr,e,t[0]),e.required=(...t)=>function(e,t,n){const r=h(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 d(this,"shape",o),o},checks:[]});return x(t,r)}(Lr,e,t[0])});function wr(e,t){const n={type:"object",shape:e??{},..._(t)};return new yr(n)}function br(e,t){return new yr({type:"object",shape:e,catchall:pr(),..._(t)})}const vr=t("ZodUnion",(e,t)=>{It.init(e,t),Rn.init(e,t),e.options=t.options});function Er(e,t){return new vr({type:"union",options:e,..._(t)})}const xr=t("ZodDiscriminatedUnion",(e,t)=>{vr.init(e,t),$t.init(e,t)});function _r(e,t,n){return new xr({type:"union",options:t,discriminator:e,..._(n)})}const kr=t("ZodIntersection",(e,t)=>{Bt.init(e,t),Rn.init(e,t)});const Ar=t("ZodRecord",(e,t)=>{Ot.init(e,t),Rn.init(e,t),e.keyType=t.keyType,e.valueType=t.valueType});function Ir(e,t,n){return new Ar({type:"record",keyType:e,valueType:t,..._(n)})}const $r=t("ZodEnum",(e,t)=>{Tt.init(e,t),Rn.init(e,t),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 r of e){if(!n.has(r))throw new Error(`Key ${r} not found in enum`);o[r]=t.entries[r]}return new $r({...t,checks:[],..._(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 $r({...t,checks:[],..._(r),entries:o})}});function Br(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new $r({type:"enum",entries:n,..._(t)})}const Sr=t("ZodLiteral",(e,t)=>{Nt.init(e,t),Rn.init(e,t),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]}})});function zr(e,t){return new Sr({type:"literal",values:Array.isArray(e)?e:[e],..._(t)})}const Or=t("ZodTransform",(e,t)=>{Rt.init(e,t),Rn.init(e,t),e._zod.parse=(n,o)=>{if("backward"===o.direction)throw new r(e.constructor.name);n.addIssue=r=>{if("string"==typeof r)n.issues.push(z(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(z(t))}};const i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function Tr(e){return new Or({type:"transform",transform:e})}const Nr=t("ZodOptional",(e,t)=>{Pt.init(e,t),Rn.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Rr(e){return new Nr({type:"optional",innerType:e})}const Ur=t("ZodNullable",(e,t)=>{Ft.init(e,t),Rn.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Pr(e){return new Ur({type:"nullable",innerType:e})}const Fr=t("ZodDefault",(e,t)=>{Ct.init(e,t),Rn.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});const Cr=t("ZodPrefault",(e,t)=>{Mt.init(e,t),Rn.init(e,t),e.unwrap=()=>e._zod.def.innerType});const Lr=t("ZodNonOptional",(e,t)=>{Dt.init(e,t),Rn.init(e,t),e.unwrap=()=>e._zod.def.innerType});const Mr=t("ZodCatch",(e,t)=>{jt.init(e,t),Rn.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});const Dr=t("ZodPipe",(e,t)=>{qt.init(e,t),Rn.init(e,t),e.in=t.in,e.out=t.out});function Zr(e,t){return new Dr({type:"pipe",in:e,out:t})}const jr=t("ZodReadonly",(e,t)=>{Ht.init(e,t),Rn.init(e,t),e.unwrap=()=>e._zod.def.innerType});const qr=t("ZodCustom",(e,t)=>{Kt.init(e,t),Rn.init(e,t)});function Gr(e,t={error:`Input not instance of ${e.name}`}){const n=new qr({type:"custom",check:"custom",fn:t=>t instanceof e,abort:!0,..._(t)});return n._zod.bag.Class=e,n}function Hr(e,t){return Zr(Tr(e),t)}function Vr(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Kr,Wr={};var Jr=(Kr||(Kr=1,function(e){var t;async function n(e){return new Promise((t,n)=>e.then(n,t))}async function r(e){return new Promise(t=>setTimeout(()=>{t(!0)},e))}function o(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 i(e,t,n=Math.random){return o(H(0,e.length-1),n).slice(0,t)}function s(e,t,n=Math.random){return Math.floor(n()*(t-e+1))+e}function a(e,t,n){return t>=e.x&&t<e.x+e.width&&n>=e.y&&n<e.y+e.height}function c(e,t=Math.random){return t()<e}function u(e,t=Math.random){return e[Math.floor(e.length*t())]}function l(e){if(!e.length)throw Error("Received empty array");return e[e.length-1]}function f(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 e of n){if(null===r[e]||void 0===r[e])return null;r=r[e]}return r}function h(e,t,n){const r=t.split(/\.|\[/);let o=e;for(let e=0;e<r.length;e++){const t=r[e],i=e<r.length-1&&r[e+1].includes("]"),s=t.includes("]")?t.replace(/\[|\]/g,""):t;if(e===r.length-1)return o[s]=n,n;m(o[s])||(o[s]=i?[]:{}),o=o[s]}return n}function p(e,t){return Math.round(e/t)*t}function m(e,t=!0){return!(!e||t&&!w(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 g(e){return m(e)&&!Array.isArray(e)}function y(e){return Array.isArray(e)&&0===e.length}function w(e){return void 0===e}function b(e){return"[object Function]"===Object.prototype.toString.call(e)||"[object AsyncFunction]"===Object.prototype.toString.call(e)}function v(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 _(e){return"[object Date]"===Object.prototype.toString.call(e)}function k(e){return!v(e)||0===e.trim().length}function A(e){return E(e)&&Number.isInteger(e)&&e>=1}function I(e){return v(e)&&null!==e.match(/^-?\d+$/)}function $(e){return v(e)&&null!==e.match(/^(0x)?[0-9a-f]+$/i)}Object.defineProperty(e,"__esModule",{value:!0}),e.Vector=e.Cache=e.Assertions=e.Strings=e.Types=e.Objects=e.Dates=e.Promises=e.Numbers=e.System=e.Arrays=e.Random=e.Elliptic=e.Binary=e.Lock=e.Solver=e.RollingValueProvider=e.TrieRouter=e.AsyncQueue=e.PubSubChannel=e.FixedPointNumber=e.MerkleTree=e.Chunk=e.Uint8ArrayWriter=e.Uint8ArrayReader=e.AsyncLazy=e.Lazy=e.Optional=void 0;const B="!@#$%^&*()_+-=[]{}|;:<>?,./".split(""),S="abcdefghijklmnopqrstuvwxyz",z=S+"ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890",O=z+"!@#$%^&*()_+-=[]{}|;:<>?,./",T=["—","\\","東","京","都","𝖆","𝖇","𝖈","👾","🙇","💁","🙅","ᚠ","ᛇ","ᚻ","ᛦ"],N="0123456789abcdef";function R(e,t){if(k(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 U(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&&U(e,t),e;if(!v(e)||!e.match(/^-?\d+(\.\d+)?$/))throw new TypeError(`Expected number${t?.name?` for ${t.name}`:""}, got: `+e);const n=parseFloat(e);return t&&U(n,t),n}function F(e,t){return Math.trunc(P(e,t))}function C(e,t){if(!g(e))throw new TypeError(`Expected object${t?.name?` for ${t.name}`:""}, got: `+e);return e}function L(e){return v(e)&&null!==e.match(/^https?:\/\/.+/)}function M(e){return"bigint"==typeof e}function D(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 Z(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(g(e)&&g(t))for(const n in t)g(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 q(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 G(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 V(e,t=()=>!1){return e.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"").split("").map(e=>/[a-z0-9]/.test(e)||t(e)?e:"-").join("").replace(/-+/g,"-").replace(/^-|-$/g,"")}function K(e,t){if(0===t.length)return 0;const n=e.toLowerCase(),r=t.toLowerCase();return e===t?1e4:n.startsWith(r)?1e4-e.length:n.includes(r)?5e3-e.length:new RegExp(".*"+r.split("").join(".*")+".*").test(n)?1e3-e.length:0}const W={"&amp;":"&","&quot;":'"',"&apos;":"'","&gt;":">","&lt;":"<"};function J(e,t){const n=e.indexOf(t);return-1===n?null:e.slice(0,n)}function X(e,t){const n=e.indexOf(t);return-1===n?null:e.slice(n+t.length)}function Y(e,t){const n=e.lastIndexOf(t);return-1===n?null:e.slice(0,n)}function Q(e,t){const n=e.lastIndexOf(t);return-1===n?null:e.slice(n+t.length)}function ee(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 te(e,t){let n=[e];for(const e of t)n=n.flatMap(t=>t.split(e));return n.filter(e=>e)}function ne(e){const t=l(e.split(/\\|\//g)),n=t.lastIndexOf(".",t.length-1);return n<=0?"":t.slice(n+1)}function re(e){const t=l(e.split(/\\|\//g)),n=t.lastIndexOf(".",t.length-1);return n<=0?t:t.slice(0,n)}function oe(e){return e.split("\n").map(e=>e.trim().replace(/\s+/g," ")).filter(e=>e.length>0).join("\n")}function ie(e){return e.charAt(0).toUpperCase()+e.slice(1)}function se(e){return e.charAt(0).toLowerCase()+e.slice(1)}function ae(e){if(!e)return!1;const t=e.charCodeAt(0);return t>=65&&t<=90||t>=97&&t<=122}function ce(e){if(!e)return!1;const t=e.charCodeAt(0);return t>=48&&t<=57}function ue(e){return ae(e)||ce(e)}const le=" \n\t\r.,?!:;\"'`(){}[]~@#$%^&*-+=|<>/\\".split("");function fe(e){return le.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 he(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 n of t)if(n instanceof RegExp){const t=de(e,n,r);if(!t)return!1;r=t.index+t.match.length}else{const t=e.indexOf(n,r);if(-1===t)return!1;r=t+n.length}return!0}function pe(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 me(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 ge(e,t=0){for(let n=t;n<e.length;n++)if(fe(e[n]))return n;return-1}function ye(e,t=0){for(let n=t;n<e.length;n++)if("#"===e[n]&&ue(e[n+1]))return n;return-1}function we(e,t,n=0){return e.slice(0,n).lastIndexOf(t)}function be(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 ve(e,t){const n=t.wordBoundary?me(e,[`${t.opening} `,`${t.opening}\n`],t.start||0):e.indexOf(t.opening,t.start||0);if(-1===n)return null;const r=be(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 _e(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 ke(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 Ae(e,t,n){const r=[];for(const o of n)o!==t&&r.push(e.replace(t,o));return r}function Ie(e){const t=e.lastIndexOf(" ");return-1===t?{line:e,rest:""}:{line:e.slice(0,t),rest:e.slice(t+1)}}function $e(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 Be(e,t){return new RegExp(`\\b${t}\\b`).test(e)}function Se(e,t,n=[]){let r="";for(;t<e.length&&(ue(e[t])||n.includes(e[t]));)r+=e[t++];return r}function ze(e,t,n,r="$",o=":"){if(""===n)return e;let i=e.indexOf(`${r}${t}`);for(;-1!==i;){if(e[i+t.length+1]===o)if(e[i+t.length+2]===o)e=e.replace(`${r}${t}${o}${o}`,n);else{const s=Se(e,i+t.length+2,["_"]);e=e.replace(`${r}${t}${o}${s}`,n)}else e=e.replace(`${r}${t}`,n);i=e.indexOf(`${r}${t}`,i+n.length)}return e}function Oe(e,t="$",n=":"){let r=e.indexOf(t);for(;-1!==r;){const o=Se(e,r+1);if(e[r+o.length+1]===n)if(e[r+o.length+2]===n)e=e.replace(`${t}${o}${n}${n}`,"");else{const i=Se(e,r+o.length+2);e=e.replace(`${t}${o}${n}${i}`,i)}r=e.indexOf(t,r+1)}return e}function Te(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 Ne(e){return String(Math.floor(e)).padStart(2,"0")}function Re(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?`${Ne(t)}:${Ne(n)}:${Ne(r)}`:`${Ne(n)}:${Ne(r)}`}function Ue(e){return Math.floor((_(e)?e.getTime():e)/864e5)}const Pe={today:(e,t)=>Ne(e)+":"+Ne(t),yesterday:()=>"Yesterday",monday:()=>"Mon",tuesday:()=>"Tue",wednesday:()=>"Wed",thursday:()=>"Thu",friday:()=>"Fri",saturday:()=>"Sat",sunday:()=>"Sun",weeks:e=>`${e}w`},Fe={now:()=>"A few seconds",seconds:e=>`${e} seconds`,minutes:e=>`${e} minutes`,hours:e=>`${e} hours`,days:e=>`${e} days`,weeks:e=>`${e} weeks`};function Ce(t,n){const r=n?.now??Date.now(),o=n?.labels||Fe;let i=(r-(e.Types.isDate(t)?t.getTime():t))/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 Le={},Me={s:1e3,m:6e4,h:36e5,d:864e5},De={0:"sunday",1:"monday",2:"tuesday",3:"wednesday",4:"thursday",5:"friday",6:"saturday"};function Ze(e){return{zeroBasedIndex:e,day:De[e]}}function je(e){return Ze(e.getDay())}const qe={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},Ge={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},He=new Map;function Ve(e,t=!1){e=e.filter(e=>e),t&&v(e[1])&&(e[1]="../"+e[1]);let n="";v(e[0])&&e[0].includes("://")&&(n=J(e[0],"://")??"",e[0]=X(e[0],"://")??"");const r=e.map(e=>String(e)).flatMap(e=>e.split("/")),o=[];for(let e=0;e<r.length;e++)"."!==r[e]&&(".."===r[e]?(!n||o.length>1)&&o.pop():o.push(r[e]));return(n?n+"://":"")+o.join("/").replaceAll(/\/{2,}/g,"/")}function Ke(e){const t=Object.keys(e).sort((e,t)=>e.localeCompare(t)),n={};for(const r of t)n[r]=Je(e[r]);return n}function We(e){const t=[];return e.sort((e,t)=>JSON.stringify(Je(e)).localeCompare(JSON.stringify(Je(t)))).forEach(e=>t.push(Je(e))),t}function Je(e){return Array.isArray(e)?We(e):m(e)?Ke(e):e}function Xe(e,t){return JSON.stringify(Je(e))===JSON.stringify(Je(t))}function Ye(e){const t=Object.keys(e);return t[Math.floor(Math.random()*t.length)]}const Qe=[1e3,1e6,1e9,1e12,1e15,1e18,1e21,1e24,1e27,1e30,1e9,1e16,1e18,1e18,1e18,1e33],et=["thousand","million","billion","trillion","quadrillion","quintillion","sextillion","septillion","octillion","nonillion","gwei","bzz","btc","eth","dai","decillion"],tt=["K","M","B","T","Qa","Qi","Sx","Sp","O","N","gwei","bzz","eth","btc","dai","D"];function nt(e){const t=parseFloat(e);if(isNaN(t))throw Error("makeNumber got NaN for input");const n=e.replace(/^-?[0-9.]+/,"").trim(),r=tt.findIndex(e=>e.toLowerCase()===n.toLowerCase());return-1===r?t:t*Qe[r]}function rt(e,t,n){return e<t?t:e>n?n:e}function ot(e,t,n){return e+(n?"["+t+"]":(e.length?".":"")+t)}function it(e,t,n,r,o){if(!m(t))return t;for(const[i,s]of Object.entries(t)){const t=ot(n,i,r);Array.isArray(s)?o?it(e,s,t,!0,o):e[t]=s.map(e=>it(Array.isArray(e)?[]:{},e,"",!1,o)):m(s)?it(e,s,t,!1,o):e[t]=s}return e}function st(e,t){const n={};for(const r of e)n[t(r)]=r;return n}function at(e,t){const n=Math.ceil(e.length/t),r=[];for(let t=0;t<e.length;t+=n)r.push(e.slice(t,t+n));return r}function ct(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 ut(e,t){return Object.fromEntries(Object.entries(e).sort(t))}function lt(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 ft(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}}e.Optional=dt,e.Lazy=class{constructor(e){this.supplier=e,this.value=null}get(){return this.value||(this.value=this.supplier()),this.value}},e.AsyncLazy=class{constructor(e){this.supplier=e,this.value=null}async get(){return this.value||(this.value=await this.supplier()),this.value}};class ht{constructor(e){this.value=e,this.children=[]}}function pt(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 mt(...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 gt(e){return 137===e[0]&&80===e[1]&&78===e[2]&&71===e[3]}function yt(e){return 255===e[0]&&216===e[1]}function wt(e){return 87===e[8]&&69===e[9]&&66===e[10]&&80===e[11]}function bt(e,t){const n=new ArrayBuffer(8);return new DataView(n).setBigUint64(0,BigInt(e),"LE"===t),new Uint8Array(n)}function vt(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 e=31;e>=0;e--)n[e]=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 t=0;t<32;t++)n=n<<8n|BigInt(e[t]);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 _t=[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 kt(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],d=l^(o<<1|i>>>31),h=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),E=u^(r<<1|n>>>31);e[0]^=d,e[1]^=h,e[2]^=p,e[3]^=m,e[4]^=g,e[5]^=y,e[6]^=w,e[7]^=b,e[8]^=v,e[9]^=E,e[10]^=d,e[11]^=h,e[12]^=p,e[13]^=m,e[14]^=g,e[15]^=y,e[16]^=w,e[17]^=b,e[18]^=v,e[19]^=E,e[20]^=d,e[21]^=h,e[22]^=p,e[23]^=m,e[24]^=g,e[25]^=y,e[26]^=w,e[27]^=b,e[28]^=v,e[29]^=E,e[30]^=d,e[31]^=h,e[32]^=p,e[33]^=m,e[34]^=g,e[35]^=y,e[36]^=w,e[37]^=b,e[38]^=v,e[39]^=E,e[40]^=d,e[41]^=h,e[42]^=p,e[43]^=m,e[44]^=g,e[45]^=y,e[46]^=w,e[47]^=b,e[48]^=v,e[49]^=E;const x=e[0],_=e[1],k=e[2]<<1|e[3]>>>31,A=e[3]<<1|e[2]>>>31,I=e[5]<<30|e[4]>>>2,$=e[4]<<30|e[5]>>>2,B=e[6]<<28|e[7]>>>4,S=e[7]<<28|e[6]>>>4,z=e[8]<<27|e[9]>>>5,O=e[9]<<27|e[8]>>>5,T=e[11]<<4|e[10]>>>28,N=e[10]<<4|e[11]>>>28,R=e[13]<<12|e[12]>>>20,U=e[12]<<12|e[13]>>>20,P=e[14]<<6|e[15]>>>26,F=e[15]<<6|e[14]>>>26,C=e[17]<<23|e[16]>>>9,L=e[16]<<23|e[17]>>>9,M=e[18]<<20|e[19]>>>12,D=e[19]<<20|e[18]>>>12,Z=e[20]<<3|e[21]>>>29,j=e[21]<<3|e[20]>>>29,q=e[22]<<10|e[23]>>>22,G=e[23]<<10|e[22]>>>22,H=e[25]<<11|e[24]>>>21,V=e[24]<<11|e[25]>>>21,K=e[26]<<25|e[27]>>>7,W=e[27]<<25|e[26]>>>7,J=e[29]<<7|e[28]>>>25,X=e[28]<<7|e[29]>>>25,Y=e[31]<<9|e[30]>>>23,Q=e[30]<<9|e[31]>>>23,ee=e[33]<<13|e[32]>>>19,te=e[32]<<13|e[33]>>>19,ne=e[34]<<15|e[35]>>>17,re=e[35]<<15|e[34]>>>17,oe=e[36]<<21|e[37]>>>11,ie=e[37]<<21|e[36]>>>11,se=e[38]<<8|e[39]>>>24,ae=e[39]<<8|e[38]>>>24,ce=e[40]<<18|e[41]>>>14,ue=e[41]<<18|e[40]>>>14,le=e[42]<<2|e[43]>>>30,fe=e[43]<<2|e[42]>>>30,de=e[45]<<29|e[44]>>>3,he=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]=x^~R&H,e[1]=_^~U&V,e[2]=R^~H&oe,e[3]=U^~V&ie,e[4]=H^~oe&ge,e[5]=V^~ie&ye,e[6]=oe^~ge&x,e[7]=ie^~ye&_,e[8]=ge^~x&R,e[9]=ye^~_&U,e[10]=B^~M&Z,e[11]=S^~D&j,e[12]=M^~Z&ee,e[13]=D^~j&te,e[14]=Z^~ee&de,e[15]=j^~te&he,e[16]=ee^~de&B,e[17]=te^~he&S,e[18]=de^~B&M,e[19]=he^~S&D,e[20]=k^~P&K,e[21]=A^~F&W,e[22]=P^~K&se,e[23]=F^~W&ae,e[24]=K^~se&ce,e[25]=W^~ae&ue,e[26]=se^~ce&k,e[27]=ae^~ue&A,e[28]=ce^~k&P,e[29]=ue^~A&F,e[30]=z^~T&q,e[31]=O^~N&G,e[32]=T^~q&ne,e[33]=N^~G&re,e[34]=q^~ne&pe,e[35]=G^~re&me,e[36]=ne^~pe&z,e[37]=re^~me&O,e[38]=pe^~z&T,e[39]=me^~O&N,e[40]=I^~C&J,e[41]=$^~L&X,e[42]=C^~J&Y,e[43]=L^~X&Q,e[44]=J^~Y&le,e[45]=X^~Q&fe,e[46]=Y^~le&I,e[47]=Q^~fe&$,e[48]=le^~I&C,e[49]=fe^~$&L,e[0]^=_t[2*t],e[1]^=_t[2*t+1]}}function At(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 It(e,t){if(!e.length){const e=new Uint8Array(136);return e[0]=t,e[135]=128,[At(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(At)}function $t(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];kt(e)}return e}function Bt(e){return new Uint8Array([e[1],e[1]>>-24,e[1]>>-16,e[1]>>-8,e[0],e[0]>>8,e[0]>>16,e[0]>>24,e[3],e[3]>>-24,e[3]>>-16,e[3]>>-8,e[2],e[2]>>8,e[2]>>16,e[2]>>24,e[5],e[5]>>-24,e[5]>>-16,e[5]>>-8,e[4],e[4]>>8,e[4]>>16,e[4]>>24,e[7],e[7]>>-24,e[7]>>-16,e[7]>>-8,e[6],e[6]>>8,e[6]>>16,e[6]>>24])}function St(e){return Bt($t(new Array(50).fill(0),It(e,1)))}function zt(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 Ot(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 Tt(e,t){return(e%t+t)%t}function Nt(e,t){e=Tt(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&&(n+=t),n}function Rt(e,t){return 0n===Tt(e,t)?0n:t%4n==3n?function(e,t,n){let r=1n;for(e=Tt(e,n);t>0;)t%2n==1n&&(r=Tt(r*e,n)),e=Tt(e*e,n),t/=2n;return r}(e,(t+1n)/4n,t):null}const Ut=0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2fn,Pt=0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n,Ft=0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798n,Ct=0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8n;function Lt(e,t,n){if(0n===t)return[0n,0n];const r=Tt(3n*e*e*Nt(2n*t,n),n),o=Tt(r*r-2n*e,n);return[o,Tt(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===Tt(-r,o))return[0n,0n];if(e===n&&t===r)return Lt(e,t,o);const i=Tt((r-t)*Nt(n-e,o),o),s=Tt(i*i-e-n,o);return[s,Tt(i*(e-s)-t,o)]}function Dt(e,t,n,r){let o=[0n,0n],i=[e,t];const s=n.toString(2);for(const e of s)"0"===e?(i=Mt(o[0],o[1],i[0],i[1],r),o=Lt(o[0],o[1],r)):(o=Mt(o[0],o[1],i[0],i[1],r),i=Lt(i[0],i[1],r));return o}function Zt(e,t,n){if(t<=0n||t>=Pt)throw new Error("Invalid private key");if(n||(n=Tt(Et(St(mt(St(vt(t,"BE")),vt(e,"BE"))),"BE"),Pt)),n<=0n||n>=Pt)throw new Error("Invalid nonce");const r=Tt(e,Pt),o=Dt(Ft,Ct,n,Ut),i=Tt(o[0],Pt);let s=Tt((r+Tt(i,Pt)*t)*Nt(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&&(s=Pt-s,a=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}}e.Uint8ArrayReader=jt;class qt{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}}e.Uint8ArrayWriter=qt;class Gt{constructor(e,t=0n){this.span=t,this.writer=new qt(new Uint8Array(e))}build(){return mt(bt(this.span,"LE"),this.writer.buffer)}hash(){const e=pt(xt(this.writer.buffer,32),(e,t)=>Gt.hashFunction(mt(e,t)));return Gt.hashFunction(mt(bt(this.span,"LE"),e))}}e.Chunk=Gt,Gt.hashFunction=St;class Ht{constructor(e,t=4096){this.counters=[1],this.capacity=t,this.chunks=[new Gt(t)],this.onChunk=e}static async root(e,n=4096){const r=new t(t.NOOP,n);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 Gt(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 Gt(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])}}e.MerkleTree=Ht,t=Ht,Ht.NOOP=async e=>{};class Vt{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 Vt)return e;const t=D(e.value),n=P(e.scale);return new Vt(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 Vt(BigInt(n+r),t)}static fromFloat(e,t){return Vt.fromDecimalString(e.toString(),t)}add(e){return this.assertSameScale(e),new Vt(this.value+e.value,this.scale)}subtract(e){return this.assertSameScale(e),new Vt(this.value-e.value,this.scale)}multiply(e){return new Vt(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 Vt(t,this.scale),new Vt(n,this.scale)]}exchange(e,t,n){if("*"===e){const e=this.value*t.value/10n**BigInt(this.scale);return new Vt(e,n)}this.assertSameScale(t);const r=this.value*10n**BigInt(n)/t.value;return new Vt(r,n)}compare(e){return this.assertSameScale(e),this.value>e.value?1:this.value<e.value?-1:0}toDecimalString(){if(0===this.scale)return this.value.toString();const e=this.value.toString();return`${e.slice(0,-this.scale)||"0"}.${e.slice(-this.scale).padStart(this.scale,"0")}`}toString(){return this.value.toString()}toJSON(){return this.toString()}toFloat(){return parseFloat(this.toDecimalString())}assertSameScale(e){if(this.scale!==e.scale)throw new Error(`Scale mismatch: expected ${this.scale}, but got ${e.scale}`)}}function Kt(e,t,n,r){const o=e.findIndex(e=>e===`--${t}`||e.startsWith(`--${t}=`)),i=e[o];if(!i)return(n||{})[r||t||""]||null;if(i.includes("="))return i.split("=")[1];const s=e[o+1];return s&&!s.startsWith("-")?s:(n||{})[r||t||""]||null}function Wt(e,t,n,r){const o=Kt(e,t,n,r);if(!o)throw new Error(`Missing argument ${t}`);return o}function Jt(e,t){const n=e[t];e.splice(t,1),e.unshift(n)}function Xt(e,t){return{x:e.x+t.x,y:e.y+t.y}}function Yt(e,t){return{x:e.x*t,y:e.y*t}}function Qt(e,t,n){return{x:e.x+Math.cos(t)*n,y:e.y+Math.sin(t)*n}}function en(e,t){return Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2)}function tn(e,t,n="row-first"){const r=[];if("column-first"===n)for(let n=0;n<e.length;n++)for(let o=0;o<e[0].length;o++)t(n,o)&&r.push({x:n,y:o});else for(let n=0;n<e[0].length;n++)for(let o=0;o<e.length;o++)t(o,n)&&r.push({x:o,y:n});return r}function nn(e,t,n){return!e[t-1]?.[n]}function rn(e,t,n){return!e[t+1]?.[n]}function on(e,t,n){return!e[t][n-1]}function sn(e,t,n){return!e[t][n+1]}function an(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]&&nn(e,t,n)&&on(e,t,n)&&r.push({x:t,y:n}),!e[t+1]?.[n-1]&&rn(e,t,n)&&on(e,t,n)&&r.push({x:t+1,y:n}),!e[t-1]?.[n+1]&&nn(e,t,n)&&sn(e,t,n)&&r.push({x:t,y:n+1}),!e[t+1]?.[n+1]&&rn(e,t,n)&&sn(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 cn(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 un(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=a/o,s=c/o,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 ln(e,t,n){const r=[],o=Qt(e,n,1e4);for(const n of t){const t=un(e,o,n.start,n.end);t&&r.push(t)}return r.length?r.reduce((t,n)=>en(e,n)<en(e,t)?n:t):null}e.FixedPointNumber=Vt;class fn{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}}e.PubSubChannel=fn,e.AsyncQueue=class{constructor(e,t){this.queue=[],this.running=0,this.onProcessed=new fn,this.onDrained=new fn,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(":")&&(o=":",r=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))}}e.TrieRouter=dn,e.RollingValueProvider=class{constructor(e){this.index=0,this.values=e}current(){return this.values[this.index]}next(){return this.index=(this.index+1)%this.values.length,this.values[this.index]}},e.Solver=class{constructor(){this.status="pending",this.steps=[],this.onStatusChange=async()=>{},this.onStepChange=async()=>{},this.onFinish=async()=>{},this.onError=async()=>{},this.context=new Map}getStatus(){return this.status}createInitialState(){return Object.fromEntries(this.steps.map(e=>[e.name,"pending"]))}setHooks(e){e.onStatusChange&&(this.onStatusChange=e.onStatusChange),e.onStepChange&&(this.onStepChange=e.onStepChange),e.onFinish&&(this.onFinish=e.onFinish),e.onError&&(this.onError=e.onError)}addStep(e){if(this.steps.find(t=>t.name===e.name))throw Error(`Step with name ${e.name} already exists`);this.steps.push(e)}async execute(){if("pending"!==this.status)throw Error(`Cannot execute solver in status ${this.status}`);this.status="in-progress",await this.onStatusChange(this.status);let e=this.createInitialState();for(const t of this.steps)try{if(t.transientSkipStepName){const n=e[t.transientSkipStepName];if("skipped"===n||"failed"===n){e={...e,[t.name]:"skipped"},await this.onStepChange(e);continue}}if(t.precondition&&!await t.precondition(this.context)){e={...e,[t.name]:"skipped"},await this.onStepChange(e);continue}e={...e,[t.name]:"in-progress"},await this.onStepChange(e);for(let e=0;"retry"===await t.action(this.context,e);e++);e={...e,[t.name]:"completed"},await this.onStepChange(e)}catch(n){throw e={...e,[t.name]:"failed"},this.status="failed",await this.onStatusChange(this.status),await this.onStepChange(e),await this.onError(n),n}return this.status="completed",await this.onStatusChange(this.status),await this.onFinish(),this.context}},e.Lock=class{constructor(e){this.queryFunction=e.queryFunction,this.lockFunction=e.lockFunction,this.unlockFunction=e.unlockFunction,this.timeoutMillis=e.timeoutMillis}async couldLock(){const e=await this.queryFunction();try{const t=F(e);if(Date.now()<t+this.timeoutMillis)return new Date(t+this.timeoutMillis)}catch{}return await this.lockFunction(Date.now().toString()),!0}async unlock(){await this.unlockFunction()}},e.Binary={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 _e(e,Ee)},uint8ArrayToBase64:function(e){return ke(e,Ee)},base32ToUint8Array:function(e){return _e(e,xe)},uint8ArrayToBase32:function(e){return ke(e,xe)},log2Reduce:pt,partition:xt,concatBytes:mt,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:bt,uint64ToNumber:function(e,t){return new DataView(e.buffer).getBigUint64(e.byteOffset,"LE"===t)},numberToUint256:vt,uint256ToNumber:Et,sliceBytes:function(e,t){const n=[];let r=0;for(const o of t)n.push(e.subarray(r,r+o)),r+=o;return n},keccak256:St,sha3_256:function(e){return Bt($t(new Array(50).fill(0),It(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:zt,padStartToMultiple:function(e,t,n=0){const r=e.length%t;return 0===r?e:zt(e,e.length+t-r,n)},padEnd:Ot,padEndToMultiple:function(e,t,n=0){const r=e.length%t;return 0===r?e:Ot(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}},e.Elliptic={privateKeyToPublicKey:function(e){if(e<=0n||e>=Pt)throw new Error("Invalid private key");return Dt(Ft,Ct,e,Ut)},compressPublicKey:function(e){const t=e[1]%2n==0n?2:3;return new Uint8Array([t,...vt(e[0],"BE")])},publicKeyFromCompressed:function(e){if(33!==e.length||2!==e[0]&&3!==e[0])throw new Error("Invalid compressed public key");const t=Et(e.slice(1),"BE"),n=Rt(Tt(t**3n+7n,Ut),Ut);if(!n)throw Error("Invalid x: does not correspond to a valid curve point");const r=Tt(-n,Ut),o=n%2n==0n;return[t,2===e[0]?o?n:r:o?r:n]},publicKeyToAddress:function(e){const t=new Uint8Array(20),n=St(mt(vt(e[0],"BE"),vt(e[1],"BE")));return t.set(n.subarray(12)),t},signMessage:function(e,t,n){return Zt(Et(St(e),"BE"),t,n)},signHash:Zt,verifySignature:function(e,t,n,r){const o=Tt(Et(St(e),"BE"),Pt),i=Nt(r,Pt),s=Tt(o*i,Pt),a=Tt(n*i,Pt),c=Dt(Ft,Ct,s,Ut),u=Dt(t[0],t[1],a,Ut);return n===Tt(Mt(c[0],c[1],u[0],u[1],Ut)[0],Pt)},recoverPublicKey:function(e,t,n,r){const o=Rt(Tt(t**3n+7n,Ut),Ut);if(!o)throw new Error("Invalid r: does not correspond to a valid curve point");const i=o%2n==(27n===r?0n:1n)?o:Ut-o,s=Tt(Et(St(e),"BE"),Pt),a=Dt(t,i,n,Ut),c=Dt(Ft,Ct,s,Ut),u=Mt(a[0],a[1],c[0],Tt(-c[1],Ut),Ut);return Dt(u[0],u[1],Nt(t,Pt),Ut)},checksumEncode:function(t){const n=e.Binary.uint8ArrayToHex(t),r=e.Binary.uint8ArrayToHex(e.Binary.keccak256(new Uint8Array([...n].map(e=>e.charCodeAt(0)))));let o="0x";for(let e=0;e<n.length;e++)parseInt(r[e],16)>7?o+=n[e].toUpperCase():o+=n[e];return o}},e.Random={intBetween:s,floatBetween:function(e,t,n=Math.random){return n()*(t-e)+e},chance:c,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=s(0,e-1,r),i=s(0,t-1,r)}while(n&&a(n,o,i));return[o,i]},procs:function(e,t=Math.random){const n=Math.floor(e);return c(e-n,t)?n+1:n}},e.Arrays={countUnique:function(e,t,n,r,o){const i=t?e.map(t):e,s={};for(const e of i)s[e]=(s[e]||0)+1;const a=r?ut(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(st(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:at,index:st,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:o,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&&(b(t)?n.push(t()):n.push(t));return n},pluck:function(e,t){return e.map(e=>e[t])},pick:u,pickMany:function(e,t,n=Math.random){if(t>e.length)throw new Error(`Count (${t}) is greater than array length (${e.length})`);return i(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=u(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 n=0;n<e.length-1;n++)if(r-=t[n],o>=r)return e[n];return l(e)},pickRandomIndices:i,pickGuaranteed:function(t,n,r,i,s,a=Math.random){const c=t.filter(e=>e!==n&&e!==r),u=[];for(null!==n&&u.push(n);c.length&&u.length<i;){const t=e.Random.intBetween(0,c.length-1,a);s(c[t],u)&&u.push(c[t]),c.splice(t,1)}return o(u,a),{values:u,indexOfGuaranteed:null!==n?u.indexOf(n):-1}},last:l,pipe:f,makePipe:function(e,t){return n=>f(n,e,t)},sortWeighted:function(e,t,n=Math.random){const r=t.map(e=>n()*e),o=[];for(let t=0;t<e.length;t++)o.push([e[t],r[t]]);return o.sort((e,t)=>t[1]-e[1]).map(e=>e[0])},pushAll:G,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])&&G(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:lt,createOscillator:function(e){let t=0;return{next:()=>e[t++%e.length]}},organiseWithLimits:function(e,t,n,r,o){const i={};for(const e of Object.keys(t))i[e]=[];i[r]=[],o&&(e=e.sort(o));for(const o of e){const e=o[n],s=t[e]?e:r;i[s].length>=t[s]?i[r].push(o):i[s].push(o)}return i},tickPlaybook:function(e){if(0===e.length)return null;const t=e[0];return t.ttlMax?--t.ttl<=0&&e.shift():t.ttlMax=t.ttl,{progress:(t.ttlMax-t.ttl)/t.ttlMax,data:t.data}},getArgument:Kt,getBooleanArgument:function(e,t,n,r){const o=e.some(e=>e.endsWith("-"+t)),i=Kt(e,t,n,r);if(!i&&o)return!0;if(!i&&!o)return null;if(["true","1","yes","y","on"].includes(i.toLowerCase()))return!0;if(["false","0","no","n","off"].includes(i.toLowerCase()))return!1;throw Error(`Invalid boolean argument ${t}: ${i}`)},getNumberArgument:function(e,t,n,r){const o=Kt(e,t,n,r);if(!o)return null;try{return nt(o)}catch{throw new Error(`Invalid number argument ${t}: ${o}`)}},requireStringArgument:Wt,requireNumberArgument:function(e,t,n,r){const o=Wt(e,t,n,r);try{return nt(o)}catch{throw new Error(`Invalid argument ${t}: ${o}`)}},bringToFront:function(e,t){const n=[...e];return Jt(n,t),n},bringToFrontInPlace:Jt,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 ht(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}},e.System={sleepMillis:r,forever:async function(e,t,n){for(;;){try{await e()}catch(e){n&&n("Error in forever",e)}await r(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,o=0;for(let i=0;i<t.attempts;i++){try{if(await e()){if(o++,o>=n)return}else o=0}catch{o=0}i<t.attempts-1&&await r(t.waitMillis)}throw Error("Timed out waiting for predicate")},expandError:function(e,t){if(v(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,o,i,s){let a=null;for(let c=0;c<=t;c++)try{return await e()}catch(e){if(a=e,c===t)break;const u=n+c/(t-1)*(o-n);i&&i("Error in withRetries, retrying",{attempt:c+1,allowedFailures:t,delayMillis:u,error:e}),s&&s(),await r(u)}throw a}},e.Numbers={make:nt,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:rt,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?et:tt,i=t?.precision??1;if(e<Qe[0])return`${e}${r}`;for(let t=0;t<Qe.length-1;t++)if(e<Qe[t+1])return`${(e/Qe[t]).toFixed(i)}${n?" ":""}${o[t]}${r}`;return`${(e/Qe[Qe.length-1]).toFixed(i)}${n?" ":""}${o[Qe.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:Ge[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:p,formatDistance:function(e){return e>1e3?(e/1e3).toFixed(0)+" km":e>=500?p(e,100)+" m":e>=100?p(e,50)+" m":p(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)}`}},e.Promises={raceFulfilled:async function(e){return n(Promise.all(e.map(n)))},invert:n,runInParallelBatches:async function(e,t=1){const n=at(e,t),r=[],o=n.map(async e=>{for(const t of e)r.push(await t())});return await Promise.all(o),r}},e.Dates={getTimestamp:function(e,t){const n=new Date(t?.now||Date.now()),r=t?.labels||Pe,o=_(e)?e:new Date(e);if(Ue(n)===Ue(o))return r.today(o.getUTCHours(),o.getUTCMinutes(),o.getUTCHours()>12);if(Ue(n)-Ue(o)===1)return r.yesterday();const i=je(o);return Ue(n)-Ue(o)<7?r[i.day]():r.weeks(Math.round((n.getTime()-o.getTime())/6048e5))},getTimeDelta:Ce,secondsToHumanTime:function(e,t=Fe){return Ce(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(!Le[e]||Date.now()>Le[e])&&(Le[e]=Date.now()+t,!0)},timeSince:function(e,t,n){return t=_(t)?t.getTime():t,((n=n?_(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:Re,humanizeProgress:function(e){return`[${Math.floor(100*e.progress)}%] ${Re(e.deltaMs)} out of ${Re(e.totalTimeMs)} (${Re(e.remainingTimeMs)} left) [${Math.round(e.baseTimeMs)} ms each]`},createTimeDigits:Ne,mapDayNumber:Ze,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:qe[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=rt(F(t),0,23),o=rt(F(n),0,59);return`${Ne(r)}:${Ne(o)}`},absoluteDays:Ue},e.Objects={safeParse:function(e){try{return JSON.parse(e)}catch{return null}},deleteDeep:function(e,t){const n=Y(t,"."),r=Q(t,".");if(!n||!r)return;const o=d(e,n);o&&delete o[r]},getDeep:d,setDeep:h,incrementDeep:function(e,t,n=1){const r=d(e,t)||0;return h(e,t,r+n),r},ensureDeep:function(e,t,n){return d(e,t)||h(e,t,n)},replaceDeep:function(e,t,n){const r=d(e,t);if(!r)throw new Error("Key '"+t+"' does not exist.");return h(e,t,n),r},getFirstDeep:function(e,t,n){for(const n of t){const t=d(e,n);if(t)return t}if(n){const t=Object.values(e);if(t.length)return t[0]}return null},deepMergeInPlace:j,deepMerge2:function(e,t){const n={};return j(n,e),j(n,t),n},deepMerge3:function(e,t,n){const r={};return j(r,e),j(r,t),j(r,n),r},mapAllAsync:async function(e,t){const n=[];for(const r of e)n.push(await t(r));return n},cloneWithJson:function(e){return JSON.parse(JSON.stringify(e))},sortObject:Ke,sortArray:We,sortAny:Je,deepEquals:Xe,deepEqualsEvery:function(...e){for(let t=1;t<e.length;t++)if(!Xe(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:q,zipSum:function(e){return q(e,(e,t)=>e+t)},removeEmptyArrays:function(e){for(const t of Object.keys(e))(y(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]||v(t[1])&&k(t[1]))&&delete e[t[0]];return e},flatten:function(e,t=!1,n){return it({},e,n||"",!1,t)},unflatten:function e(t){if(!m(t))return t;const n=Array.isArray(t)?[]:{};for(const[r,o]of Object.entries(t))Array.isArray(o)?h(n,r,o.map(t=>e(t))):h(n,r,o);return n},match:function(e,t,n){return t[e]?t[e]:n},sort:ut,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&&h(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 e=0;e<n.length-1;e++)o*=n[e],i.push(o);const s=[];for(let n=0;n<r;n++){const r={};for(let o=0;o<t.length;o++){const s=e[t[o]],a=Math.floor(n/i[o])%s.length;r[t[o]]=s[a]}s.push(r)}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:ft,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){ft(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:Ye,mapRandomKey:function(e,t){const n=Ye(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:Te,parseQueryString:function(e){const t={},n=e.split("&");for(const e of n){const[n,r]=e.split("=");n&&r&&(t[n]=decodeURIComponent(r))}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=>ee(e,t)).map(e=>e[0]&&e[1]?[oe(e[0]),oe(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)}},e.Types={isFunction:b,isObject:m,isStrictlyObject:g,isEmptyArray:y,isEmptyObject:function(e){return g(e)&&0===Object.keys(e).length},isUndefined:w,isString:v,isNumber:E,isBoolean:x,isDate:_,isBlank:k,isId:A,isIntegerString:I,isHexString:$,isUrl:L,isBigint:M,isNullable:function(e,t){return null==t||e(t)},asString:R,asHexString:function(e,t){if(!$(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(!R(e,t).split("").every(e=>"_"===e||ue(e)))throw new TypeError(`Expected safe string${t?.name?` for ${t.name}`:""}, got: `+e);return e},asIntegerString:function(e,t){if(!I(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(!b(e))throw new TypeError(`Expected function${t?.name?` for ${t.name}`:""}, got: `+e);return e},asInteger:F,asBoolean:function(e,t){if("true"===e)return!0;if("false"===e)return!1;if(!x(e))throw new TypeError(`Expected boolean${t?.name?` for ${t.name}`:""}, got: `+e);return e},asDate:function(e,t){if(!_(e))throw new TypeError(`Expected date${t?.name?` for ${t.name}`:""}, got: `+e);return e},asNullableString:function(e){return k(e)?null:e},asEmptiableString:function(e,t){if(!v(e))throw new TypeError(`Expected string${t?.name?` for ${t.name}`:""}, got: `+e);return e},asId:function(e,t){if(A(e))return e;const n=parseInt(e,10);if(!A(n))throw new TypeError(`Expected id${t?.name?` for ${t.name}`:""}, got: `+e);return n},asTime:function(e,t){if(!v(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:C,asNullableObject:function(e,t){return null===e?null:C(e,t)},asStringMap:function(e,t){const n=C(e,t);for(const r of Object.keys(n))if(!v(n[r]))throw new TypeError(`Expected string map${t?.name?` for ${t.name}`:""}, got: `+e);return n},asNumericDictionary:function(e,t){const n=C(e),r=Object.keys(n),o=Object.values(n);if(!r.every(v)||!o.every(E))throw new TypeError(`Expected numeric dictionary${t?.name?` for ${t.name}`:""}, got: `+e);return n},asUrl:function(e,t){if(!L(e))throw new TypeError(`Expected url${t?.name?` for ${t.name}`:""}, got: `+e);return e},asBigint:D,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:Z,enforceArrayShape:function(e,t){return e.every(e=>Z(e,t))},isPng:gt,isJpg:yt,isWebp:wt,isImage:function(e){return gt(e)||yt(e)||wt(e)}},e.Strings={tokenizeByCount:function(e,t){return ct(e,Math.ceil(e.length/t))},tokenizeByLength:ct,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=B){const r=te(e,n);for(const e of r)if(t(e))return e;return null},randomHex:function(e,t=Math.random){let n="";for(let r=0;r<e;r++)n+=N[Math.floor(16*t())];return n},randomLetter:function(e,t=Math.random){let n="";for(let r=0;r<e;r++)n+=S[Math.floor(26*t())];return n},randomAlphanumeric:function(e,t=Math.random){let n="";for(let r=0;r<e;r++)n+=z[Math.floor(62*t())];return n},randomRichAscii:function(e,t=Math.random){let n="";for(let r=0;r<e;r++)n+=O[Math.floor(89*t())];return n},randomUnicode:function(e,t=Math.random){let n="";for(let r=0;r<e;r++)n+=T[Math.floor(t()*T.length)];return n},includesAny:function(e,t){return t.some(t=>e.includes(t))},slugify:V,normalForm:function(e){return V(e).replaceAll("-","")},enumify:function(e){return V(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[e,n]of Object.entries(W))t=t.replaceAll(e,n);return t},after:X,afterLast:Q,before:J,beforeLast:Y,betweenWide:function(e,t,n){const r=Y(e,n);return r?X(r,t):null},betweenNarrow:function(e,t,n){const r=X(e,t);return r?J(r,n):null},getPreLine:function(e){return e.replace(/ +/g," ").replace(/^ /gm,"")},containsWord:Be,containsWords:function(e,t,n){return"any"===n?t.some(t=>Be(e,t)):t.every(t=>Be(e,t))},joinUrl:Ve,getFuzzyMatchScore:K,sortByFuzzyScore:function(e,t){return e.filter(e=>K(e,t)).sort((e,n)=>K(n,t)-K(e,t))},splitOnce:ee,splitAll:te,randomize:function(e,t=Math.random){return e.replace(/\{(.+?)\}/g,(e,n)=>u(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 t of r){const n=e(o+t+i);s=s.concat(n)}return s},shrinkTrim:oe,capitalize:ie,decapitalize:se,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 e of s)e!==t||i?e!==n||(o||i)&&!i?o+=e:i=!i:(r.push(o),o="");return r.push(o),r},surroundInOut:function(e,t){return t+e.split("").join(t)+t},getExtension:ne,getBasename:re,normalizeEmail:function(e){let[t,n]=e.split("@");t=oe(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=oe(n.toLowerCase()).replaceAll(" ",""),`${r}@${n}`},normalizeFilename:function(e){const t=re(e),n=ne(e);return n?`${t}.${n}`:t},parseFilename:function(e){const t=re(e),n=ne(e);return{basename:t,extension:n,filename:n?`${t}.${n}`:t}},camelToTitle:function(e){return ie(e.replace(/([A-Z])/g," $1"))},slugToTitle:function(e){return e.split("-").map(ie).join(" ")},slugToCamel:function(e){return se(e.split("-").map(ie).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:be,extractBlock:ve,extractAllBlocks:function(e,t){const n=[];let r=t.wordBoundary?me(e,[`${t.opening} `,`${t.opening}\n`],t.start||0):e.indexOf(t.opening,t.start||0);for(;;){if(-1===r)return n;const o=ve(e,{...t,start:r});if(!o)return n;n.push(o),r=t.wordBoundary?me(e,[`${t.opening} `,`${t.opening}\n`],r+o.length):e.indexOf(t.opening,r+o.length)}},replaceBlocks:function(t,n,r){let o=0;for(;;){const i=e.Strings.extractBlock(t,{...r,start:o});if(!i)return t;const s=n(i);o=t.indexOf(i,o)+s.length,t=t.replace(i,s)}},indexOfEarliest:me,lastIndexOfBefore:we,parseHtmlAttributes:function(e){const t={},n=e.match(/([a-z\-]+)="([^"]+)"/g);if(n)for(const e of n){const[n,r]=ee(e,"=");t[n]=r.slice(1,r.length-1)}return t},readNextWord:Se,readWordsAfterAll:function(e,t,n=[]){const r=pe(e,t),o=[];for(const i of r)o.push(Se(e,i+t.length,n));return o},resolveVariables:function(e,t,n="$",r=":"){for(const o in t)e=ze(e,o,t[o],n,r);return e=Oe(e)},resolveVariableWithDefaultSyntax:ze,resolveRemainingVariablesWithDefaults:Oe,isLetter:ae,isDigit:ce,isLetterOrDigit:ue,isValidObjectPathCharacter:function(e){return ue(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:pe,lineMatches:he,linesMatchInOrder:function(e,t,n=!0){let r=0;for(const o of t){let t=!1;for(;!t&&r<e.length;)he(e[r],o,n)&&(t=!0),r++;if(!t)return!1}return!0},represent:function e(t,n="json",r=0){if(t&&b(t.represent)){const e=t.represent();if(v(e))return"json"===n&&0===r?JSON.stringify(e):e}if(m(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 w(t)&&(t="undefined"),0===r?JSON.stringify(t):t},resolveMarkdownLinks:function(e,t){let n=e.indexOf("](");for(;-1!==n;){const r=we(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 Ve([e,t])+Te(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=ye(e,n);if(-1===r){t.push({string:e.slice(n),symbol:null});break}const o=ge(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=me(e,["http://","https://"],n);if(-1===r){t.push({string:e.slice(n),symbol:null});break}const o=me(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 e=0;e<n.length;e++){const t=n[e];if(t.startsWith(":"))o[t.slice(1)]=r[e];else if(t!==r[e])return null}return o},explodeReplace:Ae,generateVariants:function(t,n,r,o=Math.random){const i=e.Arrays.shuffle(n.map(t=>({variants:e.Arrays.shuffle(t.variants.map(e=>e),o),avoid:t.avoid})),o),s=[];for(const e of i){const n=e.variants.filter(t=>t!==e.avoid),o=n.find(e=>t.includes(e));if(o&&(G(s,Ae(t,o,n)),s.length>=r))break}if(s.length<r)for(const e of i){const n=e.variants.find(e=>t.includes(e));if(n&&(G(s,Ae(t,n,e.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:Ie,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}=Ie(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 t=0;t<=e.length;t++)n[t]=[t];for(let e=0;e<=t.length;e++)n[0][e]=e;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:$e,findCommonDirectory:function(e){const t=$e(e),n=t.lastIndexOf("/");return-1===n?"":t.slice(0,n+1)}},e.Assertions={asEqual:function(e,t){if(e!==t)throw Error(`Expected [${e}] to equal [${t}]`);return[e,t]},asTrue:function(e){if(!0!==e)throw Error(`Expected [true], got: [${e}]`);return e},asTruthy:function(e){if(!e)throw Error(`Expected truthy value, got: [${e}]`);return e},asFalse:function(e){if(!1!==e)throw Error(`Expected [false], got: [${e}]`);return e},asFalsy:function(e){if(e)throw Error(`Expected falsy value, got: [${e}]`);return e},asEither:function(e,t){if(!t.includes(e))throw Error(`Expected any of [${t.join(", ")}], got: [${e}]`);return e}},e.Cache={get:async function(e,t,n,r){const o=Date.now(),i=He.get(e);if(i&&i.validUntil>o)return i.value;r?.onMiss?.();try{const r=await n();return He.set(e,{value:r,validUntil:o+t}),r}catch(e){throw r?.onFailure?.(e),e}},getDeferred:function(e,t,n,r){const o=Date.now(),i=He.get(e);if(i&&i.validUntil>o)return i.value;r?.onMiss?.();const s=n();return He.set(e,{value:s,validUntil:o+t}),s.catch(t=>{He.delete(e),r?.onFailure?.(t)}),s},delete:function(e){He.delete(e)},deleteExpired:function(){const e=Date.now();for(const[t,n]of He.entries())n.validUntil<=e&&He.delete(t)},size:function(){return He.size},clear:function(){He.clear()}},e.Vector={addPoint:Xt,subtractPoint:function(e,t){return{x:e.x-t.x,y:e.y-t.y}},multiplyPoint:Yt,normalizePoint:function(e){const t=Math.sqrt(e.x*e.x+e.y*e.y);return{x:e.x/t,y:e.y/t}},pushPoint:Qt,filterCoordinates:tn,findCorners:function(e,t,n,r){const o=[{x:0,y:0},{x:n,y:0},{x:0,y:r},{x:n,y:r}];for(let t=0;t<e.length;t++)for(let n=0;n<e[0].length;n++){const r=an(e,t,n);for(const e of r)o.some(t=>t.x===e.x&&t.y===e.y)||o.push(e)}return o.map(e=>({x:e.x*t,y:e.y*t}))},findLines:function(e,t){const n=tn(e,(t,n)=>0===e[t][n]&&0!==e[t][n+1],"row-first").map(e=>({...e,dx:1,dy:0})),r=tn(e,(t,n)=>0===e[t][n]&&0!==e[t][n-1],"row-first").map(e=>({...e,dx:1,dy:0})),o=tn(e,(t,n)=>0===e[t][n]&&0!==e[t-1]?.[n],"column-first").map(e=>({...e,dx:0,dy:1})),i=tn(e,(t,n)=>0===e[t][n]&&0!==e[t+1]?.[n],"column-first").map(e=>({...e,dx:0,dy:1}));return n.forEach(e=>e.y++),i.forEach(e=>e.x++),[...lt([...o,...i],(e,t)=>e.x===t.x&&e.y-1===t.y),...lt([...r,...n],(e,t)=>e.y===t.y&&e.x-1===t.x)].map(e=>({start:e[0],end:l(e)})).map(e=>({start:Yt(e.start,t),end:Yt(Xt(e.end,{x:e.start.dx,y:e.start.dy}),t)}))},raycast:ln,raycastCircle:function(e,t,n){const r=cn(e,n),o=[];for(const n of r){const r=ln(e,t,n-.001),i=ln(e,t,n+.001);r&&o.push(r),i&&o.push(i)}return o},getLineIntersectionPoint:un}}(Wr)),Wr);const Xr="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0;
2
+ /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Yr(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function Qr(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function eo(e,...t){if(!Yr(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 to(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.createHasher");Qr(e.outputLen),Qr(e.blockLen)}function no(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 ro(e,t){eo(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function oo(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function io(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function so(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function ao(e,t){return e<<32-t|e>>>t}function co(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}const uo=(()=>68===new Uint8Array(new Uint32Array([287454020]).buffer)[0])()?e=>e:function(e){for(let t=0;t<e.length;t++)e[t]=co(e[t]);return e},lo=(()=>"function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex)(),fo=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function ho(e){if(eo(e),lo)return e.toHex();let t="";for(let n=0;n<e.length;n++)t+=fo[e[n]];return t}const po=48,mo=57,go=65,yo=70,wo=97,bo=102;function vo(e){return e>=po&&e<=mo?e-po:e>=go&&e<=yo?e-(go-10):e>=wo&&e<=bo?e-(wo-10):void 0}function Eo(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);if(lo)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 t=0,o=0;t<n;t++,o+=2){const n=vo(e.charCodeAt(o)),i=vo(e.charCodeAt(o+1));if(void 0===n||void 0===i){const t=e[o]+e[o+1];throw new Error('hex string expected, got non-hex character "'+t+'" at index '+o)}r[t]=16*n+i}return r}function xo(e){return"string"==typeof e&&(e=function(e){if("string"!=typeof e)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(e))}(e)),eo(e),e}function _o(...e){let t=0;for(let n=0;n<e.length;n++){const r=e[n];eo(r),t+=r.length}const n=new Uint8Array(t);for(let t=0,r=0;t<e.length;t++){const o=e[t];n.set(o,r),r+=o.length}return n}let ko=class{};function Ao(e){const t=t=>e().update(xo(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function Io(e=32){if(Xr&&"function"==typeof Xr.getRandomValues)return Xr.getRandomValues(new Uint8Array(e));if(Xr&&"function"==typeof Xr.randomBytes)return Uint8Array.from(Xr.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}function $o(e,t,n){return e&t^~e&n}function Bo(e,t,n){return e&t^e&n^t&n}class So extends ko{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=so(this.buffer)}update(e){no(this),eo(e=xo(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){const t=so(e);for(;r<=o-i;i+=r)this.process(t,i);continue}n.set(e.subarray(i,i+s),this.pos),this.pos+=s,i+=s,this.pos===r&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){no(this),ro(e,this),this.finished=!0;const{buffer:t,view:n,blockLen:r,isLE:o}=this;let{pos:i}=this;t[i++]=128,io(this.buffer.subarray(i)),this.padOffset>r-i&&(this.process(n,0),i=0);for(let e=i;e<r;e++)t[e]=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=so(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=a/4,u=this.get();if(c>u.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e<c;e++)s.setUint32(4*e,u[e],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 zo=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Oo=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]),To=new Uint32Array(64);let No=class extends So{constructor(e=32){super(64,e,8,!1),this.A=0|zo[0],this.B=0|zo[1],this.C=0|zo[2],this.D=0|zo[3],this.E=0|zo[4],this.F=0|zo[5],this.G=0|zo[6],this.H=0|zo[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 n=0;n<16;n++,t+=4)To[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=To[e-15],n=To[e-2],r=ao(t,7)^ao(t,18)^t>>>3,o=ao(n,17)^ao(n,19)^n>>>10;To[e]=o+To[e-7]+r+To[e-16]|0}let{A:n,B:r,C:o,D:i,E:s,F:a,G:c,H:u}=this;for(let e=0;e<64;e++){const t=u+(ao(s,6)^ao(s,11)^ao(s,25))+$o(s,a,c)+Oo[e]+To[e]|0,l=(ao(n,2)^ao(n,13)^ao(n,22))+Bo(n,r,o)|0;u=c,c=a,a=s,s=i+t|0,i=o,o=r,r=n,n=t+l|0}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(){io(To)}destroy(){this.set(0,0,0,0,0,0,0,0),io(this.buffer)}};const Ro=Ao(()=>new No);let Uo=class extends ko{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,to(e);const n=xo(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 e=0;e<o.length;e++)o[e]^=54;this.iHash.update(o),this.oHash=e.create();for(let e=0;e<o.length;e++)o[e]^=106;this.oHash.update(o),io(o)}update(e){return no(this),this.iHash.update(e),this}digestInto(e){no(this),eo(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 Po=(e,t,n)=>new Uo(e,t).update(n).digest();Po.create=(e,t)=>new Uo(e,t);
3
3
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
4
- const No=BigInt(0),Ro=BigInt(1);function Uo(e,t=""){if("boolean"!=typeof e){throw new Error((t&&`"${t}"`)+"expected boolean, got type="+typeof e)}return e}function Po(e,t,n=""){const r=Yr(e),o=e?.length,i=void 0!==t;if(!r||i&&o!==t){throw new Error((n&&`"${n}" `)+"expected Uint8Array"+(i?` of length ${t}`:"")+", got "+(r?`length=${o}`:"type="+typeof e))}return e}function Fo(e){const t=e.toString(16);return 1&t.length?"0"+t:t}function Co(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);return""===e?No:BigInt("0x"+e)}function Lo(e){return Co(co(e))}function Mo(e){return eo(e),Co(co(Uint8Array.from(e).reverse()))}function Do(e,t){return yo(e.toString(16).padStart(2*t,"0"))}function Zo(e,t){return Do(e,t).reverse()}function jo(e,t,n){let r;if("string"==typeof t)try{r=yo(t)}catch(t){throw new Error(e+" must be hex string or Uint8Array, cause: "+t)}else{if(!Yr(t))throw new Error(e+" must be hex string or Uint8Array");r=Uint8Array.from(t)}return r.length,r}const qo=e=>"bigint"==typeof e&&No<=e;function Go(e,t,n,r){if(!function(e,t,n){return qo(e)&&qo(t)&&qo(n)&&t<=e&&e<n}(t,n,r))throw new Error("expected valid "+e+": "+n+" <= n < "+r+", got "+t)}function Ho(e){let t;for(t=0;e>No;e>>=Ro,t+=1);return t}const Vo=e=>(Ro<<BigInt(e))-Ro;function Ko(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 Wo(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}}
5
- /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Jo=BigInt(0),Xo=BigInt(1),Yo=BigInt(2),Qo=BigInt(3),ei=BigInt(4),ti=BigInt(5),ni=BigInt(7),ri=BigInt(8),oi=BigInt(9),ii=BigInt(16);function si(e,t){const n=e%t;return n>=Jo?n:t+n}function ai(e,t,n){let r=e;for(;t-- >Jo;)r*=r,r%=n;return r}function ci(e,t){if(e===Jo)throw new Error("invert: expected non-zero number");if(t<=Jo)throw new Error("invert: expected positive modulus, got "+t);let n=si(e,t),r=t,o=Jo,i=Xo;for(;n!==Jo;){const e=r%n,t=o-i*(r/n);r=n,n=e,o=i,i=t}if(r!==Xo)throw new Error("invert: does not exist");return si(o,t)}function ui(e,t,n){if(!e.eql(e.sqr(t),n))throw new Error("Cannot find square root")}function li(e,t){const n=(e.ORDER+Xo)/ei,r=e.pow(t,n);return ui(e,r,t),r}function fi(e,t){const n=(e.ORDER-ti)/ri,r=e.mul(t,Yo),o=e.pow(r,n),i=e.mul(t,o),s=e.mul(e.mul(i,Yo),o),a=e.mul(i,e.sub(s,e.ONE));return ui(e,a,t),a}function di(e){if(e<Qo)throw new Error("sqrt is not defined for small field");let t=e-Xo,n=0;for(;t%Yo===Jo;)t/=Yo,n++;let r=Yo;const o=wi(e);for(;1===gi(o,r);)if(r++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(1===n)return li;let i=o.pow(r,t);const s=(t+Xo)/Yo;return function(e,r){if(e.is0(r))return r;if(1!==gi(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=Xo<<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 hi(e){return e%ei===Qo?li:e%ri===ti?fi:e%ii===oi?function(e){const t=wi(e),n=di(e),r=n(t,t.neg(t.ONE)),o=n(t,r),i=n(t,t.neg(r)),s=(e+ni)/ii;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 d=e.eql(e.sqr(a),t),h=e.cmov(n,a,d);return ui(e,h,t),h}}(e):di(e)}const pi=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function mi(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 gi(e,t){const n=(e.ORDER-Xo)/Yo,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 yi(e,t){void 0!==t&&Qr(t);const n=void 0!==t?t:e.toString(2).length;return{nBitLength:n,nByteLength:Math.ceil(n/8)}}function wi(e,t,n=!1,r={}){if(e<=Jo)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}=yi(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:Vo(c),ZERO:Jo,ONE:Xo,allowedLengths:s,create:t=>si(t,e),isValid:t=>{if("bigint"!=typeof t)throw new Error("invalid field element: expected bigint, got "+typeof t);return Jo<=t&&t<e},is0:e=>e===Jo,isValidNot0:e=>!f.is0(e)&&f.isValid(e),isOdd:e=>(e&Xo)===Xo,neg:t=>si(-t,e),eql:(e,t)=>e===t,sqr:t=>si(t*t,e),add:(t,n)=>si(t+n,e),sub:(t,n)=>si(t-n,e),mul:(t,n)=>si(t*n,e),pow:(e,t)=>function(e,t,n){if(n<Jo)throw new Error("invalid exponent, negatives unsupported");if(n===Jo)return e.ONE;if(n===Xo)return t;let r=e.ONE,o=t;for(;n>Jo;)n&Xo&&(r=e.mul(r,o)),o=e.sqr(o),n>>=Xo;return r}(f,e,t),div:(t,n)=>si(t*ci(n,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>ci(t,e),sqrt:i||(t=>(l||(l=hi(e)),l(f,t))),toBytes:e=>n?Zo(e,u):Do(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?Mo(t):Lo(t);if(a&&(o=si(o,e)),!r&&!f.isValid(o))throw new Error("invalid field element: outside of range 0..ORDER");return o},invertBatch:e=>mi(f,e),cmov:(e,t,n)=>n?t:e});return Object.freeze(f)}function bi(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 vi(e){const t=bi(e);return t+Math.ceil(t/2)}
4
+ const Fo=BigInt(0),Co=BigInt(1);function Lo(e,t=""){if("boolean"!=typeof e){throw new Error((t&&`"${t}"`)+"expected boolean, got type="+typeof e)}return e}function Mo(e,t,n=""){const r=Yr(e),o=e?.length,i=void 0!==t;if(!r||i&&o!==t){throw new Error((n&&`"${n}" `)+"expected Uint8Array"+(i?` of length ${t}`:"")+", got "+(r?`length=${o}`:"type="+typeof e))}return e}function Do(e){const t=e.toString(16);return 1&t.length?"0"+t:t}function Zo(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);return""===e?Fo:BigInt("0x"+e)}function jo(e){return Zo(ho(e))}function qo(e){return eo(e),Zo(ho(Uint8Array.from(e).reverse()))}function Go(e,t){return Eo(e.toString(16).padStart(2*t,"0"))}function Ho(e,t){return Go(e,t).reverse()}function Vo(e,t,n){let r;if("string"==typeof t)try{r=Eo(t)}catch(t){throw new Error(e+" must be hex string or Uint8Array, cause: "+t)}else{if(!Yr(t))throw new Error(e+" must be hex string or Uint8Array");r=Uint8Array.from(t)}return r.length,r}const Ko=e=>"bigint"==typeof e&&Fo<=e;function Wo(e,t,n,r){if(!function(e,t,n){return Ko(e)&&Ko(t)&&Ko(n)&&t<=e&&e<n}(t,n,r))throw new Error("expected valid "+e+": "+n+" <= n < "+r+", got "+t)}function Jo(e){let t;for(t=0;e>Fo;e>>=Co,t+=1);return t}const Xo=e=>(Co<<BigInt(e))-Co;function Yo(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 Qo(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}}
5
+ /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const ei=BigInt(0),ti=BigInt(1),ni=BigInt(2),ri=BigInt(3),oi=BigInt(4),ii=BigInt(5),si=BigInt(7),ai=BigInt(8),ci=BigInt(9),ui=BigInt(16);function li(e,t){const n=e%t;return n>=ei?n:t+n}function fi(e,t,n){let r=e;for(;t-- >ei;)r*=r,r%=n;return r}function di(e,t){if(e===ei)throw new Error("invert: expected non-zero number");if(t<=ei)throw new Error("invert: expected positive modulus, got "+t);let n=li(e,t),r=t,o=ei,i=ti;for(;n!==ei;){const e=r%n,t=o-i*(r/n);r=n,n=e,o=i,i=t}if(r!==ti)throw new Error("invert: does not exist");return li(o,t)}function hi(e,t,n){if(!e.eql(e.sqr(t),n))throw new Error("Cannot find square root")}function pi(e,t){const n=(e.ORDER+ti)/oi,r=e.pow(t,n);return hi(e,r,t),r}function mi(e,t){const n=(e.ORDER-ii)/ai,r=e.mul(t,ni),o=e.pow(r,n),i=e.mul(t,o),s=e.mul(e.mul(i,ni),o),a=e.mul(i,e.sub(s,e.ONE));return hi(e,a,t),a}function gi(e){if(e<ri)throw new Error("sqrt is not defined for small field");let t=e-ti,n=0;for(;t%ni===ei;)t/=ni,n++;let r=ni;const o=xi(e);for(;1===vi(o,r);)if(r++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(1===n)return pi;let i=o.pow(r,t);const s=(t+ti)/ni;return function(e,r){if(e.is0(r))return r;if(1!==vi(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=ti<<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 yi(e){return e%oi===ri?pi:e%ai===ii?mi:e%ui===ci?function(e){const t=xi(e),n=gi(e),r=n(t,t.neg(t.ONE)),o=n(t,r),i=n(t,t.neg(r)),s=(e+si)/ui;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 d=e.eql(e.sqr(a),t),h=e.cmov(n,a,d);return hi(e,h,t),h}}(e):gi(e)}const wi=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function bi(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 vi(e,t){const n=(e.ORDER-ti)/ni,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 Ei(e,t){void 0!==t&&Qr(t);const n=void 0!==t?t:e.toString(2).length;return{nBitLength:n,nByteLength:Math.ceil(n/8)}}function xi(e,t,n=!1,r={}){if(e<=ei)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}=Ei(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:Xo(c),ZERO:ei,ONE:ti,allowedLengths:s,create:t=>li(t,e),isValid:t=>{if("bigint"!=typeof t)throw new Error("invalid field element: expected bigint, got "+typeof t);return ei<=t&&t<e},is0:e=>e===ei,isValidNot0:e=>!f.is0(e)&&f.isValid(e),isOdd:e=>(e&ti)===ti,neg:t=>li(-t,e),eql:(e,t)=>e===t,sqr:t=>li(t*t,e),add:(t,n)=>li(t+n,e),sub:(t,n)=>li(t-n,e),mul:(t,n)=>li(t*n,e),pow:(e,t)=>function(e,t,n){if(n<ei)throw new Error("invalid exponent, negatives unsupported");if(n===ei)return e.ONE;if(n===ti)return t;let r=e.ONE,o=t;for(;n>ei;)n&ti&&(r=e.mul(r,o)),o=e.sqr(o),n>>=ti;return r}(f,e,t),div:(t,n)=>li(t*di(n,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>di(t,e),sqrt:i||(t=>(l||(l=yi(e)),l(f,t))),toBytes:e=>n?Ho(e,u):Go(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?qo(t):jo(t);if(a&&(o=li(o,e)),!r&&!f.isValid(o))throw new Error("invalid field element: outside of range 0..ORDER");return o},invertBatch:e=>bi(f,e),cmov:(e,t,n)=>n?t:e});return Object.freeze(f)}function _i(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 ki(e){const t=_i(e);return t+Math.ceil(t/2)}
6
6
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
7
- const Ei=BigInt(0),_i=BigInt(1);function xi(e,t){const n=t.negate();return e?n:t}function ki(e,t){const n=mi(e.Fp,t.map(e=>e.Z));return t.map((t,r)=>e.fromAffine(t.toAffine(n[r])))}function Ai(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function Ii(e,t){Ai(e,t);const n=2**e;return{windows:Math.ceil(t/e)+1,windowSize:2**(e-1),mask:Vo(e),maxNumber:n,shiftBy:BigInt(e)}}function $i(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+=_i);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}}const Bi=new WeakMap,zi=new WeakMap;function Si(e){return zi.get(e)||1}function Oi(e){if(e!==Ei)throw new Error("invalid wNAF")}let Ti=class{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>Ei;)t&_i&&(n=n.add(r)),r=r.double(),t>>=_i;return n}precomputeWindow(e,t){const{windows:n,windowSize:r}=Ii(t,this.bits),o=[];let i=e,s=i;for(let e=0;e<n;e++){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=Ii(e,this.bits);for(let e=0;e<i.windows;e++){const{nextN:s,offset:a,isZero:c,isNeg:u,isNegF:l,offsetF:f}=$i(n,e,i);n=s,c?o=o.add(xi(l,t[f])):r=r.add(xi(u,t[a]))}return Oi(n),{p:r,f:o}}wNAFUnsafe(e,t,n,r=this.ZERO){const o=Ii(e,this.bits);for(let e=0;e<o.windows&&n!==Ei;e++){const{nextN:i,offset:s,isZero:a,isNeg:c}=$i(n,e,o);if(n=i,!a){const e=t[s];r=r.add(c?e.negate():e)}}return Oi(n),r}getPrecomputes(e,t,n){let r=Bi.get(t);return r||(r=this.precomputeWindow(t,e),1!==e&&("function"==typeof n&&(r=n(r)),Bi.set(t,r))),r}cached(e,t,n){const r=Si(e);return this.wNAF(r,this.getPrecomputes(r,e,n),t)}unsafe(e,t,n,r){const o=Si(e);return 1===o?this._unsafeLadder(e,t,r):this.wNAFUnsafe(o,this.getPrecomputes(o,e,n),t,r)}createCache(e,t){Ai(t,this.bits),zi.set(e,t),Bi.delete(e)}hasCache(e){return 1!==Si(e)}};function Ni(e,t,n,r){!function(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)})}(n,e),function(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)})}(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=Ho(BigInt(o));let c=1;a>12?c=a-3:a>4?c=a-2:a>0&&(c=2);const u=Vo(c),l=new Array(Number(u)+1).fill(s);let f=s;for(let e=Math.floor((t.BITS-1)/c)*c;e>=0;e-=c){l.fill(s);for(let t=0;t<i;t++){const o=r[t],i=Number(o>>BigInt(e)&u);l[i]=l[i].add(n[t])}let t=s;for(let e=l.length-1,n=s;e>0;e--)n=n.add(l[e]),t=t.add(n);if(f=f.add(t),0!==e)for(let e=0;e<c;e++)f=f.double()}return f}function Ri(e,t,n){if(t){if(t.ORDER!==e)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return function(e){Ko(e,pi.reduce((e,t)=>(e[t]="function",e),{ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"}))}(t),t}return wi(e,{isLE:n})}
7
+ const Ai=BigInt(0),Ii=BigInt(1);function $i(e,t){const n=t.negate();return e?n:t}function Bi(e,t){const n=bi(e.Fp,t.map(e=>e.Z));return t.map((t,r)=>e.fromAffine(t.toAffine(n[r])))}function Si(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function zi(e,t){Si(e,t);const n=2**e;return{windows:Math.ceil(t/e)+1,windowSize:2**(e-1),mask:Xo(e),maxNumber:n,shiftBy:BigInt(e)}}function Oi(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+=Ii);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}}const Ti=new WeakMap,Ni=new WeakMap;function Ri(e){return Ni.get(e)||1}function Ui(e){if(e!==Ai)throw new Error("invalid wNAF")}let Pi=class{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>Ai;)t&Ii&&(n=n.add(r)),r=r.double(),t>>=Ii;return n}precomputeWindow(e,t){const{windows:n,windowSize:r}=zi(t,this.bits),o=[];let i=e,s=i;for(let e=0;e<n;e++){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=zi(e,this.bits);for(let e=0;e<i.windows;e++){const{nextN:s,offset:a,isZero:c,isNeg:u,isNegF:l,offsetF:f}=Oi(n,e,i);n=s,c?o=o.add($i(l,t[f])):r=r.add($i(u,t[a]))}return Ui(n),{p:r,f:o}}wNAFUnsafe(e,t,n,r=this.ZERO){const o=zi(e,this.bits);for(let e=0;e<o.windows&&n!==Ai;e++){const{nextN:i,offset:s,isZero:a,isNeg:c}=Oi(n,e,o);if(n=i,!a){const e=t[s];r=r.add(c?e.negate():e)}}return Ui(n),r}getPrecomputes(e,t,n){let r=Ti.get(t);return r||(r=this.precomputeWindow(t,e),1!==e&&("function"==typeof n&&(r=n(r)),Ti.set(t,r))),r}cached(e,t,n){const r=Ri(e);return this.wNAF(r,this.getPrecomputes(r,e,n),t)}unsafe(e,t,n,r){const o=Ri(e);return 1===o?this._unsafeLadder(e,t,r):this.wNAFUnsafe(o,this.getPrecomputes(o,e,n),t,r)}createCache(e,t){Si(t,this.bits),Ni.set(e,t),Ti.delete(e)}hasCache(e){return 1!==Ri(e)}};function Fi(e,t,n,r){!function(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)})}(n,e),function(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)})}(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=Jo(BigInt(o));let c=1;a>12?c=a-3:a>4?c=a-2:a>0&&(c=2);const u=Xo(c),l=new Array(Number(u)+1).fill(s);let f=s;for(let e=Math.floor((t.BITS-1)/c)*c;e>=0;e-=c){l.fill(s);for(let t=0;t<i;t++){const o=r[t],i=Number(o>>BigInt(e)&u);l[i]=l[i].add(n[t])}let t=s;for(let e=l.length-1,n=s;e>0;e--)n=n.add(l[e]),t=t.add(n);if(f=f.add(t),0!==e)for(let e=0;e<c;e++)f=f.double()}return f}function Ci(e,t,n){if(t){if(t.ORDER!==e)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return function(e){Yo(e,wi.reduce((e,t)=>(e[t]="function",e),{ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"}))}(t),t}return xi(e,{isLE:n})}
8
8
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
9
- const Ui=(e,t)=>(e+(e>=0?t:-t)/Zi)/t;function Pi(e){if(!["compact","recovered","der"].includes(e))throw new Error('Signature format must be "compact", "recovered", or "der"');return e}function Fi(e,t){const n={};for(let r of Object.keys(t))n[r]=void 0===e[r]?t[r]:e[r];return Uo(n.lowS,"lowS"),Uo(n.prehash,"prehash"),void 0!==n.format&&Pi(n.format),n}class Ci extends Error{constructor(e=""){super(e)}}const Li={Err:Ci,_tlv:{encode:(e,t)=>{const{Err:n}=Li;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=Fo(r);if(o.length/2&128)throw new n("tlv.encode: long form length too big");const i=r>127?Fo(o.length/2|128):"";return Fo(e)+i+o+t},decode(e,t){const{Err:n}=Li;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 e of s)i=i<<8|e;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}=Li;if(e<Mi)throw new t("integer: negative integers are not allowed");let n=Fo(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}=Li;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 Lo(e)}},toSig(e){const{Err:t,_int:n,_tlv:r}=Li,o=jo("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}=Li,r=t.encode(2,n.encode(e.r))+t.encode(2,n.encode(e.s));return t.encode(48,r)}},Mi=BigInt(0),Di=BigInt(1),Zi=BigInt(2),ji=BigInt(3),qi=BigInt(4);function Gi(e,t){const{BYTES:n}=e;let r;if("bigint"==typeof t)r=t;else{let o=jo("private key",t);try{r=e.fromBytes(o)}catch(e){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 Hi(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 e of["p","n","h"]){const n=t[e];if(!("bigint"==typeof n&&n>Ei))throw new Error(`CURVE.${e} must be positive bigint`)}const o=Ri(t.p,n.Fp,r),i=Ri(t.n,n.Fn,r),s=["Gx","Gy","a","b"];for(const e of s)if(!o.isValid(t[e]))throw new Error(`CURVE.${e} 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;Ko(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=Ki(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(Uo(n,"isCompressed"),n){l();return bo(Vi(!r.isOdd(i)),s)}return bo(Uint8Array.of(4),s,r.toBytes(i))},d=t.fromBytes||function(e){Po(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=h(e);let n;try{n=r.sqrt(t)}catch(e){const t=e instanceof Error?": "+e.message:"";throw new Error("bad point: is not on curve, sqrt error"+t)}l();return!(1&~i)!==r.isOdd(n)&&(n=r.neg(n)),{x:e,y:n}}};function h(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=h(e);return r.eql(n,o)}if(!p(i.Gx,i.Gy))throw new Error("bad curve params: generator point");const m=r.mul(r.pow(i.a,ji),qi),g=r.mul(r.sqr(i.b),BigInt(27));if(r.is0(r.add(m,g)))throw new Error("bad curve params: a or b");function y(e,t,n=!1){if(!r.isValid(t)||n&&r.is0(t))throw new Error(`bad point coordinate ${e}`);return t}function w(e){if(!(e instanceof x))throw new Error("ProjectivePoint expected")}function b(e){if(!c||!c.basises)throw new Error("no endo");return function(e,t,n){const[[r,o],[i,s]]=t,a=Ui(s*e,n),c=Ui(-o*e,n);let u=e-a*r-c*i,l=-a*o-c*s;const f=u<Mi,d=l<Mi;f&&(u=-u),d&&(l=-l);const h=Vo(Math.ceil(Ho(n)/2))+Di;if(u<Mi||u>=h||l<Mi||l>=h)throw new Error("splitScalar (endomorphism): failed, k="+e);return{k1neg:f,k1:u,k2neg:d,k2:l}}(e,c.basises,o.ORDER)}const v=Wo((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=Wo(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 _(e,t,n,o,i){return n=new x(r.mul(n.X,e),n.Y,n.Z),t=xi(o,t),n=xi(i,n),t.add(n)}class x{constructor(e,t,n){this.X=y("x",e),this.Y=y("y",t,!0),this.Z=y("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 x)throw new Error("projective point not allowed");return r.is0(t)&&r.is0(n)?x.ZERO:new x(t,n,r.ONE)}static fromBytes(e){const t=x.fromAffine(d(Po(e,void 0,"point")));return t.assertValidity(),t}static fromHex(e){return x.fromBytes(jo("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(ji),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){w(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 x(this.X,r.neg(this.Y),this.Z)}double(){const{a:e,b:t}=i,n=r.mul(t,ji),{X:o,Y:s,Z:a}=this;let c=r.ZERO,u=r.ZERO,l=r.ZERO,f=r.mul(o,o),d=r.mul(s,s),h=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,h),u=r.add(c,u),c=r.sub(d,u),u=r.add(d,u),u=r.mul(c,u),c=r.mul(p,c),l=r.mul(n,l),h=r.mul(e,h),p=r.sub(f,h),p=r.mul(e,p),p=r.add(p,l),l=r.add(f,f),f=r.add(l,f),f=r.add(f,h),f=r.mul(f,p),u=r.add(u,f),h=r.mul(s,a),h=r.add(h,h),f=r.mul(h,p),c=r.sub(c,f),l=r.mul(h,d),l=r.add(l,l),l=r.add(l,l),new x(c,u,l)}add(e){w(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 d=i.a,h=r.mul(i.b,ji);let p=r.mul(t,s),m=r.mul(n,a),g=r.mul(o,c),y=r.add(t,n),b=r.add(s,a);y=r.mul(y,b),b=r.add(p,m),y=r.sub(y,b),b=r.add(t,o);let v=r.add(s,c);return b=r.mul(b,v),v=r.add(p,g),b=r.sub(b,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(d,b),u=r.mul(h,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(d,g),b=r.mul(h,b),m=r.add(m,g),g=r.sub(p,g),g=r.mul(d,g),b=r.add(b,g),p=r.mul(m,b),l=r.add(l,p),p=r.mul(v,b),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 x(u,l,f)}subtract(e){return this.add(e.negate())}is0(){return this.equals(x.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=>ki(x,e));if(n){const{k1neg:t,k1:o,k2neg:a,k2:c}=b(e),{p:u,f:l}=s(o),{p:f,f:d}=s(c);i=l.add(d),r=_(n.beta,u,f,t,a)}else{const{p:t,f:n}=s(e);r=t,i=n}return ki(x,[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===Mi||r.is0())return x.ZERO;if(e===Di)return r;if(A.hasCache(this))return this.multiply(e);if(n){const{k1neg:t,k1:o,k2neg:i,k2:s}=b(e),{p1:a,p2:c}=function(e,t,n,r){let o=t,i=e.ZERO,s=e.ZERO;for(;n>Ei||r>Ei;)n&_i&&(i=i.add(o)),r&_i&&(s=s.add(o)),o=o.double(),n>>=_i,r>>=_i;return{p1:i,p2:s}}(x,r,o,s);return _(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 v(this,e)}isTorsionFree(){const{isTorsionFree:e}=t;return s===Di||(e?e(x,this):A.unsafe(this,a).is0())}clearCofactor(){const{clearCofactor:e}=t;return s===Di?this:e?e(x,this):this.multiplyUnsafe(s)}isSmallOrder(){return this.multiplyUnsafe(s).is0()}toBytes(e=!0){return Uo(e,"isCompressed"),this.assertValidity(),f(x,this,e)}toHex(e=!0){return co(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 ki(x,e)}static msm(e,t){return Ni(x,o,e,t)}static fromPrivateKey(e){return x.BASE.multiply(Gi(o,e))}}x.BASE=new x(i.Gx,i.Gy,r.ONE),x.ZERO=new x(r.ZERO,r.ONE,r.ZERO),x.Fp=r,x.Fn=o;const k=o.BITS,A=new Ti(x,t.endo?Math.ceil(k/2):k);return x.BASE.precompute(8),x}function Vi(e){return Uint8Array.of(e?2:3)}function Ki(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function Wi(e,t={}){const{Fn:n}=e,r=t.randomBytes||_o,o=Object.assign(Ki(e.Fp,n),{seed:vi(n.ORDER)});function i(e){try{return!!Gi(n,e)}catch(e){return!1}}function s(e=r(o.seed)){return function(e,t,n=!1){const r=e.length,o=bi(t),i=vi(t);if(r<16||r<i||r>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+r);const s=si(n?Mo(e):Lo(e),t-Xo)+Xo;return n?Zo(s,o):Do(s,o)}(Po(e,o.seed,"seed"),n.ORDER)}function a(t,r=!0){return e.BASE.multiply(Gi(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=jo("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(e){return!1}},randomSecretKey:s,isValidPrivateKey:i,randomPrivateKey:s,normPrivateKeyToScalar:e=>Gi(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=Gi(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 Ji(e,t,n={}){to(t),Ko(n,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});const r=n.randomBytes||_o,o=n.hmac||((e,...n)=>To(t,e,bo(...n))),{Fp:i,Fn:s}=e,{ORDER:a,BITS:c}=s,{keygen:u,getPublicKey:l,getSharedSecret:f,utils:d,lengths:h}=Wi(e,n),p={prehash:!1,lowS:"boolean"==typeof n.lowS&&n.lowS,format:void 0,extraEntropy:!1},m="compact";function g(e){return e>a>>Di}function y(e,t){if(!s.isValidNot0(t))throw new Error(`invalid signature ${e}: out of range 1..Point.Fn.ORDER`);return t}class w{constructor(e,t,n){this.r=y("r",e),this.s=y("s",t),null!=n&&(this.recovery=n),Object.freeze(this)}static fromBytes(e,t=m){let n;if(function(e,t){Pi(t);const n=h.signature;Po(e,"compact"===t?n:"recovered"===t?n+1:void 0,`${t} signature`)}(e,t),"der"===t){const{r:t,s:n}=Li.toSig(Po(e));return new w(t,n)}"recovered"===t&&(n=e[0],t="compact",e=e.subarray(1));const r=s.BYTES,o=e.subarray(0,r),i=e.subarray(r,2*r);return new w(s.fromBytes(o),s.fromBytes(i),n)}static fromHex(e,t){return this.fromBytes(yo(e),t)}addRecoveryBit(e){return new w(this.r,this.s,e)}recoverPublicKey(t){const n=i.ORDER,{r:r,s:o,recovery:c}=this;if(null==c||![0,1,2,3].includes(c))throw new Error("recovery id invalid");if(a*Zi<n&&c>1)throw new Error("recovery id is ambiguous for h>1 curve");const u=2===c||3===c?r+a:r;if(!i.isValid(u))throw new Error("recovery id 2 or 3 invalid");const l=i.toBytes(u),f=e.fromBytes(bo(Vi(!(1&c)),l)),d=s.inv(u),h=v(jo("msgHash",t)),p=s.create(-h*d),m=s.create(o*d),g=e.BASE.multiplyUnsafe(p).add(f.multiplyUnsafe(m));if(g.is0())throw new Error("point at infinify");return g.assertValidity(),g}hasHighS(){return g(this.s)}toBytes(e=m){if(Pi(e),"der"===e)return yo(Li.hexFromSig(this));const t=s.toBytes(this.r),n=s.toBytes(this.s);if("recovered"===e){if(null==this.recovery)throw new Error("recovery bit must be present");return bo(Uint8Array.of(this.recovery),t,n)}return bo(t,n)}toHex(e){return co(this.toBytes(e))}assertValidity(){}static fromCompact(e){return w.fromBytes(jo("sig",e),"compact")}static fromDER(e){return w.fromBytes(jo("sig",e),"der")}normalizeS(){return this.hasHighS()?new w(this.r,s.neg(this.s),this.recovery):this}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return co(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return co(this.toBytes("compact"))}}const b=n.bits2int||function(e){if(e.length>8192)throw new Error("input is too large");const t=Lo(e),n=8*e.length-c;return n>0?t>>BigInt(n):t},v=n.bits2int_modN||function(e){return s.create(b(e))},E=Vo(c);function _(e){return Go("num < 2^"+c,e,Mi,E),s.toBytes(e)}function x(e,n){return Po(e,void 0,"message"),n?Po(t(e),void 0,"prehashed message"):e}return Object.freeze({keygen:u,getPublicKey:l,getSharedSecret:f,utils:d,lengths:h,Point:e,sign:function(n,i,a={}){n=jo("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:a,extraEntropy:c}=Fi(o,p);t=x(t,a);const u=v(t),l=Gi(s,n),f=[_(l),_(u)];if(null!=c&&!1!==c){const e=!0===c?r(h.secretKey):c;f.push(jo("extraEntropy",e))}const d=bo(...f),m=u;return{seed:d,k2sig:function(t){const n=b(t);if(!s.isValidNot0(n))return;const r=s.inv(n),o=e.BASE.multiply(n).toAffine(),a=s.create(o.x);if(a===Mi)return;const c=s.create(r*s.create(m+a*l));if(c===Mi)return;let u=(o.x===a?0:2)|Number(o.y&Di),f=c;return i&&g(c)&&(f=s.neg(c),u^=1),new w(a,f,u)}}}(n,i,a),l=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 bo(...n)};return(e,t)=>{let n;for(c(),l(e);!(n=t(f()));)l();return c(),n}}(t.outputLen,s.BYTES,o);return l(c,u)},verify:function(t,n,r,o={}){const{lowS:i,prehash:a,format:c}=Fi(o,p);if(r=jo("publicKey",r),n=x(jo("message",n),a),"strict"in o)throw new Error("options.strict was renamed to lowS");const u=void 0===c?function(e){let t;const n="string"==typeof e||Yr(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 w(e.r,e.s);else if(n){try{t=w.fromBytes(jo("sig",e),"der")}catch(e){if(!(e instanceof Li.Err))throw e}if(!t)try{t=w.fromBytes(jo("sig",e),"compact")}catch(e){return!1}}return t||!1}(t):w.fromBytes(jo("sig",t),c);if(!1===u)return!1;try{const t=e.fromBytes(r);if(i&&u.hasHighS())return!1;const{r:o,s:a}=u,c=v(n),l=s.inv(a),f=s.create(c*l),d=s.create(o*l),h=e.BASE.multiplyUnsafe(f).add(t.multiplyUnsafe(d));if(h.is0())return!1;return s.create(h.x)===o}catch(e){return!1}},recoverPublicKey:function(e,t,n={}){const{prehash:r}=Fi(n,p);return t=x(t,r),w.fromBytes(e,"recovered").recoverPublicKey(t).toBytes()},Signature:w,hash:t})}function Xi(e){const{CURVE:t,curveOpts:n}=function(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:wi(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}}}(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}}function Yi(e){const{CURVE:t,curveOpts:n,hash:r,ecdsaOpts:o}=Xi(e);return function(e,t){const n=t.Point;return Object.assign({},t,{ProjectivePoint:n,CURVE:Object.assign({},e,yi(n.Fn.ORDER,n.Fn.BITS))})}(e,Ji(Hi(t,n),r,o))}
9
+ const Li=(e,t)=>(e+(e>=0?t:-t)/Hi)/t;function Mi(e){if(!["compact","recovered","der"].includes(e))throw new Error('Signature format must be "compact", "recovered", or "der"');return e}function Di(e,t){const n={};for(let r of Object.keys(t))n[r]=void 0===e[r]?t[r]:e[r];return Lo(n.lowS,"lowS"),Lo(n.prehash,"prehash"),void 0!==n.format&&Mi(n.format),n}class Zi extends Error{constructor(e=""){super(e)}}const ji={Err:Zi,_tlv:{encode:(e,t)=>{const{Err:n}=ji;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=Do(r);if(o.length/2&128)throw new n("tlv.encode: long form length too big");const i=r>127?Do(o.length/2|128):"";return Do(e)+i+o+t},decode(e,t){const{Err:n}=ji;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 e of s)i=i<<8|e;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}=ji;if(e<qi)throw new t("integer: negative integers are not allowed");let n=Do(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}=ji;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 jo(e)}},toSig(e){const{Err:t,_int:n,_tlv:r}=ji,o=Vo("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}=ji,r=t.encode(2,n.encode(e.r))+t.encode(2,n.encode(e.s));return t.encode(48,r)}},qi=BigInt(0),Gi=BigInt(1),Hi=BigInt(2),Vi=BigInt(3),Ki=BigInt(4);function Wi(e,t){const{BYTES:n}=e;let r;if("bigint"==typeof t)r=t;else{let o=Vo("private key",t);try{r=e.fromBytes(o)}catch(e){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 Ji(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 e of["p","n","h"]){const n=t[e];if(!("bigint"==typeof n&&n>Ai))throw new Error(`CURVE.${e} must be positive bigint`)}const o=Ci(t.p,n.Fp,r),i=Ci(t.n,n.Fn,r),s=["Gx","Gy","a","b"];for(const e of s)if(!o.isValid(t[e]))throw new Error(`CURVE.${e} 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;Yo(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=Yi(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(Lo(n,"isCompressed"),n){l();return _o(Xi(!r.isOdd(i)),s)}return _o(Uint8Array.of(4),s,r.toBytes(i))},d=t.fromBytes||function(e){Mo(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=h(e);let n;try{n=r.sqrt(t)}catch(e){const t=e instanceof Error?": "+e.message:"";throw new Error("bad point: is not on curve, sqrt error"+t)}l();return!(1&~i)!==r.isOdd(n)&&(n=r.neg(n)),{x:e,y:n}}};function h(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=h(e);return r.eql(n,o)}if(!p(i.Gx,i.Gy))throw new Error("bad curve params: generator point");const m=r.mul(r.pow(i.a,Vi),Ki),g=r.mul(r.sqr(i.b),BigInt(27));if(r.is0(r.add(m,g)))throw new Error("bad curve params: a or b");function y(e,t,n=!1){if(!r.isValid(t)||n&&r.is0(t))throw new Error(`bad point coordinate ${e}`);return t}function w(e){if(!(e instanceof _))throw new Error("ProjectivePoint expected")}function b(e){if(!c||!c.basises)throw new Error("no endo");return function(e,t,n){const[[r,o],[i,s]]=t,a=Li(s*e,n),c=Li(-o*e,n);let u=e-a*r-c*i,l=-a*o-c*s;const f=u<qi,d=l<qi;f&&(u=-u),d&&(l=-l);const h=Xo(Math.ceil(Jo(n)/2))+Gi;if(u<qi||u>=h||l<qi||l>=h)throw new Error("splitScalar (endomorphism): failed, k="+e);return{k1neg:f,k1:u,k2neg:d,k2:l}}(e,c.basises,o.ORDER)}const v=Qo((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=Qo(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 _(r.mul(n.X,e),n.Y,n.Z),t=$i(o,t),n=$i(i,n),t.add(n)}class _{constructor(e,t,n){this.X=y("x",e),this.Y=y("y",t,!0),this.Z=y("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 _)throw new Error("projective point not allowed");return r.is0(t)&&r.is0(n)?_.ZERO:new _(t,n,r.ONE)}static fromBytes(e){const t=_.fromAffine(d(Mo(e,void 0,"point")));return t.assertValidity(),t}static fromHex(e){return _.fromBytes(Vo("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(Vi),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){w(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 _(this.X,r.neg(this.Y),this.Z)}double(){const{a:e,b:t}=i,n=r.mul(t,Vi),{X:o,Y:s,Z:a}=this;let c=r.ZERO,u=r.ZERO,l=r.ZERO,f=r.mul(o,o),d=r.mul(s,s),h=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,h),u=r.add(c,u),c=r.sub(d,u),u=r.add(d,u),u=r.mul(c,u),c=r.mul(p,c),l=r.mul(n,l),h=r.mul(e,h),p=r.sub(f,h),p=r.mul(e,p),p=r.add(p,l),l=r.add(f,f),f=r.add(l,f),f=r.add(f,h),f=r.mul(f,p),u=r.add(u,f),h=r.mul(s,a),h=r.add(h,h),f=r.mul(h,p),c=r.sub(c,f),l=r.mul(h,d),l=r.add(l,l),l=r.add(l,l),new _(c,u,l)}add(e){w(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 d=i.a,h=r.mul(i.b,Vi);let p=r.mul(t,s),m=r.mul(n,a),g=r.mul(o,c),y=r.add(t,n),b=r.add(s,a);y=r.mul(y,b),b=r.add(p,m),y=r.sub(y,b),b=r.add(t,o);let v=r.add(s,c);return b=r.mul(b,v),v=r.add(p,g),b=r.sub(b,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(d,b),u=r.mul(h,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(d,g),b=r.mul(h,b),m=r.add(m,g),g=r.sub(p,g),g=r.mul(d,g),b=r.add(b,g),p=r.mul(m,b),l=r.add(l,p),p=r.mul(v,b),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 _(u,l,f)}subtract(e){return this.add(e.negate())}is0(){return this.equals(_.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=>Bi(_,e));if(n){const{k1neg:t,k1:o,k2neg:a,k2:c}=b(e),{p:u,f:l}=s(o),{p:f,f:d}=s(c);i=l.add(d),r=x(n.beta,u,f,t,a)}else{const{p:t,f:n}=s(e);r=t,i=n}return Bi(_,[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===qi||r.is0())return _.ZERO;if(e===Gi)return r;if(A.hasCache(this))return this.multiply(e);if(n){const{k1neg:t,k1:o,k2neg:i,k2:s}=b(e),{p1:a,p2:c}=function(e,t,n,r){let o=t,i=e.ZERO,s=e.ZERO;for(;n>Ai||r>Ai;)n&Ii&&(i=i.add(o)),r&Ii&&(s=s.add(o)),o=o.double(),n>>=Ii,r>>=Ii;return{p1:i,p2:s}}(_,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 v(this,e)}isTorsionFree(){const{isTorsionFree:e}=t;return s===Gi||(e?e(_,this):A.unsafe(this,a).is0())}clearCofactor(){const{clearCofactor:e}=t;return s===Gi?this:e?e(_,this):this.multiplyUnsafe(s)}isSmallOrder(){return this.multiplyUnsafe(s).is0()}toBytes(e=!0){return Lo(e,"isCompressed"),this.assertValidity(),f(_,this,e)}toHex(e=!0){return ho(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 Bi(_,e)}static msm(e,t){return Fi(_,o,e,t)}static fromPrivateKey(e){return _.BASE.multiply(Wi(o,e))}}_.BASE=new _(i.Gx,i.Gy,r.ONE),_.ZERO=new _(r.ZERO,r.ONE,r.ZERO),_.Fp=r,_.Fn=o;const k=o.BITS,A=new Pi(_,t.endo?Math.ceil(k/2):k);return _.BASE.precompute(8),_}function Xi(e){return Uint8Array.of(e?2:3)}function Yi(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function Qi(e,t={}){const{Fn:n}=e,r=t.randomBytes||Io,o=Object.assign(Yi(e.Fp,n),{seed:ki(n.ORDER)});function i(e){try{return!!Wi(n,e)}catch(e){return!1}}function s(e=r(o.seed)){return function(e,t,n=!1){const r=e.length,o=_i(t),i=ki(t);if(r<16||r<i||r>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+r);const s=li(n?qo(e):jo(e),t-ti)+ti;return n?Ho(s,o):Go(s,o)}(Mo(e,o.seed,"seed"),n.ORDER)}function a(t,r=!0){return e.BASE.multiply(Wi(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=Vo("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(e){return!1}},randomSecretKey:s,isValidPrivateKey:i,randomPrivateKey:s,normPrivateKeyToScalar:e=>Wi(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=Wi(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 es(e,t,n={}){to(t),Yo(n,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});const r=n.randomBytes||Io,o=n.hmac||((e,...n)=>Po(t,e,_o(...n))),{Fp:i,Fn:s}=e,{ORDER:a,BITS:c}=s,{keygen:u,getPublicKey:l,getSharedSecret:f,utils:d,lengths:h}=Qi(e,n),p={prehash:!1,lowS:"boolean"==typeof n.lowS&&n.lowS,format:void 0,extraEntropy:!1},m="compact";function g(e){return e>a>>Gi}function y(e,t){if(!s.isValidNot0(t))throw new Error(`invalid signature ${e}: out of range 1..Point.Fn.ORDER`);return t}class w{constructor(e,t,n){this.r=y("r",e),this.s=y("s",t),null!=n&&(this.recovery=n),Object.freeze(this)}static fromBytes(e,t=m){let n;if(function(e,t){Mi(t);const n=h.signature;Mo(e,"compact"===t?n:"recovered"===t?n+1:void 0,`${t} signature`)}(e,t),"der"===t){const{r:t,s:n}=ji.toSig(Mo(e));return new w(t,n)}"recovered"===t&&(n=e[0],t="compact",e=e.subarray(1));const r=s.BYTES,o=e.subarray(0,r),i=e.subarray(r,2*r);return new w(s.fromBytes(o),s.fromBytes(i),n)}static fromHex(e,t){return this.fromBytes(Eo(e),t)}addRecoveryBit(e){return new w(this.r,this.s,e)}recoverPublicKey(t){const n=i.ORDER,{r:r,s:o,recovery:c}=this;if(null==c||![0,1,2,3].includes(c))throw new Error("recovery id invalid");if(a*Hi<n&&c>1)throw new Error("recovery id is ambiguous for h>1 curve");const u=2===c||3===c?r+a:r;if(!i.isValid(u))throw new Error("recovery id 2 or 3 invalid");const l=i.toBytes(u),f=e.fromBytes(_o(Xi(!(1&c)),l)),d=s.inv(u),h=v(Vo("msgHash",t)),p=s.create(-h*d),m=s.create(o*d),g=e.BASE.multiplyUnsafe(p).add(f.multiplyUnsafe(m));if(g.is0())throw new Error("point at infinify");return g.assertValidity(),g}hasHighS(){return g(this.s)}toBytes(e=m){if(Mi(e),"der"===e)return Eo(ji.hexFromSig(this));const t=s.toBytes(this.r),n=s.toBytes(this.s);if("recovered"===e){if(null==this.recovery)throw new Error("recovery bit must be present");return _o(Uint8Array.of(this.recovery),t,n)}return _o(t,n)}toHex(e){return ho(this.toBytes(e))}assertValidity(){}static fromCompact(e){return w.fromBytes(Vo("sig",e),"compact")}static fromDER(e){return w.fromBytes(Vo("sig",e),"der")}normalizeS(){return this.hasHighS()?new w(this.r,s.neg(this.s),this.recovery):this}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return ho(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return ho(this.toBytes("compact"))}}const b=n.bits2int||function(e){if(e.length>8192)throw new Error("input is too large");const t=jo(e),n=8*e.length-c;return n>0?t>>BigInt(n):t},v=n.bits2int_modN||function(e){return s.create(b(e))},E=Xo(c);function x(e){return Wo("num < 2^"+c,e,qi,E),s.toBytes(e)}function _(e,n){return Mo(e,void 0,"message"),n?Mo(t(e),void 0,"prehashed message"):e}return Object.freeze({keygen:u,getPublicKey:l,getSharedSecret:f,utils:d,lengths:h,Point:e,sign:function(n,i,a={}){n=Vo("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:a,extraEntropy:c}=Di(o,p);t=_(t,a);const u=v(t),l=Wi(s,n),f=[x(l),x(u)];if(null!=c&&!1!==c){const e=!0===c?r(h.secretKey):c;f.push(Vo("extraEntropy",e))}const d=_o(...f),m=u;return{seed:d,k2sig:function(t){const n=b(t);if(!s.isValidNot0(n))return;const r=s.inv(n),o=e.BASE.multiply(n).toAffine(),a=s.create(o.x);if(a===qi)return;const c=s.create(r*s.create(m+a*l));if(c===qi)return;let u=(o.x===a?0:2)|Number(o.y&Gi),f=c;return i&&g(c)&&(f=s.neg(c),u^=1),new w(a,f,u)}}}(n,i,a),l=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 _o(...n)};return(e,t)=>{let n;for(c(),l(e);!(n=t(f()));)l();return c(),n}}(t.outputLen,s.BYTES,o);return l(c,u)},verify:function(t,n,r,o={}){const{lowS:i,prehash:a,format:c}=Di(o,p);if(r=Vo("publicKey",r),n=_(Vo("message",n),a),"strict"in o)throw new Error("options.strict was renamed to lowS");const u=void 0===c?function(e){let t;const n="string"==typeof e||Yr(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 w(e.r,e.s);else if(n){try{t=w.fromBytes(Vo("sig",e),"der")}catch(e){if(!(e instanceof ji.Err))throw e}if(!t)try{t=w.fromBytes(Vo("sig",e),"compact")}catch(e){return!1}}return t||!1}(t):w.fromBytes(Vo("sig",t),c);if(!1===u)return!1;try{const t=e.fromBytes(r);if(i&&u.hasHighS())return!1;const{r:o,s:a}=u,c=v(n),l=s.inv(a),f=s.create(c*l),d=s.create(o*l),h=e.BASE.multiplyUnsafe(f).add(t.multiplyUnsafe(d));if(h.is0())return!1;return s.create(h.x)===o}catch(e){return!1}},recoverPublicKey:function(e,t,n={}){const{prehash:r}=Di(n,p);return t=_(t,r),w.fromBytes(e,"recovered").recoverPublicKey(t).toBytes()},Signature:w,hash:t})}function ts(e){const{CURVE:t,curveOpts:n}=function(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:xi(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}}}(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}}function ns(e){const{CURVE:t,curveOpts:n,hash:r,ecdsaOpts:o}=ts(e);return function(e,t){const n=t.Point;return Object.assign({},t,{ProjectivePoint:n,CURVE:Object.assign({},e,Ei(n.Fn.ORDER,n.Fn.BITS))})}(e,es(Ji(t,n),r,o))}
10
10
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
11
11
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
12
- const Qi={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},es={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]},ts=BigInt(2);const ns=wi(Qi.p,{sqrt:function(e){const t=Qi.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=ai(l,n,t)*l%t,d=ai(f,n,t)*l%t,h=ai(d,ts,t)*u%t,p=ai(h,o,t)*h%t,m=ai(p,i,t)*p%t,g=ai(m,a,t)*m%t,y=ai(g,c,t)*g%t,w=ai(y,a,t)*m%t,b=ai(w,n,t)*l%t,v=ai(b,s,t)*p%t,E=ai(v,r,t)*u%t,_=ai(E,ts,t);if(!ns.eql(ns.sqr(_),e))throw new Error("Cannot find square root");return _}}),rs=function(e,t){const n=t=>Yi({...e,hash:t});return{...n(t),create:n}}({...Qi,Fp:ns,lowS:!0,endo:es},So);function os(e,t){const n=[];for(let r=0;r<e.length;r+=t)n.push(e.subarray(r,r+t));return n}function is(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 ss(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 as(e){return Array.from(e).map(e=>e.toString(16).padStart(2,"0")).join("")}function cs(e,t){const n=new Uint8Array(32);let r=e;for(let e=31;e>=0;e--)n[e]=Number(0xffn&r),r>>=8n;return n}function us(e,t){let n=0n;for(let t=0;t<32;t++)n=n<<8n|BigInt(e[t]);return n}function ls(e){const t=e.startsWith("0x")||e.startsWith("0X")?e.slice(2):e,n=new Uint8Array(t.length/2);for(let e=0;e<n.length;e++)n[e]=parseInt(t.slice(2*e,2*e+2),16);return n}var fs="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";function ds(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 hs(e){return function(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)}(e,fs)}function ps(e){return ds(e,fs)}function ms(e){return new Uint8Array([e])}function gs(e){return e[0]}function ys(e,t){return new DataView(e.buffer,e.byteOffset,e.byteLength).getUint16(0,"LE"===t)}function ws(e,t){const n=new ArrayBuffer(4);return new DataView(n).setUint32(0,e,"LE"===t),new Uint8Array(n)}function bs(e,t){const n=new ArrayBuffer(8);return new DataView(n).setBigUint64(0,e,"LE"===t),new Uint8Array(n)}function vs(e,t){return new DataView(e.buffer,e.byteOffset,e.byteLength).getBigUint64(0,"LE"===t)}var Es=[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 _s(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];xs(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,[ks(e)]}const n=os(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(ks)}(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 xs(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],d=l^(o<<1|i>>>31),h=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),E=u^(r<<1|n>>>31);e[0]^=d,e[1]^=h,e[2]^=p,e[3]^=m,e[4]^=g,e[5]^=y,e[6]^=w,e[7]^=b,e[8]^=v,e[9]^=E,e[10]^=d,e[11]^=h,e[12]^=p,e[13]^=m,e[14]^=g,e[15]^=y,e[16]^=w,e[17]^=b,e[18]^=v,e[19]^=E,e[20]^=d,e[21]^=h,e[22]^=p,e[23]^=m,e[24]^=g,e[25]^=y,e[26]^=w,e[27]^=b,e[28]^=v,e[29]^=E,e[30]^=d,e[31]^=h,e[32]^=p,e[33]^=m,e[34]^=g,e[35]^=y,e[36]^=w,e[37]^=b,e[38]^=v,e[39]^=E,e[40]^=d,e[41]^=h,e[42]^=p,e[43]^=m,e[44]^=g,e[45]^=y,e[46]^=w,e[47]^=b,e[48]^=v,e[49]^=E;const _=e[0],x=e[1],k=e[2]<<1|e[3]>>>31,A=e[3]<<1|e[2]>>>31,I=e[5]<<30|e[4]>>>2,$=e[4]<<30|e[5]>>>2,B=e[6]<<28|e[7]>>>4,z=e[7]<<28|e[6]>>>4,S=e[8]<<27|e[9]>>>5,O=e[9]<<27|e[8]>>>5,T=e[11]<<4|e[10]>>>28,N=e[10]<<4|e[11]>>>28,R=e[13]<<12|e[12]>>>20,U=e[12]<<12|e[13]>>>20,P=e[14]<<6|e[15]>>>26,F=e[15]<<6|e[14]>>>26,C=e[17]<<23|e[16]>>>9,L=e[16]<<23|e[17]>>>9,M=e[18]<<20|e[19]>>>12,D=e[19]<<20|e[18]>>>12,Z=e[20]<<3|e[21]>>>29,j=e[21]<<3|e[20]>>>29,q=e[22]<<10|e[23]>>>22,G=e[23]<<10|e[22]>>>22,H=e[25]<<11|e[24]>>>21,V=e[24]<<11|e[25]>>>21,K=e[26]<<25|e[27]>>>7,W=e[27]<<25|e[26]>>>7,J=e[29]<<7|e[28]>>>25,X=e[28]<<7|e[29]>>>25,Y=e[31]<<9|e[30]>>>23,Q=e[30]<<9|e[31]>>>23,ee=e[33]<<13|e[32]>>>19,te=e[32]<<13|e[33]>>>19,ne=e[34]<<15|e[35]>>>17,re=e[35]<<15|e[34]>>>17,oe=e[36]<<21|e[37]>>>11,ie=e[37]<<21|e[36]>>>11,se=e[38]<<8|e[39]>>>24,ae=e[39]<<8|e[38]>>>24,ce=e[40]<<18|e[41]>>>14,ue=e[41]<<18|e[40]>>>14,le=e[42]<<2|e[43]>>>30,fe=e[43]<<2|e[42]>>>30,de=e[45]<<29|e[44]>>>3,he=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]=_^~R&H,e[1]=x^~U&V,e[2]=R^~H&oe,e[3]=U^~V&ie,e[4]=H^~oe&ge,e[5]=V^~ie&ye,e[6]=oe^~ge&_,e[7]=ie^~ye&x,e[8]=ge^~_&R,e[9]=ye^~x&U,e[10]=B^~M&Z,e[11]=z^~D&j,e[12]=M^~Z&ee,e[13]=D^~j&te,e[14]=Z^~ee&de,e[15]=j^~te&he,e[16]=ee^~de&B,e[17]=te^~he&z,e[18]=de^~B&M,e[19]=he^~z&D,e[20]=k^~P&K,e[21]=A^~F&W,e[22]=P^~K&se,e[23]=F^~W&ae,e[24]=K^~se&ce,e[25]=W^~ae&ue,e[26]=se^~ce&k,e[27]=ae^~ue&A,e[28]=ce^~k&P,e[29]=ue^~A&F,e[30]=S^~T&q,e[31]=O^~N&G,e[32]=T^~q&ne,e[33]=N^~G&re,e[34]=q^~ne&pe,e[35]=G^~re&me,e[36]=ne^~pe&S,e[37]=re^~me&O,e[38]=pe^~S&T,e[39]=me^~O&N,e[40]=I^~C&J,e[41]=$^~L&X,e[42]=C^~J&Y,e[43]=L^~X&Q,e[44]=J^~Y&le,e[45]=X^~Q&fe,e[46]=Y^~le&I,e[47]=Q^~fe&$,e[48]=le^~I&C,e[49]=fe^~$&L,e[0]^=Es[2*t],e[1]^=Es[2*t+1]}}function ks(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 As=new TextDecoder,Is=new TextEncoder,$s=/^(0x)?[0-9a-fA-F]*$/i;var Bs=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(!$s.test(t)||t.replace(/^0x/i,"").length%2!=0)throw new Error(`Bytes#constructor: invalid hex string: ${t}`);this.bytes=ls(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=ls(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(_s(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(Is.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 as(this.bytes)}toBase64(){return function(e){return ds(e,"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/")}(this.bytes)}toBase32(){return ps(this.bytes)}toString(){return this.toHex()}toUtf8(){return As.decode(this.bytes)}toJSON(){return JSON.parse(this.toUtf8())}equals(t){return this.toHex()===new e(t).toHex()}represent(){return this.toHex()}},zs=class extends Bs{static LENGTH=32;constructor(e){super(e,32)}},Ss=0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n;function Os(e){if(e<=0n||e>=Ss)throw new Error("Invalid private key");const t=rs.Point.BASE.multiply(e);return[t.x,t.y]}function Ts(e){const t=new Uint8Array(20),n=_s(Bs.concat(cs(e[0]),cs(e[1])));return t.set(n.subarray(12)),t}var Ns=class extends Bs{static LENGTH=20;constructor(e){super(e,20)}toChecksum(){return function(e){const t=as(e),n=as(_s(Uint8Array.from(t,e=>e.charCodeAt(0))));let r="0x";for(let e=0;e<t.length;e++)r+=parseInt(n.charAt(e),16)>7?t.charAt(e).toUpperCase():t.charAt(e);return r}(this.bytes)}},Rs=new Uint8Array(8).fill(255,0,8),Us=class e extends Bs{static LENGTH=8;static MINUS_ONE=new e(Rs);constructor(e){super(e,8)}static fromBigInt(t){return new e(bs(t,"BE"))}toBigInt(){return vs(this.bytes,"BE")}next(){return as(this.bytes)===as(Rs)?e.fromBigInt(0n):e.fromBigInt(this.toBigInt()+1n)}},Ps=new TextEncoder,Fs=class e extends Bs{static LENGTH=32;constructor(e){super(e,32)}static fromString(t){return new e(_s(Ps.encode(t)))}},Cs=class extends Bs{static LENGTH=32;constructor(e){super(e,32)}};function Ls(e,t){const n=rs.sign(_s(e),t,{prehash:!1}),r=0===n.recovery?27n:28n;return[n.r,n.s,r]}function Ms(e,t,n,r){const o=27n===r?0:1,i=new rs.Signature(t,n,o).recoverPublicKey(_s(e));return[i.x,i.y]}var Ds=class extends Bs{static LENGTH=64;constructor(e){const t=new Bs(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=rs.Point.fromBytes(e);return[t.x,t.y]}(t.toUint8Array());super(Bs.concat(cs(e),cs(n)),64)}else super(e,64)}address(){const e=us(this.bytes.slice(0,32)),t=us(this.bytes.slice(32,64));return new Ns(Ts([e,t]))}toCompressedUint8Array(){const e=us(this.bytes.slice(0,32)),t=us(this.bytes.slice(32,64));return n=[e,t],rs.Point.fromAffine({x:n[0],y:n[1]}).toBytes(!0);var n}toCompressedHex(){return as(this.toCompressedUint8Array())}},Zs=new TextEncoder,js=Zs.encode("Ethereum Signed Message:\n32");function qs(e){const t=e instanceof Uint8Array?e:Zs.encode(e);return Bs.concat(js,_s(t))}var Gs=class e extends Bs{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=us(this.bytes.slice(0,32)),n=us(this.bytes.slice(32,64)),r=BigInt(this.bytes[64]),[o,i]=Ms(qs(e),t,n,r);return new Ds(Bs.concat(cs(o),cs(i)))}isValid(e,t){return this.recoverPublicKey(e).address().equals(t)}},Hs=class extends Bs{static LENGTH=32;constructor(e){super(e,32)}publicKey(){const[e,t]=Os(this.toBigInt());return new Ds(Bs.concat(cs(e),cs(t)))}sign(e){const[t,n,r]=Ls(qs(e),this.toBigInt());return new Gs(Bs.concat(cs(t),cs(n),new Uint8Array([Number(r)])))}toBigInt(){return us(this.bytes)}};var Vs=class e extends Bs{static LENGTH=32;constructor(e){"string"==typeof e&&e.startsWith("bah5")?super(function(e){const t=hs(e.toUpperCase().slice(1)),n=t[1];if(250!==n&&251!==n)throw new Error("Unknown codec");return t.slice(-32)}(e),32):super(e,[32,64])}toCid(e){return`b${ps(Bs.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}}},Ks=class e extends Bs{static LENGTH=8;constructor(e){super(e,8)}static fromBigInt(t){return new e(bs(t,"LE"))}toBigInt(){return vs(this.bytes,"LE")}static fromSlice(t,n){return new e(t.slice(n,n+e.LENGTH))}},Ws=new TextEncoder,Js=class e extends Bs{static LENGTH=32;constructor(e){super(e,32)}static fromString(t){return new e(_s(Ws.encode(t)))}},Xs=class extends Bs{static LENGTH=32;constructor(e){super(e,32)}},Ys=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}},Qs=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 ea(e,t,n){const r=new Uint8Array(n.length),o=new Uint8Array(36);o.set(e);for(let e=0,i=0;i<n.length;e++,i+=32){const s=t+e>>>0;o[32]=255&s,o[33]=s>>>8&255,o[34]=s>>>16&255,o[35]=s>>>24&255;const a=_s(_s(o)),c=Math.min(i+32,n.length);for(let e=i;e<c;e++)r[e]=n[e]^a[e-i]}return r}var ta=4096;function na(e){const t=e.subarray(0,8),n=function(e){if(e.length>ta)throw new Error(`payload size ${e.length} exceeds maximum chunk payload size 4096`);const t=new Uint8Array(ta);t.set(e);let n=os(t,32);for(;n.length>1;){const e=[];for(let t=0;t<n.length;t+=2)e.push(_s(Bs.concat(n[t],n[t+1])));n=e}return n[0]}(e.subarray(8));return new Vs(_s(Bs.concat(t,n)))}ls("dc5b20847f43d67928f49cd4f85d696b5a7617b5");var ra=Fs.LENGTH,oa=Fs.LENGTH+65,ia=oa+Ks.LENGTH,sa=(new TextEncoder).encode("Ethereum Signed Message:\n32");function aa(e,t){const n=_s(Bs.concat(e,t));return Bs.concat(sa,n)}function ca(e,t){const n=new Fs(e),r=new Ns(t);return new Vs(_s(Bs.concat(n.toUint8Array(),r.toUint8Array())))}function ua(e,t,n){const r=new Fs(t),o=function(e,t,n){const[r,o,i]=Ls(aa(e,t),n);return Bs.concat(cs(r),cs(o),new Uint8Array([Number(i)]))}(r.toUint8Array(),e.address.toUint8Array(),n),i=new Ns(Ts(Os(n))),s=ca(r,i);return{data:Bs.concat(r.toUint8Array(),o,e.data),identifier:r,signature:new Gs(o),span:e.span,payload:e.payload,address:s,owner:i}}function la(e,t){const n=e instanceof Bs?e.toUint8Array():e,r=new Vs(t),o=new Fs(Bs.fromSlice(n,0,Fs.LENGTH)),i=n.slice(ra,ra+65),s=na(n.slice(oa)),a=new Ns(function(e,t,n){const r=us(n.subarray(0,32)),o=us(n.subarray(32,64)),i=BigInt(n[64]);return Ts(Ms(aa(e,t),r,o,i))}(o.toUint8Array(),s.toUint8Array(),i)),c=ca(o,a);if(!c.equals(r))throw new Error("SOC data does not match given address");const u=Ks.fromSlice(n,oa),l=Bs.fromSlice(n,ia);return{data:n,identifier:o,signature:new Gs(i),span:u,payload:l,address:c,owner:a}}function fa(e,t){if("string"==typeof e&&(e=Bs.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?Ks.fromBigInt(t):t:Ks.fromBigInt(BigInt(e.length)),r=new Bs(e),o=Bs.concat(n.toUint8Array(),r.toUint8Array()),i={data:o,span:n,payload:r,address:na(o),toSingleOwnerChunk:(e,t)=>ua(i,e,new Hs(t).toBigInt())};return i}function da(e){const t=new Bs(e);return fa(t.toUint8Array().slice(Ks.LENGTH),Ks.fromSlice(t.toUint8Array(),0))}var ha=class{span;writer;constructor(e=0n){this.span=e,this.writer=new Qs(new Uint8Array(4096))}build(){return Bs.concat(bs(this.span,"LE"),this.writer.buffer)}hash(){return na(this.build())}encryptedHash(e){e||(e=new Uint8Array(32),crypto.getRandomValues(e));const t=function(e,t){return ea(e,128,t)}(e,bs(this.span,"LE")),n=function(e,t){return ea(e,0,t)}(e,this.writer.buffer);return{address:na(Bs.concat(t,n)),key:e}}},pa=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 ha],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 Ys(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 ha,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 Ys(t.hash().toUint8Array()))}}async flushBatch(e){this.chunks[e+1]||(this.chunks.push(new ha),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])}};function ma(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}var ga=new TextEncoder,ya=new TextDecoder,wa=new Uint8Array([47]),ba=ls("5768b3b6a7db56d21d1abff40d41cebfc83448fed8d7e9b06ec0d3b073f28f7b");function va(e,t){const n=Math.floor(t/8),r=t%8;e[n]=e[n]|1<<r}function Ea(e,t){const n=t%8;return 1==(e[Math.floor(t/8)]>>n&1)}var _a=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 Bs.concat(this.parent?.fullPath??new Uint8Array(0),this.path)}get fullPathString(){return ya.decode(this.fullPath)}async marshal(){for(const e of this.forks.values())e.node.selfAddress||(e.node.selfAddress=(await e.node.calculateSelfAddress()).toUint8Array());this.encrypt&&is(this.obfuscationKey,new Uint8Array(32))&&(this.obfuscationKey=new Uint8Array(32),crypto.getRandomValues(this.obfuscationKey));const e=!is(this.targetAddress,new Uint8Array(this.targetAddress.length));let t=0;if(e)t=this.targetAddress.length;else for(const e of this.forks.values())if(e.node.selfAddress&&e.node.selfAddress.length>0){t=e.node.selfAddress.length;break}const n=new Uint8Array(32);n.set(ba,0),n.set(ms(t),31);const r=e?this.targetAddress:new Uint8Array(t),o=new Uint8Array(32);for(const e of this.forks.keys())va(o,e);const i=[];for(let e=0;e<256;e++)Ea(o,e)&&i.push(this.forks.get(e).marshal());const s=ma(Bs.concat(n,r,o,...i),this.obfuscationKey);return Bs.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=ma(t.subarray(32),r),i=new Ys(o);if(!is(i.read(31),ba.slice(0,31)))throw new Error("MantarayNode#unmarshalFromData invalid version hash");const s=gs(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(Ea(u,e)){const t=Aa.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:ga.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 Aa(u,new e({targetAddress:s?new Vs(n).toUint8Array():void 0,metadata:s?r:void 0,path:u,encrypt:this.encrypt})),f=a.forks.get(u[0]);if(f){const e=Aa.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:ga.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 e of t.forks.values())n.addFork(Bs.concat(t.path,e.prefix),e.node.targetAddress,e.node.metadata)}async calculateSelfAddress(){if(this.selfAddress)return new Vs(this.selfAddress);if(this.encrypt)throw new Error("MantarayNode#calculateSelfAddress is not supported for encrypted nodes - use saveRecursively");return(await pa.root(await this.marshal())).hash()}async saveRecursively(e){for(const t of this.forks.values())await t.node.saveRecursively(e);const t=new pa(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=Bs.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:ga.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:ga.encode(e)).length)return[this,t];const n=this.forks.get(e[0]);return n&&ss(n.prefix,e).length===n.prefix.length?n.node.findClosest(e.slice(n.prefix.length),Bs.concat(t,n.prefix)):[this,t]}collect(e=[]){for(const t of this.forks.values())is(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 Vs(t.targetAddress).toHex();return e}determineType(){let e=0;const t=new Uint8Array(this.targetAddress.length);return is(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,wa)>0&&(e|=8),this.metadata&&(e|=16),e}},xa=new TextEncoder,ka=new TextDecoder;var Aa=class e{prefix;node;constructor(e,t){this.prefix=e,this.node=t}static split(t,n){const r=ss(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 _a({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(ms(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}(Bs.concat(new Uint8Array([0,0]),xa.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 Bs.concat(...e)}static unmarshal(t,n){const r=gs(t.read(1)),o=gs(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=ys(t.read(2),"BE");if(e>t.max())throw new Error("Fork#unmarshal not enough bytes for metadata");a=JSON.parse(ka.decode(t.read(e)))}return new e(i,new _a({selfAddress:s,metadata:a,path:i,type:r}))}};function Ia(e,t,n){return e/Math.pow(2,t-n)}function $a(e){return 4096*2**e}function Ba(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 za,Sa=[[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"]],Oa=[[[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"]]],Ta=[[[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 Na(e,t,n){if(e<17)return 0;if(void 0!==t&&void 0!==n){const r=(t?Ta:Oa)[n],o=r?.find(([t])=>t===e);if(o)return Ba(o[1])}else{const t=Sa.find(([t])=>t===e);if(t)return Ba(t[1])}return Math.ceil(.9*$a(e))}function Ra(e,t,n){if(void 0!==t&&void 0!==n){const r=(t?Ta:Oa)[n],o=r?.find(([,t])=>e<=Ba(t));if(o)return o[0]}else for(const[t,n]of Sa)if(e<=Ba(n))return t;return 35}function Ua(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 Bs(Bs.concat(t,r,n,e))}(e.signature.toUint8Array(),e.batchId.toUint8Array(),e.timestamp,e.index)}function Pa(e,t,n,r,o=Date.now()){const i=new Hs(e),s=new zs(t),a=ys(n,"BE"),c=Bs.concat(ws(a,"BE"),ws(r,"BE")),u=bs(1000000n*BigInt(o),"BE"),l=i.sign(Bs.concat(n,s.toUint8Array(),c,u));return{batchId:s,index:c,issuer:i.publicKey().address(),signature:l,timestamp:u}}function Fa(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 e of o._zod.deferred)e();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}class Ca extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class La extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}}(za=globalThis).__zod_globalConfig??(za.__zod_globalConfig={});const Ma=globalThis.__zod_globalConfig;function Da(e){return Ma}function Za(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 ja(e,t){return"bigint"==typeof t?t.toString():t}function qa(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Ga(e){return null==e}function Ha(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}const Va=Symbol("evaluating");function Ka(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Va)return void 0===r&&(r=Va,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function Wa(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Ja(...e){const t={};for(const n of e){const e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function Xa(e){return JSON.stringify(e)}const Ya="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Qa(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}const ec=qa(()=>{if(Ma.jitless)return!1;if("undefined"!=typeof navigator&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function tc(e){if(!1===Qa(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!==Qa(n)&&!1!==Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")}function nc(e){return tc(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const rc=new Set(["string","number","symbol"]);function oc(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ic(e,t,n){const r=new e._zod.constr(t??e._zod.def);return t&&!n?.parent||(r._zod.parent=e),r}function sc(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 ac={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 cc(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 uc(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 lc(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function fc(e){return"string"==typeof e?e:e?.message}function dc(e,t,n){const r=e.message?e.message:fc(e.inst?._zod.def?.error?.(e))??fc(t?.error?.(e))??fc(n.customError?.(e))??fc(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 hc(e){return Array.isArray(e)?"array":"string"==typeof e?"string":"unknown"}function pc(...e){const[t,n,r]=e;return"string"==typeof t?{message:t,code:"custom",input:n,inst:r}:{...t}}const mc=(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,ja,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},gc=Fa("$ZodError",mc),yc=Fa("$ZodError",mc,{Parent:Error});const wc=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 Ca;if(s.issues.length){const t=new(o?.Err??e)(s.issues.map(e=>dc(e,i,Da())));throw Ya(t,o?.callee),t}return s.value},bc=wc(yc),vc=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=>dc(e,i,Da())));throw Ya(t,o?.callee),t}return s.value},Ec=vc(yc),_c=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 Ca;return i.issues.length?{success:!1,error:new(e??gc)(i.issues.map(e=>dc(e,o,Da())))}:{success:!0,data:i.value}},xc=_c(yc),kc=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=>dc(e,o,Da())))}:{success:!0,data:i.value}},Ac=kc(yc),Ic=e=>(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return wc(e)(t,n,o)},$c=e=>(t,n,r)=>wc(e)(t,n,r),Bc=e=>async(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return vc(e)(t,n,o)},zc=e=>async(t,n,r)=>vc(e)(t,n,r),Sc=e=>(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return _c(e)(t,n,o)},Oc=e=>(t,n,r)=>_c(e)(t,n,r),Tc=e=>async(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return kc(e)(t,n,o)},Nc=e=>async(t,n,r)=>kc(e)(t,n,r),Rc=/^[cC][0-9a-z]{6,}$/,Uc=/^[0-9a-z]+$/,Pc=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Fc=/^[0-9a-vA-V]{20}$/,Cc=/^[A-Za-z0-9]{27}$/,Lc=/^[a-zA-Z0-9_-]{21}$/,Mc=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Dc=/^([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})$/,Zc=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)$/,jc=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;const qc=/^(?:(?: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])$/,Gc=/^(([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}|:))$/,Hc=/^((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])$/,Vc=/^(([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])$/,Kc=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Wc=/^[A-Za-z0-9_-]*$/,Jc=/^https?$/,Xc=/^\+[1-9]\d{6,14}$/,Yc="(?:(?:\\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])))",Qc=new RegExp(`^${Yc}$`);function eu(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 tu=/^-?\d+n?$/,nu=/^-?\d+$/,ru=/^-?\d+(?:\.\d+)?$/,ou=/^(?:true|false)$/i,iu=/^[^A-Z]*$/,su=/^[^a-z]*$/,au=Fa("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),cu={number:"number",bigint:"bigint",object:"date"},uu=Fa("$ZodCheckLessThan",(e,t)=>{au.init(e,t);const n=cu[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})}}),lu=Fa("$ZodCheckGreaterThan",(e,t)=>{au.init(e,t);const n=cu[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})}}),fu=Fa("$ZodCheckMultipleOf",(e,t)=>{au.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})}}),du=Fa("$ZodCheckNumberFormat",(e,t)=>{au.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),r=n?"int":"number",[o,i]=ac[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=nu)}),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})}}),hu=Fa("$ZodCheckMaxLength",(e,t)=>{var n;au.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!Ga(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=hc(r);n.issues.push({origin:o,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),pu=Fa("$ZodCheckMinLength",(e,t)=>{var n;au.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!Ga(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=hc(r);n.issues.push({origin:o,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),mu=Fa("$ZodCheckLengthEquals",(e,t)=>{var n;au.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!Ga(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=hc(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})}}),gu=Fa("$ZodCheckStringFormat",(e,t)=>{var n,r;au.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=()=>{})}),yu=Fa("$ZodCheckRegex",(e,t)=>{gu.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})}}),wu=Fa("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=iu),gu.init(e,t)}),bu=Fa("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=su),gu.init(e,t)}),vu=Fa("$ZodCheckIncludes",(e,t)=>{au.init(e,t);const n=oc(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})}}),Eu=Fa("$ZodCheckStartsWith",(e,t)=>{au.init(e,t);const n=new RegExp(`^${oc(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})}}),_u=Fa("$ZodCheckEndsWith",(e,t)=>{au.init(e,t);const n=new RegExp(`.*${oc(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})}}),xu=Fa("$ZodCheckOverwrite",(e,t)=>{au.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});class ku{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 e of r)this.content.push(e)}compile(){const e=Function,t=this?.args;return new e(...t,[...(this?.content??[""]).map(e=>` ${e}`)].join("\n"))}}const Au={major:4,minor:4,patch:3},Iu=Fa("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Au;const r=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&r.unshift(e);for(const t of r)for(const n of t._zod.onattach)n(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=cc(e);for(const i of t){if(i._zod.def.when){if(uc(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 Ca;if(r||s instanceof Promise)r=(r??Promise.resolve()).then(async()=>{await s;e.issues.length!==t&&(o||(o=cc(e,t)))});else{if(e.issues.length===t)continue;o||(o=cc(e,t))}}return r?r.then(()=>e):e},n=(n,o,i)=>{if(cc(n))return n.aborted=!0,n;const s=t(o,r,i);if(s instanceof Promise){if(!1===i.async)throw new Ca;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 Ca;return s.then(e=>t(e,r,i))}return t(s,r,i)}}Ka(e,"~standard",()=>({validate:t=>{try{const n=xc(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch(n){return Ac(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:"zod",version:1}))}),$u=Fa("$ZodString",(e,t)=>{var n;Iu.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}}),Bu=Fa("$ZodStringFormat",(e,t)=>{gu.init(e,t),$u.init(e,t)}),zu=Fa("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Dc),Bu.init(e,t)}),Su=Fa("$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=Zc(e))}else t.pattern??(t.pattern=Zc());Bu.init(e,t)}),Ou=Fa("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=jc),Bu.init(e,t)}),Tu=Fa("$ZodURL",(e,t)=>{Bu.init(e,t),e._zod.check=n=>{try{const r=n.value.trim();if(!t.normalize&&t.protocol?.source===Jc.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})}}}),Nu=Fa("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),Bu.init(e,t)}),Ru=Fa("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Lc),Bu.init(e,t)}),Uu=Fa("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Rc),Bu.init(e,t)}),Pu=Fa("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Uc),Bu.init(e,t)}),Fu=Fa("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Pc),Bu.init(e,t)}),Cu=Fa("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Fc),Bu.init(e,t)}),Lu=Fa("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Cc),Bu.init(e,t)}),Mu=Fa("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=function(e){const t=eu({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(`^${Yc}T(?:${r})$`)}(t)),Bu.init(e,t)}),Du=Fa("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Qc),Bu.init(e,t)}),Zu=Fa("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=new RegExp(`^${eu(t)}$`)),Bu.init(e,t)}),ju=Fa("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Mc),Bu.init(e,t)}),qu=Fa("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=qc),Bu.init(e,t),e._zod.bag.format="ipv4"}),Gu=Fa("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Gc),Bu.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})}}}),Hu=Fa("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Hc),Bu.init(e,t)}),Vu=Fa("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Vc),Bu.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 Ku(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 Wu=Fa("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Kc),Bu.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{Ku(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});const Ju=Fa("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Wc),Bu.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{(function(e){if(!Wc.test(e))return!1;const t=e.replace(/[-_]/g,e=>"-"===e?"+":"/");return Ku(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})}}),Xu=Fa("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Xc),Bu.init(e,t)});const Yu=Fa("$ZodJWT",(e,t)=>{Bu.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})}}),Qu=Fa("$ZodNumber",(e,t)=>{Iu.init(e,t),e._zod.pattern=e._zod.bag.pattern??ru,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch(e){}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}}),el=Fa("$ZodNumberFormat",(e,t)=>{du.init(e,t),Qu.init(e,t)}),tl=Fa("$ZodBoolean",(e,t)=>{Iu.init(e,t),e._zod.pattern=ou,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Boolean(n.value)}catch(e){}const o=n.value;return"boolean"==typeof o||n.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),n}}),nl=Fa("$ZodBigInt",(e,t)=>{Iu.init(e,t),e._zod.pattern=tu,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=BigInt(n.value)}catch(e){}return"bigint"==typeof n.value||n.issues.push({expected:"bigint",code:"invalid_type",input:n.value,inst:e}),n}}),rl=Fa("$ZodAny",(e,t)=>{Iu.init(e,t),e._zod.parse=e=>e}),ol=Fa("$ZodUnknown",(e,t)=>{Iu.init(e,t),e._zod.parse=e=>e}),il=Fa("$ZodNever",(e,t)=>{Iu.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:e}),t)});function sl(e,t,n){e.issues.length&&t.issues.push(...lc(n,e.issues)),t.value[n]=e.value}const al=Fa("$ZodArray",(e,t)=>{Iu.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=>sl(t,n,e))):sl(a,n,e)}return i.length?Promise.all(i).then(()=>n):n}});function cl(e,t,n,r,o,i){const s=n in r;if(e.issues.length){if(o&&i&&!s)return;t.issues.push(...lc(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 ul(e){const t=Object.keys(e.shape);for(const n of t)if(!e.shape?.[n]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${n}": 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 ll(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 o in t){if("__proto__"===o)continue;if(a.has(o))continue;if("never"===u){s.push(o);continue}const i=c.run({value:t[o],issues:[]},r);i instanceof Promise?e.push(i.then(e=>cl(e,n,o,t,l,f))):cl(i,n,o,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 fl=Fa("$ZodObject",(e,t)=>{Iu.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=qa(()=>ul(t));Ka(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=Qa,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=>cl(n,t,e,a,o,i))):cl(s,t,e,a,o,i)}return i?ll(c,a,t,n,r.value,e):c.length?Promise.all(c).then(()=>t):t}}),dl=Fa("$ZodObjectJIT",(e,t)=>{fl.init(e,t);const n=e._zod.parse,r=qa(()=>ul(t));let o;const i=Qa,s=!Ma.jitless,a=s&&ec.value,c=t.catchall;let u;e._zod.parse=(l,f)=>{u??(u=r.value);const d=l.value;return i(d)?s&&a&&!1===f?.async&&!0!==f.jitless?(o||(o=(e=>{const t=new ku(["shape","payload","ctx"]),n=r.value,o=e=>{const t=Xa(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 e of n.keys)i[e]="key_"+s++;t.write("const newResult = {};");for(const r of n.keys){const n=i[r],s=Xa(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?ll([],d,l,f,u,e):l):n(l,f):(l.issues.push({expected:"object",code:"invalid_type",input:d,inst:e}),l)}});function hl(e,t,n,r){for(const n of e)if(0===n.issues.length)return t.value=n.value,t;const o=e.filter(e=>!cc(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=>dc(e,r,Da())))}),t)}const pl=Fa("$ZodUnion",(e,t)=>{Iu.init(e,t),Ka(e._zod,"optin",()=>t.options.some(e=>"optional"===e._zod.optin)?"optional":void 0),Ka(e._zod,"optout",()=>t.options.some(e=>"optional"===e._zod.optout)?"optional":void 0),Ka(e._zod,"values",()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),Ka(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=>Ha(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=>hl(t,r,e,o)):hl(s,r,e,o)}}),ml=Fa("$ZodIntersection",(e,t)=>{Iu.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])=>yl(e,t,n)):yl(e,o,i)}});function gl(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(tc(e)&&tc(t)){const n=Object.keys(t),r=Object.keys(e).filter(e=>-1!==n.indexOf(e)),o={...e,...t};for(const n of r){const r=gl(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};o[n]=r.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=gl(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 yl(e,t,n){const r=new Map;let o;for(const n of t.issues)if("unrecognized_keys"===n.code){o??(o=n);for(const e of n.keys)r.has(e)||r.set(e,{}),r.get(e).l=!0}else e.issues.push(n);for(const t of n.issues)if("unrecognized_keys"===t.code)for(const e of t.keys)r.has(e)||r.set(e,{}),r.get(e).r=!0;else e.issues.push(t);const i=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(i.length&&o&&e.issues.push({...o,keys:i}),cc(e))return e;const s=gl(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 wl=Fa("$ZodTuple",(e,t)=>{Iu.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=bl(n,"optin"),c=bl(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=>vl(t,r,e))):vl(i,r,e)}}return s.length?Promise.all(s).then(()=>El(u,r,n,i,c)):El(u,r,n,i,c)}});function bl(e,t){for(let n=e.length-1;n>=0;n--)if("optional"!==e[n]._zod[t])return n+1;return 0}function vl(e,t,n){e.issues.length&&t.issues.push(...lc(n,e.issues)),t.value[n]=e.value}function El(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(...lc(i,n.issues))}t.value[i]=n.value}for(let e=t.value.length-1;e>=r.length&&("optional"===n[e]._zod.optout&&void 0===t.value[e]);e--)t.value.length=e;return t}const _l=Fa("$ZodRecord",(e,t)=>{Iu.init(e,t),e._zod.parse=(n,r)=>{const o=n.value;if(!tc(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 c of s)if("string"==typeof c||"number"==typeof c||"symbol"==typeof c){a.add("number"==typeof c?c.toString():c);const s=t.keyType._zod.run({value:c,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=>dc(e,r,Da())),input:c,path:[c],inst:e});continue}const u=s.value,l=t.valueType._zod.run({value:o[c],issues:[]},r);l instanceof Promise?i.push(l.then(e=>{e.issues.length&&n.issues.push(...lc(c,e.issues)),n.value[u]=e.value})):(l.issues.length&&n.issues.push(...lc(c,l.issues)),n.value[u]=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&&ru.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=>dc(e,r,Da())),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(...lc(s,e.issues)),n.value[a.value]=e.value})):(c.issues.length&&n.issues.push(...lc(s,c.issues)),n.value[a.value]=c.value)}}return i.length?Promise.all(i).then(()=>n):n}}),xl=Fa("$ZodEnum",(e,t)=>{Iu.init(e,t);const n=Za(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter(e=>rc.has(typeof e)).map(e=>"string"==typeof e?oc(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}}),kl=Fa("$ZodLiteral",(e,t)=>{if(Iu.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?oc(e):e?oc(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}}),Al=Fa("$ZodTransform",(e,t)=>{Iu.init(e,t),e._zod.optin="optional",e._zod.parse=(n,r)=>{if("backward"===r.direction)throw new La(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 Ca;return n.value=o,n.fallback=!0,n}});function Il(e,t){return void 0===t&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}const $l=Fa("$ZodOptional",(e,t)=>{Iu.init(e,t),e._zod.optin="optional",e._zod.optout="optional",Ka(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),Ka(e._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${Ha(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=>Il(e,r)):Il(o,r)}return void 0===e.value?e:t.innerType._zod.run(e,n)}}),Bl=Fa("$ZodExactOptional",(e,t)=>{$l.init(e,t),Ka(e._zod,"values",()=>t.innerType._zod.values),Ka(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),zl=Fa("$ZodNullable",(e,t)=>{Iu.init(e,t),Ka(e._zod,"optin",()=>t.innerType._zod.optin),Ka(e._zod,"optout",()=>t.innerType._zod.optout),Ka(e._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${Ha(e.source)}|null)$`):void 0}),Ka(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)}),Sl=Fa("$ZodDefault",(e,t)=>{Iu.init(e,t),e._zod.optin="optional",Ka(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=>Ol(e,t)):Ol(r,t)}});function Ol(e,t){return void 0===e.value&&(e.value=t.defaultValue),e}const Tl=Fa("$ZodPrefault",(e,t)=>{Iu.init(e,t),e._zod.optin="optional",Ka(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))}),Nl=Fa("$ZodNonOptional",(e,t)=>{Iu.init(e,t),Ka(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=>Rl(t,e)):Rl(o,e)}});function Rl(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 Ul=Fa("$ZodCatch",(e,t)=>{Iu.init(e,t),e._zod.optin="optional",Ka(e._zod,"optout",()=>t.innerType._zod.optout),Ka(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=>dc(e,n,Da()))},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=>dc(e,n,Da()))},input:e.value}),e.issues=[],e.fallback=!0),e)}}),Pl=Fa("$ZodPipe",(e,t)=>{Iu.init(e,t),Ka(e._zod,"values",()=>t.in._zod.values),Ka(e._zod,"optin",()=>t.in._zod.optin),Ka(e._zod,"optout",()=>t.out._zod.optout),Ka(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=>Fl(e,t.in,n)):Fl(r,t.in,n)}const r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Fl(e,t.out,n)):Fl(r,t.out,n)}});function Fl(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 Cl=Fa("$ZodReadonly",(e,t)=>{Iu.init(e,t),Ka(e._zod,"propValues",()=>t.innerType._zod.propValues),Ka(e._zod,"values",()=>t.innerType._zod.values),Ka(e._zod,"optin",()=>t.innerType?._zod?.optin),Ka(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(Ll):Ll(r)}});function Ll(e){return e.value=Object.freeze(e.value),e}const Ml=Fa("$ZodFunction",(e,t)=>(Iu.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?bc(e._def.input,n):n,o=Reflect.apply(t,this,r);return e._def.output?bc(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 Ec(e._def.input,n):n,o=await Reflect.apply(t,this,r);return e._def.output?await Ec(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 wl({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)),Dl=Fa("$ZodCustom",(e,t)=>{au.init(e,t),Iu.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=>Zl(t,n,r,e));Zl(o,n,r,e)}});function Zl(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(pc(e))}}var jl;class ql{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)}}(jl=globalThis).__zod_globalRegistry??(jl.__zod_globalRegistry=new ql);const Gl=globalThis.__zod_globalRegistry;function Hl(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...sc(t)})}function Vl(e,t){return new uu({check:"less_than",...sc(t),value:e,inclusive:!1})}function Kl(e,t){return new uu({check:"less_than",...sc(t),value:e,inclusive:!0})}function Wl(e,t){return new lu({check:"greater_than",...sc(t),value:e,inclusive:!1})}function Jl(e,t){return new lu({check:"greater_than",...sc(t),value:e,inclusive:!0})}function Xl(e,t){return new fu({check:"multiple_of",...sc(t),value:e})}function Yl(e,t){return new hu({check:"max_length",...sc(t),maximum:e})}function Ql(e,t){return new pu({check:"min_length",...sc(t),minimum:e})}function ef(e,t){return new mu({check:"length_equals",...sc(t),length:e})}function tf(e){return new xu({check:"overwrite",tx:e})}function nf(e,t){const n=function(e,t){const n=new au({check:"custom",...sc(t)});return n._zod.check=e,n}(t=>(t.addIssue=e=>{if("string"==typeof e)t.issues.push(pc(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(pc(r))}},e(t.value,t)),t);return n}function rf(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??Gl,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 of(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),of(i,t,r),t.seen.get(i).isParent=!0)}const c=t.metadataRegistry.get(e);c&&Object.assign(s.schema,c),"input"===t.io&&cf(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 sf(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 t of e.seen.entries()){const n=e.metadataRegistry.get(t[0])?.id;if(n){const e=r.get(n);if(e&&e!==t[0])throw new Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}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 t of e.seen.entries()){const e=t[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 n of e.seen.entries()){const r=n[1];if(t===n[0]){o(n);continue}if(e.external){const r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){o(n);continue}}const i=e.metadataRegistry.get(n[0])?.id;i?o(n):(r.cycle||r.count>1&&"ref"===e.reused)&&o(n)}}function af(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 t of[...e.seen.entries()].reverse())r(t[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 t of e.seen.entries()){const e=t[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:uf(t,"input",e.processors),output:uf(t,"output",e.processors)}},enumerable:!1,writable:!1}),n}catch(e){throw new Error("Error converting schema to JSON.")}}function cf(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 cf(r.element,n);if("set"===r.type)return cf(r.valueType,n);if("lazy"===r.type)return cf(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 cf(r.innerType,n);if("intersection"===r.type)return cf(r.left,n)||cf(r.right,n);if("record"===r.type||"map"===r.type)return cf(r.keyType,n)||cf(r.valueType,n);if("pipe"===r.type)return!!e._zod.traits.has("$ZodCodec")||(cf(r.in,n)||cf(r.out,n));if("object"===r.type){for(const e in r.shape)if(cf(r.shape[e],n))return!0;return!1}if("union"===r.type){for(const e of r.options)if(cf(e,n))return!0;return!1}if("tuple"===r.type){for(const e of r.items)if(cf(e,n))return!0;return!(!r.rest||!cf(r.rest,n))}return!1}const uf=(e,t,n={})=>r=>{const{libraryOptions:o,target:i}=r??{},s=rf({...o??{},target:i,io:t,processors:n});return of(e,s),sf(s,e),af(s,e)},lf={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},ff=(e,t,n,r)=>{const o=e._zod.def;of(o.innerType,t,r);t.seen.get(e).ref=o.innerType},df=Fa("ZodISODateTime",(e,t)=>{Mu.init(e,t),Mf.init(e,t)});function hf(e){return function(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...sc(t)})}(df,e)}const pf=Fa("ZodISODate",(e,t)=>{Du.init(e,t),Mf.init(e,t)});function mf(e){return function(e,t){return new e({type:"string",format:"date",check:"string_format",...sc(t)})}(pf,e)}const gf=Fa("ZodISOTime",(e,t)=>{Zu.init(e,t),Mf.init(e,t)});function yf(e){return function(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...sc(t)})}(gf,e)}const wf=Fa("ZodISODuration",(e,t)=>{ju.init(e,t),Mf.init(e,t)});function bf(e){return function(e,t){return new e({type:"string",format:"duration",check:"string_format",...sc(t)})}(wf,e)}const vf=(e,t)=>{gc.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,ja,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,ja,2)}},isEmpty:{get:()=>0===e.issues.length}})},Ef=Fa("ZodError",vf,{Parent:Error}),_f=wc(Ef),xf=vc(Ef),kf=_c(Ef),Af=kc(Ef),If=Ic(Ef),$f=$c(Ef),Bf=Bc(Ef),zf=zc(Ef),Sf=Sc(Ef),Of=Oc(Ef),Tf=Tc(Ef),Nf=Nc(Ef),Rf=new WeakMap;function Uf(e,t,n){const r=Object.getPrototypeOf(e);let o=Rf.get(r);if(o||(o=new Set,Rf.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 Pf=Fa("ZodType",(e,t)=>(Iu.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:uf(e,"input"),output:uf(e,"output")}}),e.toJSONSchema=((e,t={})=>n=>{const r=rf({...n,processors:t});return of(e,r),sf(r,e),af(r,e)})(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>_f(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>kf(e,t,n),e.parseAsync=async(t,n)=>xf(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>Af(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>If(e,t,n),e.decode=(t,n)=>$f(e,t,n),e.encodeAsync=async(t,n)=>Bf(e,t,n),e.decodeAsync=async(t,n)=>zf(e,t,n),e.safeEncode=(t,n)=>Sf(e,t,n),e.safeDecode=(t,n)=>Of(e,t,n),e.safeEncodeAsync=async(t,n)=>Tf(e,t,n),e.safeDecodeAsync=async(t,n)=>Nf(e,t,n),Uf(e,"ZodType",{check(...e){const t=this.def;return this.clone(Ja(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 ic(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,...sc(n)})}(Vd,e,t)}(e,t))},superRefine(e,t){return this.check(function(e,t){return nf(e,t)}(e,t))},overwrite(e){return this.check(tf(e))},optional(){return Ud(this)},exactOptional(){return new Pd({type:"optional",innerType:this})},nullable(){return Cd(this)},nullish(){return Ud(Cd(this))},nonoptional(e){return function(e,t){return new Dd({type:"nonoptional",innerType:e,...sc(t)})}(this,e)},array(){return Ed(this)},or(e){return new kd({type:"union",options:[this,e],...sc(t)});var t},and(e){return new Ad({type:"intersection",left:this,right:e})},transform(e){return qd(this,new Nd({type:"transform",transform:e}))},default(e){return t=e,new Ld({type:"default",innerType:this,get defaultValue(){return"function"==typeof t?t():nc(t)}});var t},prefault(e){return t=e,new Md({type:"prefault",innerType:this,get defaultValue(){return"function"==typeof t?t():nc(t)}});var t},catch(e){return new Zd({type:"catch",innerType:this,catchValue:"function"==typeof(t=e)?t:()=>t});var t},pipe(e){return qd(this,e)},readonly(){return new Gd({type:"readonly",innerType:this})},describe(e){const t=this.clone();return Gl.add(t,{description:e}),t},meta(...e){if(0===e.length)return Gl.get(this);const t=this.clone();return Gl.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:()=>Gl.get(e)?.description,configurable:!0}),e)),Ff=Fa("_ZodString",(e,t)=>{$u.init(e,t),Pf.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n)=>{const r=n;r.type="string";const{minimum:o,maximum:i,format:s,patterns:a,contentEncoding:c}=e._zod.bag;if("number"==typeof o&&(r.minLength=o),"number"==typeof i&&(r.maxLength=i),s&&(r.format=lf[s]??s,""===r.format&&delete r.format,"time"===s&&delete r.format),c&&(r.contentEncoding=c),a&&a.size>0){const e=[...a];1===e.length?r.pattern=e[0].source:e.length>1&&(r.allOf=[...e.map(e=>({..."draft-07"===t.target||"draft-04"===t.target||"openapi-3.0"===t.target?{type:"string"}:{},pattern:e.source}))])}})(e,t,n);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,Uf(e,"_ZodString",{regex(...e){return this.check(function(e,t){return new yu({check:"string_format",format:"regex",...sc(t),pattern:e})}(...e))},includes(...e){return this.check(function(e,t){return new vu({check:"string_format",format:"includes",...sc(t),includes:e})}(...e))},startsWith(...e){return this.check(function(e,t){return new Eu({check:"string_format",format:"starts_with",...sc(t),prefix:e})}(...e))},endsWith(...e){return this.check(function(e,t){return new _u({check:"string_format",format:"ends_with",...sc(t),suffix:e})}(...e))},min(...e){return this.check(Ql(...e))},max(...e){return this.check(Yl(...e))},length(...e){return this.check(ef(...e))},nonempty(...e){return this.check(Ql(1,...e))},lowercase(e){return this.check(function(e){return new wu({check:"string_format",format:"lowercase",...sc(e)})}(e))},uppercase(e){return this.check(function(e){return new bu({check:"string_format",format:"uppercase",...sc(e)})}(e))},trim(){return this.check(tf(e=>e.trim()))},normalize(...e){return this.check(function(e){return tf(t=>t.normalize(e))}(...e))},toLowerCase(){return this.check(tf(e=>e.toLowerCase()))},toUpperCase(){return this.check(tf(e=>e.toUpperCase()))},slugify(){return this.check(tf(e=>function(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}(e)))}})}),Cf=Fa("ZodString",(e,t)=>{$u.init(e,t),Ff.init(e,t),e.email=t=>e.check(function(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...sc(t)})}(Df,t)),e.url=t=>e.check(function(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...sc(t)})}(qf,t)),e.jwt=t=>e.check(function(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...sc(t)})}(id,t)),e.emoji=t=>e.check(function(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...sc(t)})}(Gf,t)),e.guid=t=>e.check(Hl(Zf,t)),e.uuid=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...sc(t)})}(jf,t)),e.uuidv4=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...sc(t)})}(jf,t)),e.uuidv6=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...sc(t)})}(jf,t)),e.uuidv7=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...sc(t)})}(jf,t)),e.nanoid=t=>e.check(function(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...sc(t)})}(Hf,t)),e.guid=t=>e.check(Hl(Zf,t)),e.cuid=t=>e.check(function(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...sc(t)})}(Vf,t)),e.cuid2=t=>e.check(function(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...sc(t)})}(Kf,t)),e.ulid=t=>e.check(function(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...sc(t)})}(Wf,t)),e.base64=t=>e.check(function(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...sc(t)})}(nd,t)),e.base64url=t=>e.check(function(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...sc(t)})}(rd,t)),e.xid=t=>e.check(function(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...sc(t)})}(Jf,t)),e.ksuid=t=>e.check(function(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...sc(t)})}(Xf,t)),e.ipv4=t=>e.check(function(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...sc(t)})}(Yf,t)),e.ipv6=t=>e.check(function(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...sc(t)})}(Qf,t)),e.cidrv4=t=>e.check(function(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...sc(t)})}(ed,t)),e.cidrv6=t=>e.check(function(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...sc(t)})}(td,t)),e.e164=t=>e.check(function(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...sc(t)})}(od,t)),e.datetime=t=>e.check(hf(t)),e.date=t=>e.check(mf(t)),e.time=t=>e.check(yf(t)),e.duration=t=>e.check(bf(t))});function Lf(e){return function(e,t){return new e({type:"string",...sc(t)})}(Cf,e)}const Mf=Fa("ZodStringFormat",(e,t)=>{Bu.init(e,t),Ff.init(e,t)}),Df=Fa("ZodEmail",(e,t)=>{Ou.init(e,t),Mf.init(e,t)}),Zf=Fa("ZodGUID",(e,t)=>{zu.init(e,t),Mf.init(e,t)}),jf=Fa("ZodUUID",(e,t)=>{Su.init(e,t),Mf.init(e,t)}),qf=Fa("ZodURL",(e,t)=>{Tu.init(e,t),Mf.init(e,t)}),Gf=Fa("ZodEmoji",(e,t)=>{Nu.init(e,t),Mf.init(e,t)}),Hf=Fa("ZodNanoID",(e,t)=>{Ru.init(e,t),Mf.init(e,t)}),Vf=Fa("ZodCUID",(e,t)=>{Uu.init(e,t),Mf.init(e,t)}),Kf=Fa("ZodCUID2",(e,t)=>{Pu.init(e,t),Mf.init(e,t)}),Wf=Fa("ZodULID",(e,t)=>{Fu.init(e,t),Mf.init(e,t)}),Jf=Fa("ZodXID",(e,t)=>{Cu.init(e,t),Mf.init(e,t)}),Xf=Fa("ZodKSUID",(e,t)=>{Lu.init(e,t),Mf.init(e,t)}),Yf=Fa("ZodIPv4",(e,t)=>{qu.init(e,t),Mf.init(e,t)}),Qf=Fa("ZodIPv6",(e,t)=>{Gu.init(e,t),Mf.init(e,t)}),ed=Fa("ZodCIDRv4",(e,t)=>{Hu.init(e,t),Mf.init(e,t)}),td=Fa("ZodCIDRv6",(e,t)=>{Vu.init(e,t),Mf.init(e,t)}),nd=Fa("ZodBase64",(e,t)=>{Wu.init(e,t),Mf.init(e,t)}),rd=Fa("ZodBase64URL",(e,t)=>{Ju.init(e,t),Mf.init(e,t)}),od=Fa("ZodE164",(e,t)=>{Xu.init(e,t),Mf.init(e,t)}),id=Fa("ZodJWT",(e,t)=>{Yu.init(e,t),Mf.init(e,t)}),sd=Fa("ZodNumber",(e,t)=>{Qu.init(e,t),Pf.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n)=>{const r=n,{minimum:o,maximum:i,format:s,multipleOf:a,exclusiveMaximum:c,exclusiveMinimum:u}=e._zod.bag;"string"==typeof s&&s.includes("int")?r.type="integer":r.type="number";const l="number"==typeof u&&u>=(o??Number.NEGATIVE_INFINITY),f="number"==typeof c&&c<=(i??Number.POSITIVE_INFINITY),d="draft-04"===t.target||"openapi-3.0"===t.target;l?d?(r.minimum=u,r.exclusiveMinimum=!0):r.exclusiveMinimum=u:"number"==typeof o&&(r.minimum=o),f?d?(r.maximum=c,r.exclusiveMaximum=!0):r.exclusiveMaximum=c:"number"==typeof i&&(r.maximum=i),"number"==typeof a&&(r.multipleOf=a)})(e,t,n),Uf(e,"ZodNumber",{gt(e,t){return this.check(Wl(e,t))},gte(e,t){return this.check(Jl(e,t))},min(e,t){return this.check(Jl(e,t))},lt(e,t){return this.check(Vl(e,t))},lte(e,t){return this.check(Kl(e,t))},max(e,t){return this.check(Kl(e,t))},int(e){return this.check(ud(e))},safe(e){return this.check(ud(e))},positive(e){return this.check(Wl(0,e))},nonnegative(e){return this.check(Jl(0,e))},negative(e){return this.check(Vl(0,e))},nonpositive(e){return this.check(Kl(0,e))},multipleOf(e,t){return this.check(Xl(e,t))},step(e,t){return this.check(Xl(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 ad(e){return function(e,t){return new e({type:"number",checks:[],...sc(t)})}(sd,e)}const cd=Fa("ZodNumberFormat",(e,t)=>{el.init(e,t),sd.init(e,t)});function ud(e){return function(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...sc(t)})}(cd,e)}const ld=Fa("ZodBoolean",(e,t)=>{tl.init(e,t),Pf.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t,n)=>{n.type="boolean"})(0,0,t)});function fd(e){return function(e,t){return new e({type:"boolean",...sc(t)})}(ld,e)}const dd=Fa("ZodBigInt",(e,t)=>{nl.init(e,t),Pf.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t)=>{if("throw"===t.unrepresentable)throw new Error("BigInt cannot be represented in JSON Schema")})(0,e),e.gte=(t,n)=>e.check(Jl(t,n)),e.min=(t,n)=>e.check(Jl(t,n)),e.gt=(t,n)=>e.check(Wl(t,n)),e.gte=(t,n)=>e.check(Jl(t,n)),e.min=(t,n)=>e.check(Jl(t,n)),e.lt=(t,n)=>e.check(Vl(t,n)),e.lte=(t,n)=>e.check(Kl(t,n)),e.max=(t,n)=>e.check(Kl(t,n)),e.positive=t=>e.check(Wl(BigInt(0),t)),e.negative=t=>e.check(Vl(BigInt(0),t)),e.nonpositive=t=>e.check(Kl(BigInt(0),t)),e.nonnegative=t=>e.check(Jl(BigInt(0),t)),e.multipleOf=(t,n)=>e.check(Xl(t,n));const n=e._zod.bag;e.minValue=n.minimum??null,e.maxValue=n.maximum??null,e.format=n.format??null});function hd(e){return function(e,t){return new e({type:"bigint",...sc(t)})}(dd,e)}const pd=Fa("ZodAny",(e,t)=>{rl.init(e,t),Pf.init(e,t),e._zod.processJSONSchema=(e,t,n)=>{}});function md(){return new pd({type:"any"})}const gd=Fa("ZodUnknown",(e,t)=>{ol.init(e,t),Pf.init(e,t),e._zod.processJSONSchema=(e,t,n)=>{}});function yd(){return new gd({type:"unknown"})}const wd=Fa("ZodNever",(e,t)=>{il.init(e,t),Pf.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t,n)=>{n.not={}})(0,0,t)});function bd(e){return function(e,t){return new e({type:"never",...sc(t)})}(wd,e)}const vd=Fa("ZodArray",(e,t)=>{al.init(e,t),Pf.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((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=of(i.element,t,{...r,path:[...r.path,"items"]})})(e,t,n,r),e.element=t.element,Uf(e,"ZodArray",{min(e,t){return this.check(Ql(e,t))},nonempty(e){return this.check(Ql(1,e))},max(e,t){return this.check(Yl(e,t))},length(e,t){return this.check(ef(e,t))},unwrap(){return this.element}})});function Ed(e,t){return function(e,t,n){return new e({type:"array",element:t,...sc(n)})}(vd,e,t)}const _d=Fa("ZodObject",(e,t)=>{dl.init(e,t),Pf.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=n,i=e._zod.def;o.type="object",o.properties={};const s=i.shape;for(const e in s)o.properties[e]=of(s[e],t,{...r,path:[...r.path,"properties",e]});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=of(i.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):"output"===t.io&&(o.additionalProperties=!1)})(e,t,n,r),Ka(e,"shape",()=>t.shape),Uf(e,"ZodObject",{keyof(){return Od(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:yd()})},loose(){return this.clone({...this._zod.def,catchall:yd()})},strict(){return this.clone({...this._zod.def,catchall:bd()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return function(e,t){if(!tc(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=Ja(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return Wa(this,"shape",n),n}});return ic(e,r)}(this,e)},safeExtend(e){return function(e,t){if(!tc(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=Ja(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return Wa(this,"shape",n),n}});return ic(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=Ja(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t._zod.def.shape};return Wa(this,"shape",n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return ic(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 ic(e,Ja(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 Wa(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=Ja(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 Wa(this,"shape",r),r},checks:[]});return ic(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=Ja(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 Wa(this,"shape",o),o},checks:[]});return ic(t,o)}(Rd,this,e[0])},required(...e){return function(e,t,n){const r=Ja(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 Wa(this,"shape",o),o}});return ic(t,r)}(Dd,this,e[0])}})});function xd(e,t){const n={type:"object",shape:e??{},...sc(t)};return new _d(n)}const kd=Fa("ZodUnion",(e,t)=>{pl.init(e,t),Pf.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def,i=!1===o.inclusive,s=o.options.map((e,n)=>of(e,t,{...r,path:[...r.path,i?"oneOf":"anyOf",n]}));i?n.oneOf=s:n.anyOf=s})(e,t,n,r),e.options=t.options});const Ad=Fa("ZodIntersection",(e,t)=>{ml.init(e,t),Pf.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def,i=of(o.left,t,{...r,path:[...r.path,"allOf",0]}),s=of(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})(e,t,n,r)});const Id=Fa("ZodTuple",(e,t)=>{wl.init(e,t),Pf.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((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)=>of(e,t,{...r,path:[...r.path,s,n]})),u=i.rest?of(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)})(e,t,n,r),e.rest=t=>e.clone({...e._zod.def,rest:t})});function $d(e,t,n){const r=t instanceof Iu;return new Id({type:"tuple",items:e,rest:r?t:null,...sc(r?n:t)})}const Bd=Fa("ZodRecord",(e,t)=>{_l.init(e,t),Pf.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((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=of(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=of(i.keyType,t,{...r,path:[...r.path,"propertyNames"]})),o.additionalProperties=of(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)}})(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function zd(e,t,n){return t&&t._zod?new Bd({type:"record",keyType:e,valueType:t,...sc(n)}):new Bd({type:"record",keyType:Lf(),valueType:e,...sc(t)})}const Sd=Fa("ZodEnum",(e,t)=>{xl.init(e,t),Pf.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n)=>{const r=Za(e._zod.def.entries);r.every(e=>"number"==typeof e)&&(n.type="number"),r.every(e=>"string"==typeof e)&&(n.type="string"),n.enum=r})(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 r of e){if(!n.has(r))throw new Error(`Key ${r} not found in enum`);o[r]=t.entries[r]}return new Sd({...t,checks:[],...sc(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 Sd({...t,checks:[],...sc(r),entries:o})}});function Od(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new Sd({type:"enum",entries:n,...sc(t)})}const Td=Fa("ZodLiteral",(e,t)=>{kl.init(e,t),Pf.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n)=>{const r=e._zod.def,o=[];for(const e of r.values)if(void 0===e){if("throw"===t.unrepresentable)throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if("bigint"==typeof e){if("throw"===t.unrepresentable)throw new Error("BigInt literals cannot be represented in JSON Schema");o.push(Number(e))}else o.push(e);if(0===o.length);else if(1===o.length){const e=o[0];n.type=null===e?"null":typeof e,"draft-04"===t.target||"openapi-3.0"===t.target?n.enum=[e]:n.const=e}else o.every(e=>"number"==typeof e)&&(n.type="number"),o.every(e=>"string"==typeof e)&&(n.type="string"),o.every(e=>"boolean"==typeof e)&&(n.type="boolean"),o.every(e=>null===e)&&(n.type="null"),n.enum=o})(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 Nd=Fa("ZodTransform",(e,t)=>{Al.init(e,t),Pf.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t)=>{if("throw"===t.unrepresentable)throw new Error("Transforms cannot be represented in JSON Schema")})(0,e),e._zod.parse=(n,r)=>{if("backward"===r.direction)throw new La(e.constructor.name);n.addIssue=r=>{if("string"==typeof r)n.issues.push(pc(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(pc(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)}});const Rd=Fa("ZodOptional",(e,t)=>{$l.init(e,t),Pf.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ff(e,t,0,r),e.unwrap=()=>e._zod.def.innerType});function Ud(e){return new Rd({type:"optional",innerType:e})}const Pd=Fa("ZodExactOptional",(e,t)=>{Bl.init(e,t),Pf.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ff(e,t,0,r),e.unwrap=()=>e._zod.def.innerType});const Fd=Fa("ZodNullable",(e,t)=>{zl.init(e,t),Pf.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def,i=of(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"}]})(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Cd(e){return new Fd({type:"nullable",innerType:e})}const Ld=Fa("ZodDefault",(e,t)=>{Sl.init(e,t),Pf.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def;of(o.innerType,t,r),t.seen.get(e).ref=o.innerType,n.default=JSON.parse(JSON.stringify(o.defaultValue))})(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});const Md=Fa("ZodPrefault",(e,t)=>{Tl.init(e,t),Pf.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def;of(o.innerType,t,r),t.seen.get(e).ref=o.innerType,"input"===t.io&&(n._prefault=JSON.parse(JSON.stringify(o.defaultValue)))})(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});const Dd=Fa("ZodNonOptional",(e,t)=>{Nl.init(e,t),Pf.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def;of(o.innerType,t,r),t.seen.get(e).ref=o.innerType})(e,t,0,r),e.unwrap=()=>e._zod.def.innerType});const Zd=Fa("ZodCatch",(e,t)=>{Ul.init(e,t),Pf.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def;let i;of(o.innerType,t,r),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})(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});const jd=Fa("ZodPipe",(e,t)=>{Pl.init(e,t),Pf.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((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;of(s,t,r),t.seen.get(e).ref=s})(e,t,0,r),e.in=t.in,e.out=t.out});function qd(e,t){return new jd({type:"pipe",in:e,out:t})}const Gd=Fa("ZodReadonly",(e,t)=>{Cl.init(e,t),Pf.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def;of(o.innerType,t,r),t.seen.get(e).ref=o.innerType,n.readOnly=!0})(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});const Hd=Fa("ZodFunction",(e,t)=>{Ml.init(e,t),Pf.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t)=>{if("throw"===t.unrepresentable)throw new Error("Function types cannot be represented in JSON Schema")})(0,e)});const Vd=Fa("ZodCustom",(e,t)=>{Dl.init(e,t),Pf.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t)=>{if("throw"===t.unrepresentable)throw new Error("Custom types cannot be represented in JSON Schema")})(0,e)});function Kd(e){return function(e,t){return new e({type:"number",coerce:!0,checks:[],...sc(t)})}(sd,e)}const Wd=xd({issuer:Lf().transform(e=>ls(e)),index:Lf().transform(e=>ls(e)),timestamp:Lf().transform(e=>ls(e)),signature:Lf().transform(e=>ls(e))});var Jd,Xd,Yd,Qd,eh,th={exports:{}};function nh(){if(Xd)return Jd;Xd=1;var e=1e3,t=60*e,n=60*t,r=24*n,o=7*r,i=365.25*r;function s(e,t,n,r){var o=t>=1.5*n;return Math.round(e/n)+" "+r+(o?"s":"")}return Jd=function(a,c){c=c||{};var u=typeof a;if("string"===u&&a.length>0)return function(s){if((s=String(s)).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(s);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*i;case"weeks":case"week":case"w":return c*o;case"days":case"day":case"d":return c*r;case"hours":case"hour":case"hrs":case"hr":case"h":return c*n;case"minutes":case"minute":case"mins":case"min":case"m":return c*t;case"seconds":case"second":case"secs":case"sec":case"s":return c*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return c;default:return}}(a);if("number"===u&&isFinite(a))return c.long?function(o){var i=Math.abs(o);if(i>=r)return s(o,i,r,"day");if(i>=n)return s(o,i,n,"hour");if(i>=t)return s(o,i,t,"minute");if(i>=e)return s(o,i,e,"second");return o+" ms"}(a):function(o){var i=Math.abs(o);if(i>=r)return Math.round(o/r)+"d";if(i>=n)return Math.round(o/n)+"h";if(i>=t)return Math.round(o/t)+"m";if(i>=e)return Math.round(o/e)+"s";return o+"ms"}(a);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(a))}}var rh=(eh||(eh=1,function(e,t){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(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")||t.storage.getItem("DEBUG")}catch(e){}return!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG),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=(Qd||(Qd=1,Yd=function(e){function t(e){let r,o,i,s=null;function a(...e){if(!a.enabled)return;const n=a,o=Number(new Date),i=o-(r||o);n.diff=i,n.prev=r,n.curr=o,r=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,(r,o)=>{if("%%"===r)return"%";s++;const i=t.formatters[o];if("function"==typeof i){const t=e[s];r=i.call(n,t),e.splice(s,1),s--}return r}),t.formatArgs.call(n,e),(n.log||t.log).apply(n,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=n,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 n(e,n){const r=t(this.namespace+(void 0===n?":":n)+e);return r.log=this.log,r}function r(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){return e instanceof Error?e.stack||e.message: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 e of n)"-"===e[0]?t.skips.push(e.slice(1)):t.names.push(e)},t.enabled=function(e){for(const n of t.skips)if(r(e,n))return!1;for(const n of t.names)if(r(e,n))return!0;return!1},t.humanize=nh(),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}),Yd)(t);const{formatters:n}=e.exports;n.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(th,th.exports)),th.exports);const oh=Vr(rh)("bee-js:http"),ih={headers:{accept:"application/json, text/plain, */*"}};async function sh(e,t){const n=t.data,r=Jr.Objects.deepMerge3(ih,{...t,data:void 0},e);if(r.data=n,e.signal&&(r.signal=e.signal),function(e){if(void 0===e.data)return;const t=e.data;if(null!==t&&"object"==typeof t&&t.constructor===Object||Array.isArray(t))e.body=JSON.stringify(t),e.headers={"content-type":"application/json",...e.headers};else{e.body=t,e.duplex="half";const n=t instanceof Blob&&t.type?t.type:"application/octet-stream";e.headers={"content-type":n,...e.headers}}}(r),r.params)for(const e of Object.keys(r.params))void 0===r.params[e]&&delete r.params[e];const o=function(e){let t=Jr.Strings.joinUrl([e.baseURL??"",e.url??""]);if(e.params){const n=new URLSearchParams(Object.entries(e.params).filter(([,e])=>void 0!==e).map(([e,t])=>[e,String(t)])).toString();n&&(t+=`?${n}`)}return t}(r),i=(r.method||"GET").toUpperCase();r.method=i,e.onRequest?.({method:i,url:Jr.Strings.joinUrl([r.baseURL??"",r.url??""]),headers:{...r.headers},params:r.params});let s=0;for(;s<1e5;)try{oh(`${i} ${o}`,{headers:r.headers,params:r.params});const e=await fetch(o,r);return e.ok||await ah(i,o,e,r.responseType),uh(e,r.responseType)}catch(t){if(t instanceof ph)throw t;const n=t;if("TimeoutError"!==n.name||!e.endlesslyRetry)throw ch(n,i,o);s++,await Jr.System.sleepMillis(s<300?200:1e3)}throw Error("Max number of failed attempts reached")}async function ah(e,t,n,r){const o=await uh(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 ph(e,t,s,o.data,n.status,n.statusText)}function ch(e,t,n){if("AbortError"===e.name)return new ph(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 ph(t,n,o)}async function uh(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 lh=xd({durationSeconds:ad()}),fh=xd({reference:Lf().transform(e=>new Vs(e))});class dh extends Error{constructor(e){super(e)}}class hh extends dh{constructor(e,t){super(e),this.value=t}}class ph extends dh{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 mh{constructor(e){this.seconds=Math.ceil(e),e<0&&(this.seconds=0)}static fromMilliseconds(e){return new mh(e/1e3)}static fromSeconds(e){return new mh(e)}static fromHours(e){return new mh(60*e*60)}static fromDays(e){return new mh(24*e*60*60)}static fromWeeks(e){return new mh(7*e*24*60*60)}static fromYears(e){return new mh(365*e*24*60*60)}static fromEndDate(e,t){return new mh((e.getTime()-(t??new Date).getTime())/1e3)}static parseFromString(e){return mh.fromSeconds(Jr.Dates.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 Jr.Dates.secondsToHumanTime(this.seconds)}isZero(){return 0===this.seconds}}mh.ZERO=new mh(0);class gh{constructor(e){this.state=e}static fromDecimalString(e){return new gh(Jr.FixedPointNumber.fromDecimalString(e,gh.DIGITS))}static fromPLUR(e){return new gh(new Jr.FixedPointNumber(e,gh.DIGITS))}static fromFloat(e){return new gh(Jr.FixedPointNumber.fromFloat(e,gh.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 gh(this.state.add(e instanceof gh?e.state:new Jr.FixedPointNumber(e,gh.DIGITS)))}minus(e){return new gh(this.state.subtract(e instanceof gh?e.state:new Jr.FixedPointNumber(e,gh.DIGITS)))}divide(e){return new gh(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 yh.fromWei(this.state.exchange("*",new Jr.FixedPointNumber(e.toWeiBigInt(),yh.DIGITS),yh.DIGITS).value)}}gh.DIGITS=16;class yh{constructor(e){this.state=e}static fromDecimalString(e){return new yh(Jr.FixedPointNumber.fromDecimalString(e,yh.DIGITS))}static fromWei(e){return new yh(new Jr.FixedPointNumber(e,yh.DIGITS))}static fromFloat(e){return new yh(Jr.FixedPointNumber.fromFloat(e,yh.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 yh(this.state.add(e instanceof yh?e.state:new Jr.FixedPointNumber(e,yh.DIGITS)))}minus(e){return new yh(this.state.subtract(e instanceof yh?e.state:new Jr.FixedPointNumber(e,yh.DIGITS)))}divide(e){return new yh(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 gh.fromPLUR(this.state.exchange("/",new Jr.FixedPointNumber(e.toWeiBigInt(),yh.DIGITS),gh.DIGITS).value)}}function wh(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)}async function bh(e){return e.arrayBuffer?e.arrayBuffer():new Promise(t=>{const n=new FileReader;n.onload=()=>t(n.result),n.readAsArrayBuffer(e)})}var vh;function Eh(e){switch(e){case"full":return vh.FULL;case"light":return vh.LIGHT;case"ultra-light":return vh.ULTRA_LIGHT;case"dev":return vh.DEV;default:throw new Error(`Unknown Bee mode: ${e}`)}}yh.DIGITS=18,function(e){e.FULL="full",e.LIGHT="light",e.ULTRA_LIGHT="ultra-light",e.DEV="dev"}(vh||(vh={}));const _h=4096,xh=17,kh=255;var Ah,Ih;!function(e){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"}(Ah||(Ah={})),function(e){e[e.NONE=0]="NONE",e[e.DATA=1]="DATA",e[e.PROX=2]="PROX",e[e.RACE=3]="RACE"}(Ih||(Ih={})),Ah.OFF,Ah.MEDIUM,Ah.STRONG,Ah.INSANE,Ah.PARANOID,Ah.OFF,Ah.MEDIUM,Ah.STRONG,Ah.INSANE,Ah.PARANOID,Lf().regex(/^(?:0x)?[0-9a-fA-F]*$/i,"expected hex string").refine(e=>e.replace(/^0x/i,"").length%2==0,"expected even-length hex string");const $h=md().refine(e=>{return new Hd({type:"function",input:Array.isArray(t?.input)?$d(t?.input):Ed(yd()),output:yd()}).safeParse(e).success;var t},"expected a function"),Bh=md().transform(e=>(hd().safeParse(e).success&&(e=String(e)),Lf().regex(/^-?\d+$/,"expected integer string").parse(e))),zh=md().transform(e=>(hd().safeParse(e).success&&(e=String(e)),Lf().regex(/^\d+$/,"expected non-negative integer string").parse(e))),Sh=xd({baseURL:Lf().optional(),timeout:ad().int().min(0).optional(),headers:zd(Lf(),Lf()).optional(),onRequest:$h.optional(),httpAgent:yd().optional(),httpsAgent:yd().optional(),endlesslyRetry:fd().optional(),signal:md().optional()}),Oh=xd({redundancyStrategy:ad().int().optional(),fallback:fd().optional(),timeoutMs:ad().int().min(0).optional(),actPublisher:Ud(md().transform(e=>new Ds(e))),actHistoryAddress:Ud(md().transform(e=>new Vs(e))),actTimestamp:Kd().optional()}),Th=xd({act:fd().optional(),actHistoryAddress:Ud(md().transform(e=>new Vs(e))),deferred:fd().optional(),encrypt:fd().optional(),pin:fd().optional(),tag:ad().int().min(0).optional()}),Nh=Th.extend({redundancyLevel:ad().int().min(0).optional()}),Rh=Th.extend({size:ad().int().min(0).optional(),contentType:Lf().optional(),redundancyLevel:ad().int().min(0).optional()}),Uh=Th.extend({errorDocument:Lf().optional(),indexDocument:Lf().optional(),redundancyLevel:ad().int().min(0).optional()}),Ph=xd({uid:ad().int()}),Fh=Kd().min(0),Ch=xd({onMessage:$h,onError:$h,onClose:$h}),Lh=xd({onMessage:$h,onError:$h,onClose:$h}),Mh=xd({gasPrice:Bh.optional(),immutableFlag:fd().optional(),label:Lf().optional(),waitForUsable:fd().optional(),waitForUsableTimeout:ad().int().min(0).optional()}),Dh=xd({gasLimit:zh.optional(),gasPrice:zh.optional()}),Zh=xd({limit:ad().int().min(1).max(1e3).optional(),offset:ad().int().min(0).optional()});function jh(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 qh(e){if("string"!=typeof e&&!(e instanceof Uint8Array)&&!(e instanceof Blob))throw new TypeError("Data must be either string, Uint8Array, Blob or Readable!")}function Gh(e){if("string"!=typeof e&&!(e instanceof Uint8Array)&&!wh(e))throw new TypeError("Data must be either string, Readable, Uint8Array or File!")}function Hh(e){if(null==e)throw new TypeError(`Expected number | Tag | string from tagUid, got: ${e}`);if(t=e,Ph.safeParse(t).success)return e.uid;if("number"==typeof e||"string"==typeof e)return Fh.parse(e);var t;throw new TypeError(`Expected number | Tag | string from tagUid, got: ${e}`)}function Vh(e){return Number.isInteger(e)?e<1?1:e>3155695200?3155695200:e:1}const Kh=xd({peer:Lf(),balance:Lf().transform(e=>gh.fromPLUR(jh(e,{name:"balance"})))}),Wh=xd({balances:Ed(Kh)}),Jh=Kh,Xh=xd({beneficiary:Lf().transform(e=>new Ns(e)),chequebook:Lf().transform(e=>new Ns(e)),payout:Lf().transform(e=>gh.fromPLUR(jh(e,{name:"payout"})))}),Yh=xd({recipient:Lf(),lastPayout:Lf().transform(e=>gh.fromPLUR(jh(e,{name:"lastPayout"}))),bounced:fd()}),Qh=xd({chequebookAddress:Lf().transform(e=>new Ns(e))}),ep=xd({availableBalance:Lf().transform(e=>gh.fromPLUR(jh(e,{name:"availableBalance"}))),totalBalance:Lf().transform(e=>gh.fromPLUR(jh(e,{name:"totalBalance"})))}),tp=xd({peer:Lf(),uncashedAmount:Lf().transform(e=>gh.fromPLUR(jh(e,{name:"uncashedAmount"}))),transactionHash:Lf().nullish().transform(e=>e??null),lastCashedCheque:Xh.nullish().transform(e=>e??null),result:Yh.nullish().transform(e=>e??null)}),np=xd({peer:Lf(),lastreceived:Xh.nullish().transform(e=>e??null),lastsent:Xh.nullish().transform(e=>e??null)}),rp=xd({lastcheques:Ed(xd({peer:Lf(),lastreceived:Xh.nullish().transform(e=>e??null),lastsent:Xh.nullish().transform(e=>e??null)}))}),op=xd({transactionHash:Lf().transform(e=>new Xs(e))}),ip=xd({address:Lf(),fullNode:fd()}),sp=xd({population:ad(),connected:ad(),connectedPeers:Ed(xd({address:Lf()})).nullish().transform(e=>e??[]),disconnectedPeers:Ed(xd({address:Lf()})).nullish().transform(e=>e??[])}),ap=zd(Lf(),sp),cp=xd({overlay:Lf().transform(e=>new Cs(e)),underlay:Ed(Lf()),ethereum:Lf().transform(e=>new Ns(e)),publicKey:Lf().transform(e=>new Ds(e)),pssPublicKey:Lf().transform(e=>new Ds(e))}),up=xd({peers:Ed(ip)}),lp=xd({peers:Ed(ip)}),fp=xd({baseAddr:Lf(),population:ad(),connected:ad(),timestamp:Lf(),nnLowWatermark:ad(),depth:ad(),reachability:Lf(),networkAvailability:Lf(),bins:ap}),dp=xd({overlay:Lf(),proximity:ad(),beeMode:Lf().transform(Eh),reserveSize:ad(),reserveSizeWithinRadius:ad(),pullsyncRate:ad(),storageRadius:ad(),connectedPeers:ad(),neighborhoodSize:ad(),batchCommitment:ad(),isReachable:fd(),lastSyncedBlock:ad(),committedDepth:ad(),isWarmingUp:fd()}),hp=xd({apiVersion:Lf(),version:Lf(),status:(pp="ok",new Td({type:"literal",values:Array.isArray(pp)?pp:[pp],...sc(mp)}))});var pp,mp;const gp=xd({apiVersion:Lf(),version:Lf(),status:Od(["ready","notReady"])}),yp=xd({beeMode:Lf().transform(Eh),chequebookEnabled:fd(),swapEnabled:fd()}),wp=xd({gateway:fd()}),bp=xd({isRetrievable:fd()}),vp=Ed(Lf().transform(e=>new Ds(e))),Ep=xd({ref:Lf().transform(e=>new Vs(e)),historyref:Lf().transform(e=>new Vs(e))});var _p=null;"undefined"!=typeof WebSocket?_p=WebSocket:"undefined"!=typeof MozWebSocket?_p=MozWebSocket:"undefined"!=typeof global?_p=global.WebSocket||global.MozWebSocket:"undefined"!=typeof window?_p=window.WebSocket||window.MozWebSocket:"undefined"!=typeof self&&(_p=self.WebSocket||self.MozWebSocket);var xp=_p;const kp=xd({references:Ed(Lf()).nullable()}),Ap=xd({peer:Lf(),sent:Lf().transform(e=>gh.fromPLUR(jh(e,{name:"sent"}))),received:Lf().transform(e=>gh.fromPLUR(jh(e,{name:"received"})))}),Ip=Ap,$p=xd({totalSent:Lf().transform(e=>gh.fromPLUR(jh(e,{name:"totalSent"}))),totalReceived:Lf().transform(e=>gh.fromPLUR(jh(e,{name:"totalReceived"}))),settlements:Ed(Ap)}),Bp=xd({stakedAmount:Lf().transform(e=>gh.fromPLUR(jh(e,{name:"stakedAmount"})))}),zp=xd({withdrawableAmount:Lf().transform(e=>gh.fromPLUR(jh(e,{name:"withdrawableAmount"})))}),Sp=xd({txHash:Lf().transform(e=>new Xs(e))}),Op=xd({minimumGasFunds:Lf().transform(e=>yh.fromWei(jh(e,{name:"minimumGasFunds"}))),hasSufficientFunds:fd(),isFrozen:fd(),isFullySynced:fd(),phase:Lf(),round:ad(),lastWonRound:ad(),lastPlayedRound:ad(),lastFrozenRound:ad(),lastSelectedRound:ad(),lastSampleDurationSeconds:ad(),block:ad(),reward:Lf().transform(e=>gh.fromPLUR(jh(e,{name:"reward"}))),fees:Lf().transform(e=>yh.fromWei(jh(e,{name:"fees"}))),isHealthy:fd()}),Tp=xd({batchID:Lf(),utilization:ad(),utilizationRatio:ad().optional(),usable:fd(),label:Lf(),depth:ad(),amount:Lf(),bucketDepth:ad(),blockNumber:ad(),immutableFlag:fd(),batchTTL:ad()}),Np=xd({batchID:Lf().transform(e=>new zs(e)),batchTTL:ad(),bucketDepth:ad(),depth:ad(),immutable:fd(),owner:Lf().transform(e=>new Ns(e)),start:ad(),value:Lf().transform(e=>jh(e,{name:"value"}))}),Rp=xd({batches:Ed(Np)}),Up=xd({stamps:Ed(Tp)}),Pp=Tp,Fp=xd({depth:ad(),bucketDepth:ad(),bucketUpperBound:ad(),buckets:Ed(xd({bucketID:ad(),collisions:ad()}))}),Cp=xd({batchID:Lf().transform(e=>new zs(e))});var Lp,Mp,Dp,Zp;function jp(){if(Mp)return Lp;Mp=1;const e="object"==typeof process&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...e)=>console.error("SEMVER",...e):()=>{};return Lp=e}function qp(){if(Zp)return Dp;Zp=1;const e=Number.MAX_SAFE_INTEGER||9007199254740991;return Dp={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:16,MAX_SAFE_BUILD_LENGTH:250,MAX_SAFE_INTEGER:e,RELEASE_TYPES:["major","premajor","minor","preminor","patch","prepatch","prerelease"],SEMVER_SPEC_VERSION:"2.0.0",FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}}var Gp,Hp,Vp,Kp,Wp,Jp,Xp,Yp,Qp,em={exports:{}};function tm(){return Gp||(Gp=1,function(e,t){const{MAX_SAFE_COMPONENT_LENGTH:n,MAX_SAFE_BUILD_LENGTH:r,MAX_LENGTH:o}=qp(),i=jp(),s=(t=e.exports={}).re=[],a=t.safeRe=[],c=t.src=[],u=t.safeSrc=[],l=t.t={};let f=0;const d="[a-zA-Z0-9-]",h=[["\\s",1],["\\d",o],[d,r]],p=(e,t,n)=>{const r=(e=>{for(const[t,n]of h)e=e.split(`${t}*`).join(`${t}{0,${n}}`).split(`${t}+`).join(`${t}{1,${n}}`);return e})(t),o=f++;i(e,o,t),l[e]=o,c[o]=t,u[o]=r,s[o]=new RegExp(t,n?"g":void 0),a[o]=new RegExp(r,n?"g":void 0)};p("NUMERICIDENTIFIER","0|[1-9]\\d*"),p("NUMERICIDENTIFIERLOOSE","\\d+"),p("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${d}*`),p("MAINVERSION",`(${c[l.NUMERICIDENTIFIER]})\\.(${c[l.NUMERICIDENTIFIER]})\\.(${c[l.NUMERICIDENTIFIER]})`),p("MAINVERSIONLOOSE",`(${c[l.NUMERICIDENTIFIERLOOSE]})\\.(${c[l.NUMERICIDENTIFIERLOOSE]})\\.(${c[l.NUMERICIDENTIFIERLOOSE]})`),p("PRERELEASEIDENTIFIER",`(?:${c[l.NONNUMERICIDENTIFIER]}|${c[l.NUMERICIDENTIFIER]})`),p("PRERELEASEIDENTIFIERLOOSE",`(?:${c[l.NONNUMERICIDENTIFIER]}|${c[l.NUMERICIDENTIFIERLOOSE]})`),p("PRERELEASE",`(?:-(${c[l.PRERELEASEIDENTIFIER]}(?:\\.${c[l.PRERELEASEIDENTIFIER]})*))`),p("PRERELEASELOOSE",`(?:-?(${c[l.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${c[l.PRERELEASEIDENTIFIERLOOSE]})*))`),p("BUILDIDENTIFIER",`${d}+`),p("BUILD",`(?:\\+(${c[l.BUILDIDENTIFIER]}(?:\\.${c[l.BUILDIDENTIFIER]})*))`),p("FULLPLAIN",`v?${c[l.MAINVERSION]}${c[l.PRERELEASE]}?${c[l.BUILD]}?`),p("FULL",`^${c[l.FULLPLAIN]}$`),p("LOOSEPLAIN",`[v=\\s]*${c[l.MAINVERSIONLOOSE]}${c[l.PRERELEASELOOSE]}?${c[l.BUILD]}?`),p("LOOSE",`^${c[l.LOOSEPLAIN]}$`),p("GTLT","((?:<|>)?=?)"),p("XRANGEIDENTIFIERLOOSE",`${c[l.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),p("XRANGEIDENTIFIER",`${c[l.NUMERICIDENTIFIER]}|x|X|\\*`),p("XRANGEPLAIN",`[v=\\s]*(${c[l.XRANGEIDENTIFIER]})(?:\\.(${c[l.XRANGEIDENTIFIER]})(?:\\.(${c[l.XRANGEIDENTIFIER]})(?:${c[l.PRERELEASE]})?${c[l.BUILD]}?)?)?`),p("XRANGEPLAINLOOSE",`[v=\\s]*(${c[l.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[l.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[l.XRANGEIDENTIFIERLOOSE]})(?:${c[l.PRERELEASELOOSE]})?${c[l.BUILD]}?)?)?`),p("XRANGE",`^${c[l.GTLT]}\\s*${c[l.XRANGEPLAIN]}$`),p("XRANGELOOSE",`^${c[l.GTLT]}\\s*${c[l.XRANGEPLAINLOOSE]}$`),p("COERCEPLAIN",`(^|[^\\d])(\\d{1,${n}})(?:\\.(\\d{1,${n}}))?(?:\\.(\\d{1,${n}}))?`),p("COERCE",`${c[l.COERCEPLAIN]}(?:$|[^\\d])`),p("COERCEFULL",c[l.COERCEPLAIN]+`(?:${c[l.PRERELEASE]})?`+`(?:${c[l.BUILD]})?(?:$|[^\\d])`),p("COERCERTL",c[l.COERCE],!0),p("COERCERTLFULL",c[l.COERCEFULL],!0),p("LONETILDE","(?:~>?)"),p("TILDETRIM",`(\\s*)${c[l.LONETILDE]}\\s+`,!0),t.tildeTrimReplace="$1~",p("TILDE",`^${c[l.LONETILDE]}${c[l.XRANGEPLAIN]}$`),p("TILDELOOSE",`^${c[l.LONETILDE]}${c[l.XRANGEPLAINLOOSE]}$`),p("LONECARET","(?:\\^)"),p("CARETTRIM",`(\\s*)${c[l.LONECARET]}\\s+`,!0),t.caretTrimReplace="$1^",p("CARET",`^${c[l.LONECARET]}${c[l.XRANGEPLAIN]}$`),p("CARETLOOSE",`^${c[l.LONECARET]}${c[l.XRANGEPLAINLOOSE]}$`),p("COMPARATORLOOSE",`^${c[l.GTLT]}\\s*(${c[l.LOOSEPLAIN]})$|^$`),p("COMPARATOR",`^${c[l.GTLT]}\\s*(${c[l.FULLPLAIN]})$|^$`),p("COMPARATORTRIM",`(\\s*)${c[l.GTLT]}\\s*(${c[l.LOOSEPLAIN]}|${c[l.XRANGEPLAIN]})`,!0),t.comparatorTrimReplace="$1$2$3",p("HYPHENRANGE",`^\\s*(${c[l.XRANGEPLAIN]})\\s+-\\s+(${c[l.XRANGEPLAIN]})\\s*$`),p("HYPHENRANGELOOSE",`^\\s*(${c[l.XRANGEPLAINLOOSE]})\\s+-\\s+(${c[l.XRANGEPLAINLOOSE]})\\s*$`),p("STAR","(<|>)?=?\\s*\\*"),p("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$"),p("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")}(em,em.exports)),em.exports}function nm(){if(Xp)return Jp;Xp=1;const e=jp(),{MAX_LENGTH:t,MAX_SAFE_INTEGER:n}=qp(),{safeRe:r,t:o}=tm(),i=function(){if(Vp)return Hp;Vp=1;const e=Object.freeze({loose:!0}),t=Object.freeze({});return Hp=n=>n?"object"!=typeof n?e:n:t}(),{compareIdentifiers:s}=function(){if(Wp)return Kp;Wp=1;const e=/^[0-9]+$/,t=(t,n)=>{if("number"==typeof t&&"number"==typeof n)return t===n?0:t<n?-1:1;const r=e.test(t),o=e.test(n);return r&&o&&(t=+t,n=+n),t===n?0:r&&!o?-1:o&&!r?1:t<n?-1:1};return Kp={compareIdentifiers:t,rcompareIdentifiers:(e,n)=>t(n,e)}}();class a{constructor(s,c){if(c=i(c),s instanceof a){if(s.loose===!!c.loose&&s.includePrerelease===!!c.includePrerelease)return s;s=s.version}else if("string"!=typeof s)throw new TypeError(`Invalid version. Must be a string. Got type "${typeof s}".`);if(s.length>t)throw new TypeError(`version is longer than ${t} characters`);e("SemVer",s,c),this.options=c,this.loose=!!c.loose,this.includePrerelease=!!c.includePrerelease;const u=s.trim().match(c.loose?r[o.LOOSE]:r[o.FULL]);if(!u)throw new TypeError(`Invalid Version: ${s}`);if(this.raw=s,this.major=+u[1],this.minor=+u[2],this.patch=+u[3],this.major>n||this.major<0)throw new TypeError("Invalid major version");if(this.minor>n||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>n||this.patch<0)throw new TypeError("Invalid patch version");u[4]?this.prerelease=u[4].split(".").map(e=>{if(/^[0-9]+$/.test(e)){const t=+e;if(t>=0&&t<n)return t}return e}):this.prerelease=[],this.build=u[5]?u[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(t){if(e("SemVer.compare",this.version,this.options,t),!(t instanceof a)){if("string"==typeof t&&t===this.version)return 0;t=new a(t,this.options)}return t.version===this.version?0:this.compareMain(t)||this.comparePre(t)}compareMain(e){return e instanceof a||(e=new a(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(t){if(t instanceof a||(t=new a(t,this.options)),this.prerelease.length&&!t.prerelease.length)return-1;if(!this.prerelease.length&&t.prerelease.length)return 1;if(!this.prerelease.length&&!t.prerelease.length)return 0;let n=0;do{const r=this.prerelease[n],o=t.prerelease[n];if(e("prerelease compare",n,r,o),void 0===r&&void 0===o)return 0;if(void 0===o)return 1;if(void 0===r)return-1;if(r!==o)return s(r,o)}while(++n)}compareBuild(t){t instanceof a||(t=new a(t,this.options));let n=0;do{const r=this.build[n],o=t.build[n];if(e("build compare",n,r,o),void 0===r&&void 0===o)return 0;if(void 0===o)return 1;if(void 0===r)return-1;if(r!==o)return s(r,o)}while(++n)}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?r[o.PRERELEASELOOSE]:r[o.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 t=0;t<n.length;t++)if(0!==s(e[t],n[t]))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}}return Jp=a}var rm=Vr(function(){if(Qp)return Yp;Qp=1;const e=nm();return Yp=(t,n)=>new e(t,n).major}());const om="2.8.1-7cf53193";om.split("-")[0];const im="8.1.0",sm=xd({commitment:ad(),radius:ad(),storageRadius:ad(),reserveCapacityDoubling:ad()}),am=xd({block:ad(),chainTip:ad(),totalAmount:Lf().transform(e=>jh(e,{name:"totalAmount"})),currentPrice:Lf().transform(Number).transform(e=>{return t=e,Number.isInteger(t)?t<24e3?24e3:t:24e3;var t}),minimumValidityBlocks:ad().optional()}),cm=xd({bzzBalance:Lf().transform(e=>gh.fromPLUR(jh(e,{name:"bzzBalance"}))),nativeTokenBalance:Lf().transform(e=>yh.fromWei(jh(e,{name:"nativeTokenBalance"}))),chainID:ad(),chequebookContractAddress:Lf(),walletAddress:Lf()}),um=xd({transactionHash:Lf().transform(e=>new Xs(e))}),lm=xd({address:Lf().nullish().transform(e=>e??""),seen:ad(),sent:ad(),split:ad(),startedAt:Lf(),stored:ad(),synced:ad(),uid:ad()}),fm=xd({tags:Ed(lm)}),dm=xd({transactionHash:Lf().transform(e=>new Xs(e)),to:Lf(),nonce:ad(),gasPrice:Lf().transform(e=>jh(e,{name:"gasPrice"})),gasLimit:ad(),data:Lf(),created:Lf(),description:Lf(),value:Lf().transform(e=>jh(e,{name:"value"}))}),hm=xd({pendingTransactions:Ed(dm)}),pm=dm,mm=xd({transactionHash:Lf().transform(e=>new Xs(e))});new zs("0000000000000000000000000000000000000000000000000000000000000000"),new Js("0000000000000000000000000000000000000000000000000000000000000000");const gm=new Uint8Array(32);function ym(e){return e.endsWith("/")?e.slice(0,-1):e}function wm(e){try{const{protocol:t}=new URL(e);return"http:"===t||"https:"===t}catch{return!1}}function bm(e){if(!wm(e)||/[\s?#]/.test(e))return!1;const{username:t,password:n}=new URL(e);return""===t&&""===n}function vm(e,t,n,r){const o=new URLSearchParams;return o.set("origin",t),n&&(o.set("appName",n.name),n.description&&o.set("appDescription",n.description),n.icon&&o.set("appIcon",n.icon)),r?.challenge&&o.set("challenge",r.challenge),`${e}/connect#${o.toString()}`}const Em="https://api.gateway.ethswarm.org/",_m="https://xdai.fairdatasociety.org/",xm=e=>Fn().regex(new RegExp(`^[0-9a-fA-F]{${e}}$`),{message:`Must be a ${e}-character hex string`}),km=Fn().regex(/^[0-9a-fA-F]{64}$|^[0-9a-fA-F]{128}$/,{message:"Reference must be 64 hex chars (32 bytes) or 128 hex chars (64 bytes for encrypted)"}),Am=xm(64),Im=xm(40),$m=xm(64),Bm=xm(66),zm=xm(64),Sm=xm(64),Om=xm(130),Tm=xm(64),Nm=xm(226),Rm=Hr(e=>"bigint"==typeof e?e.toString():e,Er([ir(),Fn()])),Um=Hr(e=>"bigint"==typeof e?e.toString():e,Er([ir(),Fn()])),Pm=Im.transform(e=>new Ns(e)),Fm=Am.transform(e=>new zs(e)),Cm=$m.transform(e=>new Hs(e)),Lm=Fn().regex(/^\d+$/,{message:"Must be a decimal integer string"}).transform(e=>BigInt(e)),Mm=wr({deviceId:Fn(),createdAt:ir(),lastSignedInAt:ir(),name:Fn().optional(),nameUpdatedAt:ir().optional(),removedAt:ir().optional()}),Dm=wr({message:Fn().max(512),signature:Fn().regex(/^0x[0-9a-fA-F]{130}$/)}),Zm="none",jm=wr({appUrl:Fn(),appName:Fn(),lastConnectedAt:ir(),appIcon:Fn().optional(),appDescription:Fn().optional(),connectedUntil:ir().optional(),appSecret:Fn().optional(),postageStampBatchID:Er([Sr(Zm),Fm]).optional(),postageStampBatchIDAt:ir().optional(),stampPending:Sr(!0).optional(),revokedAt:ir().optional(),disconnectedAt:ir().optional(),chatBinding:Dm.optional()}),qm=wr({batchID:Fm,signerKey:Cm,name:Fn().optional(),nameUpdatedAt:ir().optional(),utilization:ir(),usable:ur(),depth:ir(),amount:Lm,bucketDepth:ir(),blockNumber:ir(),immutableFlag:ur(),exists:ur(),batchTTL:ir().optional(),createdAt:ir(),updatedAt:ir().optional(),deletedAt:ir().optional()}),Gm=xr("type",[wr({type:Sr("passkey"),credentialId:Fn()}),wr({type:Sr("eth-wallet"),encryptionSalt:Fn()}),wr({type:Sr("password"),kdfSalt:Fn(),kdfIterations:ir()})]),Hm=wr({access:Gm,encryptedSeed:Fn().regex(/^([0-9a-f]{2})+$/)}),Vm=wr({id:Pm,name:Fn(),createdAt:ir(),derivationKey:Fn().length(64),publicKey:Bm,defaultPostageStampBatchID:Fm.optional(),devices:gr(Mm).default([]),connectedApps:gr(jm).default([]),postageStamps:gr(qm).default([]),settings:wr({appSessionDuration:ir().optional()}).optional(),accountNameAt:ir().optional(),defaultStampAt:ir().optional(),settingsAt:ir().optional(),lastModified:ir().optional(),partitionCount:ir().int().min(1).optional()}),Km=Vm.extend({...Hm.shape,signedOutAt:function(e){return function(e,t){return new e({type:"undefined",...x(t)})}(lr,e)}().optional()}),Wm=Er([Km,wr({id:Pm,name:Fn(),createdAt:ir(),...Hm.shape,encryptedState:Fn().optional(),storageWarning:ur().optional(),soonestDriveExpiry:ir().optional(),signedOutAt:ir()})]),Jm=wr({accountName:Fn(),defaultPostageStampBatchID:Fn().length(64).optional(),publicKey:Bm,settings:wr({appSessionDuration:ir().optional()}).optional(),accountNameAt:ir().optional(),defaultStampAt:ir().optional(),settingsAt:ir().optional(),createdAt:ir(),lastModified:ir(),devices:gr(Mm).default([]),partitionCount:ir().int().min(1).default(1)}),Xm=wr({version:Sr(1),timestamp:ir(),accountId:Fn().length(40),metadata:Jm,connectedApps:gr(jm),postageStamps:gr(qm)});function Ym(e){return void 0!==e.signedOutAt}const Qm=wr({timestampMs:ir().int().nonnegative(),tiebreaker:Fn().regex(/^[0-9a-f]{16}$/)}),eg=wr({holderDeviceId:Fn(),generation:Qm,acquiredAt:ir().int().nonnegative(),leasedUntil:ir().int().nonnegative()}),tg=wr({deviceId:Fn(),generation:Qm,leasedUntil:ir().int().nonnegative().optional()}),ng=wr({beeNodeUrl:Fn().refine(wm,"Must be an http(s) URL"),gnosisRpcUrl:Fn().refine(wm,"Must be an http(s) URL")}),rg=Fn().refine(bm,"Must be an http(s) URL, optionally with a path, and no credentials, query or fragment"),og=wr({index:ir().int().min(0).max(65535),value:ir().int().min(0)}),ig=wr({type:Sr("utilization-updated"),batchId:Fn().length(64),partition:ir().int().min(0),partitionCount:ir().int().min(1),buckets:gr(og)}),sg="swarm-id-accounts",ag="swarm-id-network-settings",cg="swarm-storage-challenge",ug="swarm-id-site-allow-list";function lg(e,t){return`swarm-id-lease-v2:${e.toLowerCase()}:${t.toLowerCase()}`}function fg(e,t){return`swarm-id-app-stamp-usage:${e}:${t.toLowerCase()}`}function dg(e,t){return`swarm-id-soc-restamp-slots:${e}:${t.toLowerCase()}`}function hg(e){return`swarm-id-partition-session:${e}`}const pg=wr({pin:ur().optional(),encrypt:ur().optional(),encryptManifest:ur().optional(),tag:ir().optional(),deferred:ur().optional()}),mg=pg.optional(),gg=Br(["app","identity"]),yg=pg.extend({beeCompatible:ur().optional(),publisher:gg.optional()}).optional(),wg=wr({timeout:ir().optional(),headers:Ir(Fn(),Fn()).optional(),endlesslyRetry:ur().optional()}).optional(),bg=wr({redundancyStrategy:Er([Sr(0),Sr(1),Sr(2),Sr(3)]).optional(),fallback:ur().optional(),timeoutMs:ir().optional(),actPublisher:Er([Gr(Uint8Array),Fn()]).optional(),actHistoryAddress:Er([Gr(Uint8Array),Fn()]).optional(),actTimestamp:Er([ir(),Fn()]).optional()}).optional(),vg=pg.extend({indexDocument:Fn().optional(),errorDocument:Fn().optional()}).optional(),Eg=wr({path:Fn().min(1),data:Gr(Uint8Array),contentType:Fn().optional()}),_g=wr({path:Fn(),reference:km,contentType:Fn().optional()}),xg=wr({reference:km,tagUid:ir().optional()});xg.extend({encryptionKey:Fn().optional(),owner:Im}),xg.extend({encryptionKey:Fn().optional(),owner:Im}),wr({name:Fn(),data:Gr(Uint8Array)});const kg=wr({batchID:Am,utilization:ir(),usable:ur(),label:Fn(),depth:ir(),amount:Fn(),bucketDepth:ir(),blockNumber:ir(),immutableFlag:ur(),exists:ur(),batchTTL:ir().optional()});wr({authenticated:ur(),origin:Fn().optional(),beeApiUrl:Fn().url().optional()});const Ag=Br(["user-stamp","subsidised","unavailable"]),Ig=Br(["no-stamp","stamper-failed","stamp-expired","stamp-not-usable","subsidised","app-stamp-count","app-stamp-rate","app-bucket-share","app-slice-full","session-unconfirmed"]),$g=wr({source:Br(["generated"]),url:Fn()}),Bg=wr({id:Fn(),name:Fn(),address:Im,publicKey:Bm.optional(),sharingPublicKey:Bm.optional(),postageSignerAddress:Im.optional(),avatar:$g});wr({canUpload:ur(),storagePartitioned:ur().optional(),uploadMode:Ag.optional(),uploadUnavailableReason:Ig.optional(),partition:ir().int().min(0).optional(),identity:Bg.optional(),appKey:wr({address:Im,publicKey:Bm}).optional(),chatBinding:Dm.optional(),beeApiUrl:Fn().optional(),postageBatchId:Am.optional()});const zg=wr({name:Fn().min(1).max(100),description:Fn().max(500).optional(),icon:Fn().optional().refine(e=>{if(!e)return!0;if(!e.startsWith("data:image/"))return!1;if(!e.match(/^data:image\/(svg\+xml|png);/))return!1;const t=e.match(/base64,(.+)$/);if(t){if(3*t[1].length/4>4096)return!1}return!0},{message:"Icon must be a data URL with SVG or PNG mime type, max 4KB"})}),Sg=Br(["sign-in","change-stamp"]),Og=["localhost","127.0.0.1","[::1]"];const Tg=wr({family:Fn().min(1),url:Fn().refine(function(e){let t;try{t=new URL(e)}catch{return!1}return!t.username&&!t.password&&("https:"===t.protocol||"http:"===t.protocol&&Og.includes(t.hostname))},{message:"A font file is served over https, or over http on localhost, with no user name or password in its URL"}),weight:Er([Fn(),ir()]).optional(),style:Br(["normal","italic","oblique"]).optional()}),Ng=wr({text:Fn().optional(),busyText:Fn().optional(),ariaLabel:Fn().optional(),disabled:ur().optional(),busy:ur().optional(),backgroundColor:Fn().optional(),color:Fn().optional(),borderRadius:Fn().optional(),borderColor:Fn().optional(),borderWidth:Fn().optional(),borderStyle:Br(["solid","dashed","dotted","double"]).optional(),fontFamily:Fn().optional(),fontSize:Fn().optional(),fontWeight:Er([Fn(),ir()]).optional(),fontFaces:gr(Tg).max(8).optional()}),Rg=Br(["open","closed","blocked"]),Ug=wr({type:Sr("buttonIdentify"),action:Sg,config:Ng.optional(),metadata:zg,popupMode:Br(["popup","window"]).optional()}),Pg=wr({type:Sr("buttonUpdate"),action:Sg,config:Ng.optional()});xr("type",[Ug,Pg]);const Fg=xr("type",[wr({type:Sr("buttonReady")}),wr({type:Sr("buttonInitError"),error:Fn()}),wr({type:Sr("buttonWindowChanged"),state:Rg})]),Cg=wr({type:Sr("connectWindowOpened"),challenge:Fn()}),Lg="buttonFrameLoaded",Mg=wr({type:Sr("parentIdentify"),requestId:Fn(),beeApiUrl:rg.optional(),metadata:zg,subsidisedGatewayUrl:Fn().url().optional()}),Dg=wr({type:Sr("checkAuth"),requestId:Fn()}),Zg=wr({type:Sr("disconnect"),requestId:Fn()}),jg=wr({type:Sr("uploadData"),requestId:Fn(),data:Gr(Uint8Array),options:mg,requestOptions:wg,enableProgress:ur().optional(),useWebSocket:ur().optional(),useWorkers:ur().optional(),workerCount:ir().int().min(1).max(32).optional(),concurrency:ir().int().min(1).max(256).optional()}),qg=wr({type:Sr("downloadData"),requestId:Fn(),reference:km,options:bg,requestOptions:wg}),Gg=wr({type:Sr("deriveAppSecret"),requestId:Fn(),label:Fn()}),Hg=wr({type:Sr("setBeeApiUrl"),requestId:Fn(),beeApiUrl:rg}),Vg=wr({type:Sr("getChatKey"),requestId:Fn()}),Kg=Er([Sr("app"),br({privateKey:$m})]),Wg=xr("kind",[br({kind:Sr("content"),data:Gr(Uint8Array)}),br({kind:Sr("soc"),identifier:Sm,data:Gr(Uint8Array),signer:Kg})]),Jg=br({type:Sr("stampChunk"),requestId:Fn(),chunk:Wg}),Xg=wr({type:Sr("uploadFile"),requestId:Fn(),data:Gr(Uint8Array),name:Fn().optional(),options:mg,requestOptions:wg,enableProgress:ur().optional(),useWebSocket:ur().optional(),useWorkers:ur().optional(),workerCount:ir().int().min(1).max(32).optional(),concurrency:ir().int().min(1).max(256).optional()}),Yg=wr({type:Sr("downloadFile"),requestId:Fn(),reference:km,path:Fn().optional(),options:bg,requestOptions:wg}),Qg=wr({type:Sr("uploadFiles"),requestId:Fn(),files:gr(Eg),options:vg,requestOptions:wg,enableProgress:ur().optional(),useWorkers:ur().optional(),workerCount:ir().int().min(1).max(32).optional()}),ey=wr({type:Sr("listFiles"),requestId:Fn(),reference:km,requestOptions:wg}),ty=wr({type:Sr("uploadChunk"),requestId:Fn(),data:Gr(Uint8Array),options:mg,requestOptions:wg}),ny=wr({type:Sr("downloadChunk"),requestId:Fn(),reference:km,options:bg,requestOptions:wg}),ry=wr({type:Sr("isConnected"),requestId:Fn()}),oy=wr({type:Sr("getNodeInfo"),requestId:Fn()}),iy=wr({type:Sr("gsocMine"),requestId:Fn(),targetOverlay:Fn(),identifier:Fn(),proximity:ir().optional()}),sy=wr({type:Sr("gsocSend"),requestId:Fn(),signer:Fn(),identifier:Fn(),data:Gr(Uint8Array),options:mg,requestOptions:wg}),ay=wr({type:Sr("socUpload"),requestId:Fn(),identifier:Sm,data:Gr(Uint8Array),signer:$m.optional(),options:mg,requestOptions:wg}),cy=wr({type:Sr("socRawUpload"),requestId:Fn(),identifier:Sm,data:Gr(Uint8Array),signer:$m.optional(),options:mg,requestOptions:wg}),uy=wr({type:Sr("socDownload"),requestId:Fn(),owner:Im.optional(),identifier:Sm,encryptionKey:zm,requestOptions:wg}),ly=wr({type:Sr("socRawDownload"),requestId:Fn(),owner:Im.optional(),identifier:Sm,encryptionKey:zm.optional(),requestOptions:wg}),fy=wr({type:Sr("socGetOwner"),requestId:Fn()}),dy=wr({type:Sr("epochFeedDownloadReference"),requestId:Fn(),topic:Sm,owner:Im.optional(),at:Rm,after:Rm.optional(),encryptionKey:zm.optional(),requestOptions:wg}),hy=wr({lastEpoch:wr({start:Fn(),level:ir()}).optional(),lastTimestamp:Fn().optional()}).optional(),py=xr("type",[Mg,Dg,Zg,jg,qg,Gg,Vg,Hg,Jg,Xg,Yg,Qg,ey,ty,ny,ry,oy,iy,sy,ay,cy,uy,ly,fy,dy,wr({type:Sr("epochFeedUploadReference"),requestId:Fn(),topic:Sm,signer:$m.optional(),at:Rm,reference:km,encryptionKey:zm.optional(),hints:hy,requestOptions:wg}),wr({type:Sr("feedGetOwner"),requestId:Fn()}),wr({type:Sr("seqFeedGetOwner"),requestId:Fn()}),wr({type:Sr("seqFeedDownloadPayload"),requestId:Fn(),topic:Sm,owner:Im.optional(),index:Um.optional(),at:Rm.optional(),hasTimestamp:ur().optional(),lookupTimeoutMs:ir().optional(),encryptionKey:zm,requestOptions:wg}),wr({type:Sr("seqFeedDownloadRawPayload"),requestId:Fn(),topic:Sm,owner:Im.optional(),index:Um.optional(),at:Rm.optional(),hasTimestamp:ur().optional(),lookupTimeoutMs:ir().optional(),encryptionKey:zm.optional(),requestOptions:wg}),wr({type:Sr("seqFeedDownloadReference"),requestId:Fn(),topic:Sm,owner:Im.optional(),index:Um.optional(),at:Rm.optional(),hasTimestamp:ur().optional(),lookupTimeoutMs:ir().optional(),encryptionKey:zm,requestOptions:wg}),wr({type:Sr("seqFeedUploadPayload"),requestId:Fn(),topic:Sm,signer:$m.optional(),data:Gr(Uint8Array),index:Um.optional(),at:Rm.optional(),hasTimestamp:ur().optional(),lookupTimeoutMs:ir().optional(),options:mg,requestOptions:wg}),wr({type:Sr("seqFeedUploadRawPayload"),requestId:Fn(),topic:Sm,signer:$m.optional(),data:Gr(Uint8Array),index:Um.optional(),at:Rm.optional(),hasTimestamp:ur().optional(),lookupTimeoutMs:ir().optional(),encryptionKey:zm.optional(),options:mg,requestOptions:wg}),wr({type:Sr("seqFeedUploadReference"),requestId:Fn(),topic:Sm,signer:$m.optional(),reference:km,index:Um.optional(),at:Rm.optional(),hasTimestamp:ur().optional(),lookupTimeoutMs:ir().optional(),options:mg,requestOptions:wg}),wr({type:Sr("createFeedManifest"),requestId:Fn(),topic:Sm,owner:Im.optional(),feedType:Br(["Sequence","Epoch"]).optional(),uploadOptions:mg,requestOptions:wg}),wr({type:Sr("actUploadData"),requestId:Fn(),data:Gr(Uint8Array),grantees:gr(Fn()),options:yg,requestOptions:wg,enableProgress:ur().optional()}),wr({type:Sr("actDownloadData"),requestId:Fn(),encryptedReference:km,historyReference:km,publisherPubKey:Fn(),timestamp:ir().optional(),requestOptions:wg}),wr({type:Sr("actAddGrantees"),requestId:Fn(),historyReference:km,grantees:gr(Fn()),requestOptions:wg}),wr({type:Sr("actRevokeGrantees"),requestId:Fn(),historyReference:km,encryptedReference:km,revokeGrantees:gr(Fn()),requestOptions:wg}),wr({type:Sr("actGetGrantees"),requestId:Fn(),historyReference:km,requestOptions:wg}),wr({type:Sr("getPostageBatch"),requestId:Fn()})]),my=wr({type:Sr("proxyReady"),authenticated:ur(),parentOrigin:Fn(),storageShared:ur().optional()}),gy=wr({type:Sr("initError"),error:Fn()}),yy=wr({type:Sr("authStatusResponse"),requestId:Fn(),authenticated:ur(),origin:Fn().optional(),beeApiUrl:Fn().url().optional()}),wy=wr({type:Sr("disconnectResponse"),requestId:Fn(),success:ur()}),by=wr({type:Sr("authSuccess"),origin:Fn()}),vy=wr({type:Sr("uploadDataResponse"),requestId:Fn(),reference:km,tagUid:ir().optional()}),Ey=wr({type:Sr("downloadDataResponse"),requestId:Fn(),data:Gr(Uint8Array)}),_y=wr({type:Sr("deriveAppSecretResponse"),requestId:Fn(),secret:Gr(Uint8Array)}),xy=wr({type:Sr("getChatKeyResponse"),requestId:Fn(),chatKey:Gr(Uint8Array)}),ky=wr({type:Sr("setBeeApiUrlResponse"),requestId:Fn(),beeApiUrl:Fn()}),Ay=wr({type:Sr("stampChunkResponse"),requestId:Fn(),address:Tm,stamp:Nm,owner:Im.optional(),signature:Om.optional()}),Iy=wr({type:Sr("uploadFileResponse"),requestId:Fn(),reference:km,tagUid:ir().optional()}),$y=wr({type:Sr("downloadFileResponse"),requestId:Fn(),name:Fn(),data:Gr(Uint8Array)}),By=wr({type:Sr("uploadFilesResponse"),requestId:Fn(),reference:km,tagUid:ir().optional()}),zy=wr({type:Sr("listFilesResponse"),requestId:Fn(),entries:gr(_g)}),Sy=wr({type:Sr("uploadChunkResponse"),requestId:Fn(),reference:km}),Oy=wr({type:Sr("downloadChunkResponse"),requestId:Fn(),data:Gr(Uint8Array)}),Ty=wr({type:Sr("uploadProgress"),requestId:Fn(),total:ir(),processed:ir()}),Ny=Br(["not-authenticated","upload-unavailable","partition-contended","lease-lost","bee-rejected","network","timeout","invalid-request","invalid-state","init-failed","popup-blocked","button-required","internal"]),Ry=xr("type",[my,gy,yy,wy,by,vy,Ey,_y,xy,ky,Ay,Iy,$y,By,zy,Sy,Oy,Ty,wr({error:Fn(),code:Ny.catch("internal"),reason:Ig.optional().catch(void 0),status:ir().int().optional(),beeMessage:Fn().optional(),url:Fn().optional()}).extend({type:Sr("error"),requestId:Fn()}),wr({type:Sr("connectionInfoChanged"),canUpload:ur(),storagePartitioned:ur().optional(),uploadMode:Ag.optional(),uploadUnavailableReason:Ig.optional().catch(void 0),identity:Bg.optional(),appKey:wr({address:Im,publicKey:Bm}).optional(),partition:ir().int().min(0).optional(),chatBinding:Dm.optional(),beeApiUrl:Fn().optional(),postageBatchId:Am.optional()}),wr({type:Sr("isConnectedResponse"),requestId:Fn(),connected:ur()}),wr({type:Sr("getNodeInfoResponse"),requestId:Fn(),beeMode:Fn(),chequebookEnabled:ur(),swapEnabled:ur()}),wr({type:Sr("gsocMineResponse"),requestId:Fn(),signer:Fn()}),wr({type:Sr("gsocSendResponse"),requestId:Fn(),reference:km,tagUid:ir().optional()}),wr({type:Sr("socUploadResponse"),requestId:Fn(),reference:km,tagUid:ir().optional(),encryptionKey:Fn().optional(),owner:Im}),wr({type:Sr("socRawUploadResponse"),requestId:Fn(),reference:km,tagUid:ir().optional(),encryptionKey:Fn().optional(),owner:Im}),wr({type:Sr("socDownloadResponse"),requestId:Fn(),data:Gr(Uint8Array),identifier:Sm,signature:Om,span:ir(),payload:Gr(Uint8Array),address:km,owner:Im}),wr({type:Sr("socRawDownloadResponse"),requestId:Fn(),data:Gr(Uint8Array),identifier:Sm,signature:Om,span:ir(),payload:Gr(Uint8Array),address:km,owner:Im}),wr({type:Sr("socGetOwnerResponse"),requestId:Fn(),owner:Im}),wr({type:Sr("epochFeedDownloadReferenceResponse"),requestId:Fn(),reference:km.optional()}),wr({type:Sr("epochFeedUploadReferenceResponse"),requestId:Fn(),socAddress:km,encryptionKey:zm.optional(),epoch:wr({start:Fn(),level:ir()}),timestamp:Fn()}),wr({type:Sr("feedGetOwnerResponse"),requestId:Fn(),owner:Im}),wr({type:Sr("seqFeedGetOwnerResponse"),requestId:Fn(),owner:Im}),wr({type:Sr("seqFeedDownloadPayloadResponse"),requestId:Fn(),payload:Gr(Uint8Array),timestamp:ir().optional(),feedIndex:Fn(),feedIndexNext:Fn()}),wr({type:Sr("seqFeedDownloadRawPayloadResponse"),requestId:Fn(),payload:Gr(Uint8Array),timestamp:ir().optional(),feedIndex:Fn(),feedIndexNext:Fn()}),wr({type:Sr("seqFeedDownloadReferenceResponse"),requestId:Fn(),reference:km,feedIndex:Fn(),feedIndexNext:Fn()}),wr({type:Sr("seqFeedUploadPayloadResponse"),requestId:Fn(),reference:km,feedIndex:Fn(),owner:Im,encryptionKey:Fn().optional(),tagUid:ir().optional()}),wr({type:Sr("seqFeedUploadRawPayloadResponse"),requestId:Fn(),reference:km,feedIndex:Fn(),owner:Im,encryptionKey:Fn().optional(),tagUid:ir().optional()}),wr({type:Sr("seqFeedUploadReferenceResponse"),requestId:Fn(),reference:km,feedIndex:Fn(),owner:Im,encryptionKey:Fn().optional(),tagUid:ir().optional()}),wr({type:Sr("createFeedManifestResponse"),requestId:Fn(),reference:km}),wr({type:Sr("actUploadDataResponse"),requestId:Fn(),encryptedReference:km,historyReference:km,granteeListReference:km,publisherPubKey:Fn(),actReference:km,tagUid:ir().optional()}),wr({type:Sr("actDownloadDataResponse"),requestId:Fn(),data:Gr(Uint8Array)}),wr({type:Sr("actAddGranteesResponse"),requestId:Fn(),historyReference:km,granteeListReference:km,actReference:km}),wr({type:Sr("actRevokeGranteesResponse"),requestId:Fn(),encryptedReference:km,historyReference:km,granteeListReference:km,actReference:km}),wr({type:Sr("actGetGranteesResponse"),requestId:Fn(),grantees:gr(Fn())}),wr({type:Sr("getPostageBatchResponse"),requestId:Fn(),postageBatch:kg.optional()})]),Uy=wr({secret:Fn(),networkSettings:ng.optional(),account:Vm,chatBinding:Dm.optional(),stampPending:Sr(!0).optional()}),Py=wr({version:Sr(1),parentOrigin:Fn(),connectedUntil:ir(),data:Fn()}),Fy=xr("type",[wr({type:Sr("setSecret"),appOrigin:Fn(),challenge:Fn(),data:Uy})]),Cy="#FCFCFC",Ly="#131416",My=[["#FFE0CC","#DD7200","#401F00"],["#99CCFF","#0082FB","#003366"],["#99E6B3","#00C853","#004D1F"],["#E1BEE7","#9C27B0","#4A148C"]],Dy=[];for(const e of My)Dy.push([e[1],Cy]),Dy.push([e[1],Ly]),Dy.push([Cy,e[1]]),Dy.push([Ly,e[1]]);for(const e of My)Dy.push([e[0],e[1]]),Dy.push([e[2],e[1]]),Dy.push([e[1],e[0]]),Dy.push([e[1],e[2]]),Dy.push([e[0],e[2]]),Dy.push([e[2],e[0]]);for(let e=0;e<My.length;e++){const t=My[(e+1)%My.length];Dy.push([My[e][0],t[2]]),Dy.push([t[2],My[e][0]])}const Zy=[[0,1],[1,0],[0,-1],[-1,0]];function jy(e,t=40){const n=function(e){let t=0;for(let n=0;n<e.length;n++)t=e.charCodeAt(n)+(t<<6)+(t<<16)-t;return t}(e.length<6?e.padEnd(6," "):e),[r,o]=Dy[Math.abs(n)%Dy.length],i=.25*t,s=(t-2*i)/2,a=Array.from({length:2},()=>Array(2).fill(!1)),c=Math.floor(1),u=[[c,c]];a[c][c]=!0;let l="";for(let e=u.pop();void 0!==e;e=u.pop()){const[t,r]=e,o=15&Math.abs(n>>3*t+5*r),c=[];for(const[e,n]of Zy){const o=t+e,i=r+n;o>=0&&o<2&&i>=0&&i<2&&!a[o][i]&&c.push([o,i])}for(;c.length>0;){const e=Math.abs(o+c.length)%c.length,[t,n]=c.splice(e,1)[0];u.push([t,n]),a[t][n]=!0}const f=o%4*90,d=i+t*s,h=i+r*s;l+=o%5==0?`M${d},${h} h${s} v${s} h-${s}z `:0===f?`M${d},${h} h${s} v${s}z `:90===f?`M${d+s},${h} v${s} h-${s}z `:180===f?`M${d+s},${h+s} h-${s} v-${s}z `:`M${d},${h+s} v-${s} h${s}z `}return`<svg xmlns="http://www.w3.org/2000/svg" width="${t}" height="${t}" viewBox="0 0 ${t} ${t}"><rect width="${t}" height="${t}" fill="${r}"/><path d="${l}" fill="${o}"/></svg>`}function qy(e,t=40){const n=jy(e,t);return{source:"generated",url:`data:image/svg+xml;charset=utf-8,${encodeURIComponent(n)}`}}function Gy(e){const t=e.replace(/^0x/i,"");if(t.length%2!=0||!/^[0-9a-fA-F]*$/.test(t))throw new Error("Invalid hex string.");const n=new Uint8Array(t.length/2);for(let e=0;e<t.length;e+=2)n[e/2]=parseInt(t.substring(e,e+2),16);return n}function Hy(e){return Array.from(e).map(e=>e.toString(16).padStart(2,"0")).join("")}function Vy(e){const t=e.replace(/^0x/i,"").toLowerCase();if(!/^[0-9a-f]{40}$/.test(t))throw new Error(`Invalid hex address: expected 40 hex characters (with optional 0x prefix), got "${e}"`);return t}class Ky extends Error{constructor(e){super(e),this.name="TimeoutError"}}function Wy(e,t,n){let r;const o=new Promise((e,o)=>{r=setTimeout(()=>o(new Ky(n)),t)});return Promise.race([e,o]).finally(()=>clearTimeout(r))}function Jy(e){return new Promise(t=>setTimeout(t,e))}function Xy(e,t,n){let r,o=!1,i=()=>{};const s=new Promise((e,s)=>{i=()=>{o||(clearTimeout(r),r=setTimeout(()=>s(new Ky(n)),t))},i()}),a=(async()=>e(i))();return Promise.race([a,s]).finally(()=>{o=!0,clearTimeout(r)})}const Yy=0,Qy=4096,ew=8,tw=32,nw=8;class rw{constructor(e,t,n){this.encryptionKey=e,this.keyLen=e.length,this.padding=t,this.initCtr=n,this.index=0}key(){return this.encryptionKey}encrypt(e){const t=e.length;let n=t;if(this.padding>0){if(t>this.padding)throw new Error(`data length ${t} longer than padding ${this.padding}`);n=this.padding}const r=new Uint8Array(n);return this.transform(e,r),r}decrypt(e){const t=e.length;if(this.padding>0&&t!==this.padding)throw new Error(`data length ${t} different than padding ${this.padding}`);const n=new Uint8Array(t);return this.transform(e,n),n}reset(){this.index=0}transform(e,t){const n=e.length;for(let r=0;r<n;r+=this.keyLen){const o=Math.min(this.keyLen,n-r);this.transcrypt(this.index,e.subarray(r,r+o),t.subarray(r,r+o)),this.index++}ow(t.subarray(n))}transcrypt(e,t,n){const r=new Uint8Array(4);new DataView(r.buffer).setUint32(0,e+this.initCtr,!0);const o=new Uint8Array(this.encryptionKey.length+4);o.set(this.encryptionKey),o.set(r,this.encryptionKey.length);const i=Jr.Binary.keccak256(o),s=Jr.Binary.keccak256(i),a=t.length;for(let e=0;e<a;e++)n[e]=t[e]^s[e];ow(n.subarray(a))}}function ow(e){0!==e.length&&crypto.getRandomValues(e)}function iw(e=32){const t=new Uint8Array(e);return ow(t),t}function sw(e){return new rw(e,0,Math.floor(128))}function aw(e){return new rw(e,4096,0)}class cw{encryptChunk(e,t){const n=t||iw(32);return{key:n,encryptedSpan:sw(n).encrypt(e.subarray(0,8)),encryptedData:aw(n).encrypt(e.subarray(8))}}}function uw(){return new cw}function lw(e,t){const n=sw(e).decrypt(t.subarray(0,8)),r=aw(e).decrypt(t.subarray(8)),o=new Uint8Array(8+r.length);return o.set(n),o.set(r,8),o}const fw=4096;function dw(e){const t=e.slice(0,Ks.LENGTH),n=function(e){if(e.length>fw)throw new Error(`payload size ${e.length} exceeds maximum chunk payload size 4096`);const t=new Uint8Array(fw);t.set(e);let n=Jr.Binary.partition(t,32);for(;n.length>1;){const e=[];for(let t=0;t<n.length;t+=2){const r=n[t],o=n[t+1],i=Jr.Binary.concatBytes(r,o),s=Jr.Binary.keccak256(i);e.push(s)}n=e}return n[0]}(e.slice(Ks.LENGTH)),r=Jr.Binary.keccak256(Jr.Binary.concatBytes(t,n));return new Vs(r)}const hw=new TextEncoder;function pw(e,t){if(e instanceof Uint8Array||(e=hw.encode(e)),e.length<0||e.length>Qy)throw new RangeError(`payload size ${e.length} exceeds limits [0, 4096]`);let n;n=t instanceof Ks?t:"bigint"==typeof t?Ks.fromBigInt(t):Ks.fromBigInt(BigInt(e.length));const r=Jr.Binary.concatBytes(n.toUint8Array(),e),o=dw(r);return{data:r,span:n,payload:new Bs(e),address:o}}const mw=new TextEncoder;function gw(e,t){if(e instanceof Uint8Array||(e=mw.encode(e)),e.length<0||e.length>Qy)throw new RangeError(`payload size ${e.length} exceeds limits [0, 4096]`);const n=Ks.fromBigInt(BigInt(e.length)),r=Jr.Binary.concatBytes(n.toUint8Array(),e),o=uw(),{key:i,encryptedSpan:s,encryptedData:a}=o.encryptChunk(r,t),c=Jr.Binary.concatBytes(s,a),u=dw(c),l=new Vs(Jr.Binary.concatBytes(u.toUint8Array(),i));return{data:c,encryptionKey:i,span:n,payload:new Bs(c.slice(Ks.LENGTH)),address:u,reference:l}}function yw(e){const t=new DataView(e.buffer,e.byteOffset,e.byteLength);return Number(t.getBigUint64(0,!0))}function ww(e,t){return new Vs(Jr.Binary.keccak256(Jr.Binary.concatBytes(e.toUint8Array(),t.toUint8Array())))}function bw(e,t,n,r){const o=new Fs(e.slice(0,32)),i=Gs.fromSlice(e,32),s=e.slice(97),a=dw(s),c=Jr.Binary.concatBytes(o.toUint8Array(),a.toUint8Array()),u=i.recoverPublicKey(c).address();if(!u.equals(n))throw new Error("SOC owner mismatch");const l=ww(o,u);if(!Jr.Binary.equals(t.toUint8Array(),l.toUint8Array()))throw new Error("SOC data does not match given address");let f,d,h;if(r){const e=lw(r,s);f=e.slice(0,8);const t=yw(f);d=e.slice(8,8+t),h=Jr.Binary.concatBytes(o.toUint8Array(),i.toUint8Array(),f,d)}else{f=e.slice(97,105);const t=yw(f);if(t>4096)throw new Error("SOC payload length is invalid; this chunk likely requires decryption");d=e.slice(105,105+t),h=e}const p=yw(f);return{data:h,identifier:o.toHex(),signature:i.toHex(),span:p,payload:d,address:t.toHex(),owner:u.toHex()}}function vw(e,t,n){const r=[],o=n?64:tw,i=Math.floor(e.length/o),s=Math.ceil(t/Qy),a=Math.min(i,s);for(let t=0;t<a;t++){const i=t*o;if(i+o>e.length)break;const s=e.slice(i,i+tw);if(s.every(e=>0===e))break;if(n){const t=e.slice(i+tw,i+64);r.push({address:s,encryptionKey:t})}else r.push({address:s})}return r}async function Ew(e,t,n){const r=Jr.Binary.uint8ArrayToHex(t.address);let o,i;try{o=await e.chunk.download(r,void 0,n)}catch(n){throw console.error(`[DownloadData] chunk fetch failed addr=${r} encrypted=${void 0!==t.encryptionKey} bee.url=${e.url}:`,n),n}i=t.encryptionKey?lw(t.encryptionKey,o):o;return{span:yw(i.slice(0,8)),payload:i.slice(8)}}async function _w(e,t,n,r,o,i){const{span:s,payload:a}=await Ew(e,t,i);if(o(),s<=Qy)return a.slice(0,s);const c=vw(a,s,n);if(0===c.length)throw new Error("No valid references found in intermediate chunk");const u=new Array(c.length);for(let t=0;t<c.length;t+=r){const s=c.slice(t,Math.min(t+r,c.length)),a=await Promise.all(s.map(t=>_w(e,t,n,r,o,i)));for(let e=0;e<a.length;e++)u[t+e]=a[e]}const l=u.reduce((e,t)=>e+t.length,0),f=new Uint8Array(l);let d=0;for(const e of u)f.set(e,d),d+=e.length;return f}async function xw(e,t,n,r,o){const i=function(e){const t=Gy(e);if(t.length===tw)return{address:t};if(64===t.length)return{address:t.slice(0,tw),encryptionKey:t.slice(tw)};throw new Error(`Invalid reference length: ${t.length}, expected 32 or 64`)}(t),s=void 0!==i.encryptionKey;console.log(`[DownloadData] start addr=${Jr.Binary.uint8ArrayToHex(i.address)} encrypted=${s} bee.url=${e.url}`);const{span:a,payload:c}=await Ew(e,i,o);if(a<=Qy)return c.slice(0,a);const u=()=>{},l=vw(c,a,s);if(0===l.length)throw new Error("No valid references found in root chunk");const f=new Array(l.length);for(let t=0;t<l.length;t+=64){const n=l.slice(t,Math.min(t+64,l.length)),r=await Promise.all(n.map(t=>_w(e,t,s,64,u,o)));for(let e=0;e<r.length;e++)f[t+e]=r[e]}const d=f.reduce((e,t)=>e+t.length,0),h=new Uint8Array(d);let p=0;for(const e of f)h.set(e,p),p+=e.length;return h}async function kw(e,t,n,r){const o=new Ns(t),i=ww(new Fs(n),o);return bw(await e.chunk.download(i.toHex(),void 0,r),i,o)}async function Aw(e,t,n,r,o){const i=new Ns(t),s=ww(new Fs(n),i),a="string"==typeof r?Gy(r):r;return bw(await e.chunk.download(s.toHex(),void 0,o),s,i,a)}async function Iw(e,t){const n=await async function e(n,r){for(const t of n.forks.values())await e(t.node,!1);const o=await n.marshal(),i=await t(o,r);return n.selfAddress=Gy(i.reference),i}(e,!0);return{rootReference:n.reference,tagUid:n.tagUid}}async function $w(e,t,n){const r=!0===n?.encrypt;const o=await async function e(n,o){for(const t of n.forks.values())await e(t.node,!1);const i=await n.marshal();if(r){const e=gw(i),r=await t(e.data,o),s=new Uint8Array(64);return s.set(e.address.toUint8Array(),0),s.set(e.encryptionKey,32),n.selfAddress=s,r}{const e=pw(i),r=await t(e.data,o);return n.selfAddress=e.address.toUint8Array(),r}}(e,!0);return{rootReference:Hy(e.selfAddress),tagUid:o.tagUid}}const Bw=["invalid version hash","data too short"];async function zw(e,t,n){const r=function(e,t){try{return _a.unmarshalFromData(e,Gy(t))}catch(e){if(e instanceof Error&&Bw.some(t=>e.message.endsWith(t)))throw new Error("No manifest at this reference; a reference from uploadData needs downloadData.",{cause:e});throw e}}(await xw(e,t,0,0,n),t);return await async function t(r){for(const o of r.forks.values()){if(!o.node.selfAddress)throw new Error("Fork node selfAddress is not set");const i=Hy(o.node.selfAddress),s=await xw(e,i,0,0,n),a=_a.unmarshalFromData(s,o.node.selfAddress);o.node.targetAddress=a.targetAddress,o.node.forks=a.forks,o.node.obfuscationKey=a.obfuscationKey,o.node.path=o.prefix,o.node.parent=r;for(const e of o.node.forks.values())e.node.parent=o.node;await t(o.node)}}(r),r}const Sw=5,Ow=86400n/BigInt(5),Tw=86400,Nw=30n*BigInt(Tw);async function Rw(){const e=await fetch("https://api.swarmscan.io/v1/postage-stamps/stats");if(!e.ok)throw new Error(`Failed to fetch Swarmscan stats: ${e.status}`);return(await e.json()).pricePerGBPerMonth}function Uw(e,t){if(!Number.isFinite(t)||t<=0)return 0;const n=BigInt(e);if(n<=0n)return 0;const r=function(e){const t=e.toFixed(16),n=t.startsWith("-"),r=n?t.slice(1):t,[o,i=""]=r.split("."),s=i.padEnd(16,"0").slice(0,16),a=BigInt(o+s);return n?-a:a}(t)/262144n;return r<=0n?0:Number(n*Nw/r)}function Pw(e){if(void 0===e||e<=0)return"N/A";return`${Math.floor(e/Tw)}d ${Math.floor(e%Tw/3600)}h`}function Fw(e,t){return e<=0n||!Number.isInteger(t)||t<=0?0n:e*Ow*BigInt(t)}async function Cw(e,t){try{const n=e.replace(/\/$/,""),r=await fetch(`${n}/stamps/${t}`);if(!r.ok)return;const o=await r.json();if("object"!=typeof o||null===o)return;const{batchTTL:i,usable:s,exists:a}=o;return{batchTTL:"number"==typeof i?i<0?0:i:void 0,usable:"boolean"==typeof s?s:void 0,exists:"boolean"==typeof a?a:void 0}}catch{return}}async function Lw(e,t){const n=await Cw(e,t);return n?.batchTTL}const Mw=1e4;function Dw(e){try{return new URL(e).origin}catch{return"The RPC endpoint"}}function Zw(e){return"object"==typeof e&&null!==e}function jw(e,t,n){if(e.error)throw new Error(`${n} refused ${t}: ${e.error.message??"unknown error"}`);if(!("result"in e))throw new Error(`${n} returned a malformed envelope for ${t}.`);return e.result??void 0}function qw(e,t,n){if(void 0===e)throw new Error(`${n} returned no result for ${t}.`);return e}async function Gw(e,t,n,r){const o=r.label??Dw(e),i=new AbortController,s=setTimeout(()=>i.abort(),r.timeoutMs),a=e=>i.signal.aborted?new Ky(`${o} did not answer ${n} within ${r.timeoutMs}ms.`):new Error(e);try{let r;try{r=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t),signal:i.signal})}catch(e){throw a(`${o} could not be reached for ${n}: ${c=e,c instanceof Error?c.message:String(c)}`)}!function(e,t,n){if(!e.ok)throw new Error(`${n} answered ${e.status} to ${t}.`)}(r,n,o);try{return await r.json()}catch{throw a(`${o} answered ${n} with a body that is not JSON.`)}}finally{clearTimeout(s)}var c}async function Hw(e,t,n,r){const o=r.label??Dw(e);return qw(jw(await Gw(e,{jsonrpc:"2.0",id:1,method:t,params:n},t,r),t,o),t,o)}async function Vw(e,t,n){if(0===t.length)return[];const r=n.label??Dw(e),o=`a batch of ${t.length} calls`,i=t.map((e,t)=>({jsonrpc:"2.0",id:t,method:e.method,params:e.params})),s=()=>new Error(`${r} returned a malformed response to ${o}.`),a=await Gw(e,i,o,n);if(!Array.isArray(a))throw Zw(a)&&a.error&&jw(a,o,r),s();if(a.length!==t.length)throw s();const c=new Array(t.length),u=new Set;for(const e of a){if(!Zw(e))throw s();const{id:n}=e;if("number"!=typeof n||n<0||n>=t.length)throw new Error(`${r} returned a response with an unknown id.`);if(u.has(n))throw new Error(`${r} returned two responses for id ${n}.`);u.add(n);const o=t[n].method;c[n]=qw(jw(e,o,r),o,r)}return c}function Kw(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`Wrong positive integer: ${e}`)}function Ww(e,...t){if(!(e instanceof Uint8Array))throw new Error("Expected Uint8Array");if(t.length>0&&!t.includes(e.length))throw new Error(`Expected Uint8Array of length ${t}, not of length=${e.length}`)}function Jw(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 Xw(e,t){Ww(e);const n=t.outputLen;if(e.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}const Yw="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0,Qw=e=>e instanceof Uint8Array,eb=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),tb=(e,t)=>e<<32-t|e>>>t;
13
- /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */if(!(68===new Uint8Array(new Uint32Array([287454020]).buffer)[0]))throw new Error("Non little-endian hardware is not supported");function nb(e){if("string"==typeof e&&(e=function(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}(e)),!Qw(e))throw new Error("expected Uint8Array, got "+typeof e);return e}class rb{clone(){return this._cloneInto()}}function ob(e){const t=t=>e().update(nb(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function ib(e=32){if(Yw&&"function"==typeof Yw.getRandomValues)return Yw.getRandomValues(new Uint8Array(e));throw new Error("crypto.getRandomValues must be defined")}class sb extends rb{constructor(e,t,n,r){super(),this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=eb(this.buffer)}update(e){Jw(this);const{view:t,buffer:n,blockLen:r}=this,o=(e=nb(e)).length;for(let i=0;i<o;){const s=Math.min(r-this.pos,o-i);if(s===r){const t=eb(e);for(;r<=o-i;i+=r)this.process(t,i);continue}n.set(e.subarray(i,i+s),this.pos),this.pos+=s,i+=s,this.pos===r&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Jw(this),Xw(e,this),this.finished=!0;const{buffer:t,view:n,blockLen:r,isLE:o}=this;let{pos:i}=this;t[i++]=128,this.buffer.subarray(i).fill(0),this.padOffset>r-i&&(this.process(n,0),i=0);for(let e=i;e<r;e++)t[e]=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=eb(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=a/4,u=this.get();if(c>u.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e<c;e++)s.setUint32(4*e,u[e],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.length=r,e.pos=s,e.finished=o,e.destroyed=i,r%t&&e.buffer.set(n),e}}const ab=(e,t,n)=>e&t^~e&n,cb=(e,t,n)=>e&t^e&n^t&n,ub=new Uint32Array([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]),lb=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),fb=new Uint32Array(64);class db extends sb{constructor(){super(64,32,8,!1),this.A=0|lb[0],this.B=0|lb[1],this.C=0|lb[2],this.D=0|lb[3],this.E=0|lb[4],this.F=0|lb[5],this.G=0|lb[6],this.H=0|lb[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 n=0;n<16;n++,t+=4)fb[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=fb[e-15],n=fb[e-2],r=tb(t,7)^tb(t,18)^t>>>3,o=tb(n,17)^tb(n,19)^n>>>10;fb[e]=o+fb[e-7]+r+fb[e-16]|0}let{A:n,B:r,C:o,D:i,E:s,F:a,G:c,H:u}=this;for(let e=0;e<64;e++){const t=u+(tb(s,6)^tb(s,11)^tb(s,25))+ab(s,a,c)+ub[e]+fb[e]|0,l=(tb(n,2)^tb(n,13)^tb(n,22))+cb(n,r,o)|0;u=c,c=a,a=s,s=i+t|0,i=o,o=r,r=n,n=t+l|0}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(){fb.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const hb=ob(()=>new db),pb=BigInt(0),mb=BigInt(1),gb=BigInt(2),yb=e=>e instanceof Uint8Array,wb=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));
14
- /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function bb(e){if(!yb(e))throw new Error("Uint8Array expected");let t="";for(let n=0;n<e.length;n++)t+=wb[e[n]];return t}function vb(e){const t=e.toString(16);return 1&t.length?`0${t}`:t}function Eb(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);return BigInt(""===e?"0":`0x${e}`)}function _b(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);const t=e.length;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);const n=new Uint8Array(t/2);for(let t=0;t<n.length;t++){const r=2*t,o=e.slice(r,r+2),i=Number.parseInt(o,16);if(Number.isNaN(i)||i<0)throw new Error("Invalid byte sequence");n[t]=i}return n}function xb(e){return Eb(bb(e))}function kb(e){if(!yb(e))throw new Error("Uint8Array expected");return Eb(bb(Uint8Array.from(e).reverse()))}function Ab(e,t){return _b(e.toString(16).padStart(2*t,"0"))}function Ib(e,t){return Ab(e,t).reverse()}function $b(e,t,n){let r;if("string"==typeof t)try{r=_b(t)}catch(n){throw new Error(`${e} must be valid hex string, got "${t}". Cause: ${n}`)}else{if(!yb(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} expected ${n} bytes, got ${o}`);return r}function Bb(...e){const t=new Uint8Array(e.reduce((e,t)=>e+t.length,0));let n=0;return e.forEach(e=>{if(!yb(e))throw new Error("Uint8Array expected");t.set(e,n),n+=e.length}),t}const zb=e=>(gb<<BigInt(e-1))-mb,Sb=e=>new Uint8Array(e),Ob=e=>Uint8Array.from(e);function Tb(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");let r=Sb(e),o=Sb(e),i=0;const s=()=>{r.fill(1),o.fill(0),i=0},a=(...e)=>n(o,r,...e),c=(e=Sb())=>{o=a(Ob([0]),e),r=a(),0!==e.length&&(o=a(Ob([1]),e),r=a())},u=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let e=0;const n=[];for(;e<t;){r=a();const t=r.slice();n.push(t),e+=r.length}return Bb(...n)};return(e,t)=>{let n;for(s(),c(e);!(n=t(u()));)c();return s(),n}}const Nb={bigint:e=>"bigint"==typeof e,function:e=>"function"==typeof e,boolean:e=>"boolean"==typeof e,string:e=>"string"==typeof e,stringOrUint8Array:e=>"string"==typeof e||e instanceof Uint8Array,isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>"function"==typeof e&&Number.isSafeInteger(e.outputLen)};function Rb(e,t,n={}){const r=(t,n,r)=>{const o=Nb[n];if("function"!=typeof o)throw new Error(`Invalid validator "${n}", expected function`);const i=e[t];if(!(r&&void 0===i||o(i,e)))throw new Error(`Invalid param ${String(t)}=${i} (${typeof i}), expected ${n}`)};for(const[e,n]of Object.entries(t))r(e,n,!1);for(const[e,t]of Object.entries(n))r(e,t,!0);return e}var Ub=Object.freeze({__proto__:null,bitGet:function(e,t){return e>>BigInt(t)&mb},bitLen:function(e){let t;for(t=0;e>pb;e>>=mb,t+=1);return t},bitMask:zb,bitSet:(e,t,n)=>e|(n?mb:pb)<<BigInt(t),bytesToHex:bb,bytesToNumberBE:xb,bytesToNumberLE:kb,concatBytes:Bb,createHmacDrbg:Tb,ensureBytes:$b,equalBytes: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},hexToBytes:_b,hexToNumber:Eb,numberToBytesBE:Ab,numberToBytesLE:Ib,numberToHexUnpadded:vb,numberToVarBytesBE:function(e){return _b(vb(e))},utf8ToBytes:function(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))},validateObject:Rb});
15
- /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Pb=BigInt(0),Fb=BigInt(1),Cb=BigInt(2),Lb=BigInt(3),Mb=BigInt(4),Db=BigInt(5),Zb=BigInt(8);function jb(e,t){const n=e%t;return n>=Pb?n:t+n}function qb(e,t,n){if(n<=Pb||t<Pb)throw new Error("Expected power/modulo > 0");if(n===Fb)return Pb;let r=Fb;for(;t>Pb;)t&Fb&&(r=r*e%n),e=e*e%n,t>>=Fb;return r}function Gb(e,t,n){let r=e;for(;t-- >Pb;)r*=r,r%=n;return r}function Hb(e,t){if(e===Pb||t<=Pb)throw new Error(`invert: expected positive integers, got n=${e} mod=${t}`);let n=jb(e,t),r=t,o=Pb,i=Fb;for(;n!==Pb;){const e=r%n,t=o-i*(r/n);r=n,n=e,o=i,i=t}if(r!==Fb)throw new Error("invert: does not exist");return jb(o,t)}function Vb(e){if(e%Mb===Lb){const t=(e+Fb)/Mb;return function(e,n){const r=e.pow(n,t);if(!e.eql(e.sqr(r),n))throw new Error("Cannot find square root");return r}}if(e%Zb===Db){const t=(e-Db)/Zb;return function(e,n){const r=e.mul(n,Cb),o=e.pow(r,t),i=e.mul(n,o),s=e.mul(e.mul(i,Cb),o),a=e.mul(i,e.sub(s,e.ONE));if(!e.eql(e.sqr(a),n))throw new Error("Cannot find square root");return a}}return function(e){const t=(e-Fb)/Cb;let n,r,o;for(n=e-Fb,r=0;n%Cb===Pb;n/=Cb,r++);for(o=Cb;o<e&&qb(o,t,e)!==e-Fb;o++);if(1===r){const t=(e+Fb)/Mb;return function(e,n){const r=e.pow(n,t);if(!e.eql(e.sqr(r),n))throw new Error("Cannot find square root");return r}}const i=(n+Fb)/Cb;return function(e,s){if(e.pow(s,t)===e.neg(e.ONE))throw new Error("Cannot find square root");let a=r,c=e.pow(e.mul(e.ONE,o),n),u=e.pow(s,i),l=e.pow(s,n);for(;!e.eql(l,e.ONE);){if(e.eql(l,e.ZERO))return e.ZERO;let t=1;for(let n=e.sqr(l);t<a&&!e.eql(n,e.ONE);t++)n=e.sqr(n);const n=e.pow(c,Fb<<BigInt(a-t-1));c=e.sqr(n),u=e.mul(u,n),l=e.mul(l,c),a=t}return u}}(e)}BigInt(9),BigInt(16);const Kb=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Wb(e,t){const n=void 0!==t?t:e.toString(2).length;return{nBitLength:n,nByteLength:Math.ceil(n/8)}}function Jb(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 Xb(e){const t=Jb(e);return t+Math.ceil(t/2)}
12
+ const rs={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},os={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]},is=BigInt(2);const ss=xi(rs.p,{sqrt:function(e){const t=rs.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=fi(l,n,t)*l%t,d=fi(f,n,t)*l%t,h=fi(d,is,t)*u%t,p=fi(h,o,t)*h%t,m=fi(p,i,t)*p%t,g=fi(m,a,t)*m%t,y=fi(g,c,t)*g%t,w=fi(y,a,t)*m%t,b=fi(w,n,t)*l%t,v=fi(b,s,t)*p%t,E=fi(v,r,t)*u%t,x=fi(E,is,t);if(!ss.eql(ss.sqr(x),e))throw new Error("Cannot find square root");return x}}),as=function(e,t){const n=t=>ns({...e,hash:t});return{...n(t),create:n}}({...rs,Fp:ss,lowS:!0,endo:os},Ro);function cs(e,t){const n=[];for(let r=0;r<e.length;r+=t)n.push(e.subarray(r,r+t));return n}function us(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 ls(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 fs(e){return Array.from(e).map(e=>e.toString(16).padStart(2,"0")).join("")}function ds(e,t){const n=new Uint8Array(32);let r=e;for(let e=31;e>=0;e--)n[e]=Number(0xffn&r),r>>=8n;return n}function hs(e,t){let n=0n;for(let t=0;t<32;t++)n=n<<8n|BigInt(e[t]);return n}function ps(e){const t=e.startsWith("0x")||e.startsWith("0X")?e.slice(2):e,n=new Uint8Array(t.length/2);for(let e=0;e<n.length;e++)n[e]=parseInt(t.slice(2*e,2*e+2),16);return n}var ms="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";function gs(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 ys(e){return function(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)}(e,ms)}function ws(e){return gs(e,ms)}function bs(e){return new Uint8Array([e])}function vs(e){return e[0]}function Es(e,t){return new DataView(e.buffer,e.byteOffset,e.byteLength).getUint16(0,"LE"===t)}function xs(e,t){const n=new ArrayBuffer(4);return new DataView(n).setUint32(0,e,"LE"===t),new Uint8Array(n)}function _s(e,t){const n=new ArrayBuffer(8);return new DataView(n).setBigUint64(0,e,"LE"===t),new Uint8Array(n)}function ks(e,t){return new DataView(e.buffer,e.byteOffset,e.byteLength).getBigUint64(0,"LE"===t)}var As=[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 Is(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];$s(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,[Bs(e)]}const n=cs(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(Bs)}(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 $s(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],d=l^(o<<1|i>>>31),h=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),E=u^(r<<1|n>>>31);e[0]^=d,e[1]^=h,e[2]^=p,e[3]^=m,e[4]^=g,e[5]^=y,e[6]^=w,e[7]^=b,e[8]^=v,e[9]^=E,e[10]^=d,e[11]^=h,e[12]^=p,e[13]^=m,e[14]^=g,e[15]^=y,e[16]^=w,e[17]^=b,e[18]^=v,e[19]^=E,e[20]^=d,e[21]^=h,e[22]^=p,e[23]^=m,e[24]^=g,e[25]^=y,e[26]^=w,e[27]^=b,e[28]^=v,e[29]^=E,e[30]^=d,e[31]^=h,e[32]^=p,e[33]^=m,e[34]^=g,e[35]^=y,e[36]^=w,e[37]^=b,e[38]^=v,e[39]^=E,e[40]^=d,e[41]^=h,e[42]^=p,e[43]^=m,e[44]^=g,e[45]^=y,e[46]^=w,e[47]^=b,e[48]^=v,e[49]^=E;const x=e[0],_=e[1],k=e[2]<<1|e[3]>>>31,A=e[3]<<1|e[2]>>>31,I=e[5]<<30|e[4]>>>2,$=e[4]<<30|e[5]>>>2,B=e[6]<<28|e[7]>>>4,S=e[7]<<28|e[6]>>>4,z=e[8]<<27|e[9]>>>5,O=e[9]<<27|e[8]>>>5,T=e[11]<<4|e[10]>>>28,N=e[10]<<4|e[11]>>>28,R=e[13]<<12|e[12]>>>20,U=e[12]<<12|e[13]>>>20,P=e[14]<<6|e[15]>>>26,F=e[15]<<6|e[14]>>>26,C=e[17]<<23|e[16]>>>9,L=e[16]<<23|e[17]>>>9,M=e[18]<<20|e[19]>>>12,D=e[19]<<20|e[18]>>>12,Z=e[20]<<3|e[21]>>>29,j=e[21]<<3|e[20]>>>29,q=e[22]<<10|e[23]>>>22,G=e[23]<<10|e[22]>>>22,H=e[25]<<11|e[24]>>>21,V=e[24]<<11|e[25]>>>21,K=e[26]<<25|e[27]>>>7,W=e[27]<<25|e[26]>>>7,J=e[29]<<7|e[28]>>>25,X=e[28]<<7|e[29]>>>25,Y=e[31]<<9|e[30]>>>23,Q=e[30]<<9|e[31]>>>23,ee=e[33]<<13|e[32]>>>19,te=e[32]<<13|e[33]>>>19,ne=e[34]<<15|e[35]>>>17,re=e[35]<<15|e[34]>>>17,oe=e[36]<<21|e[37]>>>11,ie=e[37]<<21|e[36]>>>11,se=e[38]<<8|e[39]>>>24,ae=e[39]<<8|e[38]>>>24,ce=e[40]<<18|e[41]>>>14,ue=e[41]<<18|e[40]>>>14,le=e[42]<<2|e[43]>>>30,fe=e[43]<<2|e[42]>>>30,de=e[45]<<29|e[44]>>>3,he=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]=x^~R&H,e[1]=_^~U&V,e[2]=R^~H&oe,e[3]=U^~V&ie,e[4]=H^~oe&ge,e[5]=V^~ie&ye,e[6]=oe^~ge&x,e[7]=ie^~ye&_,e[8]=ge^~x&R,e[9]=ye^~_&U,e[10]=B^~M&Z,e[11]=S^~D&j,e[12]=M^~Z&ee,e[13]=D^~j&te,e[14]=Z^~ee&de,e[15]=j^~te&he,e[16]=ee^~de&B,e[17]=te^~he&S,e[18]=de^~B&M,e[19]=he^~S&D,e[20]=k^~P&K,e[21]=A^~F&W,e[22]=P^~K&se,e[23]=F^~W&ae,e[24]=K^~se&ce,e[25]=W^~ae&ue,e[26]=se^~ce&k,e[27]=ae^~ue&A,e[28]=ce^~k&P,e[29]=ue^~A&F,e[30]=z^~T&q,e[31]=O^~N&G,e[32]=T^~q&ne,e[33]=N^~G&re,e[34]=q^~ne&pe,e[35]=G^~re&me,e[36]=ne^~pe&z,e[37]=re^~me&O,e[38]=pe^~z&T,e[39]=me^~O&N,e[40]=I^~C&J,e[41]=$^~L&X,e[42]=C^~J&Y,e[43]=L^~X&Q,e[44]=J^~Y&le,e[45]=X^~Q&fe,e[46]=Y^~le&I,e[47]=Q^~fe&$,e[48]=le^~I&C,e[49]=fe^~$&L,e[0]^=As[2*t],e[1]^=As[2*t+1]}}function Bs(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 Ss=new TextDecoder,zs=new TextEncoder,Os=/^(0x)?[0-9a-fA-F]*$/i;var Ts=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(!Os.test(t)||t.replace(/^0x/i,"").length%2!=0)throw new Error(`Bytes#constructor: invalid hex string: ${t}`);this.bytes=ps(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=ps(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(Is(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(zs.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 fs(this.bytes)}toBase64(){return function(e){return gs(e,"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/")}(this.bytes)}toBase32(){return ws(this.bytes)}toString(){return this.toHex()}toUtf8(){return Ss.decode(this.bytes)}toJSON(){return JSON.parse(this.toUtf8())}equals(t){return this.toHex()===new e(t).toHex()}represent(){return this.toHex()}},Ns=class extends Ts{static LENGTH=32;constructor(e){super(e,32)}},Rs=0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n;function Us(e){if(e<=0n||e>=Rs)throw new Error("Invalid private key");const t=as.Point.BASE.multiply(e);return[t.x,t.y]}function Ps(e){const t=new Uint8Array(20),n=Is(Ts.concat(ds(e[0]),ds(e[1])));return t.set(n.subarray(12)),t}var Fs=class extends Ts{static LENGTH=20;constructor(e){super(e,20)}toChecksum(){return function(e){const t=fs(e),n=fs(Is(Uint8Array.from(t,e=>e.charCodeAt(0))));let r="0x";for(let e=0;e<t.length;e++)r+=parseInt(n.charAt(e),16)>7?t.charAt(e).toUpperCase():t.charAt(e);return r}(this.bytes)}},Cs=new Uint8Array(8).fill(255,0,8),Ls=class e extends Ts{static LENGTH=8;static MINUS_ONE=new e(Cs);constructor(e){super(e,8)}static fromBigInt(t){return new e(_s(t,"BE"))}toBigInt(){return ks(this.bytes,"BE")}next(){return fs(this.bytes)===fs(Cs)?e.fromBigInt(0n):e.fromBigInt(this.toBigInt()+1n)}},Ms=new TextEncoder,Ds=class e extends Ts{static LENGTH=32;constructor(e){super(e,32)}static fromString(t){return new e(Is(Ms.encode(t)))}},Zs=class extends Ts{static LENGTH=32;constructor(e){super(e,32)}};function js(e,t){const n=as.sign(Is(e),t,{prehash:!1}),r=0===n.recovery?27n:28n;return[n.r,n.s,r]}function qs(e,t,n,r){const o=27n===r?0:1,i=new as.Signature(t,n,o).recoverPublicKey(Is(e));return[i.x,i.y]}var Gs=class extends Ts{static LENGTH=64;constructor(e){const t=new Ts(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=as.Point.fromBytes(e);return[t.x,t.y]}(t.toUint8Array());super(Ts.concat(ds(e),ds(n)),64)}else super(e,64)}address(){const e=hs(this.bytes.slice(0,32)),t=hs(this.bytes.slice(32,64));return new Fs(Ps([e,t]))}toCompressedUint8Array(){const e=hs(this.bytes.slice(0,32)),t=hs(this.bytes.slice(32,64));return n=[e,t],as.Point.fromAffine({x:n[0],y:n[1]}).toBytes(!0);var n}toCompressedHex(){return fs(this.toCompressedUint8Array())}},Hs=new TextEncoder,Vs=Hs.encode("Ethereum Signed Message:\n32");function Ks(e){const t=e instanceof Uint8Array?e:Hs.encode(e);return Ts.concat(Vs,Is(t))}var Ws=class e extends Ts{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=hs(this.bytes.slice(0,32)),n=hs(this.bytes.slice(32,64)),r=BigInt(this.bytes[64]),[o,i]=qs(Ks(e),t,n,r);return new Gs(Ts.concat(ds(o),ds(i)))}isValid(e,t){return this.recoverPublicKey(e).address().equals(t)}},Js=class extends Ts{static LENGTH=32;constructor(e){super(e,32)}publicKey(){const[e,t]=Us(this.toBigInt());return new Gs(Ts.concat(ds(e),ds(t)))}sign(e){const[t,n,r]=js(Ks(e),this.toBigInt());return new Ws(Ts.concat(ds(t),ds(n),new Uint8Array([Number(r)])))}toBigInt(){return hs(this.bytes)}};var Xs=class e extends Ts{static LENGTH=32;constructor(e){"string"==typeof e&&e.startsWith("bah5")?super(function(e){const t=ys(e.toUpperCase().slice(1)),n=t[1];if(250!==n&&251!==n)throw new Error("Unknown codec");return t.slice(-32)}(e),32):super(e,[32,64])}toCid(e){return`b${ws(Ts.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}}},Ys=class e extends Ts{static LENGTH=8;constructor(e){super(e,8)}static fromBigInt(t){return new e(_s(t,"LE"))}toBigInt(){return ks(this.bytes,"LE")}static fromSlice(t,n){return new e(t.slice(n,n+e.LENGTH))}},Qs=new TextEncoder,ea=class e extends Ts{static LENGTH=32;constructor(e){super(e,32)}static fromString(t){return new e(Is(Qs.encode(t)))}},ta=class extends Ts{static LENGTH=32;constructor(e){super(e,32)}},na=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}},ra=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 oa(e,t,n){const r=new Uint8Array(n.length),o=new Uint8Array(36);o.set(e);for(let e=0,i=0;i<n.length;e++,i+=32){const s=t+e>>>0;o[32]=255&s,o[33]=s>>>8&255,o[34]=s>>>16&255,o[35]=s>>>24&255;const a=Is(Is(o)),c=Math.min(i+32,n.length);for(let e=i;e<c;e++)r[e]=n[e]^a[e-i]}return r}var ia=4096;function sa(e){const t=e.subarray(0,8),n=function(e){if(e.length>ia)throw new Error(`payload size ${e.length} exceeds maximum chunk payload size 4096`);const t=new Uint8Array(ia);t.set(e);let n=cs(t,32);for(;n.length>1;){const e=[];for(let t=0;t<n.length;t+=2)e.push(Is(Ts.concat(n[t],n[t+1])));n=e}return n[0]}(e.subarray(8));return new Xs(Is(Ts.concat(t,n)))}ps("dc5b20847f43d67928f49cd4f85d696b5a7617b5");var aa=Ds.LENGTH,ca=Ds.LENGTH+65,ua=ca+Ys.LENGTH,la=(new TextEncoder).encode("Ethereum Signed Message:\n32");function fa(e,t){const n=Is(Ts.concat(e,t));return Ts.concat(la,n)}function da(e,t){const n=new Ds(e),r=new Fs(t);return new Xs(Is(Ts.concat(n.toUint8Array(),r.toUint8Array())))}function ha(e,t,n){const r=new Ds(t),o=function(e,t,n){const[r,o,i]=js(fa(e,t),n);return Ts.concat(ds(r),ds(o),new Uint8Array([Number(i)]))}(r.toUint8Array(),e.address.toUint8Array(),n),i=new Fs(Ps(Us(n))),s=da(r,i);return{data:Ts.concat(r.toUint8Array(),o,e.data),identifier:r,signature:new Ws(o),span:e.span,payload:e.payload,address:s,owner:i}}function pa(e,t){const n=e instanceof Ts?e.toUint8Array():e,r=new Xs(t),o=new Ds(Ts.fromSlice(n,0,Ds.LENGTH)),i=n.slice(aa,aa+65),s=sa(n.slice(ca)),a=new Fs(function(e,t,n){const r=hs(n.subarray(0,32)),o=hs(n.subarray(32,64)),i=BigInt(n[64]);return Ps(qs(fa(e,t),r,o,i))}(o.toUint8Array(),s.toUint8Array(),i)),c=da(o,a);if(!c.equals(r))throw new Error("SOC data does not match given address");const u=Ys.fromSlice(n,ca),l=Ts.fromSlice(n,ua);return{data:n,identifier:o,signature:new Ws(i),span:u,payload:l,address:c,owner:a}}function ma(e,t){if("string"==typeof e&&(e=Ts.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?Ys.fromBigInt(t):t:Ys.fromBigInt(BigInt(e.length)),r=new Ts(e),o=Ts.concat(n.toUint8Array(),r.toUint8Array()),i={data:o,span:n,payload:r,address:sa(o),toSingleOwnerChunk:(e,t)=>ha(i,e,new Js(t).toBigInt())};return i}function ga(e){const t=new Ts(e);return ma(t.toUint8Array().slice(Ys.LENGTH),Ys.fromSlice(t.toUint8Array(),0))}var ya=class{span;writer;constructor(e=0n){this.span=e,this.writer=new ra(new Uint8Array(4096))}build(){return Ts.concat(_s(this.span,"LE"),this.writer.buffer)}hash(){return sa(this.build())}encryptedHash(e){e||(e=new Uint8Array(32),crypto.getRandomValues(e));const t=function(e,t){return oa(e,128,t)}(e,_s(this.span,"LE")),n=function(e,t){return oa(e,0,t)}(e,this.writer.buffer);return{address:sa(Ts.concat(t,n)),key:e}}},wa=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 ya],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 na(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 ya,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 na(t.hash().toUint8Array()))}}async flushBatch(e){this.chunks[e+1]||(this.chunks.push(new ya),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])}};function ba(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}var va=new TextEncoder,Ea=new TextDecoder,xa=new Uint8Array([47]),_a=ps("5768b3b6a7db56d21d1abff40d41cebfc83448fed8d7e9b06ec0d3b073f28f7b");function ka(e,t){const n=Math.floor(t/8),r=t%8;e[n]=e[n]|1<<r}function Aa(e,t){const n=t%8;return 1==(e[Math.floor(t/8)]>>n&1)}var Ia=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 Ts.concat(this.parent?.fullPath??new Uint8Array(0),this.path)}get fullPathString(){return Ea.decode(this.fullPath)}async marshal(){for(const e of this.forks.values())e.node.selfAddress||(e.node.selfAddress=(await e.node.calculateSelfAddress()).toUint8Array());this.encrypt&&us(this.obfuscationKey,new Uint8Array(32))&&(this.obfuscationKey=new Uint8Array(32),crypto.getRandomValues(this.obfuscationKey));const e=!us(this.targetAddress,new Uint8Array(this.targetAddress.length));let t=0;if(e)t=this.targetAddress.length;else for(const e of this.forks.values())if(e.node.selfAddress&&e.node.selfAddress.length>0){t=e.node.selfAddress.length;break}const n=new Uint8Array(32);n.set(_a,0),n.set(bs(t),31);const r=e?this.targetAddress:new Uint8Array(t),o=new Uint8Array(32);for(const e of this.forks.keys())ka(o,e);const i=[];for(let e=0;e<256;e++)Aa(o,e)&&i.push(this.forks.get(e).marshal());const s=ba(Ts.concat(n,r,o,...i),this.obfuscationKey);return Ts.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=ba(t.subarray(32),r),i=new na(o);if(!us(i.read(31),_a.slice(0,31)))throw new Error("MantarayNode#unmarshalFromData invalid version hash");const s=vs(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(Aa(u,e)){const t=Sa.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:va.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 Sa(u,new e({targetAddress:s?new Xs(n).toUint8Array():void 0,metadata:s?r:void 0,path:u,encrypt:this.encrypt})),f=a.forks.get(u[0]);if(f){const e=Sa.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:va.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 e of t.forks.values())n.addFork(Ts.concat(t.path,e.prefix),e.node.targetAddress,e.node.metadata)}async calculateSelfAddress(){if(this.selfAddress)return new Xs(this.selfAddress);if(this.encrypt)throw new Error("MantarayNode#calculateSelfAddress is not supported for encrypted nodes - use saveRecursively");return(await wa.root(await this.marshal())).hash()}async saveRecursively(e){for(const t of this.forks.values())await t.node.saveRecursively(e);const t=new wa(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=Ts.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:va.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:va.encode(e)).length)return[this,t];const n=this.forks.get(e[0]);return n&&ls(n.prefix,e).length===n.prefix.length?n.node.findClosest(e.slice(n.prefix.length),Ts.concat(t,n.prefix)):[this,t]}collect(e=[]){for(const t of this.forks.values())us(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 Xs(t.targetAddress).toHex();return e}determineType(){let e=0;const t=new Uint8Array(this.targetAddress.length);return us(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,xa)>0&&(e|=8),this.metadata&&(e|=16),e}},$a=new TextEncoder,Ba=new TextDecoder;var Sa=class e{prefix;node;constructor(e,t){this.prefix=e,this.node=t}static split(t,n){const r=ls(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 Ia({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(bs(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}(Ts.concat(new Uint8Array([0,0]),$a.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 Ts.concat(...e)}static unmarshal(t,n){const r=vs(t.read(1)),o=vs(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=Es(t.read(2),"BE");if(e>t.max())throw new Error("Fork#unmarshal not enough bytes for metadata");a=JSON.parse(Ba.decode(t.read(e)))}return new e(i,new Ia({selfAddress:s,metadata:a,path:i,type:r}))}};function za(e,t,n){return e/Math.pow(2,t-n)}function Oa(e){return 4096*2**e}function Ta(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 Na,Ra=[[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"]],Ua=[[[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"]]],Pa=[[[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 Fa(e,t,n){if(e<17)return 0;if(void 0!==t&&void 0!==n){const r=(t?Pa:Ua)[n],o=r?.find(([t])=>t===e);if(o)return Ta(o[1])}else{const t=Ra.find(([t])=>t===e);if(t)return Ta(t[1])}return Math.ceil(.9*Oa(e))}function Ca(e,t,n){if(void 0!==t&&void 0!==n){const r=(t?Pa:Ua)[n],o=r?.find(([,t])=>e<=Ta(t));if(o)return o[0]}else for(const[t,n]of Ra)if(e<=Ta(n))return t;return 35}function La(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 Ts(Ts.concat(t,r,n,e))}(e.signature.toUint8Array(),e.batchId.toUint8Array(),e.timestamp,e.index)}function Ma(e,t,n,r,o=Date.now()){const i=new Js(e),s=new Ns(t),a=Es(n,"BE"),c=Ts.concat(xs(a,"BE"),xs(r,"BE")),u=_s(1000000n*BigInt(o),"BE"),l=i.sign(Ts.concat(n,s.toUint8Array(),c,u));return{batchId:s,index:c,issuer:i.publicKey().address(),signature:l,timestamp:u}}function Da(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 e of o._zod.deferred)e();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}class Za extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class ja extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}}(Na=globalThis).__zod_globalConfig??(Na.__zod_globalConfig={});const qa=globalThis.__zod_globalConfig;function Ga(e){return qa}function Ha(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 Va(e,t){return"bigint"==typeof t?t.toString():t}function Ka(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Wa(e){return null==e}function Ja(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}const Xa=Symbol("evaluating");function Ya(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Xa)return void 0===r&&(r=Xa,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function Qa(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function ec(...e){const t={};for(const n of e){const e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function tc(e){return JSON.stringify(e)}const nc="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function rc(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}const oc=Ka(()=>{if(qa.jitless)return!1;if("undefined"!=typeof navigator&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function ic(e){if(!1===rc(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!==rc(n)&&!1!==Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")}function sc(e){return ic(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const ac=new Set(["string","number","symbol"]);function cc(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function uc(e,t,n){const r=new e._zod.constr(t??e._zod.def);return t&&!n?.parent||(r._zod.parent=e),r}function lc(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 fc={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 dc(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 hc(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 pc(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function mc(e){return"string"==typeof e?e:e?.message}function gc(e,t,n){const r=e.message?e.message:mc(e.inst?._zod.def?.error?.(e))??mc(t?.error?.(e))??mc(n.customError?.(e))??mc(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 yc(e){return Array.isArray(e)?"array":"string"==typeof e?"string":"unknown"}function wc(...e){const[t,n,r]=e;return"string"==typeof t?{message:t,code:"custom",input:n,inst:r}:{...t}}const bc=(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,Va,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},vc=Da("$ZodError",bc),Ec=Da("$ZodError",bc,{Parent:Error});const xc=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 Za;if(s.issues.length){const t=new(o?.Err??e)(s.issues.map(e=>gc(e,i,Ga())));throw nc(t,o?.callee),t}return s.value},_c=xc(Ec),kc=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=>gc(e,i,Ga())));throw nc(t,o?.callee),t}return s.value},Ac=kc(Ec),Ic=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 Za;return i.issues.length?{success:!1,error:new(e??vc)(i.issues.map(e=>gc(e,o,Ga())))}:{success:!0,data:i.value}},$c=Ic(Ec),Bc=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=>gc(e,o,Ga())))}:{success:!0,data:i.value}},Sc=Bc(Ec),zc=e=>(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return xc(e)(t,n,o)},Oc=e=>(t,n,r)=>xc(e)(t,n,r),Tc=e=>async(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return kc(e)(t,n,o)},Nc=e=>async(t,n,r)=>kc(e)(t,n,r),Rc=e=>(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return Ic(e)(t,n,o)},Uc=e=>(t,n,r)=>Ic(e)(t,n,r),Pc=e=>async(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return Bc(e)(t,n,o)},Fc=e=>async(t,n,r)=>Bc(e)(t,n,r),Cc=/^[cC][0-9a-z]{6,}$/,Lc=/^[0-9a-z]+$/,Mc=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Dc=/^[0-9a-vA-V]{20}$/,Zc=/^[A-Za-z0-9]{27}$/,jc=/^[a-zA-Z0-9_-]{21}$/,qc=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Gc=/^([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})$/,Hc=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)$/,Vc=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;const Kc=/^(?:(?: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])$/,Wc=/^(([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}|:))$/,Jc=/^((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])$/,Xc=/^(([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])$/,Yc=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Qc=/^[A-Za-z0-9_-]*$/,eu=/^https?$/,tu=/^\+[1-9]\d{6,14}$/,nu="(?:(?:\\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])))",ru=new RegExp(`^${nu}$`);function ou(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 iu=/^-?\d+n?$/,su=/^-?\d+$/,au=/^-?\d+(?:\.\d+)?$/,cu=/^(?:true|false)$/i,uu=/^[^A-Z]*$/,lu=/^[^a-z]*$/,fu=Da("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),du={number:"number",bigint:"bigint",object:"date"},hu=Da("$ZodCheckLessThan",(e,t)=>{fu.init(e,t);const n=du[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})}}),pu=Da("$ZodCheckGreaterThan",(e,t)=>{fu.init(e,t);const n=du[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})}}),mu=Da("$ZodCheckMultipleOf",(e,t)=>{fu.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})}}),gu=Da("$ZodCheckNumberFormat",(e,t)=>{fu.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),r=n?"int":"number",[o,i]=fc[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=su)}),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})}}),yu=Da("$ZodCheckMaxLength",(e,t)=>{var n;fu.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!Wa(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=yc(r);n.issues.push({origin:o,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),wu=Da("$ZodCheckMinLength",(e,t)=>{var n;fu.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!Wa(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=yc(r);n.issues.push({origin:o,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),bu=Da("$ZodCheckLengthEquals",(e,t)=>{var n;fu.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!Wa(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=yc(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})}}),vu=Da("$ZodCheckStringFormat",(e,t)=>{var n,r;fu.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=()=>{})}),Eu=Da("$ZodCheckRegex",(e,t)=>{vu.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})}}),xu=Da("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=uu),vu.init(e,t)}),_u=Da("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=lu),vu.init(e,t)}),ku=Da("$ZodCheckIncludes",(e,t)=>{fu.init(e,t);const n=cc(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})}}),Au=Da("$ZodCheckStartsWith",(e,t)=>{fu.init(e,t);const n=new RegExp(`^${cc(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})}}),Iu=Da("$ZodCheckEndsWith",(e,t)=>{fu.init(e,t);const n=new RegExp(`.*${cc(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})}}),$u=Da("$ZodCheckOverwrite",(e,t)=>{fu.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});class Bu{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 e of r)this.content.push(e)}compile(){const e=Function,t=this?.args;return new e(...t,[...(this?.content??[""]).map(e=>` ${e}`)].join("\n"))}}const Su={major:4,minor:4,patch:3},zu=Da("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Su;const r=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&r.unshift(e);for(const t of r)for(const n of t._zod.onattach)n(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=dc(e);for(const i of t){if(i._zod.def.when){if(hc(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 Za;if(r||s instanceof Promise)r=(r??Promise.resolve()).then(async()=>{await s;e.issues.length!==t&&(o||(o=dc(e,t)))});else{if(e.issues.length===t)continue;o||(o=dc(e,t))}}return r?r.then(()=>e):e},n=(n,o,i)=>{if(dc(n))return n.aborted=!0,n;const s=t(o,r,i);if(s instanceof Promise){if(!1===i.async)throw new Za;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 Za;return s.then(e=>t(e,r,i))}return t(s,r,i)}}Ya(e,"~standard",()=>({validate:t=>{try{const n=$c(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch(n){return Sc(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:"zod",version:1}))}),Ou=Da("$ZodString",(e,t)=>{var n;zu.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}}),Tu=Da("$ZodStringFormat",(e,t)=>{vu.init(e,t),Ou.init(e,t)}),Nu=Da("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Gc),Tu.init(e,t)}),Ru=Da("$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=Hc(e))}else t.pattern??(t.pattern=Hc());Tu.init(e,t)}),Uu=Da("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Vc),Tu.init(e,t)}),Pu=Da("$ZodURL",(e,t)=>{Tu.init(e,t),e._zod.check=n=>{try{const r=n.value.trim();if(!t.normalize&&t.protocol?.source===eu.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})}}}),Fu=Da("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),Tu.init(e,t)}),Cu=Da("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=jc),Tu.init(e,t)}),Lu=Da("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Cc),Tu.init(e,t)}),Mu=Da("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Lc),Tu.init(e,t)}),Du=Da("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Mc),Tu.init(e,t)}),Zu=Da("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Dc),Tu.init(e,t)}),ju=Da("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Zc),Tu.init(e,t)}),qu=Da("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=function(e){const t=ou({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(`^${nu}T(?:${r})$`)}(t)),Tu.init(e,t)}),Gu=Da("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=ru),Tu.init(e,t)}),Hu=Da("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=new RegExp(`^${ou(t)}$`)),Tu.init(e,t)}),Vu=Da("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=qc),Tu.init(e,t)}),Ku=Da("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Kc),Tu.init(e,t),e._zod.bag.format="ipv4"}),Wu=Da("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Wc),Tu.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})}}}),Ju=Da("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Jc),Tu.init(e,t)}),Xu=Da("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Xc),Tu.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 Yu(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 Qu=Da("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Yc),Tu.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{Yu(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});const el=Da("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Qc),Tu.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{(function(e){if(!Qc.test(e))return!1;const t=e.replace(/[-_]/g,e=>"-"===e?"+":"/");return Yu(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})}}),tl=Da("$ZodE164",(e,t)=>{t.pattern??(t.pattern=tu),Tu.init(e,t)});const nl=Da("$ZodJWT",(e,t)=>{Tu.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})}}),rl=Da("$ZodNumber",(e,t)=>{zu.init(e,t),e._zod.pattern=e._zod.bag.pattern??au,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch(e){}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}}),ol=Da("$ZodNumberFormat",(e,t)=>{gu.init(e,t),rl.init(e,t)}),il=Da("$ZodBoolean",(e,t)=>{zu.init(e,t),e._zod.pattern=cu,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Boolean(n.value)}catch(e){}const o=n.value;return"boolean"==typeof o||n.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),n}}),sl=Da("$ZodBigInt",(e,t)=>{zu.init(e,t),e._zod.pattern=iu,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=BigInt(n.value)}catch(e){}return"bigint"==typeof n.value||n.issues.push({expected:"bigint",code:"invalid_type",input:n.value,inst:e}),n}}),al=Da("$ZodAny",(e,t)=>{zu.init(e,t),e._zod.parse=e=>e}),cl=Da("$ZodUnknown",(e,t)=>{zu.init(e,t),e._zod.parse=e=>e}),ul=Da("$ZodNever",(e,t)=>{zu.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:e}),t)});function ll(e,t,n){e.issues.length&&t.issues.push(...pc(n,e.issues)),t.value[n]=e.value}const fl=Da("$ZodArray",(e,t)=>{zu.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=>ll(t,n,e))):ll(a,n,e)}return i.length?Promise.all(i).then(()=>n):n}});function dl(e,t,n,r,o,i){const s=n in r;if(e.issues.length){if(o&&i&&!s)return;t.issues.push(...pc(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 hl(e){const t=Object.keys(e.shape);for(const n of t)if(!e.shape?.[n]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${n}": 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 pl(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 o in t){if("__proto__"===o)continue;if(a.has(o))continue;if("never"===u){s.push(o);continue}const i=c.run({value:t[o],issues:[]},r);i instanceof Promise?e.push(i.then(e=>dl(e,n,o,t,l,f))):dl(i,n,o,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 ml=Da("$ZodObject",(e,t)=>{zu.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=Ka(()=>hl(t));Ya(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=rc,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=>dl(n,t,e,a,o,i))):dl(s,t,e,a,o,i)}return i?pl(c,a,t,n,r.value,e):c.length?Promise.all(c).then(()=>t):t}}),gl=Da("$ZodObjectJIT",(e,t)=>{ml.init(e,t);const n=e._zod.parse,r=Ka(()=>hl(t));let o;const i=rc,s=!qa.jitless,a=s&&oc.value,c=t.catchall;let u;e._zod.parse=(l,f)=>{u??(u=r.value);const d=l.value;return i(d)?s&&a&&!1===f?.async&&!0!==f.jitless?(o||(o=(e=>{const t=new Bu(["shape","payload","ctx"]),n=r.value,o=e=>{const t=tc(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 e of n.keys)i[e]="key_"+s++;t.write("const newResult = {};");for(const r of n.keys){const n=i[r],s=tc(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?pl([],d,l,f,u,e):l):n(l,f):(l.issues.push({expected:"object",code:"invalid_type",input:d,inst:e}),l)}});function yl(e,t,n,r){for(const n of e)if(0===n.issues.length)return t.value=n.value,t;const o=e.filter(e=>!dc(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=>gc(e,r,Ga())))}),t)}const wl=Da("$ZodUnion",(e,t)=>{zu.init(e,t),Ya(e._zod,"optin",()=>t.options.some(e=>"optional"===e._zod.optin)?"optional":void 0),Ya(e._zod,"optout",()=>t.options.some(e=>"optional"===e._zod.optout)?"optional":void 0),Ya(e._zod,"values",()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),Ya(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=>Ja(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=>yl(t,r,e,o)):yl(s,r,e,o)}}),bl=Da("$ZodIntersection",(e,t)=>{zu.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])=>El(e,t,n)):El(e,o,i)}});function vl(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(ic(e)&&ic(t)){const n=Object.keys(t),r=Object.keys(e).filter(e=>-1!==n.indexOf(e)),o={...e,...t};for(const n of r){const r=vl(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};o[n]=r.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=vl(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 El(e,t,n){const r=new Map;let o;for(const n of t.issues)if("unrecognized_keys"===n.code){o??(o=n);for(const e of n.keys)r.has(e)||r.set(e,{}),r.get(e).l=!0}else e.issues.push(n);for(const t of n.issues)if("unrecognized_keys"===t.code)for(const e of t.keys)r.has(e)||r.set(e,{}),r.get(e).r=!0;else e.issues.push(t);const i=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(i.length&&o&&e.issues.push({...o,keys:i}),dc(e))return e;const s=vl(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 xl=Da("$ZodTuple",(e,t)=>{zu.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=_l(n,"optin"),c=_l(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=>kl(t,r,e))):kl(i,r,e)}}return s.length?Promise.all(s).then(()=>Al(u,r,n,i,c)):Al(u,r,n,i,c)}});function _l(e,t){for(let n=e.length-1;n>=0;n--)if("optional"!==e[n]._zod[t])return n+1;return 0}function kl(e,t,n){e.issues.length&&t.issues.push(...pc(n,e.issues)),t.value[n]=e.value}function Al(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(...pc(i,n.issues))}t.value[i]=n.value}for(let e=t.value.length-1;e>=r.length&&("optional"===n[e]._zod.optout&&void 0===t.value[e]);e--)t.value.length=e;return t}const Il=Da("$ZodRecord",(e,t)=>{zu.init(e,t),e._zod.parse=(n,r)=>{const o=n.value;if(!ic(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 c of s)if("string"==typeof c||"number"==typeof c||"symbol"==typeof c){a.add("number"==typeof c?c.toString():c);const s=t.keyType._zod.run({value:c,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=>gc(e,r,Ga())),input:c,path:[c],inst:e});continue}const u=s.value,l=t.valueType._zod.run({value:o[c],issues:[]},r);l instanceof Promise?i.push(l.then(e=>{e.issues.length&&n.issues.push(...pc(c,e.issues)),n.value[u]=e.value})):(l.issues.length&&n.issues.push(...pc(c,l.issues)),n.value[u]=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&&au.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=>gc(e,r,Ga())),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(...pc(s,e.issues)),n.value[a.value]=e.value})):(c.issues.length&&n.issues.push(...pc(s,c.issues)),n.value[a.value]=c.value)}}return i.length?Promise.all(i).then(()=>n):n}}),$l=Da("$ZodEnum",(e,t)=>{zu.init(e,t);const n=Ha(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter(e=>ac.has(typeof e)).map(e=>"string"==typeof e?cc(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}}),Bl=Da("$ZodLiteral",(e,t)=>{if(zu.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?cc(e):e?cc(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}}),Sl=Da("$ZodTransform",(e,t)=>{zu.init(e,t),e._zod.optin="optional",e._zod.parse=(n,r)=>{if("backward"===r.direction)throw new ja(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 Za;return n.value=o,n.fallback=!0,n}});function zl(e,t){return void 0===t&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}const Ol=Da("$ZodOptional",(e,t)=>{zu.init(e,t),e._zod.optin="optional",e._zod.optout="optional",Ya(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),Ya(e._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${Ja(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=>zl(e,r)):zl(o,r)}return void 0===e.value?e:t.innerType._zod.run(e,n)}}),Tl=Da("$ZodExactOptional",(e,t)=>{Ol.init(e,t),Ya(e._zod,"values",()=>t.innerType._zod.values),Ya(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),Nl=Da("$ZodNullable",(e,t)=>{zu.init(e,t),Ya(e._zod,"optin",()=>t.innerType._zod.optin),Ya(e._zod,"optout",()=>t.innerType._zod.optout),Ya(e._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${Ja(e.source)}|null)$`):void 0}),Ya(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)}),Rl=Da("$ZodDefault",(e,t)=>{zu.init(e,t),e._zod.optin="optional",Ya(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=>Ul(e,t)):Ul(r,t)}});function Ul(e,t){return void 0===e.value&&(e.value=t.defaultValue),e}const Pl=Da("$ZodPrefault",(e,t)=>{zu.init(e,t),e._zod.optin="optional",Ya(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))}),Fl=Da("$ZodNonOptional",(e,t)=>{zu.init(e,t),Ya(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=>Cl(t,e)):Cl(o,e)}});function Cl(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 Ll=Da("$ZodCatch",(e,t)=>{zu.init(e,t),e._zod.optin="optional",Ya(e._zod,"optout",()=>t.innerType._zod.optout),Ya(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=>gc(e,n,Ga()))},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=>gc(e,n,Ga()))},input:e.value}),e.issues=[],e.fallback=!0),e)}}),Ml=Da("$ZodPipe",(e,t)=>{zu.init(e,t),Ya(e._zod,"values",()=>t.in._zod.values),Ya(e._zod,"optin",()=>t.in._zod.optin),Ya(e._zod,"optout",()=>t.out._zod.optout),Ya(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=>Dl(e,t.in,n)):Dl(r,t.in,n)}const r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Dl(e,t.out,n)):Dl(r,t.out,n)}});function Dl(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 Zl=Da("$ZodReadonly",(e,t)=>{zu.init(e,t),Ya(e._zod,"propValues",()=>t.innerType._zod.propValues),Ya(e._zod,"values",()=>t.innerType._zod.values),Ya(e._zod,"optin",()=>t.innerType?._zod?.optin),Ya(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(jl):jl(r)}});function jl(e){return e.value=Object.freeze(e.value),e}const ql=Da("$ZodFunction",(e,t)=>(zu.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?_c(e._def.input,n):n,o=Reflect.apply(t,this,r);return e._def.output?_c(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 Ac(e._def.input,n):n,o=await Reflect.apply(t,this,r);return e._def.output?await Ac(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 xl({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)),Gl=Da("$ZodCustom",(e,t)=>{fu.init(e,t),zu.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=>Hl(t,n,r,e));Hl(o,n,r,e)}});function Hl(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(wc(e))}}var Vl;class Kl{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)}}(Vl=globalThis).__zod_globalRegistry??(Vl.__zod_globalRegistry=new Kl);const Wl=globalThis.__zod_globalRegistry;function Jl(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...lc(t)})}function Xl(e,t){return new hu({check:"less_than",...lc(t),value:e,inclusive:!1})}function Yl(e,t){return new hu({check:"less_than",...lc(t),value:e,inclusive:!0})}function Ql(e,t){return new pu({check:"greater_than",...lc(t),value:e,inclusive:!1})}function ef(e,t){return new pu({check:"greater_than",...lc(t),value:e,inclusive:!0})}function tf(e,t){return new mu({check:"multiple_of",...lc(t),value:e})}function nf(e,t){return new yu({check:"max_length",...lc(t),maximum:e})}function rf(e,t){return new wu({check:"min_length",...lc(t),minimum:e})}function of(e,t){return new bu({check:"length_equals",...lc(t),length:e})}function sf(e){return new $u({check:"overwrite",tx:e})}function af(e,t){const n=function(e,t){const n=new fu({check:"custom",...lc(t)});return n._zod.check=e,n}(t=>(t.addIssue=e=>{if("string"==typeof e)t.issues.push(wc(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(wc(r))}},e(t.value,t)),t);return n}function cf(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??Wl,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 uf(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),uf(i,t,r),t.seen.get(i).isParent=!0)}const c=t.metadataRegistry.get(e);c&&Object.assign(s.schema,c),"input"===t.io&&df(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 lf(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 t of e.seen.entries()){const n=e.metadataRegistry.get(t[0])?.id;if(n){const e=r.get(n);if(e&&e!==t[0])throw new Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}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 t of e.seen.entries()){const e=t[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 n of e.seen.entries()){const r=n[1];if(t===n[0]){o(n);continue}if(e.external){const r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){o(n);continue}}const i=e.metadataRegistry.get(n[0])?.id;i?o(n):(r.cycle||r.count>1&&"ref"===e.reused)&&o(n)}}function ff(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 t of[...e.seen.entries()].reverse())r(t[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 t of e.seen.entries()){const e=t[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:hf(t,"input",e.processors),output:hf(t,"output",e.processors)}},enumerable:!1,writable:!1}),n}catch(e){throw new Error("Error converting schema to JSON.")}}function df(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 df(r.element,n);if("set"===r.type)return df(r.valueType,n);if("lazy"===r.type)return df(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 df(r.innerType,n);if("intersection"===r.type)return df(r.left,n)||df(r.right,n);if("record"===r.type||"map"===r.type)return df(r.keyType,n)||df(r.valueType,n);if("pipe"===r.type)return!!e._zod.traits.has("$ZodCodec")||(df(r.in,n)||df(r.out,n));if("object"===r.type){for(const e in r.shape)if(df(r.shape[e],n))return!0;return!1}if("union"===r.type){for(const e of r.options)if(df(e,n))return!0;return!1}if("tuple"===r.type){for(const e of r.items)if(df(e,n))return!0;return!(!r.rest||!df(r.rest,n))}return!1}const hf=(e,t,n={})=>r=>{const{libraryOptions:o,target:i}=r??{},s=cf({...o??{},target:i,io:t,processors:n});return uf(e,s),lf(s,e),ff(s,e)},pf={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},mf=(e,t,n,r)=>{const o=e._zod.def;uf(o.innerType,t,r);t.seen.get(e).ref=o.innerType},gf=Da("ZodISODateTime",(e,t)=>{qu.init(e,t),qf.init(e,t)});function yf(e){return function(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...lc(t)})}(gf,e)}const wf=Da("ZodISODate",(e,t)=>{Gu.init(e,t),qf.init(e,t)});function bf(e){return function(e,t){return new e({type:"string",format:"date",check:"string_format",...lc(t)})}(wf,e)}const vf=Da("ZodISOTime",(e,t)=>{Hu.init(e,t),qf.init(e,t)});function Ef(e){return function(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...lc(t)})}(vf,e)}const xf=Da("ZodISODuration",(e,t)=>{Vu.init(e,t),qf.init(e,t)});function _f(e){return function(e,t){return new e({type:"string",format:"duration",check:"string_format",...lc(t)})}(xf,e)}const kf=(e,t)=>{vc.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,Va,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Va,2)}},isEmpty:{get:()=>0===e.issues.length}})},Af=Da("ZodError",kf,{Parent:Error}),If=xc(Af),$f=kc(Af),Bf=Ic(Af),Sf=Bc(Af),zf=zc(Af),Of=Oc(Af),Tf=Tc(Af),Nf=Nc(Af),Rf=Rc(Af),Uf=Uc(Af),Pf=Pc(Af),Ff=Fc(Af),Cf=new WeakMap;function Lf(e,t,n){const r=Object.getPrototypeOf(e);let o=Cf.get(r);if(o||(o=new Set,Cf.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 Mf=Da("ZodType",(e,t)=>(zu.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:hf(e,"input"),output:hf(e,"output")}}),e.toJSONSchema=((e,t={})=>n=>{const r=cf({...n,processors:t});return uf(e,r),lf(r,e),ff(r,e)})(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>If(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>Bf(e,t,n),e.parseAsync=async(t,n)=>$f(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>Sf(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>zf(e,t,n),e.decode=(t,n)=>Of(e,t,n),e.encodeAsync=async(t,n)=>Tf(e,t,n),e.decodeAsync=async(t,n)=>Nf(e,t,n),e.safeEncode=(t,n)=>Rf(e,t,n),e.safeDecode=(t,n)=>Uf(e,t,n),e.safeEncodeAsync=async(t,n)=>Pf(e,t,n),e.safeDecodeAsync=async(t,n)=>Ff(e,t,n),Lf(e,"ZodType",{check(...e){const t=this.def;return this.clone(ec(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 uc(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,...lc(n)})}(Xd,e,t)}(e,t))},superRefine(e,t){return this.check(function(e,t){return af(e,t)}(e,t))},overwrite(e){return this.check(sf(e))},optional(){return Ld(this)},exactOptional(){return new Md({type:"optional",innerType:this})},nullable(){return Zd(this)},nullish(){return Ld(Zd(this))},nonoptional(e){return function(e,t){return new Gd({type:"nonoptional",innerType:e,...lc(t)})}(this,e)},array(){return Ad(this)},or(e){return new Bd({type:"union",options:[this,e],...lc(t)});var t},and(e){return new Sd({type:"intersection",left:this,right:e})},transform(e){return Kd(this,new Fd({type:"transform",transform:e}))},default(e){return t=e,new jd({type:"default",innerType:this,get defaultValue(){return"function"==typeof t?t():sc(t)}});var t},prefault(e){return t=e,new qd({type:"prefault",innerType:this,get defaultValue(){return"function"==typeof t?t():sc(t)}});var t},catch(e){return new Hd({type:"catch",innerType:this,catchValue:"function"==typeof(t=e)?t:()=>t});var t},pipe(e){return Kd(this,e)},readonly(){return new Wd({type:"readonly",innerType:this})},describe(e){const t=this.clone();return Wl.add(t,{description:e}),t},meta(...e){if(0===e.length)return Wl.get(this);const t=this.clone();return Wl.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:()=>Wl.get(e)?.description,configurable:!0}),e)),Df=Da("_ZodString",(e,t)=>{Ou.init(e,t),Mf.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n)=>{const r=n;r.type="string";const{minimum:o,maximum:i,format:s,patterns:a,contentEncoding:c}=e._zod.bag;if("number"==typeof o&&(r.minLength=o),"number"==typeof i&&(r.maxLength=i),s&&(r.format=pf[s]??s,""===r.format&&delete r.format,"time"===s&&delete r.format),c&&(r.contentEncoding=c),a&&a.size>0){const e=[...a];1===e.length?r.pattern=e[0].source:e.length>1&&(r.allOf=[...e.map(e=>({..."draft-07"===t.target||"draft-04"===t.target||"openapi-3.0"===t.target?{type:"string"}:{},pattern:e.source}))])}})(e,t,n);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,Lf(e,"_ZodString",{regex(...e){return this.check(function(e,t){return new Eu({check:"string_format",format:"regex",...lc(t),pattern:e})}(...e))},includes(...e){return this.check(function(e,t){return new ku({check:"string_format",format:"includes",...lc(t),includes:e})}(...e))},startsWith(...e){return this.check(function(e,t){return new Au({check:"string_format",format:"starts_with",...lc(t),prefix:e})}(...e))},endsWith(...e){return this.check(function(e,t){return new Iu({check:"string_format",format:"ends_with",...lc(t),suffix:e})}(...e))},min(...e){return this.check(rf(...e))},max(...e){return this.check(nf(...e))},length(...e){return this.check(of(...e))},nonempty(...e){return this.check(rf(1,...e))},lowercase(e){return this.check(function(e){return new xu({check:"string_format",format:"lowercase",...lc(e)})}(e))},uppercase(e){return this.check(function(e){return new _u({check:"string_format",format:"uppercase",...lc(e)})}(e))},trim(){return this.check(sf(e=>e.trim()))},normalize(...e){return this.check(function(e){return sf(t=>t.normalize(e))}(...e))},toLowerCase(){return this.check(sf(e=>e.toLowerCase()))},toUpperCase(){return this.check(sf(e=>e.toUpperCase()))},slugify(){return this.check(sf(e=>function(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}(e)))}})}),Zf=Da("ZodString",(e,t)=>{Ou.init(e,t),Df.init(e,t),e.email=t=>e.check(function(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...lc(t)})}(Gf,t)),e.url=t=>e.check(function(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...lc(t)})}(Kf,t)),e.jwt=t=>e.check(function(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...lc(t)})}(ud,t)),e.emoji=t=>e.check(function(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...lc(t)})}(Wf,t)),e.guid=t=>e.check(Jl(Hf,t)),e.uuid=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...lc(t)})}(Vf,t)),e.uuidv4=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...lc(t)})}(Vf,t)),e.uuidv6=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...lc(t)})}(Vf,t)),e.uuidv7=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...lc(t)})}(Vf,t)),e.nanoid=t=>e.check(function(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...lc(t)})}(Jf,t)),e.guid=t=>e.check(Jl(Hf,t)),e.cuid=t=>e.check(function(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...lc(t)})}(Xf,t)),e.cuid2=t=>e.check(function(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...lc(t)})}(Yf,t)),e.ulid=t=>e.check(function(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...lc(t)})}(Qf,t)),e.base64=t=>e.check(function(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...lc(t)})}(sd,t)),e.base64url=t=>e.check(function(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...lc(t)})}(ad,t)),e.xid=t=>e.check(function(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...lc(t)})}(ed,t)),e.ksuid=t=>e.check(function(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...lc(t)})}(td,t)),e.ipv4=t=>e.check(function(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...lc(t)})}(nd,t)),e.ipv6=t=>e.check(function(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...lc(t)})}(rd,t)),e.cidrv4=t=>e.check(function(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...lc(t)})}(od,t)),e.cidrv6=t=>e.check(function(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...lc(t)})}(id,t)),e.e164=t=>e.check(function(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...lc(t)})}(cd,t)),e.datetime=t=>e.check(yf(t)),e.date=t=>e.check(bf(t)),e.time=t=>e.check(Ef(t)),e.duration=t=>e.check(_f(t))});function jf(e){return function(e,t){return new e({type:"string",...lc(t)})}(Zf,e)}const qf=Da("ZodStringFormat",(e,t)=>{Tu.init(e,t),Df.init(e,t)}),Gf=Da("ZodEmail",(e,t)=>{Uu.init(e,t),qf.init(e,t)}),Hf=Da("ZodGUID",(e,t)=>{Nu.init(e,t),qf.init(e,t)}),Vf=Da("ZodUUID",(e,t)=>{Ru.init(e,t),qf.init(e,t)}),Kf=Da("ZodURL",(e,t)=>{Pu.init(e,t),qf.init(e,t)}),Wf=Da("ZodEmoji",(e,t)=>{Fu.init(e,t),qf.init(e,t)}),Jf=Da("ZodNanoID",(e,t)=>{Cu.init(e,t),qf.init(e,t)}),Xf=Da("ZodCUID",(e,t)=>{Lu.init(e,t),qf.init(e,t)}),Yf=Da("ZodCUID2",(e,t)=>{Mu.init(e,t),qf.init(e,t)}),Qf=Da("ZodULID",(e,t)=>{Du.init(e,t),qf.init(e,t)}),ed=Da("ZodXID",(e,t)=>{Zu.init(e,t),qf.init(e,t)}),td=Da("ZodKSUID",(e,t)=>{ju.init(e,t),qf.init(e,t)}),nd=Da("ZodIPv4",(e,t)=>{Ku.init(e,t),qf.init(e,t)}),rd=Da("ZodIPv6",(e,t)=>{Wu.init(e,t),qf.init(e,t)}),od=Da("ZodCIDRv4",(e,t)=>{Ju.init(e,t),qf.init(e,t)}),id=Da("ZodCIDRv6",(e,t)=>{Xu.init(e,t),qf.init(e,t)}),sd=Da("ZodBase64",(e,t)=>{Qu.init(e,t),qf.init(e,t)}),ad=Da("ZodBase64URL",(e,t)=>{el.init(e,t),qf.init(e,t)}),cd=Da("ZodE164",(e,t)=>{tl.init(e,t),qf.init(e,t)}),ud=Da("ZodJWT",(e,t)=>{nl.init(e,t),qf.init(e,t)}),ld=Da("ZodNumber",(e,t)=>{rl.init(e,t),Mf.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n)=>{const r=n,{minimum:o,maximum:i,format:s,multipleOf:a,exclusiveMaximum:c,exclusiveMinimum:u}=e._zod.bag;"string"==typeof s&&s.includes("int")?r.type="integer":r.type="number";const l="number"==typeof u&&u>=(o??Number.NEGATIVE_INFINITY),f="number"==typeof c&&c<=(i??Number.POSITIVE_INFINITY),d="draft-04"===t.target||"openapi-3.0"===t.target;l?d?(r.minimum=u,r.exclusiveMinimum=!0):r.exclusiveMinimum=u:"number"==typeof o&&(r.minimum=o),f?d?(r.maximum=c,r.exclusiveMaximum=!0):r.exclusiveMaximum=c:"number"==typeof i&&(r.maximum=i),"number"==typeof a&&(r.multipleOf=a)})(e,t,n),Lf(e,"ZodNumber",{gt(e,t){return this.check(Ql(e,t))},gte(e,t){return this.check(ef(e,t))},min(e,t){return this.check(ef(e,t))},lt(e,t){return this.check(Xl(e,t))},lte(e,t){return this.check(Yl(e,t))},max(e,t){return this.check(Yl(e,t))},int(e){return this.check(hd(e))},safe(e){return this.check(hd(e))},positive(e){return this.check(Ql(0,e))},nonnegative(e){return this.check(ef(0,e))},negative(e){return this.check(Xl(0,e))},nonpositive(e){return this.check(Yl(0,e))},multipleOf(e,t){return this.check(tf(e,t))},step(e,t){return this.check(tf(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 fd(e){return function(e,t){return new e({type:"number",checks:[],...lc(t)})}(ld,e)}const dd=Da("ZodNumberFormat",(e,t)=>{ol.init(e,t),ld.init(e,t)});function hd(e){return function(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...lc(t)})}(dd,e)}const pd=Da("ZodBoolean",(e,t)=>{il.init(e,t),Mf.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t,n)=>{n.type="boolean"})(0,0,t)});function md(e){return function(e,t){return new e({type:"boolean",...lc(t)})}(pd,e)}const gd=Da("ZodBigInt",(e,t)=>{sl.init(e,t),Mf.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t)=>{if("throw"===t.unrepresentable)throw new Error("BigInt cannot be represented in JSON Schema")})(0,e),e.gte=(t,n)=>e.check(ef(t,n)),e.min=(t,n)=>e.check(ef(t,n)),e.gt=(t,n)=>e.check(Ql(t,n)),e.gte=(t,n)=>e.check(ef(t,n)),e.min=(t,n)=>e.check(ef(t,n)),e.lt=(t,n)=>e.check(Xl(t,n)),e.lte=(t,n)=>e.check(Yl(t,n)),e.max=(t,n)=>e.check(Yl(t,n)),e.positive=t=>e.check(Ql(BigInt(0),t)),e.negative=t=>e.check(Xl(BigInt(0),t)),e.nonpositive=t=>e.check(Yl(BigInt(0),t)),e.nonnegative=t=>e.check(ef(BigInt(0),t)),e.multipleOf=(t,n)=>e.check(tf(t,n));const n=e._zod.bag;e.minValue=n.minimum??null,e.maxValue=n.maximum??null,e.format=n.format??null});function yd(e){return function(e,t){return new e({type:"bigint",...lc(t)})}(gd,e)}const wd=Da("ZodAny",(e,t)=>{al.init(e,t),Mf.init(e,t),e._zod.processJSONSchema=(e,t,n)=>{}});function bd(){return new wd({type:"any"})}const vd=Da("ZodUnknown",(e,t)=>{cl.init(e,t),Mf.init(e,t),e._zod.processJSONSchema=(e,t,n)=>{}});function Ed(){return new vd({type:"unknown"})}const xd=Da("ZodNever",(e,t)=>{ul.init(e,t),Mf.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t,n)=>{n.not={}})(0,0,t)});function _d(e){return function(e,t){return new e({type:"never",...lc(t)})}(xd,e)}const kd=Da("ZodArray",(e,t)=>{fl.init(e,t),Mf.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((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=uf(i.element,t,{...r,path:[...r.path,"items"]})})(e,t,n,r),e.element=t.element,Lf(e,"ZodArray",{min(e,t){return this.check(rf(e,t))},nonempty(e){return this.check(rf(1,e))},max(e,t){return this.check(nf(e,t))},length(e,t){return this.check(of(e,t))},unwrap(){return this.element}})});function Ad(e,t){return function(e,t,n){return new e({type:"array",element:t,...lc(n)})}(kd,e,t)}const Id=Da("ZodObject",(e,t)=>{gl.init(e,t),Mf.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=n,i=e._zod.def;o.type="object",o.properties={};const s=i.shape;for(const e in s)o.properties[e]=uf(s[e],t,{...r,path:[...r.path,"properties",e]});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=uf(i.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):"output"===t.io&&(o.additionalProperties=!1)})(e,t,n,r),Ya(e,"shape",()=>t.shape),Lf(e,"ZodObject",{keyof(){return Ud(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:Ed()})},loose(){return this.clone({...this._zod.def,catchall:Ed()})},strict(){return this.clone({...this._zod.def,catchall:_d()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return function(e,t){if(!ic(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=ec(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return Qa(this,"shape",n),n}});return uc(e,r)}(this,e)},safeExtend(e){return function(e,t){if(!ic(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=ec(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return Qa(this,"shape",n),n}});return uc(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=ec(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t._zod.def.shape};return Qa(this,"shape",n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return uc(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 uc(e,ec(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 Qa(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=ec(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 Qa(this,"shape",r),r},checks:[]});return uc(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=ec(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 Qa(this,"shape",o),o},checks:[]});return uc(t,o)}(Cd,this,e[0])},required(...e){return function(e,t,n){const r=ec(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 Qa(this,"shape",o),o}});return uc(t,r)}(Gd,this,e[0])}})});function $d(e,t){const n={type:"object",shape:e??{},...lc(t)};return new Id(n)}const Bd=Da("ZodUnion",(e,t)=>{wl.init(e,t),Mf.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def,i=!1===o.inclusive,s=o.options.map((e,n)=>uf(e,t,{...r,path:[...r.path,i?"oneOf":"anyOf",n]}));i?n.oneOf=s:n.anyOf=s})(e,t,n,r),e.options=t.options});const Sd=Da("ZodIntersection",(e,t)=>{bl.init(e,t),Mf.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def,i=uf(o.left,t,{...r,path:[...r.path,"allOf",0]}),s=uf(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})(e,t,n,r)});const zd=Da("ZodTuple",(e,t)=>{xl.init(e,t),Mf.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((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)=>uf(e,t,{...r,path:[...r.path,s,n]})),u=i.rest?uf(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)})(e,t,n,r),e.rest=t=>e.clone({...e._zod.def,rest:t})});function Od(e,t,n){const r=t instanceof zu;return new zd({type:"tuple",items:e,rest:r?t:null,...lc(r?n:t)})}const Td=Da("ZodRecord",(e,t)=>{Il.init(e,t),Mf.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((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=uf(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=uf(i.keyType,t,{...r,path:[...r.path,"propertyNames"]})),o.additionalProperties=uf(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)}})(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function Nd(e,t,n){return t&&t._zod?new Td({type:"record",keyType:e,valueType:t,...lc(n)}):new Td({type:"record",keyType:jf(),valueType:e,...lc(t)})}const Rd=Da("ZodEnum",(e,t)=>{$l.init(e,t),Mf.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n)=>{const r=Ha(e._zod.def.entries);r.every(e=>"number"==typeof e)&&(n.type="number"),r.every(e=>"string"==typeof e)&&(n.type="string"),n.enum=r})(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 r of e){if(!n.has(r))throw new Error(`Key ${r} not found in enum`);o[r]=t.entries[r]}return new Rd({...t,checks:[],...lc(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 Rd({...t,checks:[],...lc(r),entries:o})}});function Ud(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new Rd({type:"enum",entries:n,...lc(t)})}const Pd=Da("ZodLiteral",(e,t)=>{Bl.init(e,t),Mf.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n)=>{const r=e._zod.def,o=[];for(const e of r.values)if(void 0===e){if("throw"===t.unrepresentable)throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if("bigint"==typeof e){if("throw"===t.unrepresentable)throw new Error("BigInt literals cannot be represented in JSON Schema");o.push(Number(e))}else o.push(e);if(0===o.length);else if(1===o.length){const e=o[0];n.type=null===e?"null":typeof e,"draft-04"===t.target||"openapi-3.0"===t.target?n.enum=[e]:n.const=e}else o.every(e=>"number"==typeof e)&&(n.type="number"),o.every(e=>"string"==typeof e)&&(n.type="string"),o.every(e=>"boolean"==typeof e)&&(n.type="boolean"),o.every(e=>null===e)&&(n.type="null"),n.enum=o})(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 Fd=Da("ZodTransform",(e,t)=>{Sl.init(e,t),Mf.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t)=>{if("throw"===t.unrepresentable)throw new Error("Transforms cannot be represented in JSON Schema")})(0,e),e._zod.parse=(n,r)=>{if("backward"===r.direction)throw new ja(e.constructor.name);n.addIssue=r=>{if("string"==typeof r)n.issues.push(wc(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(wc(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)}});const Cd=Da("ZodOptional",(e,t)=>{Ol.init(e,t),Mf.init(e,t),e._zod.processJSONSchema=(t,n,r)=>mf(e,t,0,r),e.unwrap=()=>e._zod.def.innerType});function Ld(e){return new Cd({type:"optional",innerType:e})}const Md=Da("ZodExactOptional",(e,t)=>{Tl.init(e,t),Mf.init(e,t),e._zod.processJSONSchema=(t,n,r)=>mf(e,t,0,r),e.unwrap=()=>e._zod.def.innerType});const Dd=Da("ZodNullable",(e,t)=>{Nl.init(e,t),Mf.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def,i=uf(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"}]})(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Zd(e){return new Dd({type:"nullable",innerType:e})}const jd=Da("ZodDefault",(e,t)=>{Rl.init(e,t),Mf.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def;uf(o.innerType,t,r),t.seen.get(e).ref=o.innerType,n.default=JSON.parse(JSON.stringify(o.defaultValue))})(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});const qd=Da("ZodPrefault",(e,t)=>{Pl.init(e,t),Mf.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def;uf(o.innerType,t,r),t.seen.get(e).ref=o.innerType,"input"===t.io&&(n._prefault=JSON.parse(JSON.stringify(o.defaultValue)))})(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});const Gd=Da("ZodNonOptional",(e,t)=>{Fl.init(e,t),Mf.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def;uf(o.innerType,t,r),t.seen.get(e).ref=o.innerType})(e,t,0,r),e.unwrap=()=>e._zod.def.innerType});const Hd=Da("ZodCatch",(e,t)=>{Ll.init(e,t),Mf.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def;let i;uf(o.innerType,t,r),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})(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});const Vd=Da("ZodPipe",(e,t)=>{Ml.init(e,t),Mf.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((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;uf(s,t,r),t.seen.get(e).ref=s})(e,t,0,r),e.in=t.in,e.out=t.out});function Kd(e,t){return new Vd({type:"pipe",in:e,out:t})}const Wd=Da("ZodReadonly",(e,t)=>{Zl.init(e,t),Mf.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def;uf(o.innerType,t,r),t.seen.get(e).ref=o.innerType,n.readOnly=!0})(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});const Jd=Da("ZodFunction",(e,t)=>{ql.init(e,t),Mf.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t)=>{if("throw"===t.unrepresentable)throw new Error("Function types cannot be represented in JSON Schema")})(0,e)});const Xd=Da("ZodCustom",(e,t)=>{Gl.init(e,t),Mf.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t)=>{if("throw"===t.unrepresentable)throw new Error("Custom types cannot be represented in JSON Schema")})(0,e)});function Yd(e){return function(e,t){return new e({type:"number",coerce:!0,checks:[],...lc(t)})}(ld,e)}const Qd=$d({issuer:jf().transform(e=>ps(e)),index:jf().transform(e=>ps(e)),timestamp:jf().transform(e=>ps(e)),signature:jf().transform(e=>ps(e))});var eh,th,nh,rh,oh,ih={exports:{}};function sh(){if(th)return eh;th=1;var e=1e3,t=60*e,n=60*t,r=24*n,o=7*r,i=365.25*r;function s(e,t,n,r){var o=t>=1.5*n;return Math.round(e/n)+" "+r+(o?"s":"")}return eh=function(a,c){c=c||{};var u=typeof a;if("string"===u&&a.length>0)return function(s){if((s=String(s)).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(s);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*i;case"weeks":case"week":case"w":return c*o;case"days":case"day":case"d":return c*r;case"hours":case"hour":case"hrs":case"hr":case"h":return c*n;case"minutes":case"minute":case"mins":case"min":case"m":return c*t;case"seconds":case"second":case"secs":case"sec":case"s":return c*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return c;default:return}}(a);if("number"===u&&isFinite(a))return c.long?function(o){var i=Math.abs(o);if(i>=r)return s(o,i,r,"day");if(i>=n)return s(o,i,n,"hour");if(i>=t)return s(o,i,t,"minute");if(i>=e)return s(o,i,e,"second");return o+" ms"}(a):function(o){var i=Math.abs(o);if(i>=r)return Math.round(o/r)+"d";if(i>=n)return Math.round(o/n)+"h";if(i>=t)return Math.round(o/t)+"m";if(i>=e)return Math.round(o/e)+"s";return o+"ms"}(a);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(a))}}var ah=(oh||(oh=1,function(e,t){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(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")||t.storage.getItem("DEBUG")}catch(e){}return!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG),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=(rh||(rh=1,nh=function(e){function t(e){let r,o,i,s=null;function a(...e){if(!a.enabled)return;const n=a,o=Number(new Date),i=o-(r||o);n.diff=i,n.prev=r,n.curr=o,r=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,(r,o)=>{if("%%"===r)return"%";s++;const i=t.formatters[o];if("function"==typeof i){const t=e[s];r=i.call(n,t),e.splice(s,1),s--}return r}),t.formatArgs.call(n,e),(n.log||t.log).apply(n,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=n,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 n(e,n){const r=t(this.namespace+(void 0===n?":":n)+e);return r.log=this.log,r}function r(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){return e instanceof Error?e.stack||e.message: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 e of n)"-"===e[0]?t.skips.push(e.slice(1)):t.names.push(e)},t.enabled=function(e){for(const n of t.skips)if(r(e,n))return!1;for(const n of t.names)if(r(e,n))return!0;return!1},t.humanize=sh(),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}),nh)(t);const{formatters:n}=e.exports;n.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(ih,ih.exports)),ih.exports);const ch=Vr(ah)("bee-js:http"),uh={headers:{accept:"application/json, text/plain, */*"}};async function lh(e,t){const n=t.data,r=Jr.Objects.deepMerge3(uh,{...t,data:void 0},e);if(r.data=n,e.signal&&(r.signal=e.signal),function(e){if(void 0===e.data)return;const t=e.data;if(null!==t&&"object"==typeof t&&t.constructor===Object||Array.isArray(t))e.body=JSON.stringify(t),e.headers={"content-type":"application/json",...e.headers};else{e.body=t,e.duplex="half";const n=t instanceof Blob&&t.type?t.type:"application/octet-stream";e.headers={"content-type":n,...e.headers}}}(r),r.params)for(const e of Object.keys(r.params))void 0===r.params[e]&&delete r.params[e];const o=function(e){let t=Jr.Strings.joinUrl([e.baseURL??"",e.url??""]);if(e.params){const n=new URLSearchParams(Object.entries(e.params).filter(([,e])=>void 0!==e).map(([e,t])=>[e,String(t)])).toString();n&&(t+=`?${n}`)}return t}(r),i=(r.method||"GET").toUpperCase();r.method=i,e.onRequest?.({method:i,url:Jr.Strings.joinUrl([r.baseURL??"",r.url??""]),headers:{...r.headers},params:r.params});let s=0;for(;s<1e5;)try{ch(`${i} ${o}`,{headers:r.headers,params:r.params});const e=await fetch(o,r);return e.ok||await fh(i,o,e,r.responseType),hh(e,r.responseType)}catch(t){if(t instanceof wh)throw t;const n=t;if("TimeoutError"!==n.name||!e.endlesslyRetry)throw dh(n,i,o);s++,await Jr.System.sleepMillis(s<300?200:1e3)}throw Error("Max number of failed attempts reached")}async function fh(e,t,n,r){const o=await hh(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 wh(e,t,s,o.data,n.status,n.statusText)}function dh(e,t,n){if("AbortError"===e.name)return new wh(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 wh(t,n,o)}async function hh(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 ph=$d({durationSeconds:fd()}),mh=$d({reference:jf().transform(e=>new Xs(e))});class gh extends Error{constructor(e){super(e)}}class yh extends gh{constructor(e,t){super(e),this.value=t}}class wh extends gh{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 bh{constructor(e){this.seconds=Math.ceil(e),e<0&&(this.seconds=0)}static fromMilliseconds(e){return new bh(e/1e3)}static fromSeconds(e){return new bh(e)}static fromHours(e){return new bh(60*e*60)}static fromDays(e){return new bh(24*e*60*60)}static fromWeeks(e){return new bh(7*e*24*60*60)}static fromYears(e){return new bh(365*e*24*60*60)}static fromEndDate(e,t){return new bh((e.getTime()-(t??new Date).getTime())/1e3)}static parseFromString(e){return bh.fromSeconds(Jr.Dates.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 Jr.Dates.secondsToHumanTime(this.seconds)}isZero(){return 0===this.seconds}}bh.ZERO=new bh(0);class vh{constructor(e){this.state=e}static fromDecimalString(e){return new vh(Jr.FixedPointNumber.fromDecimalString(e,vh.DIGITS))}static fromPLUR(e){return new vh(new Jr.FixedPointNumber(e,vh.DIGITS))}static fromFloat(e){return new vh(Jr.FixedPointNumber.fromFloat(e,vh.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 vh(this.state.add(e instanceof vh?e.state:new Jr.FixedPointNumber(e,vh.DIGITS)))}minus(e){return new vh(this.state.subtract(e instanceof vh?e.state:new Jr.FixedPointNumber(e,vh.DIGITS)))}divide(e){return new vh(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 Eh.fromWei(this.state.exchange("*",new Jr.FixedPointNumber(e.toWeiBigInt(),Eh.DIGITS),Eh.DIGITS).value)}}vh.DIGITS=16;class Eh{constructor(e){this.state=e}static fromDecimalString(e){return new Eh(Jr.FixedPointNumber.fromDecimalString(e,Eh.DIGITS))}static fromWei(e){return new Eh(new Jr.FixedPointNumber(e,Eh.DIGITS))}static fromFloat(e){return new Eh(Jr.FixedPointNumber.fromFloat(e,Eh.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 Eh(this.state.add(e instanceof Eh?e.state:new Jr.FixedPointNumber(e,Eh.DIGITS)))}minus(e){return new Eh(this.state.subtract(e instanceof Eh?e.state:new Jr.FixedPointNumber(e,Eh.DIGITS)))}divide(e){return new Eh(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 vh.fromPLUR(this.state.exchange("/",new Jr.FixedPointNumber(e.toWeiBigInt(),Eh.DIGITS),vh.DIGITS).value)}}function xh(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)}async function _h(e){return e.arrayBuffer?e.arrayBuffer():new Promise(t=>{const n=new FileReader;n.onload=()=>t(n.result),n.readAsArrayBuffer(e)})}var kh;function Ah(e){switch(e){case"full":return kh.FULL;case"light":return kh.LIGHT;case"ultra-light":return kh.ULTRA_LIGHT;case"dev":return kh.DEV;default:throw new Error(`Unknown Bee mode: ${e}`)}}Eh.DIGITS=18,function(e){e.FULL="full",e.LIGHT="light",e.ULTRA_LIGHT="ultra-light",e.DEV="dev"}(kh||(kh={}));const Ih=4096,$h=17,Bh=255;var Sh,zh;!function(e){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"}(Sh||(Sh={})),function(e){e[e.NONE=0]="NONE",e[e.DATA=1]="DATA",e[e.PROX=2]="PROX",e[e.RACE=3]="RACE"}(zh||(zh={})),Sh.OFF,Sh.MEDIUM,Sh.STRONG,Sh.INSANE,Sh.PARANOID,Sh.OFF,Sh.MEDIUM,Sh.STRONG,Sh.INSANE,Sh.PARANOID,jf().regex(/^(?:0x)?[0-9a-fA-F]*$/i,"expected hex string").refine(e=>e.replace(/^0x/i,"").length%2==0,"expected even-length hex string");const Oh=bd().refine(e=>{return new Jd({type:"function",input:Array.isArray(t?.input)?Od(t?.input):Ad(Ed()),output:Ed()}).safeParse(e).success;var t},"expected a function"),Th=bd().transform(e=>(yd().safeParse(e).success&&(e=String(e)),jf().regex(/^-?\d+$/,"expected integer string").parse(e))),Nh=bd().transform(e=>(yd().safeParse(e).success&&(e=String(e)),jf().regex(/^\d+$/,"expected non-negative integer string").parse(e))),Rh=$d({baseURL:jf().optional(),timeout:fd().int().min(0).optional(),headers:Nd(jf(),jf()).optional(),onRequest:Oh.optional(),httpAgent:Ed().optional(),httpsAgent:Ed().optional(),endlesslyRetry:md().optional(),signal:bd().optional()}),Uh=$d({redundancyStrategy:fd().int().optional(),fallback:md().optional(),timeoutMs:fd().int().min(0).optional(),actPublisher:Ld(bd().transform(e=>new Gs(e))),actHistoryAddress:Ld(bd().transform(e=>new Xs(e))),actTimestamp:Yd().optional()}),Ph=$d({act:md().optional(),actHistoryAddress:Ld(bd().transform(e=>new Xs(e))),deferred:md().optional(),encrypt:md().optional(),pin:md().optional(),tag:fd().int().min(0).optional()}),Fh=Ph.extend({redundancyLevel:fd().int().min(0).optional()}),Ch=Ph.extend({size:fd().int().min(0).optional(),contentType:jf().optional(),redundancyLevel:fd().int().min(0).optional()}),Lh=Ph.extend({errorDocument:jf().optional(),indexDocument:jf().optional(),redundancyLevel:fd().int().min(0).optional()}),Mh=$d({uid:fd().int()}),Dh=Yd().min(0),Zh=$d({onMessage:Oh,onError:Oh,onClose:Oh}),jh=$d({onMessage:Oh,onError:Oh,onClose:Oh}),qh=$d({gasPrice:Th.optional(),immutableFlag:md().optional(),label:jf().optional(),waitForUsable:md().optional(),waitForUsableTimeout:fd().int().min(0).optional()}),Gh=$d({gasLimit:Nh.optional(),gasPrice:Nh.optional()}),Hh=$d({limit:fd().int().min(1).max(1e3).optional(),offset:fd().int().min(0).optional()});function Vh(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 Kh(e){if("string"!=typeof e&&!(e instanceof Uint8Array)&&!(e instanceof Blob))throw new TypeError("Data must be either string, Uint8Array, Blob or Readable!")}function Wh(e){if("string"!=typeof e&&!(e instanceof Uint8Array)&&!xh(e))throw new TypeError("Data must be either string, Readable, Uint8Array or File!")}function Jh(e){if(null==e)throw new TypeError(`Expected number | Tag | string from tagUid, got: ${e}`);if(t=e,Mh.safeParse(t).success)return e.uid;if("number"==typeof e||"string"==typeof e)return Dh.parse(e);var t;throw new TypeError(`Expected number | Tag | string from tagUid, got: ${e}`)}function Xh(e){return Number.isInteger(e)?e<1?1:e>3155695200?3155695200:e:1}const Yh=$d({peer:jf(),balance:jf().transform(e=>vh.fromPLUR(Vh(e,{name:"balance"})))}),Qh=$d({balances:Ad(Yh)}),ep=Yh,tp=$d({beneficiary:jf().transform(e=>new Fs(e)),chequebook:jf().transform(e=>new Fs(e)),payout:jf().transform(e=>vh.fromPLUR(Vh(e,{name:"payout"})))}),np=$d({recipient:jf(),lastPayout:jf().transform(e=>vh.fromPLUR(Vh(e,{name:"lastPayout"}))),bounced:md()}),rp=$d({chequebookAddress:jf().transform(e=>new Fs(e))}),op=$d({availableBalance:jf().transform(e=>vh.fromPLUR(Vh(e,{name:"availableBalance"}))),totalBalance:jf().transform(e=>vh.fromPLUR(Vh(e,{name:"totalBalance"})))}),ip=$d({peer:jf(),uncashedAmount:jf().transform(e=>vh.fromPLUR(Vh(e,{name:"uncashedAmount"}))),transactionHash:jf().nullish().transform(e=>e??null),lastCashedCheque:tp.nullish().transform(e=>e??null),result:np.nullish().transform(e=>e??null)}),sp=$d({peer:jf(),lastreceived:tp.nullish().transform(e=>e??null),lastsent:tp.nullish().transform(e=>e??null)}),ap=$d({lastcheques:Ad($d({peer:jf(),lastreceived:tp.nullish().transform(e=>e??null),lastsent:tp.nullish().transform(e=>e??null)}))}),cp=$d({transactionHash:jf().transform(e=>new ta(e))}),up=$d({address:jf(),fullNode:md()}),lp=$d({population:fd(),connected:fd(),connectedPeers:Ad($d({address:jf()})).nullish().transform(e=>e??[]),disconnectedPeers:Ad($d({address:jf()})).nullish().transform(e=>e??[])}),fp=Nd(jf(),lp),dp=$d({overlay:jf().transform(e=>new Zs(e)),underlay:Ad(jf()),ethereum:jf().transform(e=>new Fs(e)),publicKey:jf().transform(e=>new Gs(e)),pssPublicKey:jf().transform(e=>new Gs(e))}),hp=$d({peers:Ad(up)}),pp=$d({peers:Ad(up)}),mp=$d({baseAddr:jf(),population:fd(),connected:fd(),timestamp:jf(),nnLowWatermark:fd(),depth:fd(),reachability:jf(),networkAvailability:jf(),bins:fp}),gp=$d({overlay:jf(),proximity:fd(),beeMode:jf().transform(Ah),reserveSize:fd(),reserveSizeWithinRadius:fd(),pullsyncRate:fd(),storageRadius:fd(),connectedPeers:fd(),neighborhoodSize:fd(),batchCommitment:fd(),isReachable:md(),lastSyncedBlock:fd(),committedDepth:fd(),isWarmingUp:md()}),yp=$d({apiVersion:jf(),version:jf(),status:(wp="ok",new Pd({type:"literal",values:Array.isArray(wp)?wp:[wp],...lc(bp)}))});var wp,bp;const vp=$d({apiVersion:jf(),version:jf(),status:Ud(["ready","notReady"])}),Ep=$d({beeMode:jf().transform(Ah),chequebookEnabled:md(),swapEnabled:md()}),xp=$d({gateway:md()}),_p=$d({isRetrievable:md()}),kp=Ad(jf().transform(e=>new Gs(e))),Ap=$d({ref:jf().transform(e=>new Xs(e)),historyref:jf().transform(e=>new Xs(e))});var Ip=null;"undefined"!=typeof WebSocket?Ip=WebSocket:"undefined"!=typeof MozWebSocket?Ip=MozWebSocket:"undefined"!=typeof global?Ip=global.WebSocket||global.MozWebSocket:"undefined"!=typeof window?Ip=window.WebSocket||window.MozWebSocket:"undefined"!=typeof self&&(Ip=self.WebSocket||self.MozWebSocket);var $p=Ip;const Bp=$d({references:Ad(jf()).nullable()}),Sp=$d({peer:jf(),sent:jf().transform(e=>vh.fromPLUR(Vh(e,{name:"sent"}))),received:jf().transform(e=>vh.fromPLUR(Vh(e,{name:"received"})))}),zp=Sp,Op=$d({totalSent:jf().transform(e=>vh.fromPLUR(Vh(e,{name:"totalSent"}))),totalReceived:jf().transform(e=>vh.fromPLUR(Vh(e,{name:"totalReceived"}))),settlements:Ad(Sp)}),Tp=$d({stakedAmount:jf().transform(e=>vh.fromPLUR(Vh(e,{name:"stakedAmount"})))}),Np=$d({withdrawableAmount:jf().transform(e=>vh.fromPLUR(Vh(e,{name:"withdrawableAmount"})))}),Rp=$d({txHash:jf().transform(e=>new ta(e))}),Up=$d({minimumGasFunds:jf().transform(e=>Eh.fromWei(Vh(e,{name:"minimumGasFunds"}))),hasSufficientFunds:md(),isFrozen:md(),isFullySynced:md(),phase:jf(),round:fd(),lastWonRound:fd(),lastPlayedRound:fd(),lastFrozenRound:fd(),lastSelectedRound:fd(),lastSampleDurationSeconds:fd(),block:fd(),reward:jf().transform(e=>vh.fromPLUR(Vh(e,{name:"reward"}))),fees:jf().transform(e=>Eh.fromWei(Vh(e,{name:"fees"}))),isHealthy:md()}),Pp=$d({batchID:jf(),utilization:fd(),utilizationRatio:fd().optional(),usable:md(),label:jf(),depth:fd(),amount:jf(),bucketDepth:fd(),blockNumber:fd(),immutableFlag:md(),batchTTL:fd()}),Fp=$d({batchID:jf().transform(e=>new Ns(e)),batchTTL:fd(),bucketDepth:fd(),depth:fd(),immutable:md(),owner:jf().transform(e=>new Fs(e)),start:fd(),value:jf().transform(e=>Vh(e,{name:"value"}))}),Cp=$d({batches:Ad(Fp)}),Lp=$d({stamps:Ad(Pp)}),Mp=Pp,Dp=$d({depth:fd(),bucketDepth:fd(),bucketUpperBound:fd(),buckets:Ad($d({bucketID:fd(),collisions:fd()}))}),Zp=$d({batchID:jf().transform(e=>new Ns(e))});var jp,qp,Gp,Hp;function Vp(){if(qp)return jp;qp=1;const e="object"==typeof process&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...e)=>console.error("SEMVER",...e):()=>{};return jp=e}function Kp(){if(Hp)return Gp;Hp=1;const e=Number.MAX_SAFE_INTEGER||9007199254740991;return Gp={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:16,MAX_SAFE_BUILD_LENGTH:250,MAX_SAFE_INTEGER:e,RELEASE_TYPES:["major","premajor","minor","preminor","patch","prepatch","prerelease"],SEMVER_SPEC_VERSION:"2.0.0",FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}}var Wp,Jp,Xp,Yp,Qp,em,tm,nm,rm,om={exports:{}};function im(){return Wp||(Wp=1,function(e,t){const{MAX_SAFE_COMPONENT_LENGTH:n,MAX_SAFE_BUILD_LENGTH:r,MAX_LENGTH:o}=Kp(),i=Vp(),s=(t=e.exports={}).re=[],a=t.safeRe=[],c=t.src=[],u=t.safeSrc=[],l=t.t={};let f=0;const d="[a-zA-Z0-9-]",h=[["\\s",1],["\\d",o],[d,r]],p=(e,t,n)=>{const r=(e=>{for(const[t,n]of h)e=e.split(`${t}*`).join(`${t}{0,${n}}`).split(`${t}+`).join(`${t}{1,${n}}`);return e})(t),o=f++;i(e,o,t),l[e]=o,c[o]=t,u[o]=r,s[o]=new RegExp(t,n?"g":void 0),a[o]=new RegExp(r,n?"g":void 0)};p("NUMERICIDENTIFIER","0|[1-9]\\d*"),p("NUMERICIDENTIFIERLOOSE","\\d+"),p("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${d}*`),p("MAINVERSION",`(${c[l.NUMERICIDENTIFIER]})\\.(${c[l.NUMERICIDENTIFIER]})\\.(${c[l.NUMERICIDENTIFIER]})`),p("MAINVERSIONLOOSE",`(${c[l.NUMERICIDENTIFIERLOOSE]})\\.(${c[l.NUMERICIDENTIFIERLOOSE]})\\.(${c[l.NUMERICIDENTIFIERLOOSE]})`),p("PRERELEASEIDENTIFIER",`(?:${c[l.NONNUMERICIDENTIFIER]}|${c[l.NUMERICIDENTIFIER]})`),p("PRERELEASEIDENTIFIERLOOSE",`(?:${c[l.NONNUMERICIDENTIFIER]}|${c[l.NUMERICIDENTIFIERLOOSE]})`),p("PRERELEASE",`(?:-(${c[l.PRERELEASEIDENTIFIER]}(?:\\.${c[l.PRERELEASEIDENTIFIER]})*))`),p("PRERELEASELOOSE",`(?:-?(${c[l.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${c[l.PRERELEASEIDENTIFIERLOOSE]})*))`),p("BUILDIDENTIFIER",`${d}+`),p("BUILD",`(?:\\+(${c[l.BUILDIDENTIFIER]}(?:\\.${c[l.BUILDIDENTIFIER]})*))`),p("FULLPLAIN",`v?${c[l.MAINVERSION]}${c[l.PRERELEASE]}?${c[l.BUILD]}?`),p("FULL",`^${c[l.FULLPLAIN]}$`),p("LOOSEPLAIN",`[v=\\s]*${c[l.MAINVERSIONLOOSE]}${c[l.PRERELEASELOOSE]}?${c[l.BUILD]}?`),p("LOOSE",`^${c[l.LOOSEPLAIN]}$`),p("GTLT","((?:<|>)?=?)"),p("XRANGEIDENTIFIERLOOSE",`${c[l.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),p("XRANGEIDENTIFIER",`${c[l.NUMERICIDENTIFIER]}|x|X|\\*`),p("XRANGEPLAIN",`[v=\\s]*(${c[l.XRANGEIDENTIFIER]})(?:\\.(${c[l.XRANGEIDENTIFIER]})(?:\\.(${c[l.XRANGEIDENTIFIER]})(?:${c[l.PRERELEASE]})?${c[l.BUILD]}?)?)?`),p("XRANGEPLAINLOOSE",`[v=\\s]*(${c[l.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[l.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[l.XRANGEIDENTIFIERLOOSE]})(?:${c[l.PRERELEASELOOSE]})?${c[l.BUILD]}?)?)?`),p("XRANGE",`^${c[l.GTLT]}\\s*${c[l.XRANGEPLAIN]}$`),p("XRANGELOOSE",`^${c[l.GTLT]}\\s*${c[l.XRANGEPLAINLOOSE]}$`),p("COERCEPLAIN",`(^|[^\\d])(\\d{1,${n}})(?:\\.(\\d{1,${n}}))?(?:\\.(\\d{1,${n}}))?`),p("COERCE",`${c[l.COERCEPLAIN]}(?:$|[^\\d])`),p("COERCEFULL",c[l.COERCEPLAIN]+`(?:${c[l.PRERELEASE]})?`+`(?:${c[l.BUILD]})?(?:$|[^\\d])`),p("COERCERTL",c[l.COERCE],!0),p("COERCERTLFULL",c[l.COERCEFULL],!0),p("LONETILDE","(?:~>?)"),p("TILDETRIM",`(\\s*)${c[l.LONETILDE]}\\s+`,!0),t.tildeTrimReplace="$1~",p("TILDE",`^${c[l.LONETILDE]}${c[l.XRANGEPLAIN]}$`),p("TILDELOOSE",`^${c[l.LONETILDE]}${c[l.XRANGEPLAINLOOSE]}$`),p("LONECARET","(?:\\^)"),p("CARETTRIM",`(\\s*)${c[l.LONECARET]}\\s+`,!0),t.caretTrimReplace="$1^",p("CARET",`^${c[l.LONECARET]}${c[l.XRANGEPLAIN]}$`),p("CARETLOOSE",`^${c[l.LONECARET]}${c[l.XRANGEPLAINLOOSE]}$`),p("COMPARATORLOOSE",`^${c[l.GTLT]}\\s*(${c[l.LOOSEPLAIN]})$|^$`),p("COMPARATOR",`^${c[l.GTLT]}\\s*(${c[l.FULLPLAIN]})$|^$`),p("COMPARATORTRIM",`(\\s*)${c[l.GTLT]}\\s*(${c[l.LOOSEPLAIN]}|${c[l.XRANGEPLAIN]})`,!0),t.comparatorTrimReplace="$1$2$3",p("HYPHENRANGE",`^\\s*(${c[l.XRANGEPLAIN]})\\s+-\\s+(${c[l.XRANGEPLAIN]})\\s*$`),p("HYPHENRANGELOOSE",`^\\s*(${c[l.XRANGEPLAINLOOSE]})\\s+-\\s+(${c[l.XRANGEPLAINLOOSE]})\\s*$`),p("STAR","(<|>)?=?\\s*\\*"),p("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$"),p("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")}(om,om.exports)),om.exports}function sm(){if(tm)return em;tm=1;const e=Vp(),{MAX_LENGTH:t,MAX_SAFE_INTEGER:n}=Kp(),{safeRe:r,t:o}=im(),i=function(){if(Xp)return Jp;Xp=1;const e=Object.freeze({loose:!0}),t=Object.freeze({});return Jp=n=>n?"object"!=typeof n?e:n:t}(),{compareIdentifiers:s}=function(){if(Qp)return Yp;Qp=1;const e=/^[0-9]+$/,t=(t,n)=>{if("number"==typeof t&&"number"==typeof n)return t===n?0:t<n?-1:1;const r=e.test(t),o=e.test(n);return r&&o&&(t=+t,n=+n),t===n?0:r&&!o?-1:o&&!r?1:t<n?-1:1};return Yp={compareIdentifiers:t,rcompareIdentifiers:(e,n)=>t(n,e)}}();class a{constructor(s,c){if(c=i(c),s instanceof a){if(s.loose===!!c.loose&&s.includePrerelease===!!c.includePrerelease)return s;s=s.version}else if("string"!=typeof s)throw new TypeError(`Invalid version. Must be a string. Got type "${typeof s}".`);if(s.length>t)throw new TypeError(`version is longer than ${t} characters`);e("SemVer",s,c),this.options=c,this.loose=!!c.loose,this.includePrerelease=!!c.includePrerelease;const u=s.trim().match(c.loose?r[o.LOOSE]:r[o.FULL]);if(!u)throw new TypeError(`Invalid Version: ${s}`);if(this.raw=s,this.major=+u[1],this.minor=+u[2],this.patch=+u[3],this.major>n||this.major<0)throw new TypeError("Invalid major version");if(this.minor>n||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>n||this.patch<0)throw new TypeError("Invalid patch version");u[4]?this.prerelease=u[4].split(".").map(e=>{if(/^[0-9]+$/.test(e)){const t=+e;if(t>=0&&t<n)return t}return e}):this.prerelease=[],this.build=u[5]?u[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(t){if(e("SemVer.compare",this.version,this.options,t),!(t instanceof a)){if("string"==typeof t&&t===this.version)return 0;t=new a(t,this.options)}return t.version===this.version?0:this.compareMain(t)||this.comparePre(t)}compareMain(e){return e instanceof a||(e=new a(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(t){if(t instanceof a||(t=new a(t,this.options)),this.prerelease.length&&!t.prerelease.length)return-1;if(!this.prerelease.length&&t.prerelease.length)return 1;if(!this.prerelease.length&&!t.prerelease.length)return 0;let n=0;do{const r=this.prerelease[n],o=t.prerelease[n];if(e("prerelease compare",n,r,o),void 0===r&&void 0===o)return 0;if(void 0===o)return 1;if(void 0===r)return-1;if(r!==o)return s(r,o)}while(++n)}compareBuild(t){t instanceof a||(t=new a(t,this.options));let n=0;do{const r=this.build[n],o=t.build[n];if(e("build compare",n,r,o),void 0===r&&void 0===o)return 0;if(void 0===o)return 1;if(void 0===r)return-1;if(r!==o)return s(r,o)}while(++n)}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?r[o.PRERELEASELOOSE]:r[o.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 t=0;t<n.length;t++)if(0!==s(e[t],n[t]))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}}return em=a}var am=Vr(function(){if(rm)return nm;rm=1;const e=sm();return nm=(t,n)=>new e(t,n).major}());const cm="2.8.1-7cf53193";cm.split("-")[0];const um="8.1.0",lm=$d({commitment:fd(),radius:fd(),storageRadius:fd(),reserveCapacityDoubling:fd()}),fm=$d({block:fd(),chainTip:fd(),totalAmount:jf().transform(e=>Vh(e,{name:"totalAmount"})),currentPrice:jf().transform(Number).transform(e=>{return t=e,Number.isInteger(t)?t<24e3?24e3:t:24e3;var t}),minimumValidityBlocks:fd().optional()}),dm=$d({bzzBalance:jf().transform(e=>vh.fromPLUR(Vh(e,{name:"bzzBalance"}))),nativeTokenBalance:jf().transform(e=>Eh.fromWei(Vh(e,{name:"nativeTokenBalance"}))),chainID:fd(),chequebookContractAddress:jf(),walletAddress:jf()}),hm=$d({transactionHash:jf().transform(e=>new ta(e))}),pm=$d({address:jf().nullish().transform(e=>e??""),seen:fd(),sent:fd(),split:fd(),startedAt:jf(),stored:fd(),synced:fd(),uid:fd()}),mm=$d({tags:Ad(pm)}),gm=$d({transactionHash:jf().transform(e=>new ta(e)),to:jf(),nonce:fd(),gasPrice:jf().transform(e=>Vh(e,{name:"gasPrice"})),gasLimit:fd(),data:jf(),created:jf(),description:jf(),value:jf().transform(e=>Vh(e,{name:"value"}))}),ym=$d({pendingTransactions:Ad(gm)}),wm=gm,bm=$d({transactionHash:jf().transform(e=>new ta(e))});new Ns("0000000000000000000000000000000000000000000000000000000000000000"),new ea("0000000000000000000000000000000000000000000000000000000000000000");const vm=new Uint8Array(32);function Em(e){return e.endsWith("/")?e.slice(0,-1):e}function xm(e){try{const{protocol:t}=new URL(e);return"http:"===t||"https:"===t}catch{return!1}}function _m(e){if(!xm(e)||/[\s?#]/.test(e))return!1;const{username:t,password:n}=new URL(e);return""===t&&""===n}function km(e,t,n,r){const o=new URLSearchParams;return o.set("origin",t),n&&(o.set("appName",n.name),n.description&&o.set("appDescription",n.description),n.icon&&o.set("appIcon",n.icon)),r?.challenge&&o.set("challenge",r.challenge),`${e}/connect#${o.toString()}`}function Am(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`Wrong positive integer: ${e}`)}function Im(e,...t){if(!(e instanceof Uint8Array))throw new Error("Expected Uint8Array");if(t.length>0&&!t.includes(e.length))throw new Error(`Expected Uint8Array of length ${t}, not of length=${e.length}`)}function $m(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 Bm(e,t){Im(e);const n=t.outputLen;if(e.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}const Sm="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0,zm=e=>e instanceof Uint8Array,Om=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),Tm=(e,t)=>e<<32-t|e>>>t;
13
+ /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */if(!(68===new Uint8Array(new Uint32Array([287454020]).buffer)[0]))throw new Error("Non little-endian hardware is not supported");function Nm(e){if("string"==typeof e&&(e=function(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}(e)),!zm(e))throw new Error("expected Uint8Array, got "+typeof e);return e}class Rm{clone(){return this._cloneInto()}}function Um(e){const t=t=>e().update(Nm(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function Pm(e=32){if(Sm&&"function"==typeof Sm.getRandomValues)return Sm.getRandomValues(new Uint8Array(e));throw new Error("crypto.getRandomValues must be defined")}class Fm extends Rm{constructor(e,t,n,r){super(),this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=Om(this.buffer)}update(e){$m(this);const{view:t,buffer:n,blockLen:r}=this,o=(e=Nm(e)).length;for(let i=0;i<o;){const s=Math.min(r-this.pos,o-i);if(s===r){const t=Om(e);for(;r<=o-i;i+=r)this.process(t,i);continue}n.set(e.subarray(i,i+s),this.pos),this.pos+=s,i+=s,this.pos===r&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){$m(this),Bm(e,this),this.finished=!0;const{buffer:t,view:n,blockLen:r,isLE:o}=this;let{pos:i}=this;t[i++]=128,this.buffer.subarray(i).fill(0),this.padOffset>r-i&&(this.process(n,0),i=0);for(let e=i;e<r;e++)t[e]=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=Om(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=a/4,u=this.get();if(c>u.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e<c;e++)s.setUint32(4*e,u[e],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.length=r,e.pos=s,e.finished=o,e.destroyed=i,r%t&&e.buffer.set(n),e}}const Cm=(e,t,n)=>e&t^~e&n,Lm=(e,t,n)=>e&t^e&n^t&n,Mm=new Uint32Array([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]),Dm=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Zm=new Uint32Array(64);class jm extends Fm{constructor(){super(64,32,8,!1),this.A=0|Dm[0],this.B=0|Dm[1],this.C=0|Dm[2],this.D=0|Dm[3],this.E=0|Dm[4],this.F=0|Dm[5],this.G=0|Dm[6],this.H=0|Dm[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 n=0;n<16;n++,t+=4)Zm[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=Zm[e-15],n=Zm[e-2],r=Tm(t,7)^Tm(t,18)^t>>>3,o=Tm(n,17)^Tm(n,19)^n>>>10;Zm[e]=o+Zm[e-7]+r+Zm[e-16]|0}let{A:n,B:r,C:o,D:i,E:s,F:a,G:c,H:u}=this;for(let e=0;e<64;e++){const t=u+(Tm(s,6)^Tm(s,11)^Tm(s,25))+Cm(s,a,c)+Mm[e]+Zm[e]|0,l=(Tm(n,2)^Tm(n,13)^Tm(n,22))+Lm(n,r,o)|0;u=c,c=a,a=s,s=i+t|0,i=o,o=r,r=n,n=t+l|0}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(){Zm.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const qm=Um(()=>new jm),Gm=BigInt(0),Hm=BigInt(1),Vm=BigInt(2),Km=e=>e instanceof Uint8Array,Wm=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));
14
+ /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Jm(e){if(!Km(e))throw new Error("Uint8Array expected");let t="";for(let n=0;n<e.length;n++)t+=Wm[e[n]];return t}function Xm(e){const t=e.toString(16);return 1&t.length?`0${t}`:t}function Ym(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);return BigInt(""===e?"0":`0x${e}`)}function Qm(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);const t=e.length;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);const n=new Uint8Array(t/2);for(let t=0;t<n.length;t++){const r=2*t,o=e.slice(r,r+2),i=Number.parseInt(o,16);if(Number.isNaN(i)||i<0)throw new Error("Invalid byte sequence");n[t]=i}return n}function eg(e){return Ym(Jm(e))}function tg(e){if(!Km(e))throw new Error("Uint8Array expected");return Ym(Jm(Uint8Array.from(e).reverse()))}function ng(e,t){return Qm(e.toString(16).padStart(2*t,"0"))}function rg(e,t){return ng(e,t).reverse()}function og(e,t,n){let r;if("string"==typeof t)try{r=Qm(t)}catch(n){throw new Error(`${e} must be valid hex string, got "${t}". Cause: ${n}`)}else{if(!Km(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} expected ${n} bytes, got ${o}`);return r}function ig(...e){const t=new Uint8Array(e.reduce((e,t)=>e+t.length,0));let n=0;return e.forEach(e=>{if(!Km(e))throw new Error("Uint8Array expected");t.set(e,n),n+=e.length}),t}const sg=e=>(Vm<<BigInt(e-1))-Hm,ag=e=>new Uint8Array(e),cg=e=>Uint8Array.from(e);function ug(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");let r=ag(e),o=ag(e),i=0;const s=()=>{r.fill(1),o.fill(0),i=0},a=(...e)=>n(o,r,...e),c=(e=ag())=>{o=a(cg([0]),e),r=a(),0!==e.length&&(o=a(cg([1]),e),r=a())},u=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let e=0;const n=[];for(;e<t;){r=a();const t=r.slice();n.push(t),e+=r.length}return ig(...n)};return(e,t)=>{let n;for(s(),c(e);!(n=t(u()));)c();return s(),n}}const lg={bigint:e=>"bigint"==typeof e,function:e=>"function"==typeof e,boolean:e=>"boolean"==typeof e,string:e=>"string"==typeof e,stringOrUint8Array:e=>"string"==typeof e||e instanceof Uint8Array,isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>"function"==typeof e&&Number.isSafeInteger(e.outputLen)};function fg(e,t,n={}){const r=(t,n,r)=>{const o=lg[n];if("function"!=typeof o)throw new Error(`Invalid validator "${n}", expected function`);const i=e[t];if(!(r&&void 0===i||o(i,e)))throw new Error(`Invalid param ${String(t)}=${i} (${typeof i}), expected ${n}`)};for(const[e,n]of Object.entries(t))r(e,n,!1);for(const[e,t]of Object.entries(n))r(e,t,!0);return e}var dg=Object.freeze({__proto__:null,bitGet:function(e,t){return e>>BigInt(t)&Hm},bitLen:function(e){let t;for(t=0;e>Gm;e>>=Hm,t+=1);return t},bitMask:sg,bitSet:(e,t,n)=>e|(n?Hm:Gm)<<BigInt(t),bytesToHex:Jm,bytesToNumberBE:eg,bytesToNumberLE:tg,concatBytes:ig,createHmacDrbg:ug,ensureBytes:og,equalBytes: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},hexToBytes:Qm,hexToNumber:Ym,numberToBytesBE:ng,numberToBytesLE:rg,numberToHexUnpadded:Xm,numberToVarBytesBE:function(e){return Qm(Xm(e))},utf8ToBytes:function(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))},validateObject:fg});
15
+ /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const hg=BigInt(0),pg=BigInt(1),mg=BigInt(2),gg=BigInt(3),yg=BigInt(4),wg=BigInt(5),bg=BigInt(8);function vg(e,t){const n=e%t;return n>=hg?n:t+n}function Eg(e,t,n){if(n<=hg||t<hg)throw new Error("Expected power/modulo > 0");if(n===pg)return hg;let r=pg;for(;t>hg;)t&pg&&(r=r*e%n),e=e*e%n,t>>=pg;return r}function xg(e,t,n){let r=e;for(;t-- >hg;)r*=r,r%=n;return r}function _g(e,t){if(e===hg||t<=hg)throw new Error(`invert: expected positive integers, got n=${e} mod=${t}`);let n=vg(e,t),r=t,o=hg,i=pg;for(;n!==hg;){const e=r%n,t=o-i*(r/n);r=n,n=e,o=i,i=t}if(r!==pg)throw new Error("invert: does not exist");return vg(o,t)}function kg(e){if(e%yg===gg){const t=(e+pg)/yg;return function(e,n){const r=e.pow(n,t);if(!e.eql(e.sqr(r),n))throw new Error("Cannot find square root");return r}}if(e%bg===wg){const t=(e-wg)/bg;return function(e,n){const r=e.mul(n,mg),o=e.pow(r,t),i=e.mul(n,o),s=e.mul(e.mul(i,mg),o),a=e.mul(i,e.sub(s,e.ONE));if(!e.eql(e.sqr(a),n))throw new Error("Cannot find square root");return a}}return function(e){const t=(e-pg)/mg;let n,r,o;for(n=e-pg,r=0;n%mg===hg;n/=mg,r++);for(o=mg;o<e&&Eg(o,t,e)!==e-pg;o++);if(1===r){const t=(e+pg)/yg;return function(e,n){const r=e.pow(n,t);if(!e.eql(e.sqr(r),n))throw new Error("Cannot find square root");return r}}const i=(n+pg)/mg;return function(e,s){if(e.pow(s,t)===e.neg(e.ONE))throw new Error("Cannot find square root");let a=r,c=e.pow(e.mul(e.ONE,o),n),u=e.pow(s,i),l=e.pow(s,n);for(;!e.eql(l,e.ONE);){if(e.eql(l,e.ZERO))return e.ZERO;let t=1;for(let n=e.sqr(l);t<a&&!e.eql(n,e.ONE);t++)n=e.sqr(n);const n=e.pow(c,pg<<BigInt(a-t-1));c=e.sqr(n),u=e.mul(u,n),l=e.mul(l,c),a=t}return u}}(e)}BigInt(9),BigInt(16);const Ag=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Ig(e,t){const n=void 0!==t?t:e.toString(2).length;return{nBitLength:n,nByteLength:Math.ceil(n/8)}}function $g(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 Bg(e){const t=$g(e);return t+Math.ceil(t/2)}
16
16
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
17
- const Yb=BigInt(0),Qb=BigInt(1);function ev(e){return function(e){Rb(e,Kb.reduce((e,t)=>(e[t]="function",e),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"}))}(e.Fp),Rb(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Wb(e.n,e.nBitLength),...e,p:e.Fp.ORDER})}
18
- /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const{bytesToNumberBE:tv,hexToBytes:nv}=Ub,rv={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(e){const{Err:t}=rv;if(e.length<2||2!==e[0])throw new t("Invalid signature integer tag");const n=e[1],r=e.subarray(2,n+2);if(!n||r.length!==n)throw new t("Invalid signature integer: wrong length");if(128&r[0])throw new t("Invalid signature integer: negative");if(0===r[0]&&!(128&r[1]))throw new t("Invalid signature integer: unnecessary leading zero");return{d:tv(r),l:e.subarray(n+2)}},toSig(e){const{Err:t}=rv,n="string"==typeof e?nv(e):e;if(!(n instanceof Uint8Array))throw new Error("ui8a expected");let r=n.length;if(r<2||48!=n[0])throw new t("Invalid signature tag");if(n[1]!==r-2)throw new t("Invalid signature: incorrect length");const{d:o,l:i}=rv._parseInt(n.subarray(2)),{d:s,l:a}=rv._parseInt(i);if(a.length)throw new t("Invalid signature: left bytes after parsing");return{r:o,s:s}},hexFromSig(e){const t=e=>8&Number.parseInt(e[0],16)?"00"+e:e,n=e=>{const t=e.toString(16);return 1&t.length?`0${t}`:t},r=t(n(e.s)),o=t(n(e.r)),i=r.length/2,s=o.length/2,a=n(i),c=n(s);return`30${n(s+i+4)}02${c}${o}02${a}${r}`}},ov=BigInt(0),iv=BigInt(1);BigInt(2);const sv=BigInt(3);function av(e){const t=function(e){const t=ev(e);Rb(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:n,Fp:r,a:o}=t;if(n){if(!r.eql(o,r.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if("object"!=typeof n||"bigint"!=typeof n.beta||"function"!=typeof n.splitScalar)throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...t})}(e),{Fp:n}=t,r=t.toBytes||((e,t,r)=>{const o=t.toAffine();return Bb(Uint8Array.from([4]),n.toBytes(o.x),n.toBytes(o.y))}),o=t.fromBytes||(e=>{const t=e.subarray(1);return{x:n.fromBytes(t.subarray(0,n.BYTES)),y:n.fromBytes(t.subarray(n.BYTES,2*n.BYTES))}});function i(e){const{a:r,b:o}=t,i=n.sqr(e),s=n.mul(i,e);return n.add(n.add(s,n.mul(e,r)),o)}if(!n.eql(n.sqr(t.Gy),i(t.Gx)))throw new Error("bad generator point: equation left != right");function s(e){return"bigint"==typeof e&&ov<e&&e<t.n}function a(e){if(!s(e))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function c(e){const{allowedPrivateKeyLengths:n,nByteLength:r,wrapPrivateKey:o,n:i}=t;if(n&&"bigint"!=typeof e){if(e instanceof Uint8Array&&(e=bb(e)),"string"!=typeof e||!n.includes(e.length))throw new Error("Invalid key");e=e.padStart(2*r,"0")}let s;try{s="bigint"==typeof e?e:xb($b("private key",e,r))}catch(t){throw new Error(`private key must be ${r} bytes, hex or bigint, not ${typeof e}`)}return o&&(s=jb(s,i)),a(s),s}const u=new Map;function l(e){if(!(e instanceof f))throw new Error("ProjectivePoint expected")}class f{constructor(e,t,r){if(this.px=e,this.py=t,this.pz=r,null==e||!n.isValid(e))throw new Error("x required");if(null==t||!n.isValid(t))throw new Error("y required");if(null==r||!n.isValid(r))throw new Error("z required")}static fromAffine(e){const{x:t,y:r}=e||{};if(!e||!n.isValid(t)||!n.isValid(r))throw new Error("invalid affine point");if(e instanceof f)throw new Error("projective point not allowed");const o=e=>n.eql(e,n.ZERO);return o(t)&&o(r)?f.ZERO:new f(t,r,n.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(e){const t=n.invertBatch(e.map(e=>e.pz));return e.map((e,n)=>e.toAffine(t[n])).map(f.fromAffine)}static fromHex(e){const t=f.fromAffine(o($b("pointHex",e)));return t.assertValidity(),t}static fromPrivateKey(e){return f.BASE.multiply(c(e))}_setWindowSize(e){this._WINDOW_SIZE=e,u.delete(this)}assertValidity(){if(this.is0()){if(t.allowInfinityPoint&&!n.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:e,y:r}=this.toAffine();if(!n.isValid(e)||!n.isValid(r))throw new Error("bad point: x or y not FE");const o=n.sqr(r),s=i(e);if(!n.eql(o,s))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:e}=this.toAffine();if(n.isOdd)return!n.isOdd(e);throw new Error("Field doesn't support isOdd")}equals(e){l(e);const{px:t,py:r,pz:o}=this,{px:i,py:s,pz:a}=e,c=n.eql(n.mul(t,a),n.mul(i,o)),u=n.eql(n.mul(r,a),n.mul(s,o));return c&&u}negate(){return new f(this.px,n.neg(this.py),this.pz)}double(){const{a:e,b:r}=t,o=n.mul(r,sv),{px:i,py:s,pz:a}=this;let c=n.ZERO,u=n.ZERO,l=n.ZERO,d=n.mul(i,i),h=n.mul(s,s),p=n.mul(a,a),m=n.mul(i,s);return m=n.add(m,m),l=n.mul(i,a),l=n.add(l,l),c=n.mul(e,l),u=n.mul(o,p),u=n.add(c,u),c=n.sub(h,u),u=n.add(h,u),u=n.mul(c,u),c=n.mul(m,c),l=n.mul(o,l),p=n.mul(e,p),m=n.sub(d,p),m=n.mul(e,m),m=n.add(m,l),l=n.add(d,d),d=n.add(l,d),d=n.add(d,p),d=n.mul(d,m),u=n.add(u,d),p=n.mul(s,a),p=n.add(p,p),d=n.mul(p,m),c=n.sub(c,d),l=n.mul(p,h),l=n.add(l,l),l=n.add(l,l),new f(c,u,l)}add(e){l(e);const{px:r,py:o,pz:i}=this,{px:s,py:a,pz:c}=e;let u=n.ZERO,d=n.ZERO,h=n.ZERO;const p=t.a,m=n.mul(t.b,sv);let g=n.mul(r,s),y=n.mul(o,a),w=n.mul(i,c),b=n.add(r,o),v=n.add(s,a);b=n.mul(b,v),v=n.add(g,y),b=n.sub(b,v),v=n.add(r,i);let E=n.add(s,c);return v=n.mul(v,E),E=n.add(g,w),v=n.sub(v,E),E=n.add(o,i),u=n.add(a,c),E=n.mul(E,u),u=n.add(y,w),E=n.sub(E,u),h=n.mul(p,v),u=n.mul(m,w),h=n.add(u,h),u=n.sub(y,h),h=n.add(y,h),d=n.mul(u,h),y=n.add(g,g),y=n.add(y,g),w=n.mul(p,w),v=n.mul(m,v),y=n.add(y,w),w=n.sub(g,w),w=n.mul(p,w),v=n.add(v,w),g=n.mul(y,v),d=n.add(d,g),g=n.mul(E,v),u=n.mul(b,u),u=n.sub(u,g),g=n.mul(b,y),h=n.mul(E,h),h=n.add(h,g),new f(u,d,h)}subtract(e){return this.add(e.negate())}is0(){return this.equals(f.ZERO)}wNAF(e){return h.wNAFCached(this,u,e,e=>{const t=n.invertBatch(e.map(e=>e.pz));return e.map((e,n)=>e.toAffine(t[n])).map(f.fromAffine)})}multiplyUnsafe(e){const r=f.ZERO;if(e===ov)return r;if(a(e),e===iv)return this;const{endo:o}=t;if(!o)return h.unsafeLadder(this,e);let{k1neg:i,k1:s,k2neg:c,k2:u}=o.splitScalar(e),l=r,d=r,p=this;for(;s>ov||u>ov;)s&iv&&(l=l.add(p)),u&iv&&(d=d.add(p)),p=p.double(),s>>=iv,u>>=iv;return i&&(l=l.negate()),c&&(d=d.negate()),d=new f(n.mul(d.px,o.beta),d.py,d.pz),l.add(d)}multiply(e){a(e);let r,o,i=e;const{endo:s}=t;if(s){const{k1neg:e,k1:t,k2neg:a,k2:c}=s.splitScalar(i);let{p:u,f:l}=this.wNAF(t),{p:d,f:p}=this.wNAF(c);u=h.constTimeNegate(e,u),d=h.constTimeNegate(a,d),d=new f(n.mul(d.px,s.beta),d.py,d.pz),r=u.add(d),o=l.add(p)}else{const{p:e,f:t}=this.wNAF(i);r=e,o=t}return f.normalizeZ([r,o])[0]}multiplyAndAddUnsafe(e,t,n){const r=f.BASE,o=(e,t)=>t!==ov&&t!==iv&&e.equals(r)?e.multiply(t):e.multiplyUnsafe(t),i=o(this,t).add(o(e,n));return i.is0()?void 0:i}toAffine(e){const{px:t,py:r,pz:o}=this,i=this.is0();null==e&&(e=i?n.ONE:n.inv(o));const s=n.mul(t,e),a=n.mul(r,e),c=n.mul(o,e);if(i)return{x:n.ZERO,y:n.ZERO};if(!n.eql(c,n.ONE))throw new Error("invZ was invalid");return{x:s,y:a}}isTorsionFree(){const{h:e,isTorsionFree:n}=t;if(e===iv)return!0;if(n)return n(f,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:e,clearCofactor:n}=t;return e===iv?this:n?n(f,this):this.multiplyUnsafe(t.h)}toRawBytes(e=!0){return this.assertValidity(),r(f,this,e)}toHex(e=!0){return bb(this.toRawBytes(e))}}f.BASE=new f(t.Gx,t.Gy,n.ONE),f.ZERO=new f(n.ZERO,n.ONE,n.ZERO);const d=t.nBitLength,h=function(e,t){const n=(e,t)=>{const n=t.negate();return e?n:t},r=e=>({windows:Math.ceil(t/e)+1,windowSize:2**(e-1)});return{constTimeNegate:n,unsafeLadder(t,n){let r=e.ZERO,o=t;for(;n>Yb;)n&Qb&&(r=r.add(o)),o=o.double(),n>>=Qb;return r},precomputeWindow(e,t){const{windows:n,windowSize:o}=r(t),i=[];let s=e,a=s;for(let e=0;e<n;e++){a=s,i.push(a);for(let e=1;e<o;e++)a=a.add(s),i.push(a);s=a.double()}return i},wNAF(t,o,i){const{windows:s,windowSize:a}=r(t);let c=e.ZERO,u=e.BASE;const l=BigInt(2**t-1),f=2**t,d=BigInt(t);for(let e=0;e<s;e++){const t=e*a;let r=Number(i&l);i>>=d,r>a&&(r-=f,i+=Qb);const s=t,h=t+Math.abs(r)-1,p=e%2!=0,m=r<0;0===r?u=u.add(n(p,o[s])):c=c.add(n(m,o[h]))}return{p:c,f:u}},wNAFCached(e,t,n,r){const o=e._WINDOW_SIZE||1;let i=t.get(e);return i||(i=this.precomputeWindow(e,o),1!==o&&t.set(e,r(i))),this.wNAF(o,i,n)}}}(f,t.endo?Math.ceil(d/2):d);return{CURVE:t,ProjectivePoint:f,normPrivateKeyToScalar:c,weierstrassEquation:i,isWithinCurveOrder:s}}function cv(e){const t=function(e){const t=ev(e);return Rb(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}(e),{Fp:n,n:r}=t,o=n.BYTES+1,i=2*n.BYTES+1;function s(e){return jb(e,r)}function a(e){return Hb(e,r)}const{ProjectivePoint:c,normPrivateKeyToScalar:u,weierstrassEquation:l,isWithinCurveOrder:f}=av({...t,toBytes(e,t,r){const o=t.toAffine(),i=n.toBytes(o.x),s=Bb;return r?s(Uint8Array.from([t.hasEvenY()?2:3]),i):s(Uint8Array.from([4]),i,n.toBytes(o.y))},fromBytes(e){const t=e.length,r=e[0],s=e.subarray(1);if(t!==o||2!==r&&3!==r){if(t===i&&4===r){return{x:n.fromBytes(s.subarray(0,n.BYTES)),y:n.fromBytes(s.subarray(n.BYTES,2*n.BYTES))}}throw new Error(`Point of length ${t} was invalid. Expected ${o} compressed bytes or ${i} uncompressed bytes`)}{const e=xb(s);if(!(ov<(a=e)&&a<n.ORDER))throw new Error("Point is not on curve");const t=l(e);let o=n.sqrt(t);return!(1&~r)!==((o&iv)===iv)&&(o=n.neg(o)),{x:e,y:o}}var a}}),d=e=>bb(Ab(e,t.nByteLength));function h(e){return e>r>>iv}const p=(e,t,n)=>xb(e.slice(t,n));class m{constructor(e,t,n){this.r=e,this.s=t,this.recovery=n,this.assertValidity()}static fromCompact(e){const n=t.nByteLength;return e=$b("compactSignature",e,2*n),new m(p(e,0,n),p(e,n,2*n))}static fromDER(e){const{r:t,s:n}=rv.toSig($b("DER",e));return new m(t,n)}assertValidity(){if(!f(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!f(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(e){return new m(this.r,this.s,e)}recoverPublicKey(e){const{r:r,s:o,recovery:i}=this,u=b($b("msgHash",e));if(null==i||![0,1,2,3].includes(i))throw new Error("recovery id invalid");const l=2===i||3===i?r+t.n:r;if(l>=n.ORDER)throw new Error("recovery id 2 or 3 invalid");const f=1&i?"03":"02",h=c.fromHex(f+d(l)),p=a(l),m=s(-u*p),g=s(o*p),y=c.BASE.multiplyAndAddUnsafe(h,m,g);if(!y)throw new Error("point at infinify");return y.assertValidity(),y}hasHighS(){return h(this.s)}normalizeS(){return this.hasHighS()?new m(this.r,s(-this.s),this.recovery):this}toDERRawBytes(){return _b(this.toDERHex())}toDERHex(){return rv.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return _b(this.toCompactHex())}toCompactHex(){return d(this.r)+d(this.s)}}const g={isValidPrivateKey(e){try{return u(e),!0}catch(e){return!1}},normPrivateKeyToScalar:u,randomPrivateKey:()=>{const e=Xb(t.n);return function(e,t,n=!1){const r=e.length,o=Jb(t),i=Xb(t);if(r<16||r<i||r>1024)throw new Error(`expected ${i}-1024 bytes of input, got ${r}`);const s=jb(n?xb(e):kb(e),t-Fb)+Fb;return n?Ib(s,o):Ab(s,o)}(t.randomBytes(e),t.n)},precompute:(e=8,t=c.BASE)=>(t._setWindowSize(e),t.multiply(BigInt(3)),t)};function y(e){const t=e instanceof Uint8Array,n="string"==typeof e,r=(t||n)&&e.length;return t?r===o||r===i:n?r===2*o||r===2*i:e instanceof c}const w=t.bits2int||function(e){const n=xb(e),r=8*e.length-t.nBitLength;return r>0?n>>BigInt(r):n},b=t.bits2int_modN||function(e){return s(w(e))},v=zb(t.nBitLength);function E(e){if("bigint"!=typeof e)throw new Error("bigint expected");if(!(ov<=e&&e<v))throw new Error(`bigint expected < 2^${t.nBitLength}`);return Ab(e,t.nByteLength)}function _(e,r,o=x){if(["recovered","canonical"].some(e=>e in o))throw new Error("sign() legacy options not supported");const{hash:i,randomBytes:l}=t;let{lowS:d,prehash:p,extraEntropy:g}=o;null==d&&(d=!0),e=$b("msgHash",e),p&&(e=$b("prehashed msgHash",i(e)));const y=b(e),v=u(r),_=[E(v),E(y)];if(null!=g){const e=!0===g?l(n.BYTES):g;_.push($b("extraEntropy",e))}const k=Bb(..._),A=y;return{seed:k,k2sig:function(e){const t=w(e);if(!f(t))return;const n=a(t),r=c.BASE.multiply(t).toAffine(),o=s(r.x);if(o===ov)return;const i=s(n*s(A+o*v));if(i===ov)return;let u=(r.x===o?0:2)|Number(r.y&iv),l=i;return d&&h(i)&&(l=function(e){return h(e)?s(-e):e}(i),u^=1),new m(o,l,u)}}}const x={lowS:t.lowS,prehash:!1},k={lowS:t.lowS,prehash:!1};return c.BASE._setWindowSize(8),{CURVE:t,getPublicKey:function(e,t=!0){return c.fromPrivateKey(e).toRawBytes(t)},getSharedSecret:function(e,t,n=!0){if(y(e))throw new Error("first arg must be private key");if(!y(t))throw new Error("second arg must be public key");return c.fromHex(t).multiply(u(e)).toRawBytes(n)},sign:function(e,n,r=x){const{seed:o,k2sig:i}=_(e,n,r),s=t;return Tb(s.hash.outputLen,s.nByteLength,s.hmac)(o,i)},verify:function(e,n,r,o=k){const i=e;if(n=$b("msgHash",n),r=$b("publicKey",r),"strict"in o)throw new Error("options.strict was renamed to lowS");const{lowS:u,prehash:l}=o;let f,d;try{if("string"==typeof i||i instanceof Uint8Array)try{f=m.fromDER(i)}catch(e){if(!(e instanceof rv.Err))throw e;f=m.fromCompact(i)}else{if("object"!=typeof i||"bigint"!=typeof i.r||"bigint"!=typeof i.s)throw new Error("PARSE");{const{r:e,s:t}=i;f=new m(e,t)}}d=c.fromHex(r)}catch(e){if("PARSE"===e.message)throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(u&&f.hasHighS())return!1;l&&(n=t.hash(n));const{r:h,s:p}=f,g=b(n),y=a(p),w=s(g*y),v=s(h*y),E=c.BASE.multiplyAndAddUnsafe(d,w,v)?.toAffine();return!!E&&s(E.x)===h},ProjectivePoint:c,Signature:m,utils:g}}BigInt(4);class uv extends rb{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,function(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");Kw(e.outputLen),Kw(e.blockLen)}(e);const n=nb(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 e=0;e<o.length;e++)o[e]^=54;this.iHash.update(o),this.oHash=e.create();for(let e=0;e<o.length;e++)o[e]^=106;this.oHash.update(o),o.fill(0)}update(e){return Jw(this),this.iHash.update(e),this}digestInto(e){Jw(this),Ww(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}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const lv=(e,t,n)=>new uv(e,t).update(n).digest();
17
+ const Sg=BigInt(0),zg=BigInt(1);function Og(e){return function(e){fg(e,Ag.reduce((e,t)=>(e[t]="function",e),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"}))}(e.Fp),fg(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Ig(e.n,e.nBitLength),...e,p:e.Fp.ORDER})}
18
+ /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const{bytesToNumberBE:Tg,hexToBytes:Ng}=dg,Rg={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(e){const{Err:t}=Rg;if(e.length<2||2!==e[0])throw new t("Invalid signature integer tag");const n=e[1],r=e.subarray(2,n+2);if(!n||r.length!==n)throw new t("Invalid signature integer: wrong length");if(128&r[0])throw new t("Invalid signature integer: negative");if(0===r[0]&&!(128&r[1]))throw new t("Invalid signature integer: unnecessary leading zero");return{d:Tg(r),l:e.subarray(n+2)}},toSig(e){const{Err:t}=Rg,n="string"==typeof e?Ng(e):e;if(!(n instanceof Uint8Array))throw new Error("ui8a expected");let r=n.length;if(r<2||48!=n[0])throw new t("Invalid signature tag");if(n[1]!==r-2)throw new t("Invalid signature: incorrect length");const{d:o,l:i}=Rg._parseInt(n.subarray(2)),{d:s,l:a}=Rg._parseInt(i);if(a.length)throw new t("Invalid signature: left bytes after parsing");return{r:o,s:s}},hexFromSig(e){const t=e=>8&Number.parseInt(e[0],16)?"00"+e:e,n=e=>{const t=e.toString(16);return 1&t.length?`0${t}`:t},r=t(n(e.s)),o=t(n(e.r)),i=r.length/2,s=o.length/2,a=n(i),c=n(s);return`30${n(s+i+4)}02${c}${o}02${a}${r}`}},Ug=BigInt(0),Pg=BigInt(1);BigInt(2);const Fg=BigInt(3);function Cg(e){const t=function(e){const t=Og(e);fg(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:n,Fp:r,a:o}=t;if(n){if(!r.eql(o,r.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if("object"!=typeof n||"bigint"!=typeof n.beta||"function"!=typeof n.splitScalar)throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...t})}(e),{Fp:n}=t,r=t.toBytes||((e,t,r)=>{const o=t.toAffine();return ig(Uint8Array.from([4]),n.toBytes(o.x),n.toBytes(o.y))}),o=t.fromBytes||(e=>{const t=e.subarray(1);return{x:n.fromBytes(t.subarray(0,n.BYTES)),y:n.fromBytes(t.subarray(n.BYTES,2*n.BYTES))}});function i(e){const{a:r,b:o}=t,i=n.sqr(e),s=n.mul(i,e);return n.add(n.add(s,n.mul(e,r)),o)}if(!n.eql(n.sqr(t.Gy),i(t.Gx)))throw new Error("bad generator point: equation left != right");function s(e){return"bigint"==typeof e&&Ug<e&&e<t.n}function a(e){if(!s(e))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function c(e){const{allowedPrivateKeyLengths:n,nByteLength:r,wrapPrivateKey:o,n:i}=t;if(n&&"bigint"!=typeof e){if(e instanceof Uint8Array&&(e=Jm(e)),"string"!=typeof e||!n.includes(e.length))throw new Error("Invalid key");e=e.padStart(2*r,"0")}let s;try{s="bigint"==typeof e?e:eg(og("private key",e,r))}catch(t){throw new Error(`private key must be ${r} bytes, hex or bigint, not ${typeof e}`)}return o&&(s=vg(s,i)),a(s),s}const u=new Map;function l(e){if(!(e instanceof f))throw new Error("ProjectivePoint expected")}class f{constructor(e,t,r){if(this.px=e,this.py=t,this.pz=r,null==e||!n.isValid(e))throw new Error("x required");if(null==t||!n.isValid(t))throw new Error("y required");if(null==r||!n.isValid(r))throw new Error("z required")}static fromAffine(e){const{x:t,y:r}=e||{};if(!e||!n.isValid(t)||!n.isValid(r))throw new Error("invalid affine point");if(e instanceof f)throw new Error("projective point not allowed");const o=e=>n.eql(e,n.ZERO);return o(t)&&o(r)?f.ZERO:new f(t,r,n.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(e){const t=n.invertBatch(e.map(e=>e.pz));return e.map((e,n)=>e.toAffine(t[n])).map(f.fromAffine)}static fromHex(e){const t=f.fromAffine(o(og("pointHex",e)));return t.assertValidity(),t}static fromPrivateKey(e){return f.BASE.multiply(c(e))}_setWindowSize(e){this._WINDOW_SIZE=e,u.delete(this)}assertValidity(){if(this.is0()){if(t.allowInfinityPoint&&!n.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:e,y:r}=this.toAffine();if(!n.isValid(e)||!n.isValid(r))throw new Error("bad point: x or y not FE");const o=n.sqr(r),s=i(e);if(!n.eql(o,s))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:e}=this.toAffine();if(n.isOdd)return!n.isOdd(e);throw new Error("Field doesn't support isOdd")}equals(e){l(e);const{px:t,py:r,pz:o}=this,{px:i,py:s,pz:a}=e,c=n.eql(n.mul(t,a),n.mul(i,o)),u=n.eql(n.mul(r,a),n.mul(s,o));return c&&u}negate(){return new f(this.px,n.neg(this.py),this.pz)}double(){const{a:e,b:r}=t,o=n.mul(r,Fg),{px:i,py:s,pz:a}=this;let c=n.ZERO,u=n.ZERO,l=n.ZERO,d=n.mul(i,i),h=n.mul(s,s),p=n.mul(a,a),m=n.mul(i,s);return m=n.add(m,m),l=n.mul(i,a),l=n.add(l,l),c=n.mul(e,l),u=n.mul(o,p),u=n.add(c,u),c=n.sub(h,u),u=n.add(h,u),u=n.mul(c,u),c=n.mul(m,c),l=n.mul(o,l),p=n.mul(e,p),m=n.sub(d,p),m=n.mul(e,m),m=n.add(m,l),l=n.add(d,d),d=n.add(l,d),d=n.add(d,p),d=n.mul(d,m),u=n.add(u,d),p=n.mul(s,a),p=n.add(p,p),d=n.mul(p,m),c=n.sub(c,d),l=n.mul(p,h),l=n.add(l,l),l=n.add(l,l),new f(c,u,l)}add(e){l(e);const{px:r,py:o,pz:i}=this,{px:s,py:a,pz:c}=e;let u=n.ZERO,d=n.ZERO,h=n.ZERO;const p=t.a,m=n.mul(t.b,Fg);let g=n.mul(r,s),y=n.mul(o,a),w=n.mul(i,c),b=n.add(r,o),v=n.add(s,a);b=n.mul(b,v),v=n.add(g,y),b=n.sub(b,v),v=n.add(r,i);let E=n.add(s,c);return v=n.mul(v,E),E=n.add(g,w),v=n.sub(v,E),E=n.add(o,i),u=n.add(a,c),E=n.mul(E,u),u=n.add(y,w),E=n.sub(E,u),h=n.mul(p,v),u=n.mul(m,w),h=n.add(u,h),u=n.sub(y,h),h=n.add(y,h),d=n.mul(u,h),y=n.add(g,g),y=n.add(y,g),w=n.mul(p,w),v=n.mul(m,v),y=n.add(y,w),w=n.sub(g,w),w=n.mul(p,w),v=n.add(v,w),g=n.mul(y,v),d=n.add(d,g),g=n.mul(E,v),u=n.mul(b,u),u=n.sub(u,g),g=n.mul(b,y),h=n.mul(E,h),h=n.add(h,g),new f(u,d,h)}subtract(e){return this.add(e.negate())}is0(){return this.equals(f.ZERO)}wNAF(e){return h.wNAFCached(this,u,e,e=>{const t=n.invertBatch(e.map(e=>e.pz));return e.map((e,n)=>e.toAffine(t[n])).map(f.fromAffine)})}multiplyUnsafe(e){const r=f.ZERO;if(e===Ug)return r;if(a(e),e===Pg)return this;const{endo:o}=t;if(!o)return h.unsafeLadder(this,e);let{k1neg:i,k1:s,k2neg:c,k2:u}=o.splitScalar(e),l=r,d=r,p=this;for(;s>Ug||u>Ug;)s&Pg&&(l=l.add(p)),u&Pg&&(d=d.add(p)),p=p.double(),s>>=Pg,u>>=Pg;return i&&(l=l.negate()),c&&(d=d.negate()),d=new f(n.mul(d.px,o.beta),d.py,d.pz),l.add(d)}multiply(e){a(e);let r,o,i=e;const{endo:s}=t;if(s){const{k1neg:e,k1:t,k2neg:a,k2:c}=s.splitScalar(i);let{p:u,f:l}=this.wNAF(t),{p:d,f:p}=this.wNAF(c);u=h.constTimeNegate(e,u),d=h.constTimeNegate(a,d),d=new f(n.mul(d.px,s.beta),d.py,d.pz),r=u.add(d),o=l.add(p)}else{const{p:e,f:t}=this.wNAF(i);r=e,o=t}return f.normalizeZ([r,o])[0]}multiplyAndAddUnsafe(e,t,n){const r=f.BASE,o=(e,t)=>t!==Ug&&t!==Pg&&e.equals(r)?e.multiply(t):e.multiplyUnsafe(t),i=o(this,t).add(o(e,n));return i.is0()?void 0:i}toAffine(e){const{px:t,py:r,pz:o}=this,i=this.is0();null==e&&(e=i?n.ONE:n.inv(o));const s=n.mul(t,e),a=n.mul(r,e),c=n.mul(o,e);if(i)return{x:n.ZERO,y:n.ZERO};if(!n.eql(c,n.ONE))throw new Error("invZ was invalid");return{x:s,y:a}}isTorsionFree(){const{h:e,isTorsionFree:n}=t;if(e===Pg)return!0;if(n)return n(f,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:e,clearCofactor:n}=t;return e===Pg?this:n?n(f,this):this.multiplyUnsafe(t.h)}toRawBytes(e=!0){return this.assertValidity(),r(f,this,e)}toHex(e=!0){return Jm(this.toRawBytes(e))}}f.BASE=new f(t.Gx,t.Gy,n.ONE),f.ZERO=new f(n.ZERO,n.ONE,n.ZERO);const d=t.nBitLength,h=function(e,t){const n=(e,t)=>{const n=t.negate();return e?n:t},r=e=>({windows:Math.ceil(t/e)+1,windowSize:2**(e-1)});return{constTimeNegate:n,unsafeLadder(t,n){let r=e.ZERO,o=t;for(;n>Sg;)n&zg&&(r=r.add(o)),o=o.double(),n>>=zg;return r},precomputeWindow(e,t){const{windows:n,windowSize:o}=r(t),i=[];let s=e,a=s;for(let e=0;e<n;e++){a=s,i.push(a);for(let e=1;e<o;e++)a=a.add(s),i.push(a);s=a.double()}return i},wNAF(t,o,i){const{windows:s,windowSize:a}=r(t);let c=e.ZERO,u=e.BASE;const l=BigInt(2**t-1),f=2**t,d=BigInt(t);for(let e=0;e<s;e++){const t=e*a;let r=Number(i&l);i>>=d,r>a&&(r-=f,i+=zg);const s=t,h=t+Math.abs(r)-1,p=e%2!=0,m=r<0;0===r?u=u.add(n(p,o[s])):c=c.add(n(m,o[h]))}return{p:c,f:u}},wNAFCached(e,t,n,r){const o=e._WINDOW_SIZE||1;let i=t.get(e);return i||(i=this.precomputeWindow(e,o),1!==o&&t.set(e,r(i))),this.wNAF(o,i,n)}}}(f,t.endo?Math.ceil(d/2):d);return{CURVE:t,ProjectivePoint:f,normPrivateKeyToScalar:c,weierstrassEquation:i,isWithinCurveOrder:s}}function Lg(e){const t=function(e){const t=Og(e);return fg(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}(e),{Fp:n,n:r}=t,o=n.BYTES+1,i=2*n.BYTES+1;function s(e){return vg(e,r)}function a(e){return _g(e,r)}const{ProjectivePoint:c,normPrivateKeyToScalar:u,weierstrassEquation:l,isWithinCurveOrder:f}=Cg({...t,toBytes(e,t,r){const o=t.toAffine(),i=n.toBytes(o.x),s=ig;return r?s(Uint8Array.from([t.hasEvenY()?2:3]),i):s(Uint8Array.from([4]),i,n.toBytes(o.y))},fromBytes(e){const t=e.length,r=e[0],s=e.subarray(1);if(t!==o||2!==r&&3!==r){if(t===i&&4===r){return{x:n.fromBytes(s.subarray(0,n.BYTES)),y:n.fromBytes(s.subarray(n.BYTES,2*n.BYTES))}}throw new Error(`Point of length ${t} was invalid. Expected ${o} compressed bytes or ${i} uncompressed bytes`)}{const e=eg(s);if(!(Ug<(a=e)&&a<n.ORDER))throw new Error("Point is not on curve");const t=l(e);let o=n.sqrt(t);return!(1&~r)!==((o&Pg)===Pg)&&(o=n.neg(o)),{x:e,y:o}}var a}}),d=e=>Jm(ng(e,t.nByteLength));function h(e){return e>r>>Pg}const p=(e,t,n)=>eg(e.slice(t,n));class m{constructor(e,t,n){this.r=e,this.s=t,this.recovery=n,this.assertValidity()}static fromCompact(e){const n=t.nByteLength;return e=og("compactSignature",e,2*n),new m(p(e,0,n),p(e,n,2*n))}static fromDER(e){const{r:t,s:n}=Rg.toSig(og("DER",e));return new m(t,n)}assertValidity(){if(!f(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!f(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(e){return new m(this.r,this.s,e)}recoverPublicKey(e){const{r:r,s:o,recovery:i}=this,u=b(og("msgHash",e));if(null==i||![0,1,2,3].includes(i))throw new Error("recovery id invalid");const l=2===i||3===i?r+t.n:r;if(l>=n.ORDER)throw new Error("recovery id 2 or 3 invalid");const f=1&i?"03":"02",h=c.fromHex(f+d(l)),p=a(l),m=s(-u*p),g=s(o*p),y=c.BASE.multiplyAndAddUnsafe(h,m,g);if(!y)throw new Error("point at infinify");return y.assertValidity(),y}hasHighS(){return h(this.s)}normalizeS(){return this.hasHighS()?new m(this.r,s(-this.s),this.recovery):this}toDERRawBytes(){return Qm(this.toDERHex())}toDERHex(){return Rg.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Qm(this.toCompactHex())}toCompactHex(){return d(this.r)+d(this.s)}}const g={isValidPrivateKey(e){try{return u(e),!0}catch(e){return!1}},normPrivateKeyToScalar:u,randomPrivateKey:()=>{const e=Bg(t.n);return function(e,t,n=!1){const r=e.length,o=$g(t),i=Bg(t);if(r<16||r<i||r>1024)throw new Error(`expected ${i}-1024 bytes of input, got ${r}`);const s=vg(n?eg(e):tg(e),t-pg)+pg;return n?rg(s,o):ng(s,o)}(t.randomBytes(e),t.n)},precompute:(e=8,t=c.BASE)=>(t._setWindowSize(e),t.multiply(BigInt(3)),t)};function y(e){const t=e instanceof Uint8Array,n="string"==typeof e,r=(t||n)&&e.length;return t?r===o||r===i:n?r===2*o||r===2*i:e instanceof c}const w=t.bits2int||function(e){const n=eg(e),r=8*e.length-t.nBitLength;return r>0?n>>BigInt(r):n},b=t.bits2int_modN||function(e){return s(w(e))},v=sg(t.nBitLength);function E(e){if("bigint"!=typeof e)throw new Error("bigint expected");if(!(Ug<=e&&e<v))throw new Error(`bigint expected < 2^${t.nBitLength}`);return ng(e,t.nByteLength)}function x(e,r,o=_){if(["recovered","canonical"].some(e=>e in o))throw new Error("sign() legacy options not supported");const{hash:i,randomBytes:l}=t;let{lowS:d,prehash:p,extraEntropy:g}=o;null==d&&(d=!0),e=og("msgHash",e),p&&(e=og("prehashed msgHash",i(e)));const y=b(e),v=u(r),x=[E(v),E(y)];if(null!=g){const e=!0===g?l(n.BYTES):g;x.push(og("extraEntropy",e))}const k=ig(...x),A=y;return{seed:k,k2sig:function(e){const t=w(e);if(!f(t))return;const n=a(t),r=c.BASE.multiply(t).toAffine(),o=s(r.x);if(o===Ug)return;const i=s(n*s(A+o*v));if(i===Ug)return;let u=(r.x===o?0:2)|Number(r.y&Pg),l=i;return d&&h(i)&&(l=function(e){return h(e)?s(-e):e}(i),u^=1),new m(o,l,u)}}}const _={lowS:t.lowS,prehash:!1},k={lowS:t.lowS,prehash:!1};return c.BASE._setWindowSize(8),{CURVE:t,getPublicKey:function(e,t=!0){return c.fromPrivateKey(e).toRawBytes(t)},getSharedSecret:function(e,t,n=!0){if(y(e))throw new Error("first arg must be private key");if(!y(t))throw new Error("second arg must be public key");return c.fromHex(t).multiply(u(e)).toRawBytes(n)},sign:function(e,n,r=_){const{seed:o,k2sig:i}=x(e,n,r),s=t;return ug(s.hash.outputLen,s.nByteLength,s.hmac)(o,i)},verify:function(e,n,r,o=k){const i=e;if(n=og("msgHash",n),r=og("publicKey",r),"strict"in o)throw new Error("options.strict was renamed to lowS");const{lowS:u,prehash:l}=o;let f,d;try{if("string"==typeof i||i instanceof Uint8Array)try{f=m.fromDER(i)}catch(e){if(!(e instanceof Rg.Err))throw e;f=m.fromCompact(i)}else{if("object"!=typeof i||"bigint"!=typeof i.r||"bigint"!=typeof i.s)throw new Error("PARSE");{const{r:e,s:t}=i;f=new m(e,t)}}d=c.fromHex(r)}catch(e){if("PARSE"===e.message)throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(u&&f.hasHighS())return!1;l&&(n=t.hash(n));const{r:h,s:p}=f,g=b(n),y=a(p),w=s(g*y),v=s(h*y),E=c.BASE.multiplyAndAddUnsafe(d,w,v)?.toAffine();return!!E&&s(E.x)===h},ProjectivePoint:c,Signature:m,utils:g}}BigInt(4);class Mg extends Rm{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,function(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");Am(e.outputLen),Am(e.blockLen)}(e);const n=Nm(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 e=0;e<o.length;e++)o[e]^=54;this.iHash.update(o),this.oHash=e.create();for(let e=0;e<o.length;e++)o[e]^=106;this.oHash.update(o),o.fill(0)}update(e){return $m(this),this.iHash.update(e),this}digestInto(e){$m(this),Im(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}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const Dg=(e,t,n)=>new Mg(e,t).update(n).digest();
19
19
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
20
- function fv(e){return{hash:e,hmac:(t,...n)=>lv(e,t,function(...e){const t=new Uint8Array(e.reduce((e,t)=>e+t.length,0));let n=0;return e.forEach(e=>{if(!Qw(e))throw new Error("Uint8Array expected");t.set(e,n),n+=e.length}),t}(...n)),randomBytes:ib}}lv.create=(e,t)=>new uv(e,t);
20
+ function Zg(e){return{hash:e,hmac:(t,...n)=>Dg(e,t,function(...e){const t=new Uint8Array(e.reduce((e,t)=>e+t.length,0));let n=0;return e.forEach(e=>{if(!zm(e))throw new Error("Uint8Array expected");t.set(e,n),n+=e.length}),t}(...n)),randomBytes:Pm}}Dg.create=(e,t)=>new Mg(e,t);
21
21
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
22
- const dv=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),hv=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),pv=BigInt(1),mv=BigInt(2),gv=(e,t)=>(e+t/mv)/t;const yv=function(e,t,n=!1,r={}){if(e<=Pb)throw new Error(`Expected Field ORDER > 0, got ${e}`);const{nBitLength:o,nByteLength:i}=Wb(e,t);if(i>2048)throw new Error("Field lengths over 2048 bytes are not supported");const s=Vb(e),a=Object.freeze({ORDER:e,BITS:o,BYTES:i,MASK:zb(o),ZERO:Pb,ONE:Fb,create:t=>jb(t,e),isValid:t=>{if("bigint"!=typeof t)throw new Error("Invalid field element: expected bigint, got "+typeof t);return Pb<=t&&t<e},is0:e=>e===Pb,isOdd:e=>(e&Fb)===Fb,neg:t=>jb(-t,e),eql:(e,t)=>e===t,sqr:t=>jb(t*t,e),add:(t,n)=>jb(t+n,e),sub:(t,n)=>jb(t-n,e),mul:(t,n)=>jb(t*n,e),pow:(e,t)=>function(e,t,n){if(n<Pb)throw new Error("Expected power > 0");if(n===Pb)return e.ONE;if(n===Fb)return t;let r=e.ONE,o=t;for(;n>Pb;)n&Fb&&(r=e.mul(r,o)),o=e.sqr(o),n>>=Fb;return r}(a,e,t),div:(t,n)=>jb(t*Hb(n,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>Hb(t,e),sqrt:r.sqrt||(e=>s(a,e)),invertBatch:e=>function(e,t){const n=new Array(t.length),r=t.reduce((t,r,o)=>e.is0(r)?t:(n[o]=t,e.mul(t,r)),e.ONE),o=e.inv(r);return t.reduceRight((t,r,o)=>e.is0(r)?t:(n[o]=e.mul(t,n[o]),e.mul(t,r)),o),n}(a,e),cmov:(e,t,n)=>n?t:e,toBytes:e=>n?Ib(e,i):Ab(e,i),fromBytes:e=>{if(e.length!==i)throw new Error(`Fp.fromBytes: expected ${i}, got ${e.length}`);return n?kb(e):xb(e)}});return Object.freeze(a)}(dv,void 0,void 0,{sqrt:function(e){const t=dv,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=Gb(l,n,t)*l%t,d=Gb(f,n,t)*l%t,h=Gb(d,mv,t)*u%t,p=Gb(h,o,t)*h%t,m=Gb(p,i,t)*p%t,g=Gb(m,a,t)*m%t,y=Gb(g,c,t)*g%t,w=Gb(y,a,t)*m%t,b=Gb(w,n,t)*l%t,v=Gb(b,s,t)*p%t,E=Gb(v,r,t)*u%t,_=Gb(E,mv,t);if(!yv.eql(yv.sqr(_),e))throw new Error("Cannot find square root");return _}}),wv=function(e,t){const n=t=>cv({...e,...fv(t)});return Object.freeze({...n(t),create:n})}({a:BigInt(0),b:BigInt(7),Fp:yv,n:hv,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{const t=hv,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-pv*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=n,s=BigInt("0x100000000000000000000000000000000"),a=gv(i*e,t),c=gv(-r*e,t);let u=jb(e-a*n-c*o,t),l=jb(-a*r-c*i,t);const f=u>s,d=l>s;if(f&&(u=t-u),d&&(l=t-l),u>s||l>s)throw new Error("splitScalar: Endomorphism failed, k="+e);return{k1neg:f,k1:u,k2neg:d,k2:l}}}},hb);BigInt(0),wv.ProjectivePoint;const bv=BigInt(2**32-1),vv=BigInt(32);function Ev(e,t=!1){return t?{h:Number(e&bv),l:Number(e>>vv&bv)}:{h:0|Number(e>>vv&bv),l:0|Number(e&bv)}}function _v(e,t=!1){let n=new Uint32Array(e.length),r=new Uint32Array(e.length);for(let o=0;o<e.length;o++){const{h:i,l:s}=Ev(e[o],t);[n[o],r[o]]=[i,s]}return[n,r]}const[xv,kv,Av]=[[],[],[]],Iv=BigInt(0),$v=BigInt(1),Bv=BigInt(2),zv=BigInt(7),Sv=BigInt(256),Ov=BigInt(113);for(let e=0,t=$v,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],xv.push(2*(5*r+n)),kv.push((e+1)*(e+2)/2%64);let o=Iv;for(let e=0;e<7;e++)t=(t<<$v^(t>>zv)*Ov)%Sv,t&Bv&&(o^=$v<<($v<<BigInt(e))-$v);Av.push(o)}const[Tv,Nv]=_v(Av,!0),Rv=(e,t,n)=>n>32?((e,t,n)=>t<<n-32|e>>>64-n)(e,t,n):((e,t,n)=>e<<n|t>>>32-n)(e,t,n),Uv=(e,t,n)=>n>32?((e,t,n)=>e<<n-32|t>>>64-n)(e,t,n):((e,t,n)=>t<<n|e>>>32-n)(e,t,n);class Pv extends rb{constructor(e,t,n,r=!1,o=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=n,this.enableXOF=r,this.rounds=o,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,Kw(n),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");var i;this.state=new Uint8Array(200),this.state32=(i=this.state,new Uint32Array(i.buffer,i.byteOffset,Math.floor(i.byteLength/4)))}keccak(){!function(e,t=24){const n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let t=0;t<10;t++)n[t]=e[t]^e[t+10]^e[t+20]^e[t+30]^e[t+40];for(let t=0;t<10;t+=2){const r=(t+8)%10,o=(t+2)%10,i=n[o],s=n[o+1],a=Rv(i,s,1)^n[r],c=Uv(i,s,1)^n[r+1];for(let n=0;n<50;n+=10)e[t+n]^=a,e[t+n+1]^=c}let t=e[2],o=e[3];for(let n=0;n<24;n++){const r=kv[n],i=Rv(t,o,r),s=Uv(t,o,r),a=xv[n];t=e[a],o=e[a+1],e[a]=i,e[a+1]=s}for(let t=0;t<50;t+=10){for(let r=0;r<10;r++)n[r]=e[t+r];for(let r=0;r<10;r++)e[t+r]^=~n[(r+2)%10]&n[(r+4)%10]}e[0]^=Tv[r],e[1]^=Nv[r]}n.fill(0)}(this.state32,this.rounds),this.posOut=0,this.pos=0}update(e){Jw(this);const{blockLen:t,state:n}=this,r=(e=nb(e)).length;for(let o=0;o<r;){const i=Math.min(t-this.pos,r-o);for(let t=0;t<i;t++)n[this.pos++]^=e[o++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:n,blockLen:r}=this;e[n]^=t,128&t&&n===r-1&&this.keccak(),e[r-1]^=128,this.keccak()}writeInto(e){Jw(this,!1),Ww(e),this.finish();const t=this.state,{blockLen:n}=this;for(let r=0,o=e.length;r<o;){this.posOut>=n&&this.keccak();const i=Math.min(n-this.posOut,o-r);e.set(t.subarray(this.posOut,this.posOut+i),r),this.posOut+=i,r+=i}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return Kw(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(Xw(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:t,suffix:n,outputLen:r,rounds:o,enableXOF:i}=this;return e||(e=new Pv(t,n,r,i,o)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=o,e.suffix=n,e.outputLen=r,e.enableXOF=i,e.destroyed=this.destroyed,e}}const Fv=((e,t,n)=>ob(()=>new Pv(t,e,n)))(1,136,32),Cv="swarm-encryption",Lv="postage-signer",Mv="backup-key",Dv="act-sharing";async function Zv(e,t){const n=await crypto.subtle.importKey("raw",Gy(e),{name:"HMAC",hash:"SHA-256"},!1,["sign"]),r=await crypto.subtle.sign("HMAC",n,(new TextEncoder).encode(t));return Hy(new Uint8Array(r))}function jv(e,t){return Hy(lv(hb,Gy(e),(new TextEncoder).encode(t)))}async function qv(e,t){const n=await Zv(e,t);return crypto.subtle.importKey("raw",Gy(n),"AES-GCM",!1,["encrypt","decrypt"])}async function Gv(e){return Zv(e,"derivation-key")}async function Hv(e){return Zv(e,Cv)}async function Vv(e){return Zv(e,Lv)}function Kv(e){return jv(e,Lv)}function Wv(e){const t=Gy(jv(e,Dv));return{secret:t,publicKey:new Hs(t).publicKey().toCompressedHex()}}function Jv(e){return function(e,t){for(let n=0;n<16;n++){const r=e(0===n?t:`${t}/${n}`);if(wv.utils.isValidPrivateKey(r))return r}throw new Error(`No valid secp256k1 private key under "${t}" in 16 attempts.`)}(t=>Gy(jv(e,t)),"swarm-id chat key v1")}const Xv="Swarm ID chat binding v1",Yv="Site: ",Qv="Chat address: ",eE="Date: ",tE=/^0x[0-9a-fA-F]{130}$/,nE=/^0x[0-9a-f]{40}$/,rE=/^(0x)?[0-9a-fA-F]{40}$/,oE=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/,iE=/^[a-z0-9-]+(\.[a-z0-9-]+)*$/,sE=new Set(["localhost","127.0.0.1","[::1]"]);function aE(e,t={}){let n;try{n=new URL(e)}catch{return!1}const r="https:"===n.protocol,o=!0===t.allowLocalHttp&&"http:"===n.protocol&&sE.has(n.hostname);return!(!r&&!o)&&(!(!o&&!iE.test(n.hostname))&&(""!==n.host&&""===n.username&&""===n.password&&n.origin===e))}function cE(e){return e.toLowerCase().replace(/^0x/,"")}function uE(e,t){if(!aE(e,t))throw new Error(`Chat binding site is not a clean https origin: ${e}`)}function lE(e,t={}){if(uE(e.site,t),!rE.test(e.chatAddress))throw new Error("Chat address is not 20 bytes of hex.");if(Number.isNaN(e.date.getTime()))throw new Error("Chat binding date is not a valid date.");return[Xv,`${Yv}${e.site}`,`${Qv}0x${cE(e.chatAddress)}`,`${eE}${e.date.toISOString()}`].join("\n")}function fE(e,t){if(!e.startsWith(t))throw new Error(`Chat binding line does not start with "${t}".`);return e.slice(t.length)}function dE(e,t={}){const n=e.split("\n");if(4!==n.length)throw new Error(`Chat binding has ${n.length} lines, not 4.`);const[r,o,i,s]=n;if(r!==Xv)throw new Error("Not a Swarm ID chat binding v1.");const a=fE(o,Yv);uE(a,t);const c=fE(i,Qv);if(!nE.test(c))throw new Error("Chat address is not 0x and 40 lower-case hex characters.");const u=fE(s,eE);if(!function(e){if(!oE.test(e))return!1;const t=Date.parse(e);return!Number.isNaN(t)&&new Date(t).toISOString()===e}(u))throw new Error("Chat binding date is not ISO 8601 UTC.");return{site:a,chatAddress:c,date:u}}function hE(e){const t=(new TextEncoder).encode(e),n=(new TextEncoder).encode(`Ethereum Signed Message:\n${t.length}`),r=new Uint8Array(n.length+t.length);return r.set(n),r.set(t,n.length),Fv(r)}function pE(e){return new Hs(Jv(e)).publicKey().address().toHex()}function mE(e,t,n,r={}){uE(t,r);const o=lE({site:t,chatAddress:pE(jv(e,t)),date:n},r),i=wv.sign(hE(o),Gy(e)),s=(i.recovery+27).toString(16);return{message:o,signature:`0x${i.toCompactHex()}${s}`}}function gE(e,t={}){const n=dE(e.message,t);if(!tE.test(e.signature))throw new Error("Chat binding signature is not 65 bytes of 0x hex.");const r=e.signature.slice(2,130),o=parseInt(e.signature.slice(130),16)-27;if(0!==o&&1!==o)throw new Error("Chat binding signature has a recovery byte other than 27 or 28.");let i;try{const t=wv.Signature.fromCompact(r);if(t.hasHighS())throw new Error("high s");const n=t.addRecoveryBit(o).recoverPublicKey(hE(e.message));s=n.toRawBytes(!1),i=`0x${Hy(Fv(s.slice(1)).slice(-20))}`}catch(e){throw new Error(`Chat binding signature does not recover a signer: ${String(e)}`)}var s;return{signer:i,...n}}function yE(e,t,n={}){if(!e)return;let r;try{r=gE(e,n)}catch{return}return r.site===t.site&&cE(r.chatAddress)===cE(t.chatAddress)&&cE(r.signer)===cE(t.signer)?e:void 0}function wE(e,t){return e.map(e=>{if(e.appUrl===t||void 0===e.chatBinding)return e;const{chatBinding:n,...r}=e;return r})}const bE={allowLocalHttp:!0};function vE(e){try{return Date.parse(dE(e.message,bE).date)}catch{return Number.NEGATIVE_INFINITY}}function EE(e,t,n){try{const r=gE(e,bE);return r.site===t&&cE(r.signer)===cE(n)}catch{return!1}}function _E(e,t,n,r){if(!e||!t)return e??t;const o=EE(e,n,r);return o!==EE(t,n,r)?o?e:t:vE(t)>vE(e)?t:e}export{fh as $,zg as A,Lg as B,Xv as C,Em as D,Ns as E,Jr as F,jh as G,mh as H,Ry as I,Ra as J,gh as K,Vh as L,_a as M,gm as N,Na as O,py as P,Ia as Q,Vs as R,e as S,Js as T,zs as U,$a as V,Ua as W,fd as X,Ds as Y,xd as Z,dh as _,Fs as a,kh as a$,Hh as a0,Bs as a1,ua as a2,la as a3,ca as a4,fa as a5,Wh as a6,Jh as a7,Cs as a8,Qh as a9,da as aA,bs as aB,ph as aC,Gh as aD,Rh as aE,wh as aF,Ep as aG,vp as aH,Ch as aI,cs as aJ,Lh as aK,xp as aL,kp as aM,Ip as aN,$p as aO,Bp as aP,zp as aQ,Sp as aR,Op as aS,Cp as aT,Pp as aU,Fp as aV,Up as aW,Np as aX,Rp as aY,Mh as aZ,xh as a_,ep as aa,op as ab,rp as ac,np as ad,tp as ae,Dh as af,Th as ag,Ks as ah,hh as ai,_h as aj,Oh as ak,pa as al,bh as am,Uh as an,wp as ao,cp as ap,lp as aq,up as ar,fp as as,bp as at,Lf as au,qh as av,Nh as aw,Us as ax,_s as ay,vs as az,vm as b,Gr as b$,ad as b0,dp as b1,hp as b2,gp as b3,yp as b4,sm as b5,am as b6,om as b7,rm as b8,im as b9,nw as bA,uw as bB,Zv as bC,Pa as bD,Mv as bE,ag as bF,ng as bG,sg as bH,Ym as bI,Wm as bJ,qv as bK,jv as bL,Cv as bM,Lv as bN,Dv as bO,ew as bP,Yy as bQ,Qy as bR,Ir as bS,$w as bT,zw as bU,Zm as bV,_E as bW,Aw as bX,eg as bY,Jy as bZ,tg as b_,lm as ba,fm as bb,Zh as bc,hm as bd,pm as be,mm as bf,Xs as bg,cm as bh,um as bi,yh as bj,Sh as bk,jm as bl,wr as bm,Xm as bn,Sr as bo,gr as bp,Fn as bq,ir as br,xr as bs,ig as bt,dr as bu,vn as bv,gw as bw,pw as bx,ym as by,dw as bz,Hs as c,xw as c0,Mm as c1,qm as c2,Hv as c3,Sw as c4,Mw as c5,Lw as c6,wv as c7,iw as c8,_m as c9,Gv as cA,Vv as cB,mE as cC,Vy as cD,Xy as cE,Fw as cF,wm as cG,cg as ca,pE as cb,wE as cc,hg as cd,Py as ce,Uy as cf,lg as cg,Mg as ch,Cg as ci,Fy as cj,Wv as ck,Kv as cl,kw as cm,Jv as cn,fg as co,dg as cp,Cw as cq,Rw as cr,Uw as cs,Ug as ct,Pg as cu,Fv as cv,ug as cw,Am as cx,$m as cy,Vm as cz,Fg as d,Ky as e,Sg as f,qy as g,Ng as h,bm as i,Gy as j,jy as k,Pw as l,Hw as m,Vw as n,yE as o,lE as p,aE as q,dE as r,Iw as s,sh as t,Hy as u,gE as v,Wy as w,Wd as x,Gs as y,lh as z};
23
- //# sourceMappingURL=chat-binding-BirKsDU3.js.map
22
+ const jg=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),qg=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Gg=BigInt(1),Hg=BigInt(2),Vg=(e,t)=>(e+t/Hg)/t;const Kg=function(e,t,n=!1,r={}){if(e<=hg)throw new Error(`Expected Field ORDER > 0, got ${e}`);const{nBitLength:o,nByteLength:i}=Ig(e,t);if(i>2048)throw new Error("Field lengths over 2048 bytes are not supported");const s=kg(e),a=Object.freeze({ORDER:e,BITS:o,BYTES:i,MASK:sg(o),ZERO:hg,ONE:pg,create:t=>vg(t,e),isValid:t=>{if("bigint"!=typeof t)throw new Error("Invalid field element: expected bigint, got "+typeof t);return hg<=t&&t<e},is0:e=>e===hg,isOdd:e=>(e&pg)===pg,neg:t=>vg(-t,e),eql:(e,t)=>e===t,sqr:t=>vg(t*t,e),add:(t,n)=>vg(t+n,e),sub:(t,n)=>vg(t-n,e),mul:(t,n)=>vg(t*n,e),pow:(e,t)=>function(e,t,n){if(n<hg)throw new Error("Expected power > 0");if(n===hg)return e.ONE;if(n===pg)return t;let r=e.ONE,o=t;for(;n>hg;)n&pg&&(r=e.mul(r,o)),o=e.sqr(o),n>>=pg;return r}(a,e,t),div:(t,n)=>vg(t*_g(n,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>_g(t,e),sqrt:r.sqrt||(e=>s(a,e)),invertBatch:e=>function(e,t){const n=new Array(t.length),r=t.reduce((t,r,o)=>e.is0(r)?t:(n[o]=t,e.mul(t,r)),e.ONE),o=e.inv(r);return t.reduceRight((t,r,o)=>e.is0(r)?t:(n[o]=e.mul(t,n[o]),e.mul(t,r)),o),n}(a,e),cmov:(e,t,n)=>n?t:e,toBytes:e=>n?rg(e,i):ng(e,i),fromBytes:e=>{if(e.length!==i)throw new Error(`Fp.fromBytes: expected ${i}, got ${e.length}`);return n?tg(e):eg(e)}});return Object.freeze(a)}(jg,void 0,void 0,{sqrt:function(e){const t=jg,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=xg(l,n,t)*l%t,d=xg(f,n,t)*l%t,h=xg(d,Hg,t)*u%t,p=xg(h,o,t)*h%t,m=xg(p,i,t)*p%t,g=xg(m,a,t)*m%t,y=xg(g,c,t)*g%t,w=xg(y,a,t)*m%t,b=xg(w,n,t)*l%t,v=xg(b,s,t)*p%t,E=xg(v,r,t)*u%t,x=xg(E,Hg,t);if(!Kg.eql(Kg.sqr(x),e))throw new Error("Cannot find square root");return x}}),Wg=function(e,t){const n=t=>Lg({...e,...Zg(t)});return Object.freeze({...n(t),create:n})}({a:BigInt(0),b:BigInt(7),Fp:Kg,n:qg,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{const t=qg,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-Gg*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=n,s=BigInt("0x100000000000000000000000000000000"),a=Vg(i*e,t),c=Vg(-r*e,t);let u=vg(e-a*n-c*o,t),l=vg(-a*r-c*i,t);const f=u>s,d=l>s;if(f&&(u=t-u),d&&(l=t-l),u>s||l>s)throw new Error("splitScalar: Endomorphism failed, k="+e);return{k1neg:f,k1:u,k2neg:d,k2:l}}}},qm);BigInt(0),Wg.ProjectivePoint;const Jg=BigInt(2**32-1),Xg=BigInt(32);function Yg(e,t=!1){return t?{h:Number(e&Jg),l:Number(e>>Xg&Jg)}:{h:0|Number(e>>Xg&Jg),l:0|Number(e&Jg)}}function Qg(e,t=!1){let n=new Uint32Array(e.length),r=new Uint32Array(e.length);for(let o=0;o<e.length;o++){const{h:i,l:s}=Yg(e[o],t);[n[o],r[o]]=[i,s]}return[n,r]}const[ey,ty,ny]=[[],[],[]],ry=BigInt(0),oy=BigInt(1),iy=BigInt(2),sy=BigInt(7),ay=BigInt(256),cy=BigInt(113);for(let e=0,t=oy,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],ey.push(2*(5*r+n)),ty.push((e+1)*(e+2)/2%64);let o=ry;for(let e=0;e<7;e++)t=(t<<oy^(t>>sy)*cy)%ay,t&iy&&(o^=oy<<(oy<<BigInt(e))-oy);ny.push(o)}const[uy,ly]=Qg(ny,!0),fy=(e,t,n)=>n>32?((e,t,n)=>t<<n-32|e>>>64-n)(e,t,n):((e,t,n)=>e<<n|t>>>32-n)(e,t,n),dy=(e,t,n)=>n>32?((e,t,n)=>e<<n-32|t>>>64-n)(e,t,n):((e,t,n)=>t<<n|e>>>32-n)(e,t,n);class hy extends Rm{constructor(e,t,n,r=!1,o=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=n,this.enableXOF=r,this.rounds=o,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,Am(n),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");var i;this.state=new Uint8Array(200),this.state32=(i=this.state,new Uint32Array(i.buffer,i.byteOffset,Math.floor(i.byteLength/4)))}keccak(){!function(e,t=24){const n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let t=0;t<10;t++)n[t]=e[t]^e[t+10]^e[t+20]^e[t+30]^e[t+40];for(let t=0;t<10;t+=2){const r=(t+8)%10,o=(t+2)%10,i=n[o],s=n[o+1],a=fy(i,s,1)^n[r],c=dy(i,s,1)^n[r+1];for(let n=0;n<50;n+=10)e[t+n]^=a,e[t+n+1]^=c}let t=e[2],o=e[3];for(let n=0;n<24;n++){const r=ty[n],i=fy(t,o,r),s=dy(t,o,r),a=ey[n];t=e[a],o=e[a+1],e[a]=i,e[a+1]=s}for(let t=0;t<50;t+=10){for(let r=0;r<10;r++)n[r]=e[t+r];for(let r=0;r<10;r++)e[t+r]^=~n[(r+2)%10]&n[(r+4)%10]}e[0]^=uy[r],e[1]^=ly[r]}n.fill(0)}(this.state32,this.rounds),this.posOut=0,this.pos=0}update(e){$m(this);const{blockLen:t,state:n}=this,r=(e=Nm(e)).length;for(let o=0;o<r;){const i=Math.min(t-this.pos,r-o);for(let t=0;t<i;t++)n[this.pos++]^=e[o++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:n,blockLen:r}=this;e[n]^=t,128&t&&n===r-1&&this.keccak(),e[r-1]^=128,this.keccak()}writeInto(e){$m(this,!1),Im(e),this.finish();const t=this.state,{blockLen:n}=this;for(let r=0,o=e.length;r<o;){this.posOut>=n&&this.keccak();const i=Math.min(n-this.posOut,o-r);e.set(t.subarray(this.posOut,this.posOut+i),r),this.posOut+=i,r+=i}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return Am(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(Bm(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:t,suffix:n,outputLen:r,rounds:o,enableXOF:i}=this;return e||(e=new hy(t,n,r,i,o)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=o,e.suffix=n,e.outputLen=r,e.enableXOF=i,e.destroyed=this.destroyed,e}}const py=((e,t,n)=>Um(()=>new hy(t,e,n)))(1,136,32);function my(e){const t=e.replace(/^0x/i,"");if(t.length%2!=0||!/^[0-9a-fA-F]*$/.test(t))throw new Error("Invalid hex string.");const n=new Uint8Array(t.length/2);for(let e=0;e<t.length;e+=2)n[e/2]=parseInt(t.substring(e,e+2),16);return n}function gy(e){return Array.from(e).map(e=>e.toString(16).padStart(2,"0")).join("")}function yy(e){const t=e.replace(/^0x/i,"").toLowerCase();if(!/^[0-9a-f]{40}$/.test(t))throw new Error(`Invalid hex address: expected 40 hex characters (with optional 0x prefix), got "${e}"`);return t}const wy=/^0x[0-9a-fA-F]{130}$/;function by(e){const t=(new TextEncoder).encode(e),n=(new TextEncoder).encode(`Ethereum Signed Message:\n${t.length}`),r=new Uint8Array(n.length+t.length);return r.set(n),r.set(t,n.length),py(r)}function vy(e,t){const n=Wg.sign(by(e),my(t)),r=(n.recovery+27).toString(16);return`0x${n.toCompactHex()}${r}`}function Ey(e,t,n){if(!wy.test(t))throw new Error(`${n} is not 65 bytes of 0x hex.`);const r=t.slice(2,130),o=parseInt(t.slice(130),16)-27;if(0!==o&&1!==o)throw new Error(`${n} has a recovery byte other than 27 or 28.`);try{const t=Wg.Signature.fromCompact(r);if(t.hasHighS())throw new Error("high s");const n=t.addRecoveryBit(o).recoverPublicKey(by(e));return i=n.toRawBytes(!1),`0x${gy(py(i.slice(1)).slice(-20))}`}catch(e){throw new Error(`${n} does not recover a signer: ${String(e)}`)}var i}const xy="Swarm ID wallet link v1",_y="I link this wallet to the Swarm ID account below, so sites may show my ENS name beside its messages.",ky="Account: ",Ay="Wallet: ",Iy="Date: ",$y=/^0x[0-9a-f]{40}$/,By=/^(0x)?[0-9a-fA-F]{40}$/,Sy=/^0x[0-9a-f]{130}$/,zy=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/;function Oy(e){return e.toLowerCase().replace(/^0x/,"")}function Ty(e,t,n){if(!Sy.test(t))throw new Error(`${n} is not 0x and 130 lower-case hex characters.`);return Ey(e,t,n)}function Ny(e){if(!By.test(e.account))throw new Error("Wallet link account is not 20 bytes of hex.");if(!By.test(e.wallet))throw new Error("Wallet link wallet is not 20 bytes of hex.");if(Number.isNaN(e.date.getTime()))throw new Error("Wallet link date is not a valid date.");return[xy,_y,`${ky}0x${Oy(e.account)}`,`${Ay}0x${Oy(e.wallet)}`,`${Iy}${e.date.toISOString()}`].join("\n")}function Ry(e,t){if(!e.startsWith(t))throw new Error(`Wallet link line does not start with "${t}".`);return e.slice(t.length)}function Uy(e,t){const n=Ry(e,t);if(!$y.test(n))throw new Error(`Wallet link "${t.trim()}" is not 0x and 40 lower-case hex characters.`);return n}function Py(e){const t=e.split("\n");if(5!==t.length)throw new Error(`Wallet link has ${t.length} lines, not 5.`);const[n,r,o,i,s]=t;if(n!==xy)throw new Error("Not a Swarm ID wallet link v1.");if(r!==_y)throw new Error("Wallet link statement is not the v1 statement.");const a=Uy(o,ky),c=Uy(i,Ay),u=Ry(s,Iy);if(!function(e){if(!zy.test(e))return!1;const t=Date.parse(e);return!Number.isNaN(t)&&new Date(t).toISOString()===e}(u))throw new Error("Wallet link date is not ISO 8601 UTC.");return{account:a,wallet:c,date:u}}function Fy(e,t){try{const n=Py(e.message),r=Ty(e.message,e.walletSignature,"Wallet link wallet signature"),o=Ty(e.message,e.accountSignature,"Wallet link account signature");return r===n.wallet&&o===n.account&&n.account===`0x${Oy(t.account)}`?n:void 0}catch{return}}function Cy(e,t,n){const r=Py(t);if(Ty(t,n,"Wallet link wallet signature")!==r.wallet)throw new Error("The wallet signature does not recover the wallet the link names.");if(`0x${new Js(e).publicKey().address().toHex()}`!==r.account)throw new Error("The link names another account than this key's.");return{message:t,walletSignature:n,accountSignature:vy(t,e)}}const Ly="https://api.gateway.ethswarm.org/",My="https://xdai.fairdatasociety.org/",Dy=e=>Fn().regex(new RegExp(`^[0-9a-fA-F]{${e}}$`),{message:`Must be a ${e}-character hex string`}),Zy=Fn().regex(/^[0-9a-fA-F]{64}$|^[0-9a-fA-F]{128}$/,{message:"Reference must be 64 hex chars (32 bytes) or 128 hex chars (64 bytes for encrypted)"}),jy=Dy(64),qy=Dy(40),Gy=Dy(64),Hy=Dy(66),Vy=Dy(64),Ky=Dy(64),Wy=Dy(130),Jy=Dy(64),Xy=Dy(226),Yy=Hr(e=>"bigint"==typeof e?e.toString():e,Er([ir(),Fn()])),Qy=Hr(e=>"bigint"==typeof e?e.toString():e,Er([ir(),Fn()])),ew=qy.transform(e=>new Fs(e)),tw=jy.transform(e=>new Ns(e)),nw=Gy.transform(e=>new Js(e)),rw=Fn().regex(/^\d+$/,{message:"Must be a decimal integer string"}).transform(e=>BigInt(e)),ow=wr({deviceId:Fn(),createdAt:ir(),lastSignedInAt:ir(),name:Fn().optional(),nameUpdatedAt:ir().optional(),removedAt:ir().optional()}),iw=wr({message:Fn().max(512),signature:Fn().regex(/^0x[0-9a-fA-F]{130}$/)}),sw=wr({message:Fn().max(320),walletSignature:Fn().regex(Sy),accountSignature:Fn().regex(Sy)}),aw=wr({appSessionDuration:ir().optional()}),cw="none",uw=wr({appUrl:Fn(),appName:Fn(),lastConnectedAt:ir(),appIcon:Fn().optional(),appDescription:Fn().optional(),connectedUntil:ir().optional(),appSecret:Fn().optional(),postageStampBatchID:Er([zr(cw),tw]).optional(),postageStampBatchIDAt:ir().optional(),stampPending:zr(!0).optional(),revokedAt:ir().optional(),disconnectedAt:ir().optional(),chatBinding:iw.optional()}),lw=wr({batchID:tw,signerKey:nw,name:Fn().optional(),nameUpdatedAt:ir().optional(),utilization:ir(),usable:ur(),depth:ir(),amount:rw,bucketDepth:ir(),blockNumber:ir(),immutableFlag:ur(),exists:ur(),batchTTL:ir().optional(),createdAt:ir(),updatedAt:ir().optional(),deletedAt:ir().optional()}),fw=_r("type",[wr({type:zr("passkey"),credentialId:Fn()}),wr({type:zr("eth-wallet"),encryptionSalt:Fn()}),wr({type:zr("password"),kdfSalt:Fn(),kdfIterations:ir()})]),dw=wr({access:fw,encryptedSeed:Fn().regex(/^([0-9a-f]{2})+$/)}),hw=wr({id:ew,name:Fn(),createdAt:ir(),derivationKey:Fn().length(64),publicKey:Hy,defaultPostageStampBatchID:tw.optional(),devices:gr(ow).default([]),connectedApps:gr(uw).default([]),postageStamps:gr(lw).default([]),settings:aw.optional(),walletLink:sw.optional(),accountNameAt:ir().optional(),defaultStampAt:ir().optional(),settingsAt:ir().optional(),walletLinkAt:ir().optional(),lastModified:ir().optional(),partitionCount:ir().int().min(1).optional()}),pw=hw.extend({...dw.shape,signedOutAt:function(e){return function(e,t){return new e({type:"undefined",..._(t)})}(lr,e)}().optional()}),mw=Er([pw,wr({id:ew,name:Fn(),createdAt:ir(),...dw.shape,encryptedState:Fn().optional(),storageWarning:ur().optional(),soonestDriveExpiry:ir().optional(),signedOutAt:ir()})]),gw=wr({accountName:Fn(),defaultPostageStampBatchID:Fn().length(64).optional(),publicKey:Hy,settings:aw.optional(),walletLink:sw.optional(),accountNameAt:ir().optional(),defaultStampAt:ir().optional(),settingsAt:ir().optional(),walletLinkAt:ir().optional(),createdAt:ir(),lastModified:ir(),devices:gr(ow).default([]),partitionCount:ir().int().min(1).default(1)}),yw=wr({version:zr(1),timestamp:ir(),accountId:Fn().length(40),metadata:gw,connectedApps:gr(uw),postageStamps:gr(lw)});function ww(e){return void 0!==e.signedOutAt}const bw=wr({timestampMs:ir().int().nonnegative(),tiebreaker:Fn().regex(/^[0-9a-f]{16}$/)}),vw=wr({holderDeviceId:Fn(),generation:bw,acquiredAt:ir().int().nonnegative(),leasedUntil:ir().int().nonnegative()}),Ew=wr({deviceId:Fn(),generation:bw,leasedUntil:ir().int().nonnegative().optional()}),xw=wr({beeNodeUrl:Fn().refine(xm,"Must be an http(s) URL"),gnosisRpcUrl:Fn().refine(xm,"Must be an http(s) URL")}),_w=Fn().refine(_m,"Must be an http(s) URL, optionally with a path, and no credentials, query or fragment"),kw=wr({index:ir().int().min(0).max(65535),value:ir().int().min(0)}),Aw=wr({type:zr("utilization-updated"),batchId:Fn().length(64),partition:ir().int().min(0),partitionCount:ir().int().min(1),buckets:gr(kw)}),Iw="swarm-id-accounts",$w="swarm-id-network-settings",Bw="swarm-storage-challenge",Sw="swarm-id-site-allow-list";function zw(e,t){return`swarm-id-lease-v2:${e.toLowerCase()}:${t.toLowerCase()}`}function Ow(e,t){return`swarm-id-app-stamp-usage:${e}:${t.toLowerCase()}`}function Tw(e,t){return`swarm-id-soc-restamp-slots:${e}:${t.toLowerCase()}`}function Nw(e){return`swarm-id-partition-session:${e}`}const Rw=wr({pin:ur().optional(),encrypt:ur().optional(),encryptManifest:ur().optional(),tag:ir().optional(),deferred:ur().optional()}),Uw=Rw.optional(),Pw=Br(["app","identity"]),Fw=Rw.extend({beeCompatible:ur().optional(),publisher:Pw.optional()}).optional(),Cw=wr({timeout:ir().optional(),headers:Ir(Fn(),Fn()).optional(),endlesslyRetry:ur().optional()}).optional(),Lw=wr({redundancyStrategy:Er([zr(0),zr(1),zr(2),zr(3)]).optional(),fallback:ur().optional(),timeoutMs:ir().optional(),actPublisher:Er([Gr(Uint8Array),Fn()]).optional(),actHistoryAddress:Er([Gr(Uint8Array),Fn()]).optional(),actTimestamp:Er([ir(),Fn()]).optional()}).optional(),Mw=Rw.extend({indexDocument:Fn().optional(),errorDocument:Fn().optional()}).optional(),Dw=wr({path:Fn().min(1),data:Gr(Uint8Array),contentType:Fn().optional()}),Zw=wr({path:Fn(),reference:Zy,contentType:Fn().optional()}),jw=wr({reference:Zy,tagUid:ir().optional()});jw.extend({encryptionKey:Fn().optional(),owner:qy}),jw.extend({encryptionKey:Fn().optional(),owner:qy}),wr({name:Fn(),data:Gr(Uint8Array)});const qw=wr({batchID:jy,utilization:ir(),usable:ur(),label:Fn(),depth:ir(),amount:Fn(),bucketDepth:ir(),blockNumber:ir(),immutableFlag:ur(),exists:ur(),batchTTL:ir().optional()});wr({authenticated:ur(),origin:Fn().optional(),beeApiUrl:Fn().url().optional()});const Gw=Br(["user-stamp","subsidised","unavailable"]),Hw=Br(["no-stamp","stamper-failed","stamp-expired","stamp-not-usable","subsidised","app-stamp-count","app-stamp-rate","app-bucket-share","app-slice-full","session-unconfirmed"]),Vw=wr({source:Br(["generated"]),url:Fn()}),Kw=wr({id:Fn(),name:Fn(),address:qy,publicKey:Hy.optional(),sharingPublicKey:Hy.optional(),postageSignerAddress:qy.optional(),avatar:Vw,walletLink:sw.optional()});wr({canUpload:ur(),storagePartitioned:ur().optional(),uploadMode:Gw.optional(),uploadUnavailableReason:Hw.optional(),partition:ir().int().min(0).optional(),identity:Kw.optional(),appKey:wr({address:qy,publicKey:Hy}).optional(),chatBinding:iw.optional(),beeApiUrl:Fn().optional(),postageBatchId:jy.optional()});const Ww=wr({name:Fn().min(1).max(100),description:Fn().max(500).optional(),icon:Fn().optional().refine(e=>{if(!e)return!0;if(!e.startsWith("data:image/"))return!1;if(!e.match(/^data:image\/(svg\+xml|png);/))return!1;const t=e.match(/base64,(.+)$/);if(t){if(3*t[1].length/4>4096)return!1}return!0},{message:"Icon must be a data URL with SVG or PNG mime type, max 4KB"})}),Jw=Br(["sign-in","change-stamp"]),Xw=["localhost","127.0.0.1","[::1]"];const Yw=wr({family:Fn().min(1),url:Fn().refine(function(e){let t;try{t=new URL(e)}catch{return!1}return!t.username&&!t.password&&("https:"===t.protocol||"http:"===t.protocol&&Xw.includes(t.hostname))},{message:"A font file is served over https, or over http on localhost, with no user name or password in its URL"}),weight:Er([Fn(),ir()]).optional(),style:Br(["normal","italic","oblique"]).optional()}),Qw=wr({text:Fn().optional(),busyText:Fn().optional(),ariaLabel:Fn().optional(),disabled:ur().optional(),busy:ur().optional(),backgroundColor:Fn().optional(),color:Fn().optional(),borderRadius:Fn().optional(),borderColor:Fn().optional(),borderWidth:Fn().optional(),borderStyle:Br(["solid","dashed","dotted","double"]).optional(),fontFamily:Fn().optional(),fontSize:Fn().optional(),fontWeight:Er([Fn(),ir()]).optional(),fontFaces:gr(Yw).max(8).optional()}),eb=Br(["open","closed","blocked"]),tb=wr({type:zr("buttonIdentify"),action:Jw,config:Qw.optional(),metadata:Ww,popupMode:Br(["popup","window"]).optional()}),nb=wr({type:zr("buttonUpdate"),action:Jw,config:Qw.optional()});_r("type",[tb,nb]);const rb=_r("type",[wr({type:zr("buttonReady")}),wr({type:zr("buttonInitError"),error:Fn()}),wr({type:zr("buttonWindowChanged"),state:eb})]),ob=wr({type:zr("connectWindowOpened"),challenge:Fn()}),ib="buttonFrameLoaded",sb=wr({type:zr("parentIdentify"),requestId:Fn(),beeApiUrl:_w.optional(),metadata:Ww,subsidisedGatewayUrl:Fn().url().optional()}),ab=wr({type:zr("checkAuth"),requestId:Fn()}),cb=wr({type:zr("disconnect"),requestId:Fn()}),ub=wr({type:zr("uploadData"),requestId:Fn(),data:Gr(Uint8Array),options:Uw,requestOptions:Cw,enableProgress:ur().optional(),useWebSocket:ur().optional(),useWorkers:ur().optional(),workerCount:ir().int().min(1).max(32).optional(),concurrency:ir().int().min(1).max(256).optional()}),lb=wr({type:zr("downloadData"),requestId:Fn(),reference:Zy,options:Lw,requestOptions:Cw}),fb=wr({type:zr("deriveAppSecret"),requestId:Fn(),label:Fn()}),db=wr({type:zr("setBeeApiUrl"),requestId:Fn(),beeApiUrl:_w}),hb=wr({type:zr("getChatKey"),requestId:Fn()}),pb=Er([zr("app"),br({privateKey:Gy})]),mb=_r("kind",[br({kind:zr("content"),data:Gr(Uint8Array)}),br({kind:zr("soc"),identifier:Ky,data:Gr(Uint8Array),signer:pb})]),gb=br({type:zr("stampChunk"),requestId:Fn(),chunk:mb}),yb=wr({type:zr("uploadFile"),requestId:Fn(),data:Gr(Uint8Array),name:Fn().optional(),options:Uw,requestOptions:Cw,enableProgress:ur().optional(),useWebSocket:ur().optional(),useWorkers:ur().optional(),workerCount:ir().int().min(1).max(32).optional(),concurrency:ir().int().min(1).max(256).optional()}),wb=wr({type:zr("downloadFile"),requestId:Fn(),reference:Zy,path:Fn().optional(),options:Lw,requestOptions:Cw}),bb=wr({type:zr("uploadFiles"),requestId:Fn(),files:gr(Dw),options:Mw,requestOptions:Cw,enableProgress:ur().optional(),useWorkers:ur().optional(),workerCount:ir().int().min(1).max(32).optional()}),vb=wr({type:zr("listFiles"),requestId:Fn(),reference:Zy,requestOptions:Cw}),Eb=wr({type:zr("uploadChunk"),requestId:Fn(),data:Gr(Uint8Array),options:Uw,requestOptions:Cw}),xb=wr({type:zr("downloadChunk"),requestId:Fn(),reference:Zy,options:Lw,requestOptions:Cw}),_b=wr({type:zr("isConnected"),requestId:Fn()}),kb=wr({type:zr("getNodeInfo"),requestId:Fn()}),Ab=wr({type:zr("gsocMine"),requestId:Fn(),targetOverlay:Fn(),identifier:Fn(),proximity:ir().optional()}),Ib=wr({type:zr("gsocSend"),requestId:Fn(),signer:Fn(),identifier:Fn(),data:Gr(Uint8Array),options:Uw,requestOptions:Cw}),$b=wr({type:zr("socUpload"),requestId:Fn(),identifier:Ky,data:Gr(Uint8Array),signer:Gy.optional(),options:Uw,requestOptions:Cw}),Bb=wr({type:zr("socRawUpload"),requestId:Fn(),identifier:Ky,data:Gr(Uint8Array),signer:Gy.optional(),options:Uw,requestOptions:Cw}),Sb=wr({type:zr("socDownload"),requestId:Fn(),owner:qy.optional(),identifier:Ky,encryptionKey:Vy,requestOptions:Cw}),zb=wr({type:zr("socRawDownload"),requestId:Fn(),owner:qy.optional(),identifier:Ky,encryptionKey:Vy.optional(),requestOptions:Cw}),Ob=wr({type:zr("socGetOwner"),requestId:Fn()}),Tb=wr({type:zr("epochFeedDownloadReference"),requestId:Fn(),topic:Ky,owner:qy.optional(),at:Yy,after:Yy.optional(),encryptionKey:Vy.optional(),requestOptions:Cw}),Nb=wr({lastEpoch:wr({start:Fn(),level:ir()}).optional(),lastTimestamp:Fn().optional()}).optional(),Rb=_r("type",[sb,ab,cb,ub,lb,fb,hb,db,gb,yb,wb,bb,vb,Eb,xb,_b,kb,Ab,Ib,$b,Bb,Sb,zb,Ob,Tb,wr({type:zr("epochFeedUploadReference"),requestId:Fn(),topic:Ky,signer:Gy.optional(),at:Yy,reference:Zy,encryptionKey:Vy.optional(),hints:Nb,requestOptions:Cw}),wr({type:zr("feedGetOwner"),requestId:Fn()}),wr({type:zr("seqFeedGetOwner"),requestId:Fn()}),wr({type:zr("seqFeedDownloadPayload"),requestId:Fn(),topic:Ky,owner:qy.optional(),index:Qy.optional(),at:Yy.optional(),hasTimestamp:ur().optional(),lookupTimeoutMs:ir().optional(),encryptionKey:Vy,requestOptions:Cw}),wr({type:zr("seqFeedDownloadRawPayload"),requestId:Fn(),topic:Ky,owner:qy.optional(),index:Qy.optional(),at:Yy.optional(),hasTimestamp:ur().optional(),lookupTimeoutMs:ir().optional(),encryptionKey:Vy.optional(),requestOptions:Cw}),wr({type:zr("seqFeedDownloadReference"),requestId:Fn(),topic:Ky,owner:qy.optional(),index:Qy.optional(),at:Yy.optional(),hasTimestamp:ur().optional(),lookupTimeoutMs:ir().optional(),encryptionKey:Vy,requestOptions:Cw}),wr({type:zr("seqFeedUploadPayload"),requestId:Fn(),topic:Ky,signer:Gy.optional(),data:Gr(Uint8Array),index:Qy.optional(),at:Yy.optional(),hasTimestamp:ur().optional(),lookupTimeoutMs:ir().optional(),options:Uw,requestOptions:Cw}),wr({type:zr("seqFeedUploadRawPayload"),requestId:Fn(),topic:Ky,signer:Gy.optional(),data:Gr(Uint8Array),index:Qy.optional(),at:Yy.optional(),hasTimestamp:ur().optional(),lookupTimeoutMs:ir().optional(),encryptionKey:Vy.optional(),options:Uw,requestOptions:Cw}),wr({type:zr("seqFeedUploadReference"),requestId:Fn(),topic:Ky,signer:Gy.optional(),reference:Zy,index:Qy.optional(),at:Yy.optional(),hasTimestamp:ur().optional(),lookupTimeoutMs:ir().optional(),options:Uw,requestOptions:Cw}),wr({type:zr("createFeedManifest"),requestId:Fn(),topic:Ky,owner:qy.optional(),feedType:Br(["Sequence","Epoch"]).optional(),uploadOptions:Uw,requestOptions:Cw}),wr({type:zr("actUploadData"),requestId:Fn(),data:Gr(Uint8Array),grantees:gr(Fn()),options:Fw,requestOptions:Cw,enableProgress:ur().optional()}),wr({type:zr("actDownloadData"),requestId:Fn(),encryptedReference:Zy,historyReference:Zy,publisherPubKey:Fn(),timestamp:ir().optional(),requestOptions:Cw}),wr({type:zr("actAddGrantees"),requestId:Fn(),historyReference:Zy,grantees:gr(Fn()),requestOptions:Cw}),wr({type:zr("actRevokeGrantees"),requestId:Fn(),historyReference:Zy,encryptedReference:Zy,revokeGrantees:gr(Fn()),requestOptions:Cw}),wr({type:zr("actGetGrantees"),requestId:Fn(),historyReference:Zy,requestOptions:Cw}),wr({type:zr("getPostageBatch"),requestId:Fn()})]),Ub=wr({type:zr("proxyReady"),authenticated:ur(),parentOrigin:Fn(),storageShared:ur().optional()}),Pb=wr({type:zr("initError"),error:Fn()}),Fb=wr({type:zr("authStatusResponse"),requestId:Fn(),authenticated:ur(),origin:Fn().optional(),beeApiUrl:Fn().url().optional()}),Cb=wr({type:zr("disconnectResponse"),requestId:Fn(),success:ur()}),Lb=wr({type:zr("authSuccess"),origin:Fn()}),Mb=wr({type:zr("uploadDataResponse"),requestId:Fn(),reference:Zy,tagUid:ir().optional()}),Db=wr({type:zr("downloadDataResponse"),requestId:Fn(),data:Gr(Uint8Array)}),Zb=wr({type:zr("deriveAppSecretResponse"),requestId:Fn(),secret:Gr(Uint8Array)}),jb=wr({type:zr("getChatKeyResponse"),requestId:Fn(),chatKey:Gr(Uint8Array)}),qb=wr({type:zr("setBeeApiUrlResponse"),requestId:Fn(),beeApiUrl:Fn()}),Gb=wr({type:zr("stampChunkResponse"),requestId:Fn(),address:Jy,stamp:Xy,owner:qy.optional(),signature:Wy.optional()}),Hb=wr({type:zr("uploadFileResponse"),requestId:Fn(),reference:Zy,tagUid:ir().optional()}),Vb=wr({type:zr("downloadFileResponse"),requestId:Fn(),name:Fn(),data:Gr(Uint8Array)}),Kb=wr({type:zr("uploadFilesResponse"),requestId:Fn(),reference:Zy,tagUid:ir().optional()}),Wb=wr({type:zr("listFilesResponse"),requestId:Fn(),entries:gr(Zw)}),Jb=wr({type:zr("uploadChunkResponse"),requestId:Fn(),reference:Zy}),Xb=wr({type:zr("downloadChunkResponse"),requestId:Fn(),data:Gr(Uint8Array)}),Yb=wr({type:zr("uploadProgress"),requestId:Fn(),total:ir(),processed:ir()}),Qb=Br(["not-authenticated","upload-unavailable","partition-contended","lease-lost","bee-rejected","network","timeout","invalid-request","invalid-state","init-failed","popup-blocked","button-required","internal"]),ev=_r("type",[Ub,Pb,Fb,Cb,Lb,Mb,Db,Zb,jb,qb,Gb,Hb,Vb,Kb,Wb,Jb,Xb,Yb,wr({error:Fn(),code:Qb.catch("internal"),reason:Hw.optional().catch(void 0),status:ir().int().optional(),beeMessage:Fn().optional(),url:Fn().optional()}).extend({type:zr("error"),requestId:Fn()}),wr({type:zr("connectionInfoChanged"),canUpload:ur(),storagePartitioned:ur().optional(),uploadMode:Gw.optional(),uploadUnavailableReason:Hw.optional().catch(void 0),identity:Kw.optional(),appKey:wr({address:qy,publicKey:Hy}).optional(),partition:ir().int().min(0).optional(),chatBinding:iw.optional(),beeApiUrl:Fn().optional(),postageBatchId:jy.optional()}),wr({type:zr("isConnectedResponse"),requestId:Fn(),connected:ur()}),wr({type:zr("getNodeInfoResponse"),requestId:Fn(),beeMode:Fn(),chequebookEnabled:ur(),swapEnabled:ur()}),wr({type:zr("gsocMineResponse"),requestId:Fn(),signer:Fn()}),wr({type:zr("gsocSendResponse"),requestId:Fn(),reference:Zy,tagUid:ir().optional()}),wr({type:zr("socUploadResponse"),requestId:Fn(),reference:Zy,tagUid:ir().optional(),encryptionKey:Fn().optional(),owner:qy}),wr({type:zr("socRawUploadResponse"),requestId:Fn(),reference:Zy,tagUid:ir().optional(),encryptionKey:Fn().optional(),owner:qy}),wr({type:zr("socDownloadResponse"),requestId:Fn(),data:Gr(Uint8Array),identifier:Ky,signature:Wy,span:ir(),payload:Gr(Uint8Array),address:Zy,owner:qy}),wr({type:zr("socRawDownloadResponse"),requestId:Fn(),data:Gr(Uint8Array),identifier:Ky,signature:Wy,span:ir(),payload:Gr(Uint8Array),address:Zy,owner:qy}),wr({type:zr("socGetOwnerResponse"),requestId:Fn(),owner:qy}),wr({type:zr("epochFeedDownloadReferenceResponse"),requestId:Fn(),reference:Zy.optional()}),wr({type:zr("epochFeedUploadReferenceResponse"),requestId:Fn(),socAddress:Zy,encryptionKey:Vy.optional(),epoch:wr({start:Fn(),level:ir()}),timestamp:Fn()}),wr({type:zr("feedGetOwnerResponse"),requestId:Fn(),owner:qy}),wr({type:zr("seqFeedGetOwnerResponse"),requestId:Fn(),owner:qy}),wr({type:zr("seqFeedDownloadPayloadResponse"),requestId:Fn(),payload:Gr(Uint8Array),timestamp:ir().optional(),feedIndex:Fn(),feedIndexNext:Fn()}),wr({type:zr("seqFeedDownloadRawPayloadResponse"),requestId:Fn(),payload:Gr(Uint8Array),timestamp:ir().optional(),feedIndex:Fn(),feedIndexNext:Fn()}),wr({type:zr("seqFeedDownloadReferenceResponse"),requestId:Fn(),reference:Zy,feedIndex:Fn(),feedIndexNext:Fn()}),wr({type:zr("seqFeedUploadPayloadResponse"),requestId:Fn(),reference:Zy,feedIndex:Fn(),owner:qy,encryptionKey:Fn().optional(),tagUid:ir().optional()}),wr({type:zr("seqFeedUploadRawPayloadResponse"),requestId:Fn(),reference:Zy,feedIndex:Fn(),owner:qy,encryptionKey:Fn().optional(),tagUid:ir().optional()}),wr({type:zr("seqFeedUploadReferenceResponse"),requestId:Fn(),reference:Zy,feedIndex:Fn(),owner:qy,encryptionKey:Fn().optional(),tagUid:ir().optional()}),wr({type:zr("createFeedManifestResponse"),requestId:Fn(),reference:Zy}),wr({type:zr("actUploadDataResponse"),requestId:Fn(),encryptedReference:Zy,historyReference:Zy,granteeListReference:Zy,publisherPubKey:Fn(),actReference:Zy,tagUid:ir().optional()}),wr({type:zr("actDownloadDataResponse"),requestId:Fn(),data:Gr(Uint8Array)}),wr({type:zr("actAddGranteesResponse"),requestId:Fn(),historyReference:Zy,granteeListReference:Zy,actReference:Zy}),wr({type:zr("actRevokeGranteesResponse"),requestId:Fn(),encryptedReference:Zy,historyReference:Zy,granteeListReference:Zy,actReference:Zy}),wr({type:zr("actGetGranteesResponse"),requestId:Fn(),grantees:gr(Fn())}),wr({type:zr("getPostageBatchResponse"),requestId:Fn(),postageBatch:qw.optional()})]),tv=wr({secret:Fn(),networkSettings:xw.optional(),account:hw,chatBinding:iw.optional(),stampPending:zr(!0).optional()}),nv=wr({version:zr(1),parentOrigin:Fn(),connectedUntil:ir(),data:Fn()}),rv=_r("type",[wr({type:zr("setSecret"),appOrigin:Fn(),challenge:Fn(),data:tv})]),ov="#FCFCFC",iv="#131416",sv=[["#FFE0CC","#DD7200","#401F00"],["#99CCFF","#0082FB","#003366"],["#99E6B3","#00C853","#004D1F"],["#E1BEE7","#9C27B0","#4A148C"]],av=[];for(const e of sv)av.push([e[1],ov]),av.push([e[1],iv]),av.push([ov,e[1]]),av.push([iv,e[1]]);for(const e of sv)av.push([e[0],e[1]]),av.push([e[2],e[1]]),av.push([e[1],e[0]]),av.push([e[1],e[2]]),av.push([e[0],e[2]]),av.push([e[2],e[0]]);for(let e=0;e<sv.length;e++){const t=sv[(e+1)%sv.length];av.push([sv[e][0],t[2]]),av.push([t[2],sv[e][0]])}const cv=[[0,1],[1,0],[0,-1],[-1,0]];function uv(e,t=40){const n=function(e){let t=0;for(let n=0;n<e.length;n++)t=e.charCodeAt(n)+(t<<6)+(t<<16)-t;return t}(e.length<6?e.padEnd(6," "):e),[r,o]=av[Math.abs(n)%av.length],i=.25*t,s=(t-2*i)/2,a=Array.from({length:2},()=>Array(2).fill(!1)),c=Math.floor(1),u=[[c,c]];a[c][c]=!0;let l="";for(let e=u.pop();void 0!==e;e=u.pop()){const[t,r]=e,o=15&Math.abs(n>>3*t+5*r),c=[];for(const[e,n]of cv){const o=t+e,i=r+n;o>=0&&o<2&&i>=0&&i<2&&!a[o][i]&&c.push([o,i])}for(;c.length>0;){const e=Math.abs(o+c.length)%c.length,[t,n]=c.splice(e,1)[0];u.push([t,n]),a[t][n]=!0}const f=o%4*90,d=i+t*s,h=i+r*s;l+=o%5==0?`M${d},${h} h${s} v${s} h-${s}z `:0===f?`M${d},${h} h${s} v${s}z `:90===f?`M${d+s},${h} v${s} h-${s}z `:180===f?`M${d+s},${h+s} h-${s} v-${s}z `:`M${d},${h+s} v-${s} h${s}z `}return`<svg xmlns="http://www.w3.org/2000/svg" width="${t}" height="${t}" viewBox="0 0 ${t} ${t}"><rect width="${t}" height="${t}" fill="${r}"/><path d="${l}" fill="${o}"/></svg>`}function lv(e,t=40){const n=uv(e,t);return{source:"generated",url:`data:image/svg+xml;charset=utf-8,${encodeURIComponent(n)}`}}class fv extends Error{constructor(e){super(e),this.name="TimeoutError"}}function dv(e,t,n){let r;const o=new Promise((e,o)=>{r=setTimeout(()=>o(new fv(n)),t)});return Promise.race([e,o]).finally(()=>clearTimeout(r))}function hv(e){return new Promise(t=>setTimeout(t,e))}function pv(e,t,n){let r,o=!1,i=()=>{};const s=new Promise((e,s)=>{i=()=>{o||(clearTimeout(r),r=setTimeout(()=>s(new fv(n)),t))},i()}),a=(async()=>e(i))();return Promise.race([a,s]).finally(()=>{o=!0,clearTimeout(r)})}const mv=0,gv=4096,yv=8,wv=32,bv=8;class vv{constructor(e,t,n){this.encryptionKey=e,this.keyLen=e.length,this.padding=t,this.initCtr=n,this.index=0}key(){return this.encryptionKey}encrypt(e){const t=e.length;let n=t;if(this.padding>0){if(t>this.padding)throw new Error(`data length ${t} longer than padding ${this.padding}`);n=this.padding}const r=new Uint8Array(n);return this.transform(e,r),r}decrypt(e){const t=e.length;if(this.padding>0&&t!==this.padding)throw new Error(`data length ${t} different than padding ${this.padding}`);const n=new Uint8Array(t);return this.transform(e,n),n}reset(){this.index=0}transform(e,t){const n=e.length;for(let r=0;r<n;r+=this.keyLen){const o=Math.min(this.keyLen,n-r);this.transcrypt(this.index,e.subarray(r,r+o),t.subarray(r,r+o)),this.index++}Ev(t.subarray(n))}transcrypt(e,t,n){const r=new Uint8Array(4);new DataView(r.buffer).setUint32(0,e+this.initCtr,!0);const o=new Uint8Array(this.encryptionKey.length+4);o.set(this.encryptionKey),o.set(r,this.encryptionKey.length);const i=Jr.Binary.keccak256(o),s=Jr.Binary.keccak256(i),a=t.length;for(let e=0;e<a;e++)n[e]=t[e]^s[e];Ev(n.subarray(a))}}function Ev(e){0!==e.length&&crypto.getRandomValues(e)}function xv(e=32){const t=new Uint8Array(e);return Ev(t),t}function _v(e){return new vv(e,0,Math.floor(128))}function kv(e){return new vv(e,4096,0)}class Av{encryptChunk(e,t){const n=t||xv(32);return{key:n,encryptedSpan:_v(n).encrypt(e.subarray(0,8)),encryptedData:kv(n).encrypt(e.subarray(8))}}}function Iv(){return new Av}function $v(e,t){const n=_v(e).decrypt(t.subarray(0,8)),r=kv(e).decrypt(t.subarray(8)),o=new Uint8Array(8+r.length);return o.set(n),o.set(r,8),o}const Bv=4096;function Sv(e){const t=e.slice(0,Ys.LENGTH),n=function(e){if(e.length>Bv)throw new Error(`payload size ${e.length} exceeds maximum chunk payload size 4096`);const t=new Uint8Array(Bv);t.set(e);let n=Jr.Binary.partition(t,32);for(;n.length>1;){const e=[];for(let t=0;t<n.length;t+=2){const r=n[t],o=n[t+1],i=Jr.Binary.concatBytes(r,o),s=Jr.Binary.keccak256(i);e.push(s)}n=e}return n[0]}(e.slice(Ys.LENGTH)),r=Jr.Binary.keccak256(Jr.Binary.concatBytes(t,n));return new Xs(r)}const zv=new TextEncoder;function Ov(e,t){if(e instanceof Uint8Array||(e=zv.encode(e)),e.length<0||e.length>gv)throw new RangeError(`payload size ${e.length} exceeds limits [0, 4096]`);let n;n=t instanceof Ys?t:"bigint"==typeof t?Ys.fromBigInt(t):Ys.fromBigInt(BigInt(e.length));const r=Jr.Binary.concatBytes(n.toUint8Array(),e),o=Sv(r);return{data:r,span:n,payload:new Ts(e),address:o}}const Tv=new TextEncoder;function Nv(e,t){if(e instanceof Uint8Array||(e=Tv.encode(e)),e.length<0||e.length>gv)throw new RangeError(`payload size ${e.length} exceeds limits [0, 4096]`);const n=Ys.fromBigInt(BigInt(e.length)),r=Jr.Binary.concatBytes(n.toUint8Array(),e),o=Iv(),{key:i,encryptedSpan:s,encryptedData:a}=o.encryptChunk(r,t),c=Jr.Binary.concatBytes(s,a),u=Sv(c),l=new Xs(Jr.Binary.concatBytes(u.toUint8Array(),i));return{data:c,encryptionKey:i,span:n,payload:new Ts(c.slice(Ys.LENGTH)),address:u,reference:l}}function Rv(e){const t=new DataView(e.buffer,e.byteOffset,e.byteLength);return Number(t.getBigUint64(0,!0))}function Uv(e,t){return new Xs(Jr.Binary.keccak256(Jr.Binary.concatBytes(e.toUint8Array(),t.toUint8Array())))}function Pv(e,t,n,r){const o=new Ds(e.slice(0,32)),i=Ws.fromSlice(e,32),s=e.slice(97),a=Sv(s),c=Jr.Binary.concatBytes(o.toUint8Array(),a.toUint8Array()),u=i.recoverPublicKey(c).address();if(!u.equals(n))throw new Error("SOC owner mismatch");const l=Uv(o,u);if(!Jr.Binary.equals(t.toUint8Array(),l.toUint8Array()))throw new Error("SOC data does not match given address");let f,d,h;if(r){const e=$v(r,s);f=e.slice(0,8);const t=Rv(f);d=e.slice(8,8+t),h=Jr.Binary.concatBytes(o.toUint8Array(),i.toUint8Array(),f,d)}else{f=e.slice(97,105);const t=Rv(f);if(t>4096)throw new Error("SOC payload length is invalid; this chunk likely requires decryption");d=e.slice(105,105+t),h=e}const p=Rv(f);return{data:h,identifier:o.toHex(),signature:i.toHex(),span:p,payload:d,address:t.toHex(),owner:u.toHex()}}function Fv(e,t,n){const r=[],o=n?64:wv,i=Math.floor(e.length/o),s=Math.ceil(t/gv),a=Math.min(i,s);for(let t=0;t<a;t++){const i=t*o;if(i+o>e.length)break;const s=e.slice(i,i+wv);if(s.every(e=>0===e))break;if(n){const t=e.slice(i+wv,i+64);r.push({address:s,encryptionKey:t})}else r.push({address:s})}return r}async function Cv(e,t,n){const r=Jr.Binary.uint8ArrayToHex(t.address);let o,i;try{o=await e.chunk.download(r,void 0,n)}catch(n){throw console.error(`[DownloadData] chunk fetch failed addr=${r} encrypted=${void 0!==t.encryptionKey} bee.url=${e.url}:`,n),n}i=t.encryptionKey?$v(t.encryptionKey,o):o;return{span:Rv(i.slice(0,8)),payload:i.slice(8)}}async function Lv(e,t,n,r,o,i){const{span:s,payload:a}=await Cv(e,t,i);if(o(),s<=gv)return a.slice(0,s);const c=Fv(a,s,n);if(0===c.length)throw new Error("No valid references found in intermediate chunk");const u=new Array(c.length);for(let t=0;t<c.length;t+=r){const s=c.slice(t,Math.min(t+r,c.length)),a=await Promise.all(s.map(t=>Lv(e,t,n,r,o,i)));for(let e=0;e<a.length;e++)u[t+e]=a[e]}const l=u.reduce((e,t)=>e+t.length,0),f=new Uint8Array(l);let d=0;for(const e of u)f.set(e,d),d+=e.length;return f}async function Mv(e,t,n,r,o){const i=function(e){const t=my(e);if(t.length===wv)return{address:t};if(64===t.length)return{address:t.slice(0,wv),encryptionKey:t.slice(wv)};throw new Error(`Invalid reference length: ${t.length}, expected 32 or 64`)}(t),s=void 0!==i.encryptionKey;console.log(`[DownloadData] start addr=${Jr.Binary.uint8ArrayToHex(i.address)} encrypted=${s} bee.url=${e.url}`);const{span:a,payload:c}=await Cv(e,i,o);if(a<=gv)return c.slice(0,a);const u=()=>{},l=Fv(c,a,s);if(0===l.length)throw new Error("No valid references found in root chunk");const f=new Array(l.length);for(let t=0;t<l.length;t+=64){const n=l.slice(t,Math.min(t+64,l.length)),r=await Promise.all(n.map(t=>Lv(e,t,s,64,u,o)));for(let e=0;e<r.length;e++)f[t+e]=r[e]}const d=f.reduce((e,t)=>e+t.length,0),h=new Uint8Array(d);let p=0;for(const e of f)h.set(e,p),p+=e.length;return h}async function Dv(e,t,n,r){const o=new Fs(t),i=Uv(new Ds(n),o);return Pv(await e.chunk.download(i.toHex(),void 0,r),i,o)}async function Zv(e,t,n,r,o){const i=new Fs(t),s=Uv(new Ds(n),i),a="string"==typeof r?my(r):r;return Pv(await e.chunk.download(s.toHex(),void 0,o),s,i,a)}async function jv(e,t){const n=await async function e(n,r){for(const t of n.forks.values())await e(t.node,!1);const o=await n.marshal(),i=await t(o,r);return n.selfAddress=my(i.reference),i}(e,!0);return{rootReference:n.reference,tagUid:n.tagUid}}async function qv(e,t,n){const r=!0===n?.encrypt;const o=await async function e(n,o){for(const t of n.forks.values())await e(t.node,!1);const i=await n.marshal();if(r){const e=Nv(i),r=await t(e.data,o),s=new Uint8Array(64);return s.set(e.address.toUint8Array(),0),s.set(e.encryptionKey,32),n.selfAddress=s,r}{const e=Ov(i),r=await t(e.data,o);return n.selfAddress=e.address.toUint8Array(),r}}(e,!0);return{rootReference:gy(e.selfAddress),tagUid:o.tagUid}}const Gv=["invalid version hash","data too short"];async function Hv(e,t,n){const r=function(e,t){try{return Ia.unmarshalFromData(e,my(t))}catch(e){if(e instanceof Error&&Gv.some(t=>e.message.endsWith(t)))throw new Error("No manifest at this reference; a reference from uploadData needs downloadData.",{cause:e});throw e}}(await Mv(e,t,0,0,n),t);return await async function t(r){for(const o of r.forks.values()){if(!o.node.selfAddress)throw new Error("Fork node selfAddress is not set");const i=gy(o.node.selfAddress),s=await Mv(e,i,0,0,n),a=Ia.unmarshalFromData(s,o.node.selfAddress);o.node.targetAddress=a.targetAddress,o.node.forks=a.forks,o.node.obfuscationKey=a.obfuscationKey,o.node.path=o.prefix,o.node.parent=r;for(const e of o.node.forks.values())e.node.parent=o.node;await t(o.node)}}(r),r}const Vv=5,Kv=86400n/BigInt(5),Wv=86400,Jv=30n*BigInt(Wv);async function Xv(){const e=await fetch("https://api.swarmscan.io/v1/postage-stamps/stats");if(!e.ok)throw new Error(`Failed to fetch Swarmscan stats: ${e.status}`);return(await e.json()).pricePerGBPerMonth}function Yv(e,t){if(!Number.isFinite(t)||t<=0)return 0;const n=BigInt(e);if(n<=0n)return 0;const r=function(e){const t=e.toFixed(16),n=t.startsWith("-"),r=n?t.slice(1):t,[o,i=""]=r.split("."),s=i.padEnd(16,"0").slice(0,16),a=BigInt(o+s);return n?-a:a}(t)/262144n;return r<=0n?0:Number(n*Jv/r)}function Qv(e){if(void 0===e||e<=0)return"N/A";return`${Math.floor(e/Wv)}d ${Math.floor(e%Wv/3600)}h`}function eE(e,t){return e<=0n||!Number.isInteger(t)||t<=0?0n:e*Kv*BigInt(t)}async function tE(e,t){try{const n=e.replace(/\/$/,""),r=await fetch(`${n}/stamps/${t}`);if(!r.ok)return;const o=await r.json();if("object"!=typeof o||null===o)return;const{batchTTL:i,usable:s,exists:a}=o;return{batchTTL:"number"==typeof i?i<0?0:i:void 0,usable:"boolean"==typeof s?s:void 0,exists:"boolean"==typeof a?a:void 0}}catch{return}}async function nE(e,t){const n=await tE(e,t);return n?.batchTTL}const rE=1e4;function oE(e){try{return new URL(e).origin}catch{return"The RPC endpoint"}}function iE(e){return"object"==typeof e&&null!==e}class sE extends Error{}function aE(e,t,n){if(e.error)throw new Error(`${n} refused ${t}: ${e.error.message??"unknown error"}`);if(!("result"in e))throw new Error(`${n} returned a malformed envelope for ${t}.`);return e.result??void 0}function cE(e,t,n){if(void 0===e)throw new Error(`${n} returned no result for ${t}.`);return e}async function uE(e,t,n,r){const o=r.label??oE(e),i=new AbortController,s=setTimeout(()=>i.abort(),r.timeoutMs),a=e=>i.signal.aborted?new fv(`${o} did not answer ${n} within ${r.timeoutMs}ms.`):new Error(e);try{let s;try{s=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t),signal:i.signal})}catch(e){throw a(`${o} could not be reached for ${n}: ${c=e,c instanceof Error?c.message:String(c)}`)}!function(e,t,n){if(!e.ok)throw new Error(`${n} answered ${e.status} to ${t}.`)}(s,n,o);const{maxBodyBytes:u}=r;try{return void 0===u?await s.json():JSON.parse(await async function(e,t){if(!e.body)return"";const n=e.body.getReader(),r=[];let o=0;for(;;){const{done:e,value:i}=await n.read();if(e)break;if(o+=i.byteLength,o>t)throw await n.cancel().catch(()=>{}),new sE;r.push(i)}const i=new Uint8Array(o);let s=0;for(const e of r)i.set(e,s),s+=e.byteLength;return(new TextDecoder).decode(i)}(s,u))}catch(e){if(e instanceof sE)throw new Error(`${o} answered ${n} with a body longer than ${u} bytes.`);throw a(`${o} answered ${n} with a body that is not JSON.`)}}finally{clearTimeout(s)}var c}async function lE(e,t,n,r){const o=r.label??oE(e);return cE(aE(await uE(e,{jsonrpc:"2.0",id:1,method:t,params:n},t,r),t,o),t,o)}async function fE(e,t,n){if(0===t.length)return[];const r=n.label??oE(e),o=`a batch of ${t.length} calls`,i=t.map((e,t)=>({jsonrpc:"2.0",id:t,method:e.method,params:e.params})),s=()=>new Error(`${r} returned a malformed response to ${o}.`),a=await uE(e,i,o,n);if(!Array.isArray(a))throw iE(a)&&a.error&&aE(a,o,r),s();if(a.length!==t.length)throw s();const c=new Array(t.length),u=new Set;for(const e of a){if(!iE(e))throw s();const{id:n}=e;if("number"!=typeof n||n<0||n>=t.length)throw new Error(`${r} returned a response with an unknown id.`);if(u.has(n))throw new Error(`${r} returned two responses for id ${n}.`);u.add(n);const o=t[n].method;c[n]=cE(aE(e,o,r),o,r)}return c}const dE="swarm-encryption",hE="postage-signer",pE="backup-key",mE="act-sharing";async function gE(e,t){const n=await crypto.subtle.importKey("raw",my(e),{name:"HMAC",hash:"SHA-256"},!1,["sign"]),r=await crypto.subtle.sign("HMAC",n,(new TextEncoder).encode(t));return gy(new Uint8Array(r))}function yE(e,t){return gy(Dg(qm,my(e),(new TextEncoder).encode(t)))}async function wE(e,t){const n=await gE(e,t);return crypto.subtle.importKey("raw",my(n),"AES-GCM",!1,["encrypt","decrypt"])}async function bE(e){return gE(e,"derivation-key")}async function vE(e){return gE(e,dE)}async function EE(e){return gE(e,hE)}function xE(e){return yE(e,hE)}function _E(e){const t=my(yE(e,mE));return{secret:t,publicKey:new Js(t).publicKey().toCompressedHex()}}function kE(e){return function(e,t){for(let n=0;n<16;n++){const r=e(0===n?t:`${t}/${n}`);if(Wg.utils.isValidPrivateKey(r))return r}throw new Error(`No valid secp256k1 private key under "${t}" in 16 attempts.`)}(t=>my(yE(e,t)),"swarm-id chat key v1")}const AE="Swarm ID chat binding v1",IE="Site: ",$E="Chat address: ",BE="Date: ",SE=/^0x[0-9a-f]{40}$/,zE=/^(0x)?[0-9a-fA-F]{40}$/,OE=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/,TE=/^[a-z0-9-]+(\.[a-z0-9-]+)*$/,NE=new Set(["localhost","127.0.0.1","[::1]"]);function RE(e,t={}){let n;try{n=new URL(e)}catch{return!1}const r="https:"===n.protocol,o=!0===t.allowLocalHttp&&"http:"===n.protocol&&NE.has(n.hostname);return!(!r&&!o)&&(!(!o&&!TE.test(n.hostname))&&(""!==n.host&&""===n.username&&""===n.password&&n.origin===e))}function UE(e){return e.toLowerCase().replace(/^0x/,"")}function PE(e,t){if(!RE(e,t))throw new Error(`Chat binding site is not a clean https origin: ${e}`)}function FE(e,t={}){if(PE(e.site,t),!zE.test(e.chatAddress))throw new Error("Chat address is not 20 bytes of hex.");if(Number.isNaN(e.date.getTime()))throw new Error("Chat binding date is not a valid date.");return[AE,`${IE}${e.site}`,`${$E}0x${UE(e.chatAddress)}`,`${BE}${e.date.toISOString()}`].join("\n")}function CE(e,t){if(!e.startsWith(t))throw new Error(`Chat binding line does not start with "${t}".`);return e.slice(t.length)}function LE(e,t={}){const n=e.split("\n");if(4!==n.length)throw new Error(`Chat binding has ${n.length} lines, not 4.`);const[r,o,i,s]=n;if(r!==AE)throw new Error("Not a Swarm ID chat binding v1.");const a=CE(o,IE);PE(a,t);const c=CE(i,$E);if(!SE.test(c))throw new Error("Chat address is not 0x and 40 lower-case hex characters.");const u=CE(s,BE);if(!function(e){if(!OE.test(e))return!1;const t=Date.parse(e);return!Number.isNaN(t)&&new Date(t).toISOString()===e}(u))throw new Error("Chat binding date is not ISO 8601 UTC.");return{site:a,chatAddress:c,date:u}}function ME(e){return new Js(kE(e)).publicKey().address().toHex()}function DE(e,t,n,r={}){PE(t,r);const o=FE({site:t,chatAddress:ME(yE(e,t)),date:n},r);return{message:o,signature:vy(o,e)}}function ZE(e,t={}){const n=LE(e.message,t);return{signer:Ey(e.message,e.signature,"Chat binding signature"),...n}}function jE(e,t,n={}){if(!e)return;let r;try{r=ZE(e,n)}catch{return}return r.site===t.site&&UE(r.chatAddress)===UE(t.chatAddress)&&UE(r.signer)===UE(t.signer)?e:void 0}function qE(e,t){return e.map(e=>{if(e.appUrl===t||void 0===e.chatBinding)return e;const{chatBinding:n,...r}=e;return r})}const GE={allowLocalHttp:!0};function HE(e){try{return Date.parse(LE(e.message,GE).date)}catch{return Number.NEGATIVE_INFINITY}}function VE(e,t,n){try{const r=ZE(e,GE);return r.site===t&&UE(r.signer)===UE(n)}catch{return!1}}function KE(e,t,n,r){if(!e||!t)return e??t;const o=VE(e,n,r);return o!==VE(t,n,r)?o?e:t:HE(t)>HE(e)?t:e}export{ph as $,Ww as A,ib as B,rE as C,Ly as D,Fs as E,AE as F,jE as G,ko as H,ev as I,FE as J,RE as K,LE as L,Ia as M,vm as N,ZE as O,Rb as P,xy as Q,Xs as R,e as S,ea as T,Ny as U,Py as V,_y as W,Fy as X,lh as Y,Qd as Z,Ws as _,Ds as a,$p as a$,Jr as a0,Vh as a1,bh as a2,Ca as a3,vh as a4,Xh as a5,Fa as a6,za as a7,Ns as a8,Oa as a9,Uh as aA,wa as aB,_h as aC,Lh as aD,xp as aE,dp as aF,pp as aG,hp as aH,mp as aI,_p as aJ,jf as aK,Kh as aL,Fh as aM,Ls as aN,Is as aO,ks as aP,ga as aQ,_s as aR,wh as aS,Wh as aT,Ch as aU,xh as aV,Ap as aW,kp as aX,Zh as aY,ds as aZ,jh as a_,La as aa,md as ab,Gs as ac,$d as ad,gh as ae,mh as af,Jh as ag,Ts as ah,ha as ai,pa as aj,da as ak,ma as al,Qh as am,ep as an,Zs as ao,rp as ap,op as aq,cp as ar,ap as as,sp as at,ip as au,Gh as av,Ph as aw,Ys as ax,yh as ay,Ih as az,km as b,yE as b$,Bp as b0,zp as b1,Op as b2,Tp as b3,Np as b4,Rp as b5,Up as b6,Zp as b7,Mp as b8,Dp as b9,Rh as bA,uw as bB,wr as bC,yw as bD,zr as bE,gr as bF,Fn as bG,ir as bH,_r as bI,Aw as bJ,dr as bK,vn as bL,Nv as bM,Ov as bN,Em as bO,Sv as bP,bv as bQ,Iv as bR,gE as bS,Ma as bT,pE as bU,$w as bV,xw as bW,Iw as bX,ww as bY,mw as bZ,wE as b_,Lp as ba,Fp as bb,Cp as bc,qh as bd,$h as be,Bh as bf,fd as bg,gp as bh,yp as bi,vp as bj,Ep as bk,lm as bl,fm as bm,cm as bn,am as bo,um as bp,pm as bq,mm as br,Hh as bs,ym as bt,wm as bu,bm as bv,ta as bw,dm as bx,hm as by,Eh as bz,Js as c,dE as c0,hE as c1,mE as c2,yv as c3,mv as c4,gv as c5,Ir as c6,qv as c7,Hv as c8,cw as c9,rv as cA,_E as cB,xE as cC,Dv as cD,kE as cE,Ow as cF,Tw as cG,tE as cH,Xv as cI,Yv as cJ,tb as cK,nb as cL,py as cM,Sw as cN,jy as cO,Gy as cP,hw as cQ,bE as cR,EE as cS,DE as cT,Cy as cU,yy as cV,pv as cW,eE as cX,xm as cY,KE as ca,Zv as cb,vw as cc,hv as cd,Ew as ce,Gr as cf,Mv as cg,ow as ch,sw as ci,aw as cj,lw as ck,vE as cl,Vv as cm,nE as cn,Wg as co,xv as cp,My as cq,Bw as cr,ME as cs,qE as ct,Nw as cu,nv as cv,tv as cw,zw as cx,sb as cy,ob as cz,rb as d,fv as e,Jw as f,lv as g,Qw as h,_m as i,my as j,Ao as k,Qr as l,oo as m,no as n,eo as o,ro as p,io as q,uv as r,uo as s,xo as t,gy as u,jv as v,dv as w,Qv as x,lE as y,fE as z};
23
+ //# sourceMappingURL=chat-binding-gSvKTm5l.js.map