@solarpunkltd/swarm-id 0.8.0 → 0.8.1

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.
@@ -9,15 +9,15 @@ const Ei=BigInt(0),_i=BigInt(1);function xi(e,t){const n=t.negate();return e?n:t
9
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))}
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,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 vm="https://api.gateway.ethswarm.org/",Em="https://xdai.fairdatasociety.org/",_m=e=>Fn().regex(new RegExp(`^[0-9a-fA-F]{${e}}$`),{message:`Must be a ${e}-character hex string`}),xm=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)"}),km=_m(64),Am=_m(40),Im=_m(64),$m=_m(66),Bm=_m(64),zm=_m(64),Sm=_m(130),Om=_m(64),Tm=_m(226),Nm=Hr(e=>"bigint"==typeof e?e.toString():e,Er([ir(),Fn()])),Rm=Hr(e=>"bigint"==typeof e?e.toString():e,Er([ir(),Fn()])),Um=Am.transform(e=>new Ns(e)),Pm=km.transform(e=>new zs(e)),Fm=Im.transform(e=>new Hs(e)),Cm=Fn().regex(/^\d+$/,{message:"Must be a decimal integer string"}).transform(e=>BigInt(e)),Lm=wr({deviceId:Fn(),createdAt:ir(),lastSignedInAt:ir(),name:Fn().optional(),nameUpdatedAt:ir().optional(),removedAt:ir().optional()}),Mm=wr({message:Fn().max(512),signature:Fn().regex(/^0x[0-9a-fA-F]{130}$/)}),Dm=wr({appUrl:Fn(),appName:Fn(),lastConnectedAt:ir(),appIcon:Fn().optional(),appDescription:Fn().optional(),connectedUntil:ir().optional(),appSecret:Fn().optional(),postageStampBatchID:Pm.optional(),postageStampBatchIDAt:ir().optional(),revokedAt:ir().optional(),disconnectedAt:ir().optional(),chatBinding:Mm.optional()}),Zm=wr({batchID:Pm,signerKey:Fm,name:Fn().optional(),nameUpdatedAt:ir().optional(),utilization:ir(),usable:ur(),depth:ir(),amount:Cm,bucketDepth:ir(),blockNumber:ir(),immutableFlag:ur(),exists:ur(),batchTTL:ir().optional(),createdAt:ir(),updatedAt:ir().optional(),deletedAt:ir().optional()}),jm=xr("type",[wr({type:Sr("passkey"),credentialId:Fn()}),wr({type:Sr("eth-wallet"),encryptionSalt:Fn()}),wr({type:Sr("password"),kdfSalt:Fn(),kdfIterations:ir()})]),qm=wr({access:jm,encryptedSeed:Fn().regex(/^([0-9a-f]{2})+$/)}),Gm=wr({id:Um,name:Fn(),createdAt:ir(),derivationKey:Fn().length(64),publicKey:$m,defaultPostageStampBatchID:Pm.optional(),devices:gr(Lm).default([]),connectedApps:gr(Dm).default([]),postageStamps:gr(Zm).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()}),Hm=Gm.extend({...qm.shape,signedOutAt:function(e){return function(e,t){return new e({type:"undefined",...x(t)})}(lr,e)}().optional()}),Vm=Er([Hm,wr({id:Um,name:Fn(),createdAt:ir(),...qm.shape,encryptedState:Fn().optional(),storageWarning:ur().optional(),soonestDriveExpiry:ir().optional(),signedOutAt:ir()})]),Km=wr({accountName:Fn(),defaultPostageStampBatchID:Fn().length(64).optional(),publicKey:$m,settings:wr({appSessionDuration:ir().optional()}).optional(),accountNameAt:ir().optional(),defaultStampAt:ir().optional(),settingsAt:ir().optional(),createdAt:ir(),lastModified:ir(),devices:gr(Lm).default([]),partitionCount:ir().int().min(1).default(1)}),Wm=wr({version:Sr(1),timestamp:ir(),accountId:Fn().length(40),metadata:Km,connectedApps:gr(Dm),postageStamps:gr(Zm)});function Jm(e){return void 0!==e.signedOutAt}const Xm=wr({timestampMs:ir().int().nonnegative(),tiebreaker:Fn().regex(/^[0-9a-f]{16}$/)}),Ym=wr({holderDeviceId:Fn(),generation:Xm,acquiredAt:ir().int().nonnegative(),leasedUntil:ir().int().nonnegative()}),Qm=wr({deviceId:Fn(),generation:Xm,leasedUntil:ir().int().nonnegative().optional()}),eg=wr({beeNodeUrl:Fn().refine(wm,"Must be an http(s) URL"),gnosisRpcUrl:Fn().refine(wm,"Must be an http(s) URL")}),tg=wr({index:ir().int().min(0).max(65535),value:ir().int().min(0)}),ng=wr({type:Sr("utilization-updated"),batchId:Fn().length(64),partition:ir().int().min(0),partitionCount:ir().int().min(1),buckets:gr(tg)}),rg="swarm-id-accounts",og="swarm-id-network-settings",ig="swarm-storage-challenge",sg="swarm-id-site-allow-list";function ag(e,t){return`swarm-id-lease-v2:${e.toLowerCase()}:${t.toLowerCase()}`}function cg(e,t){return`swarm-id-app-stamp-usage:${e}:${t.toLowerCase()}`}function ug(e,t){return`swarm-id-soc-restamp-slots:${e}:${t.toLowerCase()}`}function lg(e){return`swarm-id-partition-session:${e}`}const fg=wr({pin:ur().optional(),encrypt:ur().optional(),encryptManifest:ur().optional(),tag:ir().optional(),deferred:ur().optional()}),dg=fg.optional(),hg=Br(["app","identity"]),pg=fg.extend({beeCompatible:ur().optional(),publisher:hg.optional()}).optional(),mg=wr({timeout:ir().optional(),headers:Ir(Fn(),Fn()).optional(),endlesslyRetry:ur().optional()}).optional(),gg=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(),yg=fg.extend({indexDocument:Fn().optional(),errorDocument:Fn().optional()}).optional(),wg=wr({path:Fn().min(1),data:Gr(Uint8Array),contentType:Fn().optional()}),bg=wr({path:Fn(),reference:xm,contentType:Fn().optional()}),vg=wr({reference:xm,tagUid:ir().optional()});vg.extend({encryptionKey:Fn().optional(),owner:Am}),vg.extend({encryptionKey:Fn().optional(),owner:Am}),wr({name:Fn(),data:Gr(Uint8Array)});const Eg=wr({batchID:km,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 _g=Br(["user-stamp","subsidised","unavailable"]),xg=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"]),kg=wr({source:Br(["generated"]),url:Fn()}),Ag=wr({id:Fn(),name:Fn(),address:Am,publicKey:$m.optional(),sharingPublicKey:$m.optional(),postageSignerAddress:Am.optional(),avatar:kg});wr({canUpload:ur(),storagePartitioned:ur().optional(),uploadMode:_g.optional(),uploadUnavailableReason:xg.optional(),partition:ir().int().min(0).optional(),identity:Ag.optional(),appKey:wr({address:Am,publicKey:$m}).optional(),chatBinding:Mm.optional()});const Ig=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"})}),$g=wr({connectText:Fn().optional(),disconnectText:Fn().optional(),loadingText:Fn().optional(),backgroundColor:Fn().optional(),color:Fn().optional(),borderRadius:Fn().optional(),fontFamily:Fn().optional(),fontSize:Fn().optional(),fontWeight:Er([Fn(),ir()]).optional()}).optional(),Bg=wr({type:Sr("parentIdentify"),requestId:Fn(),beeApiUrl:Fn().url().optional(),popupMode:Br(["popup","window"]).optional(),metadata:Ig,buttonConfig:$g,subsidisedGatewayUrl:Fn().url().optional()}),zg=wr({type:Sr("checkAuth"),requestId:Fn()}),Sg=wr({type:Sr("disconnect"),requestId:Fn()}),Og=wr({type:Sr("uploadData"),requestId:Fn(),data:Gr(Uint8Array),options:dg,requestOptions:mg,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()}),Tg=wr({type:Sr("downloadData"),requestId:Fn(),reference:xm,options:gg,requestOptions:mg}),Ng=wr({type:Sr("deriveAppSecret"),requestId:Fn(),label:Fn()}),Rg=wr({type:Sr("getChatKey"),requestId:Fn()}),Ug=Er([Sr("app"),br({privateKey:Im})]),Pg=xr("kind",[br({kind:Sr("content"),data:Gr(Uint8Array)}),br({kind:Sr("soc"),identifier:zm,data:Gr(Uint8Array),signer:Ug})]),Fg=br({type:Sr("stampChunk"),requestId:Fn(),chunk:Pg}),Cg=wr({type:Sr("uploadFile"),requestId:Fn(),data:Gr(Uint8Array),name:Fn().optional(),options:dg,requestOptions:mg,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()}),Lg=wr({type:Sr("downloadFile"),requestId:Fn(),reference:xm,path:Fn().optional(),options:gg,requestOptions:mg}),Mg=wr({type:Sr("uploadFiles"),requestId:Fn(),files:gr(wg),options:yg,requestOptions:mg,enableProgress:ur().optional(),useWorkers:ur().optional(),workerCount:ir().int().min(1).max(32).optional()}),Dg=wr({type:Sr("listFiles"),requestId:Fn(),reference:xm,requestOptions:mg}),Zg=wr({type:Sr("uploadChunk"),requestId:Fn(),data:Gr(Uint8Array),options:dg,requestOptions:mg}),jg=wr({type:Sr("downloadChunk"),requestId:Fn(),reference:xm,options:gg,requestOptions:mg}),qg=wr({type:Sr("isConnected"),requestId:Fn()}),Gg=wr({type:Sr("getNodeInfo"),requestId:Fn()}),Hg=wr({type:Sr("gsocMine"),requestId:Fn(),targetOverlay:Fn(),identifier:Fn(),proximity:ir().optional()}),Vg=wr({type:Sr("gsocSend"),requestId:Fn(),signer:Fn(),identifier:Fn(),data:Gr(Uint8Array),options:dg,requestOptions:mg}),Kg=wr({type:Sr("socUpload"),requestId:Fn(),identifier:zm,data:Gr(Uint8Array),signer:Im.optional(),options:dg,requestOptions:mg}),Wg=wr({type:Sr("socRawUpload"),requestId:Fn(),identifier:zm,data:Gr(Uint8Array),signer:Im.optional(),options:dg,requestOptions:mg}),Jg=wr({type:Sr("socDownload"),requestId:Fn(),owner:Am.optional(),identifier:zm,encryptionKey:Bm,requestOptions:mg}),Xg=wr({type:Sr("socRawDownload"),requestId:Fn(),owner:Am.optional(),identifier:zm,encryptionKey:Bm.optional(),requestOptions:mg}),Yg=wr({type:Sr("socGetOwner"),requestId:Fn()}),Qg=wr({type:Sr("epochFeedDownloadReference"),requestId:Fn(),topic:zm,owner:Am.optional(),at:Nm,after:Nm.optional(),encryptionKey:Bm.optional(),requestOptions:mg}),ey=wr({lastEpoch:wr({start:Fn(),level:ir()}).optional(),lastTimestamp:Fn().optional()}).optional(),ty=xr("type",[Bg,zg,Sg,Og,Tg,Ng,Rg,Fg,Cg,Lg,Mg,Dg,Zg,jg,qg,Gg,Hg,Vg,Kg,Wg,Jg,Xg,Yg,Qg,wr({type:Sr("epochFeedUploadReference"),requestId:Fn(),topic:zm,signer:Im.optional(),at:Nm,reference:xm,encryptionKey:Bm.optional(),hints:ey,requestOptions:mg}),wr({type:Sr("feedGetOwner"),requestId:Fn()}),wr({type:Sr("seqFeedGetOwner"),requestId:Fn()}),wr({type:Sr("seqFeedDownloadPayload"),requestId:Fn(),topic:zm,owner:Am.optional(),index:Rm.optional(),at:Nm.optional(),hasTimestamp:ur().optional(),lookupTimeoutMs:ir().optional(),encryptionKey:Bm,requestOptions:mg}),wr({type:Sr("seqFeedDownloadRawPayload"),requestId:Fn(),topic:zm,owner:Am.optional(),index:Rm.optional(),at:Nm.optional(),hasTimestamp:ur().optional(),lookupTimeoutMs:ir().optional(),encryptionKey:Bm.optional(),requestOptions:mg}),wr({type:Sr("seqFeedDownloadReference"),requestId:Fn(),topic:zm,owner:Am.optional(),index:Rm.optional(),at:Nm.optional(),hasTimestamp:ur().optional(),lookupTimeoutMs:ir().optional(),encryptionKey:Bm,requestOptions:mg}),wr({type:Sr("seqFeedUploadPayload"),requestId:Fn(),topic:zm,signer:Im.optional(),data:Gr(Uint8Array),index:Rm.optional(),at:Nm.optional(),hasTimestamp:ur().optional(),lookupTimeoutMs:ir().optional(),options:dg,requestOptions:mg}),wr({type:Sr("seqFeedUploadRawPayload"),requestId:Fn(),topic:zm,signer:Im.optional(),data:Gr(Uint8Array),index:Rm.optional(),at:Nm.optional(),hasTimestamp:ur().optional(),lookupTimeoutMs:ir().optional(),encryptionKey:Bm.optional(),options:dg,requestOptions:mg}),wr({type:Sr("seqFeedUploadReference"),requestId:Fn(),topic:zm,signer:Im.optional(),reference:xm,index:Rm.optional(),at:Nm.optional(),hasTimestamp:ur().optional(),lookupTimeoutMs:ir().optional(),options:dg,requestOptions:mg}),wr({type:Sr("createFeedManifest"),requestId:Fn(),topic:zm,owner:Am.optional(),feedType:Br(["Sequence","Epoch"]).optional(),uploadOptions:dg,requestOptions:mg}),wr({type:Sr("actUploadData"),requestId:Fn(),data:Gr(Uint8Array),grantees:gr(Fn()),options:pg,requestOptions:mg,enableProgress:ur().optional()}),wr({type:Sr("actDownloadData"),requestId:Fn(),encryptedReference:xm,historyReference:xm,publisherPubKey:Fn(),timestamp:ir().optional(),requestOptions:mg}),wr({type:Sr("actAddGrantees"),requestId:Fn(),historyReference:xm,grantees:gr(Fn()),requestOptions:mg}),wr({type:Sr("actRevokeGrantees"),requestId:Fn(),historyReference:xm,encryptedReference:xm,revokeGrantees:gr(Fn()),requestOptions:mg}),wr({type:Sr("actGetGrantees"),requestId:Fn(),historyReference:xm,requestOptions:mg}),wr({type:Sr("getPostageBatch"),requestId:Fn()}),wr({type:Sr("connect"),requestId:Fn(),popupMode:Br(["popup","window"]).optional()})]),ny=wr({type:Sr("proxyReady"),authenticated:ur(),parentOrigin:Fn(),storageShared:ur().optional()}),ry=wr({type:Sr("initError"),error:Fn()}),oy=wr({type:Sr("authStatusResponse"),requestId:Fn(),authenticated:ur(),origin:Fn().optional(),beeApiUrl:Fn().url().optional()}),iy=wr({type:Sr("disconnectResponse"),requestId:Fn(),success:ur()}),sy=wr({type:Sr("authSuccess"),origin:Fn()}),ay=wr({type:Sr("uploadDataResponse"),requestId:Fn(),reference:xm,tagUid:ir().optional()}),cy=wr({type:Sr("downloadDataResponse"),requestId:Fn(),data:Gr(Uint8Array)}),uy=wr({type:Sr("deriveAppSecretResponse"),requestId:Fn(),secret:Gr(Uint8Array)}),ly=wr({type:Sr("getChatKeyResponse"),requestId:Fn(),chatKey:Gr(Uint8Array)}),fy=wr({type:Sr("stampChunkResponse"),requestId:Fn(),address:Om,stamp:Tm,owner:Am.optional(),signature:Sm.optional()}),dy=wr({type:Sr("uploadFileResponse"),requestId:Fn(),reference:xm,tagUid:ir().optional()}),hy=wr({type:Sr("downloadFileResponse"),requestId:Fn(),name:Fn(),data:Gr(Uint8Array)}),py=wr({type:Sr("uploadFilesResponse"),requestId:Fn(),reference:xm,tagUid:ir().optional()}),my=wr({type:Sr("listFilesResponse"),requestId:Fn(),entries:gr(bg)}),gy=wr({type:Sr("uploadChunkResponse"),requestId:Fn(),reference:xm}),yy=wr({type:Sr("downloadChunkResponse"),requestId:Fn(),data:Gr(Uint8Array)}),wy=wr({type:Sr("uploadProgress"),requestId:Fn(),total:ir(),processed:ir()}),by=Br(["not-authenticated","upload-unavailable","partition-contended","lease-lost","bee-rejected","network","timeout","invalid-request","invalid-state","init-failed","popup-blocked","internal"]),vy=xr("type",[ny,ry,oy,iy,sy,ay,cy,uy,ly,fy,dy,hy,py,my,gy,yy,wy,wr({error:Fn(),code:by.catch("internal"),reason:xg.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:_g.optional(),uploadUnavailableReason:xg.optional().catch(void 0),identity:Ag.optional(),appKey:wr({address:Am,publicKey:$m}).optional(),partition:ir().int().min(0).optional(),chatBinding:Mm.optional()}),wr({type:Sr("connectResponse"),requestId:Fn(),success:ur()}),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:xm,tagUid:ir().optional()}),wr({type:Sr("socUploadResponse"),requestId:Fn(),reference:xm,tagUid:ir().optional(),encryptionKey:Fn().optional(),owner:Am}),wr({type:Sr("socRawUploadResponse"),requestId:Fn(),reference:xm,tagUid:ir().optional(),encryptionKey:Fn().optional(),owner:Am}),wr({type:Sr("socDownloadResponse"),requestId:Fn(),data:Gr(Uint8Array),identifier:zm,signature:Sm,span:ir(),payload:Gr(Uint8Array),address:xm,owner:Am}),wr({type:Sr("socRawDownloadResponse"),requestId:Fn(),data:Gr(Uint8Array),identifier:zm,signature:Sm,span:ir(),payload:Gr(Uint8Array),address:xm,owner:Am}),wr({type:Sr("socGetOwnerResponse"),requestId:Fn(),owner:Am}),wr({type:Sr("epochFeedDownloadReferenceResponse"),requestId:Fn(),reference:xm.optional()}),wr({type:Sr("epochFeedUploadReferenceResponse"),requestId:Fn(),socAddress:xm,encryptionKey:Bm.optional(),epoch:wr({start:Fn(),level:ir()}),timestamp:Fn()}),wr({type:Sr("feedGetOwnerResponse"),requestId:Fn(),owner:Am}),wr({type:Sr("seqFeedGetOwnerResponse"),requestId:Fn(),owner:Am}),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:xm,feedIndex:Fn(),feedIndexNext:Fn()}),wr({type:Sr("seqFeedUploadPayloadResponse"),requestId:Fn(),reference:xm,feedIndex:Fn(),owner:Am,encryptionKey:Fn().optional(),tagUid:ir().optional()}),wr({type:Sr("seqFeedUploadRawPayloadResponse"),requestId:Fn(),reference:xm,feedIndex:Fn(),owner:Am,encryptionKey:Fn().optional(),tagUid:ir().optional()}),wr({type:Sr("seqFeedUploadReferenceResponse"),requestId:Fn(),reference:xm,feedIndex:Fn(),owner:Am,encryptionKey:Fn().optional(),tagUid:ir().optional()}),wr({type:Sr("createFeedManifestResponse"),requestId:Fn(),reference:xm}),wr({type:Sr("actUploadDataResponse"),requestId:Fn(),encryptedReference:xm,historyReference:xm,granteeListReference:xm,publisherPubKey:Fn(),actReference:xm,tagUid:ir().optional()}),wr({type:Sr("actDownloadDataResponse"),requestId:Fn(),data:Gr(Uint8Array)}),wr({type:Sr("actAddGranteesResponse"),requestId:Fn(),historyReference:xm,granteeListReference:xm,actReference:xm}),wr({type:Sr("actRevokeGranteesResponse"),requestId:Fn(),encryptedReference:xm,historyReference:xm,granteeListReference:xm,actReference:xm}),wr({type:Sr("actGetGranteesResponse"),requestId:Fn(),grantees:gr(Fn())}),wr({type:Sr("getPostageBatchResponse"),requestId:Fn(),postageBatch:Eg.optional()})]),Ey=wr({secret:Fn(),networkSettings:eg.optional(),account:Gm,chatBinding:Mm.optional()}),_y=wr({version:Sr(1),parentOrigin:Fn(),connectedUntil:ir(),data:Fn()}),xy=xr("type",[wr({type:Sr("setSecret"),appOrigin:Fn(),challenge:Fn(),data:Ey})]),ky="#FCFCFC",Ay="#131416",Iy=[["#FFE0CC","#DD7200","#401F00"],["#99CCFF","#0082FB","#003366"],["#99E6B3","#00C853","#004D1F"],["#E1BEE7","#9C27B0","#4A148C"]],$y=[];for(const e of Iy)$y.push([e[1],ky]),$y.push([e[1],Ay]),$y.push([ky,e[1]]),$y.push([Ay,e[1]]);for(const e of Iy)$y.push([e[0],e[1]]),$y.push([e[2],e[1]]),$y.push([e[1],e[0]]),$y.push([e[1],e[2]]),$y.push([e[0],e[2]]),$y.push([e[2],e[0]]);for(let e=0;e<Iy.length;e++){const t=Iy[(e+1)%Iy.length];$y.push([Iy[e][0],t[2]]),$y.push([t[2],Iy[e][0]])}const By=[[0,1],[1,0],[0,-1],[-1,0]];function zy(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]=$y[Math.abs(n)%$y.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 By){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 Sy(e,t=40){const n=zy(e,t);return{source:"generated",url:`data:image/svg+xml;charset=utf-8,${encodeURIComponent(n)}`}}function Oy(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 Ty(e){return Array.from(e).map(e=>e.toString(16).padStart(2,"0")).join("")}function Ny(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 Ry extends Error{constructor(e){super(e),this.name="TimeoutError"}}function Uy(e,t,n){let r;const o=new Promise((e,o)=>{r=setTimeout(()=>o(new Ry(n)),t)});return Promise.race([e,o]).finally(()=>clearTimeout(r))}function Py(e){return new Promise(t=>setTimeout(t,e))}function Fy(e,t,n){let r,o=!1,i=()=>{};const s=new Promise((e,s)=>{i=()=>{o||(clearTimeout(r),r=setTimeout(()=>s(new Ry(n)),t))},i()}),a=(async()=>e(i))();return Promise.race([a,s]).finally(()=>{o=!0,clearTimeout(r)})}const Cy=0,Ly=4096,My=8,Dy=32,Zy=8;class jy{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++}qy(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];qy(n.subarray(a))}}function qy(e){0!==e.length&&crypto.getRandomValues(e)}function Gy(e=32){const t=new Uint8Array(e);return qy(t),t}function Hy(e){return new jy(e,0,Math.floor(128))}function Vy(e){return new jy(e,4096,0)}class Ky{encryptChunk(e,t){const n=t||Gy(32);return{key:n,encryptedSpan:Hy(n).encrypt(e.subarray(0,8)),encryptedData:Vy(n).encrypt(e.subarray(8))}}}function Wy(){return new Ky}function Jy(e,t){const n=Hy(e).decrypt(t.subarray(0,8)),r=Vy(e).decrypt(t.subarray(8)),o=new Uint8Array(8+r.length);return o.set(n),o.set(r,8),o}const Xy=4096;function Yy(e){const t=e.slice(0,Ks.LENGTH),n=function(e){if(e.length>Xy)throw new Error(`payload size ${e.length} exceeds maximum chunk payload size 4096`);const t=new Uint8Array(Xy);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 Qy=new TextEncoder;function ew(e,t){if(e instanceof Uint8Array||(e=Qy.encode(e)),e.length<0||e.length>Ly)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=Yy(r);return{data:r,span:n,payload:new Bs(e),address:o}}const tw=new TextEncoder;function nw(e,t){if(e instanceof Uint8Array||(e=tw.encode(e)),e.length<0||e.length>Ly)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=Wy(),{key:i,encryptedSpan:s,encryptedData:a}=o.encryptChunk(r,t),c=Jr.Binary.concatBytes(s,a),u=Yy(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 rw(e){const t=new DataView(e.buffer,e.byteOffset,e.byteLength);return Number(t.getBigUint64(0,!0))}function ow(e,t){return new Vs(Jr.Binary.keccak256(Jr.Binary.concatBytes(e.toUint8Array(),t.toUint8Array())))}function iw(e,t,n,r){const o=new Fs(e.slice(0,32)),i=Gs.fromSlice(e,32),s=e.slice(97),a=Yy(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=ow(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=Jy(r,s);f=e.slice(0,8);const t=rw(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=rw(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=rw(f);return{data:h,identifier:o.toHex(),signature:i.toHex(),span:p,payload:d,address:t.toHex(),owner:u.toHex()}}function sw(e,t,n){const r=[],o=n?64:Dy,i=Math.floor(e.length/o),s=Math.ceil(t/Ly),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+Dy);if(s.every(e=>0===e))break;if(n){const t=e.slice(i+Dy,i+64);r.push({address:s,encryptionKey:t})}else r.push({address:s})}return r}async function aw(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?Jy(t.encryptionKey,o):o;return{span:rw(i.slice(0,8)),payload:i.slice(8)}}async function cw(e,t,n,r,o,i){const{span:s,payload:a}=await aw(e,t,i);if(o(),s<=Ly)return a.slice(0,s);const c=sw(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=>cw(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 uw(e,t,n,r,o){const i=function(e){const t=Oy(e);if(t.length===Dy)return{address:t};if(64===t.length)return{address:t.slice(0,Dy),encryptionKey:t.slice(Dy)};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 aw(e,i,o);if(a<=Ly)return c.slice(0,a);const u=()=>{},l=sw(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=>cw(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 lw(e,t,n,r){const o=new Ns(t),i=ow(new Fs(n),o);return iw(await e.chunk.download(i.toHex(),void 0,r),i,o)}async function fw(e,t,n,r,o){const i=new Ns(t),s=ow(new Fs(n),i),a="string"==typeof r?Oy(r):r;return iw(await e.chunk.download(s.toHex(),void 0,o),s,i,a)}async function dw(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=Oy(i.reference),i}(e,!0);return{rootReference:n.reference,tagUid:n.tagUid}}async function hw(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=nw(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=ew(i),r=await t(e.data,o);return n.selfAddress=e.address.toUint8Array(),r}}(e,!0);return{rootReference:Ty(e.selfAddress),tagUid:o.tagUid}}const pw=["invalid version hash","data too short"];async function mw(e,t,n){const r=function(e,t){try{return _a.unmarshalFromData(e,Oy(t))}catch(e){if(e instanceof Error&&pw.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 uw(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=Ty(o.node.selfAddress),s=await uw(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 gw=5,yw=86400n/BigInt(5),ww=86400,bw=30n*BigInt(ww);async function vw(){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 Ew(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*bw/r)}function _w(e){if(void 0===e||e<=0)return"N/A";return`${Math.floor(e/ww)}d ${Math.floor(e%ww/3600)}h`}function xw(e,t){return e<=0n||!Number.isInteger(t)||t<=0?0n:e*yw*BigInt(t)}async function kw(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 Aw(e,t){const n=await kw(e,t);return n?.batchTTL}const Iw=1e4;function $w(e){try{return new URL(e).origin}catch{return"The RPC endpoint"}}function Bw(e){return"object"==typeof e&&null!==e}function zw(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 Sw(e,t,n){if(void 0===e)throw new Error(`${n} returned no result for ${t}.`);return e}async function Ow(e,t,n,r){const o=r.label??$w(e),i=new AbortController,s=setTimeout(()=>i.abort(),r.timeoutMs),a=e=>i.signal.aborted?new Ry(`${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 Tw(e,t,n,r){const o=r.label??$w(e);return Sw(zw(await Ow(e,{jsonrpc:"2.0",id:1,method:t,params:n},t,r),t,o),t,o)}async function Nw(e,t,n){if(0===t.length)return[];const r=n.label??$w(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 Ow(e,i,o,n);if(!Array.isArray(a))throw Bw(a)&&a.error&&zw(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(!Bw(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]=Sw(zw(e,o,r),o,r)}return c}function Rw(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`Wrong positive integer: ${e}`)}function Uw(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 Pw(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 Fw(e,t){Uw(e);const n=t.outputLen;if(e.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}const Cw="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0,Lw=e=>e instanceof Uint8Array,Mw=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),Dw=(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 Zw(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)),!Lw(e))throw new Error("expected Uint8Array, got "+typeof e);return e}class jw{clone(){return this._cloneInto()}}function qw(e){const t=t=>e().update(Zw(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function Gw(e=32){if(Cw&&"function"==typeof Cw.getRandomValues)return Cw.getRandomValues(new Uint8Array(e));throw new Error("crypto.getRandomValues must be defined")}class Hw extends jw{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=Mw(this.buffer)}update(e){Pw(this);const{view:t,buffer:n,blockLen:r}=this,o=(e=Zw(e)).length;for(let i=0;i<o;){const s=Math.min(r-this.pos,o-i);if(s===r){const t=Mw(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){Pw(this),Fw(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=Mw(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 Vw=(e,t,n)=>e&t^~e&n,Kw=(e,t,n)=>e&t^e&n^t&n,Ww=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]),Jw=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Xw=new Uint32Array(64);class Yw extends Hw{constructor(){super(64,32,8,!1),this.A=0|Jw[0],this.B=0|Jw[1],this.C=0|Jw[2],this.D=0|Jw[3],this.E=0|Jw[4],this.F=0|Jw[5],this.G=0|Jw[6],this.H=0|Jw[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)Xw[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=Xw[e-15],n=Xw[e-2],r=Dw(t,7)^Dw(t,18)^t>>>3,o=Dw(n,17)^Dw(n,19)^n>>>10;Xw[e]=o+Xw[e-7]+r+Xw[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+(Dw(s,6)^Dw(s,11)^Dw(s,25))+Vw(s,a,c)+Ww[e]+Xw[e]|0,l=(Dw(n,2)^Dw(n,13)^Dw(n,22))+Kw(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(){Xw.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const Qw=qw(()=>new Yw),eb=BigInt(0),tb=BigInt(1),nb=BigInt(2),rb=e=>e instanceof Uint8Array,ob=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));
14
- /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function ib(e){if(!rb(e))throw new Error("Uint8Array expected");let t="";for(let n=0;n<e.length;n++)t+=ob[e[n]];return t}function sb(e){const t=e.toString(16);return 1&t.length?`0${t}`:t}function ab(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);return BigInt(""===e?"0":`0x${e}`)}function cb(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 ub(e){return ab(ib(e))}function lb(e){if(!rb(e))throw new Error("Uint8Array expected");return ab(ib(Uint8Array.from(e).reverse()))}function fb(e,t){return cb(e.toString(16).padStart(2*t,"0"))}function db(e,t){return fb(e,t).reverse()}function hb(e,t,n){let r;if("string"==typeof t)try{r=cb(t)}catch(n){throw new Error(`${e} must be valid hex string, got "${t}". Cause: ${n}`)}else{if(!rb(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 pb(...e){const t=new Uint8Array(e.reduce((e,t)=>e+t.length,0));let n=0;return e.forEach(e=>{if(!rb(e))throw new Error("Uint8Array expected");t.set(e,n),n+=e.length}),t}const mb=e=>(nb<<BigInt(e-1))-tb,gb=e=>new Uint8Array(e),yb=e=>Uint8Array.from(e);function wb(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=gb(e),o=gb(e),i=0;const s=()=>{r.fill(1),o.fill(0),i=0},a=(...e)=>n(o,r,...e),c=(e=gb())=>{o=a(yb([0]),e),r=a(),0!==e.length&&(o=a(yb([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 pb(...n)};return(e,t)=>{let n;for(s(),c(e);!(n=t(u()));)c();return s(),n}}const bb={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 vb(e,t,n={}){const r=(t,n,r)=>{const o=bb[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 Eb=Object.freeze({__proto__:null,bitGet:function(e,t){return e>>BigInt(t)&tb},bitLen:function(e){let t;for(t=0;e>eb;e>>=tb,t+=1);return t},bitMask:mb,bitSet:(e,t,n)=>e|(n?tb:eb)<<BigInt(t),bytesToHex:ib,bytesToNumberBE:ub,bytesToNumberLE:lb,concatBytes:pb,createHmacDrbg:wb,ensureBytes:hb,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:cb,hexToNumber:ab,numberToBytesBE:fb,numberToBytesLE:db,numberToHexUnpadded:sb,numberToVarBytesBE:function(e){return cb(sb(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:vb});
15
- /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _b=BigInt(0),xb=BigInt(1),kb=BigInt(2),Ab=BigInt(3),Ib=BigInt(4),$b=BigInt(5),Bb=BigInt(8);function zb(e,t){const n=e%t;return n>=_b?n:t+n}function Sb(e,t,n){if(n<=_b||t<_b)throw new Error("Expected power/modulo > 0");if(n===xb)return _b;let r=xb;for(;t>_b;)t&xb&&(r=r*e%n),e=e*e%n,t>>=xb;return r}function Ob(e,t,n){let r=e;for(;t-- >_b;)r*=r,r%=n;return r}function Tb(e,t){if(e===_b||t<=_b)throw new Error(`invert: expected positive integers, got n=${e} mod=${t}`);let n=zb(e,t),r=t,o=_b,i=xb;for(;n!==_b;){const e=r%n,t=o-i*(r/n);r=n,n=e,o=i,i=t}if(r!==xb)throw new Error("invert: does not exist");return zb(o,t)}function Nb(e){if(e%Ib===Ab){const t=(e+xb)/Ib;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%Bb===$b){const t=(e-$b)/Bb;return function(e,n){const r=e.mul(n,kb),o=e.pow(r,t),i=e.mul(n,o),s=e.mul(e.mul(i,kb),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-xb)/kb;let n,r,o;for(n=e-xb,r=0;n%kb===_b;n/=kb,r++);for(o=kb;o<e&&Sb(o,t,e)!==e-xb;o++);if(1===r){const t=(e+xb)/Ib;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+xb)/kb;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,xb<<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 Rb=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Ub(e,t){const n=void 0!==t?t:e.toString(2).length;return{nBitLength:n,nByteLength:Math.ceil(n/8)}}function Pb(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 Fb(e){const t=Pb(e);return t+Math.ceil(t/2)}
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=wr({appUrl:Fn(),appName:Fn(),lastConnectedAt:ir(),appIcon:Fn().optional(),appDescription:Fn().optional(),connectedUntil:ir().optional(),appSecret:Fn().optional(),postageStampBatchID:Fm.optional(),postageStampBatchIDAt:ir().optional(),revokedAt:ir().optional(),disconnectedAt:ir().optional(),chatBinding:Dm.optional()}),jm=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()}),qm=xr("type",[wr({type:Sr("passkey"),credentialId:Fn()}),wr({type:Sr("eth-wallet"),encryptionSalt:Fn()}),wr({type:Sr("password"),kdfSalt:Fn(),kdfIterations:ir()})]),Gm=wr({access:qm,encryptedSeed:Fn().regex(/^([0-9a-f]{2})+$/)}),Hm=wr({id:Pm,name:Fn(),createdAt:ir(),derivationKey:Fn().length(64),publicKey:Bm,defaultPostageStampBatchID:Fm.optional(),devices:gr(Mm).default([]),connectedApps:gr(Zm).default([]),postageStamps:gr(jm).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()}),Vm=Hm.extend({...Gm.shape,signedOutAt:function(e){return function(e,t){return new e({type:"undefined",...x(t)})}(lr,e)}().optional()}),Km=Er([Vm,wr({id:Pm,name:Fn(),createdAt:ir(),...Gm.shape,encryptedState:Fn().optional(),storageWarning:ur().optional(),soonestDriveExpiry:ir().optional(),signedOutAt:ir()})]),Wm=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)}),Jm=wr({version:Sr(1),timestamp:ir(),accountId:Fn().length(40),metadata:Wm,connectedApps:gr(Zm),postageStamps:gr(jm)});function Xm(e){return void 0!==e.signedOutAt}const Ym=wr({timestampMs:ir().int().nonnegative(),tiebreaker:Fn().regex(/^[0-9a-f]{16}$/)}),Qm=wr({holderDeviceId:Fn(),generation:Ym,acquiredAt:ir().int().nonnegative(),leasedUntil:ir().int().nonnegative()}),eg=wr({deviceId:Fn(),generation:Ym,leasedUntil:ir().int().nonnegative().optional()}),tg=wr({beeNodeUrl:Fn().refine(wm,"Must be an http(s) URL"),gnosisRpcUrl:Fn().refine(wm,"Must be an http(s) URL")}),ng=Fn().refine(bm,"Must be an http(s) URL, optionally with a path, and no credentials, query or fragment"),rg=wr({index:ir().int().min(0).max(65535),value:ir().int().min(0)}),og=wr({type:Sr("utilization-updated"),batchId:Fn().length(64),partition:ir().int().min(0),partitionCount:ir().int().min(1),buckets:gr(rg)}),ig="swarm-id-accounts",sg="swarm-id-network-settings",ag="swarm-storage-challenge",cg="swarm-id-site-allow-list";function ug(e,t){return`swarm-id-lease-v2:${e.toLowerCase()}:${t.toLowerCase()}`}function lg(e,t){return`swarm-id-app-stamp-usage:${e}:${t.toLowerCase()}`}function fg(e,t){return`swarm-id-soc-restamp-slots:${e}:${t.toLowerCase()}`}function dg(e){return`swarm-id-partition-session:${e}`}const hg=wr({pin:ur().optional(),encrypt:ur().optional(),encryptManifest:ur().optional(),tag:ir().optional(),deferred:ur().optional()}),pg=hg.optional(),mg=Br(["app","identity"]),gg=hg.extend({beeCompatible:ur().optional(),publisher:mg.optional()}).optional(),yg=wr({timeout:ir().optional(),headers:Ir(Fn(),Fn()).optional(),endlesslyRetry:ur().optional()}).optional(),wg=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(),bg=hg.extend({indexDocument:Fn().optional(),errorDocument:Fn().optional()}).optional(),vg=wr({path:Fn().min(1),data:Gr(Uint8Array),contentType:Fn().optional()}),Eg=wr({path:Fn(),reference:km,contentType:Fn().optional()}),_g=wr({reference:km,tagUid:ir().optional()});_g.extend({encryptionKey:Fn().optional(),owner:Im}),_g.extend({encryptionKey:Fn().optional(),owner:Im}),wr({name:Fn(),data:Gr(Uint8Array)});const xg=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 kg=Br(["user-stamp","subsidised","unavailable"]),Ag=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"]),Ig=wr({source:Br(["generated"]),url:Fn()}),$g=wr({id:Fn(),name:Fn(),address:Im,publicKey:Bm.optional(),sharingPublicKey:Bm.optional(),postageSignerAddress:Im.optional(),avatar:Ig});wr({canUpload:ur(),storagePartitioned:ur().optional(),uploadMode:kg.optional(),uploadUnavailableReason:Ag.optional(),partition:ir().int().min(0).optional(),identity:$g.optional(),appKey:wr({address:Im,publicKey:Bm}).optional(),chatBinding:Dm.optional(),beeApiUrl:Fn().optional()});const Bg=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"})}),zg=wr({connectText:Fn().optional(),disconnectText:Fn().optional(),loadingText:Fn().optional(),backgroundColor:Fn().optional(),color:Fn().optional(),borderRadius:Fn().optional(),fontFamily:Fn().optional(),fontSize:Fn().optional(),fontWeight:Er([Fn(),ir()]).optional()}).optional(),Sg=wr({type:Sr("parentIdentify"),requestId:Fn(),beeApiUrl:ng.optional(),popupMode:Br(["popup","window"]).optional(),metadata:Bg,buttonConfig:zg,subsidisedGatewayUrl:Fn().url().optional()}),Og=wr({type:Sr("checkAuth"),requestId:Fn()}),Tg=wr({type:Sr("disconnect"),requestId:Fn()}),Ng=wr({type:Sr("uploadData"),requestId:Fn(),data:Gr(Uint8Array),options:pg,requestOptions:yg,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()}),Rg=wr({type:Sr("downloadData"),requestId:Fn(),reference:km,options:wg,requestOptions:yg}),Ug=wr({type:Sr("deriveAppSecret"),requestId:Fn(),label:Fn()}),Pg=wr({type:Sr("setBeeApiUrl"),requestId:Fn(),beeApiUrl:ng}),Fg=wr({type:Sr("getChatKey"),requestId:Fn()}),Cg=Er([Sr("app"),br({privateKey:$m})]),Lg=xr("kind",[br({kind:Sr("content"),data:Gr(Uint8Array)}),br({kind:Sr("soc"),identifier:Sm,data:Gr(Uint8Array),signer:Cg})]),Mg=br({type:Sr("stampChunk"),requestId:Fn(),chunk:Lg}),Dg=wr({type:Sr("uploadFile"),requestId:Fn(),data:Gr(Uint8Array),name:Fn().optional(),options:pg,requestOptions:yg,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()}),Zg=wr({type:Sr("downloadFile"),requestId:Fn(),reference:km,path:Fn().optional(),options:wg,requestOptions:yg}),jg=wr({type:Sr("uploadFiles"),requestId:Fn(),files:gr(vg),options:bg,requestOptions:yg,enableProgress:ur().optional(),useWorkers:ur().optional(),workerCount:ir().int().min(1).max(32).optional()}),qg=wr({type:Sr("listFiles"),requestId:Fn(),reference:km,requestOptions:yg}),Gg=wr({type:Sr("uploadChunk"),requestId:Fn(),data:Gr(Uint8Array),options:pg,requestOptions:yg}),Hg=wr({type:Sr("downloadChunk"),requestId:Fn(),reference:km,options:wg,requestOptions:yg}),Vg=wr({type:Sr("isConnected"),requestId:Fn()}),Kg=wr({type:Sr("getNodeInfo"),requestId:Fn()}),Wg=wr({type:Sr("gsocMine"),requestId:Fn(),targetOverlay:Fn(),identifier:Fn(),proximity:ir().optional()}),Jg=wr({type:Sr("gsocSend"),requestId:Fn(),signer:Fn(),identifier:Fn(),data:Gr(Uint8Array),options:pg,requestOptions:yg}),Xg=wr({type:Sr("socUpload"),requestId:Fn(),identifier:Sm,data:Gr(Uint8Array),signer:$m.optional(),options:pg,requestOptions:yg}),Yg=wr({type:Sr("socRawUpload"),requestId:Fn(),identifier:Sm,data:Gr(Uint8Array),signer:$m.optional(),options:pg,requestOptions:yg}),Qg=wr({type:Sr("socDownload"),requestId:Fn(),owner:Im.optional(),identifier:Sm,encryptionKey:zm,requestOptions:yg}),ey=wr({type:Sr("socRawDownload"),requestId:Fn(),owner:Im.optional(),identifier:Sm,encryptionKey:zm.optional(),requestOptions:yg}),ty=wr({type:Sr("socGetOwner"),requestId:Fn()}),ny=wr({type:Sr("epochFeedDownloadReference"),requestId:Fn(),topic:Sm,owner:Im.optional(),at:Rm,after:Rm.optional(),encryptionKey:zm.optional(),requestOptions:yg}),ry=wr({lastEpoch:wr({start:Fn(),level:ir()}).optional(),lastTimestamp:Fn().optional()}).optional(),oy=xr("type",[Sg,Og,Tg,Ng,Rg,Ug,Fg,Pg,Mg,Dg,Zg,jg,qg,Gg,Hg,Vg,Kg,Wg,Jg,Xg,Yg,Qg,ey,ty,ny,wr({type:Sr("epochFeedUploadReference"),requestId:Fn(),topic:Sm,signer:$m.optional(),at:Rm,reference:km,encryptionKey:zm.optional(),hints:ry,requestOptions:yg}),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:yg}),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:yg}),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:yg}),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:pg,requestOptions:yg}),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:pg,requestOptions:yg}),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:pg,requestOptions:yg}),wr({type:Sr("createFeedManifest"),requestId:Fn(),topic:Sm,owner:Im.optional(),feedType:Br(["Sequence","Epoch"]).optional(),uploadOptions:pg,requestOptions:yg}),wr({type:Sr("actUploadData"),requestId:Fn(),data:Gr(Uint8Array),grantees:gr(Fn()),options:gg,requestOptions:yg,enableProgress:ur().optional()}),wr({type:Sr("actDownloadData"),requestId:Fn(),encryptedReference:km,historyReference:km,publisherPubKey:Fn(),timestamp:ir().optional(),requestOptions:yg}),wr({type:Sr("actAddGrantees"),requestId:Fn(),historyReference:km,grantees:gr(Fn()),requestOptions:yg}),wr({type:Sr("actRevokeGrantees"),requestId:Fn(),historyReference:km,encryptedReference:km,revokeGrantees:gr(Fn()),requestOptions:yg}),wr({type:Sr("actGetGrantees"),requestId:Fn(),historyReference:km,requestOptions:yg}),wr({type:Sr("getPostageBatch"),requestId:Fn()}),wr({type:Sr("connect"),requestId:Fn(),popupMode:Br(["popup","window"]).optional()})]),iy=wr({type:Sr("proxyReady"),authenticated:ur(),parentOrigin:Fn(),storageShared:ur().optional()}),sy=wr({type:Sr("initError"),error:Fn()}),ay=wr({type:Sr("authStatusResponse"),requestId:Fn(),authenticated:ur(),origin:Fn().optional(),beeApiUrl:Fn().url().optional()}),cy=wr({type:Sr("disconnectResponse"),requestId:Fn(),success:ur()}),uy=wr({type:Sr("authSuccess"),origin:Fn()}),ly=wr({type:Sr("uploadDataResponse"),requestId:Fn(),reference:km,tagUid:ir().optional()}),fy=wr({type:Sr("downloadDataResponse"),requestId:Fn(),data:Gr(Uint8Array)}),dy=wr({type:Sr("deriveAppSecretResponse"),requestId:Fn(),secret:Gr(Uint8Array)}),hy=wr({type:Sr("getChatKeyResponse"),requestId:Fn(),chatKey:Gr(Uint8Array)}),py=wr({type:Sr("setBeeApiUrlResponse"),requestId:Fn(),beeApiUrl:Fn()}),my=wr({type:Sr("stampChunkResponse"),requestId:Fn(),address:Tm,stamp:Nm,owner:Im.optional(),signature:Om.optional()}),gy=wr({type:Sr("uploadFileResponse"),requestId:Fn(),reference:km,tagUid:ir().optional()}),yy=wr({type:Sr("downloadFileResponse"),requestId:Fn(),name:Fn(),data:Gr(Uint8Array)}),wy=wr({type:Sr("uploadFilesResponse"),requestId:Fn(),reference:km,tagUid:ir().optional()}),by=wr({type:Sr("listFilesResponse"),requestId:Fn(),entries:gr(Eg)}),vy=wr({type:Sr("uploadChunkResponse"),requestId:Fn(),reference:km}),Ey=wr({type:Sr("downloadChunkResponse"),requestId:Fn(),data:Gr(Uint8Array)}),_y=wr({type:Sr("uploadProgress"),requestId:Fn(),total:ir(),processed:ir()}),xy=Br(["not-authenticated","upload-unavailable","partition-contended","lease-lost","bee-rejected","network","timeout","invalid-request","invalid-state","init-failed","popup-blocked","internal"]),ky=xr("type",[iy,sy,ay,cy,uy,ly,fy,dy,hy,py,my,gy,yy,wy,by,vy,Ey,_y,wr({error:Fn(),code:xy.catch("internal"),reason:Ag.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:kg.optional(),uploadUnavailableReason:Ag.optional().catch(void 0),identity:$g.optional(),appKey:wr({address:Im,publicKey:Bm}).optional(),partition:ir().int().min(0).optional(),chatBinding:Dm.optional(),beeApiUrl:Fn().optional()}),wr({type:Sr("connectResponse"),requestId:Fn(),success:ur()}),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:xg.optional()})]),Ay=wr({secret:Fn(),networkSettings:tg.optional(),account:Hm,chatBinding:Dm.optional()}),Iy=wr({version:Sr(1),parentOrigin:Fn(),connectedUntil:ir(),data:Fn()}),$y=xr("type",[wr({type:Sr("setSecret"),appOrigin:Fn(),challenge:Fn(),data:Ay})]),By="#FCFCFC",zy="#131416",Sy=[["#FFE0CC","#DD7200","#401F00"],["#99CCFF","#0082FB","#003366"],["#99E6B3","#00C853","#004D1F"],["#E1BEE7","#9C27B0","#4A148C"]],Oy=[];for(const e of Sy)Oy.push([e[1],By]),Oy.push([e[1],zy]),Oy.push([By,e[1]]),Oy.push([zy,e[1]]);for(const e of Sy)Oy.push([e[0],e[1]]),Oy.push([e[2],e[1]]),Oy.push([e[1],e[0]]),Oy.push([e[1],e[2]]),Oy.push([e[0],e[2]]),Oy.push([e[2],e[0]]);for(let e=0;e<Sy.length;e++){const t=Sy[(e+1)%Sy.length];Oy.push([Sy[e][0],t[2]]),Oy.push([t[2],Sy[e][0]])}const Ty=[[0,1],[1,0],[0,-1],[-1,0]];function Ny(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]=Oy[Math.abs(n)%Oy.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 Ty){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 Ry(e,t=40){const n=Ny(e,t);return{source:"generated",url:`data:image/svg+xml;charset=utf-8,${encodeURIComponent(n)}`}}function Uy(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 Py(e){return Array.from(e).map(e=>e.toString(16).padStart(2,"0")).join("")}function Fy(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 Cy extends Error{constructor(e){super(e),this.name="TimeoutError"}}function Ly(e,t,n){let r;const o=new Promise((e,o)=>{r=setTimeout(()=>o(new Cy(n)),t)});return Promise.race([e,o]).finally(()=>clearTimeout(r))}function My(e){return new Promise(t=>setTimeout(t,e))}function Dy(e,t,n){let r,o=!1,i=()=>{};const s=new Promise((e,s)=>{i=()=>{o||(clearTimeout(r),r=setTimeout(()=>s(new Cy(n)),t))},i()}),a=(async()=>e(i))();return Promise.race([a,s]).finally(()=>{o=!0,clearTimeout(r)})}const Zy=0,jy=4096,qy=8,Gy=32,Hy=8;class Vy{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++}Ky(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];Ky(n.subarray(a))}}function Ky(e){0!==e.length&&crypto.getRandomValues(e)}function Wy(e=32){const t=new Uint8Array(e);return Ky(t),t}function Jy(e){return new Vy(e,0,Math.floor(128))}function Xy(e){return new Vy(e,4096,0)}class Yy{encryptChunk(e,t){const n=t||Wy(32);return{key:n,encryptedSpan:Jy(n).encrypt(e.subarray(0,8)),encryptedData:Xy(n).encrypt(e.subarray(8))}}}function Qy(){return new Yy}function ew(e,t){const n=Jy(e).decrypt(t.subarray(0,8)),r=Xy(e).decrypt(t.subarray(8)),o=new Uint8Array(8+r.length);return o.set(n),o.set(r,8),o}const tw=4096;function nw(e){const t=e.slice(0,Ks.LENGTH),n=function(e){if(e.length>tw)throw new Error(`payload size ${e.length} exceeds maximum chunk payload size 4096`);const t=new Uint8Array(tw);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 rw=new TextEncoder;function ow(e,t){if(e instanceof Uint8Array||(e=rw.encode(e)),e.length<0||e.length>jy)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=nw(r);return{data:r,span:n,payload:new Bs(e),address:o}}const iw=new TextEncoder;function sw(e,t){if(e instanceof Uint8Array||(e=iw.encode(e)),e.length<0||e.length>jy)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=Qy(),{key:i,encryptedSpan:s,encryptedData:a}=o.encryptChunk(r,t),c=Jr.Binary.concatBytes(s,a),u=nw(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 aw(e){const t=new DataView(e.buffer,e.byteOffset,e.byteLength);return Number(t.getBigUint64(0,!0))}function cw(e,t){return new Vs(Jr.Binary.keccak256(Jr.Binary.concatBytes(e.toUint8Array(),t.toUint8Array())))}function uw(e,t,n,r){const o=new Fs(e.slice(0,32)),i=Gs.fromSlice(e,32),s=e.slice(97),a=nw(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=cw(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=ew(r,s);f=e.slice(0,8);const t=aw(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=aw(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=aw(f);return{data:h,identifier:o.toHex(),signature:i.toHex(),span:p,payload:d,address:t.toHex(),owner:u.toHex()}}function lw(e,t,n){const r=[],o=n?64:Gy,i=Math.floor(e.length/o),s=Math.ceil(t/jy),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+Gy);if(s.every(e=>0===e))break;if(n){const t=e.slice(i+Gy,i+64);r.push({address:s,encryptionKey:t})}else r.push({address:s})}return r}async function fw(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?ew(t.encryptionKey,o):o;return{span:aw(i.slice(0,8)),payload:i.slice(8)}}async function dw(e,t,n,r,o,i){const{span:s,payload:a}=await fw(e,t,i);if(o(),s<=jy)return a.slice(0,s);const c=lw(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=>dw(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 hw(e,t,n,r,o){const i=function(e){const t=Uy(e);if(t.length===Gy)return{address:t};if(64===t.length)return{address:t.slice(0,Gy),encryptionKey:t.slice(Gy)};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 fw(e,i,o);if(a<=jy)return c.slice(0,a);const u=()=>{},l=lw(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=>dw(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 pw(e,t,n,r){const o=new Ns(t),i=cw(new Fs(n),o);return uw(await e.chunk.download(i.toHex(),void 0,r),i,o)}async function mw(e,t,n,r,o){const i=new Ns(t),s=cw(new Fs(n),i),a="string"==typeof r?Uy(r):r;return uw(await e.chunk.download(s.toHex(),void 0,o),s,i,a)}async function gw(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=Uy(i.reference),i}(e,!0);return{rootReference:n.reference,tagUid:n.tagUid}}async function yw(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=sw(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=ow(i),r=await t(e.data,o);return n.selfAddress=e.address.toUint8Array(),r}}(e,!0);return{rootReference:Py(e.selfAddress),tagUid:o.tagUid}}const ww=["invalid version hash","data too short"];async function bw(e,t,n){const r=function(e,t){try{return _a.unmarshalFromData(e,Uy(t))}catch(e){if(e instanceof Error&&ww.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 hw(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=Py(o.node.selfAddress),s=await hw(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 vw=5,Ew=86400n/BigInt(5),_w=86400,xw=30n*BigInt(_w);async function kw(){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 Aw(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*xw/r)}function Iw(e){if(void 0===e||e<=0)return"N/A";return`${Math.floor(e/_w)}d ${Math.floor(e%_w/3600)}h`}function $w(e,t){return e<=0n||!Number.isInteger(t)||t<=0?0n:e*Ew*BigInt(t)}async function Bw(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 zw(e,t){const n=await Bw(e,t);return n?.batchTTL}const Sw=1e4;function Ow(e){try{return new URL(e).origin}catch{return"The RPC endpoint"}}function Tw(e){return"object"==typeof e&&null!==e}function Nw(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 Rw(e,t,n){if(void 0===e)throw new Error(`${n} returned no result for ${t}.`);return e}async function Uw(e,t,n,r){const o=r.label??Ow(e),i=new AbortController,s=setTimeout(()=>i.abort(),r.timeoutMs),a=e=>i.signal.aborted?new Cy(`${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 Pw(e,t,n,r){const o=r.label??Ow(e);return Rw(Nw(await Uw(e,{jsonrpc:"2.0",id:1,method:t,params:n},t,r),t,o),t,o)}async function Fw(e,t,n){if(0===t.length)return[];const r=n.label??Ow(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 Uw(e,i,o,n);if(!Array.isArray(a))throw Tw(a)&&a.error&&Nw(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(!Tw(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]=Rw(Nw(e,o,r),o,r)}return c}function Cw(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`Wrong positive integer: ${e}`)}function Lw(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 Mw(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 Dw(e,t){Lw(e);const n=t.outputLen;if(e.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}const Zw="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0,jw=e=>e instanceof Uint8Array,qw=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),Gw=(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 Hw(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)),!jw(e))throw new Error("expected Uint8Array, got "+typeof e);return e}class Vw{clone(){return this._cloneInto()}}function Kw(e){const t=t=>e().update(Hw(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function Ww(e=32){if(Zw&&"function"==typeof Zw.getRandomValues)return Zw.getRandomValues(new Uint8Array(e));throw new Error("crypto.getRandomValues must be defined")}class Jw extends Vw{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=qw(this.buffer)}update(e){Mw(this);const{view:t,buffer:n,blockLen:r}=this,o=(e=Hw(e)).length;for(let i=0;i<o;){const s=Math.min(r-this.pos,o-i);if(s===r){const t=qw(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){Mw(this),Dw(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=qw(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 Xw=(e,t,n)=>e&t^~e&n,Yw=(e,t,n)=>e&t^e&n^t&n,Qw=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]),eb=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),tb=new Uint32Array(64);class nb extends Jw{constructor(){super(64,32,8,!1),this.A=0|eb[0],this.B=0|eb[1],this.C=0|eb[2],this.D=0|eb[3],this.E=0|eb[4],this.F=0|eb[5],this.G=0|eb[6],this.H=0|eb[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)tb[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=tb[e-15],n=tb[e-2],r=Gw(t,7)^Gw(t,18)^t>>>3,o=Gw(n,17)^Gw(n,19)^n>>>10;tb[e]=o+tb[e-7]+r+tb[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+(Gw(s,6)^Gw(s,11)^Gw(s,25))+Xw(s,a,c)+Qw[e]+tb[e]|0,l=(Gw(n,2)^Gw(n,13)^Gw(n,22))+Yw(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(){tb.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const rb=Kw(()=>new nb),ob=BigInt(0),ib=BigInt(1),sb=BigInt(2),ab=e=>e instanceof Uint8Array,cb=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));
14
+ /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function ub(e){if(!ab(e))throw new Error("Uint8Array expected");let t="";for(let n=0;n<e.length;n++)t+=cb[e[n]];return t}function lb(e){const t=e.toString(16);return 1&t.length?`0${t}`:t}function fb(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);return BigInt(""===e?"0":`0x${e}`)}function db(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 hb(e){return fb(ub(e))}function pb(e){if(!ab(e))throw new Error("Uint8Array expected");return fb(ub(Uint8Array.from(e).reverse()))}function mb(e,t){return db(e.toString(16).padStart(2*t,"0"))}function gb(e,t){return mb(e,t).reverse()}function yb(e,t,n){let r;if("string"==typeof t)try{r=db(t)}catch(n){throw new Error(`${e} must be valid hex string, got "${t}". Cause: ${n}`)}else{if(!ab(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 wb(...e){const t=new Uint8Array(e.reduce((e,t)=>e+t.length,0));let n=0;return e.forEach(e=>{if(!ab(e))throw new Error("Uint8Array expected");t.set(e,n),n+=e.length}),t}const bb=e=>(sb<<BigInt(e-1))-ib,vb=e=>new Uint8Array(e),Eb=e=>Uint8Array.from(e);function _b(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=vb(e),o=vb(e),i=0;const s=()=>{r.fill(1),o.fill(0),i=0},a=(...e)=>n(o,r,...e),c=(e=vb())=>{o=a(Eb([0]),e),r=a(),0!==e.length&&(o=a(Eb([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 wb(...n)};return(e,t)=>{let n;for(s(),c(e);!(n=t(u()));)c();return s(),n}}const xb={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 kb(e,t,n={}){const r=(t,n,r)=>{const o=xb[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 Ab=Object.freeze({__proto__:null,bitGet:function(e,t){return e>>BigInt(t)&ib},bitLen:function(e){let t;for(t=0;e>ob;e>>=ib,t+=1);return t},bitMask:bb,bitSet:(e,t,n)=>e|(n?ib:ob)<<BigInt(t),bytesToHex:ub,bytesToNumberBE:hb,bytesToNumberLE:pb,concatBytes:wb,createHmacDrbg:_b,ensureBytes:yb,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:db,hexToNumber:fb,numberToBytesBE:mb,numberToBytesLE:gb,numberToHexUnpadded:lb,numberToVarBytesBE:function(e){return db(lb(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:kb});
15
+ /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Ib=BigInt(0),$b=BigInt(1),Bb=BigInt(2),zb=BigInt(3),Sb=BigInt(4),Ob=BigInt(5),Tb=BigInt(8);function Nb(e,t){const n=e%t;return n>=Ib?n:t+n}function Rb(e,t,n){if(n<=Ib||t<Ib)throw new Error("Expected power/modulo > 0");if(n===$b)return Ib;let r=$b;for(;t>Ib;)t&$b&&(r=r*e%n),e=e*e%n,t>>=$b;return r}function Ub(e,t,n){let r=e;for(;t-- >Ib;)r*=r,r%=n;return r}function Pb(e,t){if(e===Ib||t<=Ib)throw new Error(`invert: expected positive integers, got n=${e} mod=${t}`);let n=Nb(e,t),r=t,o=Ib,i=$b;for(;n!==Ib;){const e=r%n,t=o-i*(r/n);r=n,n=e,o=i,i=t}if(r!==$b)throw new Error("invert: does not exist");return Nb(o,t)}function Fb(e){if(e%Sb===zb){const t=(e+$b)/Sb;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%Tb===Ob){const t=(e-Ob)/Tb;return function(e,n){const r=e.mul(n,Bb),o=e.pow(r,t),i=e.mul(n,o),s=e.mul(e.mul(i,Bb),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-$b)/Bb;let n,r,o;for(n=e-$b,r=0;n%Bb===Ib;n/=Bb,r++);for(o=Bb;o<e&&Rb(o,t,e)!==e-$b;o++);if(1===r){const t=(e+$b)/Sb;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+$b)/Bb;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,$b<<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 Cb=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Lb(e,t){const n=void 0!==t?t:e.toString(2).length;return{nBitLength:n,nByteLength:Math.ceil(n/8)}}function Mb(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 Db(e){const t=Mb(e);return t+Math.ceil(t/2)}
16
16
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
17
- const Cb=BigInt(0),Lb=BigInt(1);function Mb(e){return function(e){vb(e,Rb.reduce((e,t)=>(e[t]="function",e),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"}))}(e.Fp),vb(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Ub(e.n,e.nBitLength),...e,p:e.Fp.ORDER})}
18
- /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const{bytesToNumberBE:Db,hexToBytes:Zb}=Eb,jb={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(e){const{Err:t}=jb;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:Db(r),l:e.subarray(n+2)}},toSig(e){const{Err:t}=jb,n="string"==typeof e?Zb(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}=jb._parseInt(n.subarray(2)),{d:s,l:a}=jb._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}`}},qb=BigInt(0),Gb=BigInt(1);BigInt(2);const Hb=BigInt(3);function Vb(e){const t=function(e){const t=Mb(e);vb(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 pb(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&&qb<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=ib(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:ub(hb("private key",e,r))}catch(t){throw new Error(`private key must be ${r} bytes, hex or bigint, not ${typeof e}`)}return o&&(s=zb(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(hb("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,Hb),{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,Hb);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===qb)return r;if(a(e),e===Gb)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>qb||u>qb;)s&Gb&&(l=l.add(p)),u&Gb&&(d=d.add(p)),p=p.double(),s>>=Gb,u>>=Gb;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!==qb&&t!==Gb&&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===Gb)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===Gb?this:n?n(f,this):this.multiplyUnsafe(t.h)}toRawBytes(e=!0){return this.assertValidity(),r(f,this,e)}toHex(e=!0){return ib(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>Cb;)n&Lb&&(r=r.add(o)),o=o.double(),n>>=Lb;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+=Lb);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 Kb(e){const t=function(e){const t=Mb(e);return vb(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 zb(e,r)}function a(e){return Tb(e,r)}const{ProjectivePoint:c,normPrivateKeyToScalar:u,weierstrassEquation:l,isWithinCurveOrder:f}=Vb({...t,toBytes(e,t,r){const o=t.toAffine(),i=n.toBytes(o.x),s=pb;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=ub(s);if(!(qb<(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&Gb)===Gb)&&(o=n.neg(o)),{x:e,y:o}}var a}}),d=e=>ib(fb(e,t.nByteLength));function h(e){return e>r>>Gb}const p=(e,t,n)=>ub(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=hb("compactSignature",e,2*n),new m(p(e,0,n),p(e,n,2*n))}static fromDER(e){const{r:t,s:n}=jb.toSig(hb("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(hb("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 cb(this.toDERHex())}toDERHex(){return jb.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return cb(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=Fb(t.n);return function(e,t,n=!1){const r=e.length,o=Pb(t),i=Fb(t);if(r<16||r<i||r>1024)throw new Error(`expected ${i}-1024 bytes of input, got ${r}`);const s=zb(n?ub(e):lb(e),t-xb)+xb;return n?db(s,o):fb(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=ub(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=mb(t.nBitLength);function E(e){if("bigint"!=typeof e)throw new Error("bigint expected");if(!(qb<=e&&e<v))throw new Error(`bigint expected < 2^${t.nBitLength}`);return fb(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=hb("msgHash",e),p&&(e=hb("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(hb("extraEntropy",e))}const k=pb(..._),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===qb)return;const i=s(n*s(A+o*v));if(i===qb)return;let u=(r.x===o?0:2)|Number(r.y&Gb),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 wb(s.hash.outputLen,s.nByteLength,s.hmac)(o,i)},verify:function(e,n,r,o=k){const i=e;if(n=hb("msgHash",n),r=hb("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 jb.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 Wb extends jw{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");Rw(e.outputLen),Rw(e.blockLen)}(e);const n=Zw(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 Pw(this),this.iHash.update(e),this}digestInto(e){Pw(this),Uw(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 Jb=(e,t,n)=>new Wb(e,t).update(n).digest();
17
+ const Zb=BigInt(0),jb=BigInt(1);function qb(e){return function(e){kb(e,Cb.reduce((e,t)=>(e[t]="function",e),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"}))}(e.Fp),kb(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Lb(e.n,e.nBitLength),...e,p:e.Fp.ORDER})}
18
+ /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const{bytesToNumberBE:Gb,hexToBytes:Hb}=Ab,Vb={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(e){const{Err:t}=Vb;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:Gb(r),l:e.subarray(n+2)}},toSig(e){const{Err:t}=Vb,n="string"==typeof e?Hb(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}=Vb._parseInt(n.subarray(2)),{d:s,l:a}=Vb._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}`}},Kb=BigInt(0),Wb=BigInt(1);BigInt(2);const Jb=BigInt(3);function Xb(e){const t=function(e){const t=qb(e);kb(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 wb(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&&Kb<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=ub(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:hb(yb("private key",e,r))}catch(t){throw new Error(`private key must be ${r} bytes, hex or bigint, not ${typeof e}`)}return o&&(s=Nb(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(yb("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,Jb),{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,Jb);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===Kb)return r;if(a(e),e===Wb)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>Kb||u>Kb;)s&Wb&&(l=l.add(p)),u&Wb&&(d=d.add(p)),p=p.double(),s>>=Wb,u>>=Wb;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!==Kb&&t!==Wb&&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===Wb)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===Wb?this:n?n(f,this):this.multiplyUnsafe(t.h)}toRawBytes(e=!0){return this.assertValidity(),r(f,this,e)}toHex(e=!0){return ub(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>Zb;)n&jb&&(r=r.add(o)),o=o.double(),n>>=jb;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+=jb);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 Yb(e){const t=function(e){const t=qb(e);return kb(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 Nb(e,r)}function a(e){return Pb(e,r)}const{ProjectivePoint:c,normPrivateKeyToScalar:u,weierstrassEquation:l,isWithinCurveOrder:f}=Xb({...t,toBytes(e,t,r){const o=t.toAffine(),i=n.toBytes(o.x),s=wb;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=hb(s);if(!(Kb<(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&Wb)===Wb)&&(o=n.neg(o)),{x:e,y:o}}var a}}),d=e=>ub(mb(e,t.nByteLength));function h(e){return e>r>>Wb}const p=(e,t,n)=>hb(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=yb("compactSignature",e,2*n),new m(p(e,0,n),p(e,n,2*n))}static fromDER(e){const{r:t,s:n}=Vb.toSig(yb("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(yb("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 db(this.toDERHex())}toDERHex(){return Vb.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return db(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=Db(t.n);return function(e,t,n=!1){const r=e.length,o=Mb(t),i=Db(t);if(r<16||r<i||r>1024)throw new Error(`expected ${i}-1024 bytes of input, got ${r}`);const s=Nb(n?hb(e):pb(e),t-$b)+$b;return n?gb(s,o):mb(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=hb(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=bb(t.nBitLength);function E(e){if("bigint"!=typeof e)throw new Error("bigint expected");if(!(Kb<=e&&e<v))throw new Error(`bigint expected < 2^${t.nBitLength}`);return mb(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=yb("msgHash",e),p&&(e=yb("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(yb("extraEntropy",e))}const k=wb(..._),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===Kb)return;const i=s(n*s(A+o*v));if(i===Kb)return;let u=(r.x===o?0:2)|Number(r.y&Wb),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 _b(s.hash.outputLen,s.nByteLength,s.hmac)(o,i)},verify:function(e,n,r,o=k){const i=e;if(n=yb("msgHash",n),r=yb("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 Vb.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 Qb extends Vw{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");Cw(e.outputLen),Cw(e.blockLen)}(e);const n=Hw(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 Mw(this),this.iHash.update(e),this}digestInto(e){Mw(this),Lw(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 ev=(e,t,n)=>new Qb(e,t).update(n).digest();
19
19
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
20
- function Xb(e){return{hash:e,hmac:(t,...n)=>Jb(e,t,function(...e){const t=new Uint8Array(e.reduce((e,t)=>e+t.length,0));let n=0;return e.forEach(e=>{if(!Lw(e))throw new Error("Uint8Array expected");t.set(e,n),n+=e.length}),t}(...n)),randomBytes:Gw}}Jb.create=(e,t)=>new Wb(e,t);
20
+ function tv(e){return{hash:e,hmac:(t,...n)=>ev(e,t,function(...e){const t=new Uint8Array(e.reduce((e,t)=>e+t.length,0));let n=0;return e.forEach(e=>{if(!jw(e))throw new Error("Uint8Array expected");t.set(e,n),n+=e.length}),t}(...n)),randomBytes:Ww}}ev.create=(e,t)=>new Qb(e,t);
21
21
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
22
- const Yb=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Qb=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),ev=BigInt(1),tv=BigInt(2),nv=(e,t)=>(e+t/tv)/t;const rv=function(e,t,n=!1,r={}){if(e<=_b)throw new Error(`Expected Field ORDER > 0, got ${e}`);const{nBitLength:o,nByteLength:i}=Ub(e,t);if(i>2048)throw new Error("Field lengths over 2048 bytes are not supported");const s=Nb(e),a=Object.freeze({ORDER:e,BITS:o,BYTES:i,MASK:mb(o),ZERO:_b,ONE:xb,create:t=>zb(t,e),isValid:t=>{if("bigint"!=typeof t)throw new Error("Invalid field element: expected bigint, got "+typeof t);return _b<=t&&t<e},is0:e=>e===_b,isOdd:e=>(e&xb)===xb,neg:t=>zb(-t,e),eql:(e,t)=>e===t,sqr:t=>zb(t*t,e),add:(t,n)=>zb(t+n,e),sub:(t,n)=>zb(t-n,e),mul:(t,n)=>zb(t*n,e),pow:(e,t)=>function(e,t,n){if(n<_b)throw new Error("Expected power > 0");if(n===_b)return e.ONE;if(n===xb)return t;let r=e.ONE,o=t;for(;n>_b;)n&xb&&(r=e.mul(r,o)),o=e.sqr(o),n>>=xb;return r}(a,e,t),div:(t,n)=>zb(t*Tb(n,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>Tb(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?db(e,i):fb(e,i),fromBytes:e=>{if(e.length!==i)throw new Error(`Fp.fromBytes: expected ${i}, got ${e.length}`);return n?lb(e):ub(e)}});return Object.freeze(a)}(Yb,void 0,void 0,{sqrt:function(e){const t=Yb,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=Ob(l,n,t)*l%t,d=Ob(f,n,t)*l%t,h=Ob(d,tv,t)*u%t,p=Ob(h,o,t)*h%t,m=Ob(p,i,t)*p%t,g=Ob(m,a,t)*m%t,y=Ob(g,c,t)*g%t,w=Ob(y,a,t)*m%t,b=Ob(w,n,t)*l%t,v=Ob(b,s,t)*p%t,E=Ob(v,r,t)*u%t,_=Ob(E,tv,t);if(!rv.eql(rv.sqr(_),e))throw new Error("Cannot find square root");return _}}),ov=function(e,t){const n=t=>Kb({...e,...Xb(t)});return Object.freeze({...n(t),create:n})}({a:BigInt(0),b:BigInt(7),Fp:rv,n:Qb,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{const t=Qb,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-ev*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=n,s=BigInt("0x100000000000000000000000000000000"),a=nv(i*e,t),c=nv(-r*e,t);let u=zb(e-a*n-c*o,t),l=zb(-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}}}},Qw);BigInt(0),ov.ProjectivePoint;const iv=BigInt(2**32-1),sv=BigInt(32);function av(e,t=!1){return t?{h:Number(e&iv),l:Number(e>>sv&iv)}:{h:0|Number(e>>sv&iv),l:0|Number(e&iv)}}function cv(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}=av(e[o],t);[n[o],r[o]]=[i,s]}return[n,r]}const[uv,lv,fv]=[[],[],[]],dv=BigInt(0),hv=BigInt(1),pv=BigInt(2),mv=BigInt(7),gv=BigInt(256),yv=BigInt(113);for(let e=0,t=hv,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],uv.push(2*(5*r+n)),lv.push((e+1)*(e+2)/2%64);let o=dv;for(let e=0;e<7;e++)t=(t<<hv^(t>>mv)*yv)%gv,t&pv&&(o^=hv<<(hv<<BigInt(e))-hv);fv.push(o)}const[wv,bv]=cv(fv,!0),vv=(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),Ev=(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 _v extends jw{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,Rw(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=vv(i,s,1)^n[r],c=Ev(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=lv[n],i=vv(t,o,r),s=Ev(t,o,r),a=uv[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]^=wv[r],e[1]^=bv[r]}n.fill(0)}(this.state32,this.rounds),this.posOut=0,this.pos=0}update(e){Pw(this);const{blockLen:t,state:n}=this,r=(e=Zw(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){Pw(this,!1),Uw(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 Rw(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(Fw(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 _v(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 xv=((e,t,n)=>qw(()=>new _v(t,e,n)))(1,136,32),kv="swarm-encryption",Av="postage-signer",Iv="backup-key",$v="act-sharing";async function Bv(e,t){const n=await crypto.subtle.importKey("raw",Oy(e),{name:"HMAC",hash:"SHA-256"},!1,["sign"]),r=await crypto.subtle.sign("HMAC",n,(new TextEncoder).encode(t));return Ty(new Uint8Array(r))}function zv(e,t){return Ty(Jb(Qw,Oy(e),(new TextEncoder).encode(t)))}async function Sv(e,t){const n=await Bv(e,t);return crypto.subtle.importKey("raw",Oy(n),"AES-GCM",!1,["encrypt","decrypt"])}async function Ov(e){return Bv(e,"derivation-key")}async function Tv(e){return Bv(e,kv)}async function Nv(e){return Bv(e,Av)}function Rv(e){return zv(e,Av)}function Uv(e){const t=Oy(zv(e,$v));return{secret:t,publicKey:new Hs(t).publicKey().toCompressedHex()}}function Pv(e){return function(e,t){for(let n=0;n<16;n++){const r=e(0===n?t:`${t}/${n}`);if(ov.utils.isValidPrivateKey(r))return r}throw new Error(`No valid secp256k1 private key under "${t}" in 16 attempts.`)}(t=>Oy(zv(e,t)),"swarm-id chat key v1")}const Fv="Swarm ID chat binding v1",Cv="Site: ",Lv="Chat address: ",Mv="Date: ",Dv=/^0x[0-9a-fA-F]{130}$/,Zv=/^0x[0-9a-f]{40}$/,jv=/^(0x)?[0-9a-fA-F]{40}$/,qv=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/,Gv=/^[a-z0-9-]+(\.[a-z0-9-]+)*$/,Hv=new Set(["localhost","127.0.0.1","[::1]"]);function Vv(e,t={}){let n;try{n=new URL(e)}catch{return!1}const r="https:"===n.protocol,o=!0===t.allowLocalHttp&&"http:"===n.protocol&&Hv.has(n.hostname);return!(!r&&!o)&&(!(!o&&!Gv.test(n.hostname))&&(""!==n.host&&""===n.username&&""===n.password&&n.origin===e))}function Kv(e){return e.toLowerCase().replace(/^0x/,"")}function Wv(e,t){if(!Vv(e,t))throw new Error(`Chat binding site is not a clean https origin: ${e}`)}function Jv(e,t={}){if(Wv(e.site,t),!jv.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[Fv,`${Cv}${e.site}`,`${Lv}0x${Kv(e.chatAddress)}`,`${Mv}${e.date.toISOString()}`].join("\n")}function Xv(e,t){if(!e.startsWith(t))throw new Error(`Chat binding line does not start with "${t}".`);return e.slice(t.length)}function Yv(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!==Fv)throw new Error("Not a Swarm ID chat binding v1.");const a=Xv(o,Cv);Wv(a,t);const c=Xv(i,Lv);if(!Zv.test(c))throw new Error("Chat address is not 0x and 40 lower-case hex characters.");const u=Xv(s,Mv);if(!function(e){if(!qv.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 Qv(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),xv(r)}function eE(e){return new Hs(Pv(e)).publicKey().address().toHex()}function tE(e,t,n,r={}){Wv(t,r);const o=Jv({site:t,chatAddress:eE(zv(e,t)),date:n},r),i=ov.sign(Qv(o),Oy(e)),s=(i.recovery+27).toString(16);return{message:o,signature:`0x${i.toCompactHex()}${s}`}}function nE(e,t={}){const n=Yv(e.message,t);if(!Dv.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=ov.Signature.fromCompact(r);if(t.hasHighS())throw new Error("high s");const n=t.addRecoveryBit(o).recoverPublicKey(Qv(e.message));s=n.toRawBytes(!1),i=`0x${Ty(xv(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 rE(e,t,n={}){if(!e)return;let r;try{r=nE(e,n)}catch{return}return r.site===t.site&&Kv(r.chatAddress)===Kv(t.chatAddress)&&Kv(r.signer)===Kv(t.signer)?e:void 0}function oE(e,t){return e.map(e=>{if(e.appUrl===t||void 0===e.chatBinding)return e;const{chatBinding:n,...r}=e;return r})}const iE={allowLocalHttp:!0};function sE(e){try{return Date.parse(Yv(e.message,iE).date)}catch{return Number.NEGATIVE_INFINITY}}function aE(e,t,n){try{const r=nE(e,iE);return r.site===t&&Kv(r.signer)===Kv(n)}catch{return!1}}function cE(e,t,n,r){if(!e||!t)return e??t;const o=aE(e,n,r);return o!==aE(t,n,r)?o?e:t:sE(t)>sE(e)?t:e}export{ca as $,Ig as A,gh as B,Fv as C,vm as D,Ns as E,Vh as F,Na as G,Ia as H,vy as I,zs as J,$a as K,Ua as L,_a as M,gm as N,fd as O,ty as P,Ds as Q,Vs as R,e as S,Js as T,xd as U,dh as V,fh as W,Hh as X,Bs as Y,ua as Z,la as _,Fs as a,yp as a$,fa as a0,Wh as a1,Jh as a2,Cs as a3,Qh as a4,ep as a5,op as a6,rp as a7,np as a8,tp as a9,wh as aA,Ep as aB,vp as aC,Ch as aD,cs as aE,Lh as aF,xp as aG,kp as aH,Ip as aI,$p as aJ,Bp as aK,zp as aL,Sp as aM,Op as aN,Cp as aO,Pp as aP,Fp as aQ,Up as aR,Np as aS,Rp as aT,Mh as aU,xh as aV,kh as aW,ad as aX,dp as aY,hp as aZ,gp as a_,Dh as aa,Th as ab,Ks as ac,hh as ad,_h as ae,Oh as af,pa as ag,bh as ah,Uh as ai,wp as aj,cp as ak,lp as al,up as am,fp as an,bp as ao,Lf as ap,qh as aq,Nh as ar,Us as as,_s as at,vs as au,da as av,bs as aw,ph as ax,Gh as ay,Rh as az,bm as b,Iw as b$,sm as b0,am as b1,om as b2,rm as b3,im as b4,lm as b5,fm as b6,Zh as b7,hm as b8,pm as b9,og as bA,eg as bB,rg as bC,Jm as bD,Vm as bE,Sv as bF,zv as bG,kv as bH,Av as bI,$v as bJ,My as bK,Cy as bL,Ly as bM,Ir as bN,hw as bO,mw as bP,cE as bQ,fw as bR,Ym as bS,Py as bT,Qm as bU,Gr as bV,uw as bW,Lm as bX,Zm as bY,Tv as bZ,gw as b_,mm as ba,Xs as bb,cm as bc,um as bd,yh as be,Sh as bf,Dm as bg,wr as bh,Wm as bi,Sr as bj,gr as bk,Fn as bl,ir as bm,xr as bn,ng as bo,dr as bp,vn as bq,nw as br,ew as bs,ym as bt,Yy as bu,Zy as bv,Wy as bw,Bv as bx,Pa as by,Iv as bz,Hs as c,Aw as c0,ov as c1,Gy as c2,Em as c3,ig as c4,eE as c5,oE as c6,lg as c7,_y as c8,Ey as c9,ag as ca,Bg as cb,xy as cc,Uv as cd,Rv as ce,lw as cf,Pv as cg,cg as ch,ug as ci,kw as cj,vw as ck,Ew as cl,xv as cm,sg as cn,km as co,Im as cp,Gm as cq,Ov as cr,Nv as cs,tE as ct,Ny as cu,Fy as cv,xw as cw,wm as cx,Ry as d,zy as e,_w as f,Sy as g,Oy as h,Nw as i,Tw as j,rE as k,Jv as l,Vv as m,sh as n,Wd as o,Yv as p,Gs as q,lh as r,dw as s,Jr as t,Ty as u,nE as v,Uy as w,jh as x,mh as y,Ra as z};
23
- //# sourceMappingURL=chat-binding-DlH_ZkTn.js.map
22
+ const nv=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),rv=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),ov=BigInt(1),iv=BigInt(2),sv=(e,t)=>(e+t/iv)/t;const av=function(e,t,n=!1,r={}){if(e<=Ib)throw new Error(`Expected Field ORDER > 0, got ${e}`);const{nBitLength:o,nByteLength:i}=Lb(e,t);if(i>2048)throw new Error("Field lengths over 2048 bytes are not supported");const s=Fb(e),a=Object.freeze({ORDER:e,BITS:o,BYTES:i,MASK:bb(o),ZERO:Ib,ONE:$b,create:t=>Nb(t,e),isValid:t=>{if("bigint"!=typeof t)throw new Error("Invalid field element: expected bigint, got "+typeof t);return Ib<=t&&t<e},is0:e=>e===Ib,isOdd:e=>(e&$b)===$b,neg:t=>Nb(-t,e),eql:(e,t)=>e===t,sqr:t=>Nb(t*t,e),add:(t,n)=>Nb(t+n,e),sub:(t,n)=>Nb(t-n,e),mul:(t,n)=>Nb(t*n,e),pow:(e,t)=>function(e,t,n){if(n<Ib)throw new Error("Expected power > 0");if(n===Ib)return e.ONE;if(n===$b)return t;let r=e.ONE,o=t;for(;n>Ib;)n&$b&&(r=e.mul(r,o)),o=e.sqr(o),n>>=$b;return r}(a,e,t),div:(t,n)=>Nb(t*Pb(n,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>Pb(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?gb(e,i):mb(e,i),fromBytes:e=>{if(e.length!==i)throw new Error(`Fp.fromBytes: expected ${i}, got ${e.length}`);return n?pb(e):hb(e)}});return Object.freeze(a)}(nv,void 0,void 0,{sqrt:function(e){const t=nv,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=Ub(l,n,t)*l%t,d=Ub(f,n,t)*l%t,h=Ub(d,iv,t)*u%t,p=Ub(h,o,t)*h%t,m=Ub(p,i,t)*p%t,g=Ub(m,a,t)*m%t,y=Ub(g,c,t)*g%t,w=Ub(y,a,t)*m%t,b=Ub(w,n,t)*l%t,v=Ub(b,s,t)*p%t,E=Ub(v,r,t)*u%t,_=Ub(E,iv,t);if(!av.eql(av.sqr(_),e))throw new Error("Cannot find square root");return _}}),cv=function(e,t){const n=t=>Yb({...e,...tv(t)});return Object.freeze({...n(t),create:n})}({a:BigInt(0),b:BigInt(7),Fp:av,n:rv,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{const t=rv,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-ov*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=n,s=BigInt("0x100000000000000000000000000000000"),a=sv(i*e,t),c=sv(-r*e,t);let u=Nb(e-a*n-c*o,t),l=Nb(-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}}}},rb);BigInt(0),cv.ProjectivePoint;const uv=BigInt(2**32-1),lv=BigInt(32);function fv(e,t=!1){return t?{h:Number(e&uv),l:Number(e>>lv&uv)}:{h:0|Number(e>>lv&uv),l:0|Number(e&uv)}}function dv(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}=fv(e[o],t);[n[o],r[o]]=[i,s]}return[n,r]}const[hv,pv,mv]=[[],[],[]],gv=BigInt(0),yv=BigInt(1),wv=BigInt(2),bv=BigInt(7),vv=BigInt(256),Ev=BigInt(113);for(let e=0,t=yv,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],hv.push(2*(5*r+n)),pv.push((e+1)*(e+2)/2%64);let o=gv;for(let e=0;e<7;e++)t=(t<<yv^(t>>bv)*Ev)%vv,t&wv&&(o^=yv<<(yv<<BigInt(e))-yv);mv.push(o)}const[_v,xv]=dv(mv,!0),kv=(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),Av=(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 Iv extends Vw{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,Cw(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=kv(i,s,1)^n[r],c=Av(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=pv[n],i=kv(t,o,r),s=Av(t,o,r),a=hv[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]^=_v[r],e[1]^=xv[r]}n.fill(0)}(this.state32,this.rounds),this.posOut=0,this.pos=0}update(e){Mw(this);const{blockLen:t,state:n}=this,r=(e=Hw(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){Mw(this,!1),Lw(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 Cw(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(Dw(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 Iv(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 $v=((e,t,n)=>Kw(()=>new Iv(t,e,n)))(1,136,32),Bv="swarm-encryption",zv="postage-signer",Sv="backup-key",Ov="act-sharing";async function Tv(e,t){const n=await crypto.subtle.importKey("raw",Uy(e),{name:"HMAC",hash:"SHA-256"},!1,["sign"]),r=await crypto.subtle.sign("HMAC",n,(new TextEncoder).encode(t));return Py(new Uint8Array(r))}function Nv(e,t){return Py(ev(rb,Uy(e),(new TextEncoder).encode(t)))}async function Rv(e,t){const n=await Tv(e,t);return crypto.subtle.importKey("raw",Uy(n),"AES-GCM",!1,["encrypt","decrypt"])}async function Uv(e){return Tv(e,"derivation-key")}async function Pv(e){return Tv(e,Bv)}async function Fv(e){return Tv(e,zv)}function Cv(e){return Nv(e,zv)}function Lv(e){const t=Uy(Nv(e,Ov));return{secret:t,publicKey:new Hs(t).publicKey().toCompressedHex()}}function Mv(e){return function(e,t){for(let n=0;n<16;n++){const r=e(0===n?t:`${t}/${n}`);if(cv.utils.isValidPrivateKey(r))return r}throw new Error(`No valid secp256k1 private key under "${t}" in 16 attempts.`)}(t=>Uy(Nv(e,t)),"swarm-id chat key v1")}const Dv="Swarm ID chat binding v1",Zv="Site: ",jv="Chat address: ",qv="Date: ",Gv=/^0x[0-9a-fA-F]{130}$/,Hv=/^0x[0-9a-f]{40}$/,Vv=/^(0x)?[0-9a-fA-F]{40}$/,Kv=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/,Wv=/^[a-z0-9-]+(\.[a-z0-9-]+)*$/,Jv=new Set(["localhost","127.0.0.1","[::1]"]);function Xv(e,t={}){let n;try{n=new URL(e)}catch{return!1}const r="https:"===n.protocol,o=!0===t.allowLocalHttp&&"http:"===n.protocol&&Jv.has(n.hostname);return!(!r&&!o)&&(!(!o&&!Wv.test(n.hostname))&&(""!==n.host&&""===n.username&&""===n.password&&n.origin===e))}function Yv(e){return e.toLowerCase().replace(/^0x/,"")}function Qv(e,t){if(!Xv(e,t))throw new Error(`Chat binding site is not a clean https origin: ${e}`)}function eE(e,t={}){if(Qv(e.site,t),!Vv.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[Dv,`${Zv}${e.site}`,`${jv}0x${Yv(e.chatAddress)}`,`${qv}${e.date.toISOString()}`].join("\n")}function tE(e,t){if(!e.startsWith(t))throw new Error(`Chat binding line does not start with "${t}".`);return e.slice(t.length)}function nE(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!==Dv)throw new Error("Not a Swarm ID chat binding v1.");const a=tE(o,Zv);Qv(a,t);const c=tE(i,jv);if(!Hv.test(c))throw new Error("Chat address is not 0x and 40 lower-case hex characters.");const u=tE(s,qv);if(!function(e){if(!Kv.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 rE(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),$v(r)}function oE(e){return new Hs(Mv(e)).publicKey().address().toHex()}function iE(e,t,n,r={}){Qv(t,r);const o=eE({site:t,chatAddress:oE(Nv(e,t)),date:n},r),i=cv.sign(rE(o),Uy(e)),s=(i.recovery+27).toString(16);return{message:o,signature:`0x${i.toCompactHex()}${s}`}}function sE(e,t={}){const n=nE(e.message,t);if(!Gv.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=cv.Signature.fromCompact(r);if(t.hasHighS())throw new Error("high s");const n=t.addRecoveryBit(o).recoverPublicKey(rE(e.message));s=n.toRawBytes(!1),i=`0x${Py($v(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 aE(e,t,n={}){if(!e)return;let r;try{r=sE(e,n)}catch{return}return r.site===t.site&&Yv(r.chatAddress)===Yv(t.chatAddress)&&Yv(r.signer)===Yv(t.signer)?e:void 0}function cE(e,t){return e.map(e=>{if(e.appUrl===t||void 0===e.chatBinding)return e;const{chatBinding:n,...r}=e;return r})}const uE={allowLocalHttp:!0};function lE(e){try{return Date.parse(nE(e.message,uE).date)}catch{return Number.NEGATIVE_INFINITY}}function fE(e,t,n){try{const r=sE(e,uE);return r.site===t&&Yv(r.signer)===Yv(n)}catch{return!1}}function dE(e,t,n,r){if(!e||!t)return e??t;const o=fE(e,n,r);return o!==fE(t,n,r)?o?e:t:lE(t)>lE(e)?t:e}export{la as $,Bg as A,Ra as B,Dv as C,Em as D,Ns as E,gh as F,Vh as G,Na as H,ky as I,Ia as J,zs as K,$a as L,_a as M,gm as N,Ua as O,oy as P,fd as Q,Vs as R,e as S,Js as T,Ds as U,xd as V,dh as W,fh as X,Hh as Y,Bs as Z,ua as _,Fs as a,gp as a$,ca as a0,fa as a1,Wh as a2,Jh as a3,Cs as a4,Qh as a5,ep as a6,op as a7,rp as a8,np as a9,Rh as aA,wh as aB,Ep as aC,vp as aD,Ch as aE,cs as aF,Lh as aG,xp as aH,kp as aI,Ip as aJ,$p as aK,Bp as aL,zp as aM,Sp as aN,Op as aO,Cp as aP,Pp as aQ,Fp as aR,Up as aS,Np as aT,Rp as aU,Mh as aV,xh as aW,kh as aX,ad as aY,dp as aZ,hp as a_,tp as aa,Dh as ab,Th as ac,Ks as ad,hh as ae,_h as af,Oh as ag,pa as ah,bh as ai,Uh as aj,wp as ak,cp as al,lp as am,up as an,fp as ao,bp as ap,Lf as aq,qh as ar,Nh as as,Us as at,_s as au,vs as av,da as aw,bs as ax,ph as ay,Gh as az,vm as b,vw as b$,yp as b0,sm as b1,am as b2,om as b3,rm as b4,im as b5,lm as b6,fm as b7,Zh as b8,hm as b9,Sv as bA,sg as bB,tg as bC,ig as bD,Xm as bE,Km as bF,Rv as bG,Nv as bH,Bv as bI,zv as bJ,Ov as bK,qy as bL,Zy as bM,jy as bN,Ir as bO,yw as bP,bw as bQ,dE as bR,mw as bS,Qm as bT,My as bU,eg as bV,Gr as bW,hw as bX,Mm as bY,jm as bZ,Pv as b_,pm as ba,mm as bb,Xs as bc,cm as bd,um as be,yh as bf,Sh as bg,Zm as bh,wr as bi,Jm as bj,Sr as bk,gr as bl,Fn as bm,ir as bn,xr as bo,og as bp,dr as bq,vn as br,sw as bs,ow as bt,ym as bu,nw as bv,Hy as bw,Qy as bx,Tv as by,Pa as bz,Hs as c,Sw as c0,zw as c1,cv as c2,Wy as c3,_m as c4,ag as c5,oE as c6,cE as c7,dg as c8,Iy as c9,Ay as ca,ug as cb,Sg as cc,$y as cd,Lv as ce,Cv as cf,pw as cg,Mv as ch,lg as ci,fg as cj,Bw as ck,kw as cl,Aw as cm,$v as cn,cg as co,Am as cp,$m as cq,Hm as cr,Uv as cs,Fv as ct,iE as cu,Fy as cv,Dy as cw,$w as cx,wm as cy,Cy as d,Ny as e,Iw as f,Ry as g,Uy as h,bm as i,Pw as j,Fw as k,aE as l,eE as m,Xv as n,sh as o,nE as p,Wd as q,Gs as r,gw as s,lh as t,Py as u,sE as v,Ly as w,Jr as x,jh as y,mh as z};
23
+ //# sourceMappingURL=chat-binding-DO5aGhPl.js.map