@halliday-sdk/payments 0.1.0-beta-1 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/paymentsWidget/ethers/index.cjs.min.js +2 -0
- package/dist/paymentsWidget/ethers/index.cjs.min.js.map +1 -0
- package/dist/paymentsWidget/ethers/index.d.ts +71 -0
- package/dist/paymentsWidget/ethers/index.esm.min.js +2 -0
- package/dist/paymentsWidget/ethers/index.esm.min.js.map +1 -0
- package/dist/paymentsWidget/ethers/index.umd.min.js +2 -0
- package/dist/paymentsWidget/ethers/index.umd.min.js.map +1 -0
- package/dist/paymentsWidget/index.cjs.min.js +1 -1
- package/dist/paymentsWidget/index.cjs.min.js.map +1 -1
- package/dist/paymentsWidget/index.d.ts +59 -52
- package/dist/paymentsWidget/index.esm.min.js +1 -1
- package/dist/paymentsWidget/index.esm.min.js.map +1 -1
- package/dist/paymentsWidget/index.umd.min.js +1 -1
- package/dist/paymentsWidget/index.umd.min.js.map +1 -1
- package/package.json +6 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";require("ethers");const r=async(r,a,e)=>{if(!a.provider)throw new Error("Signer does not have a provider");try{await a.provider.send("wallet_switchEthereumChain",[{chainId:`0x${r.toString(16)}`}])}catch(t){if(console.error("Error switching chain",t),!e)throw t;try{await(async(r,a)=>{if(!r.provider)throw new Error("Signer does not have a provider");await r.provider.send("wallet_addEthereumChain",[a])})(a,(r=>({chainId:String(r.chain_id),blockExplorerUrls:[r.explorer],chainName:r.network,iconUrls:[r.image],nativeCurrency:r.native_currency,rpcUrls:[r.rpc]}))(e)),await a.provider.send("wallet_switchEthereumChain",[{chainId:`0x${r.toString(16)}`}])}catch(r){throw console.error("Error adding chain",r),r}}};exports.connectSigner=a=>({getAddress:async()=>(await a()).getAddress(),signMessage:async({message:r,ownerAddress:e})=>{const t=await a(e);if(e){if(e!==await t.getAddress())throw new Error("Owner address does not match")}return await t.signMessage(r)},sendTransaction:async(e,t)=>{let n=await a();const i=await(n.provider?.getNetwork());i?.chainId?.toString()!==e.chainId.toString()&&(await r(e.chainId,n,t),n=await a());const s=await(async({signer:r,transaction:a,confirmations:e,timeout:t})=>{const n=await r.sendTransaction(a);return await n.wait(e,t)})({signer:n,transaction:e});return{transactionHash:(o=s).hash,blockHash:o.blockHash,blockNumber:o.blockNumber,from:o.from,to:o.to||void 0,rawReceipt:o};var o},signTypedData:async({typedData:r,ownerAddress:e})=>{const t=await a(e);if(e){if(e!==await t.getAddress())throw new Error("Owner address does not match")}return await(t.provider?.send("eth_signTypedData_v4",[e,r]))}});
|
|
2
|
+
//# sourceMappingURL=index.cjs.min.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs.min.js","sources":["../../../../_shared/utils/signerUtils.ts","../../../src/paymentsWidget/ethers/index.ts"],"sourcesContent":["import { TransactionReceipt, TransactionRequest, JsonRpcSigner, verifyMessage, toBeArray } from \"ethers\";\nimport { EVMChainConfig } from \"@shared/types\";\n\n// https://eips.ethereum.org/EIPS/eip-3085\ntype AddEthereumChainParameter = {\n chainId: string;\n blockExplorerUrls?: string[];\n chainName?: string;\n iconUrls?: string[];\n nativeCurrency?: {\n name: string;\n symbol: string;\n decimals: number;\n };\n rpcUrls?: string[];\n};\n\nexport const _getEVMChainParamFromChainConfig = (chainConfig: EVMChainConfig): AddEthereumChainParameter => ({\n chainId: String(chainConfig.chain_id),\n blockExplorerUrls: [chainConfig.explorer],\n chainName: chainConfig.network,\n iconUrls: [chainConfig.image],\n nativeCurrency: chainConfig.native_currency,\n rpcUrls: [chainConfig.rpc],\n});\n\nexport const getChainIdFromSigner = async (signer: JsonRpcSigner): Promise<number> => {\n if (!signer.provider) {\n throw new Error(\"Signer does not have a provider\");\n }\n\n const network = await signer.provider.getNetwork();\n return Number(network.chainId.toString());\n};\n\nexport const addChain = async (signer: JsonRpcSigner, chainConfig: AddEthereumChainParameter) => {\n if (!signer.provider) {\n throw new Error(\"Signer does not have a provider\");\n }\n\n await signer.provider.send(\"wallet_addEthereumChain\", [chainConfig]);\n};\n\nexport const switchChain = async (chainId: number, signer: JsonRpcSigner, chainConfig?: EVMChainConfig) => {\n if (!signer.provider) {\n throw new Error(\"Signer does not have a provider\");\n }\n\n try {\n await signer.provider.send(\"wallet_switchEthereumChain\", [{ chainId: `0x${chainId.toString(16)}` }]);\n } catch (error) {\n console.error(\"Error switching chain\", error);\n if (chainConfig) {\n try {\n await addChain(signer, _getEVMChainParamFromChainConfig(chainConfig));\n await signer.provider.send(\"wallet_switchEthereumChain\", [{ chainId: `0x${chainId.toString(16)}` }]);\n } catch (error) {\n console.error(\"Error adding chain\", error);\n throw error;\n }\n } else {\n throw error;\n }\n }\n};\n\n/**\n * Send a transaction using the signer.\n *\n * @param {JsonRpcSigner} signer {{@link JsonRpcSigner}} The signer to send the transaction.\n * @param {TransactionRequest} transaction {{@link TransactionRequest}} The transaction to send.\n * @param {number} confirmations {{@link number}} (optional) The number of confirmations to wait for default to 1.\n * @param {number} timeout {{@link number}} (optional) The timeout to wait for.\n * @returns {Promise<TransactionReceipt | null>} ``receipt`` {{@link TransactionReceipt}} The transaction receipt.\n *\n * If confirmations is 0, the promise will resolve to ``null``.\n * Check the {@link https://docs.ethers.org/v6/api/providers/#TransactionResponse-wait ethers v6 documentation} for more information.\n */\nexport const sendTransaction = async <C extends number = 1>({\n signer,\n transaction,\n confirmations,\n timeout,\n}: {\n signer: JsonRpcSigner;\n transaction: TransactionRequest;\n confirmations?: C;\n timeout?: number;\n}): Promise<C extends 0 ? null : TransactionReceipt> => {\n const txResponse = await signer.sendTransaction(transaction);\n\n return (await txResponse.wait(confirmations, timeout)) as C extends 0 ? null : TransactionReceipt;\n};\n\nexport const getSignerAddressFromMessage = (message: string, signedMessage: string) =>\n verifyMessage(toBeArray(message), signedMessage);\n","import { JsonRpcSigner, TransactionReceipt as EthersTransactionReceipt } from \"ethers\";\n\nimport { switchChain, sendTransaction as _sendTransaction } from \"@shared/utils/signerUtils\";\nimport { TransactionReceipt, Address } from \"@shared/types\";\n\nimport type { SignMessage, SendTransaction, SignTypedData } from \"../types\";\n\n/**\n * Get the transaction receipt from the ethers transaction receipt.\n *\n * @param {EthersTransactionReceipt} txReceipt The ethers transaction receipt.\n * @returns {TransactionReceipt} The transaction receipt.\n */\nconst _getTransactionReceipt = (txReceipt: EthersTransactionReceipt): TransactionReceipt => {\n return {\n transactionHash: txReceipt.hash,\n blockHash: txReceipt.blockHash,\n blockNumber: txReceipt.blockNumber,\n from: txReceipt.from,\n to: txReceipt.to || undefined,\n rawReceipt: txReceipt,\n };\n};\n\n/**\n * Connect to a signer.\n *\n * @param {function} getSigner {function} The function to get the signer.\n * @returns {function} ``getAddress`` {function} Function that returns the address of the signer.\n * @returns {function} ``signMessage`` {{@link SignMessage}} Function that signs a message.\n * @returns {function} ``sendTransaction`` {{@link SendTransaction}} Function that sends an EVM transaction.\n */\nexport const connectSigner = (\n getSigner: (address?: Address) => Promise<JsonRpcSigner>\n): {\n getAddress: () => Promise<Address>;\n signMessage: SignMessage;\n sendTransaction: SendTransaction;\n signTypedData: SignTypedData;\n} => {\n const getAddress = async (): Promise<Address> => {\n const signer = await getSigner();\n return signer.getAddress();\n };\n\n const signMessage: SignMessage = async ({ message, ownerAddress }) => {\n const signer = await getSigner(ownerAddress);\n if (ownerAddress) {\n const address = await signer.getAddress();\n if (ownerAddress !== address) {\n throw new Error(\"Owner address does not match\");\n }\n }\n const signature = await signer.signMessage(message);\n return signature;\n };\n\n const sendTransaction: SendTransaction = async (transaction, chainConfig) => {\n let signer = await getSigner();\n const signerNetwork = await signer.provider?.getNetwork();\n if (signerNetwork?.chainId?.toString() !== transaction.chainId.toString()) {\n await switchChain(transaction.chainId, signer, chainConfig);\n signer = await getSigner();\n }\n const ethersTxReceipt = await _sendTransaction({ signer, transaction });\n return _getTransactionReceipt(ethersTxReceipt);\n };\n\n const signTypedData: SignTypedData = async ({ typedData, ownerAddress }) => {\n const signer = await getSigner(ownerAddress);\n if (ownerAddress) {\n const address = await signer.getAddress();\n if (ownerAddress !== address) {\n throw new Error(\"Owner address does not match\");\n }\n }\n return await signer.provider?.send(\"eth_signTypedData_v4\", [ownerAddress, typedData]);\n };\n\n return { getAddress, signMessage, sendTransaction, signTypedData };\n};\n"],"names":["switchChain","async","chainId","signer","chainConfig","provider","Error","send","toString","error","console","addChain","String","chain_id","blockExplorerUrls","explorer","chainName","network","iconUrls","image","nativeCurrency","native_currency","rpcUrls","rpc","_getEVMChainParamFromChainConfig","getSigner","getAddress","signMessage","message","ownerAddress","sendTransaction","transaction","signerNetwork","getNetwork","ethersTxReceipt","confirmations","timeout","txResponse","wait","_sendTransaction","transactionHash","txReceipt","hash","blockHash","blockNumber","from","to","undefined","rawReceipt","signTypedData","typedData"],"mappings":"+BAiBO,MA0BMA,EAAcC,MAAOC,EAAiBC,EAAuBC,KACtE,IAAKD,EAAOE,SACR,MAAM,IAAIC,MAAM,mCAGpB,UACUH,EAAOE,SAASE,KAAK,6BAA8B,CAAC,CAAEL,QAAS,KAAKA,EAAQM,SAAS,SAC7F,MAAOC,GAEL,GADAC,QAAQD,MAAM,wBAAyBA,IACnCL,EASA,MAAMK,EARN,SAlBYR,OAAOE,EAAuBC,KAClD,IAAKD,EAAOE,SACR,MAAM,IAAIC,MAAM,yCAGdH,EAAOE,SAASE,KAAK,0BAA2B,CAACH,GAAa,EAclDO,CAASR,EArCiB,CAACC,IAA4D,CACzGF,QAASU,OAAOR,EAAYS,UAC5BC,kBAAmB,CAACV,EAAYW,UAChCC,UAAWZ,EAAYa,QACvBC,SAAU,CAACd,EAAYe,OACvBC,eAAgBhB,EAAYiB,gBAC5BC,QAAS,CAAClB,EAAYmB,OA+BaC,CAAiCpB,UAClDD,EAAOE,SAASE,KAAK,6BAA8B,CAAC,CAAEL,QAAS,KAAKA,EAAQM,SAAS,SAC7F,MAAOC,GAEL,MADAC,QAAQD,MAAM,qBAAsBA,GAC9BA,2BCzBlBgB,IA8CO,CAAEC,WAvCUzB,gBACMwB,KACPC,aAqCGC,YAlCY1B,OAAS2B,UAASC,mBAC/C,MAAM1B,QAAesB,EAAUI,GAC/B,GAAIA,EAAc,CAEd,GAAIA,UADkB1B,EAAOuB,aAEzB,MAAM,IAAIpB,MAAM,gCAIxB,aADwBH,EAAOwB,YAAYC,EAC3B,EAyBcE,gBAtBO7B,MAAO8B,EAAa3B,KACzD,IAAID,QAAesB,IACnB,MAAMO,QAAsB7B,EAAOE,UAAU4B,cACzCD,GAAe9B,SAASM,aAAeuB,EAAY7B,QAAQM,mBACrDR,EAAY+B,EAAY7B,QAASC,EAAQC,GAC/CD,QAAesB,KAEnB,MAAMS,ODciBjC,QAC3BE,SACA4B,cACAI,gBACAC,cAOA,MAAMC,QAAmBlC,EAAO2B,gBAAgBC,GAEhD,aAAcM,EAAWC,KAAKH,EAAeC,EAAQ,EC3BnBG,CAAiB,CAAEpC,SAAQ4B,gBACzD,MAnDG,CACHS,iBAFwBC,EAoDMP,GAlDHQ,KAC3BC,UAAWF,EAAUE,UACrBC,YAAaH,EAAUG,YACvBC,KAAMJ,EAAUI,KAChBC,GAAIL,EAAUK,SAAMC,EACpBC,WAAYP,GAPW,IAACA,CAoDsB,EAcCQ,cAXdhD,OAASiD,YAAWrB,mBACrD,MAAM1B,QAAesB,EAAUI,GAC/B,GAAIA,EAAc,CAEd,GAAIA,UADkB1B,EAAOuB,aAEzB,MAAM,IAAIpB,MAAM,gCAGxB,aAAaH,EAAOE,UAAUE,KAAK,uBAAwB,CAACsB,EAAcqB,IAAW"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { JsonRpcSigner } from 'ethers';
|
|
2
|
+
import { z } from 'zod/v4';
|
|
3
|
+
|
|
4
|
+
declare const Address: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
|
|
5
|
+
type Address = z.infer<typeof Address>;
|
|
6
|
+
declare const TransactionRequest: z.ZodObject<{
|
|
7
|
+
to: z.ZodString;
|
|
8
|
+
from: z.ZodOptional<z.ZodString>;
|
|
9
|
+
nonce: z.ZodOptional<z.ZodNumber>;
|
|
10
|
+
gasLimit: z.ZodOptional<z.ZodBigInt>;
|
|
11
|
+
gasPrice: z.ZodOptional<z.ZodBigInt>;
|
|
12
|
+
maxPriorityFeePerGas: z.ZodOptional<z.ZodBigInt>;
|
|
13
|
+
maxFeePerGas: z.ZodOptional<z.ZodBigInt>;
|
|
14
|
+
data: z.ZodOptional<z.ZodString>;
|
|
15
|
+
value: z.ZodOptional<z.ZodBigInt>;
|
|
16
|
+
chainId: z.ZodNumber;
|
|
17
|
+
}, z.core.$strip>;
|
|
18
|
+
type TransactionRequest = z.infer<typeof TransactionRequest>;
|
|
19
|
+
declare const TransactionReceipt: z.ZodObject<{
|
|
20
|
+
transactionHash: z.ZodOptional<z.ZodString>;
|
|
21
|
+
blockHash: z.ZodOptional<z.ZodString>;
|
|
22
|
+
blockNumber: z.ZodOptional<z.ZodNumber>;
|
|
23
|
+
from: z.ZodOptional<z.ZodString>;
|
|
24
|
+
to: z.ZodOptional<z.ZodString>;
|
|
25
|
+
rawReceipt: z.ZodAny;
|
|
26
|
+
}, z.core.$strip>;
|
|
27
|
+
type TransactionReceipt = z.infer<typeof TransactionReceipt>;
|
|
28
|
+
declare const EVMChainConfig: z.ZodObject<{
|
|
29
|
+
chain_id: z.ZodNumber;
|
|
30
|
+
network: z.ZodString;
|
|
31
|
+
native_currency: z.ZodObject<{
|
|
32
|
+
name: z.ZodString;
|
|
33
|
+
symbol: z.ZodString;
|
|
34
|
+
decimals: z.ZodNumber;
|
|
35
|
+
}, z.core.$strip>;
|
|
36
|
+
rpc: z.ZodString;
|
|
37
|
+
image: z.ZodString;
|
|
38
|
+
is_testnet: z.ZodBoolean;
|
|
39
|
+
explorer: z.ZodString;
|
|
40
|
+
}, z.core.$strip>;
|
|
41
|
+
type EVMChainConfig = z.infer<typeof EVMChainConfig>;
|
|
42
|
+
|
|
43
|
+
declare const TypedData: z.ZodString;
|
|
44
|
+
type TypedData = z.infer<typeof TypedData>;
|
|
45
|
+
|
|
46
|
+
type SignMessage = (input: {
|
|
47
|
+
message: string;
|
|
48
|
+
ownerAddress?: Address;
|
|
49
|
+
}) => Promise<string>;
|
|
50
|
+
type SignTypedData = (input: {
|
|
51
|
+
typedData: TypedData;
|
|
52
|
+
ownerAddress?: Address;
|
|
53
|
+
}) => Promise<string>;
|
|
54
|
+
type SendTransaction = (transaction: TransactionRequest, chainConfig: EVMChainConfig) => Promise<TransactionReceipt>;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Connect to a signer.
|
|
58
|
+
*
|
|
59
|
+
* @param {function} getSigner {function} The function to get the signer.
|
|
60
|
+
* @returns {function} ``getAddress`` {function} Function that returns the address of the signer.
|
|
61
|
+
* @returns {function} ``signMessage`` {{@link SignMessage}} Function that signs a message.
|
|
62
|
+
* @returns {function} ``sendTransaction`` {{@link SendTransaction}} Function that sends an EVM transaction.
|
|
63
|
+
*/
|
|
64
|
+
declare const connectSigner: (getSigner: (address?: Address) => Promise<JsonRpcSigner>) => {
|
|
65
|
+
getAddress: () => Promise<Address>;
|
|
66
|
+
signMessage: SignMessage;
|
|
67
|
+
sendTransaction: SendTransaction;
|
|
68
|
+
signTypedData: SignTypedData;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export { connectSigner };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import"ethers";const r=async(r,a,t)=>{if(!a.provider)throw new Error("Signer does not have a provider");try{await a.provider.send("wallet_switchEthereumChain",[{chainId:`0x${r.toString(16)}`}])}catch(e){if(console.error("Error switching chain",e),!t)throw e;try{await(async(r,a)=>{if(!r.provider)throw new Error("Signer does not have a provider");await r.provider.send("wallet_addEthereumChain",[a])})(a,(r=>({chainId:String(r.chain_id),blockExplorerUrls:[r.explorer],chainName:r.network,iconUrls:[r.image],nativeCurrency:r.native_currency,rpcUrls:[r.rpc]}))(t)),await a.provider.send("wallet_switchEthereumChain",[{chainId:`0x${r.toString(16)}`}])}catch(r){throw console.error("Error adding chain",r),r}}},a=a=>({getAddress:async()=>(await a()).getAddress(),signMessage:async({message:r,ownerAddress:t})=>{const e=await a(t);if(t){if(t!==await e.getAddress())throw new Error("Owner address does not match")}return await e.signMessage(r)},sendTransaction:async(t,e)=>{let n=await a();const i=await(n.provider?.getNetwork());i?.chainId?.toString()!==t.chainId.toString()&&(await r(t.chainId,n,e),n=await a());const o=await(async({signer:r,transaction:a,confirmations:t,timeout:e})=>{const n=await r.sendTransaction(a);return await n.wait(t,e)})({signer:n,transaction:t});return{transactionHash:(s=o).hash,blockHash:s.blockHash,blockNumber:s.blockNumber,from:s.from,to:s.to||void 0,rawReceipt:s};var s},signTypedData:async({typedData:r,ownerAddress:t})=>{const e=await a(t);if(t){if(t!==await e.getAddress())throw new Error("Owner address does not match")}return await(e.provider?.send("eth_signTypedData_v4",[t,r]))}});export{a as connectSigner};
|
|
2
|
+
//# sourceMappingURL=index.esm.min.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.esm.min.js","sources":["../../../../_shared/utils/signerUtils.ts","../../../src/paymentsWidget/ethers/index.ts"],"sourcesContent":["import { TransactionReceipt, TransactionRequest, JsonRpcSigner, verifyMessage, toBeArray } from \"ethers\";\nimport { EVMChainConfig } from \"@shared/types\";\n\n// https://eips.ethereum.org/EIPS/eip-3085\ntype AddEthereumChainParameter = {\n chainId: string;\n blockExplorerUrls?: string[];\n chainName?: string;\n iconUrls?: string[];\n nativeCurrency?: {\n name: string;\n symbol: string;\n decimals: number;\n };\n rpcUrls?: string[];\n};\n\nexport const _getEVMChainParamFromChainConfig = (chainConfig: EVMChainConfig): AddEthereumChainParameter => ({\n chainId: String(chainConfig.chain_id),\n blockExplorerUrls: [chainConfig.explorer],\n chainName: chainConfig.network,\n iconUrls: [chainConfig.image],\n nativeCurrency: chainConfig.native_currency,\n rpcUrls: [chainConfig.rpc],\n});\n\nexport const getChainIdFromSigner = async (signer: JsonRpcSigner): Promise<number> => {\n if (!signer.provider) {\n throw new Error(\"Signer does not have a provider\");\n }\n\n const network = await signer.provider.getNetwork();\n return Number(network.chainId.toString());\n};\n\nexport const addChain = async (signer: JsonRpcSigner, chainConfig: AddEthereumChainParameter) => {\n if (!signer.provider) {\n throw new Error(\"Signer does not have a provider\");\n }\n\n await signer.provider.send(\"wallet_addEthereumChain\", [chainConfig]);\n};\n\nexport const switchChain = async (chainId: number, signer: JsonRpcSigner, chainConfig?: EVMChainConfig) => {\n if (!signer.provider) {\n throw new Error(\"Signer does not have a provider\");\n }\n\n try {\n await signer.provider.send(\"wallet_switchEthereumChain\", [{ chainId: `0x${chainId.toString(16)}` }]);\n } catch (error) {\n console.error(\"Error switching chain\", error);\n if (chainConfig) {\n try {\n await addChain(signer, _getEVMChainParamFromChainConfig(chainConfig));\n await signer.provider.send(\"wallet_switchEthereumChain\", [{ chainId: `0x${chainId.toString(16)}` }]);\n } catch (error) {\n console.error(\"Error adding chain\", error);\n throw error;\n }\n } else {\n throw error;\n }\n }\n};\n\n/**\n * Send a transaction using the signer.\n *\n * @param {JsonRpcSigner} signer {{@link JsonRpcSigner}} The signer to send the transaction.\n * @param {TransactionRequest} transaction {{@link TransactionRequest}} The transaction to send.\n * @param {number} confirmations {{@link number}} (optional) The number of confirmations to wait for default to 1.\n * @param {number} timeout {{@link number}} (optional) The timeout to wait for.\n * @returns {Promise<TransactionReceipt | null>} ``receipt`` {{@link TransactionReceipt}} The transaction receipt.\n *\n * If confirmations is 0, the promise will resolve to ``null``.\n * Check the {@link https://docs.ethers.org/v6/api/providers/#TransactionResponse-wait ethers v6 documentation} for more information.\n */\nexport const sendTransaction = async <C extends number = 1>({\n signer,\n transaction,\n confirmations,\n timeout,\n}: {\n signer: JsonRpcSigner;\n transaction: TransactionRequest;\n confirmations?: C;\n timeout?: number;\n}): Promise<C extends 0 ? null : TransactionReceipt> => {\n const txResponse = await signer.sendTransaction(transaction);\n\n return (await txResponse.wait(confirmations, timeout)) as C extends 0 ? null : TransactionReceipt;\n};\n\nexport const getSignerAddressFromMessage = (message: string, signedMessage: string) =>\n verifyMessage(toBeArray(message), signedMessage);\n","import { JsonRpcSigner, TransactionReceipt as EthersTransactionReceipt } from \"ethers\";\n\nimport { switchChain, sendTransaction as _sendTransaction } from \"@shared/utils/signerUtils\";\nimport { TransactionReceipt, Address } from \"@shared/types\";\n\nimport type { SignMessage, SendTransaction, SignTypedData } from \"../types\";\n\n/**\n * Get the transaction receipt from the ethers transaction receipt.\n *\n * @param {EthersTransactionReceipt} txReceipt The ethers transaction receipt.\n * @returns {TransactionReceipt} The transaction receipt.\n */\nconst _getTransactionReceipt = (txReceipt: EthersTransactionReceipt): TransactionReceipt => {\n return {\n transactionHash: txReceipt.hash,\n blockHash: txReceipt.blockHash,\n blockNumber: txReceipt.blockNumber,\n from: txReceipt.from,\n to: txReceipt.to || undefined,\n rawReceipt: txReceipt,\n };\n};\n\n/**\n * Connect to a signer.\n *\n * @param {function} getSigner {function} The function to get the signer.\n * @returns {function} ``getAddress`` {function} Function that returns the address of the signer.\n * @returns {function} ``signMessage`` {{@link SignMessage}} Function that signs a message.\n * @returns {function} ``sendTransaction`` {{@link SendTransaction}} Function that sends an EVM transaction.\n */\nexport const connectSigner = (\n getSigner: (address?: Address) => Promise<JsonRpcSigner>\n): {\n getAddress: () => Promise<Address>;\n signMessage: SignMessage;\n sendTransaction: SendTransaction;\n signTypedData: SignTypedData;\n} => {\n const getAddress = async (): Promise<Address> => {\n const signer = await getSigner();\n return signer.getAddress();\n };\n\n const signMessage: SignMessage = async ({ message, ownerAddress }) => {\n const signer = await getSigner(ownerAddress);\n if (ownerAddress) {\n const address = await signer.getAddress();\n if (ownerAddress !== address) {\n throw new Error(\"Owner address does not match\");\n }\n }\n const signature = await signer.signMessage(message);\n return signature;\n };\n\n const sendTransaction: SendTransaction = async (transaction, chainConfig) => {\n let signer = await getSigner();\n const signerNetwork = await signer.provider?.getNetwork();\n if (signerNetwork?.chainId?.toString() !== transaction.chainId.toString()) {\n await switchChain(transaction.chainId, signer, chainConfig);\n signer = await getSigner();\n }\n const ethersTxReceipt = await _sendTransaction({ signer, transaction });\n return _getTransactionReceipt(ethersTxReceipt);\n };\n\n const signTypedData: SignTypedData = async ({ typedData, ownerAddress }) => {\n const signer = await getSigner(ownerAddress);\n if (ownerAddress) {\n const address = await signer.getAddress();\n if (ownerAddress !== address) {\n throw new Error(\"Owner address does not match\");\n }\n }\n return await signer.provider?.send(\"eth_signTypedData_v4\", [ownerAddress, typedData]);\n };\n\n return { getAddress, signMessage, sendTransaction, signTypedData };\n};\n"],"names":["switchChain","async","chainId","signer","chainConfig","provider","Error","send","toString","error","console","addChain","String","chain_id","blockExplorerUrls","explorer","chainName","network","iconUrls","image","nativeCurrency","native_currency","rpcUrls","rpc","_getEVMChainParamFromChainConfig","connectSigner","getSigner","getAddress","signMessage","message","ownerAddress","sendTransaction","transaction","signerNetwork","getNetwork","ethersTxReceipt","confirmations","timeout","txResponse","wait","_sendTransaction","transactionHash","txReceipt","hash","blockHash","blockNumber","from","to","undefined","rawReceipt","signTypedData","typedData"],"mappings":"eAiBO,MA0BMA,EAAcC,MAAOC,EAAiBC,EAAuBC,KACtE,IAAKD,EAAOE,SACR,MAAM,IAAIC,MAAM,mCAGpB,UACUH,EAAOE,SAASE,KAAK,6BAA8B,CAAC,CAAEL,QAAS,KAAKA,EAAQM,SAAS,SAC7F,MAAOC,GAEL,GADAC,QAAQD,MAAM,wBAAyBA,IACnCL,EASA,MAAMK,EARN,SAlBYR,OAAOE,EAAuBC,KAClD,IAAKD,EAAOE,SACR,MAAM,IAAIC,MAAM,yCAGdH,EAAOE,SAASE,KAAK,0BAA2B,CAACH,GAAa,EAclDO,CAASR,EArCiB,CAACC,IAA4D,CACzGF,QAASU,OAAOR,EAAYS,UAC5BC,kBAAmB,CAACV,EAAYW,UAChCC,UAAWZ,EAAYa,QACvBC,SAAU,CAACd,EAAYe,OACvBC,eAAgBhB,EAAYiB,gBAC5BC,QAAS,CAAClB,EAAYmB,OA+BaC,CAAiCpB,UAClDD,EAAOE,SAASE,KAAK,6BAA8B,CAAC,CAAEL,QAAS,KAAKA,EAAQM,SAAS,SAC7F,MAAOC,GAEL,MADAC,QAAQD,MAAM,qBAAsBA,GAC9BA,KC1BTgB,EACTC,IA8CO,CAAEC,WAvCU1B,gBACMyB,KACPC,aAqCGC,YAlCY3B,OAAS4B,UAASC,mBAC/C,MAAM3B,QAAeuB,EAAUI,GAC/B,GAAIA,EAAc,CAEd,GAAIA,UADkB3B,EAAOwB,aAEzB,MAAM,IAAIrB,MAAM,gCAIxB,aADwBH,EAAOyB,YAAYC,EAC3B,EAyBcE,gBAtBO9B,MAAO+B,EAAa5B,KACzD,IAAID,QAAeuB,IACnB,MAAMO,QAAsB9B,EAAOE,UAAU6B,cACzCD,GAAe/B,SAASM,aAAewB,EAAY9B,QAAQM,mBACrDR,EAAYgC,EAAY9B,QAASC,EAAQC,GAC/CD,QAAeuB,KAEnB,MAAMS,ODciBlC,QAC3BE,SACA6B,cACAI,gBACAC,cAOA,MAAMC,QAAmBnC,EAAO4B,gBAAgBC,GAEhD,aAAcM,EAAWC,KAAKH,EAAeC,EAAQ,EC3BnBG,CAAiB,CAAErC,SAAQ6B,gBACzD,MAnDG,CACHS,iBAFwBC,EAoDMP,GAlDHQ,KAC3BC,UAAWF,EAAUE,UACrBC,YAAaH,EAAUG,YACvBC,KAAMJ,EAAUI,KAChBC,GAAIL,EAAUK,SAAMC,EACpBC,WAAYP,GAPW,IAACA,CAoDsB,EAcCQ,cAXdjD,OAASkD,YAAWrB,mBACrD,MAAM3B,QAAeuB,EAAUI,GAC/B,GAAIA,EAAc,CAEd,GAAIA,UADkB3B,EAAOwB,aAEzB,MAAM,IAAIrB,MAAM,gCAGxB,aAAaH,EAAOE,UAAUE,KAAK,uBAAwB,CAACuB,EAAcqB,IAAW"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("ethers")):"function"==typeof define&&define.amd?define(["exports","ethers"],r):r((e="undefined"!=typeof globalThis?globalThis:e||self).ethers={})}(this,(function(e){"use strict";const r=async(e,r,t)=>{if(!r.provider)throw new Error("Signer does not have a provider");try{await r.provider.send("wallet_switchEthereumChain",[{chainId:`0x${e.toString(16)}`}])}catch(a){if(console.error("Error switching chain",a),!t)throw a;try{await(async(e,r)=>{if(!e.provider)throw new Error("Signer does not have a provider");await e.provider.send("wallet_addEthereumChain",[r])})(r,(e=>({chainId:String(e.chain_id),blockExplorerUrls:[e.explorer],chainName:e.network,iconUrls:[e.image],nativeCurrency:e.native_currency,rpcUrls:[e.rpc]}))(t)),await r.provider.send("wallet_switchEthereumChain",[{chainId:`0x${e.toString(16)}`}])}catch(e){throw console.error("Error adding chain",e),e}}};e.connectSigner=e=>({getAddress:async()=>(await e()).getAddress(),signMessage:async({message:r,ownerAddress:t})=>{const a=await e(t);if(t){if(t!==await a.getAddress())throw new Error("Owner address does not match")}return await a.signMessage(r)},sendTransaction:async(t,a)=>{let n=await e();const i=await(n.provider?.getNetwork());i?.chainId?.toString()!==t.chainId.toString()&&(await r(t.chainId,n,a),n=await e());const o=await(async({signer:e,transaction:r,confirmations:t,timeout:a})=>{const n=await e.sendTransaction(r);return await n.wait(t,a)})({signer:n,transaction:t});return{transactionHash:(s=o).hash,blockHash:s.blockHash,blockNumber:s.blockNumber,from:s.from,to:s.to||void 0,rawReceipt:s};var s},signTypedData:async({typedData:r,ownerAddress:t})=>{const a=await e(t);if(t){if(t!==await a.getAddress())throw new Error("Owner address does not match")}return await(a.provider?.send("eth_signTypedData_v4",[t,r]))}})}));
|
|
2
|
+
//# sourceMappingURL=index.umd.min.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.umd.min.js","sources":["../../../../_shared/utils/signerUtils.ts","../../../src/paymentsWidget/ethers/index.ts"],"sourcesContent":["import { TransactionReceipt, TransactionRequest, JsonRpcSigner, verifyMessage, toBeArray } from \"ethers\";\nimport { EVMChainConfig } from \"@shared/types\";\n\n// https://eips.ethereum.org/EIPS/eip-3085\ntype AddEthereumChainParameter = {\n chainId: string;\n blockExplorerUrls?: string[];\n chainName?: string;\n iconUrls?: string[];\n nativeCurrency?: {\n name: string;\n symbol: string;\n decimals: number;\n };\n rpcUrls?: string[];\n};\n\nexport const _getEVMChainParamFromChainConfig = (chainConfig: EVMChainConfig): AddEthereumChainParameter => ({\n chainId: String(chainConfig.chain_id),\n blockExplorerUrls: [chainConfig.explorer],\n chainName: chainConfig.network,\n iconUrls: [chainConfig.image],\n nativeCurrency: chainConfig.native_currency,\n rpcUrls: [chainConfig.rpc],\n});\n\nexport const getChainIdFromSigner = async (signer: JsonRpcSigner): Promise<number> => {\n if (!signer.provider) {\n throw new Error(\"Signer does not have a provider\");\n }\n\n const network = await signer.provider.getNetwork();\n return Number(network.chainId.toString());\n};\n\nexport const addChain = async (signer: JsonRpcSigner, chainConfig: AddEthereumChainParameter) => {\n if (!signer.provider) {\n throw new Error(\"Signer does not have a provider\");\n }\n\n await signer.provider.send(\"wallet_addEthereumChain\", [chainConfig]);\n};\n\nexport const switchChain = async (chainId: number, signer: JsonRpcSigner, chainConfig?: EVMChainConfig) => {\n if (!signer.provider) {\n throw new Error(\"Signer does not have a provider\");\n }\n\n try {\n await signer.provider.send(\"wallet_switchEthereumChain\", [{ chainId: `0x${chainId.toString(16)}` }]);\n } catch (error) {\n console.error(\"Error switching chain\", error);\n if (chainConfig) {\n try {\n await addChain(signer, _getEVMChainParamFromChainConfig(chainConfig));\n await signer.provider.send(\"wallet_switchEthereumChain\", [{ chainId: `0x${chainId.toString(16)}` }]);\n } catch (error) {\n console.error(\"Error adding chain\", error);\n throw error;\n }\n } else {\n throw error;\n }\n }\n};\n\n/**\n * Send a transaction using the signer.\n *\n * @param {JsonRpcSigner} signer {{@link JsonRpcSigner}} The signer to send the transaction.\n * @param {TransactionRequest} transaction {{@link TransactionRequest}} The transaction to send.\n * @param {number} confirmations {{@link number}} (optional) The number of confirmations to wait for default to 1.\n * @param {number} timeout {{@link number}} (optional) The timeout to wait for.\n * @returns {Promise<TransactionReceipt | null>} ``receipt`` {{@link TransactionReceipt}} The transaction receipt.\n *\n * If confirmations is 0, the promise will resolve to ``null``.\n * Check the {@link https://docs.ethers.org/v6/api/providers/#TransactionResponse-wait ethers v6 documentation} for more information.\n */\nexport const sendTransaction = async <C extends number = 1>({\n signer,\n transaction,\n confirmations,\n timeout,\n}: {\n signer: JsonRpcSigner;\n transaction: TransactionRequest;\n confirmations?: C;\n timeout?: number;\n}): Promise<C extends 0 ? null : TransactionReceipt> => {\n const txResponse = await signer.sendTransaction(transaction);\n\n return (await txResponse.wait(confirmations, timeout)) as C extends 0 ? null : TransactionReceipt;\n};\n\nexport const getSignerAddressFromMessage = (message: string, signedMessage: string) =>\n verifyMessage(toBeArray(message), signedMessage);\n","import { JsonRpcSigner, TransactionReceipt as EthersTransactionReceipt } from \"ethers\";\n\nimport { switchChain, sendTransaction as _sendTransaction } from \"@shared/utils/signerUtils\";\nimport { TransactionReceipt, Address } from \"@shared/types\";\n\nimport type { SignMessage, SendTransaction, SignTypedData } from \"../types\";\n\n/**\n * Get the transaction receipt from the ethers transaction receipt.\n *\n * @param {EthersTransactionReceipt} txReceipt The ethers transaction receipt.\n * @returns {TransactionReceipt} The transaction receipt.\n */\nconst _getTransactionReceipt = (txReceipt: EthersTransactionReceipt): TransactionReceipt => {\n return {\n transactionHash: txReceipt.hash,\n blockHash: txReceipt.blockHash,\n blockNumber: txReceipt.blockNumber,\n from: txReceipt.from,\n to: txReceipt.to || undefined,\n rawReceipt: txReceipt,\n };\n};\n\n/**\n * Connect to a signer.\n *\n * @param {function} getSigner {function} The function to get the signer.\n * @returns {function} ``getAddress`` {function} Function that returns the address of the signer.\n * @returns {function} ``signMessage`` {{@link SignMessage}} Function that signs a message.\n * @returns {function} ``sendTransaction`` {{@link SendTransaction}} Function that sends an EVM transaction.\n */\nexport const connectSigner = (\n getSigner: (address?: Address) => Promise<JsonRpcSigner>\n): {\n getAddress: () => Promise<Address>;\n signMessage: SignMessage;\n sendTransaction: SendTransaction;\n signTypedData: SignTypedData;\n} => {\n const getAddress = async (): Promise<Address> => {\n const signer = await getSigner();\n return signer.getAddress();\n };\n\n const signMessage: SignMessage = async ({ message, ownerAddress }) => {\n const signer = await getSigner(ownerAddress);\n if (ownerAddress) {\n const address = await signer.getAddress();\n if (ownerAddress !== address) {\n throw new Error(\"Owner address does not match\");\n }\n }\n const signature = await signer.signMessage(message);\n return signature;\n };\n\n const sendTransaction: SendTransaction = async (transaction, chainConfig) => {\n let signer = await getSigner();\n const signerNetwork = await signer.provider?.getNetwork();\n if (signerNetwork?.chainId?.toString() !== transaction.chainId.toString()) {\n await switchChain(transaction.chainId, signer, chainConfig);\n signer = await getSigner();\n }\n const ethersTxReceipt = await _sendTransaction({ signer, transaction });\n return _getTransactionReceipt(ethersTxReceipt);\n };\n\n const signTypedData: SignTypedData = async ({ typedData, ownerAddress }) => {\n const signer = await getSigner(ownerAddress);\n if (ownerAddress) {\n const address = await signer.getAddress();\n if (ownerAddress !== address) {\n throw new Error(\"Owner address does not match\");\n }\n }\n return await signer.provider?.send(\"eth_signTypedData_v4\", [ownerAddress, typedData]);\n };\n\n return { getAddress, signMessage, sendTransaction, signTypedData };\n};\n"],"names":["switchChain","async","chainId","signer","chainConfig","provider","Error","send","toString","error","console","addChain","String","chain_id","blockExplorerUrls","explorer","chainName","network","iconUrls","image","nativeCurrency","native_currency","rpcUrls","rpc","_getEVMChainParamFromChainConfig","getSigner","getAddress","signMessage","message","ownerAddress","sendTransaction","transaction","signerNetwork","getNetwork","ethersTxReceipt","confirmations","timeout","txResponse","wait","_sendTransaction","transactionHash","txReceipt","hash","blockHash","blockNumber","from","to","undefined","rawReceipt","signTypedData","typedData"],"mappings":"yQAiBO,MA0BMA,EAAcC,MAAOC,EAAiBC,EAAuBC,KACtE,IAAKD,EAAOE,SACR,MAAM,IAAIC,MAAM,mCAGpB,UACUH,EAAOE,SAASE,KAAK,6BAA8B,CAAC,CAAEL,QAAS,KAAKA,EAAQM,SAAS,SAC7F,MAAOC,GAEL,GADAC,QAAQD,MAAM,wBAAyBA,IACnCL,EASA,MAAMK,EARN,SAlBYR,OAAOE,EAAuBC,KAClD,IAAKD,EAAOE,SACR,MAAM,IAAIC,MAAM,yCAGdH,EAAOE,SAASE,KAAK,0BAA2B,CAACH,GAAa,EAclDO,CAASR,EArCiB,CAACC,IAA4D,CACzGF,QAASU,OAAOR,EAAYS,UAC5BC,kBAAmB,CAACV,EAAYW,UAChCC,UAAWZ,EAAYa,QACvBC,SAAU,CAACd,EAAYe,OACvBC,eAAgBhB,EAAYiB,gBAC5BC,QAAS,CAAClB,EAAYmB,OA+BaC,CAAiCpB,UAClDD,EAAOE,SAASE,KAAK,6BAA8B,CAAC,CAAEL,QAAS,KAAKA,EAAQM,SAAS,SAC7F,MAAOC,GAEL,MADAC,QAAQD,MAAM,qBAAsBA,GAC9BA,qBCzBlBgB,IA8CO,CAAEC,WAvCUzB,gBACMwB,KACPC,aAqCGC,YAlCY1B,OAAS2B,UAASC,mBAC/C,MAAM1B,QAAesB,EAAUI,GAC/B,GAAIA,EAAc,CAEd,GAAIA,UADkB1B,EAAOuB,aAEzB,MAAM,IAAIpB,MAAM,gCAIxB,aADwBH,EAAOwB,YAAYC,EAC3B,EAyBcE,gBAtBO7B,MAAO8B,EAAa3B,KACzD,IAAID,QAAesB,IACnB,MAAMO,QAAsB7B,EAAOE,UAAU4B,cACzCD,GAAe9B,SAASM,aAAeuB,EAAY7B,QAAQM,mBACrDR,EAAY+B,EAAY7B,QAASC,EAAQC,GAC/CD,QAAesB,KAEnB,MAAMS,ODciBjC,QAC3BE,SACA4B,cACAI,gBACAC,cAOA,MAAMC,QAAmBlC,EAAO2B,gBAAgBC,GAEhD,aAAcM,EAAWC,KAAKH,EAAeC,EAAQ,EC3BnBG,CAAiB,CAAEpC,SAAQ4B,gBACzD,MAnDG,CACHS,iBAFwBC,EAoDMP,GAlDHQ,KAC3BC,UAAWF,EAAUE,UACrBC,YAAaH,EAAUG,YACvBC,KAAMJ,EAAUI,KAChBC,GAAIL,EAAUK,SAAMC,EACpBC,WAAYP,GAPW,IAACA,CAoDsB,EAcCQ,cAXdhD,OAASiD,YAAWrB,mBACrD,MAAM1B,QAAesB,EAAUI,GAC/B,GAAIA,EAAc,CAEd,GAAIA,UADkB1B,EAAOuB,aAEzB,MAAM,IAAIpB,MAAM,gCAGxB,aAAaH,EAAOE,UAAUE,KAAK,uBAAwB,CAACsB,EAAcqB,IAAW"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var e=require("ethers"),t=require("viem");const n="https://app.halliday.xyz",i=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/;function o(e,t,n){function i(n,i){var o;Object.defineProperty(n,"_zod",{value:n._zod??{},enumerable:!1}),(o=n._zod).traits??(o.traits=new Set),n._zod.traits.add(e),t(n,i);for(const e in s.prototype)Object.defineProperty(n,e,{value:s.prototype[e].bind(n)});n._zod.constr=s,n._zod.def=i}const o=n?.Parent??Object;class r extends o{}function s(e){var t;const o=n?.Parent?new r:this;i(o,e),(t=o._zod).deferred??(t.deferred=[]);for(const e of o._zod.deferred)e();return o}return Object.defineProperty(r,"name",{value:e}),Object.defineProperty(s,"init",{value:i}),Object.defineProperty(s,Symbol.hasInstance,{value:t=>!!(n?.Parent&&t instanceof n.Parent)||t?._zod?.traits?.has(e)}),Object.defineProperty(s,"name",{value:e}),s}class r extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}const s={};function a(e){return s}function u(e,t){return"bigint"==typeof t?t.toString():t}function c(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function d(e){return null==e}function l(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function p(e,t,n){Object.defineProperty(e,t,{get(){{const i=n();return e[t]=i,i}},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function f(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function h(e=10){const t="abcdefghijklmnopqrstuvwxyz";let n="";for(let i=0;i<e;i++)n+=t[Math.floor(26*Math.random())];return n}function m(e){return JSON.stringify(e)}function _(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}const g=c((()=>{try{return new Function(""),!0}catch(e){return!1}}));function v(e){return"object"==typeof e&&null!==e&&(Object.getPrototypeOf(e)===Object.prototype||null===Object.getPrototypeOf(e))}const y=new Set(["string","number","symbol"]);function w(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function z(e,t,n){const i=new e._zod.constr(t??e._zod.def);return t&&!n?.parent||(i._zod.parent=e),i}function k(e){const t=e;if(!t)return{};if("string"==typeof t)return{error:()=>t};if(void 0!==t?.message){if(void 0!==t?.error)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,"string"==typeof t.error?{...t,error:()=>t.error}:t}const b={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function E(e,t=0){for(let n=t;n<e.issues.length;n++)if(!0!==e.issues[n].continue)return!0;return!1}function I(e,t){return t.map((t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t}))}function T(e){return"string"==typeof e?e:e?.message}function $(e,t,n){const i={...e,path:e.path??[]};if(!e.message){const o=T(e.inst?._zod.def?.error?.(e))??T(t?.error?.(e))??T(n.customError?.(e))??T(n.localeError?.(e))??"Invalid input";i.message=o}return delete i.inst,delete i.continue,t?.reportInput||delete i.input,i}function x(e){return Array.isArray(e)?"array":"string"==typeof e?"string":"unknown"}function A(...e){const[t,n,i]=e;return"string"==typeof t?{message:t,code:"custom",input:n,inst:i}:{...t}}const Z=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),Object.defineProperty(e,"message",{get:()=>JSON.stringify(t,u,2),enumerable:!0})},P=o("$ZodError",Z),N=o("$ZodError",Z,{Parent:Error});const O=e=>(t,n,i,o)=>{const s=i?Object.assign(i,{async:!1}):{async:!1},u=t._zod.run({value:n,issues:[]},s);if(u instanceof Promise)throw new r;if(u.issues.length){const t=new(o?.Err??e)(u.issues.map((e=>$(e,s,a()))));throw Error.captureStackTrace(t,o?.callee),t}return u.value},S=e=>async(t,n,i,o)=>{const r=i?Object.assign(i,{async:!0}):{async:!0};let s=t._zod.run({value:n,issues:[]},r);if(s instanceof Promise&&(s=await s),s.issues.length){const t=new(o?.Err??e)(s.issues.map((e=>$(e,r,a()))));throw Error.captureStackTrace(t,o?.callee),t}return s.value},D=e=>(t,n,i)=>{const o=i?{...i,async:!1}:{async:!1},s=t._zod.run({value:n,issues:[]},o);if(s instanceof Promise)throw new r;return s.issues.length?{success:!1,error:new(e??P)(s.issues.map((e=>$(e,o,a()))))}:{success:!0,data:s.value}},C=D(N),M=e=>async(t,n,i)=>{const o=i?Object.assign(i,{async:!0}):{async:!0};let r=t._zod.run({value:n,issues:[]},o);return r instanceof Promise&&(r=await r),r.issues.length?{success:!1,error:new e(r.issues.map((e=>$(e,o,a()))))}:{success:!0,data:r.value}},R=M(N),F=/^[cC][^\s-]{8,}$/,j=/^[0-9a-z]+$/,U=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,L=/^[0-9a-vA-V]{20}$/,V=/^[A-Za-z0-9]{27}$/,W=/^[a-zA-Z0-9_-]{21}$/,B=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,G=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,H=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000)$/,q=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;const K=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Y=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})$/,J=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,X=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Q=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,ee=/^[A-Za-z0-9_-]*$/,te=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/,ne=/^\+(?:[0-9]){6,14}[0-9]$/,ie="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",oe=new RegExp(`^${ie}$`);function re(e){let t="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return e.precision?t=`${t}\\.\\d{${e.precision}}`:null==e.precision&&(t=`${t}(\\.\\d+)?`),t}const se=/^\d+n?$/,ae=/^\d+$/,ue=/^-?\d+(?:\.\d+)?/i,ce=/true|false/i,de=/null/i,le=/^[^A-Z]*$/,pe=/^[^a-z]*$/,fe=o("$ZodCheck",((e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])})),he={number:"number",bigint:"bigint",object:"date"},me=o("$ZodCheckLessThan",((e,t)=>{fe.init(e,t);const n=he[typeof t.value];e._zod.onattach.push((e=>{const n=e._zod.bag,i=(t.inclusive?n.maximum:n.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<i&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)})),e._zod.check=i=>{(t.inclusive?i.value<=t.value:i.value<t.value)||i.issues.push({origin:n,code:"too_big",maximum:t.value,input:i.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}})),_e=o("$ZodCheckGreaterThan",((e,t)=>{fe.init(e,t);const n=he[typeof t.value];e._zod.onattach.push((e=>{const n=e._zod.bag,i=(t.inclusive?n.minimum:n.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>i&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)})),e._zod.check=i=>{(t.inclusive?i.value>=t.value:i.value>t.value)||i.issues.push({origin:n,code:"too_small",minimum:t.value,input:i.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}})),ge=o("$ZodCheckMultipleOf",((e,t)=>{fe.init(e,t),e._zod.onattach.push((e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)})),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");("bigint"==typeof n.value?n.value%t.value===BigInt(0):0===function(e,t){const n=(e.toString().split(".")[1]||"").length,i=(t.toString().split(".")[1]||"").length,o=n>i?n:i;return Number.parseInt(e.toFixed(o).replace(".",""))%Number.parseInt(t.toFixed(o).replace(".",""))/10**o}(n.value,t.value))||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}})),ve=o("$ZodCheckNumberFormat",((e,t)=>{fe.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),i=n?"int":"number",[o,r]=b[t.format];e._zod.onattach.push((e=>{const i=e._zod.bag;i.format=t.format,i.minimum=o,i.maximum=r,n&&(i.pattern=ae)})),e._zod.check=s=>{const a=s.value;if(n){if(!Number.isInteger(a))return void s.issues.push({expected:i,format:t.format,code:"invalid_type",input:a,inst:e});if(!Number.isSafeInteger(a))return void(a>0?s.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:i,continue:!t.abort}):s.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:i,continue:!t.abort}))}a<o&&s.issues.push({origin:"number",input:a,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),a>r&&s.issues.push({origin:"number",input:a,code:"too_big",maximum:r,inst:e})}})),ye=o("$ZodCheckMaxLength",((e,t)=>{fe.init(e,t),e._zod.when=e=>{const t=e.value;return!d(t)&&void 0!==t.length},e._zod.onattach.push((e=>{const n=e._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<n&&(e._zod.bag.maximum=t.maximum)})),e._zod.check=n=>{const i=n.value;if(i.length<=t.maximum)return;const o=x(i);n.issues.push({origin:o,code:"too_big",maximum:t.maximum,input:i,inst:e,continue:!t.abort})}})),we=o("$ZodCheckMinLength",((e,t)=>{fe.init(e,t),e._zod.when=e=>{const t=e.value;return!d(t)&&void 0!==t.length},e._zod.onattach.push((e=>{const n=e._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>n&&(e._zod.bag.minimum=t.minimum)})),e._zod.check=n=>{const i=n.value;if(i.length>=t.minimum)return;const o=x(i);n.issues.push({origin:o,code:"too_small",minimum:t.minimum,input:i,inst:e,continue:!t.abort})}})),ze=o("$ZodCheckLengthEquals",((e,t)=>{fe.init(e,t),e._zod.when=e=>{const t=e.value;return!d(t)&&void 0!==t.length},e._zod.onattach.push((e=>{const n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length})),e._zod.check=n=>{const i=n.value,o=i.length;if(o===t.length)return;const r=x(i),s=o>t.length;n.issues.push({origin:r,...s?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},input:n.value,inst:e,continue:!t.abort})}})),ke=o("$ZodCheckStringFormat",((e,t)=>{var n;fe.init(e,t),e._zod.onattach.push((e=>{const n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??(n.patterns=new Set),n.patterns.add(t.pattern))})),(n=e._zod).check??(n.check=n=>{if(!t.pattern)throw new Error("Not implemented.");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})})})),be=o("$ZodCheckRegex",((e,t)=>{ke.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})}})),Ee=o("$ZodCheckLowerCase",((e,t)=>{t.pattern??(t.pattern=le),ke.init(e,t)})),Ie=o("$ZodCheckUpperCase",((e,t)=>{t.pattern??(t.pattern=pe),ke.init(e,t)})),Te=o("$ZodCheckIncludes",((e,t)=>{fe.init(e,t);const n=w(t.includes),i=new RegExp("number"==typeof t.position?`^.{${t.position}}${n}`:n);t.pattern=i,e._zod.onattach.push((e=>{const t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(i)})),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:n.value,inst:e,continue:!t.abort})}})),$e=o("$ZodCheckStartsWith",((e,t)=>{fe.init(e,t);const n=new RegExp(`^${w(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push((e=>{const t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(n)})),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}})),xe=o("$ZodCheckEndsWith",((e,t)=>{fe.init(e,t);const n=new RegExp(`.*${w(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push((e=>{const t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(n)})),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}})),Ae=o("$ZodCheckOverwrite",((e,t)=>{fe.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}));class Ze{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if("function"==typeof e)return e(this,{execution:"sync"}),void e(this,{execution:"async"});const t=e.split("\n").filter((e=>e)),n=Math.min(...t.map((e=>e.length-e.trimStart().length))),i=t.map((e=>e.slice(n))).map((e=>" ".repeat(2*this.indent)+e));for(const e of i)this.content.push(e)}compile(){const e=Function,t=this?.args;return new e(...t,[...(this?.content??[""]).map((e=>` ${e}`))].join("\n"))}}const Pe={major:4,minor:0,patch:0},Ne=o("$ZodType",((e,t)=>{var n;e??(e={}),e._zod.id=t.type+"_"+h(10),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Pe;const i=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&i.unshift(e);for(const t of i)for(const n of t._zod.onattach)n(e);if(0===i.length)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push((()=>{e._zod.run=e._zod.parse}));else{const t=(e,t,n)=>{let i,o=E(e);for(const s of t){if(s._zod.when){if(!s._zod.when(e))continue}else if(o)continue;const t=e.issues.length,a=s._zod.check(e);if(a instanceof Promise&&!1===n?.async)throw new r;if(i||a instanceof Promise)i=(i??Promise.resolve()).then((async()=>{await a;e.issues.length!==t&&(o||(o=E(e,t)))}));else{if(e.issues.length===t)continue;o||(o=E(e,t))}}return i?i.then((()=>e)):e};e._zod.run=(n,o)=>{const s=e._zod.parse(n,o);if(s instanceof Promise){if(!1===o.async)throw new r;return s.then((e=>t(e,i,o)))}return t(s,i,o)}}e["~standard"]={validate:t=>{try{const n=C(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch(n){return R(e,t).then((e=>e.success?{value:e.data}:{issues:e.error?.issues}))}},vendor:"zod",version:1}})),Oe=o("$ZodString",((e,t)=>{var n;Ne.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??(n=e._zod.bag,new RegExp(`^${n?`[\\s\\S]{${n?.minimum??0},${n?.maximum??""}}`:"[\\s\\S]*"}$`)),e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=String(n.value)}catch(i){}return"string"==typeof n.value||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}})),Se=o("$ZodStringFormat",((e,t)=>{ke.init(e,t),Oe.init(e,t)})),De=o("$ZodGUID",((e,t)=>{t.pattern??(t.pattern=G),Se.init(e,t)})),Ce=o("$ZodUUID",((e,t)=>{if(t.version){const e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(void 0===e)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=H(e))}else t.pattern??(t.pattern=H());Se.init(e,t)})),Me=o("$ZodEmail",((e,t)=>{t.pattern??(t.pattern=q),Se.init(e,t)})),Re=o("$ZodURL",((e,t)=>{Se.init(e,t),e._zod.check=n=>{try{const i=new URL(n.value);return t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:te.source,input:n.value,inst:e})),void(t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(":")?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e})))}catch(t){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e})}}})),Fe=o("$ZodEmoji",((e,t)=>{t.pattern??(t.pattern=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),Se.init(e,t)})),je=o("$ZodNanoID",((e,t)=>{t.pattern??(t.pattern=W),Se.init(e,t)})),Ue=o("$ZodCUID",((e,t)=>{t.pattern??(t.pattern=F),Se.init(e,t)})),Le=o("$ZodCUID2",((e,t)=>{t.pattern??(t.pattern=j),Se.init(e,t)})),Ve=o("$ZodULID",((e,t)=>{t.pattern??(t.pattern=U),Se.init(e,t)})),We=o("$ZodXID",((e,t)=>{t.pattern??(t.pattern=L),Se.init(e,t)})),Be=o("$ZodKSUID",((e,t)=>{t.pattern??(t.pattern=V),Se.init(e,t)})),Ge=o("$ZodISODateTime",((e,t)=>{t.pattern??(t.pattern=function(e){let t=`${ie}T${re(e)}`;const n=[];return n.push(e.local?"Z?":"Z"),e.offset&&n.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${n.join("|")})`,new RegExp(`^${t}$`)}(t)),Se.init(e,t)})),He=o("$ZodISODate",((e,t)=>{t.pattern??(t.pattern=oe),Se.init(e,t)})),qe=o("$ZodISOTime",((e,t)=>{t.pattern??(t.pattern=new RegExp(`^${re(t)}$`)),Se.init(e,t)})),Ke=o("$ZodISODuration",((e,t)=>{t.pattern??(t.pattern=B),Se.init(e,t)})),Ye=o("$ZodIPv4",((e,t)=>{t.pattern??(t.pattern=K),Se.init(e,t),e._zod.onattach.push((e=>{e._zod.bag.format="ipv4"}))})),Je=o("$ZodIPv6",((e,t)=>{t.pattern??(t.pattern=Y),Se.init(e,t),e._zod.onattach.push((e=>{e._zod.bag.format="ipv6"})),e._zod.check=t=>{try{new URL(`http://[${t.value}]`)}catch{t.issues.push({code:"invalid_format",format:"ipv6",input:t.value,inst:e})}}})),Xe=o("$ZodCIDRv4",((e,t)=>{t.pattern??(t.pattern=J),Se.init(e,t)})),Qe=o("$ZodCIDRv6",((e,t)=>{t.pattern??(t.pattern=X),Se.init(e,t),e._zod.check=t=>{const[n,i]=t.value.split("/");try{if(!i)throw new Error;const e=Number(i);if(`${e}`!==i)throw new Error;if(e<0||e>128)throw new Error;new URL(`http://[${n}]`)}catch{t.issues.push({code:"invalid_format",format:"cidrv6",input:t.value,inst:e})}}}));function et(e){if(""===e)return!0;if(e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}const tt=o("$ZodBase64",((e,t)=>{t.pattern??(t.pattern=Q),Se.init(e,t),e._zod.onattach.push((e=>{e._zod.bag.contentEncoding="base64"})),e._zod.check=t=>{et(t.value)||t.issues.push({code:"invalid_format",format:"base64",input:t.value,inst:e})}}));const nt=o("$ZodBase64URL",((e,t)=>{t.pattern??(t.pattern=ee),Se.init(e,t),e._zod.onattach.push((e=>{e._zod.bag.contentEncoding="base64url"})),e._zod.check=t=>{(function(e){if(!ee.test(e))return!1;const t=e.replace(/[-_]/g,(e=>"-"===e?"+":"/"));return et(t.padEnd(4*Math.ceil(t.length/4),"="))})(t.value)||t.issues.push({code:"invalid_format",format:"base64url",input:t.value,inst:e})}})),it=o("$ZodE164",((e,t)=>{t.pattern??(t.pattern=ne),Se.init(e,t)}));const ot=o("$ZodJWT",((e,t)=>{Se.init(e,t),e._zod.check=n=>{(function(e,t=null){try{const n=e.split(".");if(3!==n.length)return!1;const[i]=n,o=JSON.parse(atob(i));return!("typ"in o&&"JWT"!==o?.typ||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}})(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e})}})),rt=o("$ZodNumber",((e,t)=>{Ne.init(e,t),e._zod.pattern=e._zod.bag.pattern??ue,e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=Number(n.value)}catch(e){}const o=n.value;if("number"==typeof o&&!Number.isNaN(o)&&Number.isFinite(o))return n;const r="number"==typeof o?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...r?{received:r}:{}}),n}})),st=o("$ZodNumber",((e,t)=>{ve.init(e,t),rt.init(e,t)})),at=o("$ZodBoolean",((e,t)=>{Ne.init(e,t),e._zod.pattern=ce,e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=Boolean(n.value)}catch(e){}const o=n.value;return"boolean"==typeof o||n.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),n}})),ut=o("$ZodBigInt",((e,t)=>{Ne.init(e,t),e._zod.pattern=se,e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=BigInt(n.value)}catch(e){}const{value:o}=n;return"bigint"==typeof o||n.issues.push({expected:"bigint",code:"invalid_type",input:o,inst:e}),n}})),ct=o("$ZodNull",((e,t)=>{Ne.init(e,t),e._zod.pattern=de,e._zod.values=new Set([null]),e._zod.parse=(t,n)=>{const{value:i}=t;return null===i||t.issues.push({expected:"null",code:"invalid_type",input:i,inst:e}),t}})),dt=o("$ZodAny",((e,t)=>{Ne.init(e,t),e._zod.parse=e=>e})),lt=o("$ZodUnknown",((e,t)=>{Ne.init(e,t),e._zod.parse=e=>e})),pt=o("$ZodNever",((e,t)=>{Ne.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:e}),t)}));function ft(e,t,n){e.issues.length&&t.issues.push(...I(n,e.issues)),t.value[n]=e.value}const ht=o("$ZodArray",((e,t)=>{Ne.init(e,t),e._zod.parse=(n,i)=>{const o=n.value;if(!Array.isArray(o))return n.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),n;n.value=Array(o.length);const r=[];for(let e=0;e<o.length;e++){const s=o[e],a=t.element._zod.run({value:s,issues:[]},i);a instanceof Promise?r.push(a.then((t=>ft(t,n,e)))):ft(a,n,e)}return r.length?Promise.all(r).then((()=>n)):n}}));function mt(e,t,n){e.issues.length&&t.issues.push(...I(n,e.issues)),t.value[n]=e.value}function _t(e,t,n,i){e.issues.length?void 0===i[n]?t.value[n]=n in i?void 0:e.value:t.issues.push(...I(n,e.issues)):void 0===e.value?n in i&&(t.value[n]=void 0):t.value[n]=e.value}const gt=o("$ZodObject",((e,t)=>{Ne.init(e,t);const n=c((()=>{const e=Object.keys(t.shape);for(const n of e)if(!(t.shape[n]instanceof Ne))throw new Error(`Invalid element at key "${n}": expected a Zod schema`);const n=(i=t.shape,Object.keys(i).filter((e=>"optional"===i[e]._zod.optin&&"optional"===i[e]._zod.optout)));var i;return{shape:t.shape,keys:e,keySet:new Set(e),numKeys:e.length,optionalKeys:new Set(n)}}));p(e._zod,"propValues",(()=>{const e=t.shape,n={};for(const t in e){const i=e[t]._zod;if(i.values){n[t]??(n[t]=new Set);for(const e of i.values)n[t].add(e)}}return n}));let i;const o=_,r=!s.jitless,a=r&&g.value,{catchall:u}=t;let d;e._zod.parse=(s,c)=>{d??(d=n.value);const l=s.value;if(!o(l))return s.issues.push({expected:"object",code:"invalid_type",input:l,inst:e}),s;const p=[];if(r&&a&&!1===c?.async&&!0!==c.jitless)i||(i=(e=>{const t=new Ze(["shape","payload","ctx"]),{keys:i,optionalKeys:o}=n.value,r=e=>{const t=m(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write("const input = payload.value;");const s=Object.create(null);for(const e of i)s[e]=h(15);t.write("const newResult = {}");for(const e of i)if(o.has(e)){const n=s[e];t.write(`const ${n} = ${r(e)};`);const i=m(e);t.write(`\n if (${n}.issues.length) {\n if (input[${i}] === undefined) {\n if (${i} in input) {\n newResult[${i}] = undefined;\n }\n } else {\n payload.issues = payload.issues.concat(\n ${n}.issues.map((iss) => ({\n ...iss,\n path: iss.path ? [${i}, ...iss.path] : [${i}],\n }))\n );\n }\n } else if (${n}.value === undefined) {\n if (${i} in input) newResult[${i}] = undefined;\n } else {\n newResult[${i}] = ${n}.value;\n }\n `)}else{const n=s[e];t.write(`const ${n} = ${r(e)};`),t.write(`\n if (${n}.issues.length) payload.issues = payload.issues.concat(${n}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${m(e)}, ...iss.path] : [${m(e)}]\n })));`),t.write(`newResult[${m(e)}] = ${n}.value`)}t.write("payload.value = newResult;"),t.write("return payload;");const a=t.compile();return(t,n)=>a(e,t,n)})(t.shape)),s=i(s,c);else{s.value={};const e=d.shape;for(const t of d.keys){const n=e[t],i=n._zod.run({value:l[t],issues:[]},c),o="optional"===n._zod.optin&&"optional"===n._zod.optout;i instanceof Promise?p.push(i.then((e=>o?_t(e,s,t,l):mt(e,s,t)))):o?_t(i,s,t,l):mt(i,s,t)}}if(!u)return p.length?Promise.all(p).then((()=>s)):s;const f=[],_=d.keySet,g=u._zod,v=g.def.type;for(const e of Object.keys(l)){if(_.has(e))continue;if("never"===v){f.push(e);continue}const t=g.run({value:l[e],issues:[]},c);t instanceof Promise?p.push(t.then((t=>mt(t,s,e)))):mt(t,s,e)}return f.length&&s.issues.push({code:"unrecognized_keys",keys:f,input:l,inst:e}),p.length?Promise.all(p).then((()=>s)):s}}));function vt(e,t,n,i){for(const n of e)if(0===n.issues.length)return t.value=n.value,t;return t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map((e=>e.issues.map((e=>$(e,i,a())))))}),t}const yt=o("$ZodUnion",((e,t)=>{Ne.init(e,t),p(e._zod,"values",(()=>{if(t.options.every((e=>e._zod.values)))return new Set(t.options.flatMap((e=>Array.from(e._zod.values))))})),p(e._zod,"pattern",(()=>{if(t.options.every((e=>e._zod.pattern))){const e=t.options.map((e=>e._zod.pattern));return new RegExp(`^(${e.map((e=>l(e.source))).join("|")})$`)}})),e._zod.parse=(n,i)=>{let o=!1;const r=[];for(const e of t.options){const t=e._zod.run({value:n.value,issues:[]},i);if(t instanceof Promise)r.push(t),o=!0;else{if(0===t.issues.length)return t;r.push(t)}}return o?Promise.all(r).then((t=>vt(t,n,e,i))):vt(r,n,e,i)}})),wt=o("$ZodDiscriminatedUnion",((e,t)=>{yt.init(e,t);const n=e._zod.parse;p(e._zod,"propValues",(()=>{const e={};for(const n of t.options){const i=n._zod.propValues;if(!i||0===Object.keys(i).length)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(const[t,n]of Object.entries(i)){e[t]||(e[t]=new Set);for(const i of n)e[t].add(i)}}return e}));const i=c((()=>{const e=t.options,n=new Map;for(const i of e){const e=i._zod.propValues[t.discriminator];if(!e||0===e.size)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(i)}"`);for(const t of e){if(n.has(t))throw new Error(`Duplicate discriminator value "${String(t)}"`);n.set(t,i)}}return n}));e._zod.parse=(o,r)=>{const s=o.value;if(!_(s))return o.issues.push({code:"invalid_type",expected:"object",input:s,inst:e}),o;const a=i.value.get(s?.[t.discriminator]);return a?a._zod.run(o,r):t.unionFallback?n(o,r):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",input:s,path:[t.discriminator],inst:e}),o)}})),zt=o("$ZodIntersection",((e,t)=>{Ne.init(e,t),e._zod.parse=(e,n)=>{const{value:i}=e,o=t.left._zod.run({value:i,issues:[]},n),r=t.right._zod.run({value:i,issues:[]},n);return o instanceof Promise||r instanceof Promise?Promise.all([o,r]).then((([t,n])=>bt(e,t,n))):bt(e,o,r)}}));function kt(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(v(e)&&v(t)){const n=Object.keys(t),i=Object.keys(e).filter((e=>-1!==n.indexOf(e))),o={...e,...t};for(const n of i){const i=kt(e[n],t[n]);if(!i.valid)return{valid:!1,mergeErrorPath:[n,...i.mergeErrorPath]};o[n]=i.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let i=0;i<e.length;i++){const o=kt(e[i],t[i]);if(!o.valid)return{valid:!1,mergeErrorPath:[i,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function bt(e,t,n){if(t.issues.length&&e.issues.push(...t.issues),n.issues.length&&e.issues.push(...n.issues),E(e))return e;const i=kt(t.value,n.value);if(!i.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(i.mergeErrorPath)}`);return e.value=i.data,e}const Et=o("$ZodTuple",((e,t)=>{Ne.init(e,t);const n=t.items,i=n.length-[...n].reverse().findIndex((e=>"optional"!==e._zod.optin));e._zod.parse=(o,r)=>{const s=o.value;if(!Array.isArray(s))return o.issues.push({input:s,inst:e,expected:"tuple",code:"invalid_type"}),o;o.value=[];const a=[];if(!t.rest){const t=s.length>n.length,r=s.length<i-1;if(t||r)return o.issues.push({input:s,inst:e,origin:"array",...t?{code:"too_big",maximum:n.length}:{code:"too_small",minimum:n.length}}),o}let u=-1;for(const e of n){if(u++,u>=s.length&&u>=i)continue;const t=e._zod.run({value:s[u],issues:[]},r);t instanceof Promise?a.push(t.then((e=>It(e,o,u)))):It(t,o,u)}if(t.rest){const e=s.slice(n.length);for(const n of e){u++;const e=t.rest._zod.run({value:n,issues:[]},r);e instanceof Promise?a.push(e.then((e=>It(e,o,u)))):It(e,o,u)}}return a.length?Promise.all(a).then((()=>o)):o}}));function It(e,t,n){e.issues.length&&t.issues.push(...I(n,e.issues)),t.value[n]=e.value}const Tt=o("$ZodRecord",((e,t)=>{Ne.init(e,t),e._zod.parse=(n,i)=>{const o=n.value;if(!v(o))return n.issues.push({expected:"record",code:"invalid_type",input:o,inst:e}),n;const r=[];if(t.keyType._zod.values){const s=t.keyType._zod.values;n.value={};for(const e of s)if("string"==typeof e||"number"==typeof e||"symbol"==typeof e){const s=t.valueType._zod.run({value:o[e],issues:[]},i);s instanceof Promise?r.push(s.then((t=>{t.issues.length&&n.issues.push(...I(e,t.issues)),n.value[e]=t.value}))):(s.issues.length&&n.issues.push(...I(e,s.issues)),n.value[e]=s.value)}let a;for(const e in o)s.has(e)||(a=a??[],a.push(e));a&&a.length>0&&n.issues.push({code:"unrecognized_keys",input:o,inst:e,keys:a})}else{n.value={};for(const s of Reflect.ownKeys(o)){if("__proto__"===s)continue;const u=t.keyType._zod.run({value:s,issues:[]},i);if(u instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(u.issues.length){n.issues.push({origin:"record",code:"invalid_key",issues:u.issues.map((e=>$(e,i,a()))),input:s,path:[s],inst:e}),n.value[u.value]=u.value;continue}const c=t.valueType._zod.run({value:o[s],issues:[]},i);c instanceof Promise?r.push(c.then((e=>{e.issues.length&&n.issues.push(...I(s,e.issues)),n.value[u.value]=e.value}))):(c.issues.length&&n.issues.push(...I(s,c.issues)),n.value[u.value]=c.value)}}return r.length?Promise.all(r).then((()=>n)):n}})),$t=o("$ZodEnum",((e,t)=>{Ne.init(e,t);const n=function(e){const t=Object.values(e).filter((e=>"number"==typeof e));return Object.entries(e).filter((([e,n])=>-1===t.indexOf(+e))).map((([e,t])=>t))}(t.entries);e._zod.values=new Set(n),e._zod.pattern=new RegExp(`^(${n.filter((e=>y.has(typeof e))).map((e=>"string"==typeof e?w(e):e.toString())).join("|")})$`),e._zod.parse=(t,i)=>{const o=t.value;return e._zod.values.has(o)||t.issues.push({code:"invalid_value",values:n,input:o,inst:e}),t}})),xt=o("$ZodLiteral",((e,t)=>{Ne.init(e,t),e._zod.values=new Set(t.values),e._zod.pattern=new RegExp(`^(${t.values.map((e=>"string"==typeof e?w(e):e?e.toString():String(e))).join("|")})$`),e._zod.parse=(n,i)=>{const o=n.value;return e._zod.values.has(o)||n.issues.push({code:"invalid_value",values:t.values,input:o,inst:e}),n}})),At=o("$ZodTransform",((e,t)=>{Ne.init(e,t),e._zod.parse=(e,n)=>{const i=t.transform(e.value,e);if(n.async){return(i instanceof Promise?i:Promise.resolve(i)).then((t=>(e.value=t,e)))}if(i instanceof Promise)throw new r;return e.value=i,e}})),Zt=o("$ZodOptional",((e,t)=>{Ne.init(e,t),e._zod.optin="optional",e._zod.optout="optional",p(e._zod,"values",(()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0)),p(e._zod,"pattern",(()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${l(e.source)})?$`):void 0})),e._zod.parse=(e,n)=>void 0===e.value?e:t.innerType._zod.run(e,n)})),Pt=o("$ZodNullable",((e,t)=>{Ne.init(e,t),p(e._zod,"optin",(()=>t.innerType._zod.optin)),p(e._zod,"optout",(()=>t.innerType._zod.optout)),p(e._zod,"pattern",(()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${l(e.source)}|null)$`):void 0})),p(e._zod,"values",(()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0)),e._zod.parse=(e,n)=>null===e.value?e:t.innerType._zod.run(e,n)})),Nt=o("$ZodDefault",((e,t)=>{Ne.init(e,t),e._zod.optin="optional",p(e._zod,"values",(()=>t.innerType._zod.values)),e._zod.parse=(e,n)=>{if(void 0===e.value)return e.value=t.defaultValue,e;const i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then((e=>Ot(e,t))):Ot(i,t)}}));function Ot(e,t){return void 0===e.value&&(e.value=t.defaultValue),e}const St=o("$ZodPrefault",((e,t)=>{Ne.init(e,t),e._zod.optin="optional",p(e._zod,"values",(()=>t.innerType._zod.values)),e._zod.parse=(e,n)=>(void 0===e.value&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))})),Dt=o("$ZodNonOptional",((e,t)=>{Ne.init(e,t),p(e._zod,"values",(()=>{const e=t.innerType._zod.values;return e?new Set([...e].filter((e=>void 0!==e))):void 0})),e._zod.parse=(n,i)=>{const o=t.innerType._zod.run(n,i);return o instanceof Promise?o.then((t=>Ct(t,e))):Ct(o,e)}}));function Ct(e,t){return e.issues.length||void 0!==e.value||e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const Mt=o("$ZodCatch",((e,t)=>{Ne.init(e,t),p(e._zod,"optin",(()=>t.innerType._zod.optin)),p(e._zod,"optout",(()=>t.innerType._zod.optout)),p(e._zod,"values",(()=>t.innerType._zod.values)),e._zod.parse=(e,n)=>{const i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then((i=>(e.value=i.value,i.issues.length&&(e.value=t.catchValue({...e,error:{issues:i.issues.map((e=>$(e,n,a())))},input:e.value}),e.issues=[]),e))):(e.value=i.value,i.issues.length&&(e.value=t.catchValue({...e,error:{issues:i.issues.map((e=>$(e,n,a())))},input:e.value}),e.issues=[]),e)}})),Rt=o("$ZodPipe",((e,t)=>{Ne.init(e,t),p(e._zod,"values",(()=>t.in._zod.values)),p(e._zod,"optin",(()=>t.in._zod.optin)),p(e._zod,"optout",(()=>t.out._zod.optout)),e._zod.parse=(e,n)=>{const i=t.in._zod.run(e,n);return i instanceof Promise?i.then((e=>Ft(e,t,n))):Ft(i,t,n)}}));function Ft(e,t,n){return E(e)?e:t.out._zod.run({value:e.value,issues:e.issues},n)}const jt=o("$ZodReadonly",((e,t)=>{Ne.init(e,t),p(e._zod,"propValues",(()=>t.innerType._zod.propValues)),p(e._zod,"optin",(()=>t.innerType._zod.optin)),p(e._zod,"optout",(()=>t.innerType._zod.optout)),e._zod.parse=(e,n)=>{const i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(Ut):Ut(i)}}));function Ut(e){return e.value=Object.freeze(e.value),e}const Lt=o("$ZodLazy",((e,t)=>{Ne.init(e,t),p(e._zod,"innerType",(()=>t.getter())),p(e._zod,"pattern",(()=>e._zod.innerType._zod.pattern)),p(e._zod,"propValues",(()=>e._zod.innerType._zod.propValues)),p(e._zod,"optin",(()=>e._zod.innerType._zod.optin)),p(e._zod,"optout",(()=>e._zod.innerType._zod.optout)),e._zod.parse=(t,n)=>e._zod.innerType._zod.run(t,n)})),Vt=o("$ZodCustom",((e,t)=>{fe.init(e,t),Ne.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{const i=n.value,o=t.fn(i);if(o instanceof Promise)return o.then((t=>Wt(t,n,i,e)));Wt(o,n,i,e)}}));function Wt(e,t,n,i){if(!e){const e={code:"custom",input:n,inst:i,path:[...i._zod.def.path??[]],continue:!i._zod.def.abort};i._zod.def.params&&(e.params=i._zod.def.params),t.issues.push(A(e))}}class Bt{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){const n=t[0];if(this._map.set(e,n),n&&"object"==typeof n&&"id"in n){if(this._idmap.has(n.id))throw new Error(`ID ${n.id} already exists in the registry`);this._idmap.set(n.id,e)}return this}remove(e){return this._map.delete(e),this}get(e){const t=e._zod.parent;if(t){const n={...this.get(t)??{}};return delete n.id,{...n,...this._map.get(e)}}return this._map.get(e)}has(e){return this._map.has(e)}}function Gt(){return new Bt}const Ht=Gt();function qt(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...k(t)})}function Kt(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...k(t)})}function Yt(e,t){return new me({check:"less_than",...k(t),value:e,inclusive:!1})}function Jt(e,t){return new me({check:"less_than",...k(t),value:e,inclusive:!0})}function Xt(e,t){return new _e({check:"greater_than",...k(t),value:e,inclusive:!1})}function Qt(e,t){return new _e({check:"greater_than",...k(t),value:e,inclusive:!0})}function en(e,t){return new ge({check:"multiple_of",...k(t),value:e})}function tn(e,t){return new ye({check:"max_length",...k(t),maximum:e})}function nn(e,t){return new we({check:"min_length",...k(t),minimum:e})}function on(e,t){return new ze({check:"length_equals",...k(t),length:e})}function rn(e){return new Ae({check:"overwrite",tx:e})}const sn=o("ZodISODateTime",((e,t)=>{Ge.init(e,t),bn.init(e,t)}));function an(e){return function(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...k(t)})}(sn,e)}const un=o("ZodISODate",((e,t)=>{He.init(e,t),bn.init(e,t)}));function cn(e){return function(e,t){return new e({type:"string",format:"date",check:"string_format",...k(t)})}(un,e)}const dn=o("ZodISOTime",((e,t)=>{qe.init(e,t),bn.init(e,t)}));function ln(e){return function(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...k(t)})}(dn,e)}const pn=o("ZodISODuration",((e,t)=>{Ke.init(e,t),bn.init(e,t)}));function fn(e){return function(e,t){return new e({type:"string",format:"duration",check:"string_format",...k(t)})}(pn,e)}const hn=o("ZodError",((e,t)=>{P.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:t=>function(e,t){const n=t||function(e){return e.message},i={_errors:[]},o=e=>{for(const t of e.issues)if("invalid_union"===t.code&&t.errors.length)t.errors.map((e=>o({issues:e})));else if("invalid_key"===t.code)o({issues:t.issues});else if("invalid_element"===t.code)o({issues:t.issues});else if(0===t.path.length)i._errors.push(n(t));else{let e=i,o=0;for(;o<t.path.length;){const i=t.path[o];o===t.path.length-1?(e[i]=e[i]||{_errors:[]},e[i]._errors.push(n(t))):e[i]=e[i]||{_errors:[]},e=e[i],o++}}};return o(e),i}(e,t)},flatten:{value:t=>function(e,t=e=>e.message){const n={},i=[];for(const o of e.issues)o.path.length>0?(n[o.path[0]]=n[o.path[0]]||[],n[o.path[0]].push(t(o))):i.push(t(o));return{formErrors:i,fieldErrors:n}}(e,t)},addIssue:{value:t=>e.issues.push(t)},addIssues:{value:t=>e.issues.push(...t)},isEmpty:{get:()=>0===e.issues.length}})}),{Parent:Error}),mn=O(hn),_n=S(hn),gn=D(hn),vn=M(hn),yn=o("ZodType",((e,t)=>(Ne.init(e,t),e.def=t,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone({...t,checks:[...t.checks??[],...n.map((e=>"function"==typeof e?{_zod:{check:e,def:{check:"custom"},onattach:[]}}:e))]}),e.clone=(t,n)=>z(e,t,n),e.brand=()=>e,e.register=(t,n)=>(t.add(e,n),e),e.parse=(t,n)=>mn(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>gn(e,t,n),e.parseAsync=async(t,n)=>_n(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>vn(e,t,n),e.spa=e.safeParseAsync,e.refine=(t,n)=>e.check(function(e,t={}){return function(e,t,n){return new e({type:"custom",check:"custom",fn:t,...k(n)})}(Ci,e,t)}(t,n)),e.superRefine=t=>e.check(function(e,t){const n=function(e,t){const n=new fe({check:"custom",...k(t)});return n._zod.check=e,n}((t=>(t.addIssue=e=>{if("string"==typeof e)t.issues.push(A(e,t.value,n._zod.def));else{const i=e;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=t.value),i.inst??(i.inst=n),i.continue??(i.continue=!n._zod.def.abort),t.issues.push(A(i))}},e(t.value,t))),t);return n}(t)),e.overwrite=t=>e.check(rn(t)),e.optional=()=>Ii(e),e.nullable=()=>$i(e),e.nullish=()=>Ii($i(e)),e.nonoptional=t=>function(e,t){return new Zi({type:"nonoptional",innerType:e,...k(t)})}(e,t),e.array=()=>si(e),e.or=t=>di([e,t]),e.and=t=>new fi({type:"intersection",left:e,right:t}),e.transform=t=>Oi(e,bi(t)),e.default=t=>{return n=t,new xi({type:"default",innerType:e,get defaultValue(){return"function"==typeof n?n():n}});var n},e.prefault=t=>{return n=t,new Ai({type:"prefault",innerType:e,get defaultValue(){return"function"==typeof n?n():n}});var n},e.catch=t=>{return new Pi({type:"catch",innerType:e,catchValue:"function"==typeof(n=t)?n:()=>n});var n},e.pipe=t=>Oi(e,t),e.readonly=()=>new Si({type:"readonly",innerType:e}),e.describe=t=>{const n=e.clone();return Ht.add(n,{description:t}),n},Object.defineProperty(e,"description",{get:()=>Ht.get(e)?.description,configurable:!0}),e.meta=(...t)=>{if(0===t.length)return Ht.get(e);const n=e.clone();return Ht.add(n,t[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e))),wn=o("_ZodString",((e,t)=>{Oe.init(e,t),yn.init(e,t);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...t)=>e.check(function(e,t){return new be({check:"string_format",format:"regex",...k(t),pattern:e})}(...t)),e.includes=(...t)=>e.check(function(e,t){return new Te({check:"string_format",format:"includes",...k(t),includes:e})}(...t)),e.startsWith=(...t)=>e.check(function(e,t){return new $e({check:"string_format",format:"starts_with",...k(t),prefix:e})}(...t)),e.endsWith=(...t)=>e.check(function(e,t){return new xe({check:"string_format",format:"ends_with",...k(t),suffix:e})}(...t)),e.min=(...t)=>e.check(nn(...t)),e.max=(...t)=>e.check(tn(...t)),e.length=(...t)=>e.check(on(...t)),e.nonempty=(...t)=>e.check(nn(1,...t)),e.lowercase=t=>e.check(function(e){return new Ee({check:"string_format",format:"lowercase",...k(e)})}(t)),e.uppercase=t=>e.check(function(e){return new Ie({check:"string_format",format:"uppercase",...k(e)})}(t)),e.trim=()=>e.check(rn((e=>e.trim()))),e.normalize=(...t)=>e.check(function(e){return rn((t=>t.normalize(e)))}(...t)),e.toLowerCase=()=>e.check(rn((e=>e.toLowerCase()))),e.toUpperCase=()=>e.check(rn((e=>e.toUpperCase())))})),zn=o("ZodString",((e,t)=>{Oe.init(e,t),wn.init(e,t),e.email=t=>e.check(function(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...k(t)})}(En,t)),e.url=t=>e.check(Kt($n,t)),e.jwt=t=>e.check(function(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...k(t)})}(Vn,t)),e.emoji=t=>e.check(function(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...k(t)})}(An,t)),e.guid=t=>e.check(qt(In,t)),e.uuid=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...k(t)})}(Tn,t)),e.uuidv4=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...k(t)})}(Tn,t)),e.uuidv6=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...k(t)})}(Tn,t)),e.uuidv7=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...k(t)})}(Tn,t)),e.nanoid=t=>e.check(function(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...k(t)})}(Zn,t)),e.guid=t=>e.check(qt(In,t)),e.cuid=t=>e.check(function(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...k(t)})}(Pn,t)),e.cuid2=t=>e.check(function(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...k(t)})}(Nn,t)),e.ulid=t=>e.check(function(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...k(t)})}(On,t)),e.base64=t=>e.check(function(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...k(t)})}(jn,t)),e.base64url=t=>e.check(function(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...k(t)})}(Un,t)),e.xid=t=>e.check(function(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...k(t)})}(Sn,t)),e.ksuid=t=>e.check(function(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...k(t)})}(Dn,t)),e.ipv4=t=>e.check(function(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...k(t)})}(Cn,t)),e.ipv6=t=>e.check(function(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...k(t)})}(Mn,t)),e.cidrv4=t=>e.check(function(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...k(t)})}(Rn,t)),e.cidrv6=t=>e.check(function(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...k(t)})}(Fn,t)),e.e164=t=>e.check(function(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...k(t)})}(Ln,t)),e.datetime=t=>e.check(an(t)),e.date=t=>e.check(cn(t)),e.time=t=>e.check(ln(t)),e.duration=t=>e.check(fn(t))}));function kn(e){return function(e,t){return new e({type:"string",...k(t)})}(zn,e)}const bn=o("ZodStringFormat",((e,t)=>{Se.init(e,t),wn.init(e,t)})),En=o("ZodEmail",((e,t)=>{Me.init(e,t),bn.init(e,t)})),In=o("ZodGUID",((e,t)=>{De.init(e,t),bn.init(e,t)})),Tn=o("ZodUUID",((e,t)=>{Ce.init(e,t),bn.init(e,t)})),$n=o("ZodURL",((e,t)=>{Re.init(e,t),bn.init(e,t)}));function xn(e){return Kt($n,e)}const An=o("ZodEmoji",((e,t)=>{Fe.init(e,t),bn.init(e,t)})),Zn=o("ZodNanoID",((e,t)=>{je.init(e,t),bn.init(e,t)})),Pn=o("ZodCUID",((e,t)=>{Ue.init(e,t),bn.init(e,t)})),Nn=o("ZodCUID2",((e,t)=>{Le.init(e,t),bn.init(e,t)})),On=o("ZodULID",((e,t)=>{Ve.init(e,t),bn.init(e,t)})),Sn=o("ZodXID",((e,t)=>{We.init(e,t),bn.init(e,t)})),Dn=o("ZodKSUID",((e,t)=>{Be.init(e,t),bn.init(e,t)})),Cn=o("ZodIPv4",((e,t)=>{Ye.init(e,t),bn.init(e,t)})),Mn=o("ZodIPv6",((e,t)=>{Je.init(e,t),bn.init(e,t)})),Rn=o("ZodCIDRv4",((e,t)=>{Xe.init(e,t),bn.init(e,t)})),Fn=o("ZodCIDRv6",((e,t)=>{Qe.init(e,t),bn.init(e,t)})),jn=o("ZodBase64",((e,t)=>{tt.init(e,t),bn.init(e,t)})),Un=o("ZodBase64URL",((e,t)=>{nt.init(e,t),bn.init(e,t)})),Ln=o("ZodE164",((e,t)=>{it.init(e,t),bn.init(e,t)})),Vn=o("ZodJWT",((e,t)=>{ot.init(e,t),bn.init(e,t)})),Wn=o("ZodNumber",((e,t)=>{rt.init(e,t),yn.init(e,t),e.gt=(t,n)=>e.check(Xt(t,n)),e.gte=(t,n)=>e.check(Qt(t,n)),e.min=(t,n)=>e.check(Qt(t,n)),e.lt=(t,n)=>e.check(Yt(t,n)),e.lte=(t,n)=>e.check(Jt(t,n)),e.max=(t,n)=>e.check(Jt(t,n)),e.int=t=>e.check(Hn(t)),e.safe=t=>e.check(Hn(t)),e.positive=t=>e.check(Xt(0,t)),e.nonnegative=t=>e.check(Qt(0,t)),e.negative=t=>e.check(Yt(0,t)),e.nonpositive=t=>e.check(Jt(0,t)),e.multipleOf=(t,n)=>e.check(en(t,n)),e.step=(t,n)=>e.check(en(t,n)),e.finite=()=>e;const n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null}));function Bn(e){return function(e,t){return new e({type:"number",checks:[],...k(t)})}(Wn,e)}const Gn=o("ZodNumberFormat",((e,t)=>{st.init(e,t),Wn.init(e,t)}));function Hn(e){return function(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...k(t)})}(Gn,e)}const qn=o("ZodBoolean",((e,t)=>{at.init(e,t),yn.init(e,t)}));function Kn(e){return function(e,t){return new e({type:"boolean",...k(t)})}(qn,e)}const Yn=o("ZodBigInt",((e,t)=>{ut.init(e,t),yn.init(e,t),e.gte=(t,n)=>e.check(Qt(t,n)),e.min=(t,n)=>e.check(Qt(t,n)),e.gt=(t,n)=>e.check(Xt(t,n)),e.gte=(t,n)=>e.check(Qt(t,n)),e.min=(t,n)=>e.check(Qt(t,n)),e.lt=(t,n)=>e.check(Yt(t,n)),e.lte=(t,n)=>e.check(Jt(t,n)),e.max=(t,n)=>e.check(Jt(t,n)),e.positive=t=>e.check(Xt(BigInt(0),t)),e.negative=t=>e.check(Yt(BigInt(0),t)),e.nonpositive=t=>e.check(Jt(BigInt(0),t)),e.nonnegative=t=>e.check(Qt(BigInt(0),t)),e.multipleOf=(t,n)=>e.check(en(t,n));const n=e._zod.bag;e.minValue=n.minimum??null,e.maxValue=n.maximum??null,e.format=n.format??null}));function Jn(e){return function(e,t){return new e({type:"bigint",...k(t)})}(Yn,e)}const Xn=o("ZodNull",((e,t)=>{ct.init(e,t),yn.init(e,t)}));const Qn=o("ZodAny",((e,t)=>{dt.init(e,t),yn.init(e,t)}));function ei(){return new Qn({type:"any"})}const ti=o("ZodUnknown",((e,t)=>{lt.init(e,t),yn.init(e,t)}));function ni(){return new ti({type:"unknown"})}const ii=o("ZodNever",((e,t)=>{pt.init(e,t),yn.init(e,t)}));function oi(e){return function(e,t){return new e({type:"never",...k(t)})}(ii,e)}const ri=o("ZodArray",((e,t)=>{ht.init(e,t),yn.init(e,t),e.element=t.element,e.min=(t,n)=>e.check(nn(t,n)),e.nonempty=t=>e.check(nn(1,t)),e.max=(t,n)=>e.check(tn(t,n)),e.length=(t,n)=>e.check(on(t,n)),e.unwrap=()=>e.element}));function si(e,t){return function(e,t,n){return new e({type:"array",element:t,...k(n)})}(ri,e,t)}const ai=o("ZodObject",((e,t)=>{gt.init(e,t),yn.init(e,t),p(e,"shape",(()=>Object.fromEntries(Object.entries(e._zod.def.shape)))),e.keyof=()=>yi(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:ni()}),e.loose=()=>e.clone({...e._zod.def,catchall:ni()}),e.strict=()=>e.clone({...e._zod.def,catchall:oi()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>function(e,t){const n={...e._zod.def,get shape(){const n={...e._zod.def.shape,...t};return f(this,"shape",n),n},checks:[]};return z(e,n)}(e,t),e.merge=t=>{return i=t,z(n=e,{...n._zod.def,get shape(){const e={...n._zod.def.shape,...i._zod.def.shape};return f(this,"shape",e),e},catchall:i._zod.def.catchall,checks:[]});var n,i},e.pick=t=>function(e,t){const n={},i=e._zod.def;for(const e in t){if(!(e in i.shape))throw new Error(`Unrecognized key: "${e}"`);t[e]&&(n[e]=i.shape[e])}return z(e,{...e._zod.def,shape:n,checks:[]})}(e,t),e.omit=t=>function(e,t){const n={...e._zod.def.shape},i=e._zod.def;for(const e in t){if(!(e in i.shape))throw new Error(`Unrecognized key: "${e}"`);t[e]&&delete n[e]}return z(e,{...e._zod.def,shape:n,checks:[]})}(e,t),e.partial=(...t)=>function(e,t,n){const i=t._zod.def.shape,o={...i};if(n)for(const t in n){if(!(t in i))throw new Error(`Unrecognized key: "${t}"`);n[t]&&(o[t]=e?new e({type:"optional",innerType:i[t]}):i[t])}else for(const t in i)o[t]=e?new e({type:"optional",innerType:i[t]}):i[t];return z(t,{...t._zod.def,shape:o,checks:[]})}(Ei,e,t[0]),e.required=(...t)=>function(e,t,n){const i=t._zod.def.shape,o={...i};if(n)for(const t in n){if(!(t in o))throw new Error(`Unrecognized key: "${t}"`);n[t]&&(o[t]=new e({type:"nonoptional",innerType:i[t]}))}else for(const t in i)o[t]=new e({type:"nonoptional",innerType:i[t]});return z(t,{...t._zod.def,shape:o,checks:[]})}(Zi,e,t[0])}));function ui(e,t){const n={type:"object",get shape(){return f(this,"shape",{...e}),this.shape},...k(t)};return new ai(n)}const ci=o("ZodUnion",((e,t)=>{yt.init(e,t),yn.init(e,t),e.options=t.options}));function di(e,t){return new ci({type:"union",options:e,...k(t)})}const li=o("ZodDiscriminatedUnion",((e,t)=>{ci.init(e,t),wt.init(e,t)}));function pi(e,t,n){return new li({type:"union",options:t,discriminator:e,...k(n)})}const fi=o("ZodIntersection",((e,t)=>{zt.init(e,t),yn.init(e,t)}));const hi=o("ZodTuple",((e,t)=>{Et.init(e,t),yn.init(e,t),e.rest=t=>e.clone({...e._zod.def,rest:t})}));function mi(e,t,n){const i=t instanceof Ne;return new hi({type:"tuple",items:e,rest:i?t:null,...k(i?n:t)})}const _i=o("ZodRecord",((e,t)=>{Tt.init(e,t),yn.init(e,t),e.keyType=t.keyType,e.valueType=t.valueType}));function gi(e,t,n){return new _i({type:"record",keyType:e,valueType:t,...k(n)})}const vi=o("ZodEnum",((e,t)=>{$t.init(e,t),yn.init(e,t),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(e,i)=>{const o={};for(const i of e){if(!n.has(i))throw new Error(`Key ${i} not found in enum`);o[i]=t.entries[i]}return new vi({...t,checks:[],...k(i),entries:o})},e.exclude=(e,i)=>{const o={...t.entries};for(const t of e){if(!n.has(t))throw new Error(`Key ${t} not found in enum`);delete o[t]}return new vi({...t,checks:[],...k(i),entries:o})}}));function yi(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map((e=>[e,e]))):e;return new vi({type:"enum",entries:n,...k(t)})}const wi=o("ZodLiteral",((e,t)=>{xt.init(e,t),yn.init(e,t),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})}));function zi(e,t){return new wi({type:"literal",values:Array.isArray(e)?e:[e],...k(t)})}const ki=o("ZodTransform",((e,t)=>{At.init(e,t),yn.init(e,t),e._zod.parse=(n,i)=>{n.addIssue=i=>{if("string"==typeof i)n.issues.push(A(i,n.value,t));else{const t=i;t.fatal&&(t.continue=!1),t.code??(t.code="custom"),t.input??(t.input=n.value),t.inst??(t.inst=e),t.continue??(t.continue=!0),n.issues.push(A(t))}};const o=t.transform(n.value,n);return o instanceof Promise?o.then((e=>(n.value=e,n))):(n.value=o,n)}}));function bi(e){return new ki({type:"transform",transform:e})}const Ei=o("ZodOptional",((e,t)=>{Zt.init(e,t),yn.init(e,t),e.unwrap=()=>e._zod.def.innerType}));function Ii(e){return new Ei({type:"optional",innerType:e})}const Ti=o("ZodNullable",((e,t)=>{Pt.init(e,t),yn.init(e,t),e.unwrap=()=>e._zod.def.innerType}));function $i(e){return new Ti({type:"nullable",innerType:e})}const xi=o("ZodDefault",((e,t)=>{Nt.init(e,t),yn.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap}));const Ai=o("ZodPrefault",((e,t)=>{St.init(e,t),yn.init(e,t),e.unwrap=()=>e._zod.def.innerType}));const Zi=o("ZodNonOptional",((e,t)=>{Dt.init(e,t),yn.init(e,t),e.unwrap=()=>e._zod.def.innerType}));const Pi=o("ZodCatch",((e,t)=>{Mt.init(e,t),yn.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap}));const Ni=o("ZodPipe",((e,t)=>{Rt.init(e,t),yn.init(e,t),e.in=t.in,e.out=t.out}));function Oi(e,t){return new Ni({type:"pipe",in:e,out:t})}const Si=o("ZodReadonly",((e,t)=>{jt.init(e,t),yn.init(e,t)}));const Di=o("ZodLazy",((e,t)=>{Lt.init(e,t),yn.init(e,t),e.unwrap=()=>e._zod.def.getter()}));const Ci=o("ZodCustom",((e,t)=>{Vt.init(e,t),yn.init(e,t)}));const Mi=kn().refine((e=>/^(0|[1-9]\d*)(\.\d+)?$/.test(e)),{message:"Invalid amount"}),Ri=/^(0x|0x[a-fA-F0-9]{40})$/,Fi=kn().refine((e=>Ri.test(e)),{message:"Invalid EVM token address"}),ji=Fi.refine((e=>"0x"!==e),{message:"Invalid EVM address"}),Ui=/^[1-9A-HJ-NP-Za-km-z]{32,44}$/,Li=/^So[1-2]{41}$/,Vi=kn().refine((e=>Ui.test(e)||Li.test(e)),{message:"Invalid Solana token address"}),Wi=di([ji,kn().refine((e=>Ui.test(e)),{message:"Invalid Solana address"})]),Bi=kn().refine((e=>/^[a-zA-Z_]{3,}$/.test(e)),{message:"Invalid fiat"}),Gi=ui({issuer:kn(),name:kn(),alias:kn().optional(),symbol:kn(),decimals:Bn()}),Hi=kn(),qi=kn().regex(/^[a-zA-Z]\w{1,7}$/,{message:"Must be a short alpha-numeric symbol"}),Ki=Bn().min(0).max(18),Yi=kn().url(),Ji=kn(),Xi=ui({chain:kn(),address:Fi}),Qi=ui({chain:zi("solana"),address:Vi}),eo=di([Xi,Qi]),to=kn().refine((e=>{const[t,n]=e.split(":");return eo.safeParse({chain:t,address:n}).success}),{message:"Invalid token"}),no=ui({name:Hi,symbol:qi,decimals:Ki,alias:qi.optional(),image_url:Yi.optional(),coingecko_id:Ji.optional(),wrapper:qi.optional()}),io=di([Xi.extend(no.shape),Qi.extend(no.shape)]),oo=di([to,Bi]),ro=di([io,Gi]),so=pi("type",[ui({type:zi("chain"),chain:kn()}),ui({type:zi("issuer"),issuer:kn()})]),ao=kn().transform((e=>e.toLowerCase()));var uo,co;uo=e=>"string"==typeof e?e.toUpperCase():e,co=yi(["ONRAMP","OFFRAMP"]),Oi(bi(uo),co),ui({to:ji,from:ji.optional(),nonce:Bn().optional(),gasLimit:Jn().optional(),gasPrice:Jn().optional(),maxPriorityFeePerGas:Jn().optional(),maxFeePerGas:Jn().optional(),data:kn().optional(),value:Jn().optional(),chainId:Bn()}),ui({transactionHash:kn().optional(),blockHash:kn().optional(),blockNumber:Bn().optional(),from:ji.optional(),to:ji.optional(),rawReceipt:ei()});di([ui({chain_id:Bn(),network:kn(),native_currency:ui({name:kn(),symbol:kn(),decimals:Bn()}),rpc:kn(),image:kn(),is_testnet:Kn(),explorer:kn()}),ui({chain_id:Bn(),network:kn()})]);const lo=ui({"#":kn()});ui({name:kn(),alpha2:kn().length(2),alpha3:kn().length(3)});const po=kn().refine((e=>i.test(e)),{message:"Invalid workflow ID"}),fo=ui({onramps:si(ao).optional(),offramps:si(ao).optional(),sandbox:Kn().default(!1)}),ho=fo.extend({inputs:si(oo).optional(),outputs:si(oo)});di([ho,fo.extend({inputs:si(oo),outputs:si(oo).optional()})]);const mo=new Di({type:"lazy",getter:()=>di([vo,yo,wo])});const _o=ui({asset:oo,amount:Mi}),go=ui({token:to,amount:Mi}),vo=_o,yo=_o,wo=si(mo),zo=kn(),ko=pi("kind",[ui({kind:zi("FixedInputSwap"),input:_o,output:oo,quote_fiat:Bi}),ui({kind:zi("FixedOutputSwap"),input:oo,output:_o,quote_fiat:Bi})]),bo=yi(["USER","DEST","HALLIDAY","SPW","REV_SHARE","BRIDGE"]),Eo=ui({asset:oo,property:yi(["APPROVAL","BALANCE"])}),Io=ui({account:bo,resource:Eo}),To=Io.extend({sau:lo});kn();const $o=ui({consume:si(To),produce:si(To)}),xo=yi(["user_fund","onramp","poll","bridge","rev_share","transfer_out","convert"]),Ao=ui({type:di([zi("ONRAMP"),zi("STEP")]),net_effect:$o,pieces_info:si(ui({piece_type:xo,hop_data:ui({hop_identifier:kn(),input:oo,output:oo}).optional(),ramp_data:ui({ramp_identifier:kn()}).optional()})),expected_metadata:ui({step_index:Bn().optional()})}),Zo=di([zi("COMPLETE"),zi("UNREACHABLE"),zi("FAILED")]),Po=di([Zo,zi("PENDING")]),No=yi(["INITIALIZED","PAYMENT_SUBMITTED","COMPLETED","FAILED","NOT_FOUND"]),Oo=yi(["PENDING","COMPLETED","FAILED","NOT_FOUND"]),So=yi(["PENDING","COMPLETE","FAILED"]),Do=ui({observed_status:Po,details:Ao.extend({observed_metadata:ui({tx_hash:kn().optional(),purchase_status:No.optional(),step_status:Oo.optional()})}).nullable()}),Co=ui({expected_details_list:si(Ao),preconditions:si(To)});ui({tx_hash:kn(),step_status:Oo,block_timestamp:Bn(),net_effect:$o});const Mo=function(e,t){return new e({type:"null",...k(t)})}(Xn,Ro);var Ro;const Fo=di([zi("FIXED"),zi("SOLVE"),zi("SOLVE_TEMPLATED")]),jo=di([ui({in_decl:zi(!0),instr_type:Fo}),ui({in_decl:zi(!1)})]),Uo=ui({type:xo,effect:$o,attributes:jo}),Lo=Uo.extend({type:zi("user_fund"),attributes:ui({in_decl:zi(!1)})}),Vo=Uo.extend({type:zi("onramp"),attributes:ui({in_decl:zi(!1)}),ramp_data:ui({ramp_identifier:kn()})}),Wo=Uo.extend({type:zi("poll"),attributes:ui({in_decl:zi(!1)}),hop_data:ui({hop_identifier:kn(),input:oo,output:oo})}),Bo=Uo.extend({type:zi("bridge"),attributes:ui({in_decl:zi(!0),instr_type:zi("SOLVE_TEMPLATED")}),hop_data:ui({hop_identifier:kn(),input:oo,output:oo}),template_metadata:Mo,constraint_values:mi([lo])}),Go=Uo.extend({type:zi("transfer_out"),attributes:ui({in_decl:zi(!0),instr_type:zi("FIXED")}),hop_data:ui({hop_identifier:kn(),input:oo,output:oo}),constraint_values:mi([lo])}),Ho=pi("type",[Lo,Vo,Wo,Bo,Uo.extend({type:zi("rev_share"),attributes:ui({in_decl:zi(!0),instr_type:zi("FIXED")}),hop_data:ui({hop_identifier:kn(),input:oo,output:oo}),rev_share_config:ui({numerator:Jn(),denominator:Jn()}),constraint_values:mi([lo])}),Go,Uo.extend({type:zi("convert"),attributes:ui({in_decl:zi(!0),instr_type:zi("SOLVE")})})]),qo=ui({consume:si(Io),produce:si(Io)}),Ko=Io.extend({amount:Mi}),Yo=qo.extend({consume:si(Ko),produce:si(Ko)}),Jo=Ao.extend({net_effect:Yo}),Xo=Do.extend({details:Jo.extend({observed_metadata:ui({tx_hash:kn().optional(),purchase_status:No.optional(),step_status:Oo.optional()})}).nullable()}),Qo=Co.extend({expected_details_list:si(Jo),preconditions:si(Ko)}),er=ui({observed_details_list:si(Xo),preconditions_remaining:ui({preconditions:si(Ko),current_fulfillment:si(Ko),met:si(Kn()),all_met_timestamp:kn().nullable()}).optional()}),tr=ui({realm:so,indices:si(Bn())}),nr=ui({chain:kn(),indices:si(Bn())}),ir=ui({pieces:si(Ho),workflow_id:po,all_groups:si(tr),step_groups:si(nr),workflow_expected_details_amount:Qo}),or=gi(oo,kn()),rr=ui({request:ko,prices:or,quotes:si(ir),quote_fiat:Bi,combined_asset_details_list:si(ro),quoted_at:kn(),accept_by:kn()}),sr=pi("kind",[ui({kind:di([zi("amount"),zi("amount-downstream")]),given:kn(),limits:ui({min:kn().optional(),max:kn().optional()}),source:kn(),message:kn()}),ui({kind:zi("geolocation"),message:kn()}),ui({kind:zi("provider"),message:kn()}),ui({kind:zi("other"),message:kn()}),ui({kind:zi("unknown"),message:kn()})]),ar=ui({service_ids:si(kn()),latency_seconds:Bn(),issues:si(sr).optional()});ui({content:rr,state_token:kn(),failures:si(ar)}),ui({workflowId:po,stateToken:kn(),addresses:ui({owner_address:Wi.optional(),dest_address:Wi})});const ur=gi(kn(),kn());ui({workflow_id:po,workflow_expected_details_amount:Qo,post_creation_account_store:ur,prices:or,asset_details_list:si(ro),initiate_fund_by:kn()});const cr=ui({workflow_id:po,workflow_expected_details_amount:Qo,workflow_observed_details_amount:er,owner_address:Wi,post_creation_account_store:ur,prices:or,asset_details_list:si(ro),initiate_fund_by:kn(),initiate_fund_by_passed:Kn(),observe_by_passed:Kn(),created_at:kn(),status:So});ui({ramp_type:yi(["ONRAMP","OFFRAMP"]),workflow_id:po,group_index:Bn().int().nonnegative(),redirect_url:kn().optional()}),ui({ramp_url:kn(),is_externally_initialized:Kn(),client_secret:kn().optional()}),ui({idQuery:kn().optional(),paginationKey:kn().optional(),destAddress:Wi.optional(),ownerAddress:Wi.optional(),limit:Bn().int().positive().optional()}),ui({orders:si(cr),next_pagination_key:kn().nullable()}),ui({workflowId:po.optional(),customQueries:si(ui({spw_address:Wi,token:di([to,eo])})).optional()}).refine((e=>!(!e.workflowId&&!e.customQueries?.length)),{message:"workflow_id or custom_queries is required"}),ui({balance_results:si(ui({spw_address:Wi,token:to,value:pi("kind",[ui({kind:zi("amount"),amount:Mi}),ui({kind:zi("error")})])}))});const dr=kn(),lr=ui({workflowId:kn(),tokenAmounts:si(go),recipientAddress:Wi,acceptBlame:Kn().optional()});ui({workflow_id:kn(),payload:dr}),lr.extend({signature:zo}),ui({workflow_id:kn(),tx_id:kn()});const pr=yi(["EMBED","POPUP"]),fr=kn().refine((e=>/^(#[0-9A-Fa-f]{3,8}|rgb\(\d{1,3},\s*\d{1,3},\s*\d{1,3}\)|rgba\(\d{1,3},\s*\d{1,3},\s*\d{1,3}(\s*,\s*(0(\.\d+)?|1(\.0+)?))\))$/.test(e)),{message:"Invalid CSS color value"}),hr=ui({src:xn(),alt:kn(),width:Bn().positive(),height:Bn().positive()}),mr=ui({primaryColor:fr.optional(),backgroundColor:fr.optional(),borderColor:fr.optional(),textColor:fr.optional(),textSecondaryColor:fr.optional(),logo:hr.optional()}),_r=ei(),gr=ui({apiKey:kn().nonempty(),destinationAddress:Wi.optional(),ownerAddress:Wi.optional(),...ho.shape,customStyles:mr.optional(),targetElementId:kn().optional(),windowType:pr.default(pr.enum.POPUP).optional(),signMessage:ei().refine((e=>"function"==typeof e)).optional(),sendTransaction:ei().refine((e=>"function"==typeof e)).optional(),statusCallback:ei().refine((e=>"function"==typeof e)).optional(),signTypedData:ei().refine((e=>"function"==typeof e)).optional()}).refine((e=>!("EMBED"===e.windowType&&!e.targetElementId)),{message:"targetElementId is required when windowType is EMBED"}).refine((e=>!(!e.ownerAddress&&"function"==typeof e.signMessage)),{message:"ownerAddress is required to use signMessage"}).refine((e=>!(!e.ownerAddress&&"function"==typeof e.signTypedData)),{message:"ownerAddress is required to use signTypedData"}),vr=kn().regex(/^(https:\/\/(?:[\w-]+\.)*halliday\.xyz(?:\/.*)?|http:\/\/localhost(?::\d+)?(?:\/.*)?|https:\/\/localhost(?::\d+)?(?:\/.*)?)$/,"Invalid API baseUrl"),yr=ui({dangerouslyOverrideHallidayDomainName:xn().optional(),dangerouslyOverrideApiBaseUrl:vr.optional()}),wr=ui({apiBaseUrl:vr.optional(),hasOwner:Kn(),hasTxHandler:Kn()}),zr=ui({...gr.omit({signMessage:!0,sendTransaction:!0,statusCallback:!0}).shape,...wr.shape});var kr;exports.MessageType=void 0,(kr=exports.MessageType||(exports.MessageType={})).ACTION_TRANSACTION="ACTION_TRANSACTION",kr.EVENT_ORDER_STATUS="EVENT_ORDER_STATUS",kr.EVENT_WINDOW_CLOSE="EVENT_WINDOW_CLOSE",kr.ACTION_SIGN_MESSAGE="ACTION_SIGN_MESSAGE",kr.ACTION_PROVIDER_WIDGET="ACTION_PROVIDER_WIDGET",kr.ACTION_SIGN_TYPED_DATA="ACTION_SIGN_TYPED_DATA";const br=async(e,t,n)=>{if(!t.provider)throw new Error("Signer does not have a provider");try{await t.provider.send("wallet_switchEthereumChain",[{chainId:`0x${e.toString(16)}`}])}catch(i){if(console.error("Error switching chain",i),!n)throw i;try{await(async(e,t)=>{if(!e.provider)throw new Error("Signer does not have a provider");await e.provider.send("wallet_addEthereumChain",[t])})(t,(e=>({chainId:String(e.chain_id),blockExplorerUrls:[e.explorer],chainName:e.network,iconUrls:[e.image],nativeCurrency:e.native_currency,rpcUrls:[e.rpc]}))(n)),await t.provider.send("wallet_switchEthereumChain",[{chainId:`0x${e.toString(16)}`}])}catch(e){throw console.error("Error adding chain",e),e}}},Er=e=>{const t=zr.parse(e);return btoa(JSON.stringify(t))},Ir=e=>{const{windowOrigin:t=n,...i}=e;return`${t}/payments/quote?data=${Er(i)}`},Tr=async({apiKey:e,baseURL:t,workflowId:n})=>{let i;for(let o=1;o<=3;o++)try{const i=await fetch(`${t}/quotes/status?workflow_id=${n}`,{headers:{Authorization:`Bearer ${e}`}});if(!i.ok)throw new Error(`HTTP error! status: ${i.status}`);return await i.json()}catch(e){if(i=e instanceof Error?e:new Error(String(e)),3===o)throw i;const t=1e3*Math.pow(2,o);await new Promise((e=>setTimeout(e,t)))}throw i},$r=({address:t,message:n,signedMessage:i})=>{const o=((t,n)=>e.verifyMessage(e.toBeArray(t),n))(n,i);if(o!==t)throw new Error("Signer address does not match owner address")},xr=(()=>{let e=null,t=null,i=[];const o=()=>{i.forEach((e=>{window.removeEventListener("message",e)})),i=[]};return{openWidget:async(r,...s)=>{const a=s[999]||{},u=gr.parse(r),{dangerouslyOverrideHallidayDomainName:c,dangerouslyOverrideApiBaseUrl:d}=yr.parse(a),{sendTransaction:l,signMessage:p,statusCallback:f,signTypedData:h}=u,m=c||n,_="function"==typeof p,g="function"==typeof l;o();const v=[t=>{if(t.origin!==m||t.source!==e)return;const{type:n}=t.data||{};n===exports.MessageType.EVENT_WINDOW_CLOSE&&o()}];if(_){const t=async t=>{if(t.origin!==m||t.source!==e)return;const{type:n,payload:i}=t.data||{};if(n===exports.MessageType.ACTION_SIGN_MESSAGE){const{messageId:t,message:o,ownerAddress:r}=i;try{let i;if("function"!=typeof p)throw new Error("No signMessage function provided");i=await p({message:o,ownerAddress:r}),r&&$r({address:r,message:o,signedMessage:i}),e?.postMessage({type:n,payload:{messageId:t,signature:i}},m)}catch(i){console.error("Error signing message",i),e?.postMessage({type:n,payload:{messageId:t,error:i instanceof Error?i.message:i}},m)}}else if(n===exports.MessageType.ACTION_SIGN_TYPED_DATA){const{messageId:t,typedData:o,ownerAddress:r}=i;try{let i;if("function"!=typeof h)throw new Error("No signTypedData function provided");i=await h({typedData:o,ownerAddress:r}),e?.postMessage({type:n,payload:{messageId:t,signature:i}},m)}catch(i){console.error("Error signing typed data",i),e?.postMessage({type:n,payload:{messageId:t,error:i instanceof Error?i.message:i}},m)}}};v.push(t)}if(g){const t=async t=>{if(t.origin!==m||t.source!==e)return;const{type:n,payload:i}=t.data||{};if(n===exports.MessageType.ACTION_TRANSACTION){const{messageId:t,chainConfig:o,transaction:r}=i;try{let i;if("function"!=typeof l)throw new Error("No sendTransaction function provided");i=await l(r,o),e?.postMessage({type:n,payload:{messageId:t,txReceipt:i}},m)}catch(i){console.error("Error handling transaction",i),e?.postMessage({type:n,payload:{messageId:t,error:i instanceof Error?i.message:i}},m)}}};v.push(t)}if(f){const t=t=>{if(t.origin!==m||t.source!==e)return;const{type:n,payload:i}=t.data||{};n===exports.MessageType.EVENT_ORDER_STATUS&&f({type:n,payload:i})};v.push(t)}var y;v.push((async n=>{if(n.origin!==m||n.source!==e)return;const{type:i,payload:o}=n.data||{};if(i===exports.MessageType.ACTION_PROVIDER_WIDGET&&e){const{url:n,redirectUrl:i,providerWidgetMode:r,workflowId:s}=o||{};if(!(n&&i&&r&&s))throw new Error("Invalid provider widget payload");let a=null;if("REDIRECT"===r)e.location=n,a=e;else{if("POPUP"!==r)throw new Error("Invalid provider widget mode");t=(e=>{const t=window.innerWidth/2-240;return window.open(e,"Provider Widget",`popup left=${t} top=70 width=480 height=638`)})(n),a=t}if(await(async({apiKey:e,baseURL:t,window:n,workflowId:i})=>{for(;!n.closed;){let n;try{n=await Tr({apiKey:e,baseURL:t,workflowId:i})}catch(e){console.error("Error fetching payment status",e);break}const o=n.workflow_observed_details_amount.observed_details_list.find((e=>"ONRAMP"===e.details?.type)),r=o?.details?.observed_metadata?.purchase_status;if("COMPLETED"===r)break;await new Promise((e=>setTimeout(e,5e3)))}})({apiKey:u.apiKey,baseURL:d||"https://v2.prod.halliday.xyz",workflowId:s,window:a}),a?.closed)return;"REDIRECT"===r?e.location=i:"POPUP"===r&&(t?.close(),t=null)}})),e=(e=>{const t=window.innerWidth/2-240,{windowType:n="POPUP",targetElementId:i,windowOrigin:o}=e,r=Ir(e);let s;if("EMBED"===n){const e=document.getElementById(i);if(!e)throw new Error(`Element with id ${i} not found`);const t=document.createElement("iframe");t.src=r,t.style.width="480px",t.style.height="638px",e.innerHTML="",e.appendChild(t);const n=t=>{if(t.origin!==o||t.source!==s)return;const{type:i}=t.data||{};i===exports.MessageType.EVENT_WINDOW_CLOSE&&(window.removeEventListener("message",n),e.innerHTML="")};window.addEventListener("message",n),s=t.contentWindow}else s=window.open(r,"Halliday Payments",`popup left=${t} top=70 width=480 height=638`);return s})({...r,hasOwner:_,hasTxHandler:g,windowOrigin:m,apiBaseUrl:d}),(y=v).forEach((e=>{window.addEventListener("message",e)})),i=y}}})();const Ar=e=>({blockExplorers:{default:{name:e.network,url:e.explorer??""}},id:e.chain_id,name:e.network,nativeCurrency:e.native_currency,rpcUrls:{default:{http:[e.rpc]}}}),Zr=async({wallet:e,transaction:n,chainConfig:i})=>{const o=t.createPublicClient({chain:Ar(i),transport:t.http(i.rpc)}),r=await e.sendTransaction(((e,t)=>({account:e.from,to:e.to,value:e.value,data:e.data,gas:e.gasLimit,nonce:e.nonce,chain:Ar(t)}))(n,i));return await o.waitForTransactionReceipt({hash:r})};exports.CustomStyles=mr,exports.OrderStatus=_r,exports.PaymentsWidgetQueryParams=zr,exports.PaymentsWidgetSDKParams=gr,exports.connectSigner=e=>({getAddress:async()=>(await e()).getAddress(),signMessage:async({message:t,ownerAddress:n})=>{const i=await e(n);if(n){if(n!==await i.getAddress())throw new Error("Owner address does not match")}return await i.signMessage(t)},sendTransaction:async(t,n)=>{let i=await e();const o=await(i.provider?.getNetwork());o?.chainId?.toString()!==t.chainId.toString()&&(await br(t.chainId,i,n),i=await e());const r=await(async({signer:e,transaction:t,confirmations:n,timeout:i})=>{const o=await e.sendTransaction(t);return await o.wait(n,i)})({signer:i,transaction:t});return{transactionHash:(s=r).hash,blockHash:s.blockHash,blockNumber:s.blockNumber,from:s.from,to:s.to||void 0,rawReceipt:s};var s},signTypedData:async({typedData:t,ownerAddress:n})=>{const i=await e(n);if(n){if(n!==await i.getAddress())throw new Error("Owner address does not match")}return await(i.provider?.send("eth_signTypedData_v4",[n,t]))}}),exports.connectWallet=e=>({getAddress:async()=>await e.getAddresses(),signMessage:async({message:t,ownerAddress:n})=>await e.signMessage({account:n,message:t}),sendTransaction:async(t,n)=>{const i=await Zr({wallet:e,transaction:t,chainConfig:n});return{transactionHash:(o=i).transactionHash,blockHash:o.blockHash,blockNumber:Number(o.blockNumber),from:o.from,to:o.to||void 0,rawReceipt:o};var o},signTypedData:async({typedData:t,ownerAddress:n})=>{const i=JSON.parse(t);return await e.signTypedData({account:n,...i})}}),exports.deserializeQueryParams=e=>zr.parse(JSON.parse(atob(e))),exports.getPaymentsWidgetUrl=Ir,exports.openHallidayPayments=async function(e,...t){return xr.openWidget(e,...t)},exports.serializeQueryParams=Er;
|
|
1
|
+
"use strict";const e="https://app.halliday.xyz",t=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/;function n(e,t,n){function o(n,o){var i;Object.defineProperty(n,"_zod",{value:n._zod??{},enumerable:!1}),(i=n._zod).traits??(i.traits=new Set),n._zod.traits.add(e),t(n,o);for(const e in r.prototype)Object.defineProperty(n,e,{value:r.prototype[e].bind(n)});n._zod.constr=r,n._zod.def=o}const i=n?.Parent??Object;class s extends i{}function r(e){var t;const i=n?.Parent?new s:this;o(i,e),(t=i._zod).deferred??(t.deferred=[]);for(const e of i._zod.deferred)e();return i}return Object.defineProperty(s,"name",{value:e}),Object.defineProperty(r,"init",{value:o}),Object.defineProperty(r,Symbol.hasInstance,{value:t=>!!(n?.Parent&&t instanceof n.Parent)||t?._zod?.traits?.has(e)}),Object.defineProperty(r,"name",{value:e}),r}class o extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}const i={};function s(e){return i}function r(e,t){return"bigint"==typeof t?t.toString():t}function a(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function u(e){return null==e}function c(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function d(e,t,n){Object.defineProperty(e,t,{get(){{const o=n();return e[t]=o,o}},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function l(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function p(e=10){const t="abcdefghijklmnopqrstuvwxyz";let n="";for(let o=0;o<e;o++)n+=t[Math.floor(26*Math.random())];return n}function f(e){return JSON.stringify(e)}function h(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}const m=a((()=>{try{return new Function(""),!0}catch(e){return!1}}));function _(e){return"object"==typeof e&&null!==e&&(Object.getPrototypeOf(e)===Object.prototype||null===Object.getPrototypeOf(e))}const v=new Set(["string","number","symbol"]);function g(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function y(e,t,n){const o=new e._zod.constr(t??e._zod.def);return t&&!n?.parent||(o._zod.parent=e),o}function w(e){const t=e;if(!t)return{};if("string"==typeof t)return{error:()=>t};if(void 0!==t?.message){if(void 0!==t?.error)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,"string"==typeof t.error?{...t,error:()=>t.error}:t}const z={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function k(e,t=0){for(let n=t;n<e.issues.length;n++)if(!0!==e.issues[n].continue)return!0;return!1}function b(e,t){return t.map((t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t}))}function E(e){return"string"==typeof e?e:e?.message}function I(e,t,n){const o={...e,path:e.path??[]};if(!e.message){const i=E(e.inst?._zod.def?.error?.(e))??E(t?.error?.(e))??E(n.customError?.(e))??E(n.localeError?.(e))??"Invalid input";o.message=i}return delete o.inst,delete o.continue,t?.reportInput||delete o.input,o}function $(e){return Array.isArray(e)?"array":"string"==typeof e?"string":"unknown"}function T(...e){const[t,n,o]=e;return"string"==typeof t?{message:t,code:"custom",input:n,inst:o}:{...t}}const x=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),Object.defineProperty(e,"message",{get:()=>JSON.stringify(t,r,2),enumerable:!0})},A=n("$ZodError",x),Z=n("$ZodError",x,{Parent:Error});const P=e=>(t,n,i,r)=>{const a=i?Object.assign(i,{async:!1}):{async:!1},u=t._zod.run({value:n,issues:[]},a);if(u instanceof Promise)throw new o;if(u.issues.length){const t=new(r?.Err??e)(u.issues.map((e=>I(e,a,s()))));throw Error.captureStackTrace(t,r?.callee),t}return u.value},O=e=>async(t,n,o,i)=>{const r=o?Object.assign(o,{async:!0}):{async:!0};let a=t._zod.run({value:n,issues:[]},r);if(a instanceof Promise&&(a=await a),a.issues.length){const t=new(i?.Err??e)(a.issues.map((e=>I(e,r,s()))));throw Error.captureStackTrace(t,i?.callee),t}return a.value},N=e=>(t,n,i)=>{const r=i?{...i,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},r);if(a instanceof Promise)throw new o;return a.issues.length?{success:!1,error:new(e??A)(a.issues.map((e=>I(e,r,s()))))}:{success:!0,data:a.value}},S=N(Z),D=e=>async(t,n,o)=>{const i=o?Object.assign(o,{async:!0}):{async:!0};let r=t._zod.run({value:n,issues:[]},i);return r instanceof Promise&&(r=await r),r.issues.length?{success:!1,error:new e(r.issues.map((e=>I(e,i,s()))))}:{success:!0,data:r.value}},C=D(Z),R=/^[cC][^\s-]{8,}$/,M=/^[0-9a-z]+$/,F=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,j=/^[0-9a-vA-V]{20}$/,U=/^[A-Za-z0-9]{27}$/,L=/^[a-zA-Z0-9_-]{21}$/,V=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,W=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,B=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000)$/,G=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;const H=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,K=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})$/,q=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Y=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,J=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,X=/^[A-Za-z0-9_-]*$/,Q=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/,ee=/^\+(?:[0-9]){6,14}[0-9]$/,te="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",ne=new RegExp(`^${te}$`);function oe(e){let t="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return e.precision?t=`${t}\\.\\d{${e.precision}}`:null==e.precision&&(t=`${t}(\\.\\d+)?`),t}const ie=/^\d+n?$/,se=/^\d+$/,re=/^-?\d+(?:\.\d+)?/i,ae=/true|false/i,ue=/null/i,ce=/^[^A-Z]*$/,de=/^[^a-z]*$/,le=n("$ZodCheck",((e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])})),pe={number:"number",bigint:"bigint",object:"date"},fe=n("$ZodCheckLessThan",((e,t)=>{le.init(e,t);const n=pe[typeof t.value];e._zod.onattach.push((e=>{const n=e._zod.bag,o=(t.inclusive?n.maximum:n.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<o&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)})),e._zod.check=o=>{(t.inclusive?o.value<=t.value:o.value<t.value)||o.issues.push({origin:n,code:"too_big",maximum:t.value,input:o.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}})),he=n("$ZodCheckGreaterThan",((e,t)=>{le.init(e,t);const n=pe[typeof t.value];e._zod.onattach.push((e=>{const n=e._zod.bag,o=(t.inclusive?n.minimum:n.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>o&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)})),e._zod.check=o=>{(t.inclusive?o.value>=t.value:o.value>t.value)||o.issues.push({origin:n,code:"too_small",minimum:t.value,input:o.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}})),me=n("$ZodCheckMultipleOf",((e,t)=>{le.init(e,t),e._zod.onattach.push((e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)})),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");("bigint"==typeof n.value?n.value%t.value===BigInt(0):0===function(e,t){const n=(e.toString().split(".")[1]||"").length,o=(t.toString().split(".")[1]||"").length,i=n>o?n:o;return Number.parseInt(e.toFixed(i).replace(".",""))%Number.parseInt(t.toFixed(i).replace(".",""))/10**i}(n.value,t.value))||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}})),_e=n("$ZodCheckNumberFormat",((e,t)=>{le.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),o=n?"int":"number",[i,s]=z[t.format];e._zod.onattach.push((e=>{const o=e._zod.bag;o.format=t.format,o.minimum=i,o.maximum=s,n&&(o.pattern=se)})),e._zod.check=r=>{const a=r.value;if(n){if(!Number.isInteger(a))return void r.issues.push({expected:o,format:t.format,code:"invalid_type",input:a,inst:e});if(!Number.isSafeInteger(a))return void(a>0?r.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:o,continue:!t.abort}):r.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:o,continue:!t.abort}))}a<i&&r.issues.push({origin:"number",input:a,code:"too_small",minimum:i,inclusive:!0,inst:e,continue:!t.abort}),a>s&&r.issues.push({origin:"number",input:a,code:"too_big",maximum:s,inst:e})}})),ve=n("$ZodCheckMaxLength",((e,t)=>{le.init(e,t),e._zod.when=e=>{const t=e.value;return!u(t)&&void 0!==t.length},e._zod.onattach.push((e=>{const n=e._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<n&&(e._zod.bag.maximum=t.maximum)})),e._zod.check=n=>{const o=n.value;if(o.length<=t.maximum)return;const i=$(o);n.issues.push({origin:i,code:"too_big",maximum:t.maximum,input:o,inst:e,continue:!t.abort})}})),ge=n("$ZodCheckMinLength",((e,t)=>{le.init(e,t),e._zod.when=e=>{const t=e.value;return!u(t)&&void 0!==t.length},e._zod.onattach.push((e=>{const n=e._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>n&&(e._zod.bag.minimum=t.minimum)})),e._zod.check=n=>{const o=n.value;if(o.length>=t.minimum)return;const i=$(o);n.issues.push({origin:i,code:"too_small",minimum:t.minimum,input:o,inst:e,continue:!t.abort})}})),ye=n("$ZodCheckLengthEquals",((e,t)=>{le.init(e,t),e._zod.when=e=>{const t=e.value;return!u(t)&&void 0!==t.length},e._zod.onattach.push((e=>{const n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length})),e._zod.check=n=>{const o=n.value,i=o.length;if(i===t.length)return;const s=$(o),r=i>t.length;n.issues.push({origin:s,...r?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},input:n.value,inst:e,continue:!t.abort})}})),we=n("$ZodCheckStringFormat",((e,t)=>{var n;le.init(e,t),e._zod.onattach.push((e=>{const n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??(n.patterns=new Set),n.patterns.add(t.pattern))})),(n=e._zod).check??(n.check=n=>{if(!t.pattern)throw new Error("Not implemented.");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})})})),ze=n("$ZodCheckRegex",((e,t)=>{we.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})}})),ke=n("$ZodCheckLowerCase",((e,t)=>{t.pattern??(t.pattern=ce),we.init(e,t)})),be=n("$ZodCheckUpperCase",((e,t)=>{t.pattern??(t.pattern=de),we.init(e,t)})),Ee=n("$ZodCheckIncludes",((e,t)=>{le.init(e,t);const n=g(t.includes),o=new RegExp("number"==typeof t.position?`^.{${t.position}}${n}`:n);t.pattern=o,e._zod.onattach.push((e=>{const t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(o)})),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:n.value,inst:e,continue:!t.abort})}})),Ie=n("$ZodCheckStartsWith",((e,t)=>{le.init(e,t);const n=new RegExp(`^${g(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push((e=>{const t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(n)})),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}})),$e=n("$ZodCheckEndsWith",((e,t)=>{le.init(e,t);const n=new RegExp(`.*${g(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push((e=>{const t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(n)})),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}})),Te=n("$ZodCheckOverwrite",((e,t)=>{le.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}));class xe{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if("function"==typeof e)return e(this,{execution:"sync"}),void e(this,{execution:"async"});const t=e.split("\n").filter((e=>e)),n=Math.min(...t.map((e=>e.length-e.trimStart().length))),o=t.map((e=>e.slice(n))).map((e=>" ".repeat(2*this.indent)+e));for(const e of o)this.content.push(e)}compile(){const e=Function,t=this?.args;return new e(...t,[...(this?.content??[""]).map((e=>` ${e}`))].join("\n"))}}const Ae={major:4,minor:0,patch:0},Ze=n("$ZodType",((e,t)=>{var n;e??(e={}),e._zod.id=t.type+"_"+p(10),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Ae;const i=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&i.unshift(e);for(const t of i)for(const n of t._zod.onattach)n(e);if(0===i.length)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push((()=>{e._zod.run=e._zod.parse}));else{const t=(e,t,n)=>{let i,s=k(e);for(const r of t){if(r._zod.when){if(!r._zod.when(e))continue}else if(s)continue;const t=e.issues.length,a=r._zod.check(e);if(a instanceof Promise&&!1===n?.async)throw new o;if(i||a instanceof Promise)i=(i??Promise.resolve()).then((async()=>{await a;e.issues.length!==t&&(s||(s=k(e,t)))}));else{if(e.issues.length===t)continue;s||(s=k(e,t))}}return i?i.then((()=>e)):e};e._zod.run=(n,s)=>{const r=e._zod.parse(n,s);if(r instanceof Promise){if(!1===s.async)throw new o;return r.then((e=>t(e,i,s)))}return t(r,i,s)}}e["~standard"]={validate:t=>{try{const n=S(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch(n){return C(e,t).then((e=>e.success?{value:e.data}:{issues:e.error?.issues}))}},vendor:"zod",version:1}})),Pe=n("$ZodString",((e,t)=>{var n;Ze.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??(n=e._zod.bag,new RegExp(`^${n?`[\\s\\S]{${n?.minimum??0},${n?.maximum??""}}`:"[\\s\\S]*"}$`)),e._zod.parse=(n,o)=>{if(t.coerce)try{n.value=String(n.value)}catch(o){}return"string"==typeof n.value||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}})),Oe=n("$ZodStringFormat",((e,t)=>{we.init(e,t),Pe.init(e,t)})),Ne=n("$ZodGUID",((e,t)=>{t.pattern??(t.pattern=W),Oe.init(e,t)})),Se=n("$ZodUUID",((e,t)=>{if(t.version){const e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(void 0===e)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=B(e))}else t.pattern??(t.pattern=B());Oe.init(e,t)})),De=n("$ZodEmail",((e,t)=>{t.pattern??(t.pattern=G),Oe.init(e,t)})),Ce=n("$ZodURL",((e,t)=>{Oe.init(e,t),e._zod.check=n=>{try{const o=new URL(n.value);return t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(o.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:Q.source,input:n.value,inst:e})),void(t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e})))}catch(t){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e})}}})),Re=n("$ZodEmoji",((e,t)=>{t.pattern??(t.pattern=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),Oe.init(e,t)})),Me=n("$ZodNanoID",((e,t)=>{t.pattern??(t.pattern=L),Oe.init(e,t)})),Fe=n("$ZodCUID",((e,t)=>{t.pattern??(t.pattern=R),Oe.init(e,t)})),je=n("$ZodCUID2",((e,t)=>{t.pattern??(t.pattern=M),Oe.init(e,t)})),Ue=n("$ZodULID",((e,t)=>{t.pattern??(t.pattern=F),Oe.init(e,t)})),Le=n("$ZodXID",((e,t)=>{t.pattern??(t.pattern=j),Oe.init(e,t)})),Ve=n("$ZodKSUID",((e,t)=>{t.pattern??(t.pattern=U),Oe.init(e,t)})),We=n("$ZodISODateTime",((e,t)=>{t.pattern??(t.pattern=function(e){let t=`${te}T${oe(e)}`;const n=[];return n.push(e.local?"Z?":"Z"),e.offset&&n.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${n.join("|")})`,new RegExp(`^${t}$`)}(t)),Oe.init(e,t)})),Be=n("$ZodISODate",((e,t)=>{t.pattern??(t.pattern=ne),Oe.init(e,t)})),Ge=n("$ZodISOTime",((e,t)=>{t.pattern??(t.pattern=new RegExp(`^${oe(t)}$`)),Oe.init(e,t)})),He=n("$ZodISODuration",((e,t)=>{t.pattern??(t.pattern=V),Oe.init(e,t)})),Ke=n("$ZodIPv4",((e,t)=>{t.pattern??(t.pattern=H),Oe.init(e,t),e._zod.onattach.push((e=>{e._zod.bag.format="ipv4"}))})),qe=n("$ZodIPv6",((e,t)=>{t.pattern??(t.pattern=K),Oe.init(e,t),e._zod.onattach.push((e=>{e._zod.bag.format="ipv6"})),e._zod.check=t=>{try{new URL(`http://[${t.value}]`)}catch{t.issues.push({code:"invalid_format",format:"ipv6",input:t.value,inst:e})}}})),Ye=n("$ZodCIDRv4",((e,t)=>{t.pattern??(t.pattern=q),Oe.init(e,t)})),Je=n("$ZodCIDRv6",((e,t)=>{t.pattern??(t.pattern=Y),Oe.init(e,t),e._zod.check=t=>{const[n,o]=t.value.split("/");try{if(!o)throw new Error;const e=Number(o);if(`${e}`!==o)throw new Error;if(e<0||e>128)throw new Error;new URL(`http://[${n}]`)}catch{t.issues.push({code:"invalid_format",format:"cidrv6",input:t.value,inst:e})}}}));function Xe(e){if(""===e)return!0;if(e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}const Qe=n("$ZodBase64",((e,t)=>{t.pattern??(t.pattern=J),Oe.init(e,t),e._zod.onattach.push((e=>{e._zod.bag.contentEncoding="base64"})),e._zod.check=t=>{Xe(t.value)||t.issues.push({code:"invalid_format",format:"base64",input:t.value,inst:e})}}));const et=n("$ZodBase64URL",((e,t)=>{t.pattern??(t.pattern=X),Oe.init(e,t),e._zod.onattach.push((e=>{e._zod.bag.contentEncoding="base64url"})),e._zod.check=t=>{(function(e){if(!X.test(e))return!1;const t=e.replace(/[-_]/g,(e=>"-"===e?"+":"/"));return Xe(t.padEnd(4*Math.ceil(t.length/4),"="))})(t.value)||t.issues.push({code:"invalid_format",format:"base64url",input:t.value,inst:e})}})),tt=n("$ZodE164",((e,t)=>{t.pattern??(t.pattern=ee),Oe.init(e,t)}));const nt=n("$ZodJWT",((e,t)=>{Oe.init(e,t),e._zod.check=n=>{(function(e,t=null){try{const n=e.split(".");if(3!==n.length)return!1;const[o]=n,i=JSON.parse(atob(o));return!("typ"in i&&"JWT"!==i?.typ||!i.alg||t&&(!("alg"in i)||i.alg!==t))}catch{return!1}})(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e})}})),ot=n("$ZodNumber",((e,t)=>{Ze.init(e,t),e._zod.pattern=e._zod.bag.pattern??re,e._zod.parse=(n,o)=>{if(t.coerce)try{n.value=Number(n.value)}catch(e){}const i=n.value;if("number"==typeof i&&!Number.isNaN(i)&&Number.isFinite(i))return n;const s="number"==typeof i?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:i,inst:e,...s?{received:s}:{}}),n}})),it=n("$ZodNumber",((e,t)=>{_e.init(e,t),ot.init(e,t)})),st=n("$ZodBoolean",((e,t)=>{Ze.init(e,t),e._zod.pattern=ae,e._zod.parse=(n,o)=>{if(t.coerce)try{n.value=Boolean(n.value)}catch(e){}const i=n.value;return"boolean"==typeof i||n.issues.push({expected:"boolean",code:"invalid_type",input:i,inst:e}),n}})),rt=n("$ZodBigInt",((e,t)=>{Ze.init(e,t),e._zod.pattern=ie,e._zod.parse=(n,o)=>{if(t.coerce)try{n.value=BigInt(n.value)}catch(e){}const{value:i}=n;return"bigint"==typeof i||n.issues.push({expected:"bigint",code:"invalid_type",input:i,inst:e}),n}})),at=n("$ZodNull",((e,t)=>{Ze.init(e,t),e._zod.pattern=ue,e._zod.values=new Set([null]),e._zod.parse=(t,n)=>{const{value:o}=t;return null===o||t.issues.push({expected:"null",code:"invalid_type",input:o,inst:e}),t}})),ut=n("$ZodAny",((e,t)=>{Ze.init(e,t),e._zod.parse=e=>e})),ct=n("$ZodUnknown",((e,t)=>{Ze.init(e,t),e._zod.parse=e=>e})),dt=n("$ZodNever",((e,t)=>{Ze.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:e}),t)}));function lt(e,t,n){e.issues.length&&t.issues.push(...b(n,e.issues)),t.value[n]=e.value}const pt=n("$ZodArray",((e,t)=>{Ze.init(e,t),e._zod.parse=(n,o)=>{const i=n.value;if(!Array.isArray(i))return n.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),n;n.value=Array(i.length);const s=[];for(let e=0;e<i.length;e++){const r=i[e],a=t.element._zod.run({value:r,issues:[]},o);a instanceof Promise?s.push(a.then((t=>lt(t,n,e)))):lt(a,n,e)}return s.length?Promise.all(s).then((()=>n)):n}}));function ft(e,t,n){e.issues.length&&t.issues.push(...b(n,e.issues)),t.value[n]=e.value}function ht(e,t,n,o){e.issues.length?void 0===o[n]?t.value[n]=n in o?void 0:e.value:t.issues.push(...b(n,e.issues)):void 0===e.value?n in o&&(t.value[n]=void 0):t.value[n]=e.value}const mt=n("$ZodObject",((e,t)=>{Ze.init(e,t);const n=a((()=>{const e=Object.keys(t.shape);for(const n of e)if(!(t.shape[n]instanceof Ze))throw new Error(`Invalid element at key "${n}": expected a Zod schema`);const n=(o=t.shape,Object.keys(o).filter((e=>"optional"===o[e]._zod.optin&&"optional"===o[e]._zod.optout)));var o;return{shape:t.shape,keys:e,keySet:new Set(e),numKeys:e.length,optionalKeys:new Set(n)}}));d(e._zod,"propValues",(()=>{const e=t.shape,n={};for(const t in e){const o=e[t]._zod;if(o.values){n[t]??(n[t]=new Set);for(const e of o.values)n[t].add(e)}}return n}));let o;const s=h,r=!i.jitless,u=r&&m.value,{catchall:c}=t;let l;e._zod.parse=(i,a)=>{l??(l=n.value);const d=i.value;if(!s(d))return i.issues.push({expected:"object",code:"invalid_type",input:d,inst:e}),i;const h=[];if(r&&u&&!1===a?.async&&!0!==a.jitless)o||(o=(e=>{const t=new xe(["shape","payload","ctx"]),{keys:o,optionalKeys:i}=n.value,s=e=>{const t=f(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write("const input = payload.value;");const r=Object.create(null);for(const e of o)r[e]=p(15);t.write("const newResult = {}");for(const e of o)if(i.has(e)){const n=r[e];t.write(`const ${n} = ${s(e)};`);const o=f(e);t.write(`\n if (${n}.issues.length) {\n if (input[${o}] === undefined) {\n if (${o} in input) {\n newResult[${o}] = undefined;\n }\n } else {\n payload.issues = payload.issues.concat(\n ${n}.issues.map((iss) => ({\n ...iss,\n path: iss.path ? [${o}, ...iss.path] : [${o}],\n }))\n );\n }\n } else if (${n}.value === undefined) {\n if (${o} in input) newResult[${o}] = undefined;\n } else {\n newResult[${o}] = ${n}.value;\n }\n `)}else{const n=r[e];t.write(`const ${n} = ${s(e)};`),t.write(`\n if (${n}.issues.length) payload.issues = payload.issues.concat(${n}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${f(e)}, ...iss.path] : [${f(e)}]\n })));`),t.write(`newResult[${f(e)}] = ${n}.value`)}t.write("payload.value = newResult;"),t.write("return payload;");const a=t.compile();return(t,n)=>a(e,t,n)})(t.shape)),i=o(i,a);else{i.value={};const e=l.shape;for(const t of l.keys){const n=e[t],o=n._zod.run({value:d[t],issues:[]},a),s="optional"===n._zod.optin&&"optional"===n._zod.optout;o instanceof Promise?h.push(o.then((e=>s?ht(e,i,t,d):ft(e,i,t)))):s?ht(o,i,t,d):ft(o,i,t)}}if(!c)return h.length?Promise.all(h).then((()=>i)):i;const m=[],_=l.keySet,v=c._zod,g=v.def.type;for(const e of Object.keys(d)){if(_.has(e))continue;if("never"===g){m.push(e);continue}const t=v.run({value:d[e],issues:[]},a);t instanceof Promise?h.push(t.then((t=>ft(t,i,e)))):ft(t,i,e)}return m.length&&i.issues.push({code:"unrecognized_keys",keys:m,input:d,inst:e}),h.length?Promise.all(h).then((()=>i)):i}}));function _t(e,t,n,o){for(const n of e)if(0===n.issues.length)return t.value=n.value,t;return t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map((e=>e.issues.map((e=>I(e,o,s())))))}),t}const vt=n("$ZodUnion",((e,t)=>{Ze.init(e,t),d(e._zod,"values",(()=>{if(t.options.every((e=>e._zod.values)))return new Set(t.options.flatMap((e=>Array.from(e._zod.values))))})),d(e._zod,"pattern",(()=>{if(t.options.every((e=>e._zod.pattern))){const e=t.options.map((e=>e._zod.pattern));return new RegExp(`^(${e.map((e=>c(e.source))).join("|")})$`)}})),e._zod.parse=(n,o)=>{let i=!1;const s=[];for(const e of t.options){const t=e._zod.run({value:n.value,issues:[]},o);if(t instanceof Promise)s.push(t),i=!0;else{if(0===t.issues.length)return t;s.push(t)}}return i?Promise.all(s).then((t=>_t(t,n,e,o))):_t(s,n,e,o)}})),gt=n("$ZodDiscriminatedUnion",((e,t)=>{vt.init(e,t);const n=e._zod.parse;d(e._zod,"propValues",(()=>{const e={};for(const n of t.options){const o=n._zod.propValues;if(!o||0===Object.keys(o).length)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(const[t,n]of Object.entries(o)){e[t]||(e[t]=new Set);for(const o of n)e[t].add(o)}}return e}));const o=a((()=>{const e=t.options,n=new Map;for(const o of e){const e=o._zod.propValues[t.discriminator];if(!e||0===e.size)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(o)}"`);for(const t of e){if(n.has(t))throw new Error(`Duplicate discriminator value "${String(t)}"`);n.set(t,o)}}return n}));e._zod.parse=(i,s)=>{const r=i.value;if(!h(r))return i.issues.push({code:"invalid_type",expected:"object",input:r,inst:e}),i;const a=o.value.get(r?.[t.discriminator]);return a?a._zod.run(i,s):t.unionFallback?n(i,s):(i.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",input:r,path:[t.discriminator],inst:e}),i)}})),yt=n("$ZodIntersection",((e,t)=>{Ze.init(e,t),e._zod.parse=(e,n)=>{const{value:o}=e,i=t.left._zod.run({value:o,issues:[]},n),s=t.right._zod.run({value:o,issues:[]},n);return i instanceof Promise||s instanceof Promise?Promise.all([i,s]).then((([t,n])=>zt(e,t,n))):zt(e,i,s)}}));function wt(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(_(e)&&_(t)){const n=Object.keys(t),o=Object.keys(e).filter((e=>-1!==n.indexOf(e))),i={...e,...t};for(const n of o){const o=wt(e[n],t[n]);if(!o.valid)return{valid:!1,mergeErrorPath:[n,...o.mergeErrorPath]};i[n]=o.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let o=0;o<e.length;o++){const i=wt(e[o],t[o]);if(!i.valid)return{valid:!1,mergeErrorPath:[o,...i.mergeErrorPath]};n.push(i.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function zt(e,t,n){if(t.issues.length&&e.issues.push(...t.issues),n.issues.length&&e.issues.push(...n.issues),k(e))return e;const o=wt(t.value,n.value);if(!o.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}const kt=n("$ZodTuple",((e,t)=>{Ze.init(e,t);const n=t.items,o=n.length-[...n].reverse().findIndex((e=>"optional"!==e._zod.optin));e._zod.parse=(i,s)=>{const r=i.value;if(!Array.isArray(r))return i.issues.push({input:r,inst:e,expected:"tuple",code:"invalid_type"}),i;i.value=[];const a=[];if(!t.rest){const t=r.length>n.length,s=r.length<o-1;if(t||s)return i.issues.push({input:r,inst:e,origin:"array",...t?{code:"too_big",maximum:n.length}:{code:"too_small",minimum:n.length}}),i}let u=-1;for(const e of n){if(u++,u>=r.length&&u>=o)continue;const t=e._zod.run({value:r[u],issues:[]},s);t instanceof Promise?a.push(t.then((e=>bt(e,i,u)))):bt(t,i,u)}if(t.rest){const e=r.slice(n.length);for(const n of e){u++;const e=t.rest._zod.run({value:n,issues:[]},s);e instanceof Promise?a.push(e.then((e=>bt(e,i,u)))):bt(e,i,u)}}return a.length?Promise.all(a).then((()=>i)):i}}));function bt(e,t,n){e.issues.length&&t.issues.push(...b(n,e.issues)),t.value[n]=e.value}const Et=n("$ZodRecord",((e,t)=>{Ze.init(e,t),e._zod.parse=(n,o)=>{const i=n.value;if(!_(i))return n.issues.push({expected:"record",code:"invalid_type",input:i,inst:e}),n;const r=[];if(t.keyType._zod.values){const s=t.keyType._zod.values;n.value={};for(const e of s)if("string"==typeof e||"number"==typeof e||"symbol"==typeof e){const s=t.valueType._zod.run({value:i[e],issues:[]},o);s instanceof Promise?r.push(s.then((t=>{t.issues.length&&n.issues.push(...b(e,t.issues)),n.value[e]=t.value}))):(s.issues.length&&n.issues.push(...b(e,s.issues)),n.value[e]=s.value)}let a;for(const e in i)s.has(e)||(a=a??[],a.push(e));a&&a.length>0&&n.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:a})}else{n.value={};for(const a of Reflect.ownKeys(i)){if("__proto__"===a)continue;const u=t.keyType._zod.run({value:a,issues:[]},o);if(u instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(u.issues.length){n.issues.push({origin:"record",code:"invalid_key",issues:u.issues.map((e=>I(e,o,s()))),input:a,path:[a],inst:e}),n.value[u.value]=u.value;continue}const c=t.valueType._zod.run({value:i[a],issues:[]},o);c instanceof Promise?r.push(c.then((e=>{e.issues.length&&n.issues.push(...b(a,e.issues)),n.value[u.value]=e.value}))):(c.issues.length&&n.issues.push(...b(a,c.issues)),n.value[u.value]=c.value)}}return r.length?Promise.all(r).then((()=>n)):n}})),It=n("$ZodEnum",((e,t)=>{Ze.init(e,t);const n=function(e){const t=Object.values(e).filter((e=>"number"==typeof e));return Object.entries(e).filter((([e,n])=>-1===t.indexOf(+e))).map((([e,t])=>t))}(t.entries);e._zod.values=new Set(n),e._zod.pattern=new RegExp(`^(${n.filter((e=>v.has(typeof e))).map((e=>"string"==typeof e?g(e):e.toString())).join("|")})$`),e._zod.parse=(t,o)=>{const i=t.value;return e._zod.values.has(i)||t.issues.push({code:"invalid_value",values:n,input:i,inst:e}),t}})),$t=n("$ZodLiteral",((e,t)=>{Ze.init(e,t),e._zod.values=new Set(t.values),e._zod.pattern=new RegExp(`^(${t.values.map((e=>"string"==typeof e?g(e):e?e.toString():String(e))).join("|")})$`),e._zod.parse=(n,o)=>{const i=n.value;return e._zod.values.has(i)||n.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),n}})),Tt=n("$ZodTransform",((e,t)=>{Ze.init(e,t),e._zod.parse=(e,n)=>{const i=t.transform(e.value,e);if(n.async){return(i instanceof Promise?i:Promise.resolve(i)).then((t=>(e.value=t,e)))}if(i instanceof Promise)throw new o;return e.value=i,e}})),xt=n("$ZodOptional",((e,t)=>{Ze.init(e,t),e._zod.optin="optional",e._zod.optout="optional",d(e._zod,"values",(()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0)),d(e._zod,"pattern",(()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${c(e.source)})?$`):void 0})),e._zod.parse=(e,n)=>void 0===e.value?e:t.innerType._zod.run(e,n)})),At=n("$ZodNullable",((e,t)=>{Ze.init(e,t),d(e._zod,"optin",(()=>t.innerType._zod.optin)),d(e._zod,"optout",(()=>t.innerType._zod.optout)),d(e._zod,"pattern",(()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${c(e.source)}|null)$`):void 0})),d(e._zod,"values",(()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0)),e._zod.parse=(e,n)=>null===e.value?e:t.innerType._zod.run(e,n)})),Zt=n("$ZodDefault",((e,t)=>{Ze.init(e,t),e._zod.optin="optional",d(e._zod,"values",(()=>t.innerType._zod.values)),e._zod.parse=(e,n)=>{if(void 0===e.value)return e.value=t.defaultValue,e;const o=t.innerType._zod.run(e,n);return o instanceof Promise?o.then((e=>Pt(e,t))):Pt(o,t)}}));function Pt(e,t){return void 0===e.value&&(e.value=t.defaultValue),e}const Ot=n("$ZodPrefault",((e,t)=>{Ze.init(e,t),e._zod.optin="optional",d(e._zod,"values",(()=>t.innerType._zod.values)),e._zod.parse=(e,n)=>(void 0===e.value&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))})),Nt=n("$ZodNonOptional",((e,t)=>{Ze.init(e,t),d(e._zod,"values",(()=>{const e=t.innerType._zod.values;return e?new Set([...e].filter((e=>void 0!==e))):void 0})),e._zod.parse=(n,o)=>{const i=t.innerType._zod.run(n,o);return i instanceof Promise?i.then((t=>St(t,e))):St(i,e)}}));function St(e,t){return e.issues.length||void 0!==e.value||e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const Dt=n("$ZodCatch",((e,t)=>{Ze.init(e,t),d(e._zod,"optin",(()=>t.innerType._zod.optin)),d(e._zod,"optout",(()=>t.innerType._zod.optout)),d(e._zod,"values",(()=>t.innerType._zod.values)),e._zod.parse=(e,n)=>{const o=t.innerType._zod.run(e,n);return o instanceof Promise?o.then((o=>(e.value=o.value,o.issues.length&&(e.value=t.catchValue({...e,error:{issues:o.issues.map((e=>I(e,n,s())))},input:e.value}),e.issues=[]),e))):(e.value=o.value,o.issues.length&&(e.value=t.catchValue({...e,error:{issues:o.issues.map((e=>I(e,n,s())))},input:e.value}),e.issues=[]),e)}})),Ct=n("$ZodPipe",((e,t)=>{Ze.init(e,t),d(e._zod,"values",(()=>t.in._zod.values)),d(e._zod,"optin",(()=>t.in._zod.optin)),d(e._zod,"optout",(()=>t.out._zod.optout)),e._zod.parse=(e,n)=>{const o=t.in._zod.run(e,n);return o instanceof Promise?o.then((e=>Rt(e,t,n))):Rt(o,t,n)}}));function Rt(e,t,n){return k(e)?e:t.out._zod.run({value:e.value,issues:e.issues},n)}const Mt=n("$ZodReadonly",((e,t)=>{Ze.init(e,t),d(e._zod,"propValues",(()=>t.innerType._zod.propValues)),d(e._zod,"optin",(()=>t.innerType._zod.optin)),d(e._zod,"optout",(()=>t.innerType._zod.optout)),e._zod.parse=(e,n)=>{const o=t.innerType._zod.run(e,n);return o instanceof Promise?o.then(Ft):Ft(o)}}));function Ft(e){return e.value=Object.freeze(e.value),e}const jt=n("$ZodLazy",((e,t)=>{Ze.init(e,t),d(e._zod,"innerType",(()=>t.getter())),d(e._zod,"pattern",(()=>e._zod.innerType._zod.pattern)),d(e._zod,"propValues",(()=>e._zod.innerType._zod.propValues)),d(e._zod,"optin",(()=>e._zod.innerType._zod.optin)),d(e._zod,"optout",(()=>e._zod.innerType._zod.optout)),e._zod.parse=(t,n)=>e._zod.innerType._zod.run(t,n)})),Ut=n("$ZodCustom",((e,t)=>{le.init(e,t),Ze.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{const o=n.value,i=t.fn(o);if(i instanceof Promise)return i.then((t=>Lt(t,n,o,e)));Lt(i,n,o,e)}}));function Lt(e,t,n,o){if(!e){const e={code:"custom",input:n,inst:o,path:[...o._zod.def.path??[]],continue:!o._zod.def.abort};o._zod.def.params&&(e.params=o._zod.def.params),t.issues.push(T(e))}}class Vt{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){const n=t[0];if(this._map.set(e,n),n&&"object"==typeof n&&"id"in n){if(this._idmap.has(n.id))throw new Error(`ID ${n.id} already exists in the registry`);this._idmap.set(n.id,e)}return this}remove(e){return this._map.delete(e),this}get(e){const t=e._zod.parent;if(t){const n={...this.get(t)??{}};return delete n.id,{...n,...this._map.get(e)}}return this._map.get(e)}has(e){return this._map.has(e)}}function Wt(){return new Vt}const Bt=Wt();function Gt(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...w(t)})}function Ht(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...w(t)})}function Kt(e,t){return new fe({check:"less_than",...w(t),value:e,inclusive:!1})}function qt(e,t){return new fe({check:"less_than",...w(t),value:e,inclusive:!0})}function Yt(e,t){return new he({check:"greater_than",...w(t),value:e,inclusive:!1})}function Jt(e,t){return new he({check:"greater_than",...w(t),value:e,inclusive:!0})}function Xt(e,t){return new me({check:"multiple_of",...w(t),value:e})}function Qt(e,t){return new ve({check:"max_length",...w(t),maximum:e})}function en(e,t){return new ge({check:"min_length",...w(t),minimum:e})}function tn(e,t){return new ye({check:"length_equals",...w(t),length:e})}function nn(e){return new Te({check:"overwrite",tx:e})}const on=n("ZodISODateTime",((e,t)=>{We.init(e,t),zn.init(e,t)}));function sn(e){return function(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...w(t)})}(on,e)}const rn=n("ZodISODate",((e,t)=>{Be.init(e,t),zn.init(e,t)}));function an(e){return function(e,t){return new e({type:"string",format:"date",check:"string_format",...w(t)})}(rn,e)}const un=n("ZodISOTime",((e,t)=>{Ge.init(e,t),zn.init(e,t)}));function cn(e){return function(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...w(t)})}(un,e)}const dn=n("ZodISODuration",((e,t)=>{He.init(e,t),zn.init(e,t)}));function ln(e){return function(e,t){return new e({type:"string",format:"duration",check:"string_format",...w(t)})}(dn,e)}const pn=n("ZodError",((e,t)=>{A.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:t=>function(e,t){const n=t||function(e){return e.message},o={_errors:[]},i=e=>{for(const t of e.issues)if("invalid_union"===t.code&&t.errors.length)t.errors.map((e=>i({issues:e})));else if("invalid_key"===t.code)i({issues:t.issues});else if("invalid_element"===t.code)i({issues:t.issues});else if(0===t.path.length)o._errors.push(n(t));else{let e=o,i=0;for(;i<t.path.length;){const o=t.path[i];i===t.path.length-1?(e[o]=e[o]||{_errors:[]},e[o]._errors.push(n(t))):e[o]=e[o]||{_errors:[]},e=e[o],i++}}};return i(e),o}(e,t)},flatten:{value:t=>function(e,t=e=>e.message){const n={},o=[];for(const i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):o.push(t(i));return{formErrors:o,fieldErrors:n}}(e,t)},addIssue:{value:t=>e.issues.push(t)},addIssues:{value:t=>e.issues.push(...t)},isEmpty:{get:()=>0===e.issues.length}})}),{Parent:Error}),fn=P(pn),hn=O(pn),mn=N(pn),_n=D(pn),vn=n("ZodType",((e,t)=>(Ze.init(e,t),e.def=t,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone({...t,checks:[...t.checks??[],...n.map((e=>"function"==typeof e?{_zod:{check:e,def:{check:"custom"},onattach:[]}}:e))]}),e.clone=(t,n)=>y(e,t,n),e.brand=()=>e,e.register=(t,n)=>(t.add(e,n),e),e.parse=(t,n)=>fn(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>mn(e,t,n),e.parseAsync=async(t,n)=>hn(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>_n(e,t,n),e.spa=e.safeParseAsync,e.refine=(t,n)=>e.check(function(e,t={}){return function(e,t,n){return new e({type:"custom",check:"custom",fn:t,...w(n)})}(Do,e,t)}(t,n)),e.superRefine=t=>e.check(function(e,t){const n=function(e,t){const n=new le({check:"custom",...w(t)});return n._zod.check=e,n}((t=>(t.addIssue=e=>{if("string"==typeof e)t.issues.push(T(e,t.value,n._zod.def));else{const o=e;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=t.value),o.inst??(o.inst=n),o.continue??(o.continue=!n._zod.def.abort),t.issues.push(T(o))}},e(t.value,t))),t);return n}(t)),e.overwrite=t=>e.check(nn(t)),e.optional=()=>Eo(e),e.nullable=()=>$o(e),e.nullish=()=>Eo($o(e)),e.nonoptional=t=>function(e,t){return new Ao({type:"nonoptional",innerType:e,...w(t)})}(e,t),e.array=()=>io(e),e.or=t=>uo([e,t]),e.and=t=>new po({type:"intersection",left:e,right:t}),e.transform=t=>Oo(e,ko(t)),e.default=t=>{return n=t,new To({type:"default",innerType:e,get defaultValue(){return"function"==typeof n?n():n}});var n},e.prefault=t=>{return n=t,new xo({type:"prefault",innerType:e,get defaultValue(){return"function"==typeof n?n():n}});var n},e.catch=t=>{return new Zo({type:"catch",innerType:e,catchValue:"function"==typeof(n=t)?n:()=>n});var n},e.pipe=t=>Oo(e,t),e.readonly=()=>new No({type:"readonly",innerType:e}),e.describe=t=>{const n=e.clone();return Bt.add(n,{description:t}),n},Object.defineProperty(e,"description",{get:()=>Bt.get(e)?.description,configurable:!0}),e.meta=(...t)=>{if(0===t.length)return Bt.get(e);const n=e.clone();return Bt.add(n,t[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e))),gn=n("_ZodString",((e,t)=>{Pe.init(e,t),vn.init(e,t);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...t)=>e.check(function(e,t){return new ze({check:"string_format",format:"regex",...w(t),pattern:e})}(...t)),e.includes=(...t)=>e.check(function(e,t){return new Ee({check:"string_format",format:"includes",...w(t),includes:e})}(...t)),e.startsWith=(...t)=>e.check(function(e,t){return new Ie({check:"string_format",format:"starts_with",...w(t),prefix:e})}(...t)),e.endsWith=(...t)=>e.check(function(e,t){return new $e({check:"string_format",format:"ends_with",...w(t),suffix:e})}(...t)),e.min=(...t)=>e.check(en(...t)),e.max=(...t)=>e.check(Qt(...t)),e.length=(...t)=>e.check(tn(...t)),e.nonempty=(...t)=>e.check(en(1,...t)),e.lowercase=t=>e.check(function(e){return new ke({check:"string_format",format:"lowercase",...w(e)})}(t)),e.uppercase=t=>e.check(function(e){return new be({check:"string_format",format:"uppercase",...w(e)})}(t)),e.trim=()=>e.check(nn((e=>e.trim()))),e.normalize=(...t)=>e.check(function(e){return nn((t=>t.normalize(e)))}(...t)),e.toLowerCase=()=>e.check(nn((e=>e.toLowerCase()))),e.toUpperCase=()=>e.check(nn((e=>e.toUpperCase())))})),yn=n("ZodString",((e,t)=>{Pe.init(e,t),gn.init(e,t),e.email=t=>e.check(function(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...w(t)})}(kn,t)),e.url=t=>e.check(Ht(In,t)),e.jwt=t=>e.check(function(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...w(t)})}(Un,t)),e.emoji=t=>e.check(function(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...w(t)})}(Tn,t)),e.guid=t=>e.check(Gt(bn,t)),e.uuid=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...w(t)})}(En,t)),e.uuidv4=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...w(t)})}(En,t)),e.uuidv6=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...w(t)})}(En,t)),e.uuidv7=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...w(t)})}(En,t)),e.nanoid=t=>e.check(function(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...w(t)})}(xn,t)),e.guid=t=>e.check(Gt(bn,t)),e.cuid=t=>e.check(function(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...w(t)})}(An,t)),e.cuid2=t=>e.check(function(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...w(t)})}(Zn,t)),e.ulid=t=>e.check(function(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...w(t)})}(Pn,t)),e.base64=t=>e.check(function(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...w(t)})}(Mn,t)),e.base64url=t=>e.check(function(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...w(t)})}(Fn,t)),e.xid=t=>e.check(function(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...w(t)})}(On,t)),e.ksuid=t=>e.check(function(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...w(t)})}(Nn,t)),e.ipv4=t=>e.check(function(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...w(t)})}(Sn,t)),e.ipv6=t=>e.check(function(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...w(t)})}(Dn,t)),e.cidrv4=t=>e.check(function(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...w(t)})}(Cn,t)),e.cidrv6=t=>e.check(function(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...w(t)})}(Rn,t)),e.e164=t=>e.check(function(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...w(t)})}(jn,t)),e.datetime=t=>e.check(sn(t)),e.date=t=>e.check(an(t)),e.time=t=>e.check(cn(t)),e.duration=t=>e.check(ln(t))}));function wn(e){return function(e,t){return new e({type:"string",...w(t)})}(yn,e)}const zn=n("ZodStringFormat",((e,t)=>{Oe.init(e,t),gn.init(e,t)})),kn=n("ZodEmail",((e,t)=>{De.init(e,t),zn.init(e,t)})),bn=n("ZodGUID",((e,t)=>{Ne.init(e,t),zn.init(e,t)})),En=n("ZodUUID",((e,t)=>{Se.init(e,t),zn.init(e,t)})),In=n("ZodURL",((e,t)=>{Ce.init(e,t),zn.init(e,t)}));function $n(e){return Ht(In,e)}const Tn=n("ZodEmoji",((e,t)=>{Re.init(e,t),zn.init(e,t)})),xn=n("ZodNanoID",((e,t)=>{Me.init(e,t),zn.init(e,t)})),An=n("ZodCUID",((e,t)=>{Fe.init(e,t),zn.init(e,t)})),Zn=n("ZodCUID2",((e,t)=>{je.init(e,t),zn.init(e,t)})),Pn=n("ZodULID",((e,t)=>{Ue.init(e,t),zn.init(e,t)})),On=n("ZodXID",((e,t)=>{Le.init(e,t),zn.init(e,t)})),Nn=n("ZodKSUID",((e,t)=>{Ve.init(e,t),zn.init(e,t)})),Sn=n("ZodIPv4",((e,t)=>{Ke.init(e,t),zn.init(e,t)})),Dn=n("ZodIPv6",((e,t)=>{qe.init(e,t),zn.init(e,t)})),Cn=n("ZodCIDRv4",((e,t)=>{Ye.init(e,t),zn.init(e,t)})),Rn=n("ZodCIDRv6",((e,t)=>{Je.init(e,t),zn.init(e,t)})),Mn=n("ZodBase64",((e,t)=>{Qe.init(e,t),zn.init(e,t)})),Fn=n("ZodBase64URL",((e,t)=>{et.init(e,t),zn.init(e,t)})),jn=n("ZodE164",((e,t)=>{tt.init(e,t),zn.init(e,t)})),Un=n("ZodJWT",((e,t)=>{nt.init(e,t),zn.init(e,t)})),Ln=n("ZodNumber",((e,t)=>{ot.init(e,t),vn.init(e,t),e.gt=(t,n)=>e.check(Yt(t,n)),e.gte=(t,n)=>e.check(Jt(t,n)),e.min=(t,n)=>e.check(Jt(t,n)),e.lt=(t,n)=>e.check(Kt(t,n)),e.lte=(t,n)=>e.check(qt(t,n)),e.max=(t,n)=>e.check(qt(t,n)),e.int=t=>e.check(Bn(t)),e.safe=t=>e.check(Bn(t)),e.positive=t=>e.check(Yt(0,t)),e.nonnegative=t=>e.check(Jt(0,t)),e.negative=t=>e.check(Kt(0,t)),e.nonpositive=t=>e.check(qt(0,t)),e.multipleOf=(t,n)=>e.check(Xt(t,n)),e.step=(t,n)=>e.check(Xt(t,n)),e.finite=()=>e;const n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null}));function Vn(e){return function(e,t){return new e({type:"number",checks:[],...w(t)})}(Ln,e)}const Wn=n("ZodNumberFormat",((e,t)=>{it.init(e,t),Ln.init(e,t)}));function Bn(e){return function(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...w(t)})}(Wn,e)}const Gn=n("ZodBoolean",((e,t)=>{st.init(e,t),vn.init(e,t)}));function Hn(e){return function(e,t){return new e({type:"boolean",...w(t)})}(Gn,e)}const Kn=n("ZodBigInt",((e,t)=>{rt.init(e,t),vn.init(e,t),e.gte=(t,n)=>e.check(Jt(t,n)),e.min=(t,n)=>e.check(Jt(t,n)),e.gt=(t,n)=>e.check(Yt(t,n)),e.gte=(t,n)=>e.check(Jt(t,n)),e.min=(t,n)=>e.check(Jt(t,n)),e.lt=(t,n)=>e.check(Kt(t,n)),e.lte=(t,n)=>e.check(qt(t,n)),e.max=(t,n)=>e.check(qt(t,n)),e.positive=t=>e.check(Yt(BigInt(0),t)),e.negative=t=>e.check(Kt(BigInt(0),t)),e.nonpositive=t=>e.check(qt(BigInt(0),t)),e.nonnegative=t=>e.check(Jt(BigInt(0),t)),e.multipleOf=(t,n)=>e.check(Xt(t,n));const n=e._zod.bag;e.minValue=n.minimum??null,e.maxValue=n.maximum??null,e.format=n.format??null}));function qn(e){return function(e,t){return new e({type:"bigint",...w(t)})}(Kn,e)}const Yn=n("ZodNull",((e,t)=>{at.init(e,t),vn.init(e,t)}));const Jn=n("ZodAny",((e,t)=>{ut.init(e,t),vn.init(e,t)}));function Xn(){return new Jn({type:"any"})}const Qn=n("ZodUnknown",((e,t)=>{ct.init(e,t),vn.init(e,t)}));function eo(){return new Qn({type:"unknown"})}const to=n("ZodNever",((e,t)=>{dt.init(e,t),vn.init(e,t)}));function no(e){return function(e,t){return new e({type:"never",...w(t)})}(to,e)}const oo=n("ZodArray",((e,t)=>{pt.init(e,t),vn.init(e,t),e.element=t.element,e.min=(t,n)=>e.check(en(t,n)),e.nonempty=t=>e.check(en(1,t)),e.max=(t,n)=>e.check(Qt(t,n)),e.length=(t,n)=>e.check(tn(t,n)),e.unwrap=()=>e.element}));function io(e,t){return function(e,t,n){return new e({type:"array",element:t,...w(n)})}(oo,e,t)}const so=n("ZodObject",((e,t)=>{mt.init(e,t),vn.init(e,t),d(e,"shape",(()=>Object.fromEntries(Object.entries(e._zod.def.shape)))),e.keyof=()=>go(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:eo()}),e.loose=()=>e.clone({...e._zod.def,catchall:eo()}),e.strict=()=>e.clone({...e._zod.def,catchall:no()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>function(e,t){const n={...e._zod.def,get shape(){const n={...e._zod.def.shape,...t};return l(this,"shape",n),n},checks:[]};return y(e,n)}(e,t),e.merge=t=>{return o=t,y(n=e,{...n._zod.def,get shape(){const e={...n._zod.def.shape,...o._zod.def.shape};return l(this,"shape",e),e},catchall:o._zod.def.catchall,checks:[]});var n,o},e.pick=t=>function(e,t){const n={},o=e._zod.def;for(const e in t){if(!(e in o.shape))throw new Error(`Unrecognized key: "${e}"`);t[e]&&(n[e]=o.shape[e])}return y(e,{...e._zod.def,shape:n,checks:[]})}(e,t),e.omit=t=>function(e,t){const n={...e._zod.def.shape},o=e._zod.def;for(const e in t){if(!(e in o.shape))throw new Error(`Unrecognized key: "${e}"`);t[e]&&delete n[e]}return y(e,{...e._zod.def,shape:n,checks:[]})}(e,t),e.partial=(...t)=>function(e,t,n){const o=t._zod.def.shape,i={...o};if(n)for(const t in n){if(!(t in o))throw new Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:"optional",innerType:o[t]}):o[t])}else for(const t in o)i[t]=e?new e({type:"optional",innerType:o[t]}):o[t];return y(t,{...t._zod.def,shape:i,checks:[]})}(bo,e,t[0]),e.required=(...t)=>function(e,t,n){const o=t._zod.def.shape,i={...o};if(n)for(const t in n){if(!(t in i))throw new Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:"nonoptional",innerType:o[t]}))}else for(const t in o)i[t]=new e({type:"nonoptional",innerType:o[t]});return y(t,{...t._zod.def,shape:i,checks:[]})}(Ao,e,t[0])}));function ro(e,t){const n={type:"object",get shape(){return l(this,"shape",{...e}),this.shape},...w(t)};return new so(n)}const ao=n("ZodUnion",((e,t)=>{vt.init(e,t),vn.init(e,t),e.options=t.options}));function uo(e,t){return new ao({type:"union",options:e,...w(t)})}const co=n("ZodDiscriminatedUnion",((e,t)=>{ao.init(e,t),gt.init(e,t)}));function lo(e,t,n){return new co({type:"union",options:t,discriminator:e,...w(n)})}const po=n("ZodIntersection",((e,t)=>{yt.init(e,t),vn.init(e,t)}));const fo=n("ZodTuple",((e,t)=>{kt.init(e,t),vn.init(e,t),e.rest=t=>e.clone({...e._zod.def,rest:t})}));function ho(e,t,n){const o=t instanceof Ze;return new fo({type:"tuple",items:e,rest:o?t:null,...w(o?n:t)})}const mo=n("ZodRecord",((e,t)=>{Et.init(e,t),vn.init(e,t),e.keyType=t.keyType,e.valueType=t.valueType}));function _o(e,t,n){return new mo({type:"record",keyType:e,valueType:t,...w(n)})}const vo=n("ZodEnum",((e,t)=>{It.init(e,t),vn.init(e,t),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(e,o)=>{const i={};for(const o of e){if(!n.has(o))throw new Error(`Key ${o} not found in enum`);i[o]=t.entries[o]}return new vo({...t,checks:[],...w(o),entries:i})},e.exclude=(e,o)=>{const i={...t.entries};for(const t of e){if(!n.has(t))throw new Error(`Key ${t} not found in enum`);delete i[t]}return new vo({...t,checks:[],...w(o),entries:i})}}));function go(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map((e=>[e,e]))):e;return new vo({type:"enum",entries:n,...w(t)})}const yo=n("ZodLiteral",((e,t)=>{$t.init(e,t),vn.init(e,t),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})}));function wo(e,t){return new yo({type:"literal",values:Array.isArray(e)?e:[e],...w(t)})}const zo=n("ZodTransform",((e,t)=>{Tt.init(e,t),vn.init(e,t),e._zod.parse=(n,o)=>{n.addIssue=o=>{if("string"==typeof o)n.issues.push(T(o,n.value,t));else{const t=o;t.fatal&&(t.continue=!1),t.code??(t.code="custom"),t.input??(t.input=n.value),t.inst??(t.inst=e),t.continue??(t.continue=!0),n.issues.push(T(t))}};const i=t.transform(n.value,n);return i instanceof Promise?i.then((e=>(n.value=e,n))):(n.value=i,n)}}));function ko(e){return new zo({type:"transform",transform:e})}const bo=n("ZodOptional",((e,t)=>{xt.init(e,t),vn.init(e,t),e.unwrap=()=>e._zod.def.innerType}));function Eo(e){return new bo({type:"optional",innerType:e})}const Io=n("ZodNullable",((e,t)=>{At.init(e,t),vn.init(e,t),e.unwrap=()=>e._zod.def.innerType}));function $o(e){return new Io({type:"nullable",innerType:e})}const To=n("ZodDefault",((e,t)=>{Zt.init(e,t),vn.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap}));const xo=n("ZodPrefault",((e,t)=>{Ot.init(e,t),vn.init(e,t),e.unwrap=()=>e._zod.def.innerType}));const Ao=n("ZodNonOptional",((e,t)=>{Nt.init(e,t),vn.init(e,t),e.unwrap=()=>e._zod.def.innerType}));const Zo=n("ZodCatch",((e,t)=>{Dt.init(e,t),vn.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap}));const Po=n("ZodPipe",((e,t)=>{Ct.init(e,t),vn.init(e,t),e.in=t.in,e.out=t.out}));function Oo(e,t){return new Po({type:"pipe",in:e,out:t})}const No=n("ZodReadonly",((e,t)=>{Mt.init(e,t),vn.init(e,t)}));const So=n("ZodLazy",((e,t)=>{jt.init(e,t),vn.init(e,t),e.unwrap=()=>e._zod.def.getter()}));const Do=n("ZodCustom",((e,t)=>{Ut.init(e,t),vn.init(e,t)}));const Co=wn().refine((e=>/^(0|[1-9]\d*)(\.\d+)?$/.test(e)),{message:"Invalid amount"}),Ro=/^(0x|0x[a-fA-F0-9]{40})$/,Mo=wn().refine((e=>Ro.test(e)),{message:"Invalid EVM token address"}),Fo=Mo.refine((e=>"0x"!==e),{message:"Invalid EVM address"}),jo=/^[1-9A-HJ-NP-Za-km-z]{32,44}$/,Uo=/^So[1-2]{41}$/,Lo=wn().refine((e=>jo.test(e)||Uo.test(e)),{message:"Invalid Solana token address"}),Vo=uo([Fo,wn().refine((e=>jo.test(e)),{message:"Invalid Solana address"})]),Wo=wn().refine((e=>/^[a-zA-Z_]{3,}$/.test(e)),{message:"Invalid fiat"}),Bo=ro({issuer:wn(),name:wn(),alias:wn().optional(),symbol:wn(),decimals:Vn()}),Go=wn(),Ho=wn().regex(/^[a-zA-Z]\w{1,7}$/,{message:"Must be a short alpha-numeric symbol"}),Ko=Vn().min(0).max(18),qo=wn().url(),Yo=wn(),Jo=ro({chain:wn(),address:Mo}),Xo=ro({chain:wo("solana"),address:Lo}),Qo=uo([Jo,Xo]),ei=wn().refine((e=>{const[t,n]=e.split(":");return Qo.safeParse({chain:t,address:n}).success}),{message:"Invalid token"}),ti=ro({name:Go,symbol:Ho,decimals:Ko,alias:Ho.optional(),image_url:qo.optional(),coingecko_id:Yo.optional(),wrapper:Ho.optional()}),ni=uo([Jo.extend(ti.shape),Xo.extend(ti.shape)]),oi=uo([ei,Wo]),ii=uo([ni,Bo]),si=lo("type",[ro({type:wo("chain"),chain:wn()}),ro({type:wo("issuer"),issuer:wn()})]),ri=wn().transform((e=>e.toLowerCase()));var ai,ui;ai=e=>"string"==typeof e?e.toUpperCase():e,ui=go(["ONRAMP","OFFRAMP"]),Oo(ko(ai),ui),ro({to:Fo,from:Fo.optional(),nonce:Vn().optional(),gasLimit:qn().optional(),gasPrice:qn().optional(),maxPriorityFeePerGas:qn().optional(),maxFeePerGas:qn().optional(),data:wn().optional(),value:qn().optional(),chainId:Vn()}),ro({transactionHash:wn().optional(),blockHash:wn().optional(),blockNumber:Vn().optional(),from:Fo.optional(),to:Fo.optional(),rawReceipt:Xn()});uo([ro({chain_id:Vn(),network:wn(),native_currency:ro({name:wn(),symbol:wn(),decimals:Vn()}),rpc:wn(),image:wn(),is_testnet:Hn(),explorer:wn()}),ro({chain_id:Vn(),network:wn()})]);const ci=ro({"#":wn()});ro({name:wn(),alpha2:wn().length(2),alpha3:wn().length(3)});const di=wn().refine((e=>t.test(e)),{message:"Invalid workflow ID"}),li=ro({onramps:io(ri).optional(),offramps:io(ri).optional(),sandbox:Hn().optional().default(!1)}),pi=li.extend({inputs:io(oi).optional(),outputs:io(oi)});uo([pi,li.extend({inputs:io(oi),outputs:io(oi).optional()})]);const fi=new So({type:"lazy",getter:()=>uo([_i,vi,gi])});const hi=ro({asset:oi,amount:Co}),mi=ro({token:ei,amount:Co}),_i=hi,vi=hi,gi=io(fi),yi=wn(),wi=lo("kind",[ro({kind:wo("FixedInputSwap"),input:hi,output:oi,quote_fiat:Wo}),ro({kind:wo("FixedOutputSwap"),input:oi,output:hi,quote_fiat:Wo})]),zi=go(["USER","DEST","HALLIDAY","SPW","REV_SHARE","BRIDGE"]),ki=ro({asset:oi,property:go(["APPROVAL","BALANCE"])}),bi=ro({account:zi,resource:ki}),Ei=bi.extend({sau:ci});wn();const Ii=ro({consume:io(Ei),produce:io(Ei)}),$i=go(["user_fund","onramp","poll","bridge","rev_share","transfer_out","convert"]),Ti=ro({type:uo([wo("ONRAMP"),wo("STEP")]),net_effect:Ii,pieces_info:io(ro({piece_type:$i,hop_data:ro({hop_identifier:wn(),input:oi,output:oi}).optional(),ramp_data:ro({ramp_identifier:wn()}).optional()})),expected_metadata:ro({step_index:Vn().optional()})}),xi=uo([wo("COMPLETE"),wo("UNREACHABLE"),wo("FAILED")]),Ai=uo([xi,wo("PENDING")]),Zi=go(["INITIALIZED","PAYMENT_SUBMITTED","COMPLETED","FAILED","NOT_FOUND"]),Pi=go(["PENDING","COMPLETED","FAILED","NOT_FOUND"]),Oi=go(["PENDING","COMPLETE","FAILED"]),Ni=ro({observed_status:Ai,details:Ti.extend({observed_metadata:ro({tx_hash:wn().optional(),purchase_status:Zi.optional(),step_status:Pi.optional()})}).nullable()}),Si=ro({expected_details_list:io(Ti),preconditions:io(Ei)});ro({tx_hash:wn(),step_status:Pi,block_timestamp:Vn(),net_effect:Ii});const Di=function(e,t){return new e({type:"null",...w(t)})}(Yn,Ci);var Ci;const Ri=uo([wo("FIXED"),wo("SOLVE"),wo("SOLVE_TEMPLATED")]),Mi=uo([ro({in_decl:wo(!0),instr_type:Ri}),ro({in_decl:wo(!1)})]),Fi=ro({type:$i,effect:Ii,attributes:Mi}),ji=Fi.extend({type:wo("user_fund"),attributes:ro({in_decl:wo(!1)})}),Ui=Fi.extend({type:wo("onramp"),attributes:ro({in_decl:wo(!1)}),ramp_data:ro({ramp_identifier:wn()})}),Li=Fi.extend({type:wo("poll"),attributes:ro({in_decl:wo(!1)}),hop_data:ro({hop_identifier:wn(),input:oi,output:oi})}),Vi=Fi.extend({type:wo("bridge"),attributes:ro({in_decl:wo(!0),instr_type:wo("SOLVE_TEMPLATED")}),hop_data:ro({hop_identifier:wn(),input:oi,output:oi}),template_metadata:Di,constraint_values:ho([ci])}),Wi=Fi.extend({type:wo("transfer_out"),attributes:ro({in_decl:wo(!0),instr_type:wo("FIXED")}),hop_data:ro({hop_identifier:wn(),input:oi,output:oi}),constraint_values:ho([ci])}),Bi=lo("type",[ji,Ui,Li,Vi,Fi.extend({type:wo("rev_share"),attributes:ro({in_decl:wo(!0),instr_type:wo("FIXED")}),hop_data:ro({hop_identifier:wn(),input:oi,output:oi}),rev_share_config:ro({numerator:qn(),denominator:qn()}),constraint_values:ho([ci])}),Wi,Fi.extend({type:wo("convert"),attributes:ro({in_decl:wo(!0),instr_type:wo("SOLVE")})})]),Gi=ro({consume:io(bi),produce:io(bi)}),Hi=bi.extend({amount:Co}),Ki=Gi.extend({consume:io(Hi),produce:io(Hi)}),qi=Ti.extend({net_effect:Ki}),Yi=Ni.extend({details:qi.extend({observed_metadata:ro({tx_hash:wn().optional(),purchase_status:Zi.optional(),step_status:Pi.optional()})}).nullable()}),Ji=Si.extend({expected_details_list:io(qi),preconditions:io(Hi)}),Xi=ro({observed_details_list:io(Yi),preconditions_remaining:ro({preconditions:io(Hi),current_fulfillment:io(Hi),met:io(Hn()),all_met_timestamp:wn().nullable()}).optional()}),Qi=ro({realm:si,indices:io(Vn())}),es=ro({chain:wn(),indices:io(Vn())}),ts=ro({pieces:io(Bi),workflow_id:di,all_groups:io(Qi),step_groups:io(es),workflow_expected_details_amount:Ji}),ns=_o(oi,wn()),os=ro({request:wi,prices:ns,quotes:io(ts),quote_fiat:Wo,combined_asset_details_list:io(ii),quoted_at:wn(),accept_by:wn()}),is=lo("kind",[ro({kind:uo([wo("amount"),wo("amount-downstream")]),given:wn(),limits:ro({min:wn().optional(),max:wn().optional()}),source:wn(),message:wn()}),ro({kind:wo("geolocation"),message:wn()}),ro({kind:wo("provider"),message:wn()}),ro({kind:wo("other"),message:wn()}),ro({kind:wo("unknown"),message:wn()})]),ss=ro({service_ids:io(wn()),latency_seconds:Vn(),issues:io(is).optional()});ro({content:os,state_token:wn(),failures:io(ss)}),ro({workflowId:di,stateToken:wn(),addresses:ro({owner_address:Vo.optional(),dest_address:Vo})});const rs=_o(wn(),wn());ro({workflow_id:di,workflow_expected_details_amount:Ji,post_creation_account_store:rs,prices:ns,asset_details_list:io(ii),initiate_fund_by:wn()});const as=ro({workflow_id:di,workflow_expected_details_amount:Ji,workflow_observed_details_amount:Xi,owner_address:Vo,post_creation_account_store:rs,prices:ns,asset_details_list:io(ii),initiate_fund_by:wn(),initiate_fund_by_passed:Hn(),observe_by_passed:Hn(),created_at:wn(),status:Oi});ro({ramp_type:go(["ONRAMP","OFFRAMP"]),workflow_id:di,group_index:Vn().int().nonnegative(),redirect_url:wn().optional()}),ro({ramp_url:wn(),is_externally_initialized:Hn(),client_secret:wn().optional()}),ro({idQuery:wn().optional(),paginationKey:wn().optional(),destAddress:Vo.optional(),ownerAddress:Vo.optional(),limit:Vn().int().positive().optional()}),ro({orders:io(as),next_pagination_key:wn().nullable()}),ro({workflowId:di.optional(),customQueries:io(ro({spw_address:Vo,token:uo([ei,Qo])})).optional()}).refine((e=>!(!e.workflowId&&!e.customQueries?.length)),{message:"workflow_id or custom_queries is required"}),ro({balance_results:io(ro({spw_address:Vo,token:ei,value:lo("kind",[ro({kind:wo("amount"),amount:Co}),ro({kind:wo("error")})])}))});const us=wn(),cs=ro({workflowId:wn(),tokenAmounts:io(mi),recipientAddress:Vo,acceptBlame:Hn().optional()});ro({workflow_id:wn(),payload:us}),cs.extend({signature:yi}),ro({workflow_id:wn(),tx_id:wn()});const ds=go(["EMBED","POPUP"]),ls=wn().refine((e=>/^(#[0-9A-Fa-f]{3,8}|rgb\(\d{1,3},\s*\d{1,3},\s*\d{1,3}\)|rgba\(\d{1,3},\s*\d{1,3},\s*\d{1,3}(\s*,\s*(0(\.\d+)?|1(\.0+)?))\))$/.test(e)),{message:"Invalid CSS color value"}),ps=ro({src:$n(),alt:wn(),width:Vn().positive(),height:Vn().positive()}),fs=ro({primaryColor:ls.optional(),backgroundColor:ls.optional(),borderColor:ls.optional(),textColor:ls.optional(),textSecondaryColor:ls.optional(),logo:ps.optional()}),hs=Xn(),ms=ro({address:Vo,signMessage:Xn().refine((e=>"function"==typeof e)).optional(),sendTransaction:Xn().refine((e=>"function"==typeof e)).optional(),signTypedData:Xn().refine((e=>"function"==typeof e)).optional()}),_s=ro({apiKey:wn().nonempty(),destinationAddress:Vo.optional(),...pi.shape,customStyles:fs.optional(),targetElementId:wn().optional(),windowType:ds.default(ds.enum.POPUP).optional(),statusCallback:Xn().refine((e=>"function"==typeof e)).optional(),owner:ms.optional(),funder:ms.omit({address:!0}).optional()}).refine((e=>!("EMBED"===e.windowType&&!e.targetElementId)),{message:"targetElementId is required when windowType is EMBED"});_s.omit({owner:!0,funder:!0});const vs=wn().regex(/^(https:\/\/(?:[\w-]+\.)*halliday\.xyz(?:\/.*)?|http:\/\/localhost(?::\d+)?(?:\/.*)?|https:\/\/localhost(?::\d+)?(?:\/.*)?)$/,"Invalid API baseUrl"),gs=ro({dangerouslyOverrideHallidayDomainName:$n().optional(),dangerouslyOverrideApiBaseUrl:vs.optional()}),ys=ro({apiBaseUrl:vs.optional(),hasOwner:Hn(),hasTxHandler:Hn(),hostOrigin:$n().nullable()}),ws=ro({..._s.omit({owner:!0,funder:!0,statusCallback:!0}).shape,...ys.shape,ownerAddress:Vo.optional()});var zs;exports.MessageType=void 0,(zs=exports.MessageType||(exports.MessageType={})).ACTION_TRANSACTION="ACTION_TRANSACTION",zs.EVENT_ORDER_STATUS="EVENT_ORDER_STATUS",zs.EVENT_WINDOW_CLOSE="EVENT_WINDOW_CLOSE",zs.ACTION_SIGN_MESSAGE="ACTION_SIGN_MESSAGE",zs.ACTION_PROVIDER_WIDGET="ACTION_PROVIDER_WIDGET",zs.ACTION_SIGN_TYPED_DATA="ACTION_SIGN_TYPED_DATA";const ks=e=>{const t=ws.parse(e);return btoa(JSON.stringify(t))},bs=t=>{const{windowOrigin:n=e,...o}=t;return`${n}/payments/quote?data=${ks(o)}`},Es=async({apiKey:e,baseURL:t,workflowId:n})=>{let o;for(let i=1;i<=3;i++)try{const o=await fetch(`${t}/quotes/status?workflow_id=${n}`,{headers:{Authorization:`Bearer ${e}`}});if(!o.ok)throw new Error(`HTTP error! status: ${o.status}`);return await o.json()}catch(e){if(o=e instanceof Error?e:new Error(String(e)),3===i)throw o;const t=1e3*Math.pow(2,i);await new Promise((e=>setTimeout(e,t)))}throw o},Is=(()=>{let t=null,n=null,o=[];const i=()=>{o.forEach((e=>{window.removeEventListener("message",e)})),o=[]};return{openWidget:async(s,...r)=>{const a=r[999]||{},u=_s.parse(s),{dangerouslyOverrideHallidayDomainName:c,dangerouslyOverrideApiBaseUrl:d}=gs.parse(a),{owner:l,statusCallback:p,funder:f}=u,h=c||e,m=l?.signMessage,_=l?.signTypedData,v=f?.sendTransaction||l?.sendTransaction,g=l?.address,y=Vo.safeParse(g).success&&"function"==typeof _,w="function"==typeof v;let z=null;try{z=window.origin}catch(e){}i();const k=[e=>{if(e.origin!==h||e.source!==t)return;const{type:n}=e.data||{};n===exports.MessageType.EVENT_WINDOW_CLOSE&&i()}];if(y){const e=async e=>{if(e.origin!==h||e.source!==t)return;const{type:n,payload:o}=e.data||{};if(n===exports.MessageType.ACTION_SIGN_MESSAGE){const{messageId:e,message:i,ownerAddress:s}=o;try{let o;if("function"!=typeof m)throw new Error("No signMessage function provided");o=await m({message:i,ownerAddress:s}),t?.postMessage({type:n,payload:{messageId:e,signature:o}},h)}catch(o){console.error("Error signing message",o),t?.postMessage({type:n,payload:{messageId:e,error:o instanceof Error?o.message:o}},h)}}else if(n===exports.MessageType.ACTION_SIGN_TYPED_DATA){const{messageId:e,typedData:i,ownerAddress:s}=o;try{let o;if("function"!=typeof _)throw new Error("No signTypedData function provided");o=await _({typedData:i,ownerAddress:s}),t?.postMessage({type:n,payload:{messageId:e,signature:o}},h)}catch(o){console.error("Error signing typed data",o),t?.postMessage({type:n,payload:{messageId:e,error:o instanceof Error?o.message:o}},h)}}};k.push(e)}if(w){const e=async e=>{if(e.origin!==h||e.source!==t)return;const{type:n,payload:o}=e.data||{};if(n===exports.MessageType.ACTION_TRANSACTION){const{messageId:e,chainConfig:i,transaction:s}=o;try{let o;if("function"!=typeof v)throw new Error("No sendTransaction function provided");o=await v(s,i),t?.postMessage({type:n,payload:{messageId:e,txReceipt:o}},h)}catch(o){console.error("Error handling transaction",o),t?.postMessage({type:n,payload:{messageId:e,error:o instanceof Error?o.message:o}},h)}}};k.push(e)}if(p){const e=e=>{if(e.origin!==h||e.source!==t)return;const{type:n,payload:o}=e.data||{};n===exports.MessageType.EVENT_ORDER_STATUS&&p({type:n,payload:o})};k.push(e)}var b;k.push((async e=>{if(e.origin!==h||e.source!==t)return;const{type:o,payload:i}=e.data||{};if(o===exports.MessageType.ACTION_PROVIDER_WIDGET&&t){const{url:e,redirectUrl:o,providerWidgetMode:s,workflowId:r}=i||{};if(!(e&&o&&s&&r))throw new Error("Invalid provider widget payload");let a=null;if("REDIRECT"===s)t.location=e,a=t;else{if("POPUP"!==s)throw new Error("Invalid provider widget mode");n=(e=>{const t=window.innerWidth/2-240;return window.open(e,"Provider Widget",`popup left=${t} top=70 width=480 height=638`)})(e),a=n}if(await(async({apiKey:e,baseURL:t,window:n,workflowId:o})=>{for(;!n.closed;){let n;try{n=await Es({apiKey:e,baseURL:t,workflowId:o})}catch(e){console.error("Error fetching payment status",e);break}const i=n.workflow_observed_details_amount.observed_details_list.find((e=>"ONRAMP"===e.details?.type)),s=i?.details?.observed_metadata?.purchase_status;if("COMPLETED"===s)break;await new Promise((e=>setTimeout(e,5e3)))}})({apiKey:u.apiKey,baseURL:d||"https://v2.prod.halliday.xyz",workflowId:r,window:a}),a?.closed)return;"REDIRECT"===s?t.location=o:"POPUP"===s&&(n?.close(),n=null)}})),t=(e=>{const t=window.innerWidth/2-240,{windowType:n="POPUP",targetElementId:o,windowOrigin:i}=e,s=bs(e);let r;if("EMBED"===n){const e=document.getElementById(o);if(!e)throw new Error(`Element with id ${o} not found`);const t=document.createElement("iframe");t.src=s,t.style.width="480px",t.style.height="638px",e.innerHTML="",e.appendChild(t);const n=t=>{if(t.origin!==i||t.source!==r)return;const{type:o}=t.data||{};o===exports.MessageType.EVENT_WINDOW_CLOSE&&(window.removeEventListener("message",n),e.innerHTML="")};window.addEventListener("message",n),r=t.contentWindow}else r=window.open(s,"Halliday Payments",`popup left=${t} top=70 width=480 height=638`);return r})({...s,hasOwner:y,hasTxHandler:w,windowOrigin:h,apiBaseUrl:d,hostOrigin:z,ownerAddress:g}),(b=k).forEach((e=>{window.addEventListener("message",e)})),o=b}}})();exports.CustomStyles=fs,exports.OrderStatus=hs,exports.PaymentsWidgetQueryParams=ws,exports.PaymentsWidgetSDKParams=_s,exports.deserializeQueryParams=e=>ws.parse(JSON.parse(atob(e))),exports.getPaymentsWidgetUrl=bs,exports.openHallidayPayments=async function(e,...t){return Is.openWidget(e,...t)},exports.serializeQueryParams=ks;
|
|
2
2
|
//# sourceMappingURL=index.cjs.min.js.map
|