mppx 0.17.1 → 0.17.4
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.
- package/CHANGELOG.md +65 -0
- package/dist/Errors.d.ts +94 -0
- package/dist/Errors.js +83 -0
- package/dist/Store.d.ts +413 -0
- package/dist/Store.js +837 -0
- package/dist/cli/cli.js +141 -136
- package/dist/cli/internal.js +28 -6
- package/dist/cli/plugins/index.js +16 -11
- package/dist/cli/sessions/Manager.js +12 -1
- package/dist/cli/utils.d.ts +2 -0
- package/dist/cli/utils.js +6 -0
- package/dist/cli/validate/challenge.d.ts +4 -0
- package/dist/cli/validate/challenge.js +9 -6
- package/dist/client/Mppx.d.ts +1 -1
- package/dist/client/Mppx.js +7 -3
- package/dist/client/internal/Fetch.d.ts +1 -1
- package/dist/client/internal/Fetch.js +9 -0
- package/dist/client/internal/MethodResponse.d.ts +8 -0
- package/dist/client/internal/MethodResponse.js +9 -0
- package/dist/client/internal/ProofRealm.d.ts +3 -3
- package/dist/client/internal/ProofRealm.js +4 -4
- package/dist/client/internal/protocols/Mcp.d.ts +4 -0
- package/dist/client/internal/protocols/Mcp.js +27 -14
- package/dist/cloudflare/ChannelStore.d.ts +97 -0
- package/dist/cloudflare/ChannelStore.js +304 -0
- package/dist/cloudflare/Channels.d.ts +92 -0
- package/dist/cloudflare/Channels.js +325 -0
- package/dist/cloudflare/index.d.ts +5 -0
- package/dist/cloudflare/index.js +5 -0
- package/dist/identity/Client.js +7 -1
- package/dist/internal/sse.d.ts +21 -0
- package/dist/internal/sse.js +82 -0
- package/dist/internal/version.d.ts +2 -2
- package/dist/internal/version.js +1 -1
- package/dist/mcp/client/McpClient.d.ts +2 -2
- package/dist/mcp/client/McpClient.js +5 -2
- package/dist/proxy/Proxy.d.ts +2 -0
- package/dist/proxy/Proxy.js +31 -6
- package/dist/proxy/internal/Replay.js +1 -1
- package/dist/server/Mppx.js +5 -4
- package/dist/server/Transport.js +1 -1
- package/dist/server/internal/html/config.d.ts +7 -1
- package/dist/server/internal/html/config.js +4 -0
- package/dist/stripe/internal/types.d.ts +82 -6
- package/dist/stripe/server/Charge.js +1 -2
- package/dist/stripe/server/Methods.d.ts +2 -0
- package/dist/stripe/server/Methods.js +2 -1
- package/dist/stripe/server/internal/html.gen.js +1 -1
- package/dist/stripe/server/internal/record-payment.d.ts +49 -0
- package/dist/stripe/server/internal/record-payment.js +75 -18
- package/dist/tempo/Methods.d.ts +8 -0
- package/dist/tempo/Methods.js +18 -2
- package/dist/tempo/client/Charge.d.ts +32 -1
- package/dist/tempo/client/Charge.js +201 -3
- package/dist/tempo/client/Methods.d.ts +16 -0
- package/dist/tempo/internal/fee-payer.d.ts +64 -14
- package/dist/tempo/internal/fee-payer.js +231 -20
- package/dist/tempo/internal/zone.d.ts +79 -0
- package/dist/tempo/internal/zone.js +133 -0
- package/dist/tempo/legacy/session/Chain.js +2 -0
- package/dist/tempo/server/Charge.d.ts +7 -3
- package/dist/tempo/server/Charge.js +100 -6
- package/dist/tempo/server/Methods.d.ts +40 -0
- package/dist/tempo/server/Subscription.js +1 -0
- package/dist/tempo/server/internal/html.gen.js +1 -1
- package/dist/tempo/server/internal/transport.d.ts +6 -0
- package/dist/tempo/server/internal/transport.js +21 -21
- package/dist/tempo/session/client/ChannelStore.d.ts +2 -0
- package/dist/tempo/session/client/CredentialState.js +2 -0
- package/dist/tempo/session/client/Session.d.ts +11 -1
- package/dist/tempo/session/client/Session.js +39 -6
- package/dist/tempo/session/client/SessionManager.d.ts +1 -1
- package/dist/tempo/session/client/SessionManager.js +8 -4
- package/dist/tempo/session/client/Transports.d.ts +2 -0
- package/dist/tempo/session/client/Transports.js +4 -1
- package/dist/tempo/session/precompile/Chain.js +1 -0
- package/dist/tempo/session/server/ChannelStore.d.ts +14 -0
- package/dist/tempo/session/server/ChannelStore.js +10 -3
- package/dist/tempo/session/server/CredentialVerification.js +1 -1
- package/dist/tempo/session/server/MeteredStream.d.ts +4 -0
- package/dist/tempo/session/server/MeteredStream.js +6 -1
- package/dist/tempo/session/server/Sse.d.ts +59 -0
- package/dist/tempo/session/server/Sse.js +175 -10
- package/dist/validation/core.js +2 -0
- package/dist/zod.d.ts +2 -1
- package/dist/zod.js +1 -1
- package/package.json +5 -3
- package/dist/stripe/server/internal/html/types.d.ts +0 -2
- package/dist/stripe/server/internal/html/types.js +0 -2
|
@@ -2,6 +2,10 @@ import { Json } from 'ox';
|
|
|
2
2
|
import { tabScript } from './compose.main.gen.js';
|
|
3
3
|
export { attrs, classNames, ids, params } from './constants.js';
|
|
4
4
|
import { attrs, classNames, ids } from './constants.js';
|
|
5
|
+
/** Resolves {@link Options.content}, loading it when it is a loader function. */
|
|
6
|
+
export async function resolveContent(content) {
|
|
7
|
+
return typeof content === 'function' ? content() : content;
|
|
8
|
+
}
|
|
5
9
|
function logoColorScheme(colorScheme) {
|
|
6
10
|
return colorScheme === 'dark' || colorScheme === 'light'
|
|
7
11
|
? `${classNames.logo}--${colorScheme}`
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import * as StripeJsTypes from '../../stripe/server/internal/html/types.js';
|
|
2
1
|
/**
|
|
3
2
|
* Duck-typed interface for the Stripe Node SDK (`stripe` npm package).
|
|
4
3
|
* Matches the subset of the API used by mppx for server-side payment verification.
|
|
@@ -31,9 +30,86 @@ export type StripeJs = {
|
|
|
31
30
|
createPaymentMethod(...args: any[]): Promise<Record<string, unknown>>;
|
|
32
31
|
elements(...args: any[]): unknown;
|
|
33
32
|
};
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
|
|
33
|
+
/** A nested Stripe.js option object, passed through to Stripe.js as is. */
|
|
34
|
+
type StripeJsObject = {
|
|
35
|
+
readonly [key: string]: any;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Stripe.js Elements appearance (`Appearance` in `@stripe/stripe-js`).
|
|
39
|
+
*
|
|
40
|
+
* @see https://docs.stripe.com/elements/appearance-api
|
|
41
|
+
*/
|
|
42
|
+
export type StripeAppearance = {
|
|
43
|
+
disableAnimations?: boolean | undefined;
|
|
44
|
+
theme?: 'stripe' | 'night' | 'flat' | undefined;
|
|
45
|
+
variables?: StripeJsObject | undefined;
|
|
46
|
+
rules?: StripeJsObject | undefined;
|
|
47
|
+
labels?: 'auto' | 'above' | 'floating' | undefined;
|
|
48
|
+
inputs?: 'spaced' | 'condensed' | undefined;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Options for `stripe.createPaymentMethod` with Elements, without `elements`
|
|
52
|
+
* (`CreatePaymentMethodFromElements` in `@stripe/stripe-js`).
|
|
53
|
+
*
|
|
54
|
+
* Structural so mppx's types don't depend on `@stripe/stripe-js`; its values stay assignable.
|
|
55
|
+
*/
|
|
56
|
+
export type CreatePaymentMethodFromElements = {
|
|
57
|
+
/** Payment method parameters (`PaymentMethodCreateParams`). */
|
|
58
|
+
params?: StripeJsObject | undefined;
|
|
59
|
+
metadata?: {
|
|
60
|
+
readonly [name: string]: string | number | null;
|
|
61
|
+
} | undefined;
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Options for `stripe.elements` in payment mode, without the fields mppx sets from the
|
|
65
|
+
* Challenge (`StripeElementsOptionsMode` in `@stripe/stripe-js`).
|
|
66
|
+
*
|
|
67
|
+
* Structural so mppx's types don't depend on `@stripe/stripe-js`; its values stay assignable.
|
|
68
|
+
*/
|
|
69
|
+
export type StripeElementsOptionsMode = {
|
|
70
|
+
adaptivePricing?: {
|
|
71
|
+
allowed?: boolean | undefined;
|
|
72
|
+
} | undefined;
|
|
73
|
+
allowedPaymentMethodTypes?: readonly string[] | undefined;
|
|
74
|
+
appearance?: StripeAppearance | undefined;
|
|
75
|
+
captureMethod?: 'manual' | 'automatic' | 'automatic_async' | undefined;
|
|
76
|
+
capture_method?: 'manual' | 'automatic' | 'automatic_async' | undefined;
|
|
77
|
+
clientSecret?: undefined;
|
|
78
|
+
customPaymentMethods?: readonly StripeJsObject[] | undefined;
|
|
79
|
+
customerOptions?: StripeJsObject | undefined;
|
|
80
|
+
customerSessionClientSecret?: string | undefined;
|
|
81
|
+
externalPaymentMethodTypes?: readonly string[] | undefined;
|
|
82
|
+
fonts?: readonly StripeJsObject[] | undefined;
|
|
83
|
+
loader?: 'auto' | 'always' | 'never' | undefined;
|
|
84
|
+
locale?: string | undefined;
|
|
85
|
+
onBehalfOf?: string | undefined;
|
|
86
|
+
on_behalf_of?: string | undefined;
|
|
87
|
+
paymentMethodConfiguration?: string | undefined;
|
|
88
|
+
payment_method_configuration?: string | undefined;
|
|
89
|
+
paymentMethodOptions?: StripeJsObject | undefined;
|
|
90
|
+
payment_method_options?: StripeJsObject | undefined;
|
|
91
|
+
setupFutureUsage?: 'off_session' | 'on_session' | null | undefined;
|
|
92
|
+
setup_future_usage?: 'off_session' | 'on_session' | null | undefined;
|
|
93
|
+
syncAddressCheckbox?: 'billing' | 'shipping' | 'none' | undefined;
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* Options for the Stripe.js Payment Element (`StripePaymentElementOptions` in `@stripe/stripe-js`).
|
|
97
|
+
*
|
|
98
|
+
* Structural so mppx's types don't depend on `@stripe/stripe-js`; its values stay assignable.
|
|
99
|
+
*/
|
|
100
|
+
export type StripePaymentElementOptions = {
|
|
101
|
+
applePay?: StripeJsObject | undefined;
|
|
102
|
+
business?: {
|
|
103
|
+
name: string;
|
|
104
|
+
} | undefined;
|
|
105
|
+
defaultValues?: StripeJsObject | undefined;
|
|
106
|
+
fields?: StripeJsObject | undefined;
|
|
107
|
+
layout?: string | StripeJsObject | undefined;
|
|
108
|
+
paymentMethodOrder?: readonly string[] | undefined;
|
|
109
|
+
readOnly?: boolean | undefined;
|
|
110
|
+
terms?: StripeJsObject | undefined;
|
|
111
|
+
walletOptions?: StripeJsObject | undefined;
|
|
112
|
+
wallets?: StripeJsObject | undefined;
|
|
113
|
+
};
|
|
114
|
+
export {};
|
|
39
115
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -5,7 +5,6 @@ import { stripePreviewVersion } from '../internal/constants.js';
|
|
|
5
5
|
import * as PaymentIntent from '../internal/payment-intent.js';
|
|
6
6
|
import * as Methods from '../Methods.js';
|
|
7
7
|
import { buildAnalytics } from './internal/analytics.js';
|
|
8
|
-
import { html as htmlContent } from './internal/html.gen.js';
|
|
9
8
|
/**
|
|
10
9
|
* Stripe's general minimum charge amounts in each currency's smallest unit.
|
|
11
10
|
* Payment methods with lower provider-specific exceptions remain conservatively
|
|
@@ -91,7 +90,7 @@ export function charge(parameters) {
|
|
|
91
90
|
html: 'publishableKey' in htmlConfig && htmlConfig.publishableKey && htmlConfig.createTokenUrl
|
|
92
91
|
? {
|
|
93
92
|
config: htmlConfig,
|
|
94
|
-
content:
|
|
93
|
+
content: async () => (await import('./internal/html.gen.js')).html,
|
|
95
94
|
formatAmount: (request) => {
|
|
96
95
|
try {
|
|
97
96
|
const formatter = new Intl.NumberFormat('en', {
|
|
@@ -7,6 +7,7 @@ import * as PaymentIntent from '../internal/payment-intent.js';
|
|
|
7
7
|
import type { StripeClient } from '../internal/types.js';
|
|
8
8
|
import { charge as charge_ } from './Charge.js';
|
|
9
9
|
import { findOrCreateDepositAddress as _findOrCreateDepositAddress } from './internal/deposit-address.js';
|
|
10
|
+
import { recordPayment as _recordPayment } from './internal/record-payment.js';
|
|
10
11
|
import { type ConnectConfig } from './internal/request.js';
|
|
11
12
|
export declare namespace stripe {
|
|
12
13
|
type Network = 'tempo' | 'base' | 'solana';
|
|
@@ -162,6 +163,7 @@ export declare namespace stripe {
|
|
|
162
163
|
const charge: typeof charge_;
|
|
163
164
|
const create: typeof stripe;
|
|
164
165
|
const findOrCreateDepositAddress: typeof _findOrCreateDepositAddress;
|
|
166
|
+
const recordPayment: typeof _recordPayment;
|
|
165
167
|
}
|
|
166
168
|
export {};
|
|
167
169
|
//# sourceMappingURL=Methods.d.ts.map
|
|
@@ -9,7 +9,7 @@ import { charge as charge_ } from './Charge.js';
|
|
|
9
9
|
import { buildAnalytics } from './internal/analytics.js';
|
|
10
10
|
import { findOrCreateDepositAddress as _findOrCreateDepositAddress } from './internal/deposit-address.js';
|
|
11
11
|
import * as HostedFeePayer from './internal/hosted-fee-payer.js';
|
|
12
|
-
import { recordCryptoPayment } from './internal/record-payment.js';
|
|
12
|
+
import { recordCryptoPayment, recordPayment as _recordPayment } from './internal/record-payment.js';
|
|
13
13
|
const defaultMethodNames = ['tempo', 'spt'];
|
|
14
14
|
const additionalBuiltinKeys = ['base', 'tempo'];
|
|
15
15
|
class DefaultMethodsBuilder {
|
|
@@ -276,6 +276,7 @@ export function stripe(parameters) {
|
|
|
276
276
|
stripe.charge = charge_;
|
|
277
277
|
stripe.create = stripe;
|
|
278
278
|
stripe.findOrCreateDepositAddress = _findOrCreateDepositAddress;
|
|
279
|
+
stripe.recordPayment = _recordPayment;
|
|
279
280
|
})(stripe || (stripe = {}));
|
|
280
281
|
function neededNetworks(excluded, additional) {
|
|
281
282
|
const networks = [];
|
|
@@ -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}))}},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,x=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)})};x.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=x})),r=t(((e,t)=>{t.exports=n()}));let i={payment:`Payment`};var a,o=e((()=>{a=`0.1.1`}));function s(){return a}var c=e((()=>{o()}));function l(e,t){return t?.(e)?e:e&&typeof e==`object`&&`cause`in e&&e.cause?l(e.cause,t):t?null:e}var u,d=e((()=>{c(),u=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 l(this,e)}},Object.defineProperty(u,\"defaultStaticOptions\",{enumerable:!0,configurable:!0,writable:!0,value:{docsOrigin:`https://oxlib.sh`,showVersion:!1,version:`ox@${s()}`}}),u.setStaticOptions(u.defaultStaticOptions)}));function f(e,t){if(y(e)>t)throw new x({givenSize:y(e),maxSize:t})}function p(e,t={}){let{dir:n,size:r=32}=t;if(r===0)return e;if(e.length>r)throw new ne({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 m=e((()=>{re()}));function h(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=>h(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)}:${h(r)}`),t},[]).join(`,`)}}`}function ee(e,t){return JSON.parse(e,(e,n)=>{let r=n;return typeof r==`string`&&r.endsWith(g)?BigInt(r.slice(0,-9)):typeof t==`function`?t(e,r):r})}var g,_=e((()=>{g=`#__bigint`}));function te(e,t={}){let{size:n}=t,r=b.encode(e);return typeof n==`number`?(f(r,n),v(r,n)):r}function v(e,t){return p(e,{dir:`right`,size:t})}function y(e){return e.length}var b,x,ne,re=e((()=>{d(),m(),_(),b=new TextEncoder,x=class extends u{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`})}},ne=class extends u{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`})}}}));re();let ie=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]))});function ae(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=ie.decode(new Uint8Array(i.buffer,0,o));return n&&a===1&&(s+=`==`),n&&a===2&&(s+=`=`),r&&(s=s.replaceAll(`+`,`-`).replaceAll(`/`,`_`)),s}function oe(e,t={}){return ae(te(e),t)}_();function se(e){return oe(h(e),{pad:!1,url:!0})}function ce(e,t){return typeof t==`bigint`?t.toString():t}var le=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}};function ue(e){return new le(e)}function de(e){return e==null}function fe(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function pe(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}let me=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function he(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ge(e){if(he(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return he(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function _e(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 ve(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 ye(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 be(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 D(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: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}let xe=/[\\uD800-\\uDBFF]/;function Se(e){let t=e.length;if(!xe.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 Ce(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function we(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}function Te(e,t){for(let n in t){let r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):De(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 Ee(e,t,n){return k(e,t,n,!1)}function De(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 Oe(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}let A,j=!1,ke={configurable:!0,get(){j=!0}};function M(e,t,n){let r=Object.getPrototypeOf(e._zod);if(t in r&&A!==e._zod){A=void 0;return}A=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,ke);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 Ae(e,t,n,r){let i=Oe(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 je;let N={value:void 0,enumerable:!1},Me=`captureStackTrace`in Error?Error:null;function Ne(e){let t=Me;if(t){let n=t.stackTraceLimit;if(typeof n==`number`){try{t.stackTraceLimit=0}catch{return Me=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function P(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){N.value=new a(r);try{Object.defineProperty(n,\"_zod\",N)}finally{N.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),Te(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?Ne(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}var F=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},Pe=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(je=globalThis).__zod_globalConfig??(je.__zod_globalConfig={});let I=globalThis.__zod_globalConfig;function L(e){return e&&Object.assign(I,e),I}function Fe(){let e=this._zod;return e.message??=JSON.stringify(e.def,ce,2),e.message}function Ie(e){this._zod.message=e}let Le={get:Fe,set:Ie,enumerable:!0,configurable:!0},R={value:void 0,enumerable:!1},Re=new WeakSet([Object.prototype,Error.prototype]),ze=(e,t)=>{e.name=`$ZodError`,R.value=t,Object.defineProperty(e,\"issues\",R),R.value=void 0,Object.defineProperty(e,\"message\",Le);let n=Object.getPrototypeOf(e);Re.has(n)||(Re.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})}}))};P(`$ZodError`,ze);let z=P(`$ZodError`,ze,void 0,{Parent:Error}),Be=(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,L())));throw me(n,a?.callee??t),n}return s.value};return t})(z),Ve=(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,L())));throw me(n,a?.callee??t),n}return s.value};return t})(z),He=(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?Ue(e,a.issues,i):{success:!0,data:a.value}})(z);function Ue(e,t,n){let r;return{success:!1,get error(){return r||(r=new e(t.map(e=>O(e,n,L()))),t=void 0,n=void 0),r},set error(e){r=e,t=void 0,n=void 0}}}let We=(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?Ue(e,a.issues,i):{success:!0,data:a.value}})(z),Ge=/^[\\s\\S]{0,}$/,Ke=/^-?\\d+(?:\\.\\d+)?$/,B=P(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),qe=e=>{let t=e.value;return!de(t)&&t.length!==void 0},Je=P(`$ZodCheckMinLength`,(e,t)=>{var n;B.init(e,t),(n=e._zod.def).when??(n.when=qe),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>=t.minimum&&i<t.minimum*2?Se(r):i)>=t.minimum)return;let a=Ce(r);n.issues.push({origin:a,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Ye=P(`$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=()=>{})}),Xe=P(`$ZodCheckRegex`,(e,t)=>{Ye.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})}}),Ze={major:4,minor:6,patch:7},V=P(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Ze;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(ye(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&&(D(t.issues,n,e),i||=w(t,n))});else{if(t.issues.length===n)continue;D(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 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 Ee(this,`~standard`,et(this))},set\"~standard\"(e){k(this,`~standard`,e)}}),Qe=(e,t)=>e.issues.length?{issues:e.issues.map(e=>O(e,t,L()))}:{value:e.value};async function $e(e,t){let n={async:!0};return Qe(await e._zod.run({value:t,issues:[]},n),n)}function et(e){return{validate:t=>{let n={async:!1};try{let r=e._zod.run({value:t,issues:[]},n);if(!(r instanceof Promise))return Qe(r,n)}catch{}return $e(e,t)},vendor:`zod`,version:1}}let tt=P(`$ZodString`,(e,t)=>{V.init(e,t),e._zod.pattern=t.pattern??Ge,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}}),nt=P(`$ZodNumber`,(e,t)=>{V.init(e,t),e._zod.pattern=Ke,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}});function rt(e,t){let n=be(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 be(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,D(n.issues,t,e),n}}return i(n,a)}}let it=e=>Array.isArray(e)?e.length:-1;function at(e,t,n){e.issues.length&&t.issues.push(...T(n,e.issues)),t.value[n]=e.value}let ot=P(`$ZodArray`,(e,t)=>{V.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=>at(t,r,e)));else if(at(c,r,e),s&&c.issues.length!==0&&w(c))break}return o.length?Promise.all(o).then(()=>r):r},rt(e,it)});function H(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}}let st=[];function ct(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:st,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=ve(e.shape);return{...e,allKeys:i,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(a)}}function lt(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=>H(e,n,i,t,d,f))):H(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}let ut=P(`$ZodObject`,(e,t)=>{V.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=ue(()=>ct(t));M(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)||pe(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=he,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(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=>H(n,t,e,r,a,o))):H(s,t,e,r,a,o)}return o?lt(l,r,t,n,i.value,e,d===!0):l.length?Promise.all(l).then(()=>t):t}});function dt(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=>O(e,r,L())))}),t)}let ft=P(`$ZodUnion`,(e,t)=>{V.init(e,t),M(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),M(e,`optout`,e=>e.def.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),M(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)))}),M(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=>fe(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=>dt(t,r,e,i)):dt(o,r,e,i)}}),pt=P(`$ZodRecord`,(e,t)=>{V.init(e,t);let n=I.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!ge(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,L())),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`&&Ke.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,L())),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}}),mt=P(`$ZodTransform`,(e,t)=>{V.init(e,t),e._zod.optin=`optional`,I.memoizer?.guard(e),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Pe(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}});function ht(e,t){return e.value=t.issues.length?void 0:t.value,e}let gt=P(`$ZodOptional`,(e,t)=>{V.init(e,t),M(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),e._zod.optout=`optional`,M(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t,void 0]):void 0}),M(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${fe(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=>ht(e,t)):ht(e,r)}return t.innerType._zod.run(e,n)}}),_t=P(`$ZodPipe`,(e,t)=>{V.init(e,t),M(e,`values`,e=>e.def.in._zod.values),M(e,`optin`,e=>e.def.in._zod.optin),M(e,`optout`,e=>e.def.out._zod.optout),M(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=>U(e,t.in,n)):U(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>U(e,t.out,n)):U(r,t.out,n)}});function U(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)}let vt=P(`$ZodCustom`,(e,t)=>{B.init(e,t),V.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=>yt(t,n,r,e));yt(i,n,r,e)}});function yt(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(we(e))}}function bt(e){return e.checks&&=[...e.checks],e}function xt(e,t){return new e(bt({type:`string`,...C(t)}))}function St(e,t){return new e(bt({type:`number`,checks:[],...C(t)}))}function W(e,t){return new Je({check:`min_length`,...C(t),minimum:e})}function Ct(e,t){return new Xe({check:`string_format`,format:`regex`,...C(t),pattern:e})}function wt(e,t,n){let r=C(n);return r.abort??=!0,new e({type:`custom`,check:`custom`,fn:t,...r})}let G=P(`ZodMiniType`,(e,t)=>{if(!e._zod)throw Error(`Uninitialized schema in ZodMiniType.`);V.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 Be(this,e,t,{callee:this.parse})},parseAsync(e,t){return Ve(this,e,t,{callee:this.parseAsync})},safeParse(e,t){return He(this,e,t)},safeParseAsync(e,t){return We(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 _e(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)}}),Tt=P(`ZodMiniString`,(e,t)=>{tt.init(e,t),G.init(e,t)});function K(e){return xt(Tt,e)}let Et=P(`ZodMiniNumber`,(e,t)=>{nt.init(e,t),G.init(e,t)});function Dt(e){return St(Et,e)}let Ot=P(`ZodMiniArray`,(e,t)=>{ot.init(e,t),G.init(e,t)});function kt(e,t){return new Ot({type:`array`,element:e,...C(t)})}let At=P(`ZodMiniObject`,(e,t)=>{ut.init(e,t),G.init(e,t),Ae(e,`shape`,e=>e._zod.def.shape,!1)});function q(e,t){let n={type:`object`,shape:e??{},...C(t)};return new At(n)}let jt=P(`ZodMiniUnion`,(e,t)=>{ft.init(e,t),G.init(e,t)});function Mt(e,t){return new jt({type:`union`,options:e,...C(t)})}let Nt=P(`ZodMiniRecord`,(e,t)=>{pt.init(e,t),G.init(e,t)});function Pt(e,t,n){return!t||!t._zod?new Nt({type:`record`,keyType:K(),valueType:e,...C(t)}):new Nt({type:`record`,keyType:e,valueType:t,...C(n)})}let Ft=P(`ZodMiniTransform`,(e,t)=>{mt.init(e,t),G.init(e,t)});function It(e){return new Ft({type:`transform`,transform:e})}let Lt=P(`ZodMiniOptional`,(e,t)=>{gt.init(e,t),G.init(e,t)});function J(e){return new Lt({type:`optional`,innerType:e})}let Rt=P(`ZodMiniPipe`,(e,t)=>{_t.init(e,t),G.init(e,t)});function zt(e,t){return new Rt({type:`pipe`,in:e,out:t})}let Bt=P(`ZodMiniCustom`,(e,t)=>{vt.init(e,t),G.init(e,t)});function Vt(e,t){return wt(Bt,e??(()=>!0),t)}function Ht(){return K().check(Ct(/^\\d+(\\.\\d+)?$/,`Invalid amount`))}function Ut(e){let{meta:t,opaque:n,request:r,...a}=e.challenge,o=n??(t===void 0?void 0:se(t)),s={challenge:{...a,...o!==void 0&&{opaque:o},request:se(r)},payload:e.payload,...e.source&&{source:e.source}},c=oe(JSON.stringify(s),{pad:!1,url:!0});return`${i.payment} ${c}`}function Wt(e){return e}function Gt(e,t){let{canHandleChallenge:n,context:r,createCredential:i}=t;return{...e,canHandleChallenge:n,context:r,createCredential:i}}function Kt(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}let qt=Mt([q({customer:J(K().check(W(1))),hooks:J(q({inputs:q({tax:q({calculation:K().check(W(1))})})})),metadata:J(Pt(K(),K())),receipt_email:J(K().check(W(1)))}),Vt(e=>typeof e==`function`)]),Jt=Wt({name:`stripe`,intent:`charge`,schema:{credential:{payload:q({externalId:J(K()),spt:K()})},request:zt(q({amount:Ht(),currency:K(),decimals:Dt(),description:J(K()),externalId:J(K()),metadata:J(Pt(K(),K())),networkId:K(),paymentIntentOptions:J(qt),paymentMethodTypes:kt(K()).check(W(1)),recipient:J(K())}),It(({amount:e,decimals:t,metadata:n,networkId:r,paymentIntentOptions:i,paymentMethodTypes:a,...o})=>({...o,amount:Kt(e,t).toString(),methodDetails:{networkId:r,paymentMethodTypes:a,...n!==void 0&&{metadata:n}}})))}});function Yt(e){let{client:t,createToken:n,externalId:r,paymentMethod:i}=e;return Gt(Jt,{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 Ut({challenge:e,payload:{spt:p,...m===void 0?{}:{externalId:m}}})}})}function Xt(e){return[Yt(e)]}(function(e){e.charge=Yt})(Xt||={});var Zt=r();let Y={data:`__MPPX_DATA__`,error:`root_error`,root:`root`},Qt={serviceWorker:`__mppx_worker`,tab:`__mppx_tab`},X={challengeId:`data-mppx-challenge-id`,remaining:`data-remaining`};var Z=class{name;constructor(e){this.name=`--mppx-${e}`}toString(){return`var(${this.name})`}};let $t={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: ${$t.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 en(e,t){if(t==null)return e;if(!Q(e)||!Q(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]=Q(t)&&Q(r)?en(t,r):r}return n}function Q(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}async function tn(e,t=`Authorization`){let n=new URL(location.href);n.searchParams.set(Qt.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()}_();function nn(e){let t=document.getElementById(Y.data),n=ee(t.textContent),r=t.getAttribute(X.remaining);!r||Number(r)<=1?t.remove():t.setAttribute(X.remaining,String(Number(r)-1));let i=document.currentScript,a=i?.getAttribute(X.challengeId),o=a?(i.removeAttribute(X.challengeId),n[a]):Object.values(n).find(t=>t.challenge.method===e);return{...o,error(e){if(!e){document.getElementById(Y.error)?.remove();return}let t=document.getElementById(Y.error);if(t){t.textContent=e;return}let n=document.createElement(`p`);n.id=Y.error,n.className=`mppx-error`,n.role=`alert`,n.textContent=e,document.getElementById(o.rootId)?.after(n)},root:document.getElementById(o.rootId),submit:e=>tn(e,o.challenge.header),vars:$t}}let $=nn(`stripe`),rn=String.raw,an=document.createElement(`style`);an.textContent=rn`\n form {\n display: flex;\n flex-direction: column;\n gap: calc(${$.vars.spacingUnit} * 8);\n }\n button {\n background: ${$.vars.accent};\n border-radius: ${$.vars.radius};\n color: ${$.vars.background};\n cursor: pointer;\n font-weight: 500;\n padding: calc(${$.vars.spacingUnit} * 4) calc(${$.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`,$.root.append(an),(async()=>{let e=await(0,Zt.loadStripe)($.config.publishableKey);if(!e)throw Error(`Failed to loadStripe`);let t=window.matchMedia(`(prefers-color-scheme: dark)`),n=()=>{let e=(()=>{if($.config.elements?.options?.appearance?.theme)return $.config.elements?.options?.appearance?.theme;switch($.theme.colorScheme){case`light dark`:return t.matches?`night`:`stripe`;case`light`:return`stripe`;case`dark`:return`night`}})(),n=+!!t.matches;return en({disableAnimations:!0,theme:e,variables:{borderRadius:$.theme.radius,colorBackground:$.theme.surface[n],colorDanger:$.theme.negative[n],colorPrimary:$.theme.accent[n],colorText:$.theme.foreground[n],colorTextSecondary:$.theme.muted[n],fontSizeBase:$.theme.fontSizeBase,fontFamily:$.theme.fontFamily,spacingUnit:$.theme.spacingUnit}},$.config.elements?.options?.appearance??{})},r=e.elements({appearance:n(),...$.config.elements?.options,amount:Number($.challenge.request.amount),currency:$.challenge.request.currency,mode:`payment`,paymentMethodCreation:`manual`,paymentMethodTypes:$.challenge.request.methodDetails.paymentMethodTypes});t.addEventListener(`change`,()=>{r.update({appearance:n()})});let i=document.createElement(`form`);r.create(`payment`,$.config.elements?.paymentOptions).mount(i),$.root.appendChild(i);let a=document.createElement(`button`);a.textContent=$.text.pay,a.type=`submit`,i.appendChild(a),i.onsubmit=async t=>{t.preventDefault(),$.error(),a.disabled=!0;try{await r.submit();let{paymentMethod:t,error:n}=await e.createPaymentMethod({...$.config.elements?.createPaymentMethodOptions,elements:r});if(n||!t)throw n??Error(`Failed to create payment method`);let i=await Xt({client:e,createToken:on})[0].createCredential({challenge:$.challenge,context:{paymentMethod:t.id}});await $.submit(i)}catch(e){$.error(e instanceof Error?e.message:`Payment failed`)}finally{a.disabled=!1}}})();async function on(e){let t=new URL($.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,x=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)})};x.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=x})),r=t(((e,t)=>{t.exports=n()}));let i={payment:`Payment`};var a,o=e((()=>{a=`0.1.1`}));function s(){return a}var c=e((()=>{o()}));function l(e,t){return t?.(e)?e:e&&typeof e==`object`&&`cause`in e&&e.cause?l(e.cause,t):t?null:e}var u,d=e((()=>{c(),u=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 l(this,e)}},Object.defineProperty(u,\"defaultStaticOptions\",{enumerable:!0,configurable:!0,writable:!0,value:{docsOrigin:`https://oxlib.sh`,showVersion:!1,version:`ox@${s()}`}}),u.setStaticOptions(u.defaultStaticOptions)}));function f(e,t){if(y(e)>t)throw new x({givenSize:y(e),maxSize:t})}function p(e,t={}){let{dir:n,size:r=32}=t;if(r===0)return e;if(e.length>r)throw new ne({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 m=e((()=>{re()}));function h(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=>h(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)}:${h(r)}`),t},[]).join(`,`)}}`}function ee(e,t){return JSON.parse(e,(e,n)=>{let r=n;return typeof r==`string`&&r.endsWith(g)?BigInt(r.slice(0,-9)):typeof t==`function`?t(e,r):r})}var g,_=e((()=>{g=`#__bigint`}));function te(e,t={}){let{size:n}=t,r=b.encode(e);return typeof n==`number`?(f(r,n),v(r,n)):r}function v(e,t){return p(e,{dir:`right`,size:t})}function y(e){return e.length}var b,x,ne,re=e((()=>{d(),m(),_(),b=new TextEncoder,x=class extends u{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`})}},ne=class extends u{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`})}}}));re();let ie=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]))});function ae(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=ie.decode(new Uint8Array(i.buffer,0,o));return n&&a===1&&(s+=`==`),n&&a===2&&(s+=`=`),r&&(s=s.replaceAll(`+`,`-`).replaceAll(`/`,`_`)),s}function oe(e,t={}){return ae(te(e),t)}_();function se(e){return oe(h(e),{pad:!1,url:!0})}function ce(e,t){return typeof t==`bigint`?t.toString():t}var le=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}};function ue(e){return new le(e)}function de(e){return e==null}function fe(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function pe(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}let me=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function C(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function he(e){if(C(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return C(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function ge(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 _e(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 ve(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 ye(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 O(e,t,n){var r;for(let i=t;i<e.length;i++)(r=e[i]).schema??(r.schema=n)}function k(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}let be=/[\\uD800-\\uDBFF]/;function xe(e){let t=e.length;if(!be.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 Se(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function Ce(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}function we(e,t){for(let n in t){let r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):Ee(e,n,r.value)}}function A(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function Te(e,t,n){return A(e,t,n,!1)}function Ee(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:A(this,t,n.bind(this))},set(e){A(this,t,e)}})}function De(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}let j,M=!1,Oe={configurable:!0,get(){M=!0}};function N(e,t,n){let r=Object.getPrototypeOf(e._zod);if(t in r&&j!==e._zod){j=void 0;return}j=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,Oe);let e=M;M=!1;try{let r=n(this);return M?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r}),M||=e,r}catch(n){throw delete this[t],M||=e,n}},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}})}function ke(e,t,n,r){let i=De(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 Ae;let P={value:void 0,enumerable:!1},je=`captureStackTrace`in Error?Error:null;function Me(e){let t=je;if(t){let n=t.stackTraceLimit;if(typeof n==`number`){try{t.stackTraceLimit=0}catch{return je=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function F(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){P.value=new a(r);try{Object.defineProperty(n,\"_zod\",P)}finally{P.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),we(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?Me(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}var I=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},Ne=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(Ae=globalThis).__zod_globalConfig??(Ae.__zod_globalConfig={});let L=globalThis.__zod_globalConfig;function R(e){return e&&Object.assign(L,e),L}function Pe(){let e=this._zod;return e.message??=JSON.stringify(e.def,ce,2),e.message}function Fe(e){this._zod.message=e}let Ie={get:Pe,set:Fe,enumerable:!0,configurable:!0},Le={value:void 0,enumerable:!1},Re=new WeakSet([Object.prototype,Error.prototype]),ze=(e,t)=>{e.name=`$ZodError`,Le.value=t,Object.defineProperty(e,\"issues\",Le),Le.value=void 0,Object.defineProperty(e,\"message\",Ie);let n=Object.getPrototypeOf(e);Re.has(n)||(Re.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})}}))};F(`$ZodError`,ze);let z=F(`$ZodError`,ze,void 0,{Parent:Error}),Be=(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 I;if(s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>k(e,o,R())));throw me(n,a?.callee??t),n}return s.value};return t})(z),Ve=(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=>k(e,o,R())));throw me(n,a?.callee??t),n}return s.value};return t})(z),He=(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 I;return a.issues.length?Ue(e,a.issues,i):{success:!0,data:a.value}})(z);function Ue(e,t,n){let r;return{success:!1,get error(){return r||(r=new e(t.map(e=>k(e,n,R()))),t=void 0,n=void 0),r},set error(e){r=e,t=void 0,n=void 0}}}let We=(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?Ue(e,a.issues,i):{success:!0,data:a.value}})(z),Ge=/^[\\s\\S]{0,}$/,Ke=/^-?\\d+(?:\\.\\d+)?$/,qe=F(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Je=e=>{let t=e.value;return!de(t)&&t.length!==void 0},Ye=F(`$ZodCheckMinLength`,(e,t)=>{var n;qe.init(e,t),(n=e._zod.def).when??(n.when=Je),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>=t.minimum&&i<t.minimum*2?xe(r):i)>=t.minimum)return;let a=Se(r);n.issues.push({origin:a,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Xe=F(`$ZodCheckStringFormat`,(e,t)=>{var n,r;qe.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=()=>{})}),Ze=F(`$ZodCheckRegex`,(e,t)=>{Xe.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})}}),Qe={major:4,minor:6,patch:7},B=F(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Qe;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(ve(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 I;if(a||s instanceof Promise)a=(a??Promise.resolve()).then(async()=>{await s,t.issues.length!==n&&(O(t.issues,n,e),i||=T(t,n))});else{if(t.issues.length===n)continue;O(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 I;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 I;return o.then(e=>t(e,i,a))}return t(o,i,a)}}},{get\"~standard\"(){return Te(this,`~standard`,tt(this))},set\"~standard\"(e){A(this,`~standard`,e)}}),$e=(e,t)=>e.issues.length?{issues:e.issues.map(e=>k(e,t,R()))}:{value:e.value};async function et(e,t){let n={async:!0};return $e(await e._zod.run({value:t,issues:[]},n),n)}function tt(e){return{validate:t=>{let n={async:!1};try{let r=e._zod.run({value:t,issues:[]},n);if(!(r instanceof Promise))return $e(r,n)}catch{}return et(e,t)},vendor:`zod`,version:1}}let nt=F(`$ZodString`,(e,t)=>{B.init(e,t),e._zod.pattern=t.pattern??Ge,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}}),rt=F(`$ZodNumber`,(e,t)=>{B.init(e,t),e._zod.pattern=Ke,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}});function it(e,t){let n=ye(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 ye(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,O(n.issues,t,e),n}}return i(n,a)}}let at=e=>Array.isArray(e)?e.length:-1;function ot(e,t,n){e.issues.length&&t.issues.push(...E(n,e.issues)),t.value[n]=e.value}let st=F(`$ZodArray`,(e,t)=>{B.init(e,t);let n=L.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=>ot(t,r,e)));else if(ot(c,r,e),s&&c.issues.length!==0&&T(c))break}return o.length?Promise.all(o).then(()=>r):r},it(e,at)});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}}let ct=[];function lt(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:ct,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=_e(e.shape);return{...e,allKeys:i,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(a)}}function ut(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}let dt=F(`$ZodObject`,(e,t)=>{B.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=ue(()=>lt(t));N(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)||pe(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=C,o=t.catchall,s,c=L.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?ut(l,r,t,n,i.value,e,d===!0):l.length?Promise.all(l).then(()=>t):t}});function ft(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=>k(e,r,R())))}),t)}let pt=F(`$ZodUnion`,(e,t)=>{B.init(e,t),N(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),N(e,`optout`,e=>e.def.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),N(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)))}),N(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=>fe(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=>ft(t,r,e,i)):ft(o,r,e,i)}}),mt=F(`$ZodRecord`,(e,t)=>{B.init(e,t);let n=L.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!he(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=>k(e,i,R())),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`&&Ke.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=>k(e,i,R())),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}}),ht=F(`$ZodTransform`,(e,t)=>{B.init(e,t),e._zod.optin=`optional`,L.memoizer?.guard(e),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Ne(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 I;return n.value=i,n}});function gt(e,t){return e.value=t.issues.length?void 0:t.value,e}let _t=F(`$ZodOptional`,(e,t)=>{B.init(e,t),N(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),e._zod.optout=`optional`,N(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t,void 0]):void 0}),N(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${fe(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=>gt(e,t)):gt(e,r)}return t.innerType._zod.run(e,n)}}),vt=F(`$ZodPipe`,(e,t)=>{B.init(e,t),N(e,`values`,e=>e.def.in._zod.values),N(e,`optin`,e=>e.def.in._zod.optin),N(e,`optout`,e=>e.def.out._zod.optout),N(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)}});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)}let yt=F(`$ZodCustom`,(e,t)=>{qe.init(e,t),B.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=>bt(t,n,r,e));bt(i,n,r,e)}});function bt(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(Ce(e))}}function xt(e){return e.checks&&=[...e.checks],e}function St(e,t){return new e(xt({type:`string`,...w(t)}))}function Ct(e,t){return new e(xt({type:`number`,checks:[],...w(t)}))}function U(e,t){return new Ye({check:`min_length`,...w(t),minimum:e})}function wt(e,t){return new Ze({check:`string_format`,format:`regex`,...w(t),pattern:e})}function Tt(e,t,n){let r=w(n);return r.abort??=!0,new e({type:`custom`,check:`custom`,fn:t,...r})}let W=F(`ZodMiniType`,(e,t)=>{if(!e._zod)throw Error(`Uninitialized schema in ZodMiniType.`);B.init(e,t),e.def=t,e.type=t.type},{get with(){return this.check},set with(e){A(this,`with`,e)},parse(e,t){return Be(this,e,t,{callee:this.parse})},parseAsync(e,t){return Ve(this,e,t,{callee:this.parseAsync})},safeParse(e,t){return He(this,e,t)},safeParseAsync(e,t){return We(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 ge(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)}}),Et=F(`ZodMiniString`,(e,t)=>{nt.init(e,t),W.init(e,t)});function G(e){return St(Et,e)}let Dt=F(`ZodMiniNumber`,(e,t)=>{rt.init(e,t),W.init(e,t)});function Ot(e){return Ct(Dt,e)}let kt=F(`ZodMiniArray`,(e,t)=>{st.init(e,t),W.init(e,t)});function At(e,t){return new kt({type:`array`,element:e,...w(t)})}let jt=F(`ZodMiniObject`,(e,t)=>{dt.init(e,t),W.init(e,t),ke(e,`shape`,e=>e._zod.def.shape,!1)});function K(e,t){let n={type:`object`,shape:e??{},...w(t)};return new jt(n)}let Mt=F(`ZodMiniUnion`,(e,t)=>{pt.init(e,t),W.init(e,t)});function Nt(e,t){return new Mt({type:`union`,options:e,...w(t)})}let Pt=F(`ZodMiniRecord`,(e,t)=>{mt.init(e,t),W.init(e,t)});function Ft(e,t,n){return!t||!t._zod?new Pt({type:`record`,keyType:G(),valueType:e,...w(t)}):new Pt({type:`record`,keyType:e,valueType:t,...w(n)})}let It=F(`ZodMiniTransform`,(e,t)=>{ht.init(e,t),W.init(e,t)});function Lt(e){return new It({type:`transform`,transform:e})}let Rt=F(`ZodMiniOptional`,(e,t)=>{_t.init(e,t),W.init(e,t)});function q(e){return new Rt({type:`optional`,innerType:e})}let zt=F(`ZodMiniPipe`,(e,t)=>{vt.init(e,t),W.init(e,t)});function Bt(e,t){return new zt({type:`pipe`,in:e,out:t})}let Vt=F(`ZodMiniCustom`,(e,t)=>{yt.init(e,t),W.init(e,t)});function Ht(e,t){return Tt(Vt,e??(()=>!0),t)}function Ut(){return G().check(wt(/^\\d+(\\.\\d+)?$/,`Invalid amount`))}function Wt(e){let{meta:t,opaque:n,request:r,...a}=e.challenge,o=n??(t===void 0?void 0:se(t)),s={challenge:{...a,...o!==void 0&&{opaque:o},request:se(r)},payload:e.payload,...e.source&&{source:e.source}},c=oe(JSON.stringify(s),{pad:!1,url:!0});return`${i.payment} ${c}`}function Gt(e){return e}function Kt(e,t){let{canHandleChallenge:n,context:r,createCredential:i}=t;return{...e,canHandleChallenge:n,context:r,createCredential:i}}function qt(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}let Jt=Nt([K({customer:q(G().check(U(1))),hooks:q(K({inputs:K({tax:K({calculation:G().check(U(1))})})})),metadata:q(Ft(G(),G())),receipt_email:q(G().check(U(1)))}),Ht(e=>typeof e==`function`)]),Yt=Gt({name:`stripe`,intent:`charge`,schema:{credential:{payload:K({externalId:q(G()),spt:G()})},request:Bt(K({amount:Ut(),currency:G(),decimals:Ot(),description:q(G()),externalId:q(G()),metadata:q(Ft(G(),G())),networkId:G(),paymentIntentOptions:q(Jt),paymentMethodTypes:At(G()).check(U(1)),recipient:q(G())}),Lt(({amount:e,decimals:t,metadata:n,networkId:r,paymentIntentOptions:i,paymentMethodTypes:a,...o})=>({...o,amount:qt(e,t).toString(),methodDetails:{networkId:r,paymentMethodTypes:a,...n!==void 0&&{metadata:n}}})))}});function Xt(e){let{client:t,createToken:n,externalId:r,paymentMethod:i}=e;return Kt(Yt,{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 Wt({challenge:e,payload:{spt:p,...m===void 0?{}:{externalId:m}}})}})}function Zt(e){return[Xt(e)]}(function(e){e.charge=Xt})(Zt||={});var Qt=r();let J={data:`__MPPX_DATA__`,error:`root_error`,root:`root`},$t={serviceWorker:`__mppx_worker`,tab:`__mppx_tab`},Y={challengeId:`data-mppx-challenge-id`,remaining:`data-remaining`};var X=class{name;constructor(e){this.name=`--mppx-${e}`}toString(){return`var(${this.name})`}};let en={accent:new X(`accent`),background:new X(`background`),border:new X(`border`),foreground:new X(`foreground`),muted:new X(`muted`),negative:new X(`negative`),positive:new X(`positive`),surface:new X(`surface`),fontFamily:new X(`font-family`),fontSizeBase:new X(`font-size-base`),radius:new X(`radius`),spacingUnit:new X(`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: ${en.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 tn(e,t){if(t==null)return e;if(!Z(e)||!Z(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]=Z(t)&&Z(r)?tn(t,r):r}return n}function Z(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}async function nn(e,t=`Authorization`){let n=new URL(location.href);n.searchParams.set($t.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()}_();function rn(e){let t=document.getElementById(J.data),n=ee(t.textContent),r=t.getAttribute(Y.remaining);!r||Number(r)<=1?t.remove():t.setAttribute(Y.remaining,String(Number(r)-1));let i=document.currentScript,a=i?.getAttribute(Y.challengeId),o=a?(i.removeAttribute(Y.challengeId),n[a]):Object.values(n).find(t=>t.challenge.method===e);return{...o,error(e){if(!e){document.getElementById(J.error)?.remove();return}let t=document.getElementById(J.error);if(t){t.textContent=e;return}let n=document.createElement(`p`);n.id=J.error,n.className=`mppx-error`,n.role=`alert`,n.textContent=e,document.getElementById(o.rootId)?.after(n)},root:document.getElementById(o.rootId),submit:e=>nn(e,o.challenge.header),vars:en}}let Q=rn(`stripe`),$=Q.config.elements,an=String.raw,on=document.createElement(`style`);on.textContent=an`\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(on),(async()=>{let e=await(0,Qt.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 tn({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 Zt({client:e,createToken:sn})[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 sn(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
|
|
@@ -15,4 +15,53 @@ export declare function recordCryptoPayment(client: StripeClient, parameters: {
|
|
|
15
15
|
analyticsMetadata: Record<string, string>;
|
|
16
16
|
paymentIntentOptions?: PaymentIntent.Options | undefined;
|
|
17
17
|
}): Promise<void>;
|
|
18
|
+
/**
|
|
19
|
+
* Records a settled crypto payment as a Stripe PaymentIntent in `transaction_verification` mode,
|
|
20
|
+
* the same call mppx makes after a Stripe-backed payment settles. Use it to record payments mppx
|
|
21
|
+
* could not, such as when the process stopped between the broadcast and the recording.
|
|
22
|
+
*
|
|
23
|
+
* The transaction hash (`reference`) is the Stripe idempotency key, as it is for mppx's own
|
|
24
|
+
* recording, so a repeat call for the same reference does not create a second PaymentIntent while
|
|
25
|
+
* Stripe keeps the key (at least 24 hours): it returns `replayed`, or `key_conflict` when an
|
|
26
|
+
* earlier call sent different parameters (such as mppx's own metadata). Stripe also caches failed
|
|
27
|
+
* responses under the key, so `key_conflict` does not mean a PaymentIntent exists: confirm it in
|
|
28
|
+
* Stripe before treating the payment as recorded. mppx's own recording uses
|
|
29
|
+
* `<reference>_fallback` instead only when Stripe rejected the server's `paymentIntentOptions`.
|
|
30
|
+
*
|
|
31
|
+
* Unlike mppx's own recording, it throws when Stripe fails, so the caller can retry.
|
|
32
|
+
*/
|
|
33
|
+
export declare function recordPayment(client: StripeClient, parameters: recordPayment.Parameters): Promise<recordPayment.ReturnType>;
|
|
34
|
+
export declare namespace recordPayment {
|
|
35
|
+
type Parameters = {
|
|
36
|
+
/** Amount in the token's raw units (6 decimals), as in the Challenge request. */
|
|
37
|
+
amount: string;
|
|
38
|
+
/** Stripe Connect settings, when the payment belongs to a connected account. */
|
|
39
|
+
connect?: ConnectConfig | undefined;
|
|
40
|
+
/** PaymentIntent metadata. */
|
|
41
|
+
metadata?: Record<string, string> | undefined;
|
|
42
|
+
/** Network the payment settled on. */
|
|
43
|
+
network: stripe.Network;
|
|
44
|
+
/** Transaction hash of the settled payment. */
|
|
45
|
+
reference: string;
|
|
46
|
+
};
|
|
47
|
+
type ReturnType = {
|
|
48
|
+
/** A PaymentIntent was created, or Stripe replayed the earlier one for this reference. */
|
|
49
|
+
status: 'created' | 'replayed';
|
|
50
|
+
paymentIntentId: string;
|
|
51
|
+
/**
|
|
52
|
+
* The PaymentIntent's Stripe status. Only `succeeded` means Stripe verified the
|
|
53
|
+
* transaction; others, such as `processing` or `requires_action`, need a later lookup.
|
|
54
|
+
*/
|
|
55
|
+
paymentIntentStatus: string;
|
|
56
|
+
} | {
|
|
57
|
+
/**
|
|
58
|
+
* An earlier call used this reference with different parameters. Stripe caches failed
|
|
59
|
+
* responses too, so whether that call created a PaymentIntent is unknown.
|
|
60
|
+
*/
|
|
61
|
+
status: 'key_conflict';
|
|
62
|
+
} | {
|
|
63
|
+
/** The amount is below Stripe's 1 cent minimum, so nothing was recorded. */
|
|
64
|
+
status: 'below_minimum';
|
|
65
|
+
};
|
|
66
|
+
}
|
|
18
67
|
//# sourceMappingURL=record-payment.d.ts.map
|
|
@@ -12,29 +12,17 @@ const NETWORK_CONFIG = {
|
|
|
12
12
|
export function recordCryptoPayment(client, parameters) {
|
|
13
13
|
const { network, reference, amount, connect, analyticsMetadata, paymentIntentOptions } = parameters;
|
|
14
14
|
const { customer, hooks, metadata, receipt_email } = paymentIntentOptions ?? {};
|
|
15
|
-
const
|
|
16
|
-
const amountCents = Number(BigInt(amount) / 10n ** BigInt(tokenDecimals - 2));
|
|
15
|
+
const amountCents = toAmountCents(network, amount);
|
|
17
16
|
if (amountCents < 1) {
|
|
18
17
|
console.warn(`[stripe] skipping PI recording: ${amount} raw units on ${network} floors to ${amountCents} cents (below Stripe minimum)`);
|
|
19
18
|
return Promise.resolve();
|
|
20
19
|
}
|
|
21
|
-
const requiredParams = {
|
|
22
|
-
|
|
23
|
-
currency: 'usd',
|
|
24
|
-
confirm: true,
|
|
25
|
-
payment_method_data: { type: 'crypto' },
|
|
26
|
-
payment_method_types: ['crypto'],
|
|
27
|
-
payment_method_options: {
|
|
28
|
-
crypto: {
|
|
29
|
-
mode: 'transaction_verification',
|
|
30
|
-
transaction_verification_options: {
|
|
31
|
-
network: stripeNetworkName,
|
|
32
|
-
transaction_hash: reference,
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
},
|
|
20
|
+
const requiredParams = paymentIntentParams({
|
|
21
|
+
amountCents,
|
|
36
22
|
metadata: analyticsMetadata,
|
|
37
|
-
|
|
23
|
+
network,
|
|
24
|
+
reference,
|
|
25
|
+
});
|
|
38
26
|
const options = {
|
|
39
27
|
idempotencyKey: reference,
|
|
40
28
|
...(connect && { connect }),
|
|
@@ -60,6 +48,75 @@ export function recordCryptoPayment(client, parameters) {
|
|
|
60
48
|
console.error('[stripe] failed to record crypto payment:', err);
|
|
61
49
|
});
|
|
62
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* Records a settled crypto payment as a Stripe PaymentIntent in `transaction_verification` mode,
|
|
53
|
+
* the same call mppx makes after a Stripe-backed payment settles. Use it to record payments mppx
|
|
54
|
+
* could not, such as when the process stopped between the broadcast and the recording.
|
|
55
|
+
*
|
|
56
|
+
* The transaction hash (`reference`) is the Stripe idempotency key, as it is for mppx's own
|
|
57
|
+
* recording, so a repeat call for the same reference does not create a second PaymentIntent while
|
|
58
|
+
* Stripe keeps the key (at least 24 hours): it returns `replayed`, or `key_conflict` when an
|
|
59
|
+
* earlier call sent different parameters (such as mppx's own metadata). Stripe also caches failed
|
|
60
|
+
* responses under the key, so `key_conflict` does not mean a PaymentIntent exists: confirm it in
|
|
61
|
+
* Stripe before treating the payment as recorded. mppx's own recording uses
|
|
62
|
+
* `<reference>_fallback` instead only when Stripe rejected the server's `paymentIntentOptions`.
|
|
63
|
+
*
|
|
64
|
+
* Unlike mppx's own recording, it throws when Stripe fails, so the caller can retry.
|
|
65
|
+
*/
|
|
66
|
+
export async function recordPayment(client, parameters) {
|
|
67
|
+
const { amount, connect, metadata = {}, network, reference } = parameters;
|
|
68
|
+
const amountCents = toAmountCents(network, amount);
|
|
69
|
+
if (amountCents < 1)
|
|
70
|
+
return { status: 'below_minimum' };
|
|
71
|
+
try {
|
|
72
|
+
const result = await createPaymentIntent(client, paymentIntentParams({ amountCents, metadata, network, reference }), { idempotencyKey: reference, ...(connect && { connect }) });
|
|
73
|
+
return {
|
|
74
|
+
paymentIntentId: result.id,
|
|
75
|
+
paymentIntentStatus: result.status,
|
|
76
|
+
status: result.replayed ? 'replayed' : 'created',
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
if (isIdempotencyError(error))
|
|
81
|
+
return { status: 'key_conflict' };
|
|
82
|
+
throw error;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
/** Converts raw token units to whole US cents, rounding down. */
|
|
86
|
+
function toAmountCents(network, amount) {
|
|
87
|
+
const { tokenDecimals } = NETWORK_CONFIG[network];
|
|
88
|
+
return Number(BigInt(amount) / 10n ** BigInt(tokenDecimals - 2));
|
|
89
|
+
}
|
|
90
|
+
/** The PaymentIntent parameters every recording sends. */
|
|
91
|
+
function paymentIntentParams(parameters) {
|
|
92
|
+
const { amountCents, metadata, network, reference } = parameters;
|
|
93
|
+
return {
|
|
94
|
+
amount: amountCents,
|
|
95
|
+
currency: 'usd',
|
|
96
|
+
confirm: true,
|
|
97
|
+
payment_method_data: { type: 'crypto' },
|
|
98
|
+
payment_method_types: ['crypto'],
|
|
99
|
+
payment_method_options: {
|
|
100
|
+
crypto: {
|
|
101
|
+
mode: 'transaction_verification',
|
|
102
|
+
transaction_verification_options: {
|
|
103
|
+
network: NETWORK_CONFIG[network].stripeNetworkName,
|
|
104
|
+
transaction_hash: reference,
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
metadata,
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
/** Returns whether Stripe rejected a reused idempotency key sent with different parameters. */
|
|
112
|
+
function isIdempotencyError(error) {
|
|
113
|
+
if (typeof error !== 'object' || error === null)
|
|
114
|
+
return false;
|
|
115
|
+
const candidate = error;
|
|
116
|
+
return (candidate.type === 'StripeIdempotencyError' ||
|
|
117
|
+
candidate.rawType === 'idempotency_error' ||
|
|
118
|
+
candidate.raw?.type === 'idempotency_error');
|
|
119
|
+
}
|
|
63
120
|
/** Returns whether Stripe definitively rejected request parameters before creating a PI. */
|
|
64
121
|
function isDefinitiveInvalidRequestError(error) {
|
|
65
122
|
if (typeof error !== 'object' || error === null)
|
package/dist/tempo/Methods.d.ts
CHANGED
|
@@ -33,6 +33,11 @@ export declare const charge: {
|
|
|
33
33
|
}, z.core.$strip>, z.ZodMiniObject<{
|
|
34
34
|
signature: z.ZodMiniString<string>;
|
|
35
35
|
type: z.ZodMiniLiteral<"proof">;
|
|
36
|
+
}, z.core.$strip>, z.ZodMiniObject<{
|
|
37
|
+
hash: z.ZodMiniString<string>;
|
|
38
|
+
senderTag: z.ZodMiniString<string>;
|
|
39
|
+
type: z.ZodMiniLiteral<"zone">;
|
|
40
|
+
zoneId: z.ZodMiniNumber<number>;
|
|
36
41
|
}, z.core.$strip>], "type">;
|
|
37
42
|
};
|
|
38
43
|
request: z.ZodMiniPipe<z.ZodMiniObject<{
|
|
@@ -55,6 +60,7 @@ export declare const charge: {
|
|
|
55
60
|
pull: "pull";
|
|
56
61
|
push: "push";
|
|
57
62
|
}>>>;
|
|
63
|
+
zones: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniLiteral<true>, z.ZodMiniArray<z.ZodMiniNumber<number>>]>>;
|
|
58
64
|
}, z.core.$strip>, z.ZodMiniTransform<{
|
|
59
65
|
currency: string;
|
|
60
66
|
description?: string | undefined;
|
|
@@ -71,6 +77,7 @@ export declare const charge: {
|
|
|
71
77
|
amount: string;
|
|
72
78
|
}[] | undefined;
|
|
73
79
|
supportedModes?: ("pull" | "push")[] | undefined;
|
|
80
|
+
zones?: true | number[] | undefined;
|
|
74
81
|
} | undefined;
|
|
75
82
|
}, {
|
|
76
83
|
machineTokenEnabled?: boolean | undefined;
|
|
@@ -89,6 +96,7 @@ export declare const charge: {
|
|
|
89
96
|
recipient: `0x${string}`;
|
|
90
97
|
}[] | undefined;
|
|
91
98
|
supportedModes?: ("pull" | "push")[] | undefined;
|
|
99
|
+
zones?: true | number[] | undefined;
|
|
92
100
|
}>>;
|
|
93
101
|
};
|
|
94
102
|
};
|
package/dist/tempo/Methods.js
CHANGED
|
@@ -2,6 +2,7 @@ import { parseUnits } from 'viem';
|
|
|
2
2
|
import * as Constants from '../Constants.js';
|
|
3
3
|
import * as Method from '../Method.js';
|
|
4
4
|
import * as z from '../zod.js';
|
|
5
|
+
import * as Zone from './internal/zone.js';
|
|
5
6
|
export const chargeModes = ['push', 'pull'];
|
|
6
7
|
const split = z.object({
|
|
7
8
|
amount: z.amount(),
|
|
@@ -79,6 +80,12 @@ export const charge = Method.from({
|
|
|
79
80
|
z.object({ hash: z.hash(), type: z.literal('hash') }),
|
|
80
81
|
z.object({ signature: z.signature(), type: z.literal('transaction') }),
|
|
81
82
|
z.object({ signature: z.signature(), type: z.literal('proof') }),
|
|
83
|
+
z.object({
|
|
84
|
+
hash: z.hash(),
|
|
85
|
+
senderTag: z.hash(),
|
|
86
|
+
type: z.literal('zone'),
|
|
87
|
+
zoneId: z.number().check(z.refine(Zone.isId, 'Invalid Zone ID')),
|
|
88
|
+
}),
|
|
82
89
|
]),
|
|
83
90
|
},
|
|
84
91
|
request: z.pipe(z
|
|
@@ -95,6 +102,13 @@ export const charge = Method.from({
|
|
|
95
102
|
recipient: z.optional(z.string()),
|
|
96
103
|
splits: z.optional(z.array(split).check(z.minLength(1), z.maxLength(10))),
|
|
97
104
|
supportedModes: z.optional(z.array(z.enum(chargeModes)).check(z.minLength(1))),
|
|
105
|
+
// Zone IDs the payee accepts withdrawals from, or true for any Zone on the challenge's chain.
|
|
106
|
+
zones: z.optional(z.union([
|
|
107
|
+
z.literal(true),
|
|
108
|
+
z
|
|
109
|
+
.array(z.number().check(z.refine(Zone.isId, 'Invalid Zone ID')))
|
|
110
|
+
.check(z.minLength(1)),
|
|
111
|
+
])),
|
|
98
112
|
})
|
|
99
113
|
.check(z.refine(({ amount, decimals, splits }) => {
|
|
100
114
|
if (!splits)
|
|
@@ -103,14 +117,15 @@ export const charge = Method.from({
|
|
|
103
117
|
const splitTotal = splits.reduce((sum, split) => sum + parseUnits(split.amount, decimals), 0n);
|
|
104
118
|
return (splits.every((split) => parseUnits(split.amount, decimals) > 0n) &&
|
|
105
119
|
splitTotal < totalAmount);
|
|
106
|
-
}, 'Invalid splits')), z.transform(({ machineTokenEnabled, amount, chainId, decimals, feePayer, memo: _memo, splits, supportedModes, ...rest }) => ({
|
|
120
|
+
}, 'Invalid splits')), z.transform(({ machineTokenEnabled, amount, chainId, decimals, feePayer, memo: _memo, splits, supportedModes, zones, ...rest }) => ({
|
|
107
121
|
...rest,
|
|
108
122
|
amount: parseUnits(amount, decimals).toString(),
|
|
109
123
|
...(machineTokenEnabled !== undefined ||
|
|
110
124
|
chainId !== undefined ||
|
|
111
125
|
feePayer !== undefined ||
|
|
112
126
|
splits !== undefined ||
|
|
113
|
-
supportedModes !== undefined
|
|
127
|
+
supportedModes !== undefined ||
|
|
128
|
+
zones !== undefined
|
|
114
129
|
? {
|
|
115
130
|
methodDetails: {
|
|
116
131
|
...(machineTokenEnabled !== undefined && { machineTokenEnabled }),
|
|
@@ -123,6 +138,7 @@ export const charge = Method.from({
|
|
|
123
138
|
})),
|
|
124
139
|
}),
|
|
125
140
|
...(supportedModes !== undefined && { supportedModes }),
|
|
141
|
+
...(zones !== undefined && { zones }),
|
|
126
142
|
},
|
|
127
143
|
}
|
|
128
144
|
: {}),
|