mppx 0.21.2 → 0.21.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,6 @@
1
1
  import * as Challenge from '../Challenge.js';
2
2
  import * as Constants from '../Constants.js';
3
+ import * as Errors from '../Errors.js';
3
4
  import * as Expires from '../Expires.js';
4
5
  import * as IdentityClient from '../identity/Client.js';
5
6
  import * as IdentityHeaders from '../identity/Headers.js';
@@ -85,12 +86,28 @@ export function create(config) {
85
86
  let challenge;
86
87
  let mi;
87
88
  try {
88
- let candidates = AcceptPayment.selectChallengeCandidates(challenges, methods, preferences, selectionContext);
89
+ let candidates;
90
+ let legacyError;
91
+ try {
92
+ candidates = AcceptPayment.selectChallengeCandidates(challenges, methods, preferences, selectionContext);
93
+ }
94
+ catch (error) {
95
+ // Only legacy-escaped offers passed the policy, but the deferred pass below may still
96
+ // find a clean offer the policy skipped.
97
+ if (!(error instanceof Errors.LegacyUnicodeEscapedChallengeError))
98
+ throw error;
99
+ if (selectionContext !== undefined)
100
+ throw error;
101
+ candidates = [];
102
+ legacyError = error;
103
+ }
89
104
  // Without a context yet, as in `preparePayment(response).createCredential(context)`, fall back
90
105
  // to offers a method skips only by policy: an explicit close may still use them, and the
91
106
  // method enforces the policy for anything else when the credential is created.
92
107
  if (candidates.length === 0 && selectionContext === undefined)
93
108
  candidates = AcceptPayment.selectChallengeCandidates(challenges, methods, preferences, AcceptPayment.deferredContext);
109
+ if (candidates.length === 0 && legacyError)
110
+ throw legacyError;
94
111
  const orderedCandidates = await resolveChallengeOrder(candidates, options?.orderChallenges ?? orderChallenges);
95
112
  const selected = orderedCandidates[0];
96
113
  if (!selected)
@@ -196,5 +196,13 @@ export declare function validateCredentialHeaderValue(credential: string): void;
196
196
  export declare function shouldInjectForPolicy(input: RequestInfo | URL, policy: NonNullable<from.Config['acceptPaymentPolicy']>): boolean;
197
197
  /** Counts the challenges in a 402's `WWW-Authenticate` header that list parsing skipped. */
198
198
  export declare function skippedChallengeCount(response: unknown): number;
199
+ /**
200
+ * Keys a payment retry by its Challenge. Not `Challenge.serialize`: an MCP Challenge carried as JSON
201
+ * may hold values a header can't, and its display-only `description` reads differently from a
202
+ * header (`\u2014` is the text `u2014`) than from JSON.
203
+ *
204
+ * @internal
205
+ */
206
+ export declare function retryKey(challenge: Challenge.Challenge): string;
199
207
  export {};
200
208
  //# sourceMappingURL=Fetch.d.ts.map
@@ -1,3 +1,4 @@
1
+ import { Json } from 'ox';
1
2
  import * as Challenge from '../../Challenge.js';
2
3
  import * as Constants from '../../Constants.js';
3
4
  import * as Credential from '../../Credential.js';
@@ -185,7 +186,7 @@ export function from(config) {
185
186
  const paymentInput = await resolvePaymentRetryInput(response, initialRequest.input, initialRequest.input, fetchInit);
186
187
  ProofRealm.assert(selectedChallenge, () => resolveRequestUrl(paymentInput), trustedTempoProofRealms);
187
188
  const previousCredential = preparedCredential;
188
- const key = Challenge.serialize(selectedChallenge);
189
+ const key = retryKey(selectedChallenge);
189
190
  const sameAttempt = previousCredential?.method === selected.method && previousCredential?.key === key;
190
191
  let canReusePrevious = false;
191
192
  if (previousCredential) {
@@ -931,4 +932,15 @@ export function skippedChallengeCount(response) {
931
932
  return 0;
932
933
  return Challenge.countUnsupportedCredentialHeaders(response.headers.get(Constants.Headers.wwwAuthenticate));
933
934
  }
935
+ /**
936
+ * Keys a payment retry by its Challenge. Not `Challenge.serialize`: an MCP Challenge carried as JSON
937
+ * may hold values a header can't, and its display-only `description` reads differently from a
938
+ * header (`\u2014` is the text `u2014`) than from JSON.
939
+ *
940
+ * @internal
941
+ */
942
+ export function retryKey(challenge) {
943
+ const { description: _description, ...rest } = challenge;
944
+ return Json.canonicalize(rest);
945
+ }
934
946
  //# sourceMappingURL=Fetch.js.map
@@ -1,4 +1,4 @@
1
- import type * as Challenge from '../Challenge.js';
1
+ import * as Challenge from '../Challenge.js';
2
2
  import type { MaybePromise } from './types.js';
3
3
  type MethodLike = {
4
4
  canHandleChallenge?: ((parameters: {
@@ -1,3 +1,4 @@
1
+ import * as Challenge from '../Challenge.js';
1
2
  import * as x402_ChallengeBrand from './x402/ChallengeBrand.js';
2
3
  /**
3
4
  * Selection context for flows that receive the credential context only after an offer is chosen,
@@ -90,7 +91,7 @@ export function selectChallengeCandidates(challenges, methods, preferences, cont
90
91
  else
91
92
  methodsByKey.set(key, [method]);
92
93
  }
93
- return challenges
94
+ const candidates = challenges
94
95
  .flatMap((challenge, index) => {
95
96
  const matchingMethods = methodsByKey.get(keyOf(challenge));
96
97
  if (!matchingMethods)
@@ -114,6 +115,12 @@ export function selectChallengeCandidates(challenges, methods, preferences, cont
114
115
  const { match: _match, ...rest } = candidate;
115
116
  return rest;
116
117
  });
118
+ // Skip offers a legacy server escaped as `\uXXXX`: paying one fails verification, possibly after
119
+ // funds moved. When only those remain, fail with the reason instead of "no method found".
120
+ const usable = candidates.filter(({ challenge }) => !Challenge.isLegacyUnicodeEscaped(challenge));
121
+ if (usable.length === 0 && candidates[0])
122
+ Challenge.assertNotLegacyUnicodeEscaped(candidates[0].challenge);
123
+ return usable;
117
124
  }
118
125
  /** Returns the canonical `method/intent` key for a method or challenge-like value. */
119
126
  export function keyOf(value) {
@@ -1,5 +1,5 @@
1
1
  /** Current mppx package version. */
2
- export declare const version = "0.21.2";
2
+ export declare const version = "0.21.3";
3
3
  /** Canonical SDK identifier for this mppx release. */
4
- export declare const sdkIdentifier = "mppx/0.21.2";
4
+ export declare const sdkIdentifier = "mppx/0.21.3";
5
5
  //# sourceMappingURL=version.d.ts.map
@@ -1,6 +1,6 @@
1
1
  // Generated by scripts/sync-version.ts.
2
2
  /** Current mppx package version. */
3
- export const version = '0.21.2';
3
+ export const version = '0.21.3';
4
4
  /** Canonical SDK identifier for this mppx release. */
5
5
  export const sdkIdentifier = `mppx/${version}`;
6
6
  //# sourceMappingURL=version.js.map
@@ -74,6 +74,16 @@ export function create(config) {
74
74
  }
75
75
  SecretKey.assert(secretKey);
76
76
  const methods = config.methods.flat();
77
+ // Fail at startup rather than on every 402: a challenge can't carry these values. MCP
78
+ // transports return the Challenge as JSON, so only a header-emitting transport needs the realm check.
79
+ for (const mi of methods)
80
+ Challenge.assertMethod(mi.name);
81
+ const emitsHeader = methods.some((mi) => {
82
+ const name = (mi.transport ?? transport).name;
83
+ return name !== 'mcp' && name !== 'mcp-sdk';
84
+ });
85
+ if (realm !== undefined && emitsHeader)
86
+ Challenge.assertRealm(realm);
77
87
  const serverEvents = createServerEventDispatcher();
78
88
  const handlers = {};
79
89
  const methodHandlers = new Map();
@@ -1,3 +1,3 @@
1
1
  // Generated — do not edit.
2
- export const html = "<script>(function(){var e=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(e){throw n=[e],e}},t=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),n=t((e=>{Object.defineProperty(e,\"__esModule\",{value:!0});function t(e){\"@babel/helpers - typeof\";return t=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},t(e)}var n=`dahlia`,r=function(e){return e===3?`v3`:e},i=`https://js.stripe.com`,a=`${i}/${n}/stripe.js`,o=/^https:\\/\\/js\\.stripe\\.com\\/v3\\/?(\\?.*)?$/,s=/^https:\\/\\/js\\.stripe\\.com\\/(v3|[a-z]+)\\/stripe\\.js(\\?.*)?$/,c=`loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used`,l=function(e){return o.test(e)||s.test(e)},u=function(){for(var e=document.querySelectorAll(`script[src^=\"${i}\"]`),t=0;t<e.length;t++){var n=e[t];if(l(n.src))return n}return null},d=function(e){var t=e&&!e.advancedFraudSignals?`?advancedFraudSignals=false`:``,n=document.createElement(`script`);n.src=`${a}${t}`;var r=document.head||document.body;if(!r)throw Error(`Expected document.body not to be null. Stripe.js requires a <body> element.`);return r.appendChild(n),n},f=function(e,t){!e||!e._registerWrapper||e._registerWrapper({name:`stripe-js`,version:`9.17.0`,startTime:t})},p=null,m=null,h=null,ee=function(e){return function(t){e(Error(`Failed to load Stripe.js`,{cause:t}))}},te=function(e,t){return function(){window.Stripe?e(window.Stripe):t(Error(`Stripe.js not available`))}},ne=function(e){return p===null?(p=new Promise(function(t,n){if(typeof window>`u`||typeof document>`u`){t(null);return}if(window.Stripe&&e&&console.warn(c),window.Stripe){t(window.Stripe);return}try{var r=u();if(r&&e)console.warn(c);else if(!r)r=d(e);else if(r&&h!==null&&m!==null){var i;r.removeEventListener(`load`,h),r.removeEventListener(`error`,m),(i=r.parentNode)==null||i.removeChild(r),r=d(e)}h=te(t,n),m=ee(n),r.addEventListener(`load`,h),r.addEventListener(`error`,m)}catch(e){n(e);return}}),p.catch(function(e){return p=null,Promise.reject(e)})):p},g=function(e,i,a){if(e===null)return null;var o=i[0];if(typeof o!=`string`)throw Error(`Expected publishable key to be of type string, got type ${t(o)} instead.`);var s=o.match(/^pk_test/),c=r(e.version),l=n;s&&c!==l&&console.warn(`Stripe.js@${c} was loaded on the page, but @stripe/stripe-js@9.17.0 expected Stripe.js@${l}. This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning`);var u=e.apply(void 0,i);return f(u,a),u},re=function(e){var n=`invalid load parameters; expected object of shape\n\n {advancedFraudSignals: boolean}\n\nbut received\n\n ${JSON.stringify(e)}\n`;if(e===null||t(e)!==`object`)throw Error(n);if(Object.keys(e).length===1&&typeof e.advancedFraudSignals==`boolean`)return e;throw Error(n)},_,v=!1,y=function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];v=!0;var r=Date.now();return ne(_).then(function(e){return g(e,t,r)})};y.setLoadParameters=function(e){if(v&&_){var t=re(e);if(Object.keys(t).reduce(function(t,n){return t&&e[n]===_?.[n]},!0))return}if(v)throw Error(`You cannot change load parameters after calling loadStripe`);_=re(e)},e.loadStripe=y})),r=t(((e,t)=>{t.exports=n()})),i,a=e((()=>{i={payment:`Payment`}})),o,s=e((()=>{o=`0.1.1`}));function c(){return o}var l=e((()=>{s()}));function u(e,t){return t?.(e)?e:e&&typeof e==`object`&&`cause`in e&&e.cause?u(e.cause,t):t?null:e}var d,f=e((()=>{l(),d=class e extends Error{static setStaticOptions(t){e.prototype.docsOrigin=t.docsOrigin,e.prototype.showVersion=t.showVersion,e.prototype.version=t.version}constructor(t,n={}){let r=(()=>{if(n.cause instanceof e){if(n.cause.details)return n.cause.details;if(n.cause.shortMessage)return n.cause.shortMessage}return n.cause&&`details`in n.cause&&typeof n.cause.details==`string`?n.cause.details:n.cause?.message?n.cause.message:n.details})(),i=n.cause instanceof e&&n.cause.docsPath||n.docsPath,a=n.docsOrigin??e.prototype.docsOrigin,o=`${a}${i??``}`,s=!!(n.version??e.prototype.showVersion),c=n.version??e.prototype.version,l=[t||`An error occurred.`,...n.metaMessages?[``,...n.metaMessages]:[],...r||i||s?[``,r?`Details: ${r}`:void 0,i?`See: ${o}`:void 0,s?`Version: ${c}`:void 0]:[]].filter(e=>typeof e==`string`).join(`\n`);super(l,n.cause?{cause:n.cause}:void 0),Object.defineProperty(this,\"details\",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,\"docs\",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,\"docsOrigin\",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,\"docsPath\",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,\"shortMessage\",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,\"showVersion\",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,\"version\",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,\"cause\",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,\"name\",{enumerable:!0,configurable:!0,writable:!0,value:`BaseError`}),this.cause=n.cause,this.details=r,this.docs=o,this.docsOrigin=a,this.docsPath=i,this.shortMessage=t,this.showVersion=s,this.version=c}walk(e){return u(this,e)}},Object.defineProperty(d,\"defaultStaticOptions\",{enumerable:!0,configurable:!0,writable:!0,value:{docsOrigin:`https://oxlib.sh`,showVersion:!1,version:`ox@${c()}`}}),d.setStaticOptions(d.defaultStaticOptions)}));function p(e,t){if(v(e)>t)throw new ie({givenSize:v(e),maxSize:t})}function m(e,t={}){let{dir:n,size:r=32}=t;if(r===0)return e;if(e.length>r)throw new ae({size:e.length,targetSize:r,type:`Bytes`});let i=new Uint8Array(r);for(let t=0;t<r;t++){let a=n===`right`;i[a?t:r-t-1]=e[a?t:e.length-t-1]}return i}var h=e((()=>{b()}));function ee(e){if(e===null||typeof e==`boolean`||typeof e==`string`)return JSON.stringify(e);if(typeof e==`number`){if(!Number.isFinite(e))throw TypeError(`Cannot canonicalize non-finite number`);return Object.is(e,-0)?`0`:JSON.stringify(e)}if(typeof e==`bigint`)throw TypeError(`Cannot canonicalize bigint`);if(Array.isArray(e))return`[${e.map(e=>ee(e)).join(`,`)}]`;if(typeof e==`object`)return`{${Object.keys(e).sort().reduce((t,n)=>{let r=e[n];return r!==void 0&&t.push(`${JSON.stringify(n)}:${ee(r)}`),t},[]).join(`,`)}}`}function te(e,t){return JSON.parse(e,(e,n)=>{let r=n;return typeof r==`string`&&r.endsWith(ne)?BigInt(r.slice(0,-9)):typeof t==`function`?t(e,r):r})}var ne,g=e((()=>{ne=`#__bigint`}));function re(e,t={}){let{size:n}=t,r=y.encode(e);return typeof n==`number`?(p(r,n),_(r,n)):r}function _(e,t){return m(e,{dir:`right`,size:t})}function v(e){return e.length}var y,ie,ae,b=e((()=>{f(),h(),g(),y=new TextEncoder,ie=class extends d{constructor({givenSize:e,maxSize:t}){super(`Size cannot exceed \\`${t}\\` bytes. Given size: \\`${e}\\` bytes.`),Object.defineProperty(this,\"name\",{enumerable:!0,configurable:!0,writable:!0,value:`Bytes.SizeOverflowError`})}},ae=class extends d{constructor({size:e,targetSize:t,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (\\`${e}\\`) exceeds padding size (\\`${t}\\`).`),Object.defineProperty(this,\"name\",{enumerable:!0,configurable:!0,writable:!0,value:`Bytes.SizeExceedsPaddingSizeError`})}}}));function oe(e,t={}){let{pad:n=!0,url:r=!1}=t,i=new Uint8Array(Math.ceil(e.length/3)*4);for(let t=0,n=0;n<e.length;t+=4,n+=3){let r=(e[n]<<16)+(e[n+1]<<8)+(e[n+2]|0);i[t]=x[r>>18],i[t+1]=x[r>>12&63],i[t+2]=x[r>>6&63],i[t+3]=x[r&63]}let a=e.length%3,o=Math.floor(e.length/3)*4+(a&&a+1),s=ce.decode(new Uint8Array(i.buffer,0,o));return n&&a===1&&(s+=`==`),n&&a===2&&(s+=`=`),r&&(s=s.replaceAll(`+`,`-`).replaceAll(`/`,`_`)),s}function se(e,t={}){return oe(re(e),t)}var ce,x,le=e((()=>{b(),ce=new TextDecoder,x=Object.fromEntries(Array.from(`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`).map((e,t)=>[t,e.charCodeAt(0)])),{...Object.fromEntries(Array.from(`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`).map((e,t)=>[e.charCodeAt(0),t]))}})),S=e((()=>{f(),b(),h(),g(),l(),le(),S()}));function ue(e){return se(ee(e),{pad:!1,url:!0})}var de=e((()=>{S()}));function fe(e,t){return typeof t==`bigint`?t.toString():t}function pe(e){return new Me(e)}function me(e){return e==null}function he(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function ge(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function _e(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ve(e){if(_e(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return _e(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function ye(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function C(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error(\"Cannot specify both `message` and `error` params\");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function be(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout===`optional`)}function w(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function xe(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function T(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function E(e){return typeof e==`string`?e:e?.message}function Se(e){let t=[];for(let n of e??[]){let e=n._zod.def;if(!/_(length|size)$|_equals$/.test(e.check))break;let r=e.maximum??e.length??e.size;r>=0&&t.push([r,n])}return t}function Ce(e,t,n){var r;for(let i=t;i<e.length;i++)(r=e[i]).schema??(r.schema=n)}function D(e,t,n){var r;let i=e.inst?._zod?.traits;i?.has(`$ZodType`)&&(i.has(`$ZodCheck`)?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);let a=e.schema===e.inst?void 0:e.schema?._zod.def?.error,o=e.message?e.message:E(e.inst?._zod.def?.error?.(e))??E(a?.(e))??E(t?.error?.(e))??E(n.customError?.(e))??E(n.localeError?.(e))??`Invalid input`,s={};for(let t of Object.keys(e))t!==`inst`&&t!==`schema`&&t!==`continue`&&t!==`input`&&t!==`__proto__`&&(s[t]=e[t]);return s.path??=[],s.message=o,t?.reportInput&&(s.input=e.input),s}function we(e){let t=e.length;if(!Pe.test(e))return t;let n=t;for(let r=0;r<t-1;r++)(e.charCodeAt(r)&64512)==55296&&(e.charCodeAt(r+1)&64512)==56320&&(n--,r++);return n}function Te(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function Ee(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}function De(e,t){for(let n in t){let r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):ke(e,n,r.value)}}function O(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function Oe(e,t,n){return O(e,t,n,!1)}function ke(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:O(this,t,n.bind(this))},set(e){O(this,t,e)}})}function Ae(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}function k(e,t,n){let r=Object.getPrototypeOf(e._zod);if(t in r&&Fe!==e._zod){Fe=void 0;return}Fe=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,Ie);let e=A;A=!1;try{let r=n(this);return A?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r}),A||=e,r}catch(n){throw delete this[t],A||=e,n}},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}})}function je(e,t,n,r){let i=Ae(e,t);i&&Object.defineProperty(i,t,{configurable:!0,get(){let e={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,e),e.value=n(this),Object.defineProperty(this,t,e),e.value},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:e})}})}var Me,Ne,Pe,Fe,A,Ie,j=e((()=>{Me=class{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;return e!==void 0&&(this._value=e(),this._getter=void 0),this._value}},Ne=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{},Pe=/[\\uD800-\\uDBFF]/,A=!1,Ie={configurable:!0,get(){A=!0}}}));function Le(e){let t=Be;if(t){let n=t.stackTraceLimit;if(typeof n==`number`){try{t.stackTraceLimit=0}catch{return Be=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function M(e,t,n,r){let i={};function a(e){this.def=e,this.constr=d,this.traits=new Set}a.prototype=i;let o=n,s=o&&new WeakSet;function c(n,r){if(!n._zod){ze.value=new a(r);try{Object.defineProperty(n,\"_zod\",ze)}finally{ze.value=void 0}}else if(n._zod.traits.has(e))return;if(n._zod.traits.add(e),t(n,r),s){let e=Object.getPrototypeOf(n),t=n._zod.constr.prototype,r=e;for(;r&&r!==t;)r=Object.getPrototypeOf(r);let i=r??e;s.has(i)||(s.add(i),De(i,o))}let i=d.prototype;for(let e in i)Object.prototype.hasOwnProperty.call(i,e)&&(e in n||(n[e]=i[e].bind(n)))}let l=r?.Parent??Object;class u extends l{}Object.defineProperty(u,\"name\",{value:e});function d(e){let t=r?.Parent?Le(u):this;c(t,e);let n=t._zod.deferred;if(n){for(let e of n)e();t._zod.deferred=void 0}let i=globalThis.__zod_globalConfig?.postProcessor;return i&&i(t),t}return Object.defineProperty(d,\"init\",{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:t=>r?.Parent&&t instanceof r.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(d,\"name\",{value:e}),d}function N(e){return e&&Object.assign(F,e),F}var Re,ze,Be,P,Ve,F,I=e((()=>{j(),ze={value:void 0,enumerable:!1},Be=`captureStackTrace`in Error?Error:null,P=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},Ve=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}},(Re=globalThis).__zod_globalConfig??(Re.__zod_globalConfig={}),F=globalThis.__zod_globalConfig}));function He(){let e=this._zod;return e.message??=JSON.stringify(e.def,fe,2),e.message}function Ue(e){this._zod.message=e}var We,L,Ge,Ke,R,qe=e((()=>{I(),j(),We={get:He,set:Ue,enumerable:!0,configurable:!0},L={value:void 0,enumerable:!1},Ge=new WeakSet([Object.prototype,Error.prototype]),Ke=(e,t)=>{e.name=`$ZodError`,L.value=t,Object.defineProperty(e,\"issues\",L),L.value=void 0,Object.defineProperty(e,\"message\",We);let n=Object.getPrototypeOf(e);Ge.has(n)||(Ge.add(n),Object.defineProperty(n,\"toString\",{configurable:!0,enumerable:!1,get(){let e=()=>this.message;return Object.defineProperty(this,\"toString\",{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,\"toString\",{value:e,configurable:!0,writable:!0})}}))},M(`$ZodError`,Ke),R=M(`$ZodError`,Ke,void 0,{Parent:Error})}));function Je(e,t,n){let r;return{success:!1,get error(){return r||(r=new e(t.map(e=>D(e,n,N()))),t=void 0,n=void 0),r},set error(e){r=e,t=void 0,n=void 0}}}var Ye,Xe,Ze,Qe,$e,et,tt,nt,rt=e((()=>{I(),qe(),j(),Ye=e=>{let t=(n,r,i,a)=>{let o=i?{...i,async:!1}:{async:!1},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new P;if(s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>D(e,o,N())));throw Ne(n,a?.callee??t),n}return s.value};return t},Xe=Ye(R),Ze=e=>{let t=async(n,r,i,a)=>{let o=i?{...i,async:!0}:{async:!0},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise&&(s=await s),s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>D(e,o,N())));throw Ne(n,a?.callee??t),n}return s.value};return t},Qe=Ze(R),$e=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new P;return a.issues.length?Je(e,a.issues,i):{success:!0,data:a.value}},et=$e(R),tt=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?Je(e,a.issues,i):{success:!0,data:a.value}},nt=tt(R)})),it,at,ot=e((()=>{it=/^[\\s\\S]{0,}$/,at=/^-?\\d+(?:\\.\\d+)?$/})),z,st,ct,lt,ut,dt=e((()=>{I(),j(),z=M(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),st=e=>{let t=e.value;return!me(t)&&t.length!==void 0},ct=M(`$ZodCheckMinLength`,(e,t)=>{var n;z.init(e,t),(n=e._zod.def).when??(n.when=st),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>=t.minimum&&i<t.minimum*2?we(r):i)>=t.minimum)return;let a=Te(r);n.issues.push({origin:a,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),lt=M(`$ZodCheckStringFormat`,(e,t)=>{var n,r;z.init(e,t),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),ut=M(`$ZodCheckRegex`,(e,t)=>{lt.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})}})})),ft=e((()=>{})),pt,mt=e((()=>{pt={major:4,minor:6,patch:7}}));async function ht(e,t){let n={async:!0};return wt(await e._zod.run({value:t,issues:[]},n),n)}function gt(e){return{validate:t=>{let n={async:!1};try{let r=e._zod.run({value:t,issues:[]},n);if(!(r instanceof Promise))return wt(r,n)}catch{}return ht(e,t)},vendor:`zod`,version:1}}function _t(e,t){let n=Se(e._zod.def.checks);if(!n.length)return;let r=Math.min(...n.map(e=>e[0])),i=e._zod.parse;e._zod.parse=(n,a)=>{let o=t(n.value);if(o>r&&!a?.skipChecks&&a?.direction!==`backward`){for(let[t,r]of Se(e._zod.def.checks))if(o>t&&r._zod.def.when(n)){let t=n.issues.length;return r._zod.check(n),n.issues[t].continue=!1,Ce(n.issues,t,e),n}}return i(n,a)}}function vt(e,t,n){e.issues.length&&t.issues.push(...T(n,e.issues)),t.value[n]=e.value}function B(e,t,n,r,i,a){let o=n in r,s=a===`optional`;if(!(!o&&s&&i===`optional`)){if(e.issues.length){if(i!==void 0&&s&&!o)return;t.issues.push(...T(n,e.issues))}if(!o&&i===void 0){e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]});return}e.value===void 0?(o||i===`defaulted`&&!s)&&(t.value[n]=void 0):t.value[n]=e.value}}function yt(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:kt,i=r.length?[...t,...r]:t;for(let t of i)if(!e.shape?.[t]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key \"${String(t)}\": expected a Zod schema`);let a=be(e.shape);return{...e,allKeys:i,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(a)}}function bt(e,t,n,r,i,a,o){let s=[],c=i.keySet,l=i.catchall._zod,u=l.def.type,d=l.optin,f=l.optout,p=0;for(let i in t){if(o&&n.issues.length!==p){if(w(n,p))break;p=n.issues.length}if(c.has(i))continue;if(i===`__proto__`){u===`never`&&s.push(i);continue}if(u===`never`){s.push(i);continue}let a=l.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>B(e,n,i,t,d,f))):B(a,n,i,t,d,f)}return s.length&&n.issues.push({code:`unrecognized_keys`,keys:s,input:t,inst:a,continue:!0}),e.length?Promise.all(e).then(()=>n):n}function xt(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!w(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>D(e,r,N())))}),t)}function St(e,t){return e.value=t.issues.length?void 0:t.value,e}function V(e,t,n){return e.issues.some(e=>e.code!==`unrecognized_keys`)?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}function Ct(e,t,n,r){if(!e){let 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(Ee(e))}}var H,wt,Tt,Et,Dt,Ot,kt,At,jt,Mt,Nt,Pt,Ft,It,Lt=e((()=>{dt(),I(),ot(),j(),mt(),H=M(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=pt;let r=e._zod.def.checks,i=e._zod.traits.has(`$ZodCheck`)?[e,...r??[]]:r?.length?[...r]:[];for(let t of i)for(let n of t._zod.onattach)n(e);if(i.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(t,n,r)=>{if(t.memo)return t;let i=w(t),a;for(let o of n){if(o._zod.def.when){if(xe(t)||!o._zod.def.when(t))continue}else if(i)continue;let n=t.issues.length,s=o._zod.check(t);if(s instanceof Promise&&r?.async===!1)throw new P;if(a||s instanceof Promise)a=(a??Promise.resolve()).then(async()=>{await s,t.issues.length!==n&&(Ce(t.issues,n,e),i||=w(t,n))});else{if(t.issues.length===n)continue;Ce(t.issues,n,e),i||=w(t,n)}}return a?a.then(()=>t):t},n=(n,r,a)=>{if(w(n))return n.aborted=!0,n;let o=t(r,i,a);if(o instanceof Promise){if(a.async===!1)throw new P;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(r,a)=>{if(a.skipChecks)return e._zod.parse(r,a);if(a.direction===`backward`){let t=e._zod.parse({value:r.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,r,a)):n(t,r,a)}let o=e._zod.parse(r,a);if(o instanceof Promise){if(a.async===!1)throw new P;return o.then(e=>t(e,i,a))}return t(o,i,a)}}},{get\"~standard\"(){return Oe(this,`~standard`,gt(this))},set\"~standard\"(e){O(this,`~standard`,e)}}),wt=(e,t)=>e.issues.length?{issues:e.issues.map(e=>D(e,t,N()))}:{value:e.value},Tt=M(`$ZodString`,(e,t)=>{H.init(e,t),e._zod.pattern=t.pattern??it,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),Et=M(`$ZodNumber`,(e,t)=>{H.init(e,t),e._zod.pattern=at,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:String(i):void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),Dt=e=>Array.isArray(e)?e.length:-1,Ot=M(`$ZodArray`,(e,t)=>{H.init(e,t);let n=F.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!Array.isArray(a))return r.issues.push({expected:`array`,code:`invalid_type`,input:a,inst:e}),r;r.value=n?n.alloc(e,r,Array(a.length),i):Array(a.length);let o=[],s=i?.abortEarly;for(let e=0;e<a.length;e++){let n=a[e],c=t.element._zod.run({value:n,issues:[]},i);if(c instanceof Promise)o.push(c.then(t=>vt(t,r,e)));else if(vt(c,r,e),s&&c.issues.length!==0&&w(c))break}return o.length?Promise.all(o).then(()=>r):r},_t(e,Dt)}),kt=[],At=M(`$ZodObject`,(e,t)=>{H.init(e,t);let n=Object.getOwnPropertyDescriptor(t,`shape`),r=n?.get?n.get.raw:t.shape??{};if(r){let e=()=>{let n={...r};return Object.defineProperty(t,\"shape\",{value:n}),e.raw=n,n};e.raw=r,Object.defineProperty(t,\"shape\",{get:e})}let i=pe(()=>yt(t));k(e,`propValues`,e=>{let t=e.def.shape,n={};for(let e in t){let r=t[e]._zod;if(r.values){Object.prototype.hasOwnProperty.call(n,e)||ge(n,e,new Set);for(let t of r.values)n[e].add(t);r.optin!==void 0&&n[e].add(void 0)}}return n});let a=_e,o=t.catchall,s,c=F.memoizer;c?.attach(e),e._zod.parse=(t,n)=>{s??=i.value;let r=t.value;if(!a(r))return t.issues.push({expected:`object`,code:`invalid_type`,input:r,inst:e}),t;t.value=c?c.alloc(e,t,{},n):{};let l=[],u=s.shape,d=n?.abortEarly,f=t.issues.length;for(let e of s.allKeys){if(d&&t.issues.length!==f){if(w(t,f))break;f=t.issues.length}if(e===`__proto__`)continue;let i=u[e],a=i._zod.optin,o=i._zod.optout,s=i._zod.run({value:r[e],issues:[]},n);s instanceof Promise?l.push(s.then(n=>B(n,t,e,r,a,o))):B(s,t,e,r,a,o)}return o?bt(l,r,t,n,i.value,e,d===!0):l.length?Promise.all(l).then(()=>t):t}}),jt=M(`$ZodUnion`,(e,t)=>{H.init(e,t),k(e,`optin`,e=>e.def.options.some(e=>e._zod.optin===`defaulted`)?`defaulted`:e.def.options.some(e=>e._zod.optin!==void 0)?`optional`:void 0),k(e,`optout`,e=>e.def.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),k(e,`values`,e=>{if(e.def.options.every(e=>e._zod.values))return new Set(e.def.options.flatMap(e=>Array.from(e._zod.values)))}),k(e,`pattern`,e=>{if(e.def.options.every(e=>e._zod.pattern)){let t=e.def.options.map(e=>e._zod.pattern);return RegExp(`^(${t.map(e=>he(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>xt(t,r,e,i)):xt(o,r,e,i)}}),Mt=M(`$ZodRecord`,(e,t)=>{H.init(e,t);let n=F.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!ve(a))return r.issues.push({expected:`record`,code:`invalid_type`,input:a,inst:e}),r;let o=[],s=t.keyType._zod.values;if(s&&!t.partial){r.value=n?n.alloc(e,r,{},i):{};let c=new Set;for(let n of s)if(typeof n==`string`||typeof n==`number`||typeof n==`symbol`){if(c.add(typeof n==`number`?n.toString():n),n===`__proto__`)continue;let s=t.keyType._zod.run({value:n,issues:[]},i);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(s.issues.length){r.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>D(e,i,N())),input:n,path:[n],inst:e});continue}let l=s.value;if(l===`__proto__`)continue;let u=t.valueType._zod.run({value:a[n],issues:[]},i);u instanceof Promise?o.push(u.then(e=>{e.issues.length&&r.issues.push(...T(n,e.issues)),r.value[l]=e.value})):(u.issues.length&&r.issues.push(...T(n,u.issues)),r.value[l]=u.value)}let l;for(let e in a)if(!c.has(e)){if(t.mode===`loose`){if(e===`__proto__`)continue;r.value[e]=a[e]}else l??=[],l.push(e)}l&&l.length>0&&r.issues.push({code:`unrecognized_keys`,input:a,inst:e,keys:l,continue:!0})}else{r.value=n?n.alloc(e,r,{},i):{};let c;for(let n of Reflect.ownKeys(a)){if(n===`__proto__`||!Object.prototype.propertyIsEnumerable.call(a,n))continue;let l=t.keyType._zod.run({value:n,issues:[]},i);if(l instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof n==`string`&&at.test(n)&&l.issues.length){let e=t.keyType._zod.run({value:Number(n),issues:[]},i);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(l=e)}if(l.issues.length){t.mode===`loose`?r.value[n]=a[n]:s?(c??=[],c.push(n)):r.issues.push({code:`invalid_key`,origin:`record`,issues:l.issues.map(e=>D(e,i,N())),input:n,path:[n],inst:e});continue}let u=l.value;if(u===`__proto__`)continue;let d=t.valueType._zod.run({value:a[n],issues:[]},i);d instanceof Promise?o.push(d.then(e=>{e.issues.length&&r.issues.push(...T(n,e.issues)),r.value[u]=e.value})):(d.issues.length&&r.issues.push(...T(n,d.issues)),r.value[u]=d.value)}c&&c.length>0&&r.issues.push({code:`unrecognized_keys`,input:a,inst:e,keys:c,continue:!0})}return o.length?Promise.all(o).then(()=>r):r}}),Nt=M(`$ZodTransform`,(e,t)=>{H.init(e,t),e._zod.optin=`optional`,F.memoizer?.guard(e),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Ve(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n));if(i instanceof Promise)throw new P;return n.value=i,n}}),Pt=M(`$ZodOptional`,(e,t)=>{H.init(e,t),k(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),e._zod.optout=`optional`,k(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t,void 0]):void 0}),k(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${he(t.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(e.value===void 0){if(t.innerType._zod.optin!==`defaulted`)return e;let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(t=>St(e,t)):St(e,r)}return t.innerType._zod.run(e,n)}}),Ft=M(`$ZodPipe`,(e,t)=>{H.init(e,t),k(e,`values`,e=>e.def.in._zod.values),k(e,`optin`,e=>e.def.in._zod.optin),k(e,`optout`,e=>e.def.out._zod.optout),k(e,`propValues`,e=>e.def.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>V(e,t.in,n)):V(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>V(e,t.out,n)):V(r,t.out,n)}}),It=M(`$ZodCustom`,(e,t)=>{z.init(e,t),H.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>Ct(t,n,r,e));Ct(i,n,r,e)}})})),Rt=e((()=>{})),zt=e((()=>{globalThis.__zod_globalRegistry})),Bt=e((()=>{}));function Vt(e){return e.checks&&=[...e.checks],e}function Ht(e,t){return new e(Vt({type:`string`,...C(t)}))}function Ut(e,t){return new e(Vt({type:`number`,checks:[],...C(t)}))}function U(e,t){return new ct({check:`min_length`,...C(t),minimum:e})}function Wt(e,t){return new ut({check:`string_format`,format:`regex`,...C(t),pattern:e})}function Gt(e,t,n){let r=C(n);return r.abort??=!0,new e({type:`custom`,check:`custom`,fn:t,...r})}var Kt=e((()=>{dt(),j()})),qt=e((()=>{})),W=e((()=>{I(),rt(),qe(),Lt(),Rt(),dt(),mt(),j(),ot(),zt(),ft(),Bt(),Kt(),qt(),Lt(),qt()})),Jt=e((()=>{W()}));function G(e){return Ht(nn,e)}function Yt(e){return Ut(rn,e)}function Xt(e,t){return new an({type:`array`,element:e,...C(t)})}function K(e,t){let n={type:`object`,shape:e??{},...C(t)};return new on(n)}function Zt(e,t){return new sn({type:`union`,options:e,...C(t)})}function Qt(e,t,n){return!t||!t._zod?new cn({type:`record`,keyType:G(),valueType:e,...C(t)}):new cn({type:`record`,keyType:e,valueType:t,...C(n)})}function $t(e){return new ln({type:`transform`,transform:e})}function q(e){return new un({type:`optional`,innerType:e})}function en(e,t){return new dn({type:`pipe`,in:e,out:t})}function tn(e,t){return Gt(fn,e??(()=>!0),t)}var J,nn,rn,an,on,sn,cn,ln,un,dn,fn,pn=e((()=>{W(),j(),Jt(),J=M(`ZodMiniType`,(e,t)=>{if(!e._zod)throw Error(`Uninitialized schema in ZodMiniType.`);H.init(e,t),e.def=t,e.type=t.type},{get with(){return this.check},set with(e){O(this,`with`,e)},parse(e,t){return Xe(this,e,t,{callee:this.parse})},parseAsync(e,t){return Qe(this,e,t,{callee:this.parseAsync})},safeParse(e,t){return et(this,e,t)},safeParseAsync(e,t){return nt(this,e,t)},check(...e){let t=this.def;return this.clone({...t,checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]},{parent:!0})},clone(e,t){return ye(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},apply(e,...t){return t.length===0?e(this):e(this,...t)}}),nn=M(`ZodMiniString`,(e,t)=>{Tt.init(e,t),J.init(e,t)}),rn=M(`ZodMiniNumber`,(e,t)=>{Et.init(e,t),J.init(e,t)}),an=M(`ZodMiniArray`,(e,t)=>{Ot.init(e,t),J.init(e,t)}),on=M(`ZodMiniObject`,(e,t)=>{At.init(e,t),J.init(e,t),je(e,`shape`,e=>e._zod.def.shape,!1)}),sn=M(`ZodMiniUnion`,(e,t)=>{jt.init(e,t),J.init(e,t)}),cn=M(`ZodMiniRecord`,(e,t)=>{Mt.init(e,t),J.init(e,t)}),ln=M(`ZodMiniTransform`,(e,t)=>{Nt.init(e,t),J.init(e,t)}),un=M(`ZodMiniOptional`,(e,t)=>{Pt.init(e,t),J.init(e,t)}),dn=M(`ZodMiniPipe`,(e,t)=>{Ft.init(e,t),J.init(e,t)}),fn=M(`ZodMiniCustom`,(e,t)=>{It.init(e,t),J.init(e,t)})})),mn=e((()=>{W()})),hn=e((()=>{W(),Jt(),pn(),mn(),Lt(),j(),pn(),ot(),qt()})),gn=e((()=>{hn()}));function _n(){return G().check(Wt(/^\\d+(\\.\\d+)?$/,`Invalid amount`))}var Y=e((()=>{gn(),gn()}));function vn(e){let{meta:t,opaque:n,request:r,...a}=e.challenge,o=n??(t===void 0?void 0:ue(t)),s={challenge:{...a,...o!==void 0&&{opaque:o},request:ue(r)},payload:e.payload,...e.source&&{source:e.source}},c=se(JSON.stringify(s),{pad:!1,url:!0});return`${i.payment} ${c}`}var X=e((()=>{S(),a(),de()})),yn=e((()=>{a(),S(),de(),Y(),X()}));function bn(e){return e}function xn(e,t){let{canHandleChallenge:n,context:r,createCredential:i}=t;return{...e,canHandleChallenge:n,context:r,createCredential:i}}var Sn=e((()=>{}));function Cn(e,t){if(!Number.isInteger(t)||t<0)throw RangeError(`Decimals must be a non-negative integer.`);if(!/^-?(?:\\d+(?:\\.\\d*)?|\\.\\d+)$/.test(e))throw TypeError(`Value \\`${e}\\` is not a valid decimal number.`);let n=e.startsWith(`-`),[r=`0`,i=``]=(n?e.slice(1):e).split(`.`),a=i.slice(0,t).padEnd(t,`0`),o=BigInt(`${r||`0`}${a}`);return i.length>t&&i[t]>=`5`&&(o+=1n),n?-o:o}var wn=e((()=>{})),Tn,En,Dn,On=e((()=>{Y(),Tn=K({customer:q(G().check(U(1))),hooks:q(K({inputs:K({tax:K({calculation:G().check(U(1))})})})),metadata:q(Qt(G(),G())),receipt_email:q(G().check(U(1)))}),En=tn(e=>typeof e==`function`),Dn=Zt([Tn,En])})),kn,An=e((()=>{Sn(),Y(),wn(),On(),kn=bn({name:`stripe`,intent:`charge`,schema:{credential:{payload:K({externalId:q(G()),spt:G()})},request:en(K({amount:_n(),currency:G(),decimals:Yt(),description:q(G()),externalId:q(G()),metadata:q(Qt(G(),G())),networkId:G(),paymentIntentOptions:q(Dn),paymentMethodTypes:Xt(G()).check(U(1)),recipient:q(G())}),$t(({amount:e,decimals:t,metadata:n,networkId:r,paymentIntentOptions:i,paymentMethodTypes:a,...o})=>({...o,amount:Cn(e,t).toString(),methodDetails:{networkId:r,paymentMethodTypes:a,...n!==void 0&&{metadata:n}}})))}})}));function jn(e){let{client:t,createToken:n,externalId:r,paymentMethod:i}=e;return xn(kn,{context:K({paymentMethod:q(G())}),async createCredential({challenge:e,context:a}){let o=a?.paymentMethod??i;if(!o)throw Error(`paymentMethod is required (pass via context or parameters)`);let s=e.request.amount,c=e.request.currency,l=typeof e.request.externalId==`string`?e.request.externalId:void 0,u=e.request.methodDetails?.networkId;if(!u)throw Error(`networkId is required in challenge.methodDetails`);let d=e.request.methodDetails?.metadata;if(d?.externalId)throw Error(`methodDetails.metadata.externalId is reserved; use credential externalId instead`);let f=e.expires?Math.floor(new Date(e.expires).getTime()/1e3):Math.floor(Date.now()/1e3)+3600,p=await n({amount:s,challenge:e,client:t,currency:c,expiresAt:f,metadata:d,networkId:u,paymentMethod:o}),m=l??r;return vn({challenge:e,payload:{spt:p,...m===void 0?{}:{externalId:m}}})}})}var Mn=e((()=>{X(),Sn(),Y(),An()}));function Nn(e){return[jn(e)]}var Pn=e((()=>{Mn(),(function(e){e.charge=jn})(Nn||={})})),Fn=e((()=>{Mn(),Pn()})),In=e((()=>{b(),f(),h(),g(),le(),l(),X(),Sn(),S(),Y(),de(),Fn(),Ln(),a()})),Ln=e((()=>{yn(),In(),b(),f(),h(),g(),le(),l(),S(),Ln(),X(),de(),Sn(),Y(),a()})),Rn=r();Ln();let zn={data:`__MPPX_DATA__`,error:`root_error`,root:`root`},Bn={serviceWorker:`__mppx_worker`,tab:`__mppx_tab`},Vn={challengeId:`data-mppx-challenge-id`,remaining:`data-remaining`};var Z=class{name;constructor(e){this.name=`--mppx-${e}`}toString(){return`var(${this.name})`}};let Hn={accent:new Z(`accent`),background:new Z(`background`),border:new Z(`border`),foreground:new Z(`foreground`),muted:new Z(`muted`),negative:new Z(`negative`),positive:new Z(`positive`),surface:new Z(`surface`),fontFamily:new Z(`font-family`),fontSizeBase:new Z(`font-size-base`),radius:new Z(`radius`),spacingUnit:new Z(`spacing-unit`)};String.raw`<style>\n *,\n ::after,\n ::before,\n ::backdrop,\n ::file-selector-button {\n box-sizing: border-box;\n margin: 0;\n padding: 0;\n border: 0 solid;\n border-color: ${Hn.border};\n }\n html,\n :host {\n line-height: 1.5;\n -webkit-text-size-adjust: 100%;\n tab-size: 4;\n -webkit-tap-highlight-color: transparent;\n }\n h1,\n h2,\n h3,\n h4,\n h5,\n h6 {\n font-size: inherit;\n font-weight: inherit;\n }\n a {\n color: inherit;\n -webkit-text-decoration: inherit;\n text-decoration: inherit;\n }\n b,\n strong {\n font-weight: bolder;\n }\n code,\n kbd,\n samp,\n pre {\n font-family:\n ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New',\n monospace;\n font-size: 1em;\n }\n small {\n font-size: 80%;\n }\n ol,\n ul,\n menu {\n list-style: none;\n }\n img,\n svg,\n video,\n canvas,\n audio,\n iframe,\n embed,\n object {\n display: block;\n vertical-align: middle;\n }\n img,\n video {\n max-width: 100%;\n height: auto;\n }\n button,\n input,\n select,\n optgroup,\n textarea,\n ::file-selector-button {\n font: inherit;\n font-feature-settings: inherit;\n font-variation-settings: inherit;\n letter-spacing: inherit;\n color: inherit;\n border-radius: 0;\n background-color: transparent;\n opacity: 1;\n }\n ::file-selector-button {\n margin-inline-end: 4px;\n }\n ::placeholder {\n opacity: 1;\n }\n @supports (not (-webkit-appearance: -apple-pay-button)) or (contain-intrinsic-size: 1px) {\n ::placeholder {\n color: color-mix(in oklab, currentcolor 50%, transparent);\n }\n }\n textarea {\n resize: vertical;\n }\n ::-webkit-search-decoration {\n -webkit-appearance: none;\n }\n :-moz-ui-invalid {\n box-shadow: none;\n }\n button,\n input:where([type='button'], [type='reset'], [type='submit']),\n ::file-selector-button {\n appearance: button;\n }\n ::-webkit-inner-spin-button,\n ::-webkit-outer-spin-button {\n height: auto;\n }\n [hidden]:where(:not([hidden='until-found'])) {\n display: none !important;\n }\n</style>`;function Un(e,t){if(t==null)return e;if(!Wn(e)||!Wn(t))return t??e;let n={...e};for(let[e,r]of Object.entries(t)){if(r==null||r===``)continue;let t=n[e];n[e]=Wn(t)&&Wn(r)?Un(t,r):r}return n}function Wn(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}async function Gn(e,t=`Authorization`){let n=new URL(location.href);n.searchParams.set(Bn.serviceWorker,``);let r=await navigator.serviceWorker.register(n.pathname+n.search),i=await new Promise(e=>{let t=r.installing??r.waiting??r.active;if(t?.state===`activated`)return e(t);let n=t??r;n.addEventListener(`statechange`,function t(){let i=r.active;i?.state===`activated`&&(n.removeEventListener(`statechange`,t),e(i))})});await new Promise(n=>{let r=new MessageChannel;r.port1.onmessage=()=>n(),i.postMessage({credential:e,header:t},[r.port2])}),location.reload()}S();function Kn(e){let t=document.getElementById(zn.data),n=te(t.textContent),r=t.getAttribute(Vn.remaining);!r||Number(r)<=1?t.remove():t.setAttribute(Vn.remaining,String(Number(r)-1));let i=document.currentScript,a=i?.getAttribute(Vn.challengeId),o=a?(i.removeAttribute(Vn.challengeId),n[a]):Object.values(n).find(t=>t.challenge.method===e);return{...o,error(e){if(!e){document.getElementById(zn.error)?.remove();return}let t=document.getElementById(zn.error);if(t){t.textContent=e;return}let n=document.createElement(`p`);n.id=zn.error,n.className=`mppx-error`,n.role=`alert`,n.textContent=e,document.getElementById(o.rootId)?.after(n)},root:document.getElementById(o.rootId),submit:e=>Gn(e,o.challenge.header),vars:Hn}}let Q=Kn(`stripe`),$=Q.config.elements,qn=String.raw,Jn=document.createElement(`style`);Jn.textContent=qn`\n form {\n display: flex;\n flex-direction: column;\n gap: calc(${Q.vars.spacingUnit} * 8);\n }\n button {\n background: ${Q.vars.accent};\n border-radius: ${Q.vars.radius};\n color: ${Q.vars.background};\n cursor: pointer;\n font-weight: 500;\n padding: calc(${Q.vars.spacingUnit} * 4) calc(${Q.vars.spacingUnit} * 8);\n width: 100%;\n }\n button:hover:not(:disabled) {\n opacity: 0.85;\n }\n button:disabled {\n cursor: default;\n opacity: 0.5;\n }\n`,Q.root.append(Jn),(async()=>{let e=await(0,Rn.loadStripe)(Q.config.publishableKey);if(!e)throw Error(`Failed to loadStripe`);let t=window.matchMedia(`(prefers-color-scheme: dark)`),n=()=>{let e=(()=>{if($?.options?.appearance?.theme)return $?.options?.appearance?.theme;switch(Q.theme.colorScheme){case`light dark`:return t.matches?`night`:`stripe`;case`light`:return`stripe`;case`dark`:return`night`}})(),n=+!!t.matches;return Un({disableAnimations:!0,theme:e,variables:{borderRadius:Q.theme.radius,colorBackground:Q.theme.surface[n],colorDanger:Q.theme.negative[n],colorPrimary:Q.theme.accent[n],colorText:Q.theme.foreground[n],colorTextSecondary:Q.theme.muted[n],fontSizeBase:Q.theme.fontSizeBase,fontFamily:Q.theme.fontFamily,spacingUnit:Q.theme.spacingUnit}},$?.options?.appearance??{})},r=e.elements({appearance:n(),...$?.options,amount:Number(Q.challenge.request.amount),currency:Q.challenge.request.currency,mode:`payment`,paymentMethodCreation:`manual`,paymentMethodTypes:Q.challenge.request.methodDetails.paymentMethodTypes});t.addEventListener(`change`,()=>{r.update({appearance:n()})});let i=document.createElement(`form`);r.create(`payment`,$?.paymentOptions).mount(i),Q.root.appendChild(i);let a=document.createElement(`button`);a.textContent=Q.text.pay,a.type=`submit`,i.appendChild(a),i.onsubmit=async t=>{t.preventDefault(),Q.error(),a.disabled=!0;try{await r.submit();let{paymentMethod:t,error:n}=await e.createPaymentMethod({...$?.createPaymentMethodOptions,elements:r});if(n||!t)throw n??Error(`Failed to create payment method`);let i=await Nn({client:e,createToken:Yn})[0].createCredential({challenge:Q.challenge,context:{paymentMethod:t.id}});await Q.submit(i)}catch(e){Q.error(e instanceof Error?e.message:`Payment failed`)}finally{a.disabled=!1}}})();async function Yn(e){let t=new URL(Q.config.createTokenUrl,location.origin);if(t.origin!==location.origin)throw Error(`createTokenUrl must be same-origin`);let n=await fetch(t,{method:`POST`,headers:{\"Content-Type\":`application/json`},body:JSON.stringify(e)});if(!n.ok){let e=await n.text().catch(()=>`<response body unavailable>`);throw Error(`Failed to create SPT (${n.status}): ${e}`)}return(await n.json()).spt}})();</script>";
2
+ export const html = "<script>(function(){var e=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(e){throw n=[e],e}},t=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),n=t((e=>{Object.defineProperty(e,\"__esModule\",{value:!0});function t(e){\"@babel/helpers - typeof\";return t=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},t(e)}var n=`dahlia`,r=function(e){return e===3?`v3`:e},i=`https://js.stripe.com`,a=`${i}/${n}/stripe.js`,o=/^https:\\/\\/js\\.stripe\\.com\\/v3\\/?(\\?.*)?$/,s=/^https:\\/\\/js\\.stripe\\.com\\/(v3|[a-z]+)\\/stripe\\.js(\\?.*)?$/,c=`loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used`,l=function(e){return o.test(e)||s.test(e)},u=function(){for(var e=document.querySelectorAll(`script[src^=\"${i}\"]`),t=0;t<e.length;t++){var n=e[t];if(l(n.src))return n}return null},d=function(e){var t=e&&!e.advancedFraudSignals?`?advancedFraudSignals=false`:``,n=document.createElement(`script`);n.src=`${a}${t}`;var r=document.head||document.body;if(!r)throw Error(`Expected document.body not to be null. Stripe.js requires a <body> element.`);return r.appendChild(n),n},f=function(e,t){!e||!e._registerWrapper||e._registerWrapper({name:`stripe-js`,version:`9.17.0`,startTime:t})},p=null,m=null,h=null,ee=function(e){return function(t){e(Error(`Failed to load Stripe.js`,{cause:t}))}},g=function(e,t){return function(){window.Stripe?e(window.Stripe):t(Error(`Stripe.js not available`))}},_=function(e){return p===null?(p=new Promise(function(t,n){if(typeof window>`u`||typeof document>`u`){t(null);return}if(window.Stripe&&e&&console.warn(c),window.Stripe){t(window.Stripe);return}try{var r=u();if(r&&e)console.warn(c);else if(!r)r=d(e);else if(r&&h!==null&&m!==null){var i;r.removeEventListener(`load`,h),r.removeEventListener(`error`,m),(i=r.parentNode)==null||i.removeChild(r),r=d(e)}h=g(t,n),m=ee(n),r.addEventListener(`load`,h),r.addEventListener(`error`,m)}catch(e){n(e);return}}),p.catch(function(e){return p=null,Promise.reject(e)})):p},te=function(e,i,a){if(e===null)return null;var o=i[0];if(typeof o!=`string`)throw Error(`Expected publishable key to be of type string, got type ${t(o)} instead.`);var s=o.match(/^pk_test/),c=r(e.version),l=n;s&&c!==l&&console.warn(`Stripe.js@${c} was loaded on the page, but @stripe/stripe-js@9.17.0 expected Stripe.js@${l}. This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning`);var u=e.apply(void 0,i);return f(u,a),u},v=function(e){var n=`invalid load parameters; expected object of shape\n\n {advancedFraudSignals: boolean}\n\nbut received\n\n ${JSON.stringify(e)}\n`;if(e===null||t(e)!==`object`)throw Error(n);if(Object.keys(e).length===1&&typeof e.advancedFraudSignals==`boolean`)return e;throw Error(n)},y,b=!1,ne=function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];b=!0;var r=Date.now();return _(y).then(function(e){return te(e,t,r)})};ne.setLoadParameters=function(e){if(b&&y){var t=v(e);if(Object.keys(t).reduce(function(t,n){return t&&e[n]===y?.[n]},!0))return}if(b)throw Error(`You cannot change load parameters after calling loadStripe`);y=v(e)},e.loadStripe=ne})),r=t(((e,t)=>{t.exports=n()})),i,a=e((()=>{i={payment:`Payment`}})),o,s=e((()=>{o=class extends Error{name=`LegacyUnicodeEscapedChallengeError`;constructor(){super(`Legacy unicode-escaped challenge: the server escaped a bound parameter as \\\\uXXXX; upgrade the server.`)}}})),c,l=e((()=>{c=`0.1.1`}));function u(){return c}var d=e((()=>{l()}));function f(e,t){return t?.(e)?e:e&&typeof e==`object`&&`cause`in e&&e.cause?f(e.cause,t):t?null:e}var p,m=e((()=>{d(),p=class e extends Error{static setStaticOptions(t){e.prototype.docsOrigin=t.docsOrigin,e.prototype.showVersion=t.showVersion,e.prototype.version=t.version}constructor(t,n={}){let r=(()=>{if(n.cause instanceof e){if(n.cause.details)return n.cause.details;if(n.cause.shortMessage)return n.cause.shortMessage}return n.cause&&`details`in n.cause&&typeof n.cause.details==`string`?n.cause.details:n.cause?.message?n.cause.message:n.details})(),i=n.cause instanceof e&&n.cause.docsPath||n.docsPath,a=n.docsOrigin??e.prototype.docsOrigin,o=`${a}${i??``}`,s=!!(n.version??e.prototype.showVersion),c=n.version??e.prototype.version,l=[t||`An error occurred.`,...n.metaMessages?[``,...n.metaMessages]:[],...r||i||s?[``,r?`Details: ${r}`:void 0,i?`See: ${o}`:void 0,s?`Version: ${c}`:void 0]:[]].filter(e=>typeof e==`string`).join(`\n`);super(l,n.cause?{cause:n.cause}:void 0),Object.defineProperty(this,\"details\",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,\"docs\",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,\"docsOrigin\",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,\"docsPath\",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,\"shortMessage\",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,\"showVersion\",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,\"version\",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,\"cause\",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,\"name\",{enumerable:!0,configurable:!0,writable:!0,value:`BaseError`}),this.cause=n.cause,this.details=r,this.docs=o,this.docsOrigin=a,this.docsPath=i,this.shortMessage=t,this.showVersion=s,this.version=c}walk(e){return f(this,e)}},Object.defineProperty(p,\"defaultStaticOptions\",{enumerable:!0,configurable:!0,writable:!0,value:{docsOrigin:`https://oxlib.sh`,showVersion:!1,version:`ox@${u()}`}}),p.setStaticOptions(p.defaultStaticOptions)}));function h(e,t){if(re(e)>t)throw new ae({givenSize:re(e),maxSize:t})}function ee(e,t={}){let{dir:n,size:r=32}=t;if(r===0)return e;if(e.length>r)throw new oe({size:e.length,targetSize:r,type:`Bytes`});let i=new Uint8Array(r);for(let t=0;t<r;t++){let a=n===`right`;i[a?t:r-t-1]=e[a?t:e.length-t-1]}return i}var g=e((()=>{x()}));function _(e){if(e===null||typeof e==`boolean`||typeof e==`string`)return JSON.stringify(e);if(typeof e==`number`){if(!Number.isFinite(e))throw TypeError(`Cannot canonicalize non-finite number`);return Object.is(e,-0)?`0`:JSON.stringify(e)}if(typeof e==`bigint`)throw TypeError(`Cannot canonicalize bigint`);if(Array.isArray(e))return`[${e.map(e=>_(e)).join(`,`)}]`;if(typeof e==`object`)return`{${Object.keys(e).sort().reduce((t,n)=>{let r=e[n];return r!==void 0&&t.push(`${JSON.stringify(n)}:${_(r)}`),t},[]).join(`,`)}}`}function te(e,t){return JSON.parse(e,(e,n)=>{let r=n;return typeof r==`string`&&r.endsWith(v)?BigInt(r.slice(0,-9)):typeof t==`function`?t(e,r):r})}var v,y=e((()=>{v=`#__bigint`}));function b(e,t={}){let{size:n}=t,r=ie.encode(e);return typeof n==`number`?(h(r,n),ne(r,n)):r}function ne(e,t){return ee(e,{dir:`right`,size:t})}function re(e){return e.length}var ie,ae,oe,x=e((()=>{m(),g(),y(),ie=new TextEncoder,ae=class extends p{constructor({givenSize:e,maxSize:t}){super(`Size cannot exceed \\`${t}\\` bytes. Given size: \\`${e}\\` bytes.`),Object.defineProperty(this,\"name\",{enumerable:!0,configurable:!0,writable:!0,value:`Bytes.SizeOverflowError`})}},oe=class extends p{constructor({size:e,targetSize:t,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (\\`${e}\\`) exceeds padding size (\\`${t}\\`).`),Object.defineProperty(this,\"name\",{enumerable:!0,configurable:!0,writable:!0,value:`Bytes.SizeExceedsPaddingSizeError`})}}}));function se(e,t={}){let{pad:n=!0,url:r=!1}=t,i=new Uint8Array(Math.ceil(e.length/3)*4);for(let t=0,n=0;n<e.length;t+=4,n+=3){let r=(e[n]<<16)+(e[n+1]<<8)+(e[n+2]|0);i[t]=S[r>>18],i[t+1]=S[r>>12&63],i[t+2]=S[r>>6&63],i[t+3]=S[r&63]}let a=e.length%3,o=Math.floor(e.length/3)*4+(a&&a+1),s=le.decode(new Uint8Array(i.buffer,0,o));return n&&a===1&&(s+=`==`),n&&a===2&&(s+=`=`),r&&(s=s.replaceAll(`+`,`-`).replaceAll(`/`,`_`)),s}function ce(e,t={}){return se(b(e),t)}var le,S,ue=e((()=>{x(),le=new TextDecoder,S=Object.fromEntries(Array.from(`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`).map((e,t)=>[t,e.charCodeAt(0)])),{...Object.fromEntries(Array.from(`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`).map((e,t)=>[e.charCodeAt(0),t]))}})),C=e((()=>{m(),x(),g(),y(),d(),ue(),C()}));function de(e){return ce(_(e),{pad:!1,url:!0})}var fe=e((()=>{C()}));function pe(e,t){return typeof t==`bigint`?t.toString():t}function me(e){return new Ne(e)}function he(e){return e==null}function ge(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function _e(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function ve(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ye(e){if(ve(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return ve(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function be(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function w(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error(\"Cannot specify both `message` and `error` params\");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function xe(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout===`optional`)}function T(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Se(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function E(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function D(e){return typeof e==`string`?e:e?.message}function Ce(e){let t=[];for(let n of e??[]){let e=n._zod.def;if(!/_(length|size)$|_equals$/.test(e.check))break;let r=e.maximum??e.length??e.size;r>=0&&t.push([r,n])}return t}function we(e,t,n){var r;for(let i=t;i<e.length;i++)(r=e[i]).schema??(r.schema=n)}function O(e,t,n){var r;let i=e.inst?._zod?.traits;i?.has(`$ZodType`)&&(i.has(`$ZodCheck`)?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);let a=e.schema===e.inst?void 0:e.schema?._zod.def?.error,o=e.message?e.message:D(e.inst?._zod.def?.error?.(e))??D(a?.(e))??D(t?.error?.(e))??D(n.customError?.(e))??D(n.localeError?.(e))??`Invalid input`,s={};for(let t of Object.keys(e))t!==`inst`&&t!==`schema`&&t!==`continue`&&t!==`input`&&t!==`__proto__`&&(s[t]=e[t]);return s.path??=[],s.message=o,t?.reportInput&&(s.input=e.input),s}function Te(e){let t=e.length;if(!Fe.test(e))return t;let n=t;for(let r=0;r<t-1;r++)(e.charCodeAt(r)&64512)==55296&&(e.charCodeAt(r+1)&64512)==56320&&(n--,r++);return n}function Ee(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function De(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}function Oe(e,t){for(let n in t){let r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):Ae(e,n,r.value)}}function k(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function ke(e,t,n){return k(e,t,n,!1)}function Ae(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:k(this,t,n.bind(this))},set(e){k(this,t,e)}})}function je(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}function A(e,t,n){let r=Object.getPrototypeOf(e._zod);if(t in r&&Ie!==e._zod){Ie=void 0;return}Ie=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,Le);let e=j;j=!1;try{let r=n(this);return j?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r}),j||=e,r}catch(n){throw delete this[t],j||=e,n}},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}})}function Me(e,t,n,r){let i=je(e,t);i&&Object.defineProperty(i,t,{configurable:!0,get(){let e={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,e),e.value=n(this),Object.defineProperty(this,t,e),e.value},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:e})}})}var Ne,Pe,Fe,Ie,j,Le,M=e((()=>{Ne=class{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;return e!==void 0&&(this._value=e(),this._getter=void 0),this._value}},Pe=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{},Fe=/[\\uD800-\\uDBFF]/,j=!1,Le={configurable:!0,get(){j=!0}}}));function Re(e){let t=Ve;if(t){let n=t.stackTraceLimit;if(typeof n==`number`){try{t.stackTraceLimit=0}catch{return Ve=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function N(e,t,n,r){let i={};function a(e){this.def=e,this.constr=d,this.traits=new Set}a.prototype=i;let o=n,s=o&&new WeakSet;function c(n,r){if(!n._zod){Be.value=new a(r);try{Object.defineProperty(n,\"_zod\",Be)}finally{Be.value=void 0}}else if(n._zod.traits.has(e))return;if(n._zod.traits.add(e),t(n,r),s){let e=Object.getPrototypeOf(n),t=n._zod.constr.prototype,r=e;for(;r&&r!==t;)r=Object.getPrototypeOf(r);let i=r??e;s.has(i)||(s.add(i),Oe(i,o))}let i=d.prototype;for(let e in i)Object.prototype.hasOwnProperty.call(i,e)&&(e in n||(n[e]=i[e].bind(n)))}let l=r?.Parent??Object;class u extends l{}Object.defineProperty(u,\"name\",{value:e});function d(e){let t=r?.Parent?Re(u):this;c(t,e);let n=t._zod.deferred;if(n){for(let e of n)e();t._zod.deferred=void 0}let i=globalThis.__zod_globalConfig?.postProcessor;return i&&i(t),t}return Object.defineProperty(d,\"init\",{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:t=>r?.Parent&&t instanceof r.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(d,\"name\",{value:e}),d}function P(e){return e&&Object.assign(I,e),I}var ze,Be,Ve,F,He,I,L=e((()=>{M(),Be={value:void 0,enumerable:!1},Ve=`captureStackTrace`in Error?Error:null,F=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},He=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}},(ze=globalThis).__zod_globalConfig??(ze.__zod_globalConfig={}),I=globalThis.__zod_globalConfig}));function Ue(){let e=this._zod;return e.message??=JSON.stringify(e.def,pe,2),e.message}function We(e){this._zod.message=e}var Ge,R,Ke,qe,z,Je=e((()=>{L(),M(),Ge={get:Ue,set:We,enumerable:!0,configurable:!0},R={value:void 0,enumerable:!1},Ke=new WeakSet([Object.prototype,Error.prototype]),qe=(e,t)=>{e.name=`$ZodError`,R.value=t,Object.defineProperty(e,\"issues\",R),R.value=void 0,Object.defineProperty(e,\"message\",Ge);let n=Object.getPrototypeOf(e);Ke.has(n)||(Ke.add(n),Object.defineProperty(n,\"toString\",{configurable:!0,enumerable:!1,get(){let e=()=>this.message;return Object.defineProperty(this,\"toString\",{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,\"toString\",{value:e,configurable:!0,writable:!0})}}))},N(`$ZodError`,qe),z=N(`$ZodError`,qe,void 0,{Parent:Error})}));function Ye(e,t,n){let r;return{success:!1,get error(){return r||(r=new e(t.map(e=>O(e,n,P()))),t=void 0,n=void 0),r},set error(e){r=e,t=void 0,n=void 0}}}var Xe,Ze,Qe,$e,et,tt,nt,rt,it=e((()=>{L(),Je(),M(),Xe=e=>{let t=(n,r,i,a)=>{let o=i?{...i,async:!1}:{async:!1},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new F;if(s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>O(e,o,P())));throw Pe(n,a?.callee??t),n}return s.value};return t},Ze=Xe(z),Qe=e=>{let t=async(n,r,i,a)=>{let o=i?{...i,async:!0}:{async:!0},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise&&(s=await s),s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>O(e,o,P())));throw Pe(n,a?.callee??t),n}return s.value};return t},$e=Qe(z),et=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new F;return a.issues.length?Ye(e,a.issues,i):{success:!0,data:a.value}},tt=et(z),nt=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?Ye(e,a.issues,i):{success:!0,data:a.value}},rt=nt(z)})),at,ot,st=e((()=>{at=/^[\\s\\S]{0,}$/,ot=/^-?\\d+(?:\\.\\d+)?$/})),B,ct,lt,ut,dt,ft=e((()=>{L(),M(),B=N(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),ct=e=>{let t=e.value;return!he(t)&&t.length!==void 0},lt=N(`$ZodCheckMinLength`,(e,t)=>{var n;B.init(e,t),(n=e._zod.def).when??(n.when=ct),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>=t.minimum&&i<t.minimum*2?Te(r):i)>=t.minimum)return;let a=Ee(r);n.issues.push({origin:a,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),ut=N(`$ZodCheckStringFormat`,(e,t)=>{var n,r;B.init(e,t),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),dt=N(`$ZodCheckRegex`,(e,t)=>{ut.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})}})})),pt=e((()=>{})),mt,ht=e((()=>{mt={major:4,minor:6,patch:7}}));async function gt(e,t){let n={async:!0};return Tt(await e._zod.run({value:t,issues:[]},n),n)}function _t(e){return{validate:t=>{let n={async:!1};try{let r=e._zod.run({value:t,issues:[]},n);if(!(r instanceof Promise))return Tt(r,n)}catch{}return gt(e,t)},vendor:`zod`,version:1}}function vt(e,t){let n=Ce(e._zod.def.checks);if(!n.length)return;let r=Math.min(...n.map(e=>e[0])),i=e._zod.parse;e._zod.parse=(n,a)=>{let o=t(n.value);if(o>r&&!a?.skipChecks&&a?.direction!==`backward`){for(let[t,r]of Ce(e._zod.def.checks))if(o>t&&r._zod.def.when(n)){let t=n.issues.length;return r._zod.check(n),n.issues[t].continue=!1,we(n.issues,t,e),n}}return i(n,a)}}function yt(e,t,n){e.issues.length&&t.issues.push(...E(n,e.issues)),t.value[n]=e.value}function V(e,t,n,r,i,a){let o=n in r,s=a===`optional`;if(!(!o&&s&&i===`optional`)){if(e.issues.length){if(i!==void 0&&s&&!o)return;t.issues.push(...E(n,e.issues))}if(!o&&i===void 0){e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]});return}e.value===void 0?(o||i===`defaulted`&&!s)&&(t.value[n]=void 0):t.value[n]=e.value}}function bt(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:At,i=r.length?[...t,...r]:t;for(let t of i)if(!e.shape?.[t]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key \"${String(t)}\": expected a Zod schema`);let a=xe(e.shape);return{...e,allKeys:i,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(a)}}function xt(e,t,n,r,i,a,o){let s=[],c=i.keySet,l=i.catchall._zod,u=l.def.type,d=l.optin,f=l.optout,p=0;for(let i in t){if(o&&n.issues.length!==p){if(T(n,p))break;p=n.issues.length}if(c.has(i))continue;if(i===`__proto__`){u===`never`&&s.push(i);continue}if(u===`never`){s.push(i);continue}let a=l.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>V(e,n,i,t,d,f))):V(a,n,i,t,d,f)}return s.length&&n.issues.push({code:`unrecognized_keys`,keys:s,input:t,inst:a,continue:!0}),e.length?Promise.all(e).then(()=>n):n}function St(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!T(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>O(e,r,P())))}),t)}function Ct(e,t){return e.value=t.issues.length?void 0:t.value,e}function H(e,t,n){return e.issues.some(e=>e.code!==`unrecognized_keys`)?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}function wt(e,t,n,r){if(!e){let 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(De(e))}}var U,Tt,Et,Dt,Ot,kt,At,jt,Mt,Nt,Pt,Ft,It,Lt,Rt=e((()=>{ft(),L(),st(),M(),ht(),U=N(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=mt;let r=e._zod.def.checks,i=e._zod.traits.has(`$ZodCheck`)?[e,...r??[]]:r?.length?[...r]:[];for(let t of i)for(let n of t._zod.onattach)n(e);if(i.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(t,n,r)=>{if(t.memo)return t;let i=T(t),a;for(let o of n){if(o._zod.def.when){if(Se(t)||!o._zod.def.when(t))continue}else if(i)continue;let n=t.issues.length,s=o._zod.check(t);if(s instanceof Promise&&r?.async===!1)throw new F;if(a||s instanceof Promise)a=(a??Promise.resolve()).then(async()=>{await s,t.issues.length!==n&&(we(t.issues,n,e),i||=T(t,n))});else{if(t.issues.length===n)continue;we(t.issues,n,e),i||=T(t,n)}}return a?a.then(()=>t):t},n=(n,r,a)=>{if(T(n))return n.aborted=!0,n;let o=t(r,i,a);if(o instanceof Promise){if(a.async===!1)throw new F;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(r,a)=>{if(a.skipChecks)return e._zod.parse(r,a);if(a.direction===`backward`){let t=e._zod.parse({value:r.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,r,a)):n(t,r,a)}let o=e._zod.parse(r,a);if(o instanceof Promise){if(a.async===!1)throw new F;return o.then(e=>t(e,i,a))}return t(o,i,a)}}},{get\"~standard\"(){return ke(this,`~standard`,_t(this))},set\"~standard\"(e){k(this,`~standard`,e)}}),Tt=(e,t)=>e.issues.length?{issues:e.issues.map(e=>O(e,t,P()))}:{value:e.value},Et=N(`$ZodString`,(e,t)=>{U.init(e,t),e._zod.pattern=t.pattern??at,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),Dt=N(`$ZodNumber`,(e,t)=>{U.init(e,t),e._zod.pattern=ot,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:String(i):void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),Ot=e=>Array.isArray(e)?e.length:-1,kt=N(`$ZodArray`,(e,t)=>{U.init(e,t);let n=I.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!Array.isArray(a))return r.issues.push({expected:`array`,code:`invalid_type`,input:a,inst:e}),r;r.value=n?n.alloc(e,r,Array(a.length),i):Array(a.length);let o=[],s=i?.abortEarly;for(let e=0;e<a.length;e++){let n=a[e],c=t.element._zod.run({value:n,issues:[]},i);if(c instanceof Promise)o.push(c.then(t=>yt(t,r,e)));else if(yt(c,r,e),s&&c.issues.length!==0&&T(c))break}return o.length?Promise.all(o).then(()=>r):r},vt(e,Ot)}),At=[],jt=N(`$ZodObject`,(e,t)=>{U.init(e,t);let n=Object.getOwnPropertyDescriptor(t,`shape`),r=n?.get?n.get.raw:t.shape??{};if(r){let e=()=>{let n={...r};return Object.defineProperty(t,\"shape\",{value:n}),e.raw=n,n};e.raw=r,Object.defineProperty(t,\"shape\",{get:e})}let i=me(()=>bt(t));A(e,`propValues`,e=>{let t=e.def.shape,n={};for(let e in t){let r=t[e]._zod;if(r.values){Object.prototype.hasOwnProperty.call(n,e)||_e(n,e,new Set);for(let t of r.values)n[e].add(t);r.optin!==void 0&&n[e].add(void 0)}}return n});let a=ve,o=t.catchall,s,c=I.memoizer;c?.attach(e),e._zod.parse=(t,n)=>{s??=i.value;let r=t.value;if(!a(r))return t.issues.push({expected:`object`,code:`invalid_type`,input:r,inst:e}),t;t.value=c?c.alloc(e,t,{},n):{};let l=[],u=s.shape,d=n?.abortEarly,f=t.issues.length;for(let e of s.allKeys){if(d&&t.issues.length!==f){if(T(t,f))break;f=t.issues.length}if(e===`__proto__`)continue;let i=u[e],a=i._zod.optin,o=i._zod.optout,s=i._zod.run({value:r[e],issues:[]},n);s instanceof Promise?l.push(s.then(n=>V(n,t,e,r,a,o))):V(s,t,e,r,a,o)}return o?xt(l,r,t,n,i.value,e,d===!0):l.length?Promise.all(l).then(()=>t):t}}),Mt=N(`$ZodUnion`,(e,t)=>{U.init(e,t),A(e,`optin`,e=>e.def.options.some(e=>e._zod.optin===`defaulted`)?`defaulted`:e.def.options.some(e=>e._zod.optin!==void 0)?`optional`:void 0),A(e,`optout`,e=>e.def.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),A(e,`values`,e=>{if(e.def.options.every(e=>e._zod.values))return new Set(e.def.options.flatMap(e=>Array.from(e._zod.values)))}),A(e,`pattern`,e=>{if(e.def.options.every(e=>e._zod.pattern)){let t=e.def.options.map(e=>e._zod.pattern);return RegExp(`^(${t.map(e=>ge(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>St(t,r,e,i)):St(o,r,e,i)}}),Nt=N(`$ZodRecord`,(e,t)=>{U.init(e,t);let n=I.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!ye(a))return r.issues.push({expected:`record`,code:`invalid_type`,input:a,inst:e}),r;let o=[],s=t.keyType._zod.values;if(s&&!t.partial){r.value=n?n.alloc(e,r,{},i):{};let c=new Set;for(let n of s)if(typeof n==`string`||typeof n==`number`||typeof n==`symbol`){if(c.add(typeof n==`number`?n.toString():n),n===`__proto__`)continue;let s=t.keyType._zod.run({value:n,issues:[]},i);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(s.issues.length){r.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>O(e,i,P())),input:n,path:[n],inst:e});continue}let l=s.value;if(l===`__proto__`)continue;let u=t.valueType._zod.run({value:a[n],issues:[]},i);u instanceof Promise?o.push(u.then(e=>{e.issues.length&&r.issues.push(...E(n,e.issues)),r.value[l]=e.value})):(u.issues.length&&r.issues.push(...E(n,u.issues)),r.value[l]=u.value)}let l;for(let e in a)if(!c.has(e)){if(t.mode===`loose`){if(e===`__proto__`)continue;r.value[e]=a[e]}else l??=[],l.push(e)}l&&l.length>0&&r.issues.push({code:`unrecognized_keys`,input:a,inst:e,keys:l,continue:!0})}else{r.value=n?n.alloc(e,r,{},i):{};let c;for(let n of Reflect.ownKeys(a)){if(n===`__proto__`||!Object.prototype.propertyIsEnumerable.call(a,n))continue;let l=t.keyType._zod.run({value:n,issues:[]},i);if(l instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof n==`string`&&ot.test(n)&&l.issues.length){let e=t.keyType._zod.run({value:Number(n),issues:[]},i);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(l=e)}if(l.issues.length){t.mode===`loose`?r.value[n]=a[n]:s?(c??=[],c.push(n)):r.issues.push({code:`invalid_key`,origin:`record`,issues:l.issues.map(e=>O(e,i,P())),input:n,path:[n],inst:e});continue}let u=l.value;if(u===`__proto__`)continue;let d=t.valueType._zod.run({value:a[n],issues:[]},i);d instanceof Promise?o.push(d.then(e=>{e.issues.length&&r.issues.push(...E(n,e.issues)),r.value[u]=e.value})):(d.issues.length&&r.issues.push(...E(n,d.issues)),r.value[u]=d.value)}c&&c.length>0&&r.issues.push({code:`unrecognized_keys`,input:a,inst:e,keys:c,continue:!0})}return o.length?Promise.all(o).then(()=>r):r}}),Pt=N(`$ZodTransform`,(e,t)=>{U.init(e,t),e._zod.optin=`optional`,I.memoizer?.guard(e),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new He(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n));if(i instanceof Promise)throw new F;return n.value=i,n}}),Ft=N(`$ZodOptional`,(e,t)=>{U.init(e,t),A(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),e._zod.optout=`optional`,A(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t,void 0]):void 0}),A(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${ge(t.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(e.value===void 0){if(t.innerType._zod.optin!==`defaulted`)return e;let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(t=>Ct(e,t)):Ct(e,r)}return t.innerType._zod.run(e,n)}}),It=N(`$ZodPipe`,(e,t)=>{U.init(e,t),A(e,`values`,e=>e.def.in._zod.values),A(e,`optin`,e=>e.def.in._zod.optin),A(e,`optout`,e=>e.def.out._zod.optout),A(e,`propValues`,e=>e.def.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>H(e,t.in,n)):H(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>H(e,t.out,n)):H(r,t.out,n)}}),Lt=N(`$ZodCustom`,(e,t)=>{B.init(e,t),U.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>wt(t,n,r,e));wt(i,n,r,e)}})})),zt=e((()=>{})),Bt=e((()=>{globalThis.__zod_globalRegistry})),Vt=e((()=>{}));function Ht(e){return e.checks&&=[...e.checks],e}function Ut(e,t){return new e(Ht({type:`string`,...w(t)}))}function Wt(e,t){return new e(Ht({type:`number`,checks:[],...w(t)}))}function W(e,t){return new lt({check:`min_length`,...w(t),minimum:e})}function Gt(e,t){return new dt({check:`string_format`,format:`regex`,...w(t),pattern:e})}function Kt(e,t,n){let r=w(n);return r.abort??=!0,new e({type:`custom`,check:`custom`,fn:t,...r})}function qt(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...w(n)})}var Jt=e((()=>{ft(),M()})),Yt=e((()=>{})),G=e((()=>{L(),it(),Je(),Rt(),zt(),ft(),ht(),M(),st(),Bt(),pt(),Vt(),Jt(),Yt(),Rt(),Yt()})),Xt=e((()=>{G()}));function K(e){return Ut(on,e)}function Zt(e){return Wt(sn,e)}function Qt(e,t){return new cn({type:`array`,element:e,...w(t)})}function q(e,t){let n={type:`object`,shape:e??{},...w(t)};return new ln(n)}function $t(e,t){return new un({type:`union`,options:e,...w(t)})}function en(e,t,n){return!t||!t._zod?new dn({type:`record`,keyType:K(),valueType:e,...w(t)}):new dn({type:`record`,keyType:e,valueType:t,...w(n)})}function tn(e){return new fn({type:`transform`,transform:e})}function J(e){return new pn({type:`optional`,innerType:e})}function nn(e,t){return new mn({type:`pipe`,in:e,out:t})}function rn(e,t){return Kt(hn,e??(()=>!0),t)}function an(e,t={}){return qt(hn,e,t)}var Y,on,sn,cn,ln,un,dn,fn,pn,mn,hn,gn=e((()=>{G(),M(),Xt(),Y=N(`ZodMiniType`,(e,t)=>{if(!e._zod)throw Error(`Uninitialized schema in ZodMiniType.`);U.init(e,t),e.def=t,e.type=t.type},{get with(){return this.check},set with(e){k(this,`with`,e)},parse(e,t){return Ze(this,e,t,{callee:this.parse})},parseAsync(e,t){return $e(this,e,t,{callee:this.parseAsync})},safeParse(e,t){return tt(this,e,t)},safeParseAsync(e,t){return rt(this,e,t)},check(...e){let t=this.def;return this.clone({...t,checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]},{parent:!0})},clone(e,t){return be(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},apply(e,...t){return t.length===0?e(this):e(this,...t)}}),on=N(`ZodMiniString`,(e,t)=>{Et.init(e,t),Y.init(e,t)}),sn=N(`ZodMiniNumber`,(e,t)=>{Dt.init(e,t),Y.init(e,t)}),cn=N(`ZodMiniArray`,(e,t)=>{kt.init(e,t),Y.init(e,t)}),ln=N(`ZodMiniObject`,(e,t)=>{jt.init(e,t),Y.init(e,t),Me(e,`shape`,e=>e._zod.def.shape,!1)}),un=N(`ZodMiniUnion`,(e,t)=>{Mt.init(e,t),Y.init(e,t)}),dn=N(`ZodMiniRecord`,(e,t)=>{Nt.init(e,t),Y.init(e,t)}),fn=N(`ZodMiniTransform`,(e,t)=>{Pt.init(e,t),Y.init(e,t)}),pn=N(`ZodMiniOptional`,(e,t)=>{Ft.init(e,t),Y.init(e,t)}),mn=N(`ZodMiniPipe`,(e,t)=>{It.init(e,t),Y.init(e,t)}),hn=N(`ZodMiniCustom`,(e,t)=>{Lt.init(e,t),Y.init(e,t)})})),_n=e((()=>{G()})),vn=e((()=>{G(),Xt(),gn(),_n(),Rt(),M(),gn(),st(),Yt()})),yn=e((()=>{vn()}));function bn(){return K().check(Gt(/^\\d+(\\.\\d+)?$/,`Invalid amount`))}function xn(){return K().check(Gt(/^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d+)?(?:Z|[+-]\\d{2}:\\d{2})$/,`Invalid ISO 8601 datetime`))}var X=e((()=>{yn(),yn()}));function Sn(e){return!!(e&&typeof e==`object`&&e[Tn])}function Cn(e){if(Sn(e))throw new o}function wn(e){return/^payment-authorization$/i.test(e)}var Tn,En,Dn=e((()=>{s(),X(),Tn=Symbol(`mppx.Challenge.legacyUnicodeEscape`),En=`Unsupported credential header: challenges may only select Payment-Authorization.`,K().check(Gt(/^sha-256=/,`Invalid digest format`)),xn(),K().check(an(wn,En)),K().check(W(1))}));function On(e){let{meta:t,opaque:n,request:r,...a}=e.challenge,o=n??(t===void 0?void 0:de(t)),s={challenge:{...a,...o!==void 0&&{opaque:o},request:de(r)},payload:e.payload,...e.source&&{source:e.source}},c=ce(JSON.stringify(s),{pad:!1,url:!0});return`${i.payment} ${c}`}var kn=e((()=>{C(),a(),fe()})),An=e((()=>{a(),s(),C(),Dn(),kn(),X()}));function jn(e){return e}function Mn(e,t){let{canHandleChallenge:n,context:r,createCredential:i}=t;return{...e,canHandleChallenge:n,context:r,async createCredential(e){return Cn(e.challenge),i.call(this,e)}}}var Nn=e((()=>{Dn()}));function Pn(e,t){if(!Number.isInteger(t)||t<0)throw RangeError(`Decimals must be a non-negative integer.`);if(!/^-?(?:\\d+(?:\\.\\d*)?|\\.\\d+)$/.test(e))throw TypeError(`Value \\`${e}\\` is not a valid decimal number.`);let n=e.startsWith(`-`),[r=`0`,i=``]=(n?e.slice(1):e).split(`.`),a=i.slice(0,t).padEnd(t,`0`),o=BigInt(`${r||`0`}${a}`);return i.length>t&&i[t]>=`5`&&(o+=1n),n?-o:o}var Fn=e((()=>{})),In,Ln,Rn,zn=e((()=>{X(),In=q({customer:J(K().check(W(1))),hooks:J(q({inputs:q({tax:q({calculation:K().check(W(1))})})})),metadata:J(en(K(),K())),receipt_email:J(K().check(W(1)))}),Ln=rn(e=>typeof e==`function`),Rn=$t([In,Ln])})),Bn,Vn=e((()=>{Nn(),X(),Fn(),zn(),Bn=jn({name:`stripe`,intent:`charge`,schema:{credential:{payload:q({externalId:J(K()),spt:K()})},request:nn(q({amount:bn(),currency:K(),decimals:Zt(),description:J(K()),externalId:J(K()),metadata:J(en(K(),K())),networkId:K(),paymentIntentOptions:J(Rn),paymentMethodTypes:Qt(K()).check(W(1)),recipient:J(K())}),tn(({amount:e,decimals:t,metadata:n,networkId:r,paymentIntentOptions:i,paymentMethodTypes:a,...o})=>({...o,amount:Pn(e,t).toString(),methodDetails:{networkId:r,paymentMethodTypes:a,...n!==void 0&&{metadata:n}}})))}})}));function Hn(e){let{client:t,createToken:n,externalId:r,paymentMethod:i}=e;return Mn(Bn,{context:q({paymentMethod:J(K())}),async createCredential({challenge:e,context:a}){let o=a?.paymentMethod??i;if(!o)throw Error(`paymentMethod is required (pass via context or parameters)`);let s=e.request.amount,c=e.request.currency,l=typeof e.request.externalId==`string`?e.request.externalId:void 0,u=e.request.methodDetails?.networkId;if(!u)throw Error(`networkId is required in challenge.methodDetails`);let d=e.request.methodDetails?.metadata;if(d?.externalId)throw Error(`methodDetails.metadata.externalId is reserved; use credential externalId instead`);let f=e.expires?Math.floor(new Date(e.expires).getTime()/1e3):Math.floor(Date.now()/1e3)+3600,p=await n({amount:s,challenge:e,client:t,currency:c,expiresAt:f,metadata:d,networkId:u,paymentMethod:o}),m=l??r;return On({challenge:e,payload:{spt:p,...m===void 0?{}:{externalId:m}}})}})}var Un=e((()=>{kn(),Nn(),X(),Vn()}));function Wn(e){return[Hn(e)]}var Gn=e((()=>{Un(),(function(e){e.charge=Hn})(Wn||={})})),Kn=e((()=>{Un(),Gn()})),qn=e((()=>{x(),m(),g(),y(),ue(),d(),kn(),Nn(),C(),X(),fe(),Kn(),Jn(),a(),s(),Dn()})),Jn=e((()=>{An(),qn(),x(),m(),g(),y(),ue(),d(),C(),Jn(),kn(),s(),fe(),Nn(),X(),a(),Dn()})),Yn=r();Jn();let Xn={data:`__MPPX_DATA__`,error:`root_error`,root:`root`},Zn={serviceWorker:`__mppx_worker`,tab:`__mppx_tab`},Qn={challengeId:`data-mppx-challenge-id`,remaining:`data-remaining`};var Z=class{name;constructor(e){this.name=`--mppx-${e}`}toString(){return`var(${this.name})`}};let $n={accent:new Z(`accent`),background:new Z(`background`),border:new Z(`border`),foreground:new Z(`foreground`),muted:new Z(`muted`),negative:new Z(`negative`),positive:new Z(`positive`),surface:new Z(`surface`),fontFamily:new Z(`font-family`),fontSizeBase:new Z(`font-size-base`),radius:new Z(`radius`),spacingUnit:new Z(`spacing-unit`)};String.raw`<style>\n *,\n ::after,\n ::before,\n ::backdrop,\n ::file-selector-button {\n box-sizing: border-box;\n margin: 0;\n padding: 0;\n border: 0 solid;\n border-color: ${$n.border};\n }\n html,\n :host {\n line-height: 1.5;\n -webkit-text-size-adjust: 100%;\n tab-size: 4;\n -webkit-tap-highlight-color: transparent;\n }\n h1,\n h2,\n h3,\n h4,\n h5,\n h6 {\n font-size: inherit;\n font-weight: inherit;\n }\n a {\n color: inherit;\n -webkit-text-decoration: inherit;\n text-decoration: inherit;\n }\n b,\n strong {\n font-weight: bolder;\n }\n code,\n kbd,\n samp,\n pre {\n font-family:\n ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New',\n monospace;\n font-size: 1em;\n }\n small {\n font-size: 80%;\n }\n ol,\n ul,\n menu {\n list-style: none;\n }\n img,\n svg,\n video,\n canvas,\n audio,\n iframe,\n embed,\n object {\n display: block;\n vertical-align: middle;\n }\n img,\n video {\n max-width: 100%;\n height: auto;\n }\n button,\n input,\n select,\n optgroup,\n textarea,\n ::file-selector-button {\n font: inherit;\n font-feature-settings: inherit;\n font-variation-settings: inherit;\n letter-spacing: inherit;\n color: inherit;\n border-radius: 0;\n background-color: transparent;\n opacity: 1;\n }\n ::file-selector-button {\n margin-inline-end: 4px;\n }\n ::placeholder {\n opacity: 1;\n }\n @supports (not (-webkit-appearance: -apple-pay-button)) or (contain-intrinsic-size: 1px) {\n ::placeholder {\n color: color-mix(in oklab, currentcolor 50%, transparent);\n }\n }\n textarea {\n resize: vertical;\n }\n ::-webkit-search-decoration {\n -webkit-appearance: none;\n }\n :-moz-ui-invalid {\n box-shadow: none;\n }\n button,\n input:where([type='button'], [type='reset'], [type='submit']),\n ::file-selector-button {\n appearance: button;\n }\n ::-webkit-inner-spin-button,\n ::-webkit-outer-spin-button {\n height: auto;\n }\n [hidden]:where(:not([hidden='until-found'])) {\n display: none !important;\n }\n</style>`;function er(e,t){if(t==null)return e;if(!tr(e)||!tr(t))return t??e;let n={...e};for(let[e,r]of Object.entries(t)){if(r==null||r===``)continue;let t=n[e];n[e]=tr(t)&&tr(r)?er(t,r):r}return n}function tr(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}async function nr(e,t=`Authorization`){let n=new URL(location.href);n.searchParams.set(Zn.serviceWorker,``);let r=await navigator.serviceWorker.register(n.pathname+n.search),i=await new Promise(e=>{let t=r.installing??r.waiting??r.active;if(t?.state===`activated`)return e(t);let n=t??r;n.addEventListener(`statechange`,function t(){let i=r.active;i?.state===`activated`&&(n.removeEventListener(`statechange`,t),e(i))})});await new Promise(n=>{let r=new MessageChannel;r.port1.onmessage=()=>n(),i.postMessage({credential:e,header:t},[r.port2])}),location.reload()}C();function rr(e){let t=document.getElementById(Xn.data),n=te(t.textContent),r=t.getAttribute(Qn.remaining);!r||Number(r)<=1?t.remove():t.setAttribute(Qn.remaining,String(Number(r)-1));let i=document.currentScript,a=i?.getAttribute(Qn.challengeId),o=a?(i.removeAttribute(Qn.challengeId),n[a]):Object.values(n).find(t=>t.challenge.method===e);return{...o,error(e){if(!e){document.getElementById(Xn.error)?.remove();return}let t=document.getElementById(Xn.error);if(t){t.textContent=e;return}let n=document.createElement(`p`);n.id=Xn.error,n.className=`mppx-error`,n.role=`alert`,n.textContent=e,document.getElementById(o.rootId)?.after(n)},root:document.getElementById(o.rootId),submit:e=>nr(e,o.challenge.header),vars:$n}}let Q=rr(`stripe`),$=Q.config.elements,ir=String.raw,ar=document.createElement(`style`);ar.textContent=ir`\n form {\n display: flex;\n flex-direction: column;\n gap: calc(${Q.vars.spacingUnit} * 8);\n }\n button {\n background: ${Q.vars.accent};\n border-radius: ${Q.vars.radius};\n color: ${Q.vars.background};\n cursor: pointer;\n font-weight: 500;\n padding: calc(${Q.vars.spacingUnit} * 4) calc(${Q.vars.spacingUnit} * 8);\n width: 100%;\n }\n button:hover:not(:disabled) {\n opacity: 0.85;\n }\n button:disabled {\n cursor: default;\n opacity: 0.5;\n }\n`,Q.root.append(ar),(async()=>{let e=await(0,Yn.loadStripe)(Q.config.publishableKey);if(!e)throw Error(`Failed to loadStripe`);let t=window.matchMedia(`(prefers-color-scheme: dark)`),n=()=>{let e=(()=>{if($?.options?.appearance?.theme)return $?.options?.appearance?.theme;switch(Q.theme.colorScheme){case`light dark`:return t.matches?`night`:`stripe`;case`light`:return`stripe`;case`dark`:return`night`}})(),n=+!!t.matches;return er({disableAnimations:!0,theme:e,variables:{borderRadius:Q.theme.radius,colorBackground:Q.theme.surface[n],colorDanger:Q.theme.negative[n],colorPrimary:Q.theme.accent[n],colorText:Q.theme.foreground[n],colorTextSecondary:Q.theme.muted[n],fontSizeBase:Q.theme.fontSizeBase,fontFamily:Q.theme.fontFamily,spacingUnit:Q.theme.spacingUnit}},$?.options?.appearance??{})},r=e.elements({appearance:n(),...$?.options,amount:Number(Q.challenge.request.amount),currency:Q.challenge.request.currency,mode:`payment`,paymentMethodCreation:`manual`,paymentMethodTypes:Q.challenge.request.methodDetails.paymentMethodTypes});t.addEventListener(`change`,()=>{r.update({appearance:n()})});let i=document.createElement(`form`);r.create(`payment`,$?.paymentOptions).mount(i),Q.root.appendChild(i);let a=document.createElement(`button`);a.textContent=Q.text.pay,a.type=`submit`,i.appendChild(a),i.onsubmit=async t=>{t.preventDefault(),Q.error(),a.disabled=!0;try{await r.submit();let{paymentMethod:t,error:n}=await e.createPaymentMethod({...$?.createPaymentMethodOptions,elements:r});if(n||!t)throw n??Error(`Failed to create payment method`);let i=await Wn({client:e,createToken:or})[0].createCredential({challenge:Q.challenge,context:{paymentMethod:t.id}});await Q.submit(i)}catch(e){Q.error(e instanceof Error?e.message:`Payment failed`)}finally{a.disabled=!1}}})();async function or(e){let t=new URL(Q.config.createTokenUrl,location.origin);if(t.origin!==location.origin)throw Error(`createTokenUrl must be same-origin`);let n=await fetch(t,{method:`POST`,headers:{\"Content-Type\":`application/json`},body:JSON.stringify(e)});if(!n.ok){let e=await n.text().catch(()=>`<response body unavailable>`);throw Error(`Failed to create SPT (${n.status}): ${e}`)}return(await n.json()).spt}})();</script>";
3
3
  //# sourceMappingURL=html.gen.js.map