wapi-client 0.12.0-beta.1 → 0.12.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/ws-client.cjs +1 -1
- package/dist/api/ws-client.js +1 -1
- package/dist/client.cjs +1 -1
- package/dist/client.js +1 -1
- package/dist/db/consts.browser.cjs +2 -0
- package/dist/db/consts.browser.js +2 -0
- package/dist/db/consts.cjs +2 -0
- package/dist/db/consts.d.ts +1 -1
- package/dist/db/consts.js +2 -0
- package/dist/fns/consts.browser.cjs +5 -0
- package/dist/fns/consts.browser.js +5 -0
- package/dist/fns/consts.cjs +6 -0
- package/dist/fns/consts.d.ts +1 -0
- package/dist/fns/consts.enums.d.ts +2 -1
- package/dist/fns/consts.js +5 -0
- package/dist/fns/create-deposit/create-deposit.browser.cjs +1 -0
- package/dist/fns/create-deposit/create-deposit.browser.js +2 -0
- package/dist/fns/create-deposit/create-deposit.cjs +1 -0
- package/dist/fns/create-deposit/create-deposit.js +2 -0
- package/dist/fns/create-deposit/create-deposit.schema.zod.browser.cjs +1 -1
- package/dist/fns/create-deposit/create-deposit.schema.zod.browser.js +5 -2
- package/dist/fns/create-deposit/create-deposit.schema.zod.cjs +1 -1
- package/dist/fns/create-deposit/create-deposit.schema.zod.d.ts +6 -6
- package/dist/fns/create-deposit/create-deposit.schema.zod.js +5 -2
- package/dist/fns/create-transfer/create-transfer.browser.cjs +1 -1
- package/dist/fns/create-transfer/create-transfer.browser.js +2 -1
- package/dist/fns/create-transfer/create-transfer.cjs +1 -1
- package/dist/fns/create-transfer/create-transfer.js +2 -1
- package/dist/fns/create-transfer/create-transfer.schema.zod.browser.cjs +1 -1
- package/dist/fns/create-transfer/create-transfer.schema.zod.browser.js +5 -2
- package/dist/fns/create-transfer/create-transfer.schema.zod.cjs +1 -1
- package/dist/fns/create-transfer/create-transfer.schema.zod.d.ts +30 -30
- package/dist/fns/create-transfer/create-transfer.schema.zod.js +5 -2
- package/dist/fns/create-transfer-group/create-transfer-group.schema.zod.d.ts +48 -48
- package/dist/fns/create-transfers/create-transfers.schema.zod.d.ts +15 -15
- package/dist/fns/create-withdrawal/create-withdrawal.browser.cjs +1 -0
- package/dist/fns/create-withdrawal/create-withdrawal.browser.js +2 -0
- package/dist/fns/create-withdrawal/create-withdrawal.cjs +1 -0
- package/dist/fns/create-withdrawal/create-withdrawal.js +2 -0
- package/dist/fns/create-withdrawal/create-withdrawal.schema.zod.browser.cjs +1 -1
- package/dist/fns/create-withdrawal/create-withdrawal.schema.zod.browser.js +5 -2
- package/dist/fns/create-withdrawal/create-withdrawal.schema.zod.cjs +1 -1
- package/dist/fns/create-withdrawal/create-withdrawal.schema.zod.d.ts +6 -6
- package/dist/fns/create-withdrawal/create-withdrawal.schema.zod.js +5 -2
- package/dist/fns/export-tokens/export-tokens.browser.cjs +1 -23
- package/dist/fns/export-tokens/export-tokens.browser.js +2 -27
- package/dist/fns/export-tokens/export-tokens.cjs +1 -23
- package/dist/fns/export-tokens/export-tokens.js +2 -27
- package/dist/fns/export-transfer-groups/export-transfer-groups.browser.cjs +2 -24
- package/dist/fns/export-transfer-groups/export-transfer-groups.browser.js +3 -28
- package/dist/fns/export-transfer-groups/export-transfer-groups.cjs +2 -24
- package/dist/fns/export-transfer-groups/export-transfer-groups.js +3 -28
- package/dist/fns/export-transfers/export-transfers.browser.cjs +2 -23
- package/dist/fns/export-transfers/export-transfers.browser.js +3 -27
- package/dist/fns/export-transfers/export-transfers.cjs +2 -23
- package/dist/fns/export-transfers/export-transfers.js +3 -27
- package/dist/fns/export-wallets/export-wallets.browser.cjs +15 -7
- package/dist/fns/export-wallets/export-wallets.browser.js +17 -8
- package/dist/fns/export-wallets/export-wallets.cjs +15 -7
- package/dist/fns/export-wallets/export-wallets.js +17 -8
- package/dist/fns/find-balances/find-balances.browser.cjs +1 -23
- package/dist/fns/find-balances/find-balances.browser.js +2 -27
- package/dist/fns/find-balances/find-balances.cjs +1 -23
- package/dist/fns/find-balances/find-balances.js +2 -27
- package/dist/fns/find-tokens/find-tokens.browser.cjs +1 -23
- package/dist/fns/find-tokens/find-tokens.browser.js +2 -27
- package/dist/fns/find-tokens/find-tokens.cjs +1 -23
- package/dist/fns/find-tokens/find-tokens.js +2 -27
- package/dist/fns/find-transfer-groups/find-transfer-groups.browser.cjs +1 -23
- package/dist/fns/find-transfer-groups/find-transfer-groups.browser.js +2 -27
- package/dist/fns/find-transfer-groups/find-transfer-groups.cjs +1 -23
- package/dist/fns/find-transfer-groups/find-transfer-groups.js +2 -27
- package/dist/fns/find-transfers/find-transfers.browser.cjs +28 -18
- package/dist/fns/find-transfers/find-transfers.browser.js +29 -19
- package/dist/fns/find-transfers/find-transfers.cjs +28 -18
- package/dist/fns/find-transfers/find-transfers.js +29 -19
- package/dist/fns/find-wallets/find-wallets.browser.cjs +14 -6
- package/dist/fns/find-wallets/find-wallets.browser.js +16 -7
- package/dist/fns/find-wallets/find-wallets.cjs +14 -6
- package/dist/fns/find-wallets/find-wallets.js +16 -7
- package/dist/fns/import-data/import-data.schema.zod.d.ts +186 -186
- package/dist/fns/index.d.ts +93 -93
- package/dist/fns/list-exports/list-exports.browser.cjs +2 -4
- package/dist/fns/list-exports/list-exports.browser.js +3 -5
- package/dist/fns/list-exports/list-exports.cjs +2 -4
- package/dist/fns/list-exports/list-exports.js +3 -5
- package/dist/lib/ts-utils.browser.cjs +1 -5
- package/dist/lib/ts-utils.browser.js +1 -5
- package/dist/lib/ts-utils.cjs +2 -7
- package/dist/lib/ts-utils.d.ts +0 -5
- package/dist/lib/ts-utils.js +1 -5
- package/dist/lib/utils.browser.cjs +27 -20
- package/dist/lib/utils.browser.js +29 -20
- package/dist/lib/utils.cjs +27 -22
- package/dist/lib/utils.d.ts +4 -5
- package/dist/lib/utils.js +25 -20
- package/dist/types/index.d.ts +392 -396
- package/dist/wapi-client-web.iife.js +1 -1
- package/dist/wapi-client.iife.js +1 -1
- package/package.json +2 -2
package/dist/wapi-client.iife.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var WAPI=(()=>{var yn=Object.defineProperty,kd=Object.defineProperties,vd=Object.getOwnPropertyDescriptor,wd=Object.getOwnPropertyDescriptors,Ed=Object.getOwnPropertyNames,Sn=Object.getOwnPropertySymbols;var So=Object.prototype.hasOwnProperty,up=Object.prototype.propertyIsEnumerable;var bo=(r,e,t)=>e in r?yn(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,d=(r,e)=>{for(var t in e||(e={}))So.call(e,t)&&bo(r,t,e[t]);if(Sn)for(var t of Sn(e))up.call(e,t)&&bo(r,t,e[t]);return r},b=(r,e)=>kd(r,wd(e));var ne=(r,e)=>{var t={};for(var o in r)So.call(r,o)&&e.indexOf(o)<0&&(t[o]=r[o]);if(r!=null&&Sn)for(var o of Sn(r))e.indexOf(o)<0&&up.call(r,o)&&(t[o]=r[o]);return t};var Md=(r,e)=>{for(var t in e)yn(r,t,{get:e[t],enumerable:!0})},Rd=(r,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Ed(e))!So.call(r,n)&&n!==t&&yn(r,n,{get:()=>e[n],enumerable:!(o=vd(e,n))||o.enumerable});return r};var Gd=r=>Rd(yn({},"__esModule",{value:!0}),r);var v=(r,e,t)=>bo(r,typeof e!="symbol"?e+"":e,t);var $=(r,e,t)=>new Promise((o,n)=>{var s=l=>{try{u(t.next(l))}catch(c){n(c)}},p=l=>{try{u(t.throw(l))}catch(c){n(c)}},u=l=>l.done?o(l.value):Promise.resolve(l.value).then(s,p);u((t=t.apply(r,e)).next())});var Oh={};Md(Oh,{APIFunctions:()=>$s,APIValidators:()=>Qs,AggregateQueryBuilder:()=>Tn,AuthError:()=>ze,AuthenticationError:()=>wt,AuthorizationError:()=>yo,Client:()=>Vr,ClientFunctions:()=>I,ClientFunctionsEnum:()=>hd,ClientValidators:()=>uh,ConfigError:()=>ge,ConstraintError:()=>_n,ERRORS:()=>le,ERROR_CODE_TO_TYPE:()=>lp,ERROR_DESCRIPTIONS:()=>fp,ERROR_GROUPS:()=>J,ERROR_MESSAGES:()=>cp,ERROR_TYPES:()=>Lr,ErrorDescription:()=>fp,ErrorMessage:()=>cp,ErrorType:()=>Lr,Errors:()=>le,InputError:()=>Q,InternalError:()=>In,JSONRPCError:()=>vt,QueryBuilder:()=>ee,QueryBuilderInterface:()=>It,ReverseQueryBuilder:()=>hn,StreamError:()=>ke,StreamPromise:()=>Be,TokenStatusEnum:()=>eu,TokenTypeEnum:()=>tu,TransferGroupStatusEnum:()=>Ln,TransferGroupTypeEnum:()=>au,TransferStatusEnum:()=>$p,TransferTypeEnum:()=>bt,UnknownError:()=>_o,UpdateQueryBuilder:()=>kt,ValidationError:()=>ve,Validator:()=>Od,WAPIError:()=>Ie,WalletStatusEnum:()=>Hp,WalletTypeEnum:()=>qp,WapiClientType:()=>_d,WapiSettingTypeEnum:()=>Sd,aggregateTransfers:()=>oi,create:()=>Fh,createAccessToken:()=>si,createContract:()=>ii,createDeposit:()=>pi,createExchange:()=>ui,createToken:()=>li,createTransfer:()=>mi,createTransferGroup:()=>hi,createTransfers:()=>gi,createWallet:()=>xi,createWithdrawal:()=>Oi,exportBalanceHistory:()=>bi,exportTokens:()=>Si,exportTransferGroups:()=>Ii,exportTransfers:()=>wi,exportWallets:()=>Ri,findBalances:()=>Gi,findTokens:()=>Wi,findTransferGroups:()=>Ci,findTransfers:()=>Ai,findWallets:()=>Ni,getBalance:()=>Di,getBalanceHistory:()=>Bi,getError:()=>kn,getExport:()=>Pi,getFlags:()=>Ui,getIdentifier:()=>Eo,getStatistics:()=>ji,getToken:()=>Vi,getTransfer:()=>Li,getTransferGroup:()=>Zi,getValidator:()=>i,getValidatorError:()=>Sp,getWallet:()=>zi,healthcheck:()=>Hi,importData:()=>qi,listExports:()=>Ji,reverseTransfer:()=>Ki,reverseTransferGroup:()=>Yi,reverseTransfers:()=>Xi,setFlags:()=>ep,updateToken:()=>tp,updateTransfer:()=>rp,updateTransferGroup:()=>np,updateTransferGroups:()=>ap,updateTransfers:()=>op,updateWallet:()=>sp,utils:()=>xh});var dp=WebSocket;function W(...r){window.WAPI_DEBUG&&console.log(...r.map(e=>e&&typeof e=="object"?JSON.stringify(e):e))}var J={JSONRPC:{min:-32700,max:-32600,ERRORS:{PARSE_ERROR:{code:-32700,message:"Parse error",description:"Unable to parse JSON input"},INVALID_REQUEST:{code:-32600,message:"Invalid request",description:"JSON input does not match JSONRPC spec"},METHOD_NOT_FOUND:{code:-32601,message:"Method not found",description:"Requested method not found"},INVALID_PARAMS:{code:-32602,message:"Invalid params",description:"Invalid params provided for method"},INTERNAL_SERVER_ERROR:{code:-32603,message:"Internal server error",description:"Unknown error occurred"}}},AUTH:{min:-20999,max:-2e4,ERRORS:{AUTHENTICATION_ERROR:{code:-2e4,message:"Authentication error",description:"Invalid authentication credentials"},AUTHORIZATION_ERROR:{code:-20001,message:"AUTHORIZATION_ERROR",description:"Provided credentials lack access rights"}}},STREAM:{min:-10999,max:-1e4,ERRORS:{CONNECTION_LOST:{code:-1e4,message:"CONNECTION_LOST",description:"Lost connection to server"},INPUT_STREAM_INVALID:{code:-10001,message:"INPUT_STREAM_INVALID",description:"Invalid input stream identifier provided"},INVALID_RESPONSE_STREAM_CHUNK:{code:-10002,message:"INVALID_RESPONSE_STREAM_CHUNK",description:"Received multiple chunks for non-array property"},INVALID_INPUT_STREAM_CHUNK:{code:-10003,message:"INVALID_INPUT_STREAM_CHUNK",description:"Invalid chunk sent to input stream"},INPUT_STREAM_TIMEOUT:{code:-10004,message:"INPUT_STREAM_TIMEOUT",description:"Input stream failed to finish in allotted time"},INPUT_STREAM_ERROR:{code:-10005,message:"INPUT_STREAM_ERROR",description:"Unknown error in input stream"},INPUT_STREAM_NOT_ALLOWED:{code:-10006,message:"INPUT_STREAM_NOT_ALLOWED",description:"Stream input not allowed for method"}}},INPUT:{min:-14999,max:-11e3,ERRORS:{HTTP_BODY_SIZE:{code:-11e3,message:"HTTP_BODY_SIZE",description:"Http body size can't be more than 100MB"},DATABASE_EXPORT_CONFLICT:{code:-12e3,message:"DATABASE_EXPORT_CONFLICT",description:"Database export already in progress"},DATABASE_IMPORT_CONFLICT:{code:-12001,message:"DATABASE_IMPORT_CONFLICT",description:"Database import already in progress"},DATABASE_EXPORT_PROGRESS_NOT_FOUND:{code:-12002,message:"DATABASE_EXPORT_PROGRESS_NOT_FOUND",description:"Database backup process not found"},DATABASE_IMPORT_PROGRESS_NOT_FOUND:{code:-12003,message:"DATABASE_IMPORT_PROGRESS_NOT_FOUND",description:"Database backup process not found"},DATABASE_IMPORT_NOT_FOUND:{code:-12004,message:"DATABASE_IMPORT_NOT_FOUND",description:"Database import file not found"},TR_CANT_UPDATE_TO_PENDING:{code:-12100,message:"TR_CANT_UPDATE_TO_PENDING",description:"Transfer status can only move from 'pending'->'finished'/'cancelled"},TR_CANT_UPDATE_TIMESTAMP:{code:-12101,message:"TR_CANT_UPDATE_TIMESTAMP",description:"Cant update transfer.updated_at - allow_timestamps flag is set to off"},TR_CANT_INSERT_TIMESTAMP:{code:-12102,message:"TR_CANT_INSERT_TIMESTAMP",description:"Cant insert transfer.created_at - allow_timestamps flag is set to off"},TR_EMPTY_UPDATE_REQUEST:{code:-12103,message:"TR_EMPTY_UPDATE_REQUEST",description:"Update request for transfer is empty"},TR_MISSING_FILTER:{code:-12104,message:"TR_MISSING_FILTER",description:"Transactions can't reversed or updated without valid filter"},TR_TO_WALLET_WITHDRAWAL:{code:-12105,message:"TR_TO_WALLET_WITHDRAWAL",description:"To wallet can't be specified when doing a withdrawal"},TR_FROM_WALLET_DEPOSIT:{code:-12106,message:"TR_FROM_WALLET_DEPOSIT",description:"From wallet can't be specified when doing a deposit"},TR_FROM_TO_CONFLICT:{code:-12107,message:"TR_FROM_TO_CONFLICT",description:"from_wallet and to_wallet can not be the same"},TR_UNABLE_TO_RESOLVE_INPUT:{code:-12108,message:"TR_UNABLE_TO_RESOLVE_INPUT",description:"Unable to resolve references to foreign keys"},TRG_MISSING_FILTER:{code:-12200,message:"TRG_MISSING_FILTER",description:"Transaction groups can't reversed or updated without valid filter"},INVALID_FIELD_AGR_COMB:{code:-12300,message:"INVALID_FIELD_AGR_COMB",description:"Provided aggregation field was not found on Model"},INVALID_FIELD_FOR_MODEL:{code:-12301,message:"INVALID_FIELD_FOR_MODEL",description:"Provided field was not found on Model"},NO_METADATA_ON_MODEL:{code:-12302,message:"NO_METADATA_ON_MODEL",description:"Can't use metadata field for grouping as current Model does not have metadata"},INVALID_MODEL:{code:-12303,message:"INVALID_MODEL",description:"Provided Model name is invalid"},INVALID_COMPLEX_FILTER:{code:-12304,message:"INVALID_COMPLEX_FILTER",description:"The provided complex filter does not pass validation"},UNCLEAR_AGGREGATOR:{code:-12305,message:"UNCLEAR_AGGREGATOR",description:"Invalid aggregator function provided"},CONTRACT_OWNER_NOT_FOUND:{code:-12306,message:"CONTRACT_OWNER_NOT_FOUND",description:"Unable to find Wallet specified as Contract token owner"},DISTRIBUTION_MISSING_TARGETS:{code:-12307,message:"DISTRIBUTION_MISSING_TARGETS",description:"Unable to resolve all targets (Wallets, Tokens) for distribution request"},TOKEN_INVALID_WALLET:{code:-12308,message:"TOKEN_INVALID_WALLET",description:"Invalid belongs_to wallet provided"},BAL_FUTURE_DATETIME:{code:-12309,message:"BAL_FUTURE_DATETIME",description:"Balance datetime can't be in the future"},INPUT_NEEDS_IDENTIFIER:{code:-12310,message:"INPUT_NEEDS_IDENTIFIER",description:"Missing identifier - automatically calculated identifiers conflict on identical input for 30s To make an identical transfer during that window you need to provide a unique identifier"},RESET_INVALID_CONFIRMATION:{code:-12311,message:"RESET_INVALID_CONFIRMATION",description:"Provided reset confirmation code is invalid"},INPUT_NEEDS_TOKEN:{code:-12312,message:"INPUT_NEEDS_TOKEN",description:"token must be specified on input or in client config"},CONFLICTING_OPTIONS_FOR_BALANCE:{code:-12313,message:"CONFLICTING_OPTIONS_FOR_BALANCE",description:"return_running_balance and return_running_balance_for can't be specified together"},CONFLICTING_OPTIONS_FOR_SIGNED_AMOUNT:{code:-12314,message:"CONFLICTING_OPTIONS_FOR_SIGNED_AMOUNT",description:"return_signed_amount and return_signed_amount_for_wallet can't be specified together"},RUNNING_BALANCE_WITHOUT_WALLET:{code:-12315,message:"RUNNING_BALANCE_WITHOUT_WALLET",description:"return_running_balance option requires Wallet filter to be specified"},SIGNED_AMOUNT_WITHOUT_WALLET:{code:-12316,message:"SIGNED_AMOUNT_WITHOUT_WALLET",description:"return_signed_amount option requires Wallet filter to be specified"},REQUIRED_INPUT_MISSING:{code:-12317,message:"REQUIRED_INPUT_MISSING",description:"input does not specify required keys"},TRX_NOT_ALLOWED:{code:-12400,message:"TRX_NOT_ALLOWED",description:"This method can not run in a transaction"},TRANSACTION_NOT_FOUND:{code:-12401,message:"TRANSACTION_NOT_FOUND",description:"Transaction not found"},ONLY_SELECT_ALLOWED:{code:-12402,message:"ONLY_SELECT_ALLOWED",description:"Only select queries are allowed"},CNT_DEPOSIT_TOKEN_MISMATCH:{code:-12500,message:"CNT_DEPOSIT_TOKEN_MISMATCH",description:"Unable to find tokens specified in deposits"}}},CONSTRAINT:{min:-19999,max:-19e3,ERRORS:{INVALID_LATEST_HASH:{code:-19e3,message:"INVALID_LATEST_HASH",description:"Http body size can't be more than 100MB"},TOKEN_LIMIT_REACHED:{code:-19001,message:"TOKEN_LIMIT_REACHED",description:"Unable to issue more tokens as Token.limit has been reached"},TR_INVALID_BALANCE:{code:-19101,message:"TR_INVALID_BALANCE",description:"Transfer would result in invalid balance for a Wallet"},TR_AMOUNT_NOT_DIVISIBLE:{code:-19102,message:"TR_AMOUNT_NOT_DIVISIBLE",description:"Transfer amount is not divisible by specified Token.divisor"},TR_TOKEN_DISABLED:{code:-19103,message:"TR_TOKEN_DISABLED",description:"Token status is set to 'disabled' - no new transfers allowed"},TR_TOKEN_DWONLY:{code:-19104,message:"TR_TOKEN_DWONLY",description:"Token status is set to 'dw-only' - only deposits or withdrawals allowed"},TR_TRG_STATUS_MISMATCH:{code:-19105,message:"TR_TRG_STATUS_MISMATCH",description:"Transfers in transfer_group must match transfer_group.transfer_status"},TR_TRG_CLOSED:{code:-19106,message:"TR_TRG_CLOSED",description:"Cant add Transfer to group. TransferGroup is closed"},TR_TIMESTAMP_IN_PAST:{code:-19107,message:"TR_TIMESTAMP_IN_PAST",description:"Transfer.created_at must not be in the past"},TR_TIMESTAMP_MUST_BE_LATEST:{code:-19108,message:"TR_TIMESTAMP_MUST_BE_LATEST",description:"Transfer.created_at must be the latest"},TR_INVALID_CANCELLED:{code:-19109,message:"TR_INVALID_CANCELLED",description:"Cant create cancelled transfer"},TR_FROM_WALLET_STATUS_CONSTRAINT:{code:-19110,message:"TR_FROM_WALLET_STATUS_CONSTRAINT",description:"From wallet.status doesn't allow this type of transfers"},TR_TO_WALLET_STATUS_CONSTRAINT:{code:-19111,message:"TR_TO_WALLET_STATUS_CONSTRAINT",description:"To wallet.status doesn't allow this type of transfers"},TR_CANCELLED_CANT_RV:{code:-19112,message:"TR_CANCELLED_CANT_RV",description:"Cancelled Transfer can not be reversed"},TR_DEPOSIT_CANT_RV_WITHOUT_FLAG:{code:-19113,message:"TR_DEPOSIT_CANT_RV_WITHOUT_FLAG",description:"Deposits are expected connection points with outside systems, thus extra validation is required. Reversing a Transfer.type = 'deposit' requires reverse_deposit option to be true."},TR_WITHDRAWAL_CANT_RV_WITHOUT_FLAG:{code:-19114,message:"TR_WITHDRAWAL_CANT_RV_WITHOUT_FLAG",description:"Withdrawals are expected connection points with outside systems, thus extra validation is required. Reversing a Transfer.type = 'withdrawal' requires reverse_withdrawal option to be true."},TR_UNIQUE_IDENTIFIER:{code:-19115,message:"TR_UNIQUE_IDENTIFIER",description:"The identifier for Transfer object must be unique"},TR_DIFFERENT_WALLETS:{code:-19116,message:"TR_DIFFERENT_WALLETS",description:"To and from wallets have to be different"},TRG_SINGLE_PENDING_TR_CANT_RV:{code:-19200,message:"TRG_SINGLE_PENDING_TR_CANT_RV",description:"Transfer is part of TransferGroup and can not be reversed separately"},TRG_CANCELLED_CANT_RV:{code:-19201,message:"TRG_CANCELLED_CANT_RV",description:"Cancelled TransferGroup can not be reversed"},TRG_DEPOSIT_CANT_RV_WITHOUT_FLAG:{code:-19202,message:"TRG_DEPOSIT_CANT_RV_WITHOUT_FLAG",description:"TransferGroup includes Transfer.type = 'deposit', thus for extra validation the reverse_deposit option must be set true"},TRG_WITHDRAWAL_CANT_RV_WITHOUT_FLAG:{code:-19203,message:"TRG_WITHDRAWAL_CANT_RV_WITHOUT_FLAG",description:"TransferGroup includes Transfer.type = 'withdrawal', thus for extra validation the reverse_withdrawal option must be set true"},TRG_UNIQUE_IDENTIFIER:{code:-19204,message:"TRG_UNIQUE_IDENTIFIER",description:"The identifier for TransferGroup object must be unique"},TOKEN_UNIQUE_FOREIGN:{code:-19300,message:"TOKEN_UNIQUE_FOREIGN",description:"The foreign for Token object must be unique"},WALLET_UNIQUE_FOREIGN:{code:-19400,message:"WALLET_UNIQUE_FOREIGN",description:"The foreign for Wallet object must be unique"},UNIQUE_CONSTRAINT:{code:-19500,message:"UNIQUE_CONSTRAINT",description:"Insert violates unique constraint"}}},CONFIG:{min:-16e3,max:-15e3,ERRORS:{METHOD_DISABLED:{code:-15e3,message:"METHOD_DISABLED",description:"Method is disabled"},FLAG_PRODUCTION_ON:{code:-15001,message:"FLAG_PRODUCTION_ON",description:'Production flag is "on" - this method is disabled'},FLAG_PRODUCTION_LOCKED:{code:-15002,message:"FLAG_PRODUCTION_LOCKED",description:"Cant update production flag to false in this server"},TRANSACTION_TIMEOUT:{code:-15003,message:"TRANSACTION_TIMEOUT",description:"Database transaction timed out"},CONNECTION_TIMEOUT:{code:-15004,message:"CONNECTION_TIMEOUT",description:"Unable to get initial response in specified time"},SENDING_TIMEOUT:{code:-15005,message:"SENDING_TIMEOUT",description:"Unable to get ack from server in specified time"},CONFIG_INVALID:{code:-15100,message:"CONFIG_INVALID",description:"Provided configuration is invalid"}}}},le=d(d(d(d(d(d({},J.JSONRPC.ERRORS),J.AUTH.ERRORS),J.CONFIG.ERRORS),J.STREAM.ERRORS),J.INPUT.ERRORS),J.CONSTRAINT.ERRORS);function tt(r){return Object.fromEntries(Object.keys(r).map(e=>[e,e]))}var Lr=tt(le),Ie=class extends Error{constructor({type:t,code:o,message:n,data:s}){var u;super(n);v(this,"type");v(this,"code");v(this,"data");let p=(u=le[t])!=null?u:le.INTERNAL_SERVER_ERROR;this.type=t!=null?t:Lr.INTERNAL_SERVER_ERROR,this.code=o!=null?o:p.code,this.message=n!=null?n:p.message,this.data=d({description:p.description},s&&typeof s=="object"?s:{error:s})}toJSON(){return{code:this.code,message:this.message,data:this.data}}},vt=class extends Ie{constructor(e,t,o,n){super({type:e,message:o,data:t,code:n})}static get group(){return J.JSONRPC.ERRORS}static get types(){return tt(J.JSONRPC.ERRORS)}},ke=class extends Ie{constructor(e,t,o,n){super({type:e,message:o,data:t,code:n})}static get group(){return J.STREAM.ERRORS}static get types(){return tt(J.STREAM.ERRORS)}},Q=class extends Ie{constructor(e,t,o,n){super({type:e,message:o,data:t,code:n})}static get group(){return J.INPUT.ERRORS}static get types(){return tt(J.INPUT.ERRORS)}},ge=class extends Ie{constructor(e,t,o,n){super({type:e,message:o,data:t,code:n})}static get group(){return J.CONFIG.ERRORS}static get types(){return tt(J.CONFIG.ERRORS)}},ze=class extends Ie{constructor(e,t,o,n){super({type:e,message:o,data:t,code:n})}static get group(){return J.AUTH.ERRORS}static get types(){return tt(J.AUTH.ERRORS)}},_n=class extends Ie{constructor(e,t,o,n){super({type:e,message:o,data:t,code:n})}static get group(){return J.CONSTRAINT.ERRORS}static get types(){return tt(J.CONSTRAINT.ERRORS)}},ve=class extends vt{constructor(e,t){super(vt.types.INVALID_PARAMS,e,t)}},wt=class extends ze{constructor(e){super(ze.types.AUTHENTICATION_ERROR,e)}},yo=class extends ze{constructor(e){super(ze.types.AUTHORIZATION_ERROR,e)}},In=class extends Ie{constructor(e){super({type:Lr.INTERNAL_SERVER_ERROR,data:e})}toJSON(){return{code:this.code,message:this.message,data:{description:le.INTERNAL_SERVER_ERROR.description}}}},_o=class extends In{constructor(e){super({data:{message:e}})}toJSON(){let e=super.toJSON();return e.data={description:e.data.description,message:this.data.message},{code:this.code,message:this.message,data:{message:this.data.message,description:le.INTERNAL_SERVER_ERROR.description}}}},lp=Object.fromEntries(Object.keys(le).map(r=>[le[r].code,r]));function Wd(r){let e=lp[r];if(!e){let o=Object.entries(J).find(([,n])=>r>=n.min&&r<=n.max);return{group:o==null?void 0:o[0],type:void 0}}let t=Object.keys(J).find(o=>e in J[o].ERRORS);return t?{group:t,type:e}:(console.error("ERRORS and ERROR_GROUPS are out of sync",e),{group:void 0,type:e})}function kn({code:r,message:e,data:t}){let o=Wd(r),n=o.type,s=o.group;e=e&&e!==n||!n?e:le[n].description;let p;switch(s&&s!=="JSONRPC"&&n===void 0&&(W("Novel error from server",r,e,t),n=e,p=r,e=t&&typeof t=="object"&&"description"in t&&typeof t.description=="string"?t.description:e),s){case"JSONRPC":return new vt(n,t,e);case"AUTH":return new ze(n,t,e,p);case"CONFIG":return new ge(n,t,e,p);case"CONSTRAINT":return new _n(n,t,e,p);case"INPUT":return new Q(n,t,e,p);case"STREAM":return new ke(n,t,e,p);default:return new Ie({code:r,message:e,data:t,type:n!=null?n:Lr.INTERNAL_SERVER_ERROR})}}var cp=Object.fromEntries(Object.keys(le).map(r=>[r,le[r].message])),fp=Object.fromEntries(Object.keys(le).map(r=>[r,le[r].description]));var oe=[];for(let r=0;r<256;++r)oe.push((r+256).toString(16).slice(1));function mp(r,e=0){return(oe[r[e+0]]+oe[r[e+1]]+oe[r[e+2]]+oe[r[e+3]]+"-"+oe[r[e+4]]+oe[r[e+5]]+"-"+oe[r[e+6]]+oe[r[e+7]]+"-"+oe[r[e+8]]+oe[r[e+9]]+"-"+oe[r[e+10]]+oe[r[e+11]]+oe[r[e+12]]+oe[r[e+13]]+oe[r[e+14]]+oe[r[e+15]]).toLowerCase()}var Io,Cd=new Uint8Array(16);function ko(){if(!Io){if(typeof crypto=="undefined"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Io=crypto.getRandomValues.bind(crypto)}return Io(Cd)}var Ad=typeof crypto!="undefined"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),vo={randomUUID:Ad};function Nd(r,e,t){var n,s,p;if(vo.randomUUID&&!e&&!r)return vo.randomUUID();r=r||{};let o=(p=(s=r.random)!=null?s:(n=r.rng)==null?void 0:n.call(r))!=null?p:ko();if(o.length<16)throw new Error("Random bytes length must be >= 16");if(o[6]=o[6]&15|64,o[8]=o[8]&63|128,e){if(t=t||0,t<0||t+16>e.length)throw new RangeError(`UUID byte range ${t}:${t+15} is out of buffer bounds`);for(let u=0;u<16;++u)e[t+u]=o[u];return e}return mp(o)}var Et=Nd;function rt(r=8){return Et().split("-").pop().substr(0,r)}var wo={timeouts:{},values:{},set(r,e){this.timeouts[r]=setTimeout(()=>this.clear(r),3e4),this.values[r]=e},get(r){return this.values[r]},getKey(r){let e=JSON.parse(JSON.stringify(r)),t="";return Object.keys(e).sort().forEach(o=>{let n="";e[o]&&typeof e[o]=="object"&&!Array.isArray(e[o])?n=this.getKey(e[o]):n=JSON.stringify(e[o]),t+=o+":"+n}),t},clear(r){this.timeouts[r]&&clearTimeout(this.timeouts[r]),delete this.timeouts[r],delete this.values[r]},clearAll(){Object.keys(this.timeouts).forEach(r=>{clearTimeout(this.timeouts[r])}),this.timeouts={},this.values={}}};function ie(r){if(!r)return Et();let e=wo.getKey(r);if(wo.get(e))throw new Q("INPUT_NEEDS_IDENTIFIER",{object:r});let t=Et();return wo.set(e,t),t}function hp(r){return new Promise(e=>setTimeout(e,r))}function Eo(){return ie()}function Dd(r){return JSON.parse(JSON.stringify(r))}function Me(r,e,t){if(e in r){if(r[e]===void 0)throw new ve({input:r},`undefined provided for ${e}`);return r}if(!t)throw new ve({input:r},`${e} is required if no default set`);let o=Dd(r);return o[e]=t,o}function F(r){let e=gp(r);if(e!=null)return{foreign:e}}function A(r){let e=gp(r);if(e!=null)return{identifier:e}}function gp(r){return r==null?r:r+""}function Bd(r){return Object.keys(r).filter(e=>r[e]!==void 0).map(e=>`${encodeURIComponent(e)}=${encodeURIComponent(r[e])}`).join("&")}function Tp(r){return r.host.replace(/^https:/,"wss:")+"?"+Bd({apikey:r.apikey,apisecret:r.apisecret,db:r.database,clientVersion:r.clientVersion,connectionName:r.connectionName})}function Fp(r){return typeof window=="undefined"?[Tp(r),{rejectUnauthorized:r.rejectUnauthorized}]:[Tp(r)]}function vn(r,e){let t={},o=!r||typeof r!="object"?{}:r;return Object.keys(o).forEach(n=>{e[n]?typeof e[n]=="string"?t[e[n]]=o[n]:t[n]=e[n](o[n]):t[n]=o[n]}),t}function te(r){return r.split(",").map(e=>e.split(" ")).map(e=>{let[t,o]=e;return{field:t,direction:o==="desc"?"desc":"asc"}})}function xp(r){if(!r)return;if(!r.order_by)return r;let e=r.order_by;return delete r.order_by,r.order||(r.order=te(e)),r}function Op(r){if(r!=null)return r+""}function bp(r){return new Date(r).setHours(0,0,0,0)>new Date().setHours(0,0,0,0)}var Zr=class{constructor(e){v(this,"_data",[]);v(this,"_error",[]);v(this,"_end",[]);v(this,"_finished",!1);v(this,"_options");this._options=e}on(e,t){switch(e){case"data":return this._data.push(t),this;case"end":return this._end.push(t),this;case"error":return this._error.push(t),this}}push(e){if(this._finished)throw new Error("Stream is closed");return e===null?this.end():(this._data.forEach(t=>t(e)),this)}error(e){if(this._finished)throw new Error("Stream is closed");return this._error.forEach(t=>t(e)),this}end(){if(this._finished)throw new Error("Stream is closed");return this._end.forEach(e=>e()),this._finished=!0,this}destroy(e){return this.error(e),this.end(),this}get destroyed(){return this._finished}},wn=class{constructor(){throw new TypeError("used in node version")}pipe(...e){throw new TypeError("used in node version")}pause(){throw new TypeError("used in node version")}resume(){throw new TypeError("used in node version")}on(...e){throw new TypeError("used in node version")}};var Be=class{constructor(e){v(this,"resolve");v(this,"reject");v(this,"makeRequest");v(this,"streamObject",new Zr({objectMode:!0}));v(this,"outStreamObject",new Zr({objectMode:!0}));v(this,"mode");v(this,"started",!1);v(this,"promise");this.makeRequest=e}start(e){var o;if(W("start request as",e),this.mode&&this.mode!==e)throw new Error("Already in use as "+this.mode);if(this.started)return;if(this.promise=new Promise((n,s)=>{this.resolve=n,this.reject=s}),this.started=!0,this.mode=e,this.makeRequest===void 0){this.streamObject.push(null),(o=this.resolve)==null||o.call(this,void 0);return}this.makeRequest(this.streamObject).catch(this.reject);let t=[];if(this.mode==="stream"){this.streamObject.on("data",n=>{if(W("stream data",n),n||this.outStreamObject.push(n),n.error){let s=kn(n.error);return this.outStreamObject.destroy(s),this.streamObject.destroy(s)}if(!n.prop){t.push(n);return}if(n.dataArr){let s=d({},n);delete s.dataArr,n.dataArr.forEach(p=>{this.outStreamObject.push(b(d({},s),{data:p}))});return}this.outStreamObject.push(n)}).on("end",()=>{W("stream ended");let n=t.pop();if(!n)return;let s=n.result;Object.keys(s).forEach(p=>{Array.isArray(s[p])&&(s[p].forEach(u=>{this.outStreamObject.push({type:"streamChunk",prop:p,data:u})}),s[p]=[])}),this.outStreamObject.push(n),this.outStreamObject.push(null)}).on("error",n=>{W("stream error",n),this.outStreamObject.destroy(n)});return}if(this.mode==="promise"){let n=new Map;this.streamObject.on("data",s=>{var u;if(W("streamPromise data",s),s===void 0)return;if(s.error){let l=kn(s.error);return this.streamObject.destroy(l)}if(!s.prop){t.push(s);return}let p=(u=n.get(s.prop))!=null?u:[];s.dataArr?p.push(...s.dataArr):p.push(s.data),n.set(s.prop,p)}).on("end",()=>{W("streamPromise end");let s=t.pop();if(!s)return;let p=s.result;if(!n.size)return this.resolve(p);let u=!1;n.forEach((l,c)=>{Array.isArray(p[c])?(l.push(...p[c]),p[c]=l):l.length===1?p[c]=l:(this.streamObject.destroy(new ke("INVALID_RESPONSE_STREAM_CHUNK",{property:c,value:l})),u=!0)}),u||this.resolve(p)}).on("error",s=>{var p;return W("streamPromise error",s),(p=this.reject)==null?void 0:p.call(this,s)})}}then(e,t){return this.start("promise"),this.promise.then(e,t)}catch(e){return this.start("promise"),this.promise.catch(e)}stream(){return this.start("stream"),this.outStreamObject}};var zr=class extends Be{constructor(t,o){super(t);v(this,"inputStream");this.inputStream=o}input(t){return t?typeof t=="function"?(t(this.inputStream),this):(console.warn("currently disabled"),this):this.inputStream}};var En={};var Sp=(r,e)=>{if(r)return new ve({message:r.message,data:r.format()})},Mo=(r,e,t=Sp)=>{let{success:o,error:n,data:s}=r.safeParse(e);return{data:s,success:o,isValid:o,error:t(n,e)}},yp=(r,e,t,o)=>!e||typeof e!="object"?{success:!1,isValid:!1,error:new ve({message:`Invalid input - expected object, got ${typeof e}`,data:{input:e}})}:Mo(r,d({options:t!=null?t:{}},e),o),Pd=(r,e,t,o)=>{var p;let{data:n,error:s}=Mo(r,e,o);if(s)throw((p=t==null?void 0:t.warn)!=null?p:W)(d({err:s},En),"Invalid input"),s;return n},Ud=(r,e,t,o,n)=>{!o&&t&&typeof(t==null?void 0:t.warn)=="function"&&(o=t,t={});let{data:s,error:p}=yp(r,e,t,n);if(p)throw o?o.warn(d({err:p},En),"Invalid input"):W(d({err:p},En),"Invalid input"),p;return s},i=(r,e)=>({validateInput:(t,o)=>Pd(r,t,o,e),validateInputWOptions:(t,o,n)=>Ud(r,t,o,n,e),softValidateInput:t=>Mo(r,t,e),softValidateWOptions:(t,o)=>yp(r,t,o,e)});var Z;(function(r){r.assertEqual=n=>n;function e(n){}r.assertIs=e;function t(n){throw new Error}r.assertNever=t,r.arrayToEnum=n=>{let s={};for(let p of n)s[p]=p;return s},r.getValidEnumValues=n=>{let s=r.objectKeys(n).filter(u=>typeof n[n[u]]!="number"),p={};for(let u of s)p[u]=n[u];return r.objectValues(p)},r.objectValues=n=>r.objectKeys(n).map(function(s){return n[s]}),r.objectKeys=typeof Object.keys=="function"?n=>Object.keys(n):n=>{let s=[];for(let p in n)Object.prototype.hasOwnProperty.call(n,p)&&s.push(p);return s},r.find=(n,s)=>{for(let p of n)if(s(p))return p},r.isInteger=typeof Number.isInteger=="function"?n=>Number.isInteger(n):n=>typeof n=="number"&&isFinite(n)&&Math.floor(n)===n;function o(n,s=" | "){return n.map(p=>typeof p=="string"?`'${p}'`:p).join(s)}r.joinValues=o,r.jsonStringifyReplacer=(n,s)=>typeof s=="bigint"?s.toString():s})(Z||(Z={}));var Go;(function(r){r.mergeShapes=(e,t)=>d(d({},e),t)})(Go||(Go={}));var S=Z.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Ue=r=>{switch(typeof r){case"undefined":return S.undefined;case"string":return S.string;case"number":return isNaN(r)?S.nan:S.number;case"boolean":return S.boolean;case"function":return S.function;case"bigint":return S.bigint;case"symbol":return S.symbol;case"object":return Array.isArray(r)?S.array:r===null?S.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?S.promise:typeof Map!="undefined"&&r instanceof Map?S.map:typeof Set!="undefined"&&r instanceof Set?S.set:typeof Date!="undefined"&&r instanceof Date?S.date:S.object;default:return S.unknown}},h=Z.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),jd=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:"),Fe=class r extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=o=>{this.issues=[...this.issues,o]},this.addIssues=(o=[])=>{this.issues=[...this.issues,...o]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){let t=e||function(s){return s.message},o={_errors:[]},n=s=>{for(let p of s.issues)if(p.code==="invalid_union")p.unionErrors.map(n);else if(p.code==="invalid_return_type")n(p.returnTypeError);else if(p.code==="invalid_arguments")n(p.argumentsError);else if(p.path.length===0)o._errors.push(t(p));else{let u=o,l=0;for(;l<p.path.length;){let c=p.path[l];l===p.path.length-1?(u[c]=u[c]||{_errors:[]},u[c]._errors.push(t(p))):u[c]=u[c]||{_errors:[]},u=u[c],l++}}};return n(this),o}static assert(e){if(!(e instanceof r))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Z.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){let t={},o=[];for(let n of this.issues)n.path.length>0?(t[n.path[0]]=t[n.path[0]]||[],t[n.path[0]].push(e(n))):o.push(e(n));return{formErrors:o,fieldErrors:t}}get formErrors(){return this.flatten()}};Fe.create=r=>new Fe(r);var Gt=(r,e)=>{let t;switch(r.code){case h.invalid_type:r.received===S.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case h.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,Z.jsonStringifyReplacer)}`;break;case h.unrecognized_keys:t=`Unrecognized key(s) in object: ${Z.joinValues(r.keys,", ")}`;break;case h.invalid_union:t="Invalid input";break;case h.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${Z.joinValues(r.options)}`;break;case h.invalid_enum_value:t=`Invalid enum value. Expected ${Z.joinValues(r.options)}, received '${r.received}'`;break;case h.invalid_arguments:t="Invalid function arguments";break;case h.invalid_return_type:t="Invalid function return type";break;case h.invalid_date:t="Invalid date";break;case h.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:Z.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case h.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case h.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case h.custom:t="Invalid input";break;case h.invalid_intersection_types:t="Intersection results could not be merged";break;case h.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case h.not_finite:t="Number must be finite";break;default:t=e.defaultError,Z.assertNever(r)}return{message:t}},vp=Gt;function Vd(r){vp=r}function Mn(){return vp}var Rn=r=>{let{data:e,path:t,errorMaps:o,issueData:n}=r,s=[...t,...n.path||[]],p=b(d({},n),{path:s});if(n.message!==void 0)return b(d({},n),{path:s,message:n.message});let u="",l=o.filter(c=>!!c).slice().reverse();for(let c of l)u=c(p,{data:e,defaultError:u}).message;return b(d({},n),{path:s,message:u})},Ld=[];function O(r,e){let t=Mn(),o=Rn({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===Gt?void 0:Gt].filter(n=>!!n)});r.common.issues.push(o)}var se=class r{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){let o=[];for(let n of t){if(n.status==="aborted")return R;n.status==="dirty"&&e.dirty(),o.push(n.value)}return{status:e.value,value:o}}static mergeObjectAsync(e,t){return $(this,null,function*(){let o=[];for(let n of t){let s=yield n.key,p=yield n.value;o.push({key:s,value:p})}return r.mergeObjectSync(e,o)})}static mergeObjectSync(e,t){let o={};for(let n of t){let{key:s,value:p}=n;if(s.status==="aborted"||p.status==="aborted")return R;s.status==="dirty"&&e.dirty(),p.status==="dirty"&&e.dirty(),s.value!=="__proto__"&&(typeof p.value!="undefined"||n.alwaysSet)&&(o[s.value]=p.value)}return{status:e.value,value:o}}},R=Object.freeze({status:"aborted"}),Rt=r=>({status:"dirty",value:r}),pe=r=>({status:"valid",value:r}),Wo=r=>r.status==="aborted",Co=r=>r.status==="dirty",nt=r=>r.status==="valid",Qr=r=>typeof Promise!="undefined"&&r instanceof Promise;function Gn(r,e,t,o){if(t==="a"&&!o)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!o:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?o:t==="a"?o.call(r):o?o.value:e.get(r)}function wp(r,e,t,o,n){if(o==="m")throw new TypeError("Private method is not writable");if(o==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return o==="a"?n.call(r,t):n?n.value=t:e.set(r,t),t}var y;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(y||(y={}));var Hr,qr,be=class{constructor(e,t,o,n){this._cachedPath=[],this.parent=e,this.data=t,this._path=o,this._key=n}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},_p=(r,e)=>{if(nt(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let t=new Fe(r.common.issues);return this._error=t,this._error}}};function N(r){if(!r)return{};let{errorMap:e,invalid_type_error:t,required_error:o,description:n}=r;if(e&&(t||o))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:n}:{errorMap:(p,u)=>{var l,c;let{message:f}=r;return p.code==="invalid_enum_value"?{message:f!=null?f:u.defaultError}:typeof u.data=="undefined"?{message:(l=f!=null?f:o)!==null&&l!==void 0?l:u.defaultError}:p.code!=="invalid_type"?{message:u.defaultError}:{message:(c=f!=null?f:t)!==null&&c!==void 0?c:u.defaultError}},description:n}}var D=class{get description(){return this._def.description}_getType(e){return Ue(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Ue(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new se,ctx:{common:e.parent.common,data:e.data,parsedType:Ue(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(Qr(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let o=this.safeParse(e,t);if(o.success)return o.data;throw o.error}safeParse(e,t){var o;let n={common:{issues:[],async:(o=t==null?void 0:t.async)!==null&&o!==void 0?o:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Ue(e)},s=this._parseSync({data:e,path:n.path,parent:n});return _p(n,s)}"~validate"(e){var t,o;let n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Ue(e)};if(!this["~standard"].async)try{let s=this._parseSync({data:e,path:[],parent:n});return nt(s)?{value:s.value}:{issues:n.common.issues}}catch(s){!((o=(t=s==null?void 0:s.message)===null||t===void 0?void 0:t.toLowerCase())===null||o===void 0)&&o.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:n}).then(s=>nt(s)?{value:s.value}:{issues:n.common.issues})}parseAsync(e,t){return $(this,null,function*(){let o=yield this.safeParseAsync(e,t);if(o.success)return o.data;throw o.error})}safeParseAsync(e,t){return $(this,null,function*(){let o={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Ue(e)},n=this._parse({data:e,path:o.path,parent:o}),s=yield Qr(n)?n:Promise.resolve(n);return _p(o,s)})}refine(e,t){let o=n=>typeof t=="string"||typeof t=="undefined"?{message:t}:typeof t=="function"?t(n):t;return this._refinement((n,s)=>{let p=e(n),u=()=>s.addIssue(d({code:h.custom},o(n)));return typeof Promise!="undefined"&&p instanceof Promise?p.then(l=>l?!0:(u(),!1)):p?!0:(u(),!1)})}refinement(e,t){return this._refinement((o,n)=>e(o)?!0:(n.addIssue(typeof t=="function"?t(o,n):t),!1))}_refinement(e){return new xe({schema:this,typeName:M.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:t=>this["~validate"](t)}}optional(){return Oe.create(this,this._def)}nullable(){return Ge.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Ve.create(this)}promise(){return Qe.create(this,this._def)}or(e){return dt.create([this,e],this._def)}and(e){return lt.create(this,e,this._def)}transform(e){return new xe(b(d({},N(this._def)),{schema:this,typeName:M.ZodEffects,effect:{type:"transform",transform:e}}))}default(e){let t=typeof e=="function"?e:()=>e;return new ht(b(d({},N(this._def)),{innerType:this,defaultValue:t,typeName:M.ZodDefault}))}brand(){return new $r(d({typeName:M.ZodBranded,type:this},N(this._def)))}catch(e){let t=typeof e=="function"?e:()=>e;return new gt(b(d({},N(this._def)),{innerType:this,catchValue:t,typeName:M.ZodCatch}))}describe(e){let t=this.constructor;return new t(b(d({},this._def),{description:e}))}pipe(e){return Jr.create(this,e)}readonly(){return Ft.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Zd=/^c[^\s-]{8,}$/i,zd=/^[0-9a-z]+$/,Hd=/^[0-9A-HJKMNP-TV-Z]{26}$/i,qd=/^[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}$/i,Qd=/^[a-z0-9_-]{21}$/i,$d=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Jd=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Kd=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Yd="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Ro,Xd=/^(?:(?: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])$/,el=/^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/,tl=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,rl=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,nl=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,al=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Ep="((\\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])))",ol=new RegExp(`^${Ep}$`);function Mp(r){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return r.precision?e=`${e}\\.\\d{${r.precision}}`:r.precision==null&&(e=`${e}(\\.\\d+)?`),e}function sl(r){return new RegExp(`^${Mp(r)}$`)}function Rp(r){let e=`${Ep}T${Mp(r)}`,t=[];return t.push(r.local?"Z?":"Z"),r.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function il(r,e){return!!((e==="v4"||!e)&&Xd.test(r)||(e==="v6"||!e)&&tl.test(r))}function pl(r,e){if(!$d.test(r))return!1;try{let[t]=r.split("."),o=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),n=JSON.parse(atob(o));return!(typeof n!="object"||n===null||!n.typ||!n.alg||e&&n.alg!==e)}catch(t){return!1}}function ul(r,e){return!!((e==="v4"||!e)&&el.test(r)||(e==="v6"||!e)&&rl.test(r))}var He=class r extends D{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==S.string){let s=this._getOrReturnCtx(e);return O(s,{code:h.invalid_type,expected:S.string,received:s.parsedType}),R}let o=new se,n;for(let s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(n=this._getOrReturnCtx(e,n),O(n,{code:h.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),o.dirty());else if(s.kind==="max")e.data.length>s.value&&(n=this._getOrReturnCtx(e,n),O(n,{code:h.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),o.dirty());else if(s.kind==="length"){let p=e.data.length>s.value,u=e.data.length<s.value;(p||u)&&(n=this._getOrReturnCtx(e,n),p?O(n,{code:h.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):u&&O(n,{code:h.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),o.dirty())}else if(s.kind==="email")Kd.test(e.data)||(n=this._getOrReturnCtx(e,n),O(n,{validation:"email",code:h.invalid_string,message:s.message}),o.dirty());else if(s.kind==="emoji")Ro||(Ro=new RegExp(Yd,"u")),Ro.test(e.data)||(n=this._getOrReturnCtx(e,n),O(n,{validation:"emoji",code:h.invalid_string,message:s.message}),o.dirty());else if(s.kind==="uuid")qd.test(e.data)||(n=this._getOrReturnCtx(e,n),O(n,{validation:"uuid",code:h.invalid_string,message:s.message}),o.dirty());else if(s.kind==="nanoid")Qd.test(e.data)||(n=this._getOrReturnCtx(e,n),O(n,{validation:"nanoid",code:h.invalid_string,message:s.message}),o.dirty());else if(s.kind==="cuid")Zd.test(e.data)||(n=this._getOrReturnCtx(e,n),O(n,{validation:"cuid",code:h.invalid_string,message:s.message}),o.dirty());else if(s.kind==="cuid2")zd.test(e.data)||(n=this._getOrReturnCtx(e,n),O(n,{validation:"cuid2",code:h.invalid_string,message:s.message}),o.dirty());else if(s.kind==="ulid")Hd.test(e.data)||(n=this._getOrReturnCtx(e,n),O(n,{validation:"ulid",code:h.invalid_string,message:s.message}),o.dirty());else if(s.kind==="url")try{new URL(e.data)}catch(p){n=this._getOrReturnCtx(e,n),O(n,{validation:"url",code:h.invalid_string,message:s.message}),o.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),O(n,{validation:"regex",code:h.invalid_string,message:s.message}),o.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(n=this._getOrReturnCtx(e,n),O(n,{code:h.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),o.dirty()):s.kind==="toLowerCase"?e.data=e.data.toLowerCase():s.kind==="toUpperCase"?e.data=e.data.toUpperCase():s.kind==="startsWith"?e.data.startsWith(s.value)||(n=this._getOrReturnCtx(e,n),O(n,{code:h.invalid_string,validation:{startsWith:s.value},message:s.message}),o.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(n=this._getOrReturnCtx(e,n),O(n,{code:h.invalid_string,validation:{endsWith:s.value},message:s.message}),o.dirty()):s.kind==="datetime"?Rp(s).test(e.data)||(n=this._getOrReturnCtx(e,n),O(n,{code:h.invalid_string,validation:"datetime",message:s.message}),o.dirty()):s.kind==="date"?ol.test(e.data)||(n=this._getOrReturnCtx(e,n),O(n,{code:h.invalid_string,validation:"date",message:s.message}),o.dirty()):s.kind==="time"?sl(s).test(e.data)||(n=this._getOrReturnCtx(e,n),O(n,{code:h.invalid_string,validation:"time",message:s.message}),o.dirty()):s.kind==="duration"?Jd.test(e.data)||(n=this._getOrReturnCtx(e,n),O(n,{validation:"duration",code:h.invalid_string,message:s.message}),o.dirty()):s.kind==="ip"?il(e.data,s.version)||(n=this._getOrReturnCtx(e,n),O(n,{validation:"ip",code:h.invalid_string,message:s.message}),o.dirty()):s.kind==="jwt"?pl(e.data,s.alg)||(n=this._getOrReturnCtx(e,n),O(n,{validation:"jwt",code:h.invalid_string,message:s.message}),o.dirty()):s.kind==="cidr"?ul(e.data,s.version)||(n=this._getOrReturnCtx(e,n),O(n,{validation:"cidr",code:h.invalid_string,message:s.message}),o.dirty()):s.kind==="base64"?nl.test(e.data)||(n=this._getOrReturnCtx(e,n),O(n,{validation:"base64",code:h.invalid_string,message:s.message}),o.dirty()):s.kind==="base64url"?al.test(e.data)||(n=this._getOrReturnCtx(e,n),O(n,{validation:"base64url",code:h.invalid_string,message:s.message}),o.dirty()):Z.assertNever(s);return{status:o.value,value:e.data}}_regex(e,t,o){return this.refinement(n=>e.test(n),d({validation:t,code:h.invalid_string},y.errToObj(o)))}_addCheck(e){return new r(b(d({},this._def),{checks:[...this._def.checks,e]}))}email(e){return this._addCheck(d({kind:"email"},y.errToObj(e)))}url(e){return this._addCheck(d({kind:"url"},y.errToObj(e)))}emoji(e){return this._addCheck(d({kind:"emoji"},y.errToObj(e)))}uuid(e){return this._addCheck(d({kind:"uuid"},y.errToObj(e)))}nanoid(e){return this._addCheck(d({kind:"nanoid"},y.errToObj(e)))}cuid(e){return this._addCheck(d({kind:"cuid"},y.errToObj(e)))}cuid2(e){return this._addCheck(d({kind:"cuid2"},y.errToObj(e)))}ulid(e){return this._addCheck(d({kind:"ulid"},y.errToObj(e)))}base64(e){return this._addCheck(d({kind:"base64"},y.errToObj(e)))}base64url(e){return this._addCheck(d({kind:"base64url"},y.errToObj(e)))}jwt(e){return this._addCheck(d({kind:"jwt"},y.errToObj(e)))}ip(e){return this._addCheck(d({kind:"ip"},y.errToObj(e)))}cidr(e){return this._addCheck(d({kind:"cidr"},y.errToObj(e)))}datetime(e){var t,o;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck(d({kind:"datetime",precision:typeof(e==null?void 0:e.precision)=="undefined"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,local:(o=e==null?void 0:e.local)!==null&&o!==void 0?o:!1},y.errToObj(e==null?void 0:e.message)))}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck(d({kind:"time",precision:typeof(e==null?void 0:e.precision)=="undefined"?null:e==null?void 0:e.precision},y.errToObj(e==null?void 0:e.message)))}duration(e){return this._addCheck(d({kind:"duration"},y.errToObj(e)))}regex(e,t){return this._addCheck(d({kind:"regex",regex:e},y.errToObj(t)))}includes(e,t){return this._addCheck(d({kind:"includes",value:e,position:t==null?void 0:t.position},y.errToObj(t==null?void 0:t.message)))}startsWith(e,t){return this._addCheck(d({kind:"startsWith",value:e},y.errToObj(t)))}endsWith(e,t){return this._addCheck(d({kind:"endsWith",value:e},y.errToObj(t)))}min(e,t){return this._addCheck(d({kind:"min",value:e},y.errToObj(t)))}max(e,t){return this._addCheck(d({kind:"max",value:e},y.errToObj(t)))}length(e,t){return this._addCheck(d({kind:"length",value:e},y.errToObj(t)))}nonempty(e){return this.min(1,y.errToObj(e))}trim(){return new r(b(d({},this._def),{checks:[...this._def.checks,{kind:"trim"}]}))}toLowerCase(){return new r(b(d({},this._def),{checks:[...this._def.checks,{kind:"toLowerCase"}]}))}toUpperCase(){return new r(b(d({},this._def),{checks:[...this._def.checks,{kind:"toUpperCase"}]}))}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};He.create=r=>{var e;return new He(d({checks:[],typeName:M.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1},N(r)))};function dl(r,e){let t=(r.toString().split(".")[1]||"").length,o=(e.toString().split(".")[1]||"").length,n=t>o?t:o,s=parseInt(r.toFixed(n).replace(".","")),p=parseInt(e.toFixed(n).replace(".",""));return s%p/Math.pow(10,n)}var at=class r extends D{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==S.number){let s=this._getOrReturnCtx(e);return O(s,{code:h.invalid_type,expected:S.number,received:s.parsedType}),R}let o,n=new se;for(let s of this._def.checks)s.kind==="int"?Z.isInteger(e.data)||(o=this._getOrReturnCtx(e,o),O(o,{code:h.invalid_type,expected:"integer",received:"float",message:s.message}),n.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(o=this._getOrReturnCtx(e,o),O(o,{code:h.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),n.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(o=this._getOrReturnCtx(e,o),O(o,{code:h.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),n.dirty()):s.kind==="multipleOf"?dl(e.data,s.value)!==0&&(o=this._getOrReturnCtx(e,o),O(o,{code:h.not_multiple_of,multipleOf:s.value,message:s.message}),n.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(o=this._getOrReturnCtx(e,o),O(o,{code:h.not_finite,message:s.message}),n.dirty()):Z.assertNever(s);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,y.toString(t))}gt(e,t){return this.setLimit("min",e,!1,y.toString(t))}lte(e,t){return this.setLimit("max",e,!0,y.toString(t))}lt(e,t){return this.setLimit("max",e,!1,y.toString(t))}setLimit(e,t,o,n){return new r(b(d({},this._def),{checks:[...this._def.checks,{kind:e,value:t,inclusive:o,message:y.toString(n)}]}))}_addCheck(e){return new r(b(d({},this._def),{checks:[...this._def.checks,e]}))}int(e){return this._addCheck({kind:"int",message:y.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:y.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:y.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:y.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:y.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:y.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:y.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:y.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:y.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&Z.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let o of this._def.checks){if(o.kind==="finite"||o.kind==="int"||o.kind==="multipleOf")return!0;o.kind==="min"?(t===null||o.value>t)&&(t=o.value):o.kind==="max"&&(e===null||o.value<e)&&(e=o.value)}return Number.isFinite(t)&&Number.isFinite(e)}};at.create=r=>new at(d({checks:[],typeName:M.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1},N(r)));var ot=class r extends D{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch(s){return this._getInvalidInput(e)}if(this._getType(e)!==S.bigint)return this._getInvalidInput(e);let o,n=new se;for(let s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(o=this._getOrReturnCtx(e,o),O(o,{code:h.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),n.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(o=this._getOrReturnCtx(e,o),O(o,{code:h.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),n.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(o=this._getOrReturnCtx(e,o),O(o,{code:h.not_multiple_of,multipleOf:s.value,message:s.message}),n.dirty()):Z.assertNever(s);return{status:n.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return O(t,{code:h.invalid_type,expected:S.bigint,received:t.parsedType}),R}gte(e,t){return this.setLimit("min",e,!0,y.toString(t))}gt(e,t){return this.setLimit("min",e,!1,y.toString(t))}lte(e,t){return this.setLimit("max",e,!0,y.toString(t))}lt(e,t){return this.setLimit("max",e,!1,y.toString(t))}setLimit(e,t,o,n){return new r(b(d({},this._def),{checks:[...this._def.checks,{kind:e,value:t,inclusive:o,message:y.toString(n)}]}))}_addCheck(e){return new r(b(d({},this._def),{checks:[...this._def.checks,e]}))}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:y.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:y.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:y.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:y.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:y.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};ot.create=r=>{var e;return new ot(d({checks:[],typeName:M.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1},N(r)))};var st=class extends D{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==S.boolean){let o=this._getOrReturnCtx(e);return O(o,{code:h.invalid_type,expected:S.boolean,received:o.parsedType}),R}return pe(e.data)}};st.create=r=>new st(d({typeName:M.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1},N(r)));var it=class r extends D{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==S.date){let s=this._getOrReturnCtx(e);return O(s,{code:h.invalid_type,expected:S.date,received:s.parsedType}),R}if(isNaN(e.data.getTime())){let s=this._getOrReturnCtx(e);return O(s,{code:h.invalid_date}),R}let o=new se,n;for(let s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(n=this._getOrReturnCtx(e,n),O(n,{code:h.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),o.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(n=this._getOrReturnCtx(e,n),O(n,{code:h.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),o.dirty()):Z.assertNever(s);return{status:o.value,value:new Date(e.data.getTime())}}_addCheck(e){return new r(b(d({},this._def),{checks:[...this._def.checks,e]}))}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:y.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:y.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}};it.create=r=>new it(d({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:M.ZodDate},N(r)));var Wt=class extends D{_parse(e){if(this._getType(e)!==S.symbol){let o=this._getOrReturnCtx(e);return O(o,{code:h.invalid_type,expected:S.symbol,received:o.parsedType}),R}return pe(e.data)}};Wt.create=r=>new Wt(d({typeName:M.ZodSymbol},N(r)));var pt=class extends D{_parse(e){if(this._getType(e)!==S.undefined){let o=this._getOrReturnCtx(e);return O(o,{code:h.invalid_type,expected:S.undefined,received:o.parsedType}),R}return pe(e.data)}};pt.create=r=>new pt(d({typeName:M.ZodUndefined},N(r)));var ut=class extends D{_parse(e){if(this._getType(e)!==S.null){let o=this._getOrReturnCtx(e);return O(o,{code:h.invalid_type,expected:S.null,received:o.parsedType}),R}return pe(e.data)}};ut.create=r=>new ut(d({typeName:M.ZodNull},N(r)));var qe=class extends D{constructor(){super(...arguments),this._any=!0}_parse(e){return pe(e.data)}};qe.create=r=>new qe(d({typeName:M.ZodAny},N(r)));var je=class extends D{constructor(){super(...arguments),this._unknown=!0}_parse(e){return pe(e.data)}};je.create=r=>new je(d({typeName:M.ZodUnknown},N(r)));var we=class extends D{_parse(e){let t=this._getOrReturnCtx(e);return O(t,{code:h.invalid_type,expected:S.never,received:t.parsedType}),R}};we.create=r=>new we(d({typeName:M.ZodNever},N(r)));var Ct=class extends D{_parse(e){if(this._getType(e)!==S.undefined){let o=this._getOrReturnCtx(e);return O(o,{code:h.invalid_type,expected:S.void,received:o.parsedType}),R}return pe(e.data)}};Ct.create=r=>new Ct(d({typeName:M.ZodVoid},N(r)));var Ve=class r extends D{_parse(e){let{ctx:t,status:o}=this._processInputParams(e),n=this._def;if(t.parsedType!==S.array)return O(t,{code:h.invalid_type,expected:S.array,received:t.parsedType}),R;if(n.exactLength!==null){let p=t.data.length>n.exactLength.value,u=t.data.length<n.exactLength.value;(p||u)&&(O(t,{code:p?h.too_big:h.too_small,minimum:u?n.exactLength.value:void 0,maximum:p?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),o.dirty())}if(n.minLength!==null&&t.data.length<n.minLength.value&&(O(t,{code:h.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),o.dirty()),n.maxLength!==null&&t.data.length>n.maxLength.value&&(O(t,{code:h.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),o.dirty()),t.common.async)return Promise.all([...t.data].map((p,u)=>n.type._parseAsync(new be(t,p,t.path,u)))).then(p=>se.mergeArray(o,p));let s=[...t.data].map((p,u)=>n.type._parseSync(new be(t,p,t.path,u)));return se.mergeArray(o,s)}get element(){return this._def.type}min(e,t){return new r(b(d({},this._def),{minLength:{value:e,message:y.toString(t)}}))}max(e,t){return new r(b(d({},this._def),{maxLength:{value:e,message:y.toString(t)}}))}length(e,t){return new r(b(d({},this._def),{exactLength:{value:e,message:y.toString(t)}}))}nonempty(e){return this.min(1,e)}};Ve.create=(r,e)=>new Ve(d({type:r,minLength:null,maxLength:null,exactLength:null,typeName:M.ZodArray},N(e)));function Mt(r){if(r instanceof ce){let e={};for(let t in r.shape){let o=r.shape[t];e[t]=Oe.create(Mt(o))}return new ce(b(d({},r._def),{shape:()=>e}))}else return r instanceof Ve?new Ve(b(d({},r._def),{type:Mt(r.element)})):r instanceof Oe?Oe.create(Mt(r.unwrap())):r instanceof Ge?Ge.create(Mt(r.unwrap())):r instanceof Re?Re.create(r.items.map(e=>Mt(e))):r}var ce=class r extends D{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),t=Z.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==S.object){let c=this._getOrReturnCtx(e);return O(c,{code:h.invalid_type,expected:S.object,received:c.parsedType}),R}let{status:o,ctx:n}=this._processInputParams(e),{shape:s,keys:p}=this._getCached(),u=[];if(!(this._def.catchall instanceof we&&this._def.unknownKeys==="strip"))for(let c in n.data)p.includes(c)||u.push(c);let l=[];for(let c of p){let f=s[c],g=n.data[c];l.push({key:{status:"valid",value:c},value:f._parse(new be(n,g,n.path,c)),alwaysSet:c in n.data})}if(this._def.catchall instanceof we){let c=this._def.unknownKeys;if(c==="passthrough")for(let f of u)l.push({key:{status:"valid",value:f},value:{status:"valid",value:n.data[f]}});else if(c==="strict")u.length>0&&(O(n,{code:h.unrecognized_keys,keys:u}),o.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let c=this._def.catchall;for(let f of u){let g=n.data[f];l.push({key:{status:"valid",value:f},value:c._parse(new be(n,g,n.path,f)),alwaysSet:f in n.data})}}return n.common.async?Promise.resolve().then(()=>$(this,null,function*(){let c=[];for(let f of l){let g=yield f.key,k=yield f.value;c.push({key:g,value:k,alwaysSet:f.alwaysSet})}return c})).then(c=>se.mergeObjectSync(o,c)):se.mergeObjectSync(o,l)}get shape(){return this._def.shape()}strict(e){return y.errToObj,new r(d(b(d({},this._def),{unknownKeys:"strict"}),e!==void 0?{errorMap:(t,o)=>{var n,s,p,u;let l=(p=(s=(n=this._def).errorMap)===null||s===void 0?void 0:s.call(n,t,o).message)!==null&&p!==void 0?p:o.defaultError;return t.code==="unrecognized_keys"?{message:(u=y.errToObj(e).message)!==null&&u!==void 0?u:l}:{message:l}}}:{}))}strip(){return new r(b(d({},this._def),{unknownKeys:"strip"}))}passthrough(){return new r(b(d({},this._def),{unknownKeys:"passthrough"}))}extend(e){return new r(b(d({},this._def),{shape:()=>d(d({},this._def.shape()),e)}))}merge(e){return new r({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>d(d({},this._def.shape()),e._def.shape()),typeName:M.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new r(b(d({},this._def),{catchall:e}))}pick(e){let t={};return Z.objectKeys(e).forEach(o=>{e[o]&&this.shape[o]&&(t[o]=this.shape[o])}),new r(b(d({},this._def),{shape:()=>t}))}omit(e){let t={};return Z.objectKeys(this.shape).forEach(o=>{e[o]||(t[o]=this.shape[o])}),new r(b(d({},this._def),{shape:()=>t}))}deepPartial(){return Mt(this)}partial(e){let t={};return Z.objectKeys(this.shape).forEach(o=>{let n=this.shape[o];e&&!e[o]?t[o]=n:t[o]=n.optional()}),new r(b(d({},this._def),{shape:()=>t}))}required(e){let t={};return Z.objectKeys(this.shape).forEach(o=>{if(e&&!e[o])t[o]=this.shape[o];else{let s=this.shape[o];for(;s instanceof Oe;)s=s._def.innerType;t[o]=s}}),new r(b(d({},this._def),{shape:()=>t}))}keyof(){return Gp(Z.objectKeys(this.shape))}};ce.create=(r,e)=>new ce(d({shape:()=>r,unknownKeys:"strip",catchall:we.create(),typeName:M.ZodObject},N(e)));ce.strictCreate=(r,e)=>new ce(d({shape:()=>r,unknownKeys:"strict",catchall:we.create(),typeName:M.ZodObject},N(e)));ce.lazycreate=(r,e)=>new ce(d({shape:r,unknownKeys:"strip",catchall:we.create(),typeName:M.ZodObject},N(e)));var dt=class extends D{_parse(e){let{ctx:t}=this._processInputParams(e),o=this._def.options;function n(s){for(let u of s)if(u.result.status==="valid")return u.result;for(let u of s)if(u.result.status==="dirty")return t.common.issues.push(...u.ctx.common.issues),u.result;let p=s.map(u=>new Fe(u.ctx.common.issues));return O(t,{code:h.invalid_union,unionErrors:p}),R}if(t.common.async)return Promise.all(o.map(s=>$(this,null,function*(){let p=b(d({},t),{common:b(d({},t.common),{issues:[]}),parent:null});return{result:yield s._parseAsync({data:t.data,path:t.path,parent:p}),ctx:p}}))).then(n);{let s,p=[];for(let l of o){let c=b(d({},t),{common:b(d({},t.common),{issues:[]}),parent:null}),f=l._parseSync({data:t.data,path:t.path,parent:c});if(f.status==="valid")return f;f.status==="dirty"&&!s&&(s={result:f,ctx:c}),c.common.issues.length&&p.push(c.common.issues)}if(s)return t.common.issues.push(...s.ctx.common.issues),s.result;let u=p.map(l=>new Fe(l));return O(t,{code:h.invalid_union,unionErrors:u}),R}}get options(){return this._def.options}};dt.create=(r,e)=>new dt(d({options:r,typeName:M.ZodUnion},N(e)));var Pe=r=>r instanceof ct?Pe(r.schema):r instanceof xe?Pe(r.innerType()):r instanceof ft?[r.value]:r instanceof mt?r.options:r instanceof Tt?Z.objectValues(r.enum):r instanceof ht?Pe(r._def.innerType):r instanceof pt?[void 0]:r instanceof ut?[null]:r instanceof Oe?[void 0,...Pe(r.unwrap())]:r instanceof Ge?[null,...Pe(r.unwrap())]:r instanceof $r||r instanceof Ft?Pe(r.unwrap()):r instanceof gt?Pe(r._def.innerType):[],Wn=class r extends D{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==S.object)return O(t,{code:h.invalid_type,expected:S.object,received:t.parsedType}),R;let o=this.discriminator,n=t.data[o],s=this.optionsMap.get(n);return s?t.common.async?s._parseAsync({data:t.data,path:t.path,parent:t}):s._parseSync({data:t.data,path:t.path,parent:t}):(O(t,{code:h.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[o]}),R)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,o){let n=new Map;for(let s of t){let p=Pe(s.shape[e]);if(!p.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let u of p){if(n.has(u))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(u)}`);n.set(u,s)}}return new r(d({typeName:M.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:n},N(o)))}};function Ao(r,e){let t=Ue(r),o=Ue(e);if(r===e)return{valid:!0,data:r};if(t===S.object&&o===S.object){let n=Z.objectKeys(e),s=Z.objectKeys(r).filter(u=>n.indexOf(u)!==-1),p=d(d({},r),e);for(let u of s){let l=Ao(r[u],e[u]);if(!l.valid)return{valid:!1};p[u]=l.data}return{valid:!0,data:p}}else if(t===S.array&&o===S.array){if(r.length!==e.length)return{valid:!1};let n=[];for(let s=0;s<r.length;s++){let p=r[s],u=e[s],l=Ao(p,u);if(!l.valid)return{valid:!1};n.push(l.data)}return{valid:!0,data:n}}else return t===S.date&&o===S.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}var lt=class extends D{_parse(e){let{status:t,ctx:o}=this._processInputParams(e),n=(s,p)=>{if(Wo(s)||Wo(p))return R;let u=Ao(s.value,p.value);return u.valid?((Co(s)||Co(p))&&t.dirty(),{status:t.value,value:u.data}):(O(o,{code:h.invalid_intersection_types}),R)};return o.common.async?Promise.all([this._def.left._parseAsync({data:o.data,path:o.path,parent:o}),this._def.right._parseAsync({data:o.data,path:o.path,parent:o})]).then(([s,p])=>n(s,p)):n(this._def.left._parseSync({data:o.data,path:o.path,parent:o}),this._def.right._parseSync({data:o.data,path:o.path,parent:o}))}};lt.create=(r,e,t)=>new lt(d({left:r,right:e,typeName:M.ZodIntersection},N(t)));var Re=class r extends D{_parse(e){let{status:t,ctx:o}=this._processInputParams(e);if(o.parsedType!==S.array)return O(o,{code:h.invalid_type,expected:S.array,received:o.parsedType}),R;if(o.data.length<this._def.items.length)return O(o,{code:h.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),R;!this._def.rest&&o.data.length>this._def.items.length&&(O(o,{code:h.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());let s=[...o.data].map((p,u)=>{let l=this._def.items[u]||this._def.rest;return l?l._parse(new be(o,p,o.path,u)):null}).filter(p=>!!p);return o.common.async?Promise.all(s).then(p=>se.mergeArray(t,p)):se.mergeArray(t,s)}get items(){return this._def.items}rest(e){return new r(b(d({},this._def),{rest:e}))}};Re.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Re(d({items:r,typeName:M.ZodTuple,rest:null},N(e)))};var Cn=class r extends D{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:o}=this._processInputParams(e);if(o.parsedType!==S.object)return O(o,{code:h.invalid_type,expected:S.object,received:o.parsedType}),R;let n=[],s=this._def.keyType,p=this._def.valueType;for(let u in o.data)n.push({key:s._parse(new be(o,u,o.path,u)),value:p._parse(new be(o,o.data[u],o.path,u)),alwaysSet:u in o.data});return o.common.async?se.mergeObjectAsync(t,n):se.mergeObjectSync(t,n)}get element(){return this._def.valueType}static create(e,t,o){return t instanceof D?new r(d({keyType:e,valueType:t,typeName:M.ZodRecord},N(o))):new r(d({keyType:He.create(),valueType:e,typeName:M.ZodRecord},N(t)))}},At=class extends D{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:o}=this._processInputParams(e);if(o.parsedType!==S.map)return O(o,{code:h.invalid_type,expected:S.map,received:o.parsedType}),R;let n=this._def.keyType,s=this._def.valueType,p=[...o.data.entries()].map(([u,l],c)=>({key:n._parse(new be(o,u,o.path,[c,"key"])),value:s._parse(new be(o,l,o.path,[c,"value"]))}));if(o.common.async){let u=new Map;return Promise.resolve().then(()=>$(this,null,function*(){for(let l of p){let c=yield l.key,f=yield l.value;if(c.status==="aborted"||f.status==="aborted")return R;(c.status==="dirty"||f.status==="dirty")&&t.dirty(),u.set(c.value,f.value)}return{status:t.value,value:u}}))}else{let u=new Map;for(let l of p){let c=l.key,f=l.value;if(c.status==="aborted"||f.status==="aborted")return R;(c.status==="dirty"||f.status==="dirty")&&t.dirty(),u.set(c.value,f.value)}return{status:t.value,value:u}}}};At.create=(r,e,t)=>new At(d({valueType:e,keyType:r,typeName:M.ZodMap},N(t)));var Nt=class r extends D{_parse(e){let{status:t,ctx:o}=this._processInputParams(e);if(o.parsedType!==S.set)return O(o,{code:h.invalid_type,expected:S.set,received:o.parsedType}),R;let n=this._def;n.minSize!==null&&o.data.size<n.minSize.value&&(O(o,{code:h.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),t.dirty()),n.maxSize!==null&&o.data.size>n.maxSize.value&&(O(o,{code:h.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),t.dirty());let s=this._def.valueType;function p(l){let c=new Set;for(let f of l){if(f.status==="aborted")return R;f.status==="dirty"&&t.dirty(),c.add(f.value)}return{status:t.value,value:c}}let u=[...o.data.values()].map((l,c)=>s._parse(new be(o,l,o.path,c)));return o.common.async?Promise.all(u).then(l=>p(l)):p(u)}min(e,t){return new r(b(d({},this._def),{minSize:{value:e,message:y.toString(t)}}))}max(e,t){return new r(b(d({},this._def),{maxSize:{value:e,message:y.toString(t)}}))}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};Nt.create=(r,e)=>new Nt(d({valueType:r,minSize:null,maxSize:null,typeName:M.ZodSet},N(e)));var An=class r extends D{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==S.function)return O(t,{code:h.invalid_type,expected:S.function,received:t.parsedType}),R;function o(u,l){return Rn({data:u,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Mn(),Gt].filter(c=>!!c),issueData:{code:h.invalid_arguments,argumentsError:l}})}function n(u,l){return Rn({data:u,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Mn(),Gt].filter(c=>!!c),issueData:{code:h.invalid_return_type,returnTypeError:l}})}let s={errorMap:t.common.contextualErrorMap},p=t.data;if(this._def.returns instanceof Qe){let u=this;return pe(function(...l){return $(this,null,function*(){let c=new Fe([]),f=yield u._def.args.parseAsync(l,s).catch(_=>{throw c.addIssue(o(l,_)),c}),g=yield Reflect.apply(p,this,f);return yield u._def.returns._def.type.parseAsync(g,s).catch(_=>{throw c.addIssue(n(g,_)),c})})})}else{let u=this;return pe(function(...l){let c=u._def.args.safeParse(l,s);if(!c.success)throw new Fe([o(l,c.error)]);let f=Reflect.apply(p,this,c.data),g=u._def.returns.safeParse(f,s);if(!g.success)throw new Fe([n(f,g.error)]);return g.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new r(b(d({},this._def),{args:Re.create(e).rest(je.create())}))}returns(e){return new r(b(d({},this._def),{returns:e}))}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,o){return new r(d({args:e||Re.create([]).rest(je.create()),returns:t||je.create(),typeName:M.ZodFunction},N(o)))}},ct=class extends D{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};ct.create=(r,e)=>new ct(d({getter:r,typeName:M.ZodLazy},N(e)));var ft=class extends D{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return O(t,{received:t.data,code:h.invalid_literal,expected:this._def.value}),R}return{status:"valid",value:e.data}}get value(){return this._def.value}};ft.create=(r,e)=>new ft(d({value:r,typeName:M.ZodLiteral},N(e)));function Gp(r,e){return new mt(d({values:r,typeName:M.ZodEnum},N(e)))}var mt=class r extends D{constructor(){super(...arguments),Hr.set(this,void 0)}_parse(e){if(typeof e.data!="string"){let t=this._getOrReturnCtx(e),o=this._def.values;return O(t,{expected:Z.joinValues(o),received:t.parsedType,code:h.invalid_type}),R}if(Gn(this,Hr,"f")||wp(this,Hr,new Set(this._def.values),"f"),!Gn(this,Hr,"f").has(e.data)){let t=this._getOrReturnCtx(e),o=this._def.values;return O(t,{received:t.data,code:h.invalid_enum_value,options:o}),R}return pe(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return r.create(e,d(d({},this._def),t))}exclude(e,t=this._def){return r.create(this.options.filter(o=>!e.includes(o)),d(d({},this._def),t))}};Hr=new WeakMap;mt.create=Gp;var Tt=class extends D{constructor(){super(...arguments),qr.set(this,void 0)}_parse(e){let t=Z.getValidEnumValues(this._def.values),o=this._getOrReturnCtx(e);if(o.parsedType!==S.string&&o.parsedType!==S.number){let n=Z.objectValues(t);return O(o,{expected:Z.joinValues(n),received:o.parsedType,code:h.invalid_type}),R}if(Gn(this,qr,"f")||wp(this,qr,new Set(Z.getValidEnumValues(this._def.values)),"f"),!Gn(this,qr,"f").has(e.data)){let n=Z.objectValues(t);return O(o,{received:o.data,code:h.invalid_enum_value,options:n}),R}return pe(e.data)}get enum(){return this._def.values}};qr=new WeakMap;Tt.create=(r,e)=>new Tt(d({values:r,typeName:M.ZodNativeEnum},N(e)));var Qe=class extends D{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==S.promise&&t.common.async===!1)return O(t,{code:h.invalid_type,expected:S.promise,received:t.parsedType}),R;let o=t.parsedType===S.promise?t.data:Promise.resolve(t.data);return pe(o.then(n=>this._def.type.parseAsync(n,{path:t.path,errorMap:t.common.contextualErrorMap})))}};Qe.create=(r,e)=>new Qe(d({type:r,typeName:M.ZodPromise},N(e)));var xe=class extends D{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===M.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:o}=this._processInputParams(e),n=this._def.effect||null,s={addIssue:p=>{O(o,p),p.fatal?t.abort():t.dirty()},get path(){return o.path}};if(s.addIssue=s.addIssue.bind(s),n.type==="preprocess"){let p=n.transform(o.data,s);if(o.common.async)return Promise.resolve(p).then(u=>$(this,null,function*(){if(t.value==="aborted")return R;let l=yield this._def.schema._parseAsync({data:u,path:o.path,parent:o});return l.status==="aborted"?R:l.status==="dirty"||t.value==="dirty"?Rt(l.value):l}));{if(t.value==="aborted")return R;let u=this._def.schema._parseSync({data:p,path:o.path,parent:o});return u.status==="aborted"?R:u.status==="dirty"||t.value==="dirty"?Rt(u.value):u}}if(n.type==="refinement"){let p=u=>{let l=n.refinement(u,s);if(o.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return u};if(o.common.async===!1){let u=this._def.schema._parseSync({data:o.data,path:o.path,parent:o});return u.status==="aborted"?R:(u.status==="dirty"&&t.dirty(),p(u.value),{status:t.value,value:u.value})}else return this._def.schema._parseAsync({data:o.data,path:o.path,parent:o}).then(u=>u.status==="aborted"?R:(u.status==="dirty"&&t.dirty(),p(u.value).then(()=>({status:t.value,value:u.value}))))}if(n.type==="transform")if(o.common.async===!1){let p=this._def.schema._parseSync({data:o.data,path:o.path,parent:o});if(!nt(p))return p;let u=n.transform(p.value,s);if(u instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:u}}else return this._def.schema._parseAsync({data:o.data,path:o.path,parent:o}).then(p=>nt(p)?Promise.resolve(n.transform(p.value,s)).then(u=>({status:t.value,value:u})):p);Z.assertNever(n)}};xe.create=(r,e,t)=>new xe(d({schema:r,typeName:M.ZodEffects,effect:e},N(t)));xe.createWithPreprocess=(r,e,t)=>new xe(d({schema:e,effect:{type:"preprocess",transform:r},typeName:M.ZodEffects},N(t)));var Oe=class extends D{_parse(e){return this._getType(e)===S.undefined?pe(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Oe.create=(r,e)=>new Oe(d({innerType:r,typeName:M.ZodOptional},N(e)));var Ge=class extends D{_parse(e){return this._getType(e)===S.null?pe(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Ge.create=(r,e)=>new Ge(d({innerType:r,typeName:M.ZodNullable},N(e)));var ht=class extends D{_parse(e){let{ctx:t}=this._processInputParams(e),o=t.data;return t.parsedType===S.undefined&&(o=this._def.defaultValue()),this._def.innerType._parse({data:o,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};ht.create=(r,e)=>new ht(d({innerType:r,typeName:M.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default},N(e)));var gt=class extends D{_parse(e){let{ctx:t}=this._processInputParams(e),o=b(d({},t),{common:b(d({},t.common),{issues:[]})}),n=this._def.innerType._parse({data:o.data,path:o.path,parent:d({},o)});return Qr(n)?n.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Fe(o.common.issues)},input:o.data})})):{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new Fe(o.common.issues)},input:o.data})}}removeCatch(){return this._def.innerType}};gt.create=(r,e)=>new gt(d({innerType:r,typeName:M.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch},N(e)));var Dt=class extends D{_parse(e){if(this._getType(e)!==S.nan){let o=this._getOrReturnCtx(e);return O(o,{code:h.invalid_type,expected:S.nan,received:o.parsedType}),R}return{status:"valid",value:e.data}}};Dt.create=r=>new Dt(d({typeName:M.ZodNaN},N(r)));var ll=Symbol("zod_brand"),$r=class extends D{_parse(e){let{ctx:t}=this._processInputParams(e),o=t.data;return this._def.type._parse({data:o,path:t.path,parent:t})}unwrap(){return this._def.type}},Jr=class r extends D{_parse(e){let{status:t,ctx:o}=this._processInputParams(e);if(o.common.async)return $(this,null,function*(){let s=yield this._def.in._parseAsync({data:o.data,path:o.path,parent:o});return s.status==="aborted"?R:s.status==="dirty"?(t.dirty(),Rt(s.value)):this._def.out._parseAsync({data:s.value,path:o.path,parent:o})});{let n=this._def.in._parseSync({data:o.data,path:o.path,parent:o});return n.status==="aborted"?R:n.status==="dirty"?(t.dirty(),{status:"dirty",value:n.value}):this._def.out._parseSync({data:n.value,path:o.path,parent:o})}}static create(e,t){return new r({in:e,out:t,typeName:M.ZodPipeline})}},Ft=class extends D{_parse(e){let t=this._def.innerType._parse(e),o=n=>(nt(n)&&(n.value=Object.freeze(n.value)),n);return Qr(t)?t.then(n=>o(n)):o(t)}unwrap(){return this._def.innerType}};Ft.create=(r,e)=>new Ft(d({innerType:r,typeName:M.ZodReadonly},N(e)));function Ip(r,e){let t=typeof r=="function"?r(e):typeof r=="string"?{message:r}:r;return typeof t=="string"?{message:t}:t}function Wp(r,e={},t){return r?qe.create().superRefine((o,n)=>{var s,p;let u=r(o);if(u instanceof Promise)return u.then(l=>{var c,f;if(!l){let g=Ip(e,o),k=(f=(c=g.fatal)!==null&&c!==void 0?c:t)!==null&&f!==void 0?f:!0;n.addIssue(b(d({code:"custom"},g),{fatal:k}))}});if(!u){let l=Ip(e,o),c=(p=(s=l.fatal)!==null&&s!==void 0?s:t)!==null&&p!==void 0?p:!0;n.addIssue(b(d({code:"custom"},l),{fatal:c}))}}):qe.create()}var cl={object:ce.lazycreate},M;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(M||(M={}));var fl=(r,e={message:`Input not instance of ${r.name}`})=>Wp(t=>t instanceof r,e),Cp=He.create,Ap=at.create,ml=Dt.create,Tl=ot.create,Np=st.create,hl=it.create,gl=Wt.create,Fl=pt.create,xl=ut.create,Ol=qe.create,bl=je.create,Sl=we.create,yl=Ct.create,_l=Ve.create,Il=ce.create,kl=ce.strictCreate,vl=dt.create,wl=Wn.create,El=lt.create,Ml=Re.create,Rl=Cn.create,Gl=At.create,Wl=Nt.create,Cl=An.create,Al=ct.create,Nl=ft.create,Dl=mt.create,Bl=Tt.create,Pl=Qe.create,kp=xe.create,Ul=Oe.create,jl=Ge.create,Vl=xe.createWithPreprocess,Ll=Jr.create,Zl=()=>Cp().optional(),zl=()=>Ap().optional(),Hl=()=>Np().optional(),ql={string:r=>He.create(b(d({},r),{coerce:!0})),number:r=>at.create(b(d({},r),{coerce:!0})),boolean:r=>st.create(b(d({},r),{coerce:!0})),bigint:r=>ot.create(b(d({},r),{coerce:!0})),date:r=>it.create(b(d({},r),{coerce:!0}))},Ql=R,a=Object.freeze({__proto__:null,defaultErrorMap:Gt,setErrorMap:Vd,getErrorMap:Mn,makeIssue:Rn,EMPTY_PATH:Ld,addIssueToContext:O,ParseStatus:se,INVALID:R,DIRTY:Rt,OK:pe,isAborted:Wo,isDirty:Co,isValid:nt,isAsync:Qr,get util(){return Z},get objectUtil(){return Go},ZodParsedType:S,getParsedType:Ue,ZodType:D,datetimeRegex:Rp,ZodString:He,ZodNumber:at,ZodBigInt:ot,ZodBoolean:st,ZodDate:it,ZodSymbol:Wt,ZodUndefined:pt,ZodNull:ut,ZodAny:qe,ZodUnknown:je,ZodNever:we,ZodVoid:Ct,ZodArray:Ve,ZodObject:ce,ZodUnion:dt,ZodDiscriminatedUnion:Wn,ZodIntersection:lt,ZodTuple:Re,ZodRecord:Cn,ZodMap:At,ZodSet:Nt,ZodFunction:An,ZodLazy:ct,ZodLiteral:ft,ZodEnum:mt,ZodNativeEnum:Tt,ZodPromise:Qe,ZodEffects:xe,ZodTransformer:xe,ZodOptional:Oe,ZodNullable:Ge,ZodDefault:ht,ZodCatch:gt,ZodNaN:Dt,BRAND:ll,ZodBranded:$r,ZodPipeline:Jr,ZodReadonly:Ft,custom:Wp,Schema:D,ZodSchema:D,late:cl,get ZodFirstPartyTypeKind(){return M},coerce:ql,any:Ol,array:_l,bigint:Tl,boolean:Np,date:hl,discriminatedUnion:wl,effect:kp,enum:Dl,function:Cl,instanceof:fl,intersection:El,lazy:Al,literal:Nl,map:Gl,nan:ml,nativeEnum:Bl,never:Sl,null:xl,nullable:jl,number:Ap,object:Il,oboolean:Hl,onumber:zl,optional:Ul,ostring:Zl,pipeline:Ll,preprocess:Vl,promise:Pl,record:Rl,set:Wl,strictObject:kl,string:Cp,symbol:gl,transformer:kp,tuple:Ml,undefined:Fl,union:vl,unknown:bl,void:yl,NEVER:Ql,ZodIssueCode:h,quotelessJson:jd,ZodError:Fe});function K(r){return r.reduce((e,t)=>(e[t]=t,e),{})}var We=a.record(a.string(),a.union([a.string(),a.boolean(),a.number(),a.null(),a.lazy(()=>We),a.union([a.string(),a.boolean(),a.number(),a.null(),a.lazy(()=>We)]).array()])).nullable().describe("Custom key/value object"),E=a.union([a.string().datetime({offset:!0,local:!0}),a.string({invalid_type_error:"must be a valid date-time string"}).regex(/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/),a.string().date()]),Le=a.object({allow_timestamps:a.boolean().describe("Allow setting timestamps in transfer insert/update statements"),production:a.boolean().describe("Is running in production mode?")}).partial().describe("System wide flags"),$l=a.enum(["Token","TransferGroup","TransferLog","Transfer","WalletTokenSetting","Wallet","WapiSetting"]),dg=K($l.options),No=a.enum(["="]),Do=a.enum([">=","<=","<",">"]),Dp=a.enum(["like","ilike"]),Jl=a.enum(["in","notIn"]),Kl=a.enum(["null","notNull"]),lg=a.enum([...No.options,...Do.options]).default("="),cg=a.enum([...No.options,...Do.options,...Dp.options]).default("="),fg=a.enum([...No.options,...Do.options,...Dp.options,...Jl.options,...Kl.options]),xt=a.union([a.string(),a.boolean(),a.number()]),Yl=a.object({foreign:a.union([a.string(),a.number()])}),Xl=a.object({identifier:a.union([a.string(),a.number()])}),fe=a.string().regex(/^(?!.*\.\.)[a-zA-Z_][a-zA-Z0-9_.-]*[a-zA-Z0-9_-]$/,"Key is limited to [a-zA-Z0-9_-] and cant start with a number"),Bp=a.union([a.string().array().min(1),a.number().array().min(1)]),z=a.record(fe,xt).describe("Metadata filter for custom properties"),Ce=a.enum(["where","orWhere"]),mg=K(Ce.options),Bo=a.enum(["whereNull","orWhereNull","whereNotNull","orWhereNotNull"]),Tg=K(Bo.options),Po=a.enum(["whereIn","orWhereIn"]),hg=K(Po.options),Uo=a.enum(["whereMetadata","orWhereMetadata"]),gg=K(Uo.options),jo=a.enum(["whereMetadataNull","orWhereMetadataNull","whereMetadataNotNull","orWhereMetadataNotNull"]),Fg=K(jo.options),Vo=a.enum(["whereMetadataIn","orWhereMetadataIn"]),xg=K(Vo.options),Kr=a.enum(["=",">=","<=","<",">","ilike","like"]).default("="),ec=a.object({function:Ce,field:fe,operator:Kr.optional(),value:xt}).describe("Filtering for where and orWhere"),tc=a.union([xt,Yl]),Og=a.object({function:Ce,field:fe,operator:Kr.optional(),value:tc}).describe("Filtering for where and orWhere"),rc=a.union([xt,Xl]),bg=a.object({function:Ce,field:fe,operator:Kr.optional(),value:rc}).describe("Filtering for where and orWhere"),nc=a.object({function:Uo,field:fe,operator:Kr.optional(),value:xt}).required({function:!0,field:!0,value:!0}).describe("Filtering for where and orWhere"),ac=a.object({metadata:z.optional()}).catchall(xt),Sg=a.union([xt,z]),oc=a.object({function:Ce,value:ac}),sc=a.union([ec,oc]),ic=a.object({function:Po,field:fe,value:Bp}),pc=a.object({function:Vo,field:fe,value:Bp}),uc=a.object({function:Bo,field:fe}).describe("Filtering for whereNull and orWhereNull, whereNotNull and orWhereNotNull"),dc=a.object({function:jo,field:fe}).describe("Filtering for whereNull and orWhereNull, whereNotNull and orWhereNotNull for metadata"),Pp=a.discriminatedUnion("function",[nc,pc,dc]),Up=a.union([sc,ic,uc,Pp,a.object({function:Ce,inner:a.lazy(()=>Up.array())})]),yg=a.object({function:Ce,inner:Up.array()}),lc=a.union([Ce,Po,Bo,Uo,Vo,jo]),cc=a.object({function:lc,field:fe.optional(),operator:Kr.optional(),value:a.unknown().optional(),inner:a.unknown().array().optional()}),fc=a.object({function:Ce,inner:a.unknown().array()});function Bt(r,e,t){let o=e.safeParse(r);return o.success||o.error.errors.forEach(n=>{t.addIssue(d({},n))}),o.success}function Ae(r,e){let t=Array.from(new Set([...r.strings,...r.numbers,...r.booleans,...r.nullables,...r.datetimes,...r.foreigns,...r.identifiers])),o=a.enum(t),n=a.object({function:Ce,value:e||a.object({metadata:z})}),s=(p,u)=>{if(!Bt(p,cc,u))return!1;let l=p;if(l.inner)return Bt(l,fc,u)?!l.inner.some(c=>{if(s(c,u)===!1)return!0}):!1;if(!l.field)return Bt(l,n,u);if(l.function.toLowerCase().includes("metadata"))return Bt(l,Pp,u);if(!Bt(l.field,o,u))return!1};return a.record(fe,a.unknown()).superRefine((p,u)=>e&&!p.function?Bt(p,e,u):s(p,u))}var Lo=a.object({tracking_id:a.string().max(64).describe("User provided id added to logs for debugging")}).describe("Tracking flags for input"),x=Lo.extend({transaction_id:a.string().max(64).describe("Id of the transaction context to run the query in")}).describe("Generic flags for input"),ae=a.object({limit:a.number().int().nonnegative().default(20).describe("Number of records to return"),offset:a.number().int().nonnegative().default(0).describe("Number of records to omit from the beginning")}).describe("Optional flags for input limiting"),me=a.object({return_metadata_total:a.boolean().describe("Return the total rows count in metadata")}).describe("Metadata flags for input"),Te=a.object({field:a.string().describe("Field to order by"),direction:a.enum(["asc","desc"]).default("asc").describe("Direction to order"),nulls:a.enum(["first","last"]).describe("Should nulls be first or last")}).strict().partial().required({field:!0}).describe("Input for orderBy"),Lp=a.object({order:Te.array().describe("Ordering options")}).describe("Optional flags for input ordering"),jp=a.object({id:a.number().int().positive().describe("id of the object"),foreign:a.string().max(64).describe("foreign of the object")}).strict().partial(),Pt=a.union([jp.required({id:!0}),jp.required({foreign:!0})]),Vp=a.object({id:a.number().int().positive().describe("id of the object"),identifier:a.string().max(64).describe("identifier of the object")}).strict().partial(),Nn=a.union([Vp.required({id:!0}),Vp.required({identifier:!0})]),Ee=a.enum(["replace","extend"]).default("replace").describe("Whether to replace or extend current metadata with new value"),Ot=a.enum(["replace","replace_create_only","replace_cancel_only","extend","extend_create_only","extend_cancel_only"]).default("replace").describe("Whether to replace or extend current metadata with new value"),Zo=a.enum(["keep","random","largest","target"]).describe("Rule for distribution grouping"),Eg=K(Zo.options),Se=a.object({total:a.number().int().nonnegative().describe("Total number of records matching the query"),offset:a.number().int().nonnegative().describe("Current query offset"),limit:a.number().int().nonnegative().describe("Current query limit"),more_rows:a.boolean().describe("Boolean showing if there would be more rows to return with a higher offset/limit"),order:Te.array()}).partial().required({offset:!0,limit:!0,more_rows:!0}).describe("Metadata about the search"),Dn=a.enum(["count","countDistinct","sum","average","min","max"]).default("count").describe("Function to use for grouping"),zo=a.object({function:Dn,field:fe.describe("Field to group by"),alias:fe.describe("Alias to group under")}).partial().describe("Function and field to group"),Ho=a.union([Dn,zo]).describe("Aggregator description"),qo=a.enum(["year","month","week","day","hour","minute"]).describe("Time period rows should be grouped by"),Zp=K(qo.options),mc=a.object({period:qo.default("day"),timezone:a.string()}).strict().required(),Tc=a.union([qo,mc]),Yr=a.object({type:a.literal("period"),field:Tc,alias:a.string()}).strict().partial().required({type:!0,field:!0}),Xr=a.object({type:a.literal("field"),field:a.string(),alias:a.string()}).strict().partial().required({type:!0,field:!0}),en=a.object({type:a.literal("metadata_field"),field:a.string(),alias:a.string()}).strict().partial().required({type:!0,field:!0}),hc=a.discriminatedUnion("type",[Yr,Xr,en]);var gc=hc.array().max(5),Fc=a.record(a.string(),a.union([a.string(),a.number()]).nullable()).describe("Result of the aggregation"),Bn=Fc.array().describe("Results of the aggregation"),zp=a.object({aggregators:Ho.array(),groups:gc}).partial().required({groups:!0}).describe("Metadata about the aggregation"),Mg=a.object({select:a.string().array()}).describe("Optional flags to select specific fields"),Rg=a.object({deselect:a.string().array()}).describe('Optional flag to remove field from select"'),$e=a.object({start_time:E,end_time:E}).partial().strict();var Ut=a.enum(["active","disabled"]).describe("Current status for the wallet"),Hp=K(Ut.options),jt=a.enum(["token","house","regular"]).describe("Type of the wallet"),qp=K(jt.options),j=a.object({id:a.number().int().positive().describe("System defined primary key"),foreign:a.string().min(1).max(255).describe("User provided key for wallet. Must be unique"),name:a.string().min(1).max(255).optional().nullable().describe("User provided key for wallet. Must be unique"),metadata:We.describe("Key/value object describing this wallet").optional(),default_allow_negative:a.boolean().default(!1).describe("Boolean indicating if wallet (pending_amount + finished_amount) can be negative"),default_allow_positive:a.boolean().default(!0).describe("Boolean indicating if wallet (pending_amount + finished_amount) can be positive. Used for token balance to deny positive balance."),created_at:E.describe("Datetime of the initial create"),updated_at:E.describe("Datetime of the last update"),default_dtw_to:a.string().max(3).optional().describe("Bitmap indicating default what types of transfers can originate from wallet"),default_dtw_from:a.string().max(3).optional().describe("Bitmap indicating default what types of transfers can end to wallet"),type:jt.describe("Type of the wallet").default("regular"),status:Ut.describe("Current status for the wallet").default("active")}).strict().describe("Wallet|Entities who can make transfers in this system");var Qp=j.keyof(),xc=Qp.options,Oc=Qp.exclude(["metadata"]).options,Ng=new Set(Oc),Dg=new Set(xc);var L=a.enum(["pending","finished","cancelled"]).describe("Status of the transfer"),$p=K(L.options),X=L.exclude(["cancelled"]).describe("Status of the transfer"),Je=a.enum(["transfer","deposit","withdrawal"]).describe("Type of the transfer"),bt=K(Je.options),T=a.object({id:a.number().int().positive().describe("System defined primary key"),identifier:a.string().min(1).max(255).describe("Identifier for this transfer. Must be unique"),control_hash:a.string().max(255).nullable().describe('Hash binding this transfer to the from_wallets transfer chain. It is calculated as sha256(latest_outgoing_hash + "-" + NEW.identifier)'),from_wallet_id:a.number().int().positive().describe("Foreign key to wallet funds originate from"),to_wallet_id:a.number().int().positive().describe("Foreign key to wallet where funds are going"),token_id:a.number().int().positive().describe("Foreign key to token this transfer refers to"),amount:a.number().positive().describe("The transfer amount"),type:Je.describe("Type of the transfer").default("transfer"),status:L.describe("Status of the transfer").default("pending"),force:a.boolean().default(!1).describe("Set to true to force transfer without checking for negative balance constraints"),auto_hash:a.boolean().default(!0).describe("When set to true it will automatically calculate the control_hash"),created_at:E.describe("Datetime of the initial create"),updated_at:E.describe("Datetime of the last update"),metadata:We.describe("Key/value object describing this transfer").optional(),transfer_group_id:a.number().int().positive().nullable().optional().describe("Foreign key pointing to the transfer_group this transfer belongs to"),reverses_id:a.number().int().positive().nullable().optional().describe("Foreign key pointing to the transfer this transfer reverses. Must be unique"),status_finalized_at:E.nullable().optional().describe("DateTime transfer reached final status"),group_validate:a.boolean().nullable().optional().describe("Boolean showing if the transfer_group has validate_final_balance_only")}).strict().describe("A transfer of value from one wallet to another"),Vg=T.omit({id:!0}).extend({status:X.default("pending")}).partial().required({identifier:!0,from_wallet_id:!0,to_wallet_id:!0,token_id:!0,amount:!0}),Jp={numbers:["id","amount","from_wallet_id","to_wallet_id","token_id","transfer_group_id","reverses_id"],strings:["identifier","control_hash","type","status"],booleans:["force","auto_hash","group_validate"],nullables:["transfer_group_id","reverses_id","group_validate"],datetimes:["created_at","updated_at","status_finalized_at"],foreigns:[],identifiers:[],metadata:!0},Kp=T.keyof(),bc=Kp.options,Sc=Kp.exclude(["metadata"]).options,Lg=new Set(bc),Zg=new Set(Sc);var G=a.object({id:a.number().int().positive().describe("UNIQUE|System defined primary key"),transfer_id:a.number().int().positive().describe("Foreign key pointing to the transfer this log belongs to"),wallet_id:a.number().int().positive().describe("Foreign key pointing to the wallet this log belongs to"),token_id:a.number().int().positive().describe("Foreign key pointing to the token this log belongs to"),amount:a.number().describe("The amount the wallet balance is changed by"),pending_amount:a.number().describe("The pending balance of wallet after this transfer_log"),finished_amount:a.number().describe("The finished balance of wallet after this transfer_log"),allow_negative:a.boolean().default(!1).describe("Boolean indicating if wallet (pending_amount + finished_amount) can be negative"),allow_positive:a.boolean().default(!0).describe("Boolean indicating if wallet (pending_amount + finished_amount) can be positive. Used for token balance to deny positive balance."),force:a.boolean().default(!1).describe("Boolean indicating if the latest transfer from this wallet was forced to ignore negative balance checks"),created_at:E.describe("Datetime this log was created"),latest_control_hash:a.string().max(255).nullable().describe("Latest hash related to this wallet"),pending_amount_to:a.number().describe("The incoming pending balance"),pending_amount_from:a.number().describe("The outgoing pending balance"),group_balance:a.number().nullable().describe("Running balance for the wallet in this group"),transfer_group_id:a.number().int().positive().nullable().optional().describe("Foreign key pointing to the transfer_group this transfer_log belongs to"),current:a.boolean().describe("Boolean showing if this transfer_log is the latest for this wallet/token combination"),available_balance:a.number().describe("Available balance that is sum of pending_amount_from and finished_amount"),token_limit:a.number().nullable().describe("If wallet = token.belongs_to and token has limit"),status:L.describe("Status of this log - same as Transfer.status"),type:Je.describe("Type of this log - same as Transfer.type")}).strict().describe("TransferLog|Individual parts of a transfer, will be updated internally by db. Immutable");var Yp=G.keyof(),Qo=Yp.options,yc=Yp.options,$g=new Set(yc),Jg=new Set(Qo);var Xp=a.enum(["active","dw-only","disabled"]).describe("Current status for the token"),eu=K(Xp.options),Ne=a.enum(["value","share","group","contract"]).describe("Type of the token"),tu=K(Ne.options),V=a.object({id:a.number().int().positive().describe("System defined primary key"),foreign:a.string().min(1).max(255).describe("Name of the token, used for name based token transfers. Must be unique"),public:a.boolean().describe("Boolean indicating if token can be traded with outside seed wallet").default(!0),belongs_to:a.number().int().positive().describe("Foreign key to seed wallet"),metadata:We.describe("Key/value object describing the token").optional(),divisor:a.number().nullable().describe("Minimum amount of token that can be transferred").optional(),limit:a.number().nullable().describe("Maximum amount of token that can be issued").optional(),type:Ne.describe("Type of the token").default("value"),status:Xp.describe("Current status for the token").default("active"),created_at:E.describe("Datetime when the token was created"),updated_at:E.describe("Datetime when the token was last updated")}).strict().describe("Units of value which can be transferred in this system"),ru={numbers:["id","belongs_to","divisor","limit"],strings:["foreign","type","status"],booleans:["public"],nullables:["divisor","limit"],datetimes:["created_at","updated_at"],foreigns:["belongs_to"],identifiers:[],metadata:!0},nu=V.keyof(),Pn=nu.options,$o=nu.exclude(["metadata"]).options,tF=new Set(Pn),rF=new Set($o);var H=Pt.describe("Unique wallet filter"),tn=x.extend({ignore_cache:a.boolean().describe("Ignore cached information"),create_if_not_exists:a.boolean().default(!1).describe("If true then the token will be created if not found. Only valid with 'foreign'"),return_only_id:a.boolean().default(!1).describe("If true then the returning object is only guaranteed to have id")}).partial(),Un=a.object({wallet:H,options:tn.optional()}).strict().required({wallet:!0}).describe("Input for getWallet"),Jo=j.extend({balance_token_id:V.shape.id.nullable(),balance_token_foreign:V.shape.foreign.nullable(),balance_transfer_id:G.shape.transfer_id.describe("Latest transfer id").nullable(),balance_pending_amount:G.shape.pending_amount.describe("Current pending balance").nullable(),balance_pending_amount_to:G.shape.pending_amount_to.describe("Sum of incoming pending transfers").nullable(),balance_pending_amount_from:G.shape.pending_amount_from.describe("Sum of outgoing pending transfers").nullable(),balance_finished_amount:G.shape.finished_amount.describe("Current finished balance").nullable(),balance_amount:a.number().describe("Current finished and pending balance sum").nullable(),balance_available_balance:G.shape.available_balance.describe("Available balance that is sum of pending_amount_from and finished_amount").nullable(),balance_latest_control_hash:G.shape.latest_control_hash.describe("Latest control_hash associated with wallet token combination").nullable(),balance_updated_at:G.shape.created_at.describe('"Last modification date of balance').nullable()}),jn=Jo.keyof(),Ko=j.partial().required({id:!0}),Vn=a.object({wallet:Ko.optional()}).describe("Output of getWallet");var ye=a.enum(["open","closed"]).describe("Lifecycle status for transfer group"),Ln=K(ye.options),Ke=a.enum(["regular","exchange","distribution"]).describe("Type of the transfer group"),au=K(Ke.options),B=a.object({id:a.number().int().positive().describe("UNIQUE|System defined primary key"),identifier:a.string().min(1).max(255).describe("UNIQUE,INPUT|Identifier for this transfer group. Must be unique"),created_at:E.describe("Datetime of the initial create"),updated_at:E.describe("Datetime of the last update"),metadata:We.describe("INPUT|Key/value object describing this transfer_group").optional(),transfer_group_id:a.number().int().positive().nullable().optional().describe("Foreign key pointing to the transfer_group this transfer belongs to"),reverses_id:a.number().int().positive().nullable().optional().describe("Foreign key pointing to the transfer_group this transfer_group reverses. Must be unique"),status_finalized_at:E.nullable().optional().describe("Time transfer_group was closed"),transfer_status_finalized_at:E.nullable().optional().describe("Time transfer_status reached final state"),validate_final_balance_only:a.boolean().nullable().optional().describe("Boolean if only the final balances of wallets should be validated"),transfer_status:a.enum(["pending","finished","cancelled"]).describe("INPUT|Status of the transfers").default("pending"),status:ye.describe("INPUT|Lifecycle status for transfer group").default("open"),type:Ke.describe("INPUT|Type of the transfer group").default("regular")}).strict().describe("TransferGroup|An entity collecting transfers into a group locked by status"),Yo={numbers:["id","amount","transfer_group_id","reverses_id"],strings:["identifier","transfer_status","type","status"],booleans:["validate_final_balance_only"],nullables:["transfer_group_id","reverses_id","status_finalized_at","transfer_status_finalized_at","validate_final_balance_only"],datetimes:["created_at","updated_at","status_finalized_at","transfer_status_finalized_at"],foreigns:[],identifiers:[],metadata:!0},ou=B.keyof(),Xo=ou.options,_c=ou.exclude(["metadata"]).options,fF=new Set(Xo),mF=new Set(_c);var St=Nn.describe("Unique transfer filter"),es=x.partial(),Zn=a.object({transfer:St,options:es.optional()}).strict().required({transfer:!0}).describe("Input for getTransfer"),re=T.extend({from_wallet_foreign:j.shape.foreign,to_wallet_foreign:j.shape.foreign,token_foreign:V.shape.foreign,transfer_group_identifier:B.shape.identifier.nullable(),reverses_identifier:T.shape.identifier.nullable()}),su=re.extend({balance_id:G.shape.id.nullable().describe("Iterator marking the position of the balance in the continuum"),balance_pending:G.shape.pending_amount.nullable().describe("Wallet pending balance after transfer"),balance_pending_to:G.shape.pending_amount_to.nullable().describe("Wallet pending_to balance after transfer"),balance_pending_from:G.shape.pending_amount_from.nullable().describe("Wallet pending_from balance after transfer"),balance_finished:G.shape.finished_amount.nullable().describe("Wallet finished balance after transfer"),signed_amount:G.shape.amount.nullable().describe("amount with a sign according to transfer direction"),status_finalized_at:G.shape.created_at.nullable().describe("DateTime transfer reached final status")}),_e=a.object({transfer:re.optional()}).describe("Output of getTransfer");var Y=Pt.describe("Unique token filter"),EF=V.partial().required({id:!0}),zn=V.extend({belongs_to_foreign:j.shape.foreign.describe("Wallet the token belongs to").nullable(),balance_transfer_id:G.shape.transfer_id.nullable().describe("Latest transfer id"),balance_pending_amount:G.shape.pending_amount.nullable().describe("Current pending balance"),balance_pending_amount_to:G.shape.pending_amount_to.nullable().describe("Sum of incoming pending transfers"),balance_pending_amount_from:G.shape.pending_amount_from.nullable().describe("Sum of outgoing pending transfers"),balance_finished_amount:G.shape.finished_amount.nullable().describe("Current finished balance"),balance_amount:a.number().nullable().describe("Current finished and pending balance sum"),balance_available_balance:G.shape.available_balance.nullable().describe("Available balance that is sum of pending_amount_from and finished_amount"),balance_latest_control_hash:G.shape.latest_control_hash.nullable().describe("Latest control_hash associated with wallet token combination"),balance_updated_at:G.shape.created_at.nullable().describe('"Last modification date of balance')}),ts=zn.keyof(),rn=x.extend({ignore_cache:a.boolean().describe("Ignore cached information"),create_if_not_exists:a.boolean().default(!1).describe("If true then the token will be created if not found. Only valid with 'foreign'"),return_only_id:a.boolean().default(!1).describe("If true then the returning object is only guaranteed to have id"),include_balance:a.boolean().default(!1).describe("Return the total system balance of token")}).partial(),Hn=a.object({token:Y,options:rn.optional()}).strict().required({token:!0}).describe("Input for getToken"),rs=zn.partial().required({id:!0}),qn=a.object({token:rs.optional()}).describe("Output of getToken");var ue=Nn.describe("Unique transferGroup filter"),ns=x.extend({create_if_not_exists:a.boolean().default(!1).describe("If true then the transfer_group will be created if not found. Only valid with 'identifier'"),return_only_id:a.boolean().default(!1).describe("If true then the returning object is only guaranteed to have id")}).partial(),Qn=a.object({transfer_group:ue,options:ns.optional()}).strict().required({transfer_group:!0}).describe("Input for getTransferGroup"),nn=B.extend({reverses_identifier:B.shape.identifier.nullable().describe("Identifier of the transfer group this reverses")}).partial().required({id:!0}).describe("requested transfer_group"),$n=a.object({transfer_group:nn.optional()}).describe("Output of getTransferGroup");var as=a.object({return_running_balance_for_wallet:H.describe("Return running balance for each transfer for wallet in question"),return_signed_amount_for_wallet:H.describe("Return amount as signed value for each transfer for wallet in question")}),an=x.merge(ae).merge(me).merge(as).extend({order:Te.extend({field:T.keyof()}).array(),select:re.keyof().array(),deselect:re.keyof().array()}).partial(),iu=a.object({id:T.shape.id,identifier:T.shape.identifier,from_wallet:H,to_wallet:H,wallet:H,token:Y,status:L,transfer_group:ue,metadata:z}).partial(),Ic=b(d({},Jp),{foreigns:["from_wallet","to_wallet","wallet","token"],identifiers:["transfer_group","reverses"]}),kc=Ae(Ic,iu),yt=a.union([iu,kc.array()]),Vt=a.object({transfer:yt,options:an.optional()}).strict().partial().describe("Input for findTransferMany"),Jn=a.object({transfers:su.partial().array().describe("Found transfers"),metadata:Se}).partial().required({transfers:!0,metadata:!0}).describe("Output of findTransferMany");var vc=a.object({return_all_intervals:$e.describe("Add empty values for each interval if no matching data")}).partial(),os=x.merge(vc).partial().optional(),wc=a.enum(["from.amount","to.amount","amount","abs.amount","transfer_group","from_wallet","to_wallet","wallet","token","id"]).describe("Field to group by"),Ec=zo.extend({field:wc}).partial(),ss=a.union([Ec,Dn]),Mc=a.enum(["type","status","from_wallet","to_wallet","wallet","token","transfer_group"]),is=a.union([Yr,Xr.extend({field:Mc}),en]),Kn=a.object({transfer:yt,aggregators:ss.array(),groups:is.array(),options:os}).partial().required({aggregators:!0}).describe("Input for aggregateTransferMany"),Yn=a.object({rows:Bn,metadata:zp}).partial().describe("Output of getToken");var Rc=x.partial(),Xn=a.object({options:Rc}).strict().partial().describe('Input for authenticationCheck"'),pu=a.object({}).describe("Output of authenticationCheck");var Gc=a.object({wallet_foreign:j.shape.foreign,from_wallet_foreign:j.shape.foreign,to_wallet_foreign:j.shape.foreign,token_foreign:V.shape.foreign}).partial().describe("Forced filters for requests"),ps=a.enum(["aggregateTransferMany","exportBalanceHistory","exportTokenMany","exportTransferGroupMany","exportTransferMany","exportWalletMany","findBalanceMany","findTokenMany","findTransferGroupMany","findTransferMany","findWalletMany","getBalance","getBalanceHistory","getExport","getStatistics","getToken","getTokenMany","getTransfer","getTransferGroup","getWallet","getWalletMany","healthcheck","listExportMany"]).describe("Allowed methods"),us=a.object({type:a.enum(["limited"]).describe("Type of the accessToken"),scopes:ps.array(),expiresIn:a.number().int().positive().describe("JWT expiration time in minutes"),filters:Gc.optional()}).strict(),ds=a.object({type:a.enum(["admin"]).describe("Type of the accessToken"),expiresIn:a.number().int().positive().describe("JWT expiration time in minutes")}).strict(),ls=x.partial(),ea=a.object({token:a.union([us,ds]),options:ls}).strict().partial().required({token:!0}).describe("Input for createAccessToken"),ta=a.object({authToken:a.string().describe("The JWT token")}).describe("Output of createAccessToken");var on=a.object({wallet:H,token:Y,datetime:E.describe("Time the balance should be retrieved at").optional()}).strict(),cs=x.extend({ignore_cache:a.boolean().describe("Ignore cached information"),create_wallet_if_not_exists:a.boolean().default(!1).describe("If true then the missing wallet will be created if not found. Only valid with 'foreign'"),create_token_if_not_exists:a.boolean().default(!1).describe("If true then the missing token will be created if not found. Only valid with 'foreign'"),create_if_not_exists:a.boolean().default(!1).describe("If true then the missing balance will be created if not found.")}).partial(),ra=a.object({balance:on,options:cs}).partial().strict().required({balance:!0}).describe("Input for getBalance"),_t=G.pick({transfer_id:!0,token_id:!0,wallet_id:!0,pending_amount:!0,pending_amount_from:!0,pending_amount_to:!0,available_balance:!0,finished_amount:!0,latest_control_hash:!0}).extend({token_foreign:V.shape.foreign,wallet_foreign:j.shape.foreign,amount:a.number().describe("Current finished and pending balance sum"),updated_at:G.shape.created_at}).strict().partial().required({token_id:!0,token_foreign:!0,wallet_id:!0,wallet_foreign:!0,pending_amount:!0,finished_amount:!0,amount:!0,latest_control_hash:!0,updated_at:!0}),De=a.object({balance:_t.optional()}).strict().describe("Output of getBalance");var Ye=a.object({identifier:T.shape.identifier,latest_control_hash:T.shape.control_hash.nullable().describe("Latest control_hash on the from_wallet"),from_wallet:H.describe("Wallet where funds are debited"),to_wallet:H.describe("Wallet where funds are credited"),token:Y.describe("Token that is moved"),amount:T.shape.amount,type:T.shape.type,status:X,force:T.shape.force,metadata:T.shape.metadata,transfer_group:ue.describe("TransferGroup the transfer belongs to"),created_at:T.shape.created_at}).strict(),na=Ye.extend({type:a.literal("transfer").default("transfer").describe("Type of transfer")}).partial().strict().required({from_wallet:!0,to_wallet:!0,token:!0,amount:!0}),Lt=Ye.partial().extend({type:a.literal("deposit").describe("Type of transfer")}).strict().required({to_wallet:!0,token:!0,amount:!0}),Zt=Ye.partial().extend({type:a.literal("withdrawal").describe("Type of transfer")}).strict().required({from_wallet:!0,token:!0,amount:!0}),fs=a.union([na,Lt,Zt]).pipe(a.union([na,Lt,Zt])),Ze=x.extend({return_from_balance:a.boolean().default(!1).describe("Whether the request should also return from wallet balance"),return_to_balance:a.boolean().default(!1).describe("Whether the request should also return to wallet balance"),create_to_wallet_if_not_exists:a.boolean().default(!1).describe("If true then the wallet will be created if not found. Only valid with 'foreign'")}).partial().optional(),aa=a.object({transfer:fs,options:Ze}).strict().required({transfer:!0}).describe("Input for createTransfer"),Xe=a.object({transfer:_e.shape.transfer.describe("Created transfer object"),from_balance:De.shape.balance.describe("Debited wallet balance"),to_balance:De.shape.balance.describe("Credited wallet balance")}).partial().strict().required({transfer:!0}).describe("Output of createTransfer");var Wc=na.omit({status:!0,transfer_group:!0}).strip(),Cc=Lt.omit({status:!0,transfer_group:!0}).strip(),Ac=Zt.omit({status:!0,transfer_group:!0}).strip(),Nc=a.union([Wc,Cc,Ac]),ms=a.object({identifier:B.shape.identifier,status:ye,transfer_status:L,metadata:B.shape.metadata,children:Nc.array().describe("Array of children")}).partial(),Ts=x.extend({create_to_wallet_if_not_exists:a.boolean().default(!1).describe("If true then the wallet will be created if not found. Only valid with 'foreign'"),validate_final_balance_only:a.boolean().default(!1).describe("If true then transfers within a group will ignore balance restrictions. Only final transfers for wallets are checked. Only valid with transfer_status_lock")}).partial().optional(),oa=a.object({transfer_group:ms,options:Ts}).strict().partial().describe("Input for createTransferGroup"),et=a.object({transfer_group:B,transfers:_e.shape.transfer.array().describe("Created transfer objects")}).partial().required({transfer_group:!0}).describe("Output of createTransferGroup");var hs=x.extend({return_all_intervals:$e.describe("Add empty values for each interval if no matching data")}).partial().optional(),Dc=a.object({from_wallet:H.describe("Wallet the contract will belong to at the end (buyer)"),from_latest_control_hash:T.shape.control_hash.nullable().describe("Latest control_hash on the from_wallet+from_token combo"),from_token:Y.describe("Token that is transferred from from_wallet in exchange of the contract"),to_wallet:H.describe("Wallet the payment for the contract is sent to (seller)"),amount:T.shape.amount,status:a.enum(["pending","finished"]).describe("The state at which the exchange is created"),force:T.shape.force,metadata:T.shape.metadata}).partial().strict().required({from_wallet:!0,from_token:!0,amount:!0}),Bc=a.object({foreign:V.shape.foreign,metadata:V.shape.metadata,deposits:a.object({token:Y.describe("Token that is transferred"),amount:T.shape.amount}).array().nonempty(),owner:H.describe("The inital owner of the contract, defaults to foreign = 'house'").default({foreign:"house"})}).partial().required({foreign:!0,deposits:!0}),sa=a.object({token:Bc,exchange:Dc,options:hs}).strict().partial().required({token:!0}).describe("Input for createContract"),ia=a.object({token:V,exchange:et}).partial().required({token:!0}).describe("Output of createContract");var Pc=Ze,pa=a.object({deposit:Lt.extend({type:a.literal("deposit").optional()}),options:Pc}).strict().required({deposit:!0}).describe("Input for createDeposit"),ua=Xe.describe("Output of createDeposit");var Uc=a.object({wallet:H.describe("Wallet where funds are credited"),portion:a.union([a.string(),a.number()]).describe("Number specifying the portion of funds to be credited"),metadata:T.shape.metadata}).partial().required({wallet:!0}),jc=Y.describe("Wallets will receive funds based on their balance of this token"),Vc=a.object({rule:Zo,target:a.object({wallet:H,metadata:T.shape.metadata}).strict().partial().required({wallet:!0})}).strict().partial().required({rule:!0}),Lc=a.object({identifier:B.shape.identifier.describe("Unique identifier for this distribution"),latest_control_hash:T.shape.control_hash.nullable().describe("Latest control_hash on the from_wallet"),from_wallet:H.describe("Wallet where funds are debited"),token:Y.describe("Token that is moved"),amount:T.shape.amount,status:L,force:T.shape.force,metadata:T.shape.metadata,copy_wallet_metadata_fields:a.object({from_property:a.string(),to_property:a.string()}).partial().required({from_property:!0}).array().describe("Copy metadata information from Wallet metadata to transfer metadata"),transfer_group:ue.describe("TransferGroup the transfer belongs to"),targets:a.union([jc,Uc.array().nonempty()]),leftover:Vc}).partial().required({identifier:!0,from_wallet:!0,token:!0,amount:!0,targets:!0,leftover:!0}).describe("Distribute funds from one wallet between multiple wallets"),Zc=x.extend({dryrun:a.boolean().default(!1)}).partial().optional(),da=a.object({distribution:Lc,options:Zc}).strict().partial().required({distribution:!0}).describe("Input for createDistribution"),uu=a.object({transfer_group:B,transfers:_e.shape.transfer.array().describe("Created transfer objects")}).partial().required({transfer_group:!0,transfers:!0}).describe("Output of createDistribution");var gs=a.object({foreign:V.shape.foreign,public:V.shape.public,metadata:V.shape.metadata,divisor:V.shape.divisor,limit:V.shape.limit,type:Ne,belongs_to:Pt.describe("Wallet this token belongs_to")}).partial().required({foreign:!0}),Fs=x.partial(),la=a.object({token:gs,options:Fs.optional()}).strict().required({token:!0}).describe("Input for createToken"),ca=a.object({token:V,wallet:j}).describe("Output of createToken");var xs=Ze,fa=a.object({transfers:fs.array().nonempty().describe("An array of transfers"),options:xs}).strict().required({transfers:!0}).describe("Input for createTransferMany"),ma=a.object({transfers:_e.shape.transfer.array().describe("Created transfer objects"),from_balances:De.shape.balance.array().describe("Debited wallet balances"),to_balances:De.shape.balance.array().describe("Credited wallet balances")}).partial().strict().required({transfers:!0}).describe("Output of createTransferMany");var Os=a.object({foreign:j.shape.foreign,name:j.shape.name,metadata:j.shape.metadata,type:jt,status:Ut}).partial().required({foreign:!0}),bs=x.partial(),Ta=a.object({wallet:Os,options:bs}).partial().strict().required({wallet:!0}).describe("Input for createWallet"),ha=a.object({wallet:j}).describe("Output of createWallet");var ga=a.object({withdrawal:Zt.extend({type:a.literal("withdrawal").optional()}),options:Ze}).strict().required({withdrawal:!0}).describe("Input for createWithdrawal"),Fa=Xe.describe("Output of createWithdrawal");var Ss=a.enum(["transfers","transfer_groups","tokens","wallets","balance_history","unknown"]).describe("Type of the export"),zc=a.enum(["started","completed","error"]).describe("Status of the export"),sn=a.object({identifier:a.string().describe("Unique identifier of the export"),status:zc,type:Ss,created_at:E.describe("Timestamp when export was initiated"),completed_at:E.describe("Timestamp when export was finished"),fields:a.string().array().describe("The fields selected for this export"),count:a.number().int().positive().describe("The number of entities exported in this file"),signed_url:a.string().describe("Signed URL for downloading the export file"),size:a.string().describe("Size of the exported file"),message:a.string().describe("Extra information about the state of the file")}).partial().required({identifier:!0}).describe("Information about exported file"),ys=x.extend({return_signed_url:a.boolean().describe("Return signed url for downloading the export file, will only be returned if status === 'completed'")}).partial(),xa=a.object({export:a.object({identifier:sn.shape.identifier}),options:ys.optional()}).strict().required({export:!0}).describe("Input for getExport"),he=a.object({export:sn.optional()}).describe("Output of getExport");var Hc=a.object({create_wallet_if_not_exists:a.boolean().default(!1).describe("If true then the missing wallet will be created if not found. Only valid with 'foreign'"),create_token_if_not_exists:a.boolean().default(!1).describe("If true then the missing token will be created if not found. Only valid with 'foreign'")}),du=a.object({balance_id:G.shape.id.describe("The internal ID of the balance"),token_id:G.shape.token_id.describe("Token ID of balance"),token_foreign:V.shape.foreign.describe("Token Foreign of balance"),wallet_id:G.shape.wallet_id.describe("Wallet ID of balance"),wallet_foreign:j.shape.foreign.describe("Wallet Foreign of balance"),pending_amount:G.shape.pending_amount.describe("Current pending balance"),pending_amount_to:G.shape.pending_amount_to.describe("Sum of incoming pending transfers"),pending_amount_from:G.shape.pending_amount_from.describe("Sum of outgoing pending transfers"),available_balance:G.shape.available_balance.describe("Available balance that is sum of pending_amount_from and finished_amount"),finished_amount:G.shape.finished_amount.describe("Current finished balance"),amount:a.number().describe("Current finished and pending balance sum"),status:a.enum(["pending","finished"]).describe("The status of the change to balance"),latest_control_hash:G.shape.latest_control_hash.describe("Latest control_hash associated with wallet token combination"),updated_at:G.shape.created_at.describe("Last modification date of balance"),transfer_id:T.shape.id,transfer_identifier:T.shape.identifier,transfer_control_hash:T.shape.control_hash,transfer_from_wallet_id:T.shape.from_wallet_id,transfer_from_wallet_foreign:j.shape.foreign,transfer_to_wallet_id:T.shape.to_wallet_id,transfer_to_wallet_foreign:j.shape.foreign,transfer_amount:T.shape.amount,transfer_type:Je,transfer_status:L,transfer_force:T.shape.force,transfer_created_at:T.shape.created_at,transfer_updated_at:T.shape.updated_at,transfer_metadata:T.shape.metadata,transfer_transfer_group_id:T.shape.transfer_group_id,transfer_transfer_group_identifier:B.shape.identifier.optional().nullable().describe("Transfer Group identifier if transfer belongs to a group"),transfer_reverses_id:T.shape.reverses_id,transfer_reverses_identifier:T.shape.identifier.optional().nullable().describe("Reverses identifier if transfer reverses another transfer"),transfer_status_finalized_at:T.shape.status_finalized_at.nullable().describe("DateTime transfer reached final status")}).strict().partial(),_s=a.object({order:a.enum(["asc","desc"])}).describe("Ordering options"),qc=du.keyof(),Is=a.object({select:qc.array()}).describe("Optional flags to limit search result"),ks=x.merge(ae).merge(me).merge(Hc).merge(_s).merge(Is).extend({return_all_intervals:$e.describe("Add empty values for each interval if no matching data")}).partial(),Oa=a.object({balance:on,options:ks.optional()}).strict().required({balance:!0}).describe("Input for getBalanceHistory"),ba=a.object({balances:du.array().describe("Resolved balance change objects"),metadata:Se}).required({balances:!0}).describe("Output of getBalanceHistory");var vs=x.merge(ae).merge(me).merge(Is).merge(_s).partial(),Sa=a.object({balance:on,options:vs}).strict().partial().required({balance:!0}).describe("Input for exportBalanceHistory"),ya=a.object({export:he.shape.export}).describe("Output of exportBalanceHistory");var pn=x.merge(ae).merge(me).extend({include_balance:a.boolean().describe("Return the total system balance of token"),order:Te.extend({field:a.enum(Pn)}).array(),select:ts.array(),deselect:ts.array()}).partial(),BO=a.enum(Pn),PO=a.enum($o),lu=a.object({foreign:a.string(),type:Ne,metadata:z,belongs_to:H}).partial(),Qc=ru,$c=Ae(Qc,lu),Jc=a.union([lu,$c.array()]),zt=a.object({token:Jc,options:pn.optional()}).strict().partial().describe("Input for findTokenMany"),_a=a.object({tokens:zn.partial().array().describe("Found tokens"),metadata:Se}).partial().required({tokens:!0,metadata:!0}).describe("Output of findTokenMany");var ws=pn,Ia=zt.extend({options:ws.optional()}).describe("Input of exportTokenMany"),ka=he.describe("Output of exportTokenMany");var Es=nn.extend({transfers_count:a.number().describe("Number of transfers in the group").optional()}),un=x.merge(ae).merge(me).extend({return_transfers_count:a.boolean().default(!1).describe("Return number of transfers in the transfer_group"),order:Te.extend({field:a.enum(Xo)}).array(),select:Es.keyof().array(),deselect:Es.keyof().array()}).partial(),cu=a.object({identifier:B.shape.identifier,status:ye,type:Ke,transfer_status:L,reverses:ue,metadata:z}).partial(),Kc=b(d({},Yo),{identifiers:[...Yo.identifiers,"transfer_group","reverses"]}),Yc=Ae(Kc,cu),dn=a.union([cu,Yc.array()]),Ht=a.object({transfer_group:dn,options:un}).strict().partial().describe("Input for findTransferGroup"),va=a.object({transfer_groups:Es.partial().array().describe("Found transfers"),metadata:Se}).partial().required({transfer_groups:!0,metadata:!0}).describe("Output of findTransferGroup");var Xc=un,wa=Ht.extend({options:Xc.optional()}).partial().describe("Input of exportTransferGroupManyMany"),Ea=he.describe("Output of exportTransferGroupMany");var ef=an.omit({return_running_balance_for_wallet:!0,return_signed_amount_for_wallet:!0}),Ma=Vt.extend({options:ef.optional()}).describe("Input of exportTransferMany"),Ra=he.describe("Output of exportTransferMany");var ln=x.merge(ae).merge(me).extend({include_balance_for_token:Y.describe("If specified each wallet will have its balance included"),order:Te.extend({field:jn}).array(),select:jn.array(),deselect:jn.array()}).partial(),fu=a.object({foreign:a.string(),name:a.string(),type:jt,status:Ut,metadata:z}).partial(),tf={strings:["name","type","status","foreign"],numbers:["id","balance_pending_amount","balance_finished_amount","balance_available_balance"],datetimes:["created_at","updated_at"],booleans:[],nullables:["name"],foreigns:[],identifiers:[],metadata:!0},rf=Ae(tf,fu),nf=a.union([fu,rf.array()]),qt=a.object({wallet:nf,options:ln}).strict().partial().describe("Input for findWalletMany"),Ga=a.object({wallets:Jo.partial().nullable().array().describe("Found wallets"),metadata:Se}).partial().required({wallets:!0,metadata:!0}).describe("Output of findWalletMany");var af=ln,Wa=qt.extend({options:af.optional()}).describe("Input of exportWalletMany"),Ca=he.describe("Output of exportWalletMany");var mu=_t.keyof(),Ms=x.merge(ae).merge(me).extend({order:Te.extend({field:a.enum(Qo)}).array(),select:mu.array(),deselect:mu.array()}).partial(),Tu=a.object({wallet:H,token:Y,transfer:St,type:Je,status:L,amount:G.shape.amount,pending_amount:G.shape.pending_amount,finished_amount:G.shape.finished_amount,metadata:z}).partial(),of={strings:["type","status"],numbers:["amount","pending_amount","finished_amount"],booleans:[],datetimes:["updated_at"],foreigns:["wallet","token"],identifiers:[],nullables:[],metadata:!0},sf=Ae(of,Tu),pf=a.union([Tu,sf.array()]),Aa=a.object({balance:pf,options:Ms.optional()}).strict().partial().describe("Input for findBalanceMany"),Na=a.object({balances:_t.partial().array().describe("Found balances"),metadata:Se}).partial().required({balances:!0,metadata:!0}).describe("Output of findBalanceMany");var uf=x.partial().required({transaction_id:!0}),Da=a.object({action:a.enum(["commit","rollback"]).default("commit").describe("Finish transaction with commit/rollback"),options:uf}).strict().required({action:!0,options:!0}).describe("Input for finishTransaction"),hu=a.object({success:a.boolean(),message:a.string().optional().describe("Error message when success is false")}).describe("Output of finishTransaction");var Rs=x.partial(),Ba=a.object({options:Rs.optional()}).strict().describe("Input for getFlags"),Pa=a.object({flags:Le}).describe("Output of getFlags");var df=a.enum(["Transfer","TransferGroup","Wallet","Token"]).default("Transfer").describe("Model to return statistics about"),lf=$e.extend({status:L}).strict().partial().describe("Filter to apply to transfers before grouping"),cf=a.enum(["type","status","transfer_status"]).default("type").describe("Field to group statistics about. Only used with group_by_field type"),ff=Xr.extend({field:cf}),mf=a.union([Yr,en,ff]),Gs=Lo.partial(),Qt=a.object({model:df,groups:mf.array().max(5).describe("Array of grouping definitions"),aggregator:Ho,filter:lf,options:Gs}).strict().partial().describe("Input for getStatistics"),Ua=a.object({rows:Bn}).describe("Output of getStatistics");var Tf=rn,ja=a.object({tokens:Y.array(),options:Tf.optional()}).strict().required({tokens:!0}).describe("Input for getTokenMany"),gu=a.object({tokens:rs.nullable().array()}).required({tokens:!0}).describe("Output of getTokenMany");var hf=tn,Va=a.object({wallets:H.array(),options:hf.optional()}).strict().required({wallets:!0}).describe("Input for getWalletMany"),Fu=a.object({wallets:Ko.nullable().array()}).required({wallets:!0}).describe("Output of getWalletMany");var Ws=x.partial(),La=a.object({options:Ws}).strict().partial().describe("Input for healthcheck"),Za=a.object({status:a.enum(["green","yellow","red"]).describe("Status of the service"),message:a.string().describe("Error message if some error occurred"),database_size:a.string().describe("Size of the database in MB"),indexes_size:a.string().describe("Size of all indexes of database in MB"),connection_count:a.number().describe("Number of external connections to this database"),version:a.string().describe("Version the server is running")}).partial().required({status:!0}).describe("Output of healthcheck");var Cs=x.partial(),gf=a.object({target:a.literal("wallet"),data:Os}),Ff=a.object({target:a.literal("token"),data:gs}),xf=ms.extend({created_at:E.optional(),status_finalized_at:E.optional(),transfer_status_finalized_at:E.optional()}),Of=a.object({target:a.literal("transfer_group"),data:xf}),As=a.object({identifier:T.shape.identifier,from_wallet:H,to_wallet:H,token:Y,amount:T.shape.amount,metadata:T.shape.metadata,status:L,transfer_group:ue,created_at:E,status_finalized_at:E}),bf=As.extend({type:a.literal("regular")}).partial().required({from_wallet:!0,to_wallet:!0,token:!0,amount:!0,type:!0}),Sf=As.extend({type:a.literal("deposit")}).partial().required({to_wallet:!0,token:!0,amount:!0,type:!0}),yf=As.extend({type:a.literal("withdrawal")}).partial().required({from_wallet:!0,token:!0,amount:!0,type:!0}),_f=a.union([bf,Sf,yf]),If=a.object({target:a.literal("transfer"),data:_f}),kf=a.union([gf,Ff,Of,If]),$t=a.object({actions:kf.array().describe("Array of actions to import."),options:Cs}).partial().required({actions:!0}).describe("Input for importActions"),za=a.object({progress:a.unknown().array(),erroneous:a.unknown().array()}).partial().describe("Output of importActions");var vf=a.object({order:Te.extend({field:a.enum(["identifier","completed_at","created_at"])}).array()}),Ns=x.merge(ae).merge(vf).partial(),Ha=a.object({export:a.object({date:E.describe("Date the file was created on"),type:sn.shape.type.describe("Entity that was exported")}).partial(),options:Ns}).partial().describe("Input for listExportMany"),qa=a.object({exports:sn.array()}).describe("Output of listExportMany");var wf=x.extend({exact_level:a.boolean().describe("Should query be limited to exactly defined level or greater than")}).partial(),Qa=a.object({startTime:E.describe("Log entries start time"),endTime:E.describe("Log entries end time"),tracking_id:a.string(),level:a.enum(["debug","info","warning","error"]),options:wf}).partial().describe("Input for queryLogs"),Ef=a.object({level:a.enum(["debug","info","warning","error"]),timestamp:a.string(),payload:a.record(a.string(),a.unknown())}),xu=a.object({logs:Ef.array()}).required({logs:!0}).describe("Output of queryLogs");var Mf=x.partial(),$a=a.object({confirmation:a.string().describe("hash to confirm database delete"),version:a.string().describe("target semver for the database"),options:Mf}).strict().partial().describe("Input for resetDatabase"),Ou=a.object({message:a.string().describe("Message about operation"),confirmation:a.string().describe("confirmation hash to resend")}).partial().describe("Output of resetDatabase");var Jt=T.pick({metadata:!0,status:!0,updated_at:!0}).extend({extend_metadata:T.shape.metadata}).partial(),SS=Jt.keyof(),Ds=x.extend({return_from_balance:a.boolean().default(!1).describe("Whether the request should also return from wallet balance"),return_to_balance:a.boolean().default(!1).describe("Whether the request should also return to wallet balance"),return_when_not_updated:a.boolean().default(!1).describe("Whether the request should return the transfer object even if it was not updated"),metadata_action:Ee}).partial(),Ja=a.object({transfer:St,update:Jt,options:Ds.optional()}).strict().describe("Input for updateTransfer"),Kt=a.object({transfer:re.describe("Updated transfer object"),updated:a.boolean().describe("Boolean showing if the transfer was updated"),from_balance:_t.describe("Debited wallet balance"),to_balance:_t.describe("Credited wallet balance")}).partial().describe("Output of updateTransfer");var Rf=a.object({reverse_deposit:a.boolean().default(!1).describe("Whether to create withdrawal transaction for deposit (will default to pending)"),reverse_withdrawal:a.boolean().default(!1).describe("Whether to create deposit transaction for withdrawal (will default to pending)"),return_from_balance:a.boolean().default(!1).describe("Whether the request should also return from wallet balance"),return_to_balance:a.boolean().default(!1).describe("Whether the request should also return to wallet balance"),metadata_action:Ot}),Gf=a.object({status:X,identifier:Ye.shape.identifier,force:Ye.shape.force,metadata:Ye.shape.metadata,extend_metadata:Ye.shape.metadata}).strict().partial().describe("In case the transfer will be made then apply these modifications"),Bs=x.merge(Rf).partial(),Ka=a.object({transfer:St,reverse:Gf,options:Bs}).partial().required({transfer:!0}).describe("Input for reverseTransfer"),Ya=Kt.describe("Output of reverseTransfer");var Wf=a.object({reverse_deposit:a.boolean().default(!1).describe("Whether to create withdrawal transaction for deposits (will default to pending)"),reverse_withdrawal:a.boolean().default(!1).describe("Whether to create deposit transaction for withdrawals (will default to pending)"),return_transfers:a.boolean().describe("Should the update return all transfers belonging to group"),validate_final_balance_only:a.boolean().default(!1).describe("If true then transfers within a group will ignore balance restrictions. Only final transfers for wallets are checked."),metadata_action:Ot,transfer_metadata_action:Ot}).strict().partial(),cn=x.merge(Wf).partial(),Ps=a.object({status:ye,transfer_status:X,identifier:B.shape.identifier,force:T.shape.force,metadata:B.shape.metadata,transfer_metadata:T.shape.metadata,extend_metadata:B.shape.metadata.describe("Key value object to be merged with existing metadata"),transfer_extend_metadata:T.shape.metadata.describe("Key value object to be merged with each transfers existing metadata")}).strict().partial().describe("In case the transferGroup will be made then apply these modifications"),Xa=a.object({transfer_group:ue,reverse:Ps,options:cn}).partial().required({transfer_group:!0}).describe("Input for reverseTranferGroup"),eo=a.object({transfer_group:B,transfers:re.array().describe("Updated transfers")}).partial().describe("Output of reverseTranferGroup");var Cf=Ps.omit({identifier:!0}),to=a.object({transfer_group:dn,reverse:Cf,options:cn}).strict().partial().required({transfer_group:!0}).describe("Input for reverseTranferGroupMany"),bu=a.object({transfer_groups:B.array().describe("Reversed transfer groups"),transfers:re.array().describe("Created transfer objects")}).partial().describe("Output of reverseTranferGroupMany");var Us=a.object({status:X,force:T.shape.force,metadata:T.shape.metadata}).partial(),js=x.extend({reverse_deposit:a.boolean().describe("Whether to create withdrawal transaction for deposit (will default to pending)"),reverse_withdrawal:a.boolean().describe("Whether to create deposit transaction for withdrawal (will default to pending)"),metadata_action:Ot}).partial(),ro=a.object({transfer:yt,reverse:Us,options:js}).strict().partial().required({transfer:!0}).describe("Input for reverseTranferMany"),no=a.object({transfers:re.array().describe("Created transfer array")}).partial().describe("Output of reverseTranferMany");var Vs=x.partial(),ao=a.object({flags:Le.partial(),options:Vs}).strict().partial().required({flags:!0}).describe("Input for setFlags"),oo=a.object({flags:Le,message:a.string().describe("optional message")}).strict().partial().required({flags:!0}).describe("Output of setFlags");var Af=x.partial(),so=a.object({options:Af}).strict().partial().describe("Input for startTransaction"),Su=a.object({transaction_id:a.string().describe("id of the created transaction")}).partial().describe("Output of startTransaction");var Ls=x.partial().extend({return_when_not_updated:a.boolean().default(!1).describe("Whether the request should return the token object even if it was not updated")}),yu=V.pick({metadata:!0,status:!0,public:!0}).partial(),iy=yu.keyof(),io=a.object({token:Y,update:yu,options:Ls.optional()}).strict().describe("Input for updateToken"),po=a.object({token:V,updated:a.boolean().describe("Boolean showing if the token was updated")}).partial().describe("Output of updateToken");var Zs=a.object({status:ye.describe("Lifecycle status of the TransferGroup"),transfer_status:L.describe("Status all the transfers should be set at."),metadata:B.shape.metadata.describe("Key value object to be replaced or extended with existing TransferGroup metadata"),transfer_metadata:T.shape.metadata.describe("Key value object to be replaced or extended with existing Transfer metadata")}).partial().describe("Changes to be made to the transfer_group"),fn=Zs.refine(r=>Object.values(r).some(e=>e!==void 0),{message:"One of the fields must be defined"}),Ty=Zs.keyof(),mn=x.extend({return_transfers:a.boolean().describe("Should the update return all transfers belonging to group"),return_when_not_updated:a.boolean().default(!1).describe("Whether the request should return the transfer_group object even if it was not updated"),metadata_action:Ee,transfer_metadata_action:Ee}).partial(),uo=a.object({transfer_group:ue,update:fn,options:mn.optional()}).strict().describe("Input for updateTransferGroup"),lo=a.object({transfer_group:B,updated:a.boolean().describe("Boolean showing if the transfer_group was updated"),transfers:re.array().describe("Updated transfers")}).partial().describe("Output of updateTransferGroup");var zs=mn,co=a.object({transfer_group:dn,update:fn,options:zs}).strict().partial().required({transfer_group:!0,update:!0}).describe("Input for updateTransferGroupMany"),fo=a.object({transfer_groups:nn.array().describe("Updated transfer groups"),transfers:re.array().describe("Updated transfers"),updated:a.boolean().describe("Boolean showing if the transfer_group were updated")}).partial().describe("Output of updateTransferGroupMany");var Hs=x.extend({metadata_action:Ee}).partial(),mo=a.object({transfer:yt,update:Jt,options:Hs}).strict().partial().required({transfer:!0,update:!0}).describe("Input for updateTransferMany"),To=a.object({transfers:re.array().describe("Updated transfers"),updated:a.boolean().describe("Boolean showing if the transfers were updated")}).partial().describe("Output of updateTransferMany");var qs=x.extend({return_when_not_updated:a.boolean().default(!1).describe("Whether the request should return the wallet object even if it was not updated")}).partial(),_u=j.pick({metadata:!0,status:!0,name:!0}),Wy=_u.keyof(),ho=a.object({wallet:H,update:_u.partial(),options:qs.optional()}).strict().describe("Input for updateWallet"),go=a.object({wallet:j,updated:a.boolean().describe("Boolean showing if the wallet was updated")}).partial().describe("Output of updateWallet");var Qs={aggregateTransferMany:i(Kn).validateInputWOptions,authenticationCheck:i(Xn).validateInputWOptions,createAccessToken:i(ea).validateInputWOptions,createContract:i(sa).validateInputWOptions,createDeposit:i(pa).validateInputWOptions,createDistribution:i(da).validateInputWOptions,createToken:i(la).validateInputWOptions,createTransfer:i(aa).validateInputWOptions,createTransferGroup:i(oa).validateInputWOptions,createTransferMany:i(fa).validateInputWOptions,createWallet:i(Ta).validateInputWOptions,createWithdrawal:i(ga).validateInputWOptions,exportBalanceHistory:i(Sa).validateInputWOptions,exportTokenMany:i(Ia).validateInputWOptions,exportTransferGroupMany:i(wa).validateInputWOptions,exportTransferMany:i(Ma).validateInputWOptions,exportWalletMany:i(Wa).validateInputWOptions,findBalanceMany:i(Aa).validateInputWOptions,findTokenMany:i(zt).validateInputWOptions,findTransferGroupMany:i(Ht).validateInputWOptions,findTransferMany:i(Vt).validateInputWOptions,findWalletMany:i(qt).validateInputWOptions,finishTransaction:i(Da).validateInputWOptions,getBalance:i(ra).validateInputWOptions,getBalanceHistory:i(Oa).validateInputWOptions,getExport:i(xa).validateInputWOptions,getFlags:i(Ba).validateInputWOptions,getStatistics:i(Qt).validateInputWOptions,getToken:i(Hn).validateInputWOptions,getTokenMany:i(ja).validateInputWOptions,getTransfer:i(Zn).validateInputWOptions,getTransferGroup:i(Qn).validateInputWOptions,getWallet:i(Un).validateInputWOptions,getWalletMany:i(Va).validateInputWOptions,healthcheck:i(La).validateInputWOptions,importActions:i($t).validateInputWOptions,listExportMany:i(Ha).validateInputWOptions,queryLogs:i(Qa).validateInputWOptions,resetDatabase:i($a).validateInputWOptions,reverseTransfer:i(Ka).validateInputWOptions,reverseTransferGroup:i(Xa).validateInputWOptions,reverseTransferGroupMany:i(to).validateInputWOptions,reverseTransferMany:i(ro).validateInputWOptions,setFlags:i(ao).validateInputWOptions,startTransaction:i(so).validateInputWOptions,updateToken:i(io).validateInputWOptions,updateTransfer:i(Ja).validateInputWOptions,updateTransferGroup:i(uo).validateInputWOptions,updateTransferGroupMany:i(co).validateInputWOptions,updateTransferMany:i(mo).validateInputWOptions,updateWallet:i(ho).validateInputWOptions},$s=(w=>(w.aggregateTransferMany="aggregateTransferMany",w.authenticationCheck="authenticationCheck",w.createAccessToken="createAccessToken",w.createContract="createContract",w.createDeposit="createDeposit",w.createDistribution="createDistribution",w.createToken="createToken",w.createTransfer="createTransfer",w.createTransferGroup="createTransferGroup",w.createTransferMany="createTransferMany",w.createWallet="createWallet",w.createWithdrawal="createWithdrawal",w.exportBalanceHistory="exportBalanceHistory",w.exportTokenMany="exportTokenMany",w.exportTransferGroupMany="exportTransferGroupMany",w.exportTransferMany="exportTransferMany",w.exportWalletMany="exportWalletMany",w.findBalanceMany="findBalanceMany",w.findTokenMany="findTokenMany",w.findTransferGroupMany="findTransferGroupMany",w.findTransferMany="findTransferMany",w.findWalletMany="findWalletMany",w.finishTransaction="finishTransaction",w.getBalance="getBalance",w.getBalanceHistory="getBalanceHistory",w.getExport="getExport",w.getFlags="getFlags",w.getStatistics="getStatistics",w.getToken="getToken",w.getTokenMany="getTokenMany",w.getTransfer="getTransfer",w.getTransferGroup="getTransferGroup",w.getWallet="getWallet",w.getWalletMany="getWalletMany",w.healthcheck="healthcheck",w.importActions="importActions",w.listExportMany="listExportMany",w.queryLogs="queryLogs",w.resetDatabase="resetDatabase",w.reverseTransfer="reverseTransfer",w.reverseTransferGroup="reverseTransferGroup",w.reverseTransferGroupMany="reverseTransferGroupMany",w.reverseTransferMany="reverseTransferMany",w.setFlags="setFlags",w.startTransaction="startTransaction",w.updateToken="updateToken",w.updateTransfer="updateTransfer",w.updateTransferGroup="updateTransferGroup",w.updateTransferGroupMany="updateTransferGroupMany",w.updateTransferMany="updateTransferMany",w.updateWallet="updateWallet",w))($s||{});var Nf=r=>{let{success:e}=$t.safeParse(r);return e},Yt=class{constructor(e,t,o){v(this,"type");v(this,"_connection");v(this,"$connect");v(this,"connectionType");v(this,"jwt");v(this,"host");v(this,"isConnected",!1);v(this,"socId");v(this,"hooks",new Proxy({},{set(e,t,o){if(typeof o!="function")throw new TypeError("Hooks can only be functions");return e[t]=o,!0}}));v(this,"_requests",new Map);v(this,"_error",!1);v(this,"_sending",new Map);v(this,"sendingTimeout");this.type=t,this._connection=e,this.connectionType=t,this.$connect=o}_setConnected(e){this.$connect=void 0,e&&this._error!==!1&&(this._error=!1),!this.isConnected&&e&&this.hooks.connected&&this.hooks.connected(this.socId),this.isConnected&&!e&&this.hooks.disconnected&&this.hooks.disconnected(),this.isConnected=e}_setErrored(e){this._error=e,this._setConnected(!1)}_clearError(){this._error=!1}_send(e){throw new Error("This method must be implemented by child class")}_reconnect(e){throw new Error("This method must be implemented by child class")}close(){return $(this,null,function*(){throw new Error("This method must be implemented by child class")})}_connectionLost(){this._requests.forEach((e,t)=>{"stream"in e&&e.stream.destroy(new ke("CONNECTION_LOST",{method:"connectionLost"})),this._requests.delete(t)}),this.socId=void 0}_handleMessage(e){var u,l,c,f;if(this.hooks.message&&this.hooks.message(e),"method"in e){let g=e;if(g.method==="ping"){this._send({jsonrpc:"2.0",result:"pong",id:g.id});return}W("Unexpected JSONRPCRequest",e);return}let t=e;if(this.hooks.message&&this.hooks.message(t),t.id===null){W("Unexpected JSONRPCResponse",e);return}if(t.result==="ack"){clearTimeout((u=this._sending.get(t.id))==null?void 0:u.timeout),this._sending.delete(t.id);return}let o=this._requests.get(t.id);if(!o){W("No Request found for incoming",e);return}if("handle"in o){o.handle(t),delete o.handle;return}t.error&&"error"in o&&o.error(t.error);let n=t;if(((l=n.result)==null?void 0:l.type)==="streamPause"&&"pause"in o){o.pause();return}if(((c=n.result)==null?void 0:c.type)==="streamResume"&&"resume"in o){o.resume();return}let{stream:s,start:p}=o;if(((f=n.result)==null?void 0:f.type)==="streamChunk"){s.push(n.result);return}s.push(n),s.destroyed||s.push(null),n.id&&this._requests.delete(n.id),this.connectionType==="ws"&&this._send({jsonrpc:"2.0",method:"ack",params:Date.now()-p,id:n.id})}_sendTransaction(e,t){let o=Qs[e](t);return this._sendRaw(e,o)}_setSending(e,t){if(e.id===null)throw new Error("JSONRPCMessage should not be null");this._sending.set(e.id,d({},this.sendingTimeout&&{timeout:setTimeout(()=>{this._sending.delete(e.id),t.push({error:new ge("SENDING_TIMEOUT",{timeout:this.sendingTimeout}).toJSON()}),this._requests.delete(e.id)},this.sendingTimeout)}))}_sendRaw(e,t){let o={jsonrpc:"2.0",method:e,params:t,id:rt()};return this.hooks.preflight&&this.hooks.preflight(o)===!1?new Be:new Be(n=>$(this,null,function*(){if(this._error&&this._reconnect(5),this.isConnected||(yield this.$connect),this._error)throw this._error;this._requests.set(o.id,{stream:n,start:Date.now()}),this._setSending(o,n),this._send(o)}))}_streamTransaction(e,t,o,n){let s=Date.now(),p=rt(),u,l=({stream:_,method:P,params:q})=>{if(u)return;let U={jsonrpc:"2.0",method:P,params:d({streamId:p},q),id:rt()};this._setSending(U,_),this._send(U)},c=(_,P)=>{u||(l({stream:_,method:"streamError",params:{error:P}}),u=P,_.push({error:P}))},f=new wn,g=n?f.pipe(n):f,k={jsonrpc:"2.0",method:"streamStart",params:{method:e,options:o},id:p};return this.hooks.preflight&&this.hooks.preflight(k)===!1?new zr:new zr(_=>$(this,null,function*(){if(this._error&&this._reconnect(5),this.isConnected||(yield this.$connect),this._error)throw this._error;let P=setTimeout(()=>{_.push({error:new ke("INPUT_STREAM_TIMEOUT",{streamId:p})})},3e4);this._requests.set(k.id,{stream:_,start:s,error(q){u=q,W("stream:error()>",q)},pause(){f.pause()},resume(){f.resume()},handle(q){if(q.error){_.push(q);return}g.on("data",U=>{if(!u){if(P&&(clearTimeout(P),P=null),!t(U)){c(_,new ke("INVALID_INPUT_STREAM_CHUNK",{streamId:p,chunk:U}));return}l({stream:_,method:"streamData",params:{data:U}})}}).on("error",U=>{u||(P&&(clearTimeout(P),P=null),l({stream:_,method:"streamError",params:{error:U}}),_.push({error:new ke("INPUT_STREAM_ERROR",{streamId:p,error:U})}))}).on("end",()=>{P&&(clearTimeout(P),P=null),l({stream:_,method:"streamEnd",params:{}})})}}),this._setSending(k,_),this._send(k)}),f)}aggregateTransferMany(e){return this._sendTransaction("aggregateTransferMany",e)}authenticationCheck(e){return this._sendTransaction("authenticationCheck",e!=null?e:{})}createAccessToken(e){return this._sendTransaction("createAccessToken",e)}createContract(e){return this._sendTransaction("createContract",e)}createDeposit(e){return this._sendTransaction("createDeposit",e)}createDistribution(e){return this._sendTransaction("createDistribution",e)}createToken(e){return this._sendTransaction("createToken",e)}createTransfer(e){return this._sendTransaction("createTransfer",e)}createTransferGroup(e){return this._sendTransaction("createTransferGroup",e!=null?e:{})}createTransferMany(e){return this._sendTransaction("createTransferMany",e)}createWallet(e){return this._sendTransaction("createWallet",e)}createWithdrawal(e){return this._sendTransaction("createWithdrawal",e)}exportBalanceHistory(e){return this._sendTransaction("exportBalanceHistory",e)}exportTokenMany(e){return this._sendTransaction("exportTokenMany",e!=null?e:{})}exportTransferGroupMany(e){return this._sendTransaction("exportTransferGroupMany",e!=null?e:{})}exportTransferMany(e){return this._sendTransaction("exportTransferMany",e!=null?e:{})}exportWalletMany(e){return this._sendTransaction("exportWalletMany",e!=null?e:{})}findBalanceMany(e){return this._sendTransaction("findBalanceMany",e!=null?e:{})}findTokenMany(e){return this._sendTransaction("findTokenMany",e!=null?e:{})}findTransferGroupMany(e){return this._sendTransaction("findTransferGroupMany",e!=null?e:{})}findTransferMany(e){return this._sendTransaction("findTransferMany",e!=null?e:{})}findWalletMany(e){return this._sendTransaction("findWalletMany",e!=null?e:{})}finishTransaction(e){return this._sendTransaction("finishTransaction",e)}getBalance(e){return this._sendTransaction("getBalance",e)}getBalanceHistory(e){return this._sendTransaction("getBalanceHistory",e)}getExport(e){return this._sendTransaction("getExport",e)}getFlags(e){return this._sendTransaction("getFlags",e!=null?e:{})}getStatistics(e){return this._sendTransaction("getStatistics",e!=null?e:{})}getToken(e){return this._sendTransaction("getToken",e)}getTokenMany(e){return this._sendTransaction("getTokenMany",e)}getTransfer(e){return this._sendTransaction("getTransfer",e)}getTransferGroup(e){return this._sendTransaction("getTransferGroup",e)}getWallet(e){return this._sendTransaction("getWallet",e)}getWalletMany(e){return this._sendTransaction("getWalletMany",e)}healthcheck(e){return this._sendTransaction("healthcheck",e!=null?e:{})}importActions(e){return this._sendTransaction("importActions",e)}importActionsStream(e,t){return this._streamTransaction("importActions",Nf,e,t)}listExportMany(e){return this._sendTransaction("listExportMany",e!=null?e:{})}queryLogs(e){return this._sendTransaction("queryLogs",e!=null?e:{})}resetDatabase(e){return this._sendTransaction("resetDatabase",e!=null?e:{})}reverseTransfer(e){return this._sendTransaction("reverseTransfer",e)}reverseTransferGroup(e){return this._sendTransaction("reverseTransferGroup",e)}reverseTransferGroupMany(e){return this._sendTransaction("reverseTransferGroupMany",e)}reverseTransferMany(e){return this._sendTransaction("reverseTransferMany",e)}setFlags(e){return this._sendTransaction("setFlags",e)}startTransaction(e){return this._sendTransaction("startTransaction",e!=null?e:{})}updateToken(e){return this._sendTransaction("updateToken",e)}updateTransfer(e){return this._sendTransaction("updateTransfer",e)}updateTransferGroup(e){return this._sendTransaction("updateTransferGroup",e)}updateTransferGroupMany(e){return this._sendTransaction("updateTransferGroupMany",e)}updateTransferMany(e){return this._sendTransaction("updateTransferMany",e)}updateWallet(e){return this._sendTransaction("updateWallet",e)}};var Iu,Df=(Iu=window.WAPI_VERSION)!=null?Iu:"";function Ks(r,e){let t=ku(r,{timeout:e==null?void 0:e.connectingTimeout});return new Js(t,r,e)}function ku(r,e){var q;let t=d({rejectUnauthorized:(q=r.rejectUnauthorized)!=null?q:!0,connectionName:e==null?void 0:e.connectionName,clientVersion:Df},r),o=Fp(t),n=new dp(...o),s,p,u=!1,l;n.onclose=c,n.onerror=f,n.onmessage=g;function c(U){if(W(`createConnection>close(reason:${U.reason},code:${U.code},wasClean:${U.wasClean})`),U.code===4030)return _(new wt);_(new Error("WS closed"))}function f(U){W(`createConnection>error(message:${U.message},error:${U.error},type:${U.type})`),_(U.error)}function g(U){W(`createConnection>message(type:${U.type},data:${U.data})`);let{data:xo}=U,Oo;try{Oo=JSON.parse(xo.toString())}catch(Id){return W("Invalid JSON response",Id),_(new Error("Invalid JSON response"))}if(Oo.result!=="ready")return W("Invalid first message"),_(new Error("Invalid first message - "+JSON.stringify(Oo)));_()}W(`createConnection>(message:setting up ws connection${e!=null&&e.timeout?" with timeout "+e.timeout:""})`);let k=e!=null&&e.timeout?setTimeout(()=>{_(new ge("CONNECTION_TIMEOUT",{timeout:e.timeout}))},e.timeout):void 0;function _(U){u||(clearTimeout(k),n.onmessage=()=>{},n.onerror=()=>{},n.onclose=()=>{},U?(p(U),n.close()):s(l),u=!0)}let P=new Promise((U,xo)=>{s=U,p=xo});return{ws:n,$connect:P}}var Js=class extends Yt{constructor(t,o,n){var s;super(t.ws,"ws",t.$connect);v(this,"_pingTimeout");v(this,"_opts");v(this,"_connectionConfig");v(this,"_tryToReconnect",!0);this._opts=o,this._connectionConfig=n,this.host=o.host,(s=this.$connect)==null||s.then(p=>(this.socId=p,this._ready())).catch(p=>{this.socId||this._setErrored(p)})}_setErrored(t){super._setErrored(t),(t instanceof wt||"code"in t&&t.code===J.AUTH.ERRORS.AUTHENTICATION_ERROR.code)&&(this._tryToReconnect=!1)}_ready(){this._setConnected(!0),this._connection.onmessage=t=>{let{data:o,type:n}=t;if(W(`message(type:${n},data:$0)`,o),n==="message"){let s=JSON.parse(o.toString());this._handleMessage(s),this._heartbeat()}},this._connection.onerror=t=>{let{message:o,error:n,type:s}=t;W(`error(message:$0,error:$1,type:${s})`,o,n)},this._connection.onclose=t=>{let{reason:o,code:n,wasClean:s}=t;W(`close(reason:$0,code:${n},wasClean:${s})`,o),this._setConnected(!1),clearTimeout(this._pingTimeout),this._connectionLost(),this._reconnect()},this._heartbeat()}_reconnect(t){if(W("reconnect(),tryToReconnect:",this._tryToReconnect),!this._tryToReconnect)return;if(this.hooks.reconnect&&this.hooks.reconnect()===!1){W("reconnect hook returned false");return}if(this.$connect){W("already connecting");return}super._clearError(),t!=null||(t=window.WAPI_RECONNECT_ATTEMPTS&&parseInt(window.WAPI_RECONNECT_ATTEMPTS)||10);let o=window.WAPI_MAX_RECONNECT_WAIT&&parseInt(window.WAPI_MAX_RECONNECT_WAIT)||1e4;this.$connect=$(this,null,function*(){var s,p,u;let n;for(let l=0;l<t+1;l++)try{W("Trying to connect, attempt:",l);let{ws:c,$connect:f}=ku(this._opts,{timeout:(s=this._connectionConfig)==null?void 0:s.reconnectingTimeout});n=yield f,this.socId=n,this._connection=c,this._ready();break}catch(c){let f=c.code===J.AUTH.ERRORS.AUTHENTICATION_ERROR.code,g=l>t-1;if(f||g){this._setErrored(c),(u=(p=this.hooks).reconnectError)==null||u.call(p,c);break}yield hp(Math.min(Math.pow(1.5,l)*1e3,o))}return n})}_heartbeat(){W("heartbeat"),clearTimeout(this._pingTimeout),this._pingTimeout=setTimeout(()=>{if(this._sending.size)return W("pingTimeout reached, but sending.size:",this._sending.size),this._heartbeat();W("timeout"),this._connection.close(),this._setConnected(!1),this._reconnect()},31e3)}_send(t){W("send()",t),this._connection.send(JSON.stringify(t))}close(){return $(this,null,function*(){return W("close()"),this._tryToReconnect=!1,clearTimeout(this._pingTimeout),this._setConnected(!1),this._connection.close()})}};var Ys=typeof globalThis!="undefined"&&globalThis||typeof self!="undefined"&&self||typeof Ys!="undefined"&&Ys,Xs=Ys.fetch;function ti(r,e){let t=Bf(r,{timeout:e==null?void 0:e.connectingTimeout,skipInit:e==null?void 0:e.httpSkipInitialAuthConnection,connectionName:e==null?void 0:e.connectionName});return new ei(t,r)}function Bf(r,e){let t=r.host.replace(/^wss:/,"https:"),o="x-wapi-req-id",n="x-wapi-conn-name";function s(c){return $(this,null,function*(){W("http_createConnection>message(body:$0)",c)})}function p(c,f){return $(this,null,function*(){let g=JSON.parse(c),_=yield(yield Xs(`${t}/api`,{keepalive:!0,method:"POST",headers:d({Authorization:`Bearer ${f}`,"content-type":"application/json",[o]:g==null?void 0:g.id},e!=null&&e.connectionName?{[n]:e==null?void 0:e.connectionName}:{}),body:c})).json();this.onmessage(b(d({},_),{id:g.id}))})}let u=rt(),l=new Promise((c,f)=>{if(e!=null&&e.skipInit)return c(void 0);let g=new AbortController;W(`createConnection(sending http auth request${e!=null&&e.timeout?" with timeout "+e.timeout:""})`);let k=e!=null&&e.timeout?setTimeout(()=>{g.abort(),f(new ge("CONNECTION_TIMEOUT",{timeout:e.timeout}))},e.timeout):void 0;Xs(`${t}/api`,{method:"POST",headers:d({Authorization:`Bearer ${r.jwt}`,"content-type":"application/json",[o]:u},e!=null&&e.connectionName?{[n]:e==null?void 0:e.connectionName}:{}),body:JSON.stringify({jsonrpc:"2.0",method:"authenticationCheck",params:{},id:u}),signal:g.signal}).then(_=>_.json()).then(_=>{if(clearTimeout(k),_.error)throw new Error(_.error.message);c(void 0)}).catch(f)});return{send:p,onmessage:s,$connect:l}}var ei=class extends Yt{constructor(e,t){var o;super(e,"https",e.$connect),this.host=t.host,this.jwt=t.jwt,(o=this.$connect)==null||o.then(()=>{this._ready()}).catch(n=>{this._setErrored(n)})}_send(e){W("send()",e),this._connection.send(JSON.stringify(e),this.jwt)}_ready(){this._setConnected(!0),this._connection.onmessage=e=>$(this,null,function*(){W("http_message($0)>",e),this._handleMessage(e)})}close(){return $(this,null,function*(){W("close()"),this._setConnected(!1)})}_reconnect(){return $(this,null,function*(){W("reconnect()")})}};var ni=class r{constructor(e){v(this,"filter",[]);v(this,"modifierFn");this.modifierFn=e}add(e){return this.filter.push(e),this}addWhere(e,t,o,n){if(typeof t=="object"){let s={};for(let[p,u]of Object.entries(t))s[p]=this.modifierFn?this.modifierFn(p,u):u;return this.add({function:e,value:s})}if(typeof t=="function"){let s=new r(this.modifierFn);return t.call(s,s),this.add({function:e,inner:s.toJSON().filter})}if(n!==void 0)return this.add({function:e,field:t,operator:o,value:n});if(typeof o=="object")return this.add({function:e,value:{[t]:o}});if(o!==void 0){let s=this.modifierFn?this.modifierFn(t,o):o;return this.add({function:e,field:t,value:s})}throw TypeError("Invalid input")}where(e,t,o){return this.addWhere("where",e,t,o)}orWhere(e,t,o){return this.addWhere("orWhere",e,t,o)}whereIn(e,t){return this.add({function:"whereIn",field:e,value:t})}orWhereIn(e,t){return this.add({function:"orWhereIn",field:e,value:t})}whereNull(e){return this.add({function:"whereNull",field:e})}orWhereNull(e){return this.add({function:"orWhereNull",field:e})}whereNotNull(e){return this.add({function:"whereNotNull",field:e})}orWhereNotNull(e){return this.add({function:"orWhereNotNull",field:e})}whereMetadata(e,t,o){return o===void 0?this.add({function:"whereMetadata",field:e,operator:"=",value:t}):this.add({function:"whereMetadata",field:e,operator:t,value:o})}orWhereMetadata(e,t,o){return o===void 0?this.add({function:"orWhereMetadata",field:e,operator:"=",value:t}):this.add({function:"orWhereMetadata",field:e,operator:t,value:o})}whereMetadataIn(e,t){return this.add({function:"whereMetadataIn",field:e,value:t})}orWhereMetadataIn(e,t){return this.add({function:"orWhereMetadataIn",field:e,value:t})}whereMetadataNull(e){return this.add({function:"whereMetadataNull",field:e})}orWhereMetadataNull(e){return this.add({function:"orWhereMetadataNull",field:e})}whereMetadataNotNull(e){return this.add({function:"whereMetadataNotNull",field:e})}orWhereMetadataNotNull(e){return this.add({function:"orWhereMetadataNotNull",field:e})}toJSON(){return{filter:JSON.parse(JSON.stringify(this.filter))}}};function ri(r){return r.map(e=>{if(typeof e=="string"){if(e.includes(" "))throw new TypeError("invalid order option: "+e);return{field:e,direction:"asc"}}return{field:e.column,direction:e.order,nulls:e.nulls}})}var It=class extends ni{constructor({start:t,modifiers:o,optionsModifiers:n}){super(o);v(this,"execFn");v(this,"optionsObject",{});v(this,"optionsModifiers");this.execFn=t,this.optionsModifiers=n}start(){return this.execFn(this.toJSON())}toJSON(){return b(d({},super.toJSON()),{options:d({},this.optionsObject)})}options(t){if(this.optionsModifiers===void 0)return this.optionsObject=d(d({},this.optionsObject),t),this;this.optionsObject=d({},this.optionsObject);for(let[o,n]of Object.entries(t))this.optionsObject[o]=this.optionsModifiers(o,n);return this}then(t,o){return this.start().then(t,o)}catch(t){return this.start().catch(t)}stream(){return this.start().stream()}},ee=class extends It{constructor({start:e,modifiers:t,optionsModifiers:o}){super({start:n=>e(n),modifiers:t,optionsModifiers:o})}limit(e){return this.optionsObject.limit=e,this}offset(e){return this.optionsObject.offset=e,this}orderBy(e,t,o){if(!Array.isArray(e)&&typeof e!="string")throw new TypeError("invalid input");if(Array.isArray(e))return this.optionsObject.order=ri(e),this;if(!e.includes(" "))return this.optionsObject.order=ri([{column:e,order:t||"asc",nulls:o}]),this;let[n,s,p,u]=e.split(" ");if(s!=="asc"&&s!=="desc")throw new TypeError("invalid order");let l={column:n,order:s};if(p==="nulls"){if(!["first","last"].includes(u))throw new TypeError("invalid nulls order");l.nulls=u}return this.optionsObject.order=ri([e]),this}select(...e){return this.optionsObject.select=e,this}deselect(...e){return this.optionsObject.deselect=e,this}};function Xt(r,e){if(!e)return{function:r,alias:r};if(!e.includes(" "))return{function:r,field:e,alias:r};if(!e.includes(" as "))throw new Q("UNCLEAR_AGGREGATOR",{input:e});let[t,o]=e.split(" as ");return{function:r,field:t,alias:o||t}}var Tn=class extends It{constructor({start:t,modifiers:o,optionsModifiers:n}){super({start:s=>t(s),modifiers:o,optionsModifiers:n});v(this,"aggregatorObject",{aggregators:[]});v(this,"timezoneString","")}toJSON(){return b(d({},super.toJSON()),{aggregators:JSON.parse(JSON.stringify(this.aggregatorObject.aggregators)),groups:JSON.parse(JSON.stringify(this.aggregatorObject.groups||[]))})}timezone(t){return this.timezoneString=t,this.aggregatorObject.groups&&Array.isArray(this.aggregatorObject.groups)&&this.aggregatorObject.groups.forEach(o=>{o.type==="period"&&(o.field={period:o.field,timezone:t})}),this}groupBy(t,...o){let n={};if(typeof t!="string")throw new TypeError("expected string as input, got"+typeof t);let[s,p]=t.split(" as ");if(Zp.hasOwnProperty(s))n.type="period",n.alias=p||s,this.timezoneString?n.field={period:s,timezone:this.timezoneString}:n.field=s;else if(s.startsWith("metadata.")){let[,u]=s.split(".");n.type="metadata_field",n.field=u,n.alias=p||u}else n.type="field",n.field=s,n.alias=p||s;return this.aggregatorObject.groups?this.aggregatorObject.groups.push(n):this.aggregatorObject.groups=[n],o.length&&o.forEach(u=>this.groupBy(u)),this}count(t){return this.aggregatorObject.aggregators.push(Xt("count",t)),this}distinct(t){return this.aggregatorObject.aggregators.push(Xt("countDistinct",t)),this}avg(t){return this.aggregatorObject.aggregators.push(Xt("average",t)),this}min(t){return this.aggregatorObject.aggregators.push(Xt("min",t)),this}max(t){return this.aggregatorObject.aggregators.push(Xt("max",t)),this}sum(t){return this.aggregatorObject.aggregators.push(Xt("sum",t)),this}},kt=class extends It{constructor({start:t,modifiers:o,optionsModifiers:n}){super({start:s=>t(s),modifiers:o,optionsModifiers:n});v(this,"updateObject",{})}toJSON(){return b(d({},super.toJSON()),{update:JSON.parse(JSON.stringify(this.updateObject))})}update(t){return this.updateObject=Object.assign(this.updateObject,t),this}},hn=class extends It{constructor({start:t,modifiers:o,optionsModifiers:n}){super({start:s=>t(s),modifiers:o,optionsModifiers:n});v(this,"reverseModifications",{})}toJSON(){return b(d({},super.toJSON()),{reverse:JSON.parse(JSON.stringify(this.reverseModifications))})}reverse(t){return this.reverseModifications=Object.assign(this.reverseModifications,t),this}};var de=a.object({order_by:a.string().describe("Ordering options in string format")}).describe("extra find options for client functions"),xI=ae.merge(Lp).merge(de).describe("extended find options for client functions"),m=a.union([a.string(),a.number().int()]),ai=a.union([a.string(),a.number()]);var Pf=os.describe("Optional flags for input"),er=a.object({wallet:m.describe("Foreign of the wallet connected to transfers"),token:m.describe("Foreign of the token transferred"),from_wallet:m.describe("Foreign of the wallet transfers are made from"),to_wallet:m.describe("Foreign of the wallet transfers are made to"),transfer_group:m.describe("Foreign of the transfer_group the transfers are a part of"),status:L.describe("Status of the transfers"),metadata:z.describe("Metadata filter"),aggregators:ss.array().describe("Array of aggregators to apply"),groups:is.array().describe("Specifications on grouping the data"),options:Pf}).partial().strict().describe("Input for aggregateTransfers"),vu=Yn.describe("Output of aggregateTransfers");var Uf=i(er);function oi(r,e,t){var _;let{client:o}=r;if(e===void 0)return new Tn({start(P){return o.api.aggregateTransferMany({transfer:P.filter,options:P.options,groups:P.groups,aggregators:P.aggregators})},modifiers(P,q){return["token","wallet","from_wallet","to_wallet"].includes(P)?F(q):P==="transfer_group"?A(q):q}});let n=Uf.validateInputWOptions(e,t),{token:s,wallet:p,from_wallet:u,to_wallet:l,transfer_group:c,status:f,metadata:g}=n,k={token:F(s),wallet:F(p),from_wallet:F(u),to_wallet:F(l),transfer_group:A(c),status:f,metadata:g};return o.api.aggregateTransferMany({transfer:k,groups:n.groups,aggregators:(_=n.aggregators)!=null?_:["sum"]})}var jf=ls.describe("Optional flags for input"),Vf=a.enum([...ps.options,"aggregateTransfers","exportBalanceHistory","exportTokens","exportTransferGroups","exportTransfers","exportWallets","findBalances","findTokens","findTransferGroups","findTransfers","findWallets","listExports"]),Lf=us.extend({scopes:Vf.array()}),tr=a.object({token:a.union([Lf,ds]),options:jf}).partial().strict().describe("Input for createAccessToken"),wu=ta.describe("Output of createAccessToken");var Zf=new Map(Object.entries({aggregateTransfers:"aggregateTransferMany",exportTokens:"exportTokenMany",exportTransferGroups:"exportTransferGroupMany",exportTransfers:"exportTransferMany",exportWallets:"exportWalletMany",findBalances:"findBalanceMany",findTokens:"findTokenMany",findTransferGroups:"findTransferGroupMany",findTransfers:"findTransferMany",findWallets:"findWalletMany",listExports:"listExportMany"})),zf=i(tr);function si(r,e,t){var s;let{client:o}=r,n=zf.validateInputWOptions(e,t);return n.token&&"scopes"in n.token&&(n.token.scopes=Array.from(new Set((s=n.token)==null?void 0:s.scopes.map(p=>{var u;return(u=Zf.get(p))!=null?u:p})))),o.api.createAccessToken({token:n.token,options:t})}var Hf=hs.describe("Optional flags for input"),qf=a.object({wallet:m.describe("Foreign of the wallet buying this contract"),token:m.describe("Foreign of the token buyer will buy with, defaults to Contract value token"),amount:a.number().describe("Amount the buyer will pay, defaults to contract value amount"),metadata:T.shape.metadata,latest_control_hash:T.shape.control_hash.nullable().optional().describe("Latest control_hash on the buyer wallet")}).partial().required({wallet:!0}).describe("The properties of the contract from buyer side"),Qf=a.object({foreign:ai.describe("Unique foreign of the created Contract"),metadata:V.shape.metadata,value_token:m.describe("Foreign of the token this contract is valued in"),value_amount:a.number().positive().describe("Amount of value this Contract has"),owner:ai.describe("Foreign of the wallet this contract should initially belong to"),buyer:qf}).partial().required({foreign:!0,value_amount:!0,value_token:!0}).describe("Contract description"),rr=Qf.extend({options:Hf.optional()}).strict().describe("Input for createContract"),Eu=ia.describe("Output of createContract");var $f=i(rr);function ii(r,e,t){var p;let{client:o}=r,n=$f.validateInputWOptions(e,t),s={token:{foreign:n.foreign+"",metadata:n.metadata,owner:F((p=n.owner)!=null?p:"house"),deposits:[{token:F(n.value_token),amount:n.value_amount}]}};return n.buyer&&(n.buyer.latest_control_hash&&console.warn("deprecated: latest_control_hash is deprecated and will be ignored"),s.exchange={from_wallet:F(n.buyer.wallet),amount:n.buyer.amount||n.value_amount,from_token:F(n.buyer.token||n.value_token),metadata:n.buyer.metadata}),o.api.createContract(s)}var Jf=x.extend({return_balance:a.boolean().describe("return balance after deposit"),create_wallet_if_not_exists:a.boolean().describe("If true then the wallet will be created if not found. Only valid with 'foreign'")}).partial().describe("Optional flags for input"),Kf=a.object({identifier:T.shape.identifier,token:m.describe("Id of the token to deposit as"),wallet:m.describe("Id of the wallet to deposit to"),amount:a.number().positive().describe("amount to deposit"),metadata:T.shape.metadata,status:X,transfer_group:m.describe("Id of the transfer_group this deposit is linked to"),created_at:T.shape.created_at}).partial().required({wallet:!0,amount:!0}),nr=Kf.extend({options:Jf.optional()}).strict().describe("Input for createDeposit"),Mu=ua.describe("Output of createDeposit");var Yf=i(nr);function pi(r,e,t){let{client:o}=r,n=Me(e,"token",o.getConfig("token")),s=Yf.validateInputWOptions(n,t),p=s.token||o.getConfig("token");if(p===void 0)throw new Q("INPUT_NEEDS_TOKEN",{input:e});let k=s,{wallet:u,metadata:l,options:c}=k,f=ne(k,["wallet","metadata","options"]),g=d(b(d({},f),{transfer_group:A(s.transfer_group),token:F(p),to_wallet:F(u),type:"deposit"}),l?{metadata:l}:{});return g.identifier||(g.identifier=ie(g)),o.api.createTransfer({transfer:g,options:vn(c,{return_balance:"return_to_balance",create_wallet_if_not_exists:"create_to_wallet_if_not_exists"})})}var Xf=x.partial().describe("Optional flags for input"),em=a.object({identifier:B.shape.identifier,from_identifier:T.shape.identifier,from_wallet:m.describe("Foreign of Wallet where from_token is debited from/to_token is credited to"),from_token:m.describe("Foreign of Token that is transferred from->to"),from_amount:T.shape.amount.describe("Amount of from_token transferred"),to_identifier:T.shape.identifier,to_wallet:m.describe("Foreign of Wallet where from_token is credited to/to_token is debited from. If not specified then to_token.belongs_to is used"),to_token:m.describe("Foreign of Token that is transferred to->from"),to_amount:T.shape.amount.describe("Amount of to_token transferred. If not specified then from_amount is used"),status:X.describe("The state at which the exchange is created"),force:T.shape.force,metadata:T.shape.metadata}).partial().required({from_wallet:!0,from_token:!0,from_amount:!0,to_token:!0,to_wallet:!0}),ar=em.extend({options:Xf.optional()}).strict().describe("Input for createExchange"),Ru=et.describe("Output of createExchange");var tm=i(ar);function ui(r,e,t){var l,c,f,g,k;let{client:o}=r,u=tm.validateInputWOptions(e,t),{options:s}=u,p=ne(u,["options"]);return(l=p.identifier)!=null||(p.identifier=ie(p)),o.api.createTransferGroup({transfer_group:{identifier:p.identifier,status:Ln.closed,transfer_status:(c=p.status)!=null?c:"pending",metadata:p.metadata,children:[{identifier:(f=p.from_identifier)!=null?f:ie(),from_wallet:F(p.from_wallet),to_wallet:F(p.to_wallet),token:F(p.from_token),type:p.from_wallet?bt.transfer:bt.deposit,amount:p.from_amount,metadata:p.metadata,force:p.force},{identifier:(g=p.to_identifier)!=null?g:ie(),from_wallet:F(p.to_wallet),to_wallet:F(p.from_wallet),token:F(p.to_token),type:p.to_wallet?bt.transfer:bt.deposit,amount:(k=p.to_amount)!=null?k:p.from_amount,metadata:p.metadata,force:p.force}]},options:s})}var rm=Fs.describe("Optional flags for input"),di=V.pick({foreign:!0,public:!0,metadata:!0,divisor:!0,limit:!0}).extend({belongs_to:m.describe("Id of the wallet this token belongs_to")}).partial().required({foreign:!0}),or=di.extend({options:rm.optional()}).strict().describe("Input for createToken"),Gu=ca.describe("Output of createToken");var nm=i(or);function li(r,e,t){let{client:o}=r,c=nm.validateInputWOptions(e,t),{options:s,belongs_to:p,metadata:u}=c,l=ne(c,["options","belongs_to","metadata"]);return o.api.createToken({token:d(b(d({},l),{belongs_to:F(p)}),u?{metadata:u}:{}),options:s})}var am=Ze.describe("Optional flags for input"),ci=a.object({identifier:T.shape.identifier,token:m.describe("Id of the token to transfer as"),from_wallet:m.describe("Foreign of the wallet to withdraw from"),to_wallet:m.describe("Foreign of the wallet to deposit to"),latest_control_hash:T.shape.control_hash,amount:a.number().positive().describe("amount to withdraw"),metadata:T.shape.metadata,status:X.describe("status of the transfer"),transfer_group:m.describe("Id of the transfer_group this transfer is linked to"),created_at:T.shape.created_at,type:a.literal("transfer")}),gn=ci.extend({type:a.literal("transfer")}).partial().required({from_wallet:!0,to_wallet:!0,amount:!0}),Fn=ci.omit({from_wallet:!0,to_wallet:!0}).extend({wallet:m.describe("Foreign of the wallet to withdraw from"),type:a.literal("withdrawal")}).partial().required({wallet:!0,amount:!0,type:!0}),xn=ci.omit({from_wallet:!0,to_wallet:!0}).extend({wallet:m.describe("Foreign of the wallet to deposit to"),type:a.literal("deposit")}).partial().required({wallet:!0,amount:!0,type:!0}),fi=a.union([gn,xn,Fn]),sr=fi.and(a.object({options:am.optional()})).describe("Input for createTransfer"),Wu=Xe.describe("Output of createTransfer");var om=i(sr);function mi(r,e,t){let{client:o}=r,n=Me(e,"token",o.getConfig("token")),s=om.validateInputWOptions(n,t),p=On(s,o.getConfig("token"));return p.identifier||(p.identifier=ie(p)),o.api.createTransfer({transfer:p,options:s.options})}function On(r,e){r.type=r.type||"transfer";let t={identifier:r.identifier,token:F(r.token||e),amount:r.amount,metadata:r.metadata,status:r.status,type:r.type,transfer_group:A(r.transfer_group),created_at:r.created_at};if(r.type==="transfer")return r.latest_control_hash&&console.warn("deprecated: latest_control_hash is deprecated"),b(d({},t),{from_wallet:F(r.from_wallet),to_wallet:F(r.to_wallet)});if(r.type==="withdrawal")return r.latest_control_hash&&console.warn("deprecated: latest_control_hash is deprecated"),b(d({},t),{from_wallet:F(r.wallet)});if(r.type==="deposit")return b(d({},t),{to_wallet:F(r.wallet)});throw new Error("Should not be here")}var sm=Ts.describe("Optional flags for input"),im=gn.omit({transfer_group:!0}),pm=xn.omit({transfer_group:!0}),um=Fn.omit({transfer_group:!0}),dm=a.union([pm,im,um]),Ti=B.pick({identifier:!0,status:!0,transfer_status:!0,metadata:!0}).extend({children:dm.array()}).partial(),ir=Ti.extend({options:sm.optional()}).describe("Input for createTransferGroup"),Cu=et.describe("Output of createTransferGroup");var lm=i(ir);function hi(r,e,t){let{client:o}=r,u=lm.validateInputWOptions(e,t),{options:s}=u,p=ne(u,["options"]);return p.children&&(p.children=p.children.map(l=>On(l,o.getConfig("token")))),p.identifier||(p.identifier=ie(p)),o.api.createTransferGroup({transfer_group:p,options:s})}var cm=xs.describe("Optional flags for input"),pr=a.object({transfers:fi.array().min(1).describe("Array of transfer objects to create"),options:cm.optional()}).describe("Input for createTransfers"),Au=ma.describe("Output of createTransfers");var fm=i(pr);function gi(r,e,t){let{client:o}=r,n=fm.validateInputWOptions(e,t),s=n.transfers.map(p=>On(p,o.getConfig("token")));for(let p of s)p.identifier||(p.identifier=ie(p));return o.api.createTransferMany({transfers:s,options:n.options})}var mm=bs.describe("Optional flags for input"),Fi=j.pick({foreign:!0,name:!0,metadata:!0,status:!0}).partial().required({foreign:!0}),ur=Fi.extend({options:mm.optional()}).strict().describe("Input for createWallet"),Nu=ha.describe("Output of createWallet");var Tm=i(ur);function xi(r,e,t){let{client:o}=r,l=Tm.validateInputWOptions(e,t),{options:s,metadata:p}=l,u=ne(l,["options","metadata"]);return o.api.createWallet({wallet:d(d({},u),p?{metadata:p}:{}),options:s})}var hm=x.extend({return_balance:a.boolean().describe("Return balance after withdrawal")}).partial().describe("Optional flags for input"),gm=a.object({identifier:T.shape.identifier,token:m.describe("Id of the token to withdrawal as"),wallet:m.describe("Id of the wallet to withdraw from"),latest_control_hash:T.shape.control_hash,amount:a.number().positive().describe("amount to withdraw"),metadata:T.shape.metadata,status:X.describe("status of the withdrawal"),transfer_group:m.describe("Id of the transfer_group this withdrawal is linked to"),created_at:T.shape.created_at}).partial().required({wallet:!0,amount:!0}),dr=gm.extend({options:hm.optional()}).strict().describe("Input for createWithdrawal"),Du=Fa.describe("Output of createWithdrawal");var Fm=i(dr);function Oi(r,e,t){let{client:o}=r,n=Me(e,"token",o.getConfig("token")),s=Fm.validateInputWOptions(n,t),_=s,{wallet:p,metadata:u,options:l,latest_control_hash:c}=_,f=ne(_,["wallet","metadata","options","latest_control_hash"]);c&&console.warn("deprecated: latest_control_hash is deprecated");let g=s.token||o.getConfig("token");if(g===void 0)throw new Q("INPUT_NEEDS_TOKEN",{input:e});let k=d(b(d({},f),{transfer_group:A(s.transfer_group),token:F(g),from_wallet:F(p),type:"withdrawal"}),u?{metadata:u}:{});return k.identifier||(k.identifier=ie(k)),o.api.createTransfer({transfer:k,options:vn(l,{return_balance:"return_from_balance"})})}var xm=vs.partial().describe("Optional flags for input"),Om=a.object({token:m.describe("Id of the token to withdrawal as"),wallet:m.describe("Id of the wallet to withdraw from")}).partial().required({wallet:!0}),lr=Om.extend({options:xm.optional()}).strict().describe("Input for exportBalanceHistory"),Bu=ya.describe("Output of exportBalanceHistory");var bm=i(lr);function bi(r,e,t){let{client:o}=r,n=bm.validateInputWOptions(e,t),s=n.token||o.getConfig("token");if(s===void 0)throw new Q("INPUT_NEEDS_TOKEN",{input:e});return o.api.exportBalanceHistory({balance:{wallet:F(n.wallet),token:F(s)},options:t})}var Sm=ws.merge(de).partial().describe("Optional flags for input"),ym=a.object({foreign:m.describe("Foreign of the token"),type:Ne,belongs_to:m.describe("Foreign of the wallet connected to token"),metadata:z}).partial(),cr=ym.extend({options:Sm.optional()}).strict().describe("Input for exportTokens"),Pu=ka.describe("Output of exportTokens");var _m=i(cr);function Si(r,e,t){var l,c;let{client:o}=r;if(e===void 0)return new ee({start(f){return o.api.exportTokenMany({token:f.filter,options:f.options})},modifiers(f,g){return["belongs_to"].includes(f)?F(g):g}});let n=_m.validateInputWOptions(e,t),s={foreign:n.foreign?n.foreign+"":void 0,type:n.type,metadata:n.metadata};n.belongs_to&&(s.belongs_to=F(n.belongs_to));let p=(l=n.options)==null?void 0:l.order_by;(c=n.options)==null||delete c.order_by;let u=d({},n.options);return!u.order&&p&&(u.order=te(p)),o.api.exportTokenMany({token:s,options:u})}var yi=un.merge(de).partial().describe("Optional flags for input"),_i=a.object({identifier:m.describe("Identifier of the transfer_group"),transfer_status:B.shape.transfer_status.describe("Status of the transfers"),status:B.shape.status.describe("Status of the transfer_group"),reverses:m.describe("Identifier of the transfer_group the transfer_group reverses"),type:Ke.describe("Type of the transfer group"),metadata:z}).partial(),fr=_i.extend({options:yi.optional()}).strict().describe("Input for findTransferGroups"),Uu=va.describe("Output of findTransferGroups");var Im=yi.partial().describe("Optional flags for input"),km=_i.partial(),mr=km.extend({options:Im.optional()}).strict().describe("Input for exportTransferGroups"),ju=Ea.describe("Output of exportTransferGroups");var vm=i(mr);function Ii(r,e,t){var _,P;let{client:o}=r;if(e===void 0)return new ee({start(q){return o.api.exportTransferGroupMany({transfer_group:q.filter,options:q.options})},modifiers(q,U){return["transfer_group","reverses"].includes(q)?A(U):U}});let n=vm.validateInputWOptions(e,t),{identifier:s,transfer_status:p,status:u,metadata:l,type:c}=n,f={identifier:s,transfer_status:p,status:u,metadata:l,type:c};n.reverses&&(f.reverses=A(n.reverses));let g=(_=n.options)==null?void 0:_.order_by;(P=n.options)==null||delete P.order_by;let k=d({},n.options);return!k.order&&g&&(k.order=te(g)),o.api.exportTransferGroupMany({transfer_group:f,options:k})}var wm=a.object({return_running_balance:a.boolean().describe("return running balance for specified wallet under filter"),return_signed_amount:a.boolean().describe("return running balance for specified wallet under filter"),return_running_balance_for_wallet:m.describe("foreign key for which wallet should running balance be returned for"),return_signed_amount_for_wallet:m.describe("foreign key for which wallet should signed amounts be returned for")}),Em=as.keyof().options.reduce((r,e)=>b(d({},r),{[e]:!0}),{}),ki=an.omit(Em).merge(wm).merge(de).partial().describe("Optional flags for input"),vi=a.object({wallet:m.describe("Foreign of the wallet connected to transfers"),token:m.describe("Foreign of the token transferred"),from_wallet:m.describe("Foreign of the wallet transfers are made from"),to_wallet:m.describe("Foreign of the wallet transfers are made to"),transfer_group:m.describe("Foreign of the transfer_group the transfers are a part of"),status:L.describe("Status of the transfers"),metadata:z}).partial(),Tr=vi.extend({options:ki.optional()}).strict().describe("Input for findTransfers"),Vu=Jn.describe("Output of findTransfers");var Mm=ki.partial().describe("Optional flags for input"),Rm=vi,hr=Rm.extend({options:Mm.optional()}).strict().describe("Input for exportTransfers"),Lu=Ra.describe("Output of exportTransfers");var Gm=i(hr);function wi(r,e,t){var k;let{client:o}=r;if(e===void 0)return new ee({start(_){return o.api.exportTransferMany({transfer:_.filter,options:_.options})},modifiers(_,P){return["token","wallet","from_wallet","to_wallet"].includes(_)?F(P):_==="transfer_group"?A(P):P}});let n=Gm.validateInputWOptions(e,t),{token:s,wallet:p,from_wallet:u,to_wallet:l}=n,c={token:F(s),wallet:F(p),from_wallet:F(u),to_wallet:F(l)};n.transfer_group&&(c.transfer_group=A(n.transfer_group)),n.status&&(c.status=n.status),n.metadata&&(c.metadata=n.metadata),(k=n.options)!=null||(n.options={});let f=n.options.order_by;delete n.options.order_by;let g=d({},n.options);return!g.order&&f&&(g.order=te(f)),o.api.exportTransferMany({transfer:c,options:g})}var Wm=a.object({include_balance_for_token:m.describe("Foreign of token to include balance for")}),Ei=ln.merge(de).merge(Wm).partial().describe("Optional flags for input"),Mi=j.pick({foreign:!0,name:!0,type:!0,status:!0}).extend({metadata:z}).partial(),gr=Mi.extend({options:Ei.optional()}).strict().describe("Input for findWallets"),Zu=Ga.describe("Output of findWallets");var Gw=a.object({include_balance_for_token:m.describe("Foreign of token to include balance for")}),Cm=Ei.partial().describe("Optional flags for input"),Am=Mi.partial(),Fr=Am.extend({options:Cm.optional()}).strict().describe("Input for exportWallets"),zu=Ca.describe("Output of exportWallets");var Nm=i(Fr);function Ri(r,e,t){let{client:o}=r;if(e===void 0)return new ee({start(g){return o.api.exportWalletMany({wallet:g.filter,options:g.options})},optionsModifiers(g,k){return g==="include_balance_for_token"&&typeof k!="object"?F(k):k}});let c=Nm.validateInputWOptions(e,t),{options:s}=c,p=ne(c,["options"]),f=s!=null?s:{},{order_by:u}=f,l=ne(f,["order_by"]);return!l.order&&u&&(l.order=te(u)),o.api.exportWalletMany({wallet:p,options:l})}var Dm=Ms.merge(de).partial().describe("Optional flags for input"),Bm=a.object({token:m.describe("Id of the token to withdrawal as"),wallet:m.describe("Id of the wallet to withdraw from")}).partial(),xr=Bm.extend({options:Dm.optional()}).strict().describe("Input for findBalances"),Hu=Na.describe("Output of findBalances");var Pm=i(xr);function Gi(r,e,t){var l,c;let{client:o}=r;if(e===void 0)return new ee({start(f){return o.api.findBalanceMany({balance:f.filter,options:f.options})},modifiers(f,g){return["wallet","token"].includes(f)?F(g):g}});let n=Pm.validateInputWOptions(e,t),s={};n.wallet&&(s.wallet=F(n.wallet)),n.token&&(s.token=F(n.token));let p=(l=n.options)==null?void 0:l.order_by;(c=n.options)==null||delete c.order_by;let u=d({},n.options);return!u.order&&p&&(u.order=te(p)),o.api.findBalanceMany({balance:s,options:u})}var Um=pn.merge(de).partial().describe("Optional flags for input"),jm=a.object({foreign:m.describe("Foreign of the token"),type:Ne,belongs_to:m.describe("Foreign of the wallet connected to token"),metadata:z}).partial(),Or=jm.extend({options:Um.optional()}).strict().describe("Input for findTokens"),qu=_a.describe("Output of findTokens");var Vm=i(Or);function Wi(r,e,t){var l,c;let{client:o}=r;if(e===void 0)return new ee({start(f){return o.api.findTokenMany({token:f.filter,options:f.options})},modifiers(f,g){return["belongs_to"].includes(f)?F(g):g}});let n=Vm.validateInputWOptions(e,t),s={foreign:n.foreign?n.foreign+"":void 0,type:n.type,metadata:n.metadata};n.belongs_to&&(s.belongs_to=F(n.belongs_to));let p=(l=n.options)==null?void 0:l.order_by;(c=n.options)==null||delete c.order_by;let u=d({},n.options);return!u.order&&p&&(u.order=te(p)),o.api.findTokenMany({token:s,options:u})}var Lm=i(fr);function Ci(r,e,t){var _,P;let{client:o}=r;if(e===void 0)return new ee({start(q){return o.api.findTransferGroupMany({transfer_group:q.filter,options:q.options})},modifiers(q,U){return["transfer_group","reverses"].includes(q)?A(U):U}});let n=Lm.validateInputWOptions(e,t),{identifier:s,transfer_status:p,status:u,metadata:l,type:c}=n,f={identifier:s,transfer_status:p,status:u,metadata:l,type:c};n.reverses&&(f.reverses=A(n.reverses));let g=(_=n.options)==null?void 0:_.order_by;(P=n.options)==null||delete P.order_by;let k=d({},n.options);return!k.order&&g&&(k.order=te(g)),o.api.findTransferGroupMany({transfer_group:f,options:k})}var Zm=i(Tr);function Ai(r,e,t){var P;let{client:o}=r;if(e===void 0)return new ee({start(q){return o.api.findTransferMany({transfer:q.filter,options:q.options})},modifiers(q,U){return["token","wallet","from_wallet","to_wallet"].includes(q)?F(U):q==="transfer_group"?A(U):U}});let n=Zm.validateInputWOptions(e,t),{token:s,wallet:p,from_wallet:u,to_wallet:l}=n,c={token:F(s),wallet:F(p),from_wallet:F(u),to_wallet:F(l)};n.transfer_group&&(c.transfer_group=A(n.transfer_group)),n.status&&(c.status=n.status),n.metadata&&(c.metadata=n.metadata),(P=n.options)!=null||(n.options={});let f=n.options.order_by;if(delete n.options.order_by,n.options.return_running_balance){if(n.options.return_running_balance_for_wallet)throw new Q("CONFLICTING_OPTIONS_FOR_BALANCE",{options:n.options});if(!c.wallet)throw new Q("RUNNING_BALANCE_WITHOUT_WALLET",{input:n});n.options.return_running_balance_for_wallet=n.wallet}let g=n.options.return_running_balance_for_wallet;if(delete n.options.return_running_balance_for_wallet,n.options.return_signed_amount){if(n.options.return_signed_amount_for_wallet)throw new Q("CONFLICTING_OPTIONS_FOR_SIGNED_AMOUNT",{options:n.options});if(!c.wallet)throw new Q("SIGNED_AMOUNT_WITHOUT_WALLET",{input:n});n.options.return_signed_amount_for_wallet=n.wallet}let k=n.options.return_signed_amount_for_wallet;delete n.options.return_signed_amount_for_wallet;let _=d({},n.options);return!_.order&&f&&(_.order=te(f)),g&&(_.return_running_balance_for_wallet=F(g)),k&&(_.return_signed_amount_for_wallet=F(k)),o.api.findTransferMany({transfer:c,options:_})}var zm=i(gr);function Ni(r,e,t){let{client:o}=r;if(e===void 0)return new ee({start(g){return o.api.findWalletMany({wallet:g.filter,options:g.options})},optionsModifiers(g,k){return g==="include_balance_for_token"&&typeof k!="object"?F(k):k}});let c=zm.validateInputWOptions(e,t),{options:s}=c,p=ne(c,["options"]),f=s!=null?s:{},{order_by:u}=f,l=ne(f,["order_by"]);return!l.order&&u&&(l.order=te(u)),o.api.findWalletMany({wallet:p,options:l})}var Hm=cs.describe("Optional flags for input"),qm=a.object({token:m.describe("Id of the token to get balance in"),wallet:m.describe("Id of the wallet to get balance for"),datetime:E.describe("Date and time this balance should be got")}).partial().required({wallet:!0}),br=qm.extend({options:Hm.optional()}).strict().describe("Input for getBalance"),Qu=De.describe("Output of getBalance");var Qm=i(br);function Di(r,e,t){let{client:o}=r,n=Me(e,"token",o.getConfig("token")),s=Qm.validateInputWOptions(n,t);if(s.datetime&&bp(s.datetime))throw new Q("BAL_FUTURE_DATETIME",{input:s});let p=s.token||o.getConfig("token");if(p===void 0)throw new Q("INPUT_NEEDS_TOKEN",{input:s});return o.api.getBalance({balance:{wallet:F(s.wallet),token:F(p),datetime:s.datetime},options:s.options})}var $m=ks.describe("Optional flags for input"),Jm=a.object({token:m.describe("Id of the token to get balance in"),wallet:m.describe("Id of the wallet to get balance for"),datetime:E.describe("Select entries older than")}).partial().required({wallet:!0}),Sr=Jm.extend({options:$m.optional()}).strict().describe("Input for getBalanceHistory"),$u=ba.describe("Output of getBalanceHistory");var Km=i(Sr);function Bi(r,e,t){let{client:o}=r,n=Km.validateInputWOptions(e,t),s=n.token||o.getConfig("token");if(s===void 0)throw new Q("INPUT_NEEDS_TOKEN",{input:e});return o.api.getBalanceHistory({balance:{wallet:F(n.wallet),token:F(s),datetime:n.datetime},options:n.options})}var Ym=ys.describe("Optional flags for input"),Xm=a.object({identifier:a.string().describe("File name of the export to get")}),yr=Xm.extend({options:Ym.optional()}).strict().describe("Input for getExport"),Ju=he.describe("Output of getExport");var eT=i(yr);function Pi(r,e,t){let{client:o}=r,n=eT.validateInputWOptions(e,t);return o.api.getExport({export:{identifier:n.identifier},options:n.options})}var tT=Rs.describe("Optional flags for input"),_r=a.object({options:tT.optional()}).strict().describe("Input for getFlags"),Ku=Pa.describe("Output of getFlags");var rT=i(_r);function Ui(r,e,t){let{client:o}=r,n=rT.validateInputWOptions(e,t);return o.api.getFlags({options:n.options})}var nT=Gs.describe("Optional flags for input"),Ir=Qt.extend({options:nT.optional()}).strict().describe("Input for getStatistics"),Yu=Ua.describe("Output of getStatistics");var aT=i(Ir);function ji(r,e,t){let{client:o}=r,n=aT.validateInputWOptions(e,t);return o.api.getStatistics({model:n.model||"Transfer",aggregator:n.aggregator||"count",groups:n.groups,filter:n.filter,options:n.options})}var oT=rn.describe("Optional flags for input"),sT=a.object({foreign:m.describe("Foreign of the token")}).partial(),kr=sT.extend({options:oT.optional()}).strict().describe("Input for getToken"),Xu=qn.describe("Output of getToken");var iT=i(kr);function Vi(r,e={},t){let{client:o}=r,n=Me(e,"foreign",o.getConfig("token")),s=iT.validateInputWOptions(n,t),p=s.foreign||o.getConfig("token");if(p===void 0)throw new Q("INPUT_NEEDS_TOKEN",{input:e});return o.api.getToken({token:F(p),options:s.options})}var pT=es.describe("Optional flags for input"),uT=a.object({transfer:m.describe("Transfer identifier")}).partial().required({transfer:!0}),vr=uT.extend({options:pT.optional()}).strict().describe("Input for getTransfer"),ed=_e.describe("Output of getTransfer");var dT=i(vr);function Li(r,e,t){let{client:o}=r,n=dT.validateInputWOptions(e,t);return o.api.getTransfer({transfer:A(n.transfer),options:n.options})}var lT=ns.describe("Optional flags for input"),cT=a.object({transfer_group:m.describe("identifier of the transfer group to reverse")}).partial().required({transfer_group:!0}),wr=cT.extend({options:lT.optional()}).strict().describe("Input for getTransferGroup"),td=$n.describe("Output of getTransferGroup");var fT=i(wr);function Zi(r,e,t){let{client:o}=r,n=fT.validateInputWOptions(e,t);return o.api.getTransferGroup({transfer_group:A(n.transfer_group),options:n.options})}var mT=tn.describe("Optional flags for input"),TT=a.object({wallet:m.describe("Wallet foreign")}).partial().required({wallet:!0}),Er=TT.extend({options:mT.optional()}).strict().describe("Input for getWallet"),rd=Vn.describe("Output of getWallet");var hT=i(Er);function zi(r,e,t){let{client:o}=r,n=hT.validateInputWOptions(e,t);return o.api.getWallet({wallet:F(n.wallet),options:n.options})}var gT=Ws.describe("Optional flags for input"),Mr=a.object({options:gT.optional()}).strict().describe("Input for healthcheck"),nd=Za.describe("Output of healthcheck");var FT=i(Mr);function Hi(r,e,t){let{client:o}=r,n=FT.validateInputWOptions(e,t);return o.api.healthcheck({options:d(d({},n.options),t)})}function qi(){throw new Error("import-data available only in node client")}var xT=Bs.describe("Optional flags for input"),Qi=a.object({transfer:m.describe("Transfer identifier"),status:X.describe("Status of the created transfer"),identifier:T.shape.identifier.describe("Identifier for the created transfer"),force:T.shape.force.describe("Force create the reverse transfer ignoring balance"),metadata:T.shape.metadata.describe("Metadata for the reversed transfers"),extend_metadata:T.shape.metadata.describe("Key value object to extend metadata with on created transfer")}).partial().required({transfer:!0}),Rr=Qi.extend({options:xT.optional()}).strict().describe("Input for reverseTransfer"),ad=Ya.describe("Output of reverseTransfer");var OT=cn.describe("Optional flags for input"),$i=a.object({transfer_group:m.describe("identifier of the transfer group to reverse"),status:ye,transfer_status:X,identifier:B.shape.identifier,force:T.shape.force,metadata:B.shape.metadata,transfer_metadata:T.shape.metadata,extend_metadata:B.shape.metadata.describe("Key value object to extend metadata with on created transfer"),transfer_extend_metadata:T.shape.metadata.describe("Key value object to extend metadata with on created transfer")}).partial().required({transfer_group:!0}),Gr=$i.extend({options:OT.optional()}).strict().describe("Input for reverseTransferGroup"),od=eo.describe("Output of reverseTransferGroup");var bT=Cs.describe("Optional flags for input"),ST=a.object({target:a.literal("wallet").describe("Target of the action"),data:Fi}),yT=a.object({target:a.literal("token").describe("Target of the action"),data:di}),_T=a.object({target:a.literal("transfer_group").describe("Target of the action"),data:Ti.extend({created_at:E,status_finalized_at:E,transfer_status_finalized_at:E})}),IT=gn.extend({status_finalized_at:E.optional(),status:L.optional()}),kT=xn.extend({status_finalized_at:E.optional(),status:L.optional()}),vT=Fn.extend({status_finalized_at:E.optional(),status:L.optional()}),wT=a.union([IT,kT,vT]),ET=a.object({target:a.literal("transfer").describe("Target of the action"),data:wT}),MT=a.object({target:a.literal("reverse_transfer").describe("Target of the action"),data:Qi.extend({options:a.object({metadata_action:Ee})})}),RT=a.object({target:a.literal("reverse_transfer_group").describe("Target of the action"),data:$i.extend({options:a.object({metadata_action:Ee,transfer_metadata_action:Ee})})}),GT=a.union([ST,yT,_T,ET,MT,RT]),WT=a.object({actions:GT.array()}).partial().required({actions:!0}),Fo=WT.extend({options:bT.optional()}).strict().describe("Input for importData"),sd=za.describe("Output of importData");var CT=Ns.merge(de).partial().describe("Optional flags for input"),AT=a.object({type:Ss.describe("type of the export"),date:a.string().date().describe("Date of the export")}).partial(),Wr=AT.extend({options:CT.optional()}).strict().describe("Input for listExports"),id=qa.describe("Output of listExports");var NT=i(Wr);function Ji(r,e,t){let{client:o}=r,n=NT.validateInputWOptions(e,t),s=Op(n==null?void 0:n.date);return t=xp(t!=null?t:{}),o.api.listExportMany({export:d(d({},s?{date:s}:{}),n.type?{type:n.type}:{}),options:t})}var DT=i(Rr);function Ki(r,e,t){let{client:o}=r,n=DT.validateInputWOptions(e,t);return n.extend_metadata&&console.warn("deprecated: extend_metadata is deprecated. Use metadata_action instead"),o.api.reverseTransfer({transfer:A(n.transfer),reverse:{force:n.force,metadata:n.metadata,extend_metadata:n.extend_metadata,identifier:n.identifier,status:n.status},options:n.options})}var BT=i(Gr);function Yi(r,e,t){let{client:o}=r,n=BT.validateInputWOptions(e,t);return n.extend_metadata&&console.warn("deprecated: extend_metadata is deprecated. Use metadata_action instead"),o.api.reverseTransferGroup({transfer_group:A(n.transfer_group),reverse:{status:n.status,force:n.force,transfer_status:n.transfer_status,identifier:n.identifier,metadata:n.metadata,transfer_metadata:n.transfer_metadata,extend_metadata:n.extend_metadata,transfer_extend_metadata:n.transfer_extend_metadata},options:n.options})}var PT=js.describe("Optional flags for input"),UT=Us.describe("In case the transfer will be made then apply these modifications"),jT=a.object({wallet:m.describe("Foreign of the wallet connected to transfers"),token:m.describe("Foreign of the token transferred"),from_wallet:m.describe("Foreign of the wallet transfers are made from"),to_wallet:m.describe("Foreign of the wallet transfers are made to"),transfer_group:m.describe("Foreign of the transfer_group the transfers are a part of"),status:L.describe("Status of the transfers"),metadata:z,reverse:UT}).partial(),Cr=jT.extend({options:PT.optional()}).strict().describe("Input for reverseTransfers"),pd=no.describe("Output of reverseTransfers");var VT=i(Cr);function Xi(r,e,t){let{client:o}=r;if(e===void 0)return new hn({start(f){return o.api.reverseTransferMany({transfer:f.filter,reverse:f.reverse,options:f.options})},modifiers(f,g){return["token","wallet","from_wallet","to_wallet"].includes(f)?F(g):f==="transfer_group"?A(g):g}});let n=VT.validateInputWOptions(e,t),{token:s,wallet:p,from_wallet:u,to_wallet:l}=n,c={token:F(s),wallet:F(p),from_wallet:F(u),to_wallet:F(l)};return n.transfer_group&&(c.transfer_group=A(n.transfer_group)),n.status&&(c.status=n.status),n.metadata&&(c.metadata=n.metadata),o.api.reverseTransferMany({transfer:c,reverse:n.reverse,options:n.options})}var LT=Vs.describe("Optional flags for input"),Ar=Le.extend({options:LT.optional()}).strict().describe("Input for setFlags"),ud=oo.describe("Output of setFlags");var ZT=i(Ar);function ep(r,e,t){let{client:o}=r,n=ZT.validateInputWOptions(e,t),s=Le.keyof().options,p={};if(s.forEach(u=>{u in n&&(p[u]=n[u])}),Object.keys(p).length<1)throw new Q("REQUIRED_INPUT_MISSING",{requiredOneOf:s,input:e});return o.api.setFlags({flags:p,options:n.options})}var zT=Ls.describe("Optional flags for input"),HT=a.object({token:m.describe("Token foreign"),metadata:V.shape.metadata,public:V.shape.public,status:V.shape.status}).partial().required({token:!0}),Nr=HT.extend({options:zT.optional()}).strict().describe("Input for updateToken"),dd=po.describe("Output of updateToken");var qT=i(Nr);function tp(r,e,t){let{client:o}=r,n=qT.validateInputWOptions(e,t);return o.api.updateToken({token:F(n.token),update:{public:n.public,metadata:n.metadata,status:n.status},options:n.options})}var QT=Ds.describe("Optional flags for input"),bn=a.enum(["finished","cancelled"]).describe("Status the transfer should be set to"),$T=a.object({transfer:m.describe("Transfer identifier"),metadata:T.shape.metadata,extend_metadata:T.shape.metadata,status:bn}).partial().required({transfer:!0}),Dr=$T.extend({options:QT.optional()}).strict().describe("Input for updateTransfer"),ld=Kt.describe("Output of updateTransfer");var JT=i(Dr);function rp(r,e,t){let{client:o}=r,n=JT.validateInputWOptions(e,t);return o.api.updateTransfer({transfer:A(n.transfer),update:{status:n.status,metadata:n.metadata,extend_metadata:n.extend_metadata},options:n.options})}var KT=mn.describe("Optional flags for input"),YT=a.object({transfer_group:m.describe("TransferGroup identifier"),status:a.enum(["closed"]).describe("Lifecycle status of the TransferGroup"),transfer_status:bn.describe("Status all the transfers should be set at."),metadata:B.shape.metadata.describe("Key value object to be replaced or extended with existing TransferGroup metadata")}).partial().required({transfer_group:!0}),Br=YT.extend({options:KT.optional()}).strict().describe("Input for updateTransferGroup"),cd=lo.describe("Output of updateTransferGroup");var XT=i(Br);function np(r,e,t){let{client:o}=r,n=XT.validateInputWOptions(e,t);return o.api.updateTransferGroup({transfer_group:A(n.transfer_group),update:{transfer_status:n.transfer_status,status:n.status,metadata:n.metadata},options:n.options})}var eh=zs.describe("Optional flags for input");var th=a.object({transfer_status:bn.describe("Status of the transfers"),status:B.shape.status.describe("Status of the transfer_group"),reverses:m.describe("Identifier of the transfer_group the transfer_group reverses"),type:Ke.describe("Type of the transfer group"),metadata:z,update:fn}).partial(),Pr=th.extend({options:eh.optional()}).strict().describe("Input for updateTransferGroups"),fd=fo.describe("Output of updateTransferGroups");var rh=i(Pr);function ap(r,e,t){let{client:o}=r;if(e===void 0)return new kt({start(g){return o.api.updateTransferGroupMany({transfer_group:g.filter,update:g.update,options:g.options})},modifiers(g,k){return["transfer_group","reverses"].includes(g)?A(k):k}});let n=rh.validateInputWOptions(e,t),{transfer_status:s,status:p,metadata:u,type:l,update:c}=n,f={transfer_status:s,status:p,metadata:u,type:l};return n.reverses&&(f.reverses=A(n.reverses)),o.api.updateTransferGroupMany({transfer_group:f,update:c,options:n.options})}var nh=Hs.describe("Optional flags for input"),JG=a.enum(["finished","cancelled"]).describe("Status the transfer should be set to");var ah=a.object({wallet:m.describe("Foreign of the wallet connected to transfers"),token:m.describe("Foreign of the token transferred"),from_wallet:m.describe("Foreign of the wallet transfers are made from"),to_wallet:m.describe("Foreign of the wallet transfers are made to"),transfer_group:m.describe("Foreign of the transfer_group the transfers are a part of"),status:L.describe("Status of the transfers"),metadata:z,update:Jt}).partial(),Ur=ah.extend({options:nh.optional()}).strict().describe("Input for updateTransfers"),md=To.describe("Output of updateTransfers");var oh=i(Ur);function op(r,e,t){let{client:o}=r;if(e===void 0)return new kt({start(g){return o.api.updateTransferMany({transfer:g.filter,update:g.update,options:g.options})},modifiers(g,k){return["token","wallet","from_wallet","to_wallet"].includes(g)?F(k):g==="transfer_group"?A(k):k}});let n=oh.validateInputWOptions(e,t),{token:s,wallet:p,from_wallet:u,to_wallet:l,update:c}=n;if(!c)throw new ve({message:"Update parameter cant be empty",data:{update:c}});let f={token:F(s),wallet:F(p),from_wallet:F(u),to_wallet:F(l)};return n.transfer_group&&(f.transfer_group=A(n.transfer_group)),n.status&&(f.status=n.status),n.metadata&&(f.metadata=n.metadata),o.api.updateTransferMany({transfer:f,update:c,options:n.options})}var sh=qs.describe("Optional flags for input"),ih=a.object({wallet:m.describe("Wallet foreign"),metadata:j.shape.metadata,name:j.shape.name,status:j.shape.status}).partial().required({wallet:!0}),jr=ih.extend({options:sh.optional()}).strict().describe("Input for updateWallet"),Td=go.describe("Output of updateWallet");var ph=i(jr);function sp(r,e,t){let{client:o}=r,n=ph.validateInputWOptions(e,t);return o.api.updateWallet({wallet:F(n.wallet),update:{metadata:n.metadata,status:n.status,name:n.name},options:n.options})}var hd=(C=>(C.aggregateTransfers="aggregateTransfers",C.createAccessToken="createAccessToken",C.createContract="createContract",C.createDeposit="createDeposit",C.createExchange="createExchange",C.createToken="createToken",C.createTransfer="createTransfer",C.createTransferGroup="createTransferGroup",C.createTransfers="createTransfers",C.createWallet="createWallet",C.createWithdrawal="createWithdrawal",C.exportBalanceHistory="exportBalanceHistory",C.exportTokens="exportTokens",C.exportTransferGroups="exportTransferGroups",C.exportTransfers="exportTransfers",C.exportWallets="exportWallets",C.findBalances="findBalances",C.findTokens="findTokens",C.findTransferGroups="findTransferGroups",C.findTransfers="findTransfers",C.findWallets="findWallets",C.getBalance="getBalance",C.getBalanceHistory="getBalanceHistory",C.getExport="getExport",C.getFlags="getFlags",C.getStatistics="getStatistics",C.getToken="getToken",C.getTransfer="getTransfer",C.getTransferGroup="getTransferGroup",C.getWallet="getWallet",C.healthcheck="healthcheck",C.importData="importData",C.listExports="listExports",C.reverseTransfer="reverseTransfer",C.reverseTransferGroup="reverseTransferGroup",C.reverseTransfers="reverseTransfers",C.setFlags="setFlags",C.updateToken="updateToken",C.updateTransfer="updateTransfer",C.updateTransferGroup="updateTransferGroup",C.updateTransferGroups="updateTransferGroups",C.updateTransfers="updateTransfers",C.updateWallet="updateWallet",C))(hd||{}),I={aggregateTransfers:oi,createAccessToken:si,createContract:ii,createDeposit:pi,createExchange:ui,createToken:li,createTransfer:mi,createTransferGroup:hi,createTransfers:gi,createWallet:xi,createWithdrawal:Oi,exportBalanceHistory:bi,exportTokens:Si,exportTransferGroups:Ii,exportTransfers:wi,exportWallets:Ri,findBalances:Gi,findTokens:Wi,findTransferGroups:Ci,findTransfers:Ai,findWallets:Ni,getBalance:Di,getBalanceHistory:Bi,getExport:Pi,getFlags:Ui,getStatistics:ji,getToken:Vi,getTransfer:Li,getTransferGroup:Zi,getWallet:zi,healthcheck:Hi,importData:qi,listExports:Ji,reverseTransfer:Ki,reverseTransferGroup:Yi,reverseTransfers:Xi,setFlags:ep,updateToken:tp,updateTransfer:rp,updateTransferGroup:np,updateTransferGroups:ap,updateTransfers:op,updateWallet:sp},uh={aggregateTransfers:i(er),createAccessToken:i(tr),createContract:i(rr),createDeposit:i(nr),createExchange:i(ar),createToken:i(or),createTransfer:i(sr),createTransferGroup:i(ir),createTransfers:i(pr),createWallet:i(ur),createWithdrawal:i(dr),exportBalanceHistory:i(lr),exportTokens:i(cr),exportTransferGroups:i(mr),exportTransfers:i(hr),exportWallets:i(Fr),findBalances:i(xr),findTokens:i(Or),findTransferGroups:i(fr),findTransfers:i(Tr),findWallets:i(gr),getBalance:i(br),getBalanceHistory:i(Sr),getExport:i(yr),getFlags:i(_r),getStatistics:i(Ir),getToken:i(kr),getTransfer:i(vr),getTransferGroup:i(wr),getWallet:i(Er),healthcheck:i(Mr),importData:i(Fo),listExports:i(Wr),reverseTransfer:i(Rr),reverseTransferGroup:i(Gr),reverseTransfers:i(Cr),setFlags:i(Ar),updateToken:i(Nr),updateTransfer:i(Dr),updateTransferGroup:i(Br),updateTransferGroups:i(Pr),updateTransfers:i(Ur),updateWallet:i(jr)};var gd,dh=(gd=window.WAPI_VERSION)!=null?gd:"",Vr=class{constructor(e,t){v(this,"api");v(this,"$connect");v(this,"config",{});this.api=e,this.$connect=e.$connect,t&&this.configure(d(d(d(d(d(d(d({},t.token&&{token:t.token}),t.sendingTimeout&&{sendingTimeout:t.sendingTimeout}),t.connectingTimeout&&{connectingTimeout:t.connectingTimeout}),t.reconnectingTimeout&&{reconnectingTimeout:t.reconnectingTimeout}),t.hooks&&{hooks:t.hooks}),t.connectionName&&{connectionName:t.connectionName}),t.httpSkipInitialAuthConnection&&{httpSkipInitialAuthConnection:t.httpSkipInitialAuthConnection}))}close(){return $(this,null,function*(){return this.api.close()})}version(){return dh}setHook(e,t){if(typeof t!="function")throw new TypeError("Hooks can only be functions");return this.api.hooks[e]=t,this}configure(e){if(e.token&&typeof e.token!="string"&&typeof e.token!="number")throw new ge("CONFIG_INVALID",{field:"token",error:`Must be a string|number, '${e.token}' provided`});["sendingTimeout","connectingTimeout","reconnectingTimeout"].forEach(o=>{if(e[o]&&typeof e[o]!="number")throw new ge("CONFIG_INVALID",{field:o,error:`Must be a number, '${e[o]}' provided`})});let t=e.hooks;if(delete e.hooks,this.config=d(d({},this.config),e),this.config.sendingTimeout&&(this.api.sendingTimeout=this.config.sendingTimeout),t)for(let[o,n]of Object.entries(t))this.setHook(o,n);return this}getConfig(e){return this.config[e]}aggregateTransfers(e,t){return e===void 0?I.aggregateTransfers({client:this}):I.aggregateTransfers({client:this},e,t)}createAccessToken(e,t){return I.createAccessToken({client:this},e!=null?e:{},t)}createContract(e,t){return I.createContract({client:this},e,t)}createDeposit(e,t){return I.createDeposit({client:this},e,t)}createExchange(e,t){return I.createExchange({client:this},e,t)}createToken(e,t){return I.createToken({client:this},e,t)}createTransfer(e,t){return I.createTransfer({client:this},e,t)}createTransferGroup(e,t){return I.createTransferGroup({client:this},e!=null?e:{},t)}createTransfers(e,t){return I.createTransfers({client:this},e,t)}createWallet(e,t){return I.createWallet({client:this},e,t)}createWithdrawal(e,t){return I.createWithdrawal({client:this},e,t)}exportBalanceHistory(e,t){return I.exportBalanceHistory({client:this},e,t)}exportTokens(e,t){return e===void 0?I.exportTokens({client:this}):I.exportTokens({client:this},e,t)}exportTransferGroups(e,t){return e===void 0?I.exportTransferGroups({client:this}):I.exportTransferGroups({client:this},e,t)}exportTransfers(e,t){return e===void 0?I.exportTransfers({client:this}):I.exportTransfers({client:this},e,t)}exportWallets(e,t){return e===void 0?I.exportWallets({client:this}):I.exportWallets({client:this},e,t)}findBalances(e,t){return e===void 0?I.findBalances({client:this}):I.findBalances({client:this},e,t)}findTokens(e,t){return e===void 0?I.findTokens({client:this}):I.findTokens({client:this},e,t)}findTransferGroups(e,t){return e===void 0?I.findTransferGroups({client:this}):I.findTransferGroups({client:this},e,t)}findTransfers(e,t){return e===void 0?I.findTransfers({client:this}):I.findTransfers({client:this},e,t)}findWallets(e,t){return e===void 0?I.findWallets({client:this}):I.findWallets({client:this},e,t)}getBalance(e,t){return I.getBalance({client:this},e,t)}getBalanceHistory(e,t){return I.getBalanceHistory({client:this},e,t)}getExport(e,t){return I.getExport({client:this},e,t)}getFlags(e,t){return I.getFlags({client:this},e!=null?e:{},t)}getStatistics(e,t){return I.getStatistics({client:this},e!=null?e:{},t)}getToken(e,t){return I.getToken({client:this},e!=null?e:{},t)}getTransfer(e,t){return I.getTransfer({client:this},e,t)}getTransferGroup(e,t){return I.getTransferGroup({client:this},e,t)}getWallet(e,t){return I.getWallet({client:this},e,t)}healthcheck(e,t){return I.healthcheck({client:this},e!=null?e:{},t)}listExports(e,t){return I.listExports({client:this},e!=null?e:{},t)}reverseTransfer(e,t){return I.reverseTransfer({client:this},e,t)}reverseTransferGroup(e,t){return I.reverseTransferGroup({client:this},e,t)}reverseTransfers(e,t){return e===void 0?I.reverseTransfers({client:this}):I.reverseTransfers({client:this},e,t)}setFlags(e,t){return I.setFlags({client:this},e!=null?e:{},t)}updateToken(e,t){return I.updateToken({client:this},e,t)}updateTransfer(e,t){return I.updateTransfer({client:this},e,t)}updateTransferGroup(e,t){return I.updateTransferGroup({client:this},e,t)}updateTransferGroups(e,t){return e===void 0?I.updateTransferGroups({client:this}):I.updateTransferGroups({client:this},e,t)}updateTransfers(e,t){return e===void 0?I.updateTransfers({client:this}):I.updateTransfers({client:this},e,t)}updateWallet(e,t){return I.updateWallet({client:this},e,t)}};function Fd(r,e){let t=Ks(r,{connectingTimeout:e==null?void 0:e.connectingTimeout,reconnectingTimeout:e==null?void 0:e.reconnectingTimeout});return new Vr(t,e)}function xd(r,e){let t=ti(r,{connectingTimeout:e==null?void 0:e.connectingTimeout,reconnectingTimeout:e==null?void 0:e.reconnectingTimeout,httpSkipInitialAuthConnection:e==null?void 0:e.httpSkipInitialAuthConnection,connectionName:e==null?void 0:e.connectionName});return new Vr(t,e)}var aA=a.enum(["ws","https"]),ip=a.object({host:a.string().describe("URL of the API"),apikey:a.string().describe("API key for the client"),apisecret:a.string().describe("API secret for the client")}).passthrough(),lh=a.object({client:a.literal("ws"),connection:ip}),pp=a.object({host:a.string().describe("URL of the API"),jwt:a.string().describe("Auth token for calling api")}).passthrough(),ch=a.object({client:a.literal("https"),connection:pp}),oA=a.union([lh,ch]);var Od={aggregateTransfersFnInput:i(er),aggregateTransfersFnOutput:i(vu),createAccessTokenFnInput:i(tr),createAccessTokenFnOutput:i(wu),createContractFnInput:i(rr),createContractFnOutput:i(Eu),createDepositFnInput:i(nr),createDepositFnOutput:i(Mu),createExchangeFnInput:i(ar),createExchangeFnOutput:i(Ru),createTokenFnInput:i(or),createTokenFnOutput:i(Gu),createTransferFnInput:i(sr),createTransferFnOutput:i(Wu),createTransferGroupFnInput:i(ir),createTransferGroupFnOutput:i(Cu),createTransfersFnInput:i(pr),createTransfersFnOutput:i(Au),createWalletFnInput:i(ur),createWalletFnOutput:i(Nu),createWithdrawalFnInput:i(dr),createWithdrawalFnOutput:i(Du),exportBalanceHistoryFnInput:i(lr),exportBalanceHistoryFnOutput:i(Bu),exportTokensFnInput:i(cr),exportTokensFnOutput:i(Pu),exportTransferGroupsFnInput:i(mr),exportTransferGroupsFnOutput:i(ju),exportTransfersFnInput:i(hr),exportTransfersFnOutput:i(Lu),exportWalletsFnInput:i(Fr),exportWalletsFnOutput:i(zu),findBalancesFnInput:i(xr),findBalancesFnOutput:i(Hu),findTokensFnInput:i(Or),findTokensFnOutput:i(qu),findTransferGroupsFnInput:i(fr),findTransferGroupsFnOutput:i(Uu),findTransfersFnInput:i(Tr),findTransfersFnOutput:i(Vu),findWalletsFnInput:i(gr),findWalletsFnOutput:i(Zu),getBalanceFnInput:i(br),getBalanceFnOutput:i(Qu),getBalanceHistoryFnInput:i(Sr),getBalanceHistoryFnOutput:i($u),getExportFnInput:i(yr),getExportFnOutput:i(Ju),getFlagsFnInput:i(_r),getFlagsFnOutput:i(Ku),getStatisticsFnInput:i(Ir),getStatisticsFnOutput:i(Yu),getTokenFnInput:i(kr),getTokenFnOutput:i(Xu),getTransferFnInput:i(vr),getTransferFnOutput:i(ed),getTransferGroupFnInput:i(wr),getTransferGroupFnOutput:i(td),getWalletFnInput:i(Er),getWalletFnOutput:i(rd),healthcheckFnInput:i(Mr),healthcheckFnOutput:i(nd),importDataFnInput:i(Fo),importDataFnOutput:i(sd),listExportsFnInput:i(Wr),listExportsFnOutput:i(id),reverseTransferFnInput:i(Rr),reverseTransferFnOutput:i(ad),reverseTransferGroupFnInput:i(Gr),reverseTransferGroupFnOutput:i(od),reverseTransfersFnInput:i(Cr),reverseTransfersFnOutput:i(pd),setFlagsFnInput:i(Ar),setFlagsFnOutput:i(ud),updateTokenFnInput:i(Nr),updateTokenFnOutput:i(dd),updateTransferFnInput:i(Dr),updateTransferFnOutput:i(ld),updateTransferGroupFnInput:i(Br),updateTransferGroupFnOutput:i(cd),updateTransferGroupsFnInput:i(Pr),updateTransferGroupsFnOutput:i(fd),updateTransfersFnInput:i(Ur),updateTransfersFnOutput:i(md),updateWalletFnInput:i(jr),updateWalletFnOutput:i(Td),aggregateTransferManyTxInput:i(Kn),aggregateTransferManyTxOutput:i(Yn),authenticationCheckTxInput:i(Xn),authenticationCheckTxOutput:i(pu),createAccessTokenTxInput:i(ea),createAccessTokenTxOutput:i(ta),createContractTxInput:i(sa),createContractTxOutput:i(ia),createDepositTxInput:i(pa),createDepositTxOutput:i(ua),createDistributionTxInput:i(da),createDistributionTxOutput:i(uu),createTokenTxInput:i(la),createTokenTxOutput:i(ca),createTransferTxInput:i(aa),createTransferTxOutput:i(Xe),createTransferGroupTxInput:i(oa),createTransferGroupTxOutput:i(et),createTransferManyTxInput:i(fa),createTransferManyTxOutput:i(ma),createWalletTxInput:i(Ta),createWalletTxOutput:i(ha),createWithdrawalTxInput:i(ga),createWithdrawalTxOutput:i(Fa),exportBalanceHistoryTxInput:i(Sa),exportBalanceHistoryTxOutput:i(ya),exportTokenManyTxInput:i(Ia),exportTokenManyTxOutput:i(ka),exportTransferGroupManyTxInput:i(wa),exportTransferGroupManyTxOutput:i(Ea),exportTransferManyTxInput:i(Ma),exportTransferManyTxOutput:i(Ra),exportWalletManyTxInput:i(Wa),exportWalletManyTxOutput:i(Ca),findBalanceManyTxInput:i(Aa),findBalanceManyTxOutput:i(Na),findTokenManyTxInput:i(zt),findTokenManyTxOutput:i(_a),findTransferGroupManyTxInput:i(Ht),findTransferGroupManyTxOutput:i(va),findTransferManyTxInput:i(Vt),findTransferManyTxOutput:i(Jn),findWalletManyTxInput:i(qt),findWalletManyTxOutput:i(Ga),finishTransactionTxInput:i(Da),finishTransactionTxOutput:i(hu),getBalanceTxInput:i(ra),getBalanceTxOutput:i(De),getBalanceHistoryTxInput:i(Oa),getBalanceHistoryTxOutput:i(ba),getExportTxInput:i(xa),getExportTxOutput:i(he),getFlagsTxInput:i(Ba),getFlagsTxOutput:i(Pa),getStatisticsTxInput:i(Qt),getStatisticsTxOutput:i(Ua),getTokenTxInput:i(Hn),getTokenTxOutput:i(qn),getTokenManyTxInput:i(ja),getTokenManyTxOutput:i(gu),getTransferTxInput:i(Zn),getTransferTxOutput:i(_e),getTransferGroupTxInput:i(Qn),getTransferGroupTxOutput:i($n),getWalletTxInput:i(Un),getWalletTxOutput:i(Vn),getWalletManyTxInput:i(Va),getWalletManyTxOutput:i(Fu),healthcheckTxInput:i(La),healthcheckTxOutput:i(Za),importActionsTxInput:i($t),importActionsTxOutput:i(za),listExportManyTxInput:i(Ha),listExportManyTxOutput:i(qa),queryLogsTxInput:i(Qa),queryLogsTxOutput:i(xu),resetDatabaseTxInput:i($a),resetDatabaseTxOutput:i(Ou),reverseTransferTxInput:i(Ka),reverseTransferTxOutput:i(Ya),reverseTransferGroupTxInput:i(Xa),reverseTransferGroupTxOutput:i(eo),reverseTransferGroupManyTxInput:i(to),reverseTransferGroupManyTxOutput:i(bu),reverseTransferManyTxInput:i(ro),reverseTransferManyTxOutput:i(no),setFlagsTxInput:i(ao),setFlagsTxOutput:i(oo),startTransactionTxInput:i(so),startTransactionTxOutput:i(Su),updateTokenTxInput:i(io),updateTokenTxOutput:i(po),updateTransferTxInput:i(Ja),updateTransferTxOutput:i(Kt),updateTransferGroupTxInput:i(uo),updateTransferGroupTxOutput:i(lo),updateTransferGroupManyTxInput:i(co),updateTransferGroupManyTxOutput:i(fo),updateTransferManyTxInput:i(mo),updateTransferManyTxOutput:i(To),updateWalletTxInput:i(ho),updateWalletTxOutput:i(go)};var bd=a.enum(["flag","setting"]).describe("Type of the setting"),Sd=K(bd.options),fh=a.object({id:a.number().int().positive().describe("System defined primary key"),name:a.string().min(1).max(255).describe("name of setting. Must be unique"),value:a.string().describe("value of setting"),applied:a.boolean().describe("is setting applied"),created_at:E.describe("Datetime of the initial create"),updated_at:E.describe("Datetime of the last update"),type:bd}).strict().describe("WapiSetting|Database settings");var yd=fh.keyof(),mh=yd.options,Th=yd.options,XN=new Set(Th),eD=new Set(mh);var hh=i(ip),gh=i(pp),_d=(t=>(t.ws="ws",t.https="https",t))(_d||{});function Fh(r){let{config:e,client:t,connection:o}=r;if((t!=null?t:"ws")==="ws"){let n=hh.validateInput(o);return Fd(n,e)}if(t==="https"){let n=gh.validateInput(o);return xd(n,e)}throw new TypeError("Invalid client type")}var xh={getIdentifier:Eo};return Gd(Oh);})();
|
|
1
|
+
var WAPI=(()=>{var kn=Object.defineProperty,vd=Object.defineProperties,wd=Object.getOwnPropertyDescriptor,Ed=Object.getOwnPropertyDescriptors,Md=Object.getOwnPropertyNames,In=Object.getOwnPropertySymbols;var _o=Object.prototype.hasOwnProperty,lp=Object.prototype.propertyIsEnumerable;var yo=(r,e,t)=>e in r?kn(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,d=(r,e)=>{for(var t in e||(e={}))_o.call(e,t)&&yo(r,t,e[t]);if(In)for(var t of In(e))lp.call(e,t)&&yo(r,t,e[t]);return r},S=(r,e)=>vd(r,Ed(e));var Y=(r,e)=>{var t={};for(var o in r)_o.call(r,o)&&e.indexOf(o)<0&&(t[o]=r[o]);if(r!=null&&In)for(var o of In(r))e.indexOf(o)<0&&lp.call(r,o)&&(t[o]=r[o]);return t};var Rd=(r,e)=>{for(var t in e)kn(r,t,{get:e[t],enumerable:!0})},Gd=(r,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Md(e))!_o.call(r,n)&&n!==t&&kn(r,n,{get:()=>e[n],enumerable:!(o=wd(e,n))||o.enumerable});return r};var Wd=r=>Gd(kn({},"__esModule",{value:!0}),r);var v=(r,e,t)=>yo(r,typeof e!="symbol"?e+"":e,t);var Q=(r,e,t)=>new Promise((o,n)=>{var s=l=>{try{u(t.next(l))}catch(c){n(c)}},p=l=>{try{u(t.throw(l))}catch(c){n(c)}},u=l=>l.done?o(l.value):Promise.resolve(l.value).then(s,p);u((t=t.apply(r,e)).next())});var bh={};Rd(bh,{APIFunctions:()=>Ks,APIValidators:()=>Js,AggregateQueryBuilder:()=>Fn,AuthError:()=>ze,AuthenticationError:()=>Et,AuthorizationError:()=>Io,Client:()=>zr,ClientFunctions:()=>k,ClientFunctionsEnum:()=>gd,ClientValidators:()=>lh,ConfigError:()=>ge,ConstraintError:()=>vn,ERRORS:()=>le,ERROR_CODE_TO_TYPE:()=>fp,ERROR_DESCRIPTIONS:()=>Tp,ERROR_GROUPS:()=>$,ERROR_MESSAGES:()=>mp,ERROR_TYPES:()=>Hr,ErrorDescription:()=>Tp,ErrorMessage:()=>mp,ErrorType:()=>Hr,Errors:()=>le,InputError:()=>q,InternalError:()=>wn,JSONRPCError:()=>wt,QueryBuilder:()=>ee,QueryBuilderInterface:()=>kt,ReverseQueryBuilder:()=>xn,StreamError:()=>ke,StreamPromise:()=>Be,TokenStatusEnum:()=>tu,TokenTypeEnum:()=>ru,TransferGroupStatusEnum:()=>Hn,TransferGroupTypeEnum:()=>ou,TransferStatusEnum:()=>Jp,TransferTypeEnum:()=>bt,UnknownError:()=>ko,UpdateQueryBuilder:()=>vt,ValidationError:()=>ve,Validator:()=>Sd,WAPIError:()=>Ie,WalletStatusEnum:()=>qp,WalletTypeEnum:()=>Qp,WapiClientType:()=>Id,WapiSettingTypeEnum:()=>yd,aggregateTransfers:()=>ii,create:()=>Oh,createAccessToken:()=>pi,createContract:()=>ui,createDeposit:()=>di,createExchange:()=>li,createToken:()=>fi,createTransfer:()=>hi,createTransferGroup:()=>Fi,createTransfers:()=>xi,createWallet:()=>Si,createWithdrawal:()=>bi,exportBalanceHistory:()=>yi,exportTokens:()=>_i,exportTransferGroups:()=>vi,exportTransfers:()=>Mi,exportWallets:()=>Wi,findBalances:()=>Ci,findTokens:()=>Ai,findTransferGroups:()=>Ni,findTransfers:()=>Di,findWallets:()=>Bi,getBalance:()=>Pi,getBalanceHistory:()=>Ui,getError:()=>En,getExport:()=>ji,getFlags:()=>Vi,getIdentifier:()=>Ro,getStatistics:()=>Li,getToken:()=>Zi,getTransfer:()=>zi,getTransferGroup:()=>Hi,getValidator:()=>i,getValidatorError:()=>yp,getWallet:()=>qi,healthcheck:()=>Qi,importData:()=>$i,listExports:()=>Yi,reverseTransfer:()=>Xi,reverseTransferGroup:()=>ep,reverseTransfers:()=>tp,setFlags:()=>rp,updateToken:()=>np,updateTransfer:()=>ap,updateTransferGroup:()=>op,updateTransferGroups:()=>sp,updateTransfers:()=>ip,updateWallet:()=>pp,utils:()=>Sh});var cp=WebSocket;function W(...r){window.WAPI_DEBUG&&console.log(...r.map(e=>e&&typeof e=="object"?JSON.stringify(e):e))}var $={JSONRPC:{min:-32700,max:-32600,ERRORS:{PARSE_ERROR:{code:-32700,message:"Parse error",description:"Unable to parse JSON input"},INVALID_REQUEST:{code:-32600,message:"Invalid request",description:"JSON input does not match JSONRPC spec"},METHOD_NOT_FOUND:{code:-32601,message:"Method not found",description:"Requested method not found"},INVALID_PARAMS:{code:-32602,message:"Invalid params",description:"Invalid params provided for method"},INTERNAL_SERVER_ERROR:{code:-32603,message:"Internal server error",description:"Unknown error occurred"}}},AUTH:{min:-20999,max:-2e4,ERRORS:{AUTHENTICATION_ERROR:{code:-2e4,message:"Authentication error",description:"Invalid authentication credentials"},AUTHORIZATION_ERROR:{code:-20001,message:"AUTHORIZATION_ERROR",description:"Provided credentials lack access rights"}}},STREAM:{min:-10999,max:-1e4,ERRORS:{CONNECTION_LOST:{code:-1e4,message:"CONNECTION_LOST",description:"Lost connection to server"},INPUT_STREAM_INVALID:{code:-10001,message:"INPUT_STREAM_INVALID",description:"Invalid input stream identifier provided"},INVALID_RESPONSE_STREAM_CHUNK:{code:-10002,message:"INVALID_RESPONSE_STREAM_CHUNK",description:"Received multiple chunks for non-array property"},INVALID_INPUT_STREAM_CHUNK:{code:-10003,message:"INVALID_INPUT_STREAM_CHUNK",description:"Invalid chunk sent to input stream"},INPUT_STREAM_TIMEOUT:{code:-10004,message:"INPUT_STREAM_TIMEOUT",description:"Input stream failed to finish in allotted time"},INPUT_STREAM_ERROR:{code:-10005,message:"INPUT_STREAM_ERROR",description:"Unknown error in input stream"},INPUT_STREAM_NOT_ALLOWED:{code:-10006,message:"INPUT_STREAM_NOT_ALLOWED",description:"Stream input not allowed for method"}}},INPUT:{min:-14999,max:-11e3,ERRORS:{HTTP_BODY_SIZE:{code:-11e3,message:"HTTP_BODY_SIZE",description:"Http body size can't be more than 100MB"},DATABASE_EXPORT_CONFLICT:{code:-12e3,message:"DATABASE_EXPORT_CONFLICT",description:"Database export already in progress"},DATABASE_IMPORT_CONFLICT:{code:-12001,message:"DATABASE_IMPORT_CONFLICT",description:"Database import already in progress"},DATABASE_EXPORT_PROGRESS_NOT_FOUND:{code:-12002,message:"DATABASE_EXPORT_PROGRESS_NOT_FOUND",description:"Database backup process not found"},DATABASE_IMPORT_PROGRESS_NOT_FOUND:{code:-12003,message:"DATABASE_IMPORT_PROGRESS_NOT_FOUND",description:"Database backup process not found"},DATABASE_IMPORT_NOT_FOUND:{code:-12004,message:"DATABASE_IMPORT_NOT_FOUND",description:"Database import file not found"},TR_CANT_UPDATE_TO_PENDING:{code:-12100,message:"TR_CANT_UPDATE_TO_PENDING",description:"Transfer status can only move from 'pending'->'finished'/'cancelled"},TR_CANT_UPDATE_TIMESTAMP:{code:-12101,message:"TR_CANT_UPDATE_TIMESTAMP",description:"Cant update transfer.updated_at - allow_timestamps flag is set to off"},TR_CANT_INSERT_TIMESTAMP:{code:-12102,message:"TR_CANT_INSERT_TIMESTAMP",description:"Cant insert transfer.created_at - allow_timestamps flag is set to off"},TR_EMPTY_UPDATE_REQUEST:{code:-12103,message:"TR_EMPTY_UPDATE_REQUEST",description:"Update request for transfer is empty"},TR_MISSING_FILTER:{code:-12104,message:"TR_MISSING_FILTER",description:"Transactions can't reversed or updated without valid filter"},TR_TO_WALLET_WITHDRAWAL:{code:-12105,message:"TR_TO_WALLET_WITHDRAWAL",description:"To wallet can't be specified when doing a withdrawal"},TR_FROM_WALLET_DEPOSIT:{code:-12106,message:"TR_FROM_WALLET_DEPOSIT",description:"From wallet can't be specified when doing a deposit"},TR_FROM_TO_CONFLICT:{code:-12107,message:"TR_FROM_TO_CONFLICT",description:"from_wallet and to_wallet can not be the same"},TR_UNABLE_TO_RESOLVE_INPUT:{code:-12108,message:"TR_UNABLE_TO_RESOLVE_INPUT",description:"Unable to resolve references to foreign keys"},TRG_MISSING_FILTER:{code:-12200,message:"TRG_MISSING_FILTER",description:"Transaction groups can't reversed or updated without valid filter"},INVALID_FIELD_AGR_COMB:{code:-12300,message:"INVALID_FIELD_AGR_COMB",description:"Provided aggregation field was not found on Model"},INVALID_FIELD_FOR_MODEL:{code:-12301,message:"INVALID_FIELD_FOR_MODEL",description:"Provided field was not found on Model"},NO_METADATA_ON_MODEL:{code:-12302,message:"NO_METADATA_ON_MODEL",description:"Can't use metadata field for grouping as current Model does not have metadata"},INVALID_MODEL:{code:-12303,message:"INVALID_MODEL",description:"Provided Model name is invalid"},INVALID_COMPLEX_FILTER:{code:-12304,message:"INVALID_COMPLEX_FILTER",description:"The provided complex filter does not pass validation"},UNCLEAR_AGGREGATOR:{code:-12305,message:"UNCLEAR_AGGREGATOR",description:"Invalid aggregator function provided"},CONTRACT_OWNER_NOT_FOUND:{code:-12306,message:"CONTRACT_OWNER_NOT_FOUND",description:"Unable to find Wallet specified as Contract token owner"},DISTRIBUTION_MISSING_TARGETS:{code:-12307,message:"DISTRIBUTION_MISSING_TARGETS",description:"Unable to resolve all targets (Wallets, Tokens) for distribution request"},TOKEN_INVALID_WALLET:{code:-12308,message:"TOKEN_INVALID_WALLET",description:"Invalid belongs_to wallet provided"},BAL_FUTURE_DATETIME:{code:-12309,message:"BAL_FUTURE_DATETIME",description:"Balance datetime can't be in the future"},INPUT_NEEDS_IDENTIFIER:{code:-12310,message:"INPUT_NEEDS_IDENTIFIER",description:"Missing identifier - automatically calculated identifiers conflict on identical input for 30s To make an identical transfer during that window you need to provide a unique identifier"},RESET_INVALID_CONFIRMATION:{code:-12311,message:"RESET_INVALID_CONFIRMATION",description:"Provided reset confirmation code is invalid"},INPUT_NEEDS_TOKEN:{code:-12312,message:"INPUT_NEEDS_TOKEN",description:"token must be specified on input or in client config"},CONFLICTING_OPTIONS_FOR_BALANCE:{code:-12313,message:"CONFLICTING_OPTIONS_FOR_BALANCE",description:"return_running_balance and return_running_balance_for can't be specified together"},CONFLICTING_OPTIONS_FOR_SIGNED_AMOUNT:{code:-12314,message:"CONFLICTING_OPTIONS_FOR_SIGNED_AMOUNT",description:"return_signed_amount and return_signed_amount_for_wallet can't be specified together"},RUNNING_BALANCE_WITHOUT_WALLET:{code:-12315,message:"RUNNING_BALANCE_WITHOUT_WALLET",description:"return_running_balance option requires Wallet filter to be specified"},SIGNED_AMOUNT_WITHOUT_WALLET:{code:-12316,message:"SIGNED_AMOUNT_WITHOUT_WALLET",description:"return_signed_amount option requires Wallet filter to be specified"},REQUIRED_INPUT_MISSING:{code:-12317,message:"REQUIRED_INPUT_MISSING",description:"input does not specify required keys"},TRX_NOT_ALLOWED:{code:-12400,message:"TRX_NOT_ALLOWED",description:"This method can not run in a transaction"},TRANSACTION_NOT_FOUND:{code:-12401,message:"TRANSACTION_NOT_FOUND",description:"Transaction not found"},ONLY_SELECT_ALLOWED:{code:-12402,message:"ONLY_SELECT_ALLOWED",description:"Only select queries are allowed"},CNT_DEPOSIT_TOKEN_MISMATCH:{code:-12500,message:"CNT_DEPOSIT_TOKEN_MISMATCH",description:"Unable to find tokens specified in deposits"}}},CONSTRAINT:{min:-19999,max:-19e3,ERRORS:{INVALID_LATEST_HASH:{code:-19e3,message:"INVALID_LATEST_HASH",description:"Http body size can't be more than 100MB"},TOKEN_LIMIT_REACHED:{code:-19001,message:"TOKEN_LIMIT_REACHED",description:"Unable to issue more tokens as Token.limit has been reached"},TR_INVALID_BALANCE:{code:-19101,message:"TR_INVALID_BALANCE",description:"Transfer would result in invalid balance for a Wallet"},TR_AMOUNT_NOT_DIVISIBLE:{code:-19102,message:"TR_AMOUNT_NOT_DIVISIBLE",description:"Transfer amount is not divisible by specified Token.divisor"},TR_TOKEN_DISABLED:{code:-19103,message:"TR_TOKEN_DISABLED",description:"Token status is set to 'disabled' - no new transfers allowed"},TR_TOKEN_DWONLY:{code:-19104,message:"TR_TOKEN_DWONLY",description:"Token status is set to 'dw-only' - only deposits or withdrawals allowed"},TR_TRG_STATUS_MISMATCH:{code:-19105,message:"TR_TRG_STATUS_MISMATCH",description:"Transfers in transfer_group must match transfer_group.transfer_status"},TR_TRG_CLOSED:{code:-19106,message:"TR_TRG_CLOSED",description:"Cant add Transfer to group. TransferGroup is closed"},TR_TIMESTAMP_IN_PAST:{code:-19107,message:"TR_TIMESTAMP_IN_PAST",description:"Transfer.created_at must not be in the past"},TR_TIMESTAMP_MUST_BE_LATEST:{code:-19108,message:"TR_TIMESTAMP_MUST_BE_LATEST",description:"Transfer.created_at must be the latest"},TR_INVALID_CANCELLED:{code:-19109,message:"TR_INVALID_CANCELLED",description:"Cant create cancelled transfer"},TR_FROM_WALLET_STATUS_CONSTRAINT:{code:-19110,message:"TR_FROM_WALLET_STATUS_CONSTRAINT",description:"From wallet.status doesn't allow this type of transfers"},TR_TO_WALLET_STATUS_CONSTRAINT:{code:-19111,message:"TR_TO_WALLET_STATUS_CONSTRAINT",description:"To wallet.status doesn't allow this type of transfers"},TR_CANCELLED_CANT_RV:{code:-19112,message:"TR_CANCELLED_CANT_RV",description:"Cancelled Transfer can not be reversed"},TR_DEPOSIT_CANT_RV_WITHOUT_FLAG:{code:-19113,message:"TR_DEPOSIT_CANT_RV_WITHOUT_FLAG",description:"Deposits are expected connection points with outside systems, thus extra validation is required. Reversing a Transfer.type = 'deposit' requires reverse_deposit option to be true."},TR_WITHDRAWAL_CANT_RV_WITHOUT_FLAG:{code:-19114,message:"TR_WITHDRAWAL_CANT_RV_WITHOUT_FLAG",description:"Withdrawals are expected connection points with outside systems, thus extra validation is required. Reversing a Transfer.type = 'withdrawal' requires reverse_withdrawal option to be true."},TR_UNIQUE_IDENTIFIER:{code:-19115,message:"TR_UNIQUE_IDENTIFIER",description:"The identifier for Transfer object must be unique"},TR_DIFFERENT_WALLETS:{code:-19116,message:"TR_DIFFERENT_WALLETS",description:"To and from wallets have to be different"},TRG_SINGLE_PENDING_TR_CANT_RV:{code:-19200,message:"TRG_SINGLE_PENDING_TR_CANT_RV",description:"Transfer is part of TransferGroup and can not be reversed separately"},TRG_CANCELLED_CANT_RV:{code:-19201,message:"TRG_CANCELLED_CANT_RV",description:"Cancelled TransferGroup can not be reversed"},TRG_DEPOSIT_CANT_RV_WITHOUT_FLAG:{code:-19202,message:"TRG_DEPOSIT_CANT_RV_WITHOUT_FLAG",description:"TransferGroup includes Transfer.type = 'deposit', thus for extra validation the reverse_deposit option must be set true"},TRG_WITHDRAWAL_CANT_RV_WITHOUT_FLAG:{code:-19203,message:"TRG_WITHDRAWAL_CANT_RV_WITHOUT_FLAG",description:"TransferGroup includes Transfer.type = 'withdrawal', thus for extra validation the reverse_withdrawal option must be set true"},TRG_UNIQUE_IDENTIFIER:{code:-19204,message:"TRG_UNIQUE_IDENTIFIER",description:"The identifier for TransferGroup object must be unique"},TOKEN_UNIQUE_FOREIGN:{code:-19300,message:"TOKEN_UNIQUE_FOREIGN",description:"The foreign for Token object must be unique"},WALLET_UNIQUE_FOREIGN:{code:-19400,message:"WALLET_UNIQUE_FOREIGN",description:"The foreign for Wallet object must be unique"},UNIQUE_CONSTRAINT:{code:-19500,message:"UNIQUE_CONSTRAINT",description:"Insert violates unique constraint"}}},CONFIG:{min:-16e3,max:-15e3,ERRORS:{METHOD_DISABLED:{code:-15e3,message:"METHOD_DISABLED",description:"Method is disabled"},FLAG_PRODUCTION_ON:{code:-15001,message:"FLAG_PRODUCTION_ON",description:'Production flag is "on" - this method is disabled'},FLAG_PRODUCTION_LOCKED:{code:-15002,message:"FLAG_PRODUCTION_LOCKED",description:"Cant update production flag to false in this server"},TRANSACTION_TIMEOUT:{code:-15003,message:"TRANSACTION_TIMEOUT",description:"Database transaction timed out"},CONNECTION_TIMEOUT:{code:-15004,message:"CONNECTION_TIMEOUT",description:"Unable to get initial response in specified time"},SENDING_TIMEOUT:{code:-15005,message:"SENDING_TIMEOUT",description:"Unable to get ack from server in specified time"},CONFIG_INVALID:{code:-15100,message:"CONFIG_INVALID",description:"Provided configuration is invalid"}}}},le=d(d(d(d(d(d({},$.JSONRPC.ERRORS),$.AUTH.ERRORS),$.CONFIG.ERRORS),$.STREAM.ERRORS),$.INPUT.ERRORS),$.CONSTRAINT.ERRORS);function rt(r){return Object.fromEntries(Object.keys(r).map(e=>[e,e]))}var Hr=rt(le),Ie=class extends Error{constructor({type:t,code:o,message:n,data:s}){var u;super(n);v(this,"type");v(this,"code");v(this,"data");let p=(u=le[t])!=null?u:le.INTERNAL_SERVER_ERROR;this.type=t!=null?t:Hr.INTERNAL_SERVER_ERROR,this.code=o!=null?o:p.code,this.message=n!=null?n:p.message,this.data=d({description:p.description},s&&typeof s=="object"?s:{error:s})}toJSON(){return{code:this.code,message:this.message,data:this.data}}},wt=class extends Ie{constructor(e,t,o,n){super({type:e,message:o,data:t,code:n})}static get group(){return $.JSONRPC.ERRORS}static get types(){return rt($.JSONRPC.ERRORS)}},ke=class extends Ie{constructor(e,t,o,n){super({type:e,message:o,data:t,code:n})}static get group(){return $.STREAM.ERRORS}static get types(){return rt($.STREAM.ERRORS)}},q=class extends Ie{constructor(e,t,o,n){super({type:e,message:o,data:t,code:n})}static get group(){return $.INPUT.ERRORS}static get types(){return rt($.INPUT.ERRORS)}},ge=class extends Ie{constructor(e,t,o,n){super({type:e,message:o,data:t,code:n})}static get group(){return $.CONFIG.ERRORS}static get types(){return rt($.CONFIG.ERRORS)}},ze=class extends Ie{constructor(e,t,o,n){super({type:e,message:o,data:t,code:n})}static get group(){return $.AUTH.ERRORS}static get types(){return rt($.AUTH.ERRORS)}},vn=class extends Ie{constructor(e,t,o,n){super({type:e,message:o,data:t,code:n})}static get group(){return $.CONSTRAINT.ERRORS}static get types(){return rt($.CONSTRAINT.ERRORS)}},ve=class extends wt{constructor(e,t){super(wt.types.INVALID_PARAMS,e,t)}},Et=class extends ze{constructor(e){super(ze.types.AUTHENTICATION_ERROR,e)}},Io=class extends ze{constructor(e){super(ze.types.AUTHORIZATION_ERROR,e)}},wn=class extends Ie{constructor(e){super({type:Hr.INTERNAL_SERVER_ERROR,data:e})}toJSON(){return{code:this.code,message:this.message,data:{description:le.INTERNAL_SERVER_ERROR.description}}}},ko=class extends wn{constructor(e){super({data:{message:e}})}toJSON(){let e=super.toJSON();return e.data={description:e.data.description,message:this.data.message},{code:this.code,message:this.message,data:{message:this.data.message,description:le.INTERNAL_SERVER_ERROR.description}}}},fp=Object.fromEntries(Object.keys(le).map(r=>[le[r].code,r]));function Cd(r){let e=fp[r];if(!e){let o=Object.entries($).find(([,n])=>r>=n.min&&r<=n.max);return{group:o==null?void 0:o[0],type:void 0}}let t=Object.keys($).find(o=>e in $[o].ERRORS);return t?{group:t,type:e}:(console.error("ERRORS and ERROR_GROUPS are out of sync",e),{group:void 0,type:e})}function En({code:r,message:e,data:t}){let o=Cd(r),n=o.type,s=o.group;e=e&&e!==n||!n?e:le[n].description;let p;switch(s&&s!=="JSONRPC"&&n===void 0&&(W("Novel error from server",r,e,t),n=e,p=r,e=t&&typeof t=="object"&&"description"in t&&typeof t.description=="string"?t.description:e),s){case"JSONRPC":return new wt(n,t,e);case"AUTH":return new ze(n,t,e,p);case"CONFIG":return new ge(n,t,e,p);case"CONSTRAINT":return new vn(n,t,e,p);case"INPUT":return new q(n,t,e,p);case"STREAM":return new ke(n,t,e,p);default:return new Ie({code:r,message:e,data:t,type:n!=null?n:Hr.INTERNAL_SERVER_ERROR})}}var mp=Object.fromEntries(Object.keys(le).map(r=>[r,le[r].message])),Tp=Object.fromEntries(Object.keys(le).map(r=>[r,le[r].description]));var oe=[];for(let r=0;r<256;++r)oe.push((r+256).toString(16).slice(1));function hp(r,e=0){return(oe[r[e+0]]+oe[r[e+1]]+oe[r[e+2]]+oe[r[e+3]]+"-"+oe[r[e+4]]+oe[r[e+5]]+"-"+oe[r[e+6]]+oe[r[e+7]]+"-"+oe[r[e+8]]+oe[r[e+9]]+"-"+oe[r[e+10]]+oe[r[e+11]]+oe[r[e+12]]+oe[r[e+13]]+oe[r[e+14]]+oe[r[e+15]]).toLowerCase()}var vo,Ad=new Uint8Array(16);function wo(){if(!vo){if(typeof crypto=="undefined"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");vo=crypto.getRandomValues.bind(crypto)}return vo(Ad)}var Nd=typeof crypto!="undefined"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Eo={randomUUID:Nd};function Dd(r,e,t){var n,s,p;if(Eo.randomUUID&&!e&&!r)return Eo.randomUUID();r=r||{};let o=(p=(s=r.random)!=null?s:(n=r.rng)==null?void 0:n.call(r))!=null?p:wo();if(o.length<16)throw new Error("Random bytes length must be >= 16");if(o[6]=o[6]&15|64,o[8]=o[8]&63|128,e){if(t=t||0,t<0||t+16>e.length)throw new RangeError(`UUID byte range ${t}:${t+15} is out of buffer bounds`);for(let u=0;u<16;++u)e[t+u]=o[u];return e}return hp(o)}var Mt=Dd;function nt(r=8){return Mt().split("-").pop().substr(0,r)}var Mo={timeouts:{},values:{},set(r,e){this.timeouts[r]=setTimeout(()=>this.clear(r),3e4),this.values[r]=e},get(r){return this.values[r]},getKey(r){let e=JSON.parse(JSON.stringify(r)),t="";return Object.keys(e).sort().forEach(o=>{let n="";e[o]&&typeof e[o]=="object"&&!Array.isArray(e[o])?n=this.getKey(e[o]):n=JSON.stringify(e[o]),t+=o+":"+n}),t},clear(r){this.timeouts[r]&&clearTimeout(this.timeouts[r]),delete this.timeouts[r],delete this.values[r]},clearAll(){Object.keys(this.timeouts).forEach(r=>{clearTimeout(this.timeouts[r])}),this.timeouts={},this.values={}}};function ie(r){if(!r)return Mt();let e=Mo.getKey(r);if(Mo.get(e))throw new q("INPUT_NEEDS_IDENTIFIER",{object:r});let t=Mt();return Mo.set(e,t),t}function Fp(r){return new Promise(e=>setTimeout(e,r))}function Ro(){return ie()}function Bd(r){return JSON.parse(JSON.stringify(r))}function Me(r,e,t){if(e in r){if(r[e]===void 0)throw new ve({input:r},`undefined provided for ${e}`);return r}if(!t)throw new ve({input:r},`${e} is required if no default set`);let o=Bd(r);return o[e]=t,o}function g(r){let e=xp(r);if(e!=null)return{foreign:e}}function A(r){let e=xp(r);if(e!=null)return{identifier:e}}function xp(r){return r==null?r:r+""}function Pd(r){return Object.keys(r).filter(e=>r[e]!==void 0).map(e=>`${encodeURIComponent(e)}=${encodeURIComponent(r[e])}`).join("&")}function gp(r){return r.host.replace(/^https:/,"wss:")+"?"+Pd({apikey:r.apikey,apisecret:r.apisecret,db:r.database,clientVersion:r.clientVersion,connectionName:r.connectionName})}function Op(r){return typeof window=="undefined"?[gp(r),{rejectUnauthorized:r.rejectUnauthorized}]:[gp(r)]}function Mn(r,e){let t={},o=!r||typeof r!="object"?{}:r;return Object.keys(o).forEach(n=>{e[n]?typeof e[n]=="string"?t[e[n]]=o[n]:t[n]=e[n](o[n]):t[n]=o[n]}),t}function Ud(r){return r.split(",").map(e=>e.split(" ")).map(e=>{let[t,o]=e;return{field:t,direction:o==="desc"?"desc":"asc"}})}function te(r){let o=r,{order_by:e}=o,t=Y(o,["order_by"]);return!t.order&&e&&(t.order=Ud(e)),t}function Sp(r){if(r!=null)return r+""}function Rt(r){return typeof r=="number"?r:parseFloat(r)}function bp(r){return new Date(r).setHours(0,0,0,0)>new Date().setHours(0,0,0,0)}var qr=class{constructor(e){v(this,"_data",[]);v(this,"_error",[]);v(this,"_end",[]);v(this,"_finished",!1);v(this,"_options");this._options=e}on(e,t){switch(e){case"data":return this._data.push(t),this;case"end":return this._end.push(t),this;case"error":return this._error.push(t),this}}push(e){if(this._finished)throw new Error("Stream is closed");return e===null?this.end():(this._data.forEach(t=>t(e)),this)}error(e){if(this._finished)throw new Error("Stream is closed");return this._error.forEach(t=>t(e)),this}end(){if(this._finished)throw new Error("Stream is closed");return this._end.forEach(e=>e()),this._finished=!0,this}destroy(e){return this.error(e),this.end(),this}get destroyed(){return this._finished}},Rn=class{constructor(){throw new TypeError("used in node version")}pipe(...e){throw new TypeError("used in node version")}pause(){throw new TypeError("used in node version")}resume(){throw new TypeError("used in node version")}on(...e){throw new TypeError("used in node version")}};var Be=class{constructor(e){v(this,"resolve");v(this,"reject");v(this,"makeRequest");v(this,"streamObject",new qr({objectMode:!0}));v(this,"outStreamObject",new qr({objectMode:!0}));v(this,"mode");v(this,"started",!1);v(this,"promise");this.makeRequest=e}start(e){var o;if(W("start request as",e),this.mode&&this.mode!==e)throw new Error("Already in use as "+this.mode);if(this.started)return;if(this.promise=new Promise((n,s)=>{this.resolve=n,this.reject=s}),this.started=!0,this.mode=e,this.makeRequest===void 0){this.streamObject.push(null),(o=this.resolve)==null||o.call(this,void 0);return}this.makeRequest(this.streamObject).catch(this.reject);let t=[];if(this.mode==="stream"){this.streamObject.on("data",n=>{if(W("stream data",n),n||this.outStreamObject.push(n),n.error){let s=En(n.error);return this.outStreamObject.destroy(s),this.streamObject.destroy(s)}if(!n.prop){t.push(n);return}if(n.dataArr){let s=d({},n);delete s.dataArr,n.dataArr.forEach(p=>{this.outStreamObject.push(S(d({},s),{data:p}))});return}this.outStreamObject.push(n)}).on("end",()=>{W("stream ended");let n=t.pop();if(!n)return;let s=n.result;Object.keys(s).forEach(p=>{Array.isArray(s[p])&&(s[p].forEach(u=>{this.outStreamObject.push({type:"streamChunk",prop:p,data:u})}),s[p]=[])}),this.outStreamObject.push(n),this.outStreamObject.push(null)}).on("error",n=>{W("stream error",n),this.outStreamObject.destroy(n)});return}if(this.mode==="promise"){let n=new Map;this.streamObject.on("data",s=>{var u;if(W("streamPromise data",s),s===void 0)return;if(s.error){let l=En(s.error);return this.streamObject.destroy(l)}if(!s.prop){t.push(s);return}let p=(u=n.get(s.prop))!=null?u:[];s.dataArr?p.push(...s.dataArr):p.push(s.data),n.set(s.prop,p)}).on("end",()=>{W("streamPromise end");let s=t.pop();if(!s)return;let p=s.result;if(!n.size)return this.resolve(p);let u=!1;n.forEach((l,c)=>{Array.isArray(p[c])?(l.push(...p[c]),p[c]=l):l.length===1?p[c]=l:(this.streamObject.destroy(new ke("INVALID_RESPONSE_STREAM_CHUNK",{property:c,value:l})),u=!0)}),u||this.resolve(p)}).on("error",s=>{var p;return W("streamPromise error",s),(p=this.reject)==null?void 0:p.call(this,s)})}}then(e,t){return this.start("promise"),this.promise.then(e,t)}catch(e){return this.start("promise"),this.promise.catch(e)}stream(){return this.start("stream"),this.outStreamObject}};var Qr=class extends Be{constructor(t,o){super(t);v(this,"inputStream");this.inputStream=o}input(t){return t?typeof t=="function"?(t(this.inputStream),this):(console.warn("currently disabled"),this):this.inputStream}};var Gn={};var yp=(r,e)=>{if(r)return new ve({message:r.message,data:r.format()})},Go=(r,e,t=yp)=>{let{success:o,error:n,data:s}=r.safeParse(e);return{data:s,success:o,isValid:o,error:t(n,e)}},_p=(r,e,t,o)=>!e||typeof e!="object"?{success:!1,isValid:!1,error:new ve({message:`Invalid input - expected object, got ${typeof e}`,data:{input:e}})}:Go(r,d({options:t!=null?t:{}},e),o),jd=(r,e,t,o)=>{var p;let{data:n,error:s}=Go(r,e,o);if(s)throw((p=t==null?void 0:t.warn)!=null?p:W)(d({err:s},Gn),"Invalid input"),s;return n},Vd=(r,e,t,o,n)=>{!o&&t&&typeof(t==null?void 0:t.warn)=="function"&&(o=t,t={});let{data:s,error:p}=_p(r,e,t,n);if(p)throw o?o.warn(d({err:p},Gn),"Invalid input"):W(d({err:p},Gn),"Invalid input"),p;return s},i=(r,e)=>({validateInput:(t,o)=>jd(r,t,o,e),validateInputWOptions:(t,o,n)=>Vd(r,t,o,n,e),softValidateInput:t=>Go(r,t,e),softValidateWOptions:(t,o)=>_p(r,t,o,e)});var L;(function(r){r.assertEqual=n=>n;function e(n){}r.assertIs=e;function t(n){throw new Error}r.assertNever=t,r.arrayToEnum=n=>{let s={};for(let p of n)s[p]=p;return s},r.getValidEnumValues=n=>{let s=r.objectKeys(n).filter(u=>typeof n[n[u]]!="number"),p={};for(let u of s)p[u]=n[u];return r.objectValues(p)},r.objectValues=n=>r.objectKeys(n).map(function(s){return n[s]}),r.objectKeys=typeof Object.keys=="function"?n=>Object.keys(n):n=>{let s=[];for(let p in n)Object.prototype.hasOwnProperty.call(n,p)&&s.push(p);return s},r.find=(n,s)=>{for(let p of n)if(s(p))return p},r.isInteger=typeof Number.isInteger=="function"?n=>Number.isInteger(n):n=>typeof n=="number"&&isFinite(n)&&Math.floor(n)===n;function o(n,s=" | "){return n.map(p=>typeof p=="string"?`'${p}'`:p).join(s)}r.joinValues=o,r.jsonStringifyReplacer=(n,s)=>typeof s=="bigint"?s.toString():s})(L||(L={}));var Co;(function(r){r.mergeShapes=(e,t)=>d(d({},e),t)})(Co||(Co={}));var b=L.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Ue=r=>{switch(typeof r){case"undefined":return b.undefined;case"string":return b.string;case"number":return isNaN(r)?b.nan:b.number;case"boolean":return b.boolean;case"function":return b.function;case"bigint":return b.bigint;case"symbol":return b.symbol;case"object":return Array.isArray(r)?b.array:r===null?b.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?b.promise:typeof Map!="undefined"&&r instanceof Map?b.map:typeof Set!="undefined"&&r instanceof Set?b.set:typeof Date!="undefined"&&r instanceof Date?b.date:b.object;default:return b.unknown}},h=L.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),Ld=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:"),Fe=class r extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=o=>{this.issues=[...this.issues,o]},this.addIssues=(o=[])=>{this.issues=[...this.issues,...o]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){let t=e||function(s){return s.message},o={_errors:[]},n=s=>{for(let p of s.issues)if(p.code==="invalid_union")p.unionErrors.map(n);else if(p.code==="invalid_return_type")n(p.returnTypeError);else if(p.code==="invalid_arguments")n(p.argumentsError);else if(p.path.length===0)o._errors.push(t(p));else{let u=o,l=0;for(;l<p.path.length;){let c=p.path[l];l===p.path.length-1?(u[c]=u[c]||{_errors:[]},u[c]._errors.push(t(p))):u[c]=u[c]||{_errors:[]},u=u[c],l++}}};return n(this),o}static assert(e){if(!(e instanceof r))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,L.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){let t={},o=[];for(let n of this.issues)n.path.length>0?(t[n.path[0]]=t[n.path[0]]||[],t[n.path[0]].push(e(n))):o.push(e(n));return{formErrors:o,fieldErrors:t}}get formErrors(){return this.flatten()}};Fe.create=r=>new Fe(r);var Ct=(r,e)=>{let t;switch(r.code){case h.invalid_type:r.received===b.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case h.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,L.jsonStringifyReplacer)}`;break;case h.unrecognized_keys:t=`Unrecognized key(s) in object: ${L.joinValues(r.keys,", ")}`;break;case h.invalid_union:t="Invalid input";break;case h.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${L.joinValues(r.options)}`;break;case h.invalid_enum_value:t=`Invalid enum value. Expected ${L.joinValues(r.options)}, received '${r.received}'`;break;case h.invalid_arguments:t="Invalid function arguments";break;case h.invalid_return_type:t="Invalid function return type";break;case h.invalid_date:t="Invalid date";break;case h.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:L.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case h.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case h.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case h.custom:t="Invalid input";break;case h.invalid_intersection_types:t="Intersection results could not be merged";break;case h.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case h.not_finite:t="Number must be finite";break;default:t=e.defaultError,L.assertNever(r)}return{message:t}},wp=Ct;function Zd(r){wp=r}function Wn(){return wp}var Cn=r=>{let{data:e,path:t,errorMaps:o,issueData:n}=r,s=[...t,...n.path||[]],p=S(d({},n),{path:s});if(n.message!==void 0)return S(d({},n),{path:s,message:n.message});let u="",l=o.filter(c=>!!c).slice().reverse();for(let c of l)u=c(p,{data:e,defaultError:u}).message;return S(d({},n),{path:s,message:u})},zd=[];function O(r,e){let t=Wn(),o=Cn({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===Ct?void 0:Ct].filter(n=>!!n)});r.common.issues.push(o)}var se=class r{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){let o=[];for(let n of t){if(n.status==="aborted")return R;n.status==="dirty"&&e.dirty(),o.push(n.value)}return{status:e.value,value:o}}static mergeObjectAsync(e,t){return Q(this,null,function*(){let o=[];for(let n of t){let s=yield n.key,p=yield n.value;o.push({key:s,value:p})}return r.mergeObjectSync(e,o)})}static mergeObjectSync(e,t){let o={};for(let n of t){let{key:s,value:p}=n;if(s.status==="aborted"||p.status==="aborted")return R;s.status==="dirty"&&e.dirty(),p.status==="dirty"&&e.dirty(),s.value!=="__proto__"&&(typeof p.value!="undefined"||n.alwaysSet)&&(o[s.value]=p.value)}return{status:e.value,value:o}}},R=Object.freeze({status:"aborted"}),Wt=r=>({status:"dirty",value:r}),pe=r=>({status:"valid",value:r}),Ao=r=>r.status==="aborted",No=r=>r.status==="dirty",at=r=>r.status==="valid",Kr=r=>typeof Promise!="undefined"&&r instanceof Promise;function An(r,e,t,o){if(t==="a"&&!o)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!o:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?o:t==="a"?o.call(r):o?o.value:e.get(r)}function Ep(r,e,t,o,n){if(o==="m")throw new TypeError("Private method is not writable");if(o==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return o==="a"?n.call(r,t):n?n.value=t:e.set(r,t),t}var _;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(_||(_={}));var $r,Jr,Se=class{constructor(e,t,o,n){this._cachedPath=[],this.parent=e,this.data=t,this._path=o,this._key=n}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},Ip=(r,e)=>{if(at(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let t=new Fe(r.common.issues);return this._error=t,this._error}}};function N(r){if(!r)return{};let{errorMap:e,invalid_type_error:t,required_error:o,description:n}=r;if(e&&(t||o))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:n}:{errorMap:(p,u)=>{var l,c;let{message:f}=r;return p.code==="invalid_enum_value"?{message:f!=null?f:u.defaultError}:typeof u.data=="undefined"?{message:(l=f!=null?f:o)!==null&&l!==void 0?l:u.defaultError}:p.code!=="invalid_type"?{message:u.defaultError}:{message:(c=f!=null?f:t)!==null&&c!==void 0?c:u.defaultError}},description:n}}var D=class{get description(){return this._def.description}_getType(e){return Ue(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Ue(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new se,ctx:{common:e.parent.common,data:e.data,parsedType:Ue(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(Kr(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let o=this.safeParse(e,t);if(o.success)return o.data;throw o.error}safeParse(e,t){var o;let n={common:{issues:[],async:(o=t==null?void 0:t.async)!==null&&o!==void 0?o:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Ue(e)},s=this._parseSync({data:e,path:n.path,parent:n});return Ip(n,s)}"~validate"(e){var t,o;let n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Ue(e)};if(!this["~standard"].async)try{let s=this._parseSync({data:e,path:[],parent:n});return at(s)?{value:s.value}:{issues:n.common.issues}}catch(s){!((o=(t=s==null?void 0:s.message)===null||t===void 0?void 0:t.toLowerCase())===null||o===void 0)&&o.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:n}).then(s=>at(s)?{value:s.value}:{issues:n.common.issues})}parseAsync(e,t){return Q(this,null,function*(){let o=yield this.safeParseAsync(e,t);if(o.success)return o.data;throw o.error})}safeParseAsync(e,t){return Q(this,null,function*(){let o={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Ue(e)},n=this._parse({data:e,path:o.path,parent:o}),s=yield Kr(n)?n:Promise.resolve(n);return Ip(o,s)})}refine(e,t){let o=n=>typeof t=="string"||typeof t=="undefined"?{message:t}:typeof t=="function"?t(n):t;return this._refinement((n,s)=>{let p=e(n),u=()=>s.addIssue(d({code:h.custom},o(n)));return typeof Promise!="undefined"&&p instanceof Promise?p.then(l=>l?!0:(u(),!1)):p?!0:(u(),!1)})}refinement(e,t){return this._refinement((o,n)=>e(o)?!0:(n.addIssue(typeof t=="function"?t(o,n):t),!1))}_refinement(e){return new xe({schema:this,typeName:M.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:t=>this["~validate"](t)}}optional(){return Oe.create(this,this._def)}nullable(){return Ge.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Ve.create(this)}promise(){return Qe.create(this,this._def)}or(e){return lt.create([this,e],this._def)}and(e){return ct.create(this,e,this._def)}transform(e){return new xe(S(d({},N(this._def)),{schema:this,typeName:M.ZodEffects,effect:{type:"transform",transform:e}}))}default(e){let t=typeof e=="function"?e:()=>e;return new gt(S(d({},N(this._def)),{innerType:this,defaultValue:t,typeName:M.ZodDefault}))}brand(){return new Yr(d({typeName:M.ZodBranded,type:this},N(this._def)))}catch(e){let t=typeof e=="function"?e:()=>e;return new Ft(S(d({},N(this._def)),{innerType:this,catchValue:t,typeName:M.ZodCatch}))}describe(e){let t=this.constructor;return new t(S(d({},this._def),{description:e}))}pipe(e){return Xr.create(this,e)}readonly(){return xt.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Hd=/^c[^\s-]{8,}$/i,qd=/^[0-9a-z]+$/,Qd=/^[0-9A-HJKMNP-TV-Z]{26}$/i,$d=/^[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}$/i,Jd=/^[a-z0-9_-]{21}$/i,Kd=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Yd=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Xd=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,el="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Wo,tl=/^(?:(?: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])$/,rl=/^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/,nl=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,al=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,ol=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,sl=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Mp="((\\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])))",il=new RegExp(`^${Mp}$`);function Rp(r){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return r.precision?e=`${e}\\.\\d{${r.precision}}`:r.precision==null&&(e=`${e}(\\.\\d+)?`),e}function pl(r){return new RegExp(`^${Rp(r)}$`)}function Gp(r){let e=`${Mp}T${Rp(r)}`,t=[];return t.push(r.local?"Z?":"Z"),r.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function ul(r,e){return!!((e==="v4"||!e)&&tl.test(r)||(e==="v6"||!e)&&nl.test(r))}function dl(r,e){if(!Kd.test(r))return!1;try{let[t]=r.split("."),o=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),n=JSON.parse(atob(o));return!(typeof n!="object"||n===null||!n.typ||!n.alg||e&&n.alg!==e)}catch(t){return!1}}function ll(r,e){return!!((e==="v4"||!e)&&rl.test(r)||(e==="v6"||!e)&&al.test(r))}var He=class r extends D{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==b.string){let s=this._getOrReturnCtx(e);return O(s,{code:h.invalid_type,expected:b.string,received:s.parsedType}),R}let o=new se,n;for(let s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(n=this._getOrReturnCtx(e,n),O(n,{code:h.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),o.dirty());else if(s.kind==="max")e.data.length>s.value&&(n=this._getOrReturnCtx(e,n),O(n,{code:h.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),o.dirty());else if(s.kind==="length"){let p=e.data.length>s.value,u=e.data.length<s.value;(p||u)&&(n=this._getOrReturnCtx(e,n),p?O(n,{code:h.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):u&&O(n,{code:h.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),o.dirty())}else if(s.kind==="email")Xd.test(e.data)||(n=this._getOrReturnCtx(e,n),O(n,{validation:"email",code:h.invalid_string,message:s.message}),o.dirty());else if(s.kind==="emoji")Wo||(Wo=new RegExp(el,"u")),Wo.test(e.data)||(n=this._getOrReturnCtx(e,n),O(n,{validation:"emoji",code:h.invalid_string,message:s.message}),o.dirty());else if(s.kind==="uuid")$d.test(e.data)||(n=this._getOrReturnCtx(e,n),O(n,{validation:"uuid",code:h.invalid_string,message:s.message}),o.dirty());else if(s.kind==="nanoid")Jd.test(e.data)||(n=this._getOrReturnCtx(e,n),O(n,{validation:"nanoid",code:h.invalid_string,message:s.message}),o.dirty());else if(s.kind==="cuid")Hd.test(e.data)||(n=this._getOrReturnCtx(e,n),O(n,{validation:"cuid",code:h.invalid_string,message:s.message}),o.dirty());else if(s.kind==="cuid2")qd.test(e.data)||(n=this._getOrReturnCtx(e,n),O(n,{validation:"cuid2",code:h.invalid_string,message:s.message}),o.dirty());else if(s.kind==="ulid")Qd.test(e.data)||(n=this._getOrReturnCtx(e,n),O(n,{validation:"ulid",code:h.invalid_string,message:s.message}),o.dirty());else if(s.kind==="url")try{new URL(e.data)}catch(p){n=this._getOrReturnCtx(e,n),O(n,{validation:"url",code:h.invalid_string,message:s.message}),o.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),O(n,{validation:"regex",code:h.invalid_string,message:s.message}),o.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(n=this._getOrReturnCtx(e,n),O(n,{code:h.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),o.dirty()):s.kind==="toLowerCase"?e.data=e.data.toLowerCase():s.kind==="toUpperCase"?e.data=e.data.toUpperCase():s.kind==="startsWith"?e.data.startsWith(s.value)||(n=this._getOrReturnCtx(e,n),O(n,{code:h.invalid_string,validation:{startsWith:s.value},message:s.message}),o.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(n=this._getOrReturnCtx(e,n),O(n,{code:h.invalid_string,validation:{endsWith:s.value},message:s.message}),o.dirty()):s.kind==="datetime"?Gp(s).test(e.data)||(n=this._getOrReturnCtx(e,n),O(n,{code:h.invalid_string,validation:"datetime",message:s.message}),o.dirty()):s.kind==="date"?il.test(e.data)||(n=this._getOrReturnCtx(e,n),O(n,{code:h.invalid_string,validation:"date",message:s.message}),o.dirty()):s.kind==="time"?pl(s).test(e.data)||(n=this._getOrReturnCtx(e,n),O(n,{code:h.invalid_string,validation:"time",message:s.message}),o.dirty()):s.kind==="duration"?Yd.test(e.data)||(n=this._getOrReturnCtx(e,n),O(n,{validation:"duration",code:h.invalid_string,message:s.message}),o.dirty()):s.kind==="ip"?ul(e.data,s.version)||(n=this._getOrReturnCtx(e,n),O(n,{validation:"ip",code:h.invalid_string,message:s.message}),o.dirty()):s.kind==="jwt"?dl(e.data,s.alg)||(n=this._getOrReturnCtx(e,n),O(n,{validation:"jwt",code:h.invalid_string,message:s.message}),o.dirty()):s.kind==="cidr"?ll(e.data,s.version)||(n=this._getOrReturnCtx(e,n),O(n,{validation:"cidr",code:h.invalid_string,message:s.message}),o.dirty()):s.kind==="base64"?ol.test(e.data)||(n=this._getOrReturnCtx(e,n),O(n,{validation:"base64",code:h.invalid_string,message:s.message}),o.dirty()):s.kind==="base64url"?sl.test(e.data)||(n=this._getOrReturnCtx(e,n),O(n,{validation:"base64url",code:h.invalid_string,message:s.message}),o.dirty()):L.assertNever(s);return{status:o.value,value:e.data}}_regex(e,t,o){return this.refinement(n=>e.test(n),d({validation:t,code:h.invalid_string},_.errToObj(o)))}_addCheck(e){return new r(S(d({},this._def),{checks:[...this._def.checks,e]}))}email(e){return this._addCheck(d({kind:"email"},_.errToObj(e)))}url(e){return this._addCheck(d({kind:"url"},_.errToObj(e)))}emoji(e){return this._addCheck(d({kind:"emoji"},_.errToObj(e)))}uuid(e){return this._addCheck(d({kind:"uuid"},_.errToObj(e)))}nanoid(e){return this._addCheck(d({kind:"nanoid"},_.errToObj(e)))}cuid(e){return this._addCheck(d({kind:"cuid"},_.errToObj(e)))}cuid2(e){return this._addCheck(d({kind:"cuid2"},_.errToObj(e)))}ulid(e){return this._addCheck(d({kind:"ulid"},_.errToObj(e)))}base64(e){return this._addCheck(d({kind:"base64"},_.errToObj(e)))}base64url(e){return this._addCheck(d({kind:"base64url"},_.errToObj(e)))}jwt(e){return this._addCheck(d({kind:"jwt"},_.errToObj(e)))}ip(e){return this._addCheck(d({kind:"ip"},_.errToObj(e)))}cidr(e){return this._addCheck(d({kind:"cidr"},_.errToObj(e)))}datetime(e){var t,o;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck(d({kind:"datetime",precision:typeof(e==null?void 0:e.precision)=="undefined"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,local:(o=e==null?void 0:e.local)!==null&&o!==void 0?o:!1},_.errToObj(e==null?void 0:e.message)))}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck(d({kind:"time",precision:typeof(e==null?void 0:e.precision)=="undefined"?null:e==null?void 0:e.precision},_.errToObj(e==null?void 0:e.message)))}duration(e){return this._addCheck(d({kind:"duration"},_.errToObj(e)))}regex(e,t){return this._addCheck(d({kind:"regex",regex:e},_.errToObj(t)))}includes(e,t){return this._addCheck(d({kind:"includes",value:e,position:t==null?void 0:t.position},_.errToObj(t==null?void 0:t.message)))}startsWith(e,t){return this._addCheck(d({kind:"startsWith",value:e},_.errToObj(t)))}endsWith(e,t){return this._addCheck(d({kind:"endsWith",value:e},_.errToObj(t)))}min(e,t){return this._addCheck(d({kind:"min",value:e},_.errToObj(t)))}max(e,t){return this._addCheck(d({kind:"max",value:e},_.errToObj(t)))}length(e,t){return this._addCheck(d({kind:"length",value:e},_.errToObj(t)))}nonempty(e){return this.min(1,_.errToObj(e))}trim(){return new r(S(d({},this._def),{checks:[...this._def.checks,{kind:"trim"}]}))}toLowerCase(){return new r(S(d({},this._def),{checks:[...this._def.checks,{kind:"toLowerCase"}]}))}toUpperCase(){return new r(S(d({},this._def),{checks:[...this._def.checks,{kind:"toUpperCase"}]}))}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};He.create=r=>{var e;return new He(d({checks:[],typeName:M.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1},N(r)))};function cl(r,e){let t=(r.toString().split(".")[1]||"").length,o=(e.toString().split(".")[1]||"").length,n=t>o?t:o,s=parseInt(r.toFixed(n).replace(".","")),p=parseInt(e.toFixed(n).replace(".",""));return s%p/Math.pow(10,n)}var ot=class r extends D{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==b.number){let s=this._getOrReturnCtx(e);return O(s,{code:h.invalid_type,expected:b.number,received:s.parsedType}),R}let o,n=new se;for(let s of this._def.checks)s.kind==="int"?L.isInteger(e.data)||(o=this._getOrReturnCtx(e,o),O(o,{code:h.invalid_type,expected:"integer",received:"float",message:s.message}),n.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(o=this._getOrReturnCtx(e,o),O(o,{code:h.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),n.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(o=this._getOrReturnCtx(e,o),O(o,{code:h.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),n.dirty()):s.kind==="multipleOf"?cl(e.data,s.value)!==0&&(o=this._getOrReturnCtx(e,o),O(o,{code:h.not_multiple_of,multipleOf:s.value,message:s.message}),n.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(o=this._getOrReturnCtx(e,o),O(o,{code:h.not_finite,message:s.message}),n.dirty()):L.assertNever(s);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,_.toString(t))}gt(e,t){return this.setLimit("min",e,!1,_.toString(t))}lte(e,t){return this.setLimit("max",e,!0,_.toString(t))}lt(e,t){return this.setLimit("max",e,!1,_.toString(t))}setLimit(e,t,o,n){return new r(S(d({},this._def),{checks:[...this._def.checks,{kind:e,value:t,inclusive:o,message:_.toString(n)}]}))}_addCheck(e){return new r(S(d({},this._def),{checks:[...this._def.checks,e]}))}int(e){return this._addCheck({kind:"int",message:_.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:_.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:_.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:_.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:_.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:_.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:_.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:_.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:_.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&L.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let o of this._def.checks){if(o.kind==="finite"||o.kind==="int"||o.kind==="multipleOf")return!0;o.kind==="min"?(t===null||o.value>t)&&(t=o.value):o.kind==="max"&&(e===null||o.value<e)&&(e=o.value)}return Number.isFinite(t)&&Number.isFinite(e)}};ot.create=r=>new ot(d({checks:[],typeName:M.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1},N(r)));var st=class r extends D{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch(s){return this._getInvalidInput(e)}if(this._getType(e)!==b.bigint)return this._getInvalidInput(e);let o,n=new se;for(let s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(o=this._getOrReturnCtx(e,o),O(o,{code:h.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),n.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(o=this._getOrReturnCtx(e,o),O(o,{code:h.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),n.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(o=this._getOrReturnCtx(e,o),O(o,{code:h.not_multiple_of,multipleOf:s.value,message:s.message}),n.dirty()):L.assertNever(s);return{status:n.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return O(t,{code:h.invalid_type,expected:b.bigint,received:t.parsedType}),R}gte(e,t){return this.setLimit("min",e,!0,_.toString(t))}gt(e,t){return this.setLimit("min",e,!1,_.toString(t))}lte(e,t){return this.setLimit("max",e,!0,_.toString(t))}lt(e,t){return this.setLimit("max",e,!1,_.toString(t))}setLimit(e,t,o,n){return new r(S(d({},this._def),{checks:[...this._def.checks,{kind:e,value:t,inclusive:o,message:_.toString(n)}]}))}_addCheck(e){return new r(S(d({},this._def),{checks:[...this._def.checks,e]}))}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:_.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:_.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:_.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:_.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:_.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};st.create=r=>{var e;return new st(d({checks:[],typeName:M.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1},N(r)))};var it=class extends D{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==b.boolean){let o=this._getOrReturnCtx(e);return O(o,{code:h.invalid_type,expected:b.boolean,received:o.parsedType}),R}return pe(e.data)}};it.create=r=>new it(d({typeName:M.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1},N(r)));var pt=class r extends D{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==b.date){let s=this._getOrReturnCtx(e);return O(s,{code:h.invalid_type,expected:b.date,received:s.parsedType}),R}if(isNaN(e.data.getTime())){let s=this._getOrReturnCtx(e);return O(s,{code:h.invalid_date}),R}let o=new se,n;for(let s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(n=this._getOrReturnCtx(e,n),O(n,{code:h.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),o.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(n=this._getOrReturnCtx(e,n),O(n,{code:h.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),o.dirty()):L.assertNever(s);return{status:o.value,value:new Date(e.data.getTime())}}_addCheck(e){return new r(S(d({},this._def),{checks:[...this._def.checks,e]}))}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:_.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:_.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}};pt.create=r=>new pt(d({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:M.ZodDate},N(r)));var At=class extends D{_parse(e){if(this._getType(e)!==b.symbol){let o=this._getOrReturnCtx(e);return O(o,{code:h.invalid_type,expected:b.symbol,received:o.parsedType}),R}return pe(e.data)}};At.create=r=>new At(d({typeName:M.ZodSymbol},N(r)));var ut=class extends D{_parse(e){if(this._getType(e)!==b.undefined){let o=this._getOrReturnCtx(e);return O(o,{code:h.invalid_type,expected:b.undefined,received:o.parsedType}),R}return pe(e.data)}};ut.create=r=>new ut(d({typeName:M.ZodUndefined},N(r)));var dt=class extends D{_parse(e){if(this._getType(e)!==b.null){let o=this._getOrReturnCtx(e);return O(o,{code:h.invalid_type,expected:b.null,received:o.parsedType}),R}return pe(e.data)}};dt.create=r=>new dt(d({typeName:M.ZodNull},N(r)));var qe=class extends D{constructor(){super(...arguments),this._any=!0}_parse(e){return pe(e.data)}};qe.create=r=>new qe(d({typeName:M.ZodAny},N(r)));var je=class extends D{constructor(){super(...arguments),this._unknown=!0}_parse(e){return pe(e.data)}};je.create=r=>new je(d({typeName:M.ZodUnknown},N(r)));var we=class extends D{_parse(e){let t=this._getOrReturnCtx(e);return O(t,{code:h.invalid_type,expected:b.never,received:t.parsedType}),R}};we.create=r=>new we(d({typeName:M.ZodNever},N(r)));var Nt=class extends D{_parse(e){if(this._getType(e)!==b.undefined){let o=this._getOrReturnCtx(e);return O(o,{code:h.invalid_type,expected:b.void,received:o.parsedType}),R}return pe(e.data)}};Nt.create=r=>new Nt(d({typeName:M.ZodVoid},N(r)));var Ve=class r extends D{_parse(e){let{ctx:t,status:o}=this._processInputParams(e),n=this._def;if(t.parsedType!==b.array)return O(t,{code:h.invalid_type,expected:b.array,received:t.parsedType}),R;if(n.exactLength!==null){let p=t.data.length>n.exactLength.value,u=t.data.length<n.exactLength.value;(p||u)&&(O(t,{code:p?h.too_big:h.too_small,minimum:u?n.exactLength.value:void 0,maximum:p?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),o.dirty())}if(n.minLength!==null&&t.data.length<n.minLength.value&&(O(t,{code:h.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),o.dirty()),n.maxLength!==null&&t.data.length>n.maxLength.value&&(O(t,{code:h.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),o.dirty()),t.common.async)return Promise.all([...t.data].map((p,u)=>n.type._parseAsync(new Se(t,p,t.path,u)))).then(p=>se.mergeArray(o,p));let s=[...t.data].map((p,u)=>n.type._parseSync(new Se(t,p,t.path,u)));return se.mergeArray(o,s)}get element(){return this._def.type}min(e,t){return new r(S(d({},this._def),{minLength:{value:e,message:_.toString(t)}}))}max(e,t){return new r(S(d({},this._def),{maxLength:{value:e,message:_.toString(t)}}))}length(e,t){return new r(S(d({},this._def),{exactLength:{value:e,message:_.toString(t)}}))}nonempty(e){return this.min(1,e)}};Ve.create=(r,e)=>new Ve(d({type:r,minLength:null,maxLength:null,exactLength:null,typeName:M.ZodArray},N(e)));function Gt(r){if(r instanceof ce){let e={};for(let t in r.shape){let o=r.shape[t];e[t]=Oe.create(Gt(o))}return new ce(S(d({},r._def),{shape:()=>e}))}else return r instanceof Ve?new Ve(S(d({},r._def),{type:Gt(r.element)})):r instanceof Oe?Oe.create(Gt(r.unwrap())):r instanceof Ge?Ge.create(Gt(r.unwrap())):r instanceof Re?Re.create(r.items.map(e=>Gt(e))):r}var ce=class r extends D{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),t=L.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==b.object){let c=this._getOrReturnCtx(e);return O(c,{code:h.invalid_type,expected:b.object,received:c.parsedType}),R}let{status:o,ctx:n}=this._processInputParams(e),{shape:s,keys:p}=this._getCached(),u=[];if(!(this._def.catchall instanceof we&&this._def.unknownKeys==="strip"))for(let c in n.data)p.includes(c)||u.push(c);let l=[];for(let c of p){let f=s[c],x=n.data[c];l.push({key:{status:"valid",value:c},value:f._parse(new Se(n,x,n.path,c)),alwaysSet:c in n.data})}if(this._def.catchall instanceof we){let c=this._def.unknownKeys;if(c==="passthrough")for(let f of u)l.push({key:{status:"valid",value:f},value:{status:"valid",value:n.data[f]}});else if(c==="strict")u.length>0&&(O(n,{code:h.unrecognized_keys,keys:u}),o.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let c=this._def.catchall;for(let f of u){let x=n.data[f];l.push({key:{status:"valid",value:f},value:c._parse(new Se(n,x,n.path,f)),alwaysSet:f in n.data})}}return n.common.async?Promise.resolve().then(()=>Q(this,null,function*(){let c=[];for(let f of l){let x=yield f.key,y=yield f.value;c.push({key:x,value:y,alwaysSet:f.alwaysSet})}return c})).then(c=>se.mergeObjectSync(o,c)):se.mergeObjectSync(o,l)}get shape(){return this._def.shape()}strict(e){return _.errToObj,new r(d(S(d({},this._def),{unknownKeys:"strict"}),e!==void 0?{errorMap:(t,o)=>{var n,s,p,u;let l=(p=(s=(n=this._def).errorMap)===null||s===void 0?void 0:s.call(n,t,o).message)!==null&&p!==void 0?p:o.defaultError;return t.code==="unrecognized_keys"?{message:(u=_.errToObj(e).message)!==null&&u!==void 0?u:l}:{message:l}}}:{}))}strip(){return new r(S(d({},this._def),{unknownKeys:"strip"}))}passthrough(){return new r(S(d({},this._def),{unknownKeys:"passthrough"}))}extend(e){return new r(S(d({},this._def),{shape:()=>d(d({},this._def.shape()),e)}))}merge(e){return new r({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>d(d({},this._def.shape()),e._def.shape()),typeName:M.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new r(S(d({},this._def),{catchall:e}))}pick(e){let t={};return L.objectKeys(e).forEach(o=>{e[o]&&this.shape[o]&&(t[o]=this.shape[o])}),new r(S(d({},this._def),{shape:()=>t}))}omit(e){let t={};return L.objectKeys(this.shape).forEach(o=>{e[o]||(t[o]=this.shape[o])}),new r(S(d({},this._def),{shape:()=>t}))}deepPartial(){return Gt(this)}partial(e){let t={};return L.objectKeys(this.shape).forEach(o=>{let n=this.shape[o];e&&!e[o]?t[o]=n:t[o]=n.optional()}),new r(S(d({},this._def),{shape:()=>t}))}required(e){let t={};return L.objectKeys(this.shape).forEach(o=>{if(e&&!e[o])t[o]=this.shape[o];else{let s=this.shape[o];for(;s instanceof Oe;)s=s._def.innerType;t[o]=s}}),new r(S(d({},this._def),{shape:()=>t}))}keyof(){return Wp(L.objectKeys(this.shape))}};ce.create=(r,e)=>new ce(d({shape:()=>r,unknownKeys:"strip",catchall:we.create(),typeName:M.ZodObject},N(e)));ce.strictCreate=(r,e)=>new ce(d({shape:()=>r,unknownKeys:"strict",catchall:we.create(),typeName:M.ZodObject},N(e)));ce.lazycreate=(r,e)=>new ce(d({shape:r,unknownKeys:"strip",catchall:we.create(),typeName:M.ZodObject},N(e)));var lt=class extends D{_parse(e){let{ctx:t}=this._processInputParams(e),o=this._def.options;function n(s){for(let u of s)if(u.result.status==="valid")return u.result;for(let u of s)if(u.result.status==="dirty")return t.common.issues.push(...u.ctx.common.issues),u.result;let p=s.map(u=>new Fe(u.ctx.common.issues));return O(t,{code:h.invalid_union,unionErrors:p}),R}if(t.common.async)return Promise.all(o.map(s=>Q(this,null,function*(){let p=S(d({},t),{common:S(d({},t.common),{issues:[]}),parent:null});return{result:yield s._parseAsync({data:t.data,path:t.path,parent:p}),ctx:p}}))).then(n);{let s,p=[];for(let l of o){let c=S(d({},t),{common:S(d({},t.common),{issues:[]}),parent:null}),f=l._parseSync({data:t.data,path:t.path,parent:c});if(f.status==="valid")return f;f.status==="dirty"&&!s&&(s={result:f,ctx:c}),c.common.issues.length&&p.push(c.common.issues)}if(s)return t.common.issues.push(...s.ctx.common.issues),s.result;let u=p.map(l=>new Fe(l));return O(t,{code:h.invalid_union,unionErrors:u}),R}}get options(){return this._def.options}};lt.create=(r,e)=>new lt(d({options:r,typeName:M.ZodUnion},N(e)));var Pe=r=>r instanceof ft?Pe(r.schema):r instanceof xe?Pe(r.innerType()):r instanceof mt?[r.value]:r instanceof Tt?r.options:r instanceof ht?L.objectValues(r.enum):r instanceof gt?Pe(r._def.innerType):r instanceof ut?[void 0]:r instanceof dt?[null]:r instanceof Oe?[void 0,...Pe(r.unwrap())]:r instanceof Ge?[null,...Pe(r.unwrap())]:r instanceof Yr||r instanceof xt?Pe(r.unwrap()):r instanceof Ft?Pe(r._def.innerType):[],Nn=class r extends D{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==b.object)return O(t,{code:h.invalid_type,expected:b.object,received:t.parsedType}),R;let o=this.discriminator,n=t.data[o],s=this.optionsMap.get(n);return s?t.common.async?s._parseAsync({data:t.data,path:t.path,parent:t}):s._parseSync({data:t.data,path:t.path,parent:t}):(O(t,{code:h.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[o]}),R)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,o){let n=new Map;for(let s of t){let p=Pe(s.shape[e]);if(!p.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let u of p){if(n.has(u))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(u)}`);n.set(u,s)}}return new r(d({typeName:M.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:n},N(o)))}};function Do(r,e){let t=Ue(r),o=Ue(e);if(r===e)return{valid:!0,data:r};if(t===b.object&&o===b.object){let n=L.objectKeys(e),s=L.objectKeys(r).filter(u=>n.indexOf(u)!==-1),p=d(d({},r),e);for(let u of s){let l=Do(r[u],e[u]);if(!l.valid)return{valid:!1};p[u]=l.data}return{valid:!0,data:p}}else if(t===b.array&&o===b.array){if(r.length!==e.length)return{valid:!1};let n=[];for(let s=0;s<r.length;s++){let p=r[s],u=e[s],l=Do(p,u);if(!l.valid)return{valid:!1};n.push(l.data)}return{valid:!0,data:n}}else return t===b.date&&o===b.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}var ct=class extends D{_parse(e){let{status:t,ctx:o}=this._processInputParams(e),n=(s,p)=>{if(Ao(s)||Ao(p))return R;let u=Do(s.value,p.value);return u.valid?((No(s)||No(p))&&t.dirty(),{status:t.value,value:u.data}):(O(o,{code:h.invalid_intersection_types}),R)};return o.common.async?Promise.all([this._def.left._parseAsync({data:o.data,path:o.path,parent:o}),this._def.right._parseAsync({data:o.data,path:o.path,parent:o})]).then(([s,p])=>n(s,p)):n(this._def.left._parseSync({data:o.data,path:o.path,parent:o}),this._def.right._parseSync({data:o.data,path:o.path,parent:o}))}};ct.create=(r,e,t)=>new ct(d({left:r,right:e,typeName:M.ZodIntersection},N(t)));var Re=class r extends D{_parse(e){let{status:t,ctx:o}=this._processInputParams(e);if(o.parsedType!==b.array)return O(o,{code:h.invalid_type,expected:b.array,received:o.parsedType}),R;if(o.data.length<this._def.items.length)return O(o,{code:h.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),R;!this._def.rest&&o.data.length>this._def.items.length&&(O(o,{code:h.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());let s=[...o.data].map((p,u)=>{let l=this._def.items[u]||this._def.rest;return l?l._parse(new Se(o,p,o.path,u)):null}).filter(p=>!!p);return o.common.async?Promise.all(s).then(p=>se.mergeArray(t,p)):se.mergeArray(t,s)}get items(){return this._def.items}rest(e){return new r(S(d({},this._def),{rest:e}))}};Re.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Re(d({items:r,typeName:M.ZodTuple,rest:null},N(e)))};var Dn=class r extends D{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:o}=this._processInputParams(e);if(o.parsedType!==b.object)return O(o,{code:h.invalid_type,expected:b.object,received:o.parsedType}),R;let n=[],s=this._def.keyType,p=this._def.valueType;for(let u in o.data)n.push({key:s._parse(new Se(o,u,o.path,u)),value:p._parse(new Se(o,o.data[u],o.path,u)),alwaysSet:u in o.data});return o.common.async?se.mergeObjectAsync(t,n):se.mergeObjectSync(t,n)}get element(){return this._def.valueType}static create(e,t,o){return t instanceof D?new r(d({keyType:e,valueType:t,typeName:M.ZodRecord},N(o))):new r(d({keyType:He.create(),valueType:e,typeName:M.ZodRecord},N(t)))}},Dt=class extends D{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:o}=this._processInputParams(e);if(o.parsedType!==b.map)return O(o,{code:h.invalid_type,expected:b.map,received:o.parsedType}),R;let n=this._def.keyType,s=this._def.valueType,p=[...o.data.entries()].map(([u,l],c)=>({key:n._parse(new Se(o,u,o.path,[c,"key"])),value:s._parse(new Se(o,l,o.path,[c,"value"]))}));if(o.common.async){let u=new Map;return Promise.resolve().then(()=>Q(this,null,function*(){for(let l of p){let c=yield l.key,f=yield l.value;if(c.status==="aborted"||f.status==="aborted")return R;(c.status==="dirty"||f.status==="dirty")&&t.dirty(),u.set(c.value,f.value)}return{status:t.value,value:u}}))}else{let u=new Map;for(let l of p){let c=l.key,f=l.value;if(c.status==="aborted"||f.status==="aborted")return R;(c.status==="dirty"||f.status==="dirty")&&t.dirty(),u.set(c.value,f.value)}return{status:t.value,value:u}}}};Dt.create=(r,e,t)=>new Dt(d({valueType:e,keyType:r,typeName:M.ZodMap},N(t)));var Bt=class r extends D{_parse(e){let{status:t,ctx:o}=this._processInputParams(e);if(o.parsedType!==b.set)return O(o,{code:h.invalid_type,expected:b.set,received:o.parsedType}),R;let n=this._def;n.minSize!==null&&o.data.size<n.minSize.value&&(O(o,{code:h.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),t.dirty()),n.maxSize!==null&&o.data.size>n.maxSize.value&&(O(o,{code:h.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),t.dirty());let s=this._def.valueType;function p(l){let c=new Set;for(let f of l){if(f.status==="aborted")return R;f.status==="dirty"&&t.dirty(),c.add(f.value)}return{status:t.value,value:c}}let u=[...o.data.values()].map((l,c)=>s._parse(new Se(o,l,o.path,c)));return o.common.async?Promise.all(u).then(l=>p(l)):p(u)}min(e,t){return new r(S(d({},this._def),{minSize:{value:e,message:_.toString(t)}}))}max(e,t){return new r(S(d({},this._def),{maxSize:{value:e,message:_.toString(t)}}))}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};Bt.create=(r,e)=>new Bt(d({valueType:r,minSize:null,maxSize:null,typeName:M.ZodSet},N(e)));var Bn=class r extends D{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==b.function)return O(t,{code:h.invalid_type,expected:b.function,received:t.parsedType}),R;function o(u,l){return Cn({data:u,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Wn(),Ct].filter(c=>!!c),issueData:{code:h.invalid_arguments,argumentsError:l}})}function n(u,l){return Cn({data:u,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Wn(),Ct].filter(c=>!!c),issueData:{code:h.invalid_return_type,returnTypeError:l}})}let s={errorMap:t.common.contextualErrorMap},p=t.data;if(this._def.returns instanceof Qe){let u=this;return pe(function(...l){return Q(this,null,function*(){let c=new Fe([]),f=yield u._def.args.parseAsync(l,s).catch(I=>{throw c.addIssue(o(l,I)),c}),x=yield Reflect.apply(p,this,f);return yield u._def.returns._def.type.parseAsync(x,s).catch(I=>{throw c.addIssue(n(x,I)),c})})})}else{let u=this;return pe(function(...l){let c=u._def.args.safeParse(l,s);if(!c.success)throw new Fe([o(l,c.error)]);let f=Reflect.apply(p,this,c.data),x=u._def.returns.safeParse(f,s);if(!x.success)throw new Fe([n(f,x.error)]);return x.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new r(S(d({},this._def),{args:Re.create(e).rest(je.create())}))}returns(e){return new r(S(d({},this._def),{returns:e}))}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,o){return new r(d({args:e||Re.create([]).rest(je.create()),returns:t||je.create(),typeName:M.ZodFunction},N(o)))}},ft=class extends D{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};ft.create=(r,e)=>new ft(d({getter:r,typeName:M.ZodLazy},N(e)));var mt=class extends D{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return O(t,{received:t.data,code:h.invalid_literal,expected:this._def.value}),R}return{status:"valid",value:e.data}}get value(){return this._def.value}};mt.create=(r,e)=>new mt(d({value:r,typeName:M.ZodLiteral},N(e)));function Wp(r,e){return new Tt(d({values:r,typeName:M.ZodEnum},N(e)))}var Tt=class r extends D{constructor(){super(...arguments),$r.set(this,void 0)}_parse(e){if(typeof e.data!="string"){let t=this._getOrReturnCtx(e),o=this._def.values;return O(t,{expected:L.joinValues(o),received:t.parsedType,code:h.invalid_type}),R}if(An(this,$r,"f")||Ep(this,$r,new Set(this._def.values),"f"),!An(this,$r,"f").has(e.data)){let t=this._getOrReturnCtx(e),o=this._def.values;return O(t,{received:t.data,code:h.invalid_enum_value,options:o}),R}return pe(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return r.create(e,d(d({},this._def),t))}exclude(e,t=this._def){return r.create(this.options.filter(o=>!e.includes(o)),d(d({},this._def),t))}};$r=new WeakMap;Tt.create=Wp;var ht=class extends D{constructor(){super(...arguments),Jr.set(this,void 0)}_parse(e){let t=L.getValidEnumValues(this._def.values),o=this._getOrReturnCtx(e);if(o.parsedType!==b.string&&o.parsedType!==b.number){let n=L.objectValues(t);return O(o,{expected:L.joinValues(n),received:o.parsedType,code:h.invalid_type}),R}if(An(this,Jr,"f")||Ep(this,Jr,new Set(L.getValidEnumValues(this._def.values)),"f"),!An(this,Jr,"f").has(e.data)){let n=L.objectValues(t);return O(o,{received:o.data,code:h.invalid_enum_value,options:n}),R}return pe(e.data)}get enum(){return this._def.values}};Jr=new WeakMap;ht.create=(r,e)=>new ht(d({values:r,typeName:M.ZodNativeEnum},N(e)));var Qe=class extends D{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==b.promise&&t.common.async===!1)return O(t,{code:h.invalid_type,expected:b.promise,received:t.parsedType}),R;let o=t.parsedType===b.promise?t.data:Promise.resolve(t.data);return pe(o.then(n=>this._def.type.parseAsync(n,{path:t.path,errorMap:t.common.contextualErrorMap})))}};Qe.create=(r,e)=>new Qe(d({type:r,typeName:M.ZodPromise},N(e)));var xe=class extends D{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===M.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:o}=this._processInputParams(e),n=this._def.effect||null,s={addIssue:p=>{O(o,p),p.fatal?t.abort():t.dirty()},get path(){return o.path}};if(s.addIssue=s.addIssue.bind(s),n.type==="preprocess"){let p=n.transform(o.data,s);if(o.common.async)return Promise.resolve(p).then(u=>Q(this,null,function*(){if(t.value==="aborted")return R;let l=yield this._def.schema._parseAsync({data:u,path:o.path,parent:o});return l.status==="aborted"?R:l.status==="dirty"||t.value==="dirty"?Wt(l.value):l}));{if(t.value==="aborted")return R;let u=this._def.schema._parseSync({data:p,path:o.path,parent:o});return u.status==="aborted"?R:u.status==="dirty"||t.value==="dirty"?Wt(u.value):u}}if(n.type==="refinement"){let p=u=>{let l=n.refinement(u,s);if(o.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return u};if(o.common.async===!1){let u=this._def.schema._parseSync({data:o.data,path:o.path,parent:o});return u.status==="aborted"?R:(u.status==="dirty"&&t.dirty(),p(u.value),{status:t.value,value:u.value})}else return this._def.schema._parseAsync({data:o.data,path:o.path,parent:o}).then(u=>u.status==="aborted"?R:(u.status==="dirty"&&t.dirty(),p(u.value).then(()=>({status:t.value,value:u.value}))))}if(n.type==="transform")if(o.common.async===!1){let p=this._def.schema._parseSync({data:o.data,path:o.path,parent:o});if(!at(p))return p;let u=n.transform(p.value,s);if(u instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:u}}else return this._def.schema._parseAsync({data:o.data,path:o.path,parent:o}).then(p=>at(p)?Promise.resolve(n.transform(p.value,s)).then(u=>({status:t.value,value:u})):p);L.assertNever(n)}};xe.create=(r,e,t)=>new xe(d({schema:r,typeName:M.ZodEffects,effect:e},N(t)));xe.createWithPreprocess=(r,e,t)=>new xe(d({schema:e,effect:{type:"preprocess",transform:r},typeName:M.ZodEffects},N(t)));var Oe=class extends D{_parse(e){return this._getType(e)===b.undefined?pe(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Oe.create=(r,e)=>new Oe(d({innerType:r,typeName:M.ZodOptional},N(e)));var Ge=class extends D{_parse(e){return this._getType(e)===b.null?pe(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Ge.create=(r,e)=>new Ge(d({innerType:r,typeName:M.ZodNullable},N(e)));var gt=class extends D{_parse(e){let{ctx:t}=this._processInputParams(e),o=t.data;return t.parsedType===b.undefined&&(o=this._def.defaultValue()),this._def.innerType._parse({data:o,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};gt.create=(r,e)=>new gt(d({innerType:r,typeName:M.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default},N(e)));var Ft=class extends D{_parse(e){let{ctx:t}=this._processInputParams(e),o=S(d({},t),{common:S(d({},t.common),{issues:[]})}),n=this._def.innerType._parse({data:o.data,path:o.path,parent:d({},o)});return Kr(n)?n.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Fe(o.common.issues)},input:o.data})})):{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new Fe(o.common.issues)},input:o.data})}}removeCatch(){return this._def.innerType}};Ft.create=(r,e)=>new Ft(d({innerType:r,typeName:M.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch},N(e)));var Pt=class extends D{_parse(e){if(this._getType(e)!==b.nan){let o=this._getOrReturnCtx(e);return O(o,{code:h.invalid_type,expected:b.nan,received:o.parsedType}),R}return{status:"valid",value:e.data}}};Pt.create=r=>new Pt(d({typeName:M.ZodNaN},N(r)));var fl=Symbol("zod_brand"),Yr=class extends D{_parse(e){let{ctx:t}=this._processInputParams(e),o=t.data;return this._def.type._parse({data:o,path:t.path,parent:t})}unwrap(){return this._def.type}},Xr=class r extends D{_parse(e){let{status:t,ctx:o}=this._processInputParams(e);if(o.common.async)return Q(this,null,function*(){let s=yield this._def.in._parseAsync({data:o.data,path:o.path,parent:o});return s.status==="aborted"?R:s.status==="dirty"?(t.dirty(),Wt(s.value)):this._def.out._parseAsync({data:s.value,path:o.path,parent:o})});{let n=this._def.in._parseSync({data:o.data,path:o.path,parent:o});return n.status==="aborted"?R:n.status==="dirty"?(t.dirty(),{status:"dirty",value:n.value}):this._def.out._parseSync({data:n.value,path:o.path,parent:o})}}static create(e,t){return new r({in:e,out:t,typeName:M.ZodPipeline})}},xt=class extends D{_parse(e){let t=this._def.innerType._parse(e),o=n=>(at(n)&&(n.value=Object.freeze(n.value)),n);return Kr(t)?t.then(n=>o(n)):o(t)}unwrap(){return this._def.innerType}};xt.create=(r,e)=>new xt(d({innerType:r,typeName:M.ZodReadonly},N(e)));function kp(r,e){let t=typeof r=="function"?r(e):typeof r=="string"?{message:r}:r;return typeof t=="string"?{message:t}:t}function Cp(r,e={},t){return r?qe.create().superRefine((o,n)=>{var s,p;let u=r(o);if(u instanceof Promise)return u.then(l=>{var c,f;if(!l){let x=kp(e,o),y=(f=(c=x.fatal)!==null&&c!==void 0?c:t)!==null&&f!==void 0?f:!0;n.addIssue(S(d({code:"custom"},x),{fatal:y}))}});if(!u){let l=kp(e,o),c=(p=(s=l.fatal)!==null&&s!==void 0?s:t)!==null&&p!==void 0?p:!0;n.addIssue(S(d({code:"custom"},l),{fatal:c}))}}):qe.create()}var ml={object:ce.lazycreate},M;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(M||(M={}));var Tl=(r,e={message:`Input not instance of ${r.name}`})=>Cp(t=>t instanceof r,e),Ap=He.create,Np=ot.create,hl=Pt.create,gl=st.create,Dp=it.create,Fl=pt.create,xl=At.create,Ol=ut.create,Sl=dt.create,bl=qe.create,yl=je.create,_l=we.create,Il=Nt.create,kl=Ve.create,vl=ce.create,wl=ce.strictCreate,El=lt.create,Ml=Nn.create,Rl=ct.create,Gl=Re.create,Wl=Dn.create,Cl=Dt.create,Al=Bt.create,Nl=Bn.create,Dl=ft.create,Bl=mt.create,Pl=Tt.create,Ul=ht.create,jl=Qe.create,vp=xe.create,Vl=Oe.create,Ll=Ge.create,Zl=xe.createWithPreprocess,zl=Xr.create,Hl=()=>Ap().optional(),ql=()=>Np().optional(),Ql=()=>Dp().optional(),$l={string:r=>He.create(S(d({},r),{coerce:!0})),number:r=>ot.create(S(d({},r),{coerce:!0})),boolean:r=>it.create(S(d({},r),{coerce:!0})),bigint:r=>st.create(S(d({},r),{coerce:!0})),date:r=>pt.create(S(d({},r),{coerce:!0}))},Jl=R,a=Object.freeze({__proto__:null,defaultErrorMap:Ct,setErrorMap:Zd,getErrorMap:Wn,makeIssue:Cn,EMPTY_PATH:zd,addIssueToContext:O,ParseStatus:se,INVALID:R,DIRTY:Wt,OK:pe,isAborted:Ao,isDirty:No,isValid:at,isAsync:Kr,get util(){return L},get objectUtil(){return Co},ZodParsedType:b,getParsedType:Ue,ZodType:D,datetimeRegex:Gp,ZodString:He,ZodNumber:ot,ZodBigInt:st,ZodBoolean:it,ZodDate:pt,ZodSymbol:At,ZodUndefined:ut,ZodNull:dt,ZodAny:qe,ZodUnknown:je,ZodNever:we,ZodVoid:Nt,ZodArray:Ve,ZodObject:ce,ZodUnion:lt,ZodDiscriminatedUnion:Nn,ZodIntersection:ct,ZodTuple:Re,ZodRecord:Dn,ZodMap:Dt,ZodSet:Bt,ZodFunction:Bn,ZodLazy:ft,ZodLiteral:mt,ZodEnum:Tt,ZodNativeEnum:ht,ZodPromise:Qe,ZodEffects:xe,ZodTransformer:xe,ZodOptional:Oe,ZodNullable:Ge,ZodDefault:gt,ZodCatch:Ft,ZodNaN:Pt,BRAND:fl,ZodBranded:Yr,ZodPipeline:Xr,ZodReadonly:xt,custom:Cp,Schema:D,ZodSchema:D,late:ml,get ZodFirstPartyTypeKind(){return M},coerce:$l,any:bl,array:kl,bigint:gl,boolean:Dp,date:Fl,discriminatedUnion:Ml,effect:vp,enum:Pl,function:Nl,instanceof:Tl,intersection:Rl,lazy:Dl,literal:Bl,map:Cl,nan:hl,nativeEnum:Ul,never:_l,null:Sl,nullable:Ll,number:Np,object:vl,oboolean:Ql,onumber:ql,optional:Vl,ostring:Hl,pipeline:zl,preprocess:Zl,promise:jl,record:Wl,set:Al,strictObject:wl,string:Ap,symbol:xl,transformer:vp,tuple:Gl,undefined:Ol,union:El,unknown:yl,void:Il,NEVER:Jl,ZodIssueCode:h,quotelessJson:Ld,ZodError:Fe});function J(r){return r.reduce((e,t)=>(e[t]=t,e),{})}var We=a.record(a.string(),a.union([a.string(),a.boolean(),a.number(),a.null(),a.undefined(),a.lazy(()=>We),a.union([a.string(),a.boolean(),a.number(),a.null(),a.undefined(),a.lazy(()=>We)]).array()])).nullable().describe("Custom key/value object"),E=a.union([a.string().datetime({offset:!0,local:!0}),a.string({invalid_type_error:"must be a valid date-time string"}).regex(/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/),a.string().date()]),Le=a.object({allow_timestamps:a.boolean().describe("Allow setting timestamps in transfer insert/update statements"),production:a.boolean().describe("Is running in production mode?")}).partial().describe("System wide flags"),Kl=a.enum(["Token","TransferGroup","TransferLog","Transfer","WalletTokenSetting","Wallet","WapiSetting"]),fg=J(Kl.options),Bo=a.enum(["="]),Po=a.enum([">=","<=","<",">"]),Bp=a.enum(["like","ilike"]),Yl=a.enum(["in","notIn"]),Xl=a.enum(["null","notNull"]),mg=a.enum([...Bo.options,...Po.options]).default("="),Tg=a.enum([...Bo.options,...Po.options,...Bp.options]).default("="),hg=a.enum([...Bo.options,...Po.options,...Bp.options,...Yl.options,...Xl.options]),Ot=a.union([a.string(),a.boolean(),a.number()]),ec=a.object({foreign:a.union([a.string(),a.number()])}),tc=a.object({identifier:a.union([a.string(),a.number()])}),fe=a.string().regex(/^(?!.*\.\.)[a-zA-Z_][a-zA-Z0-9_.-]*[a-zA-Z0-9_-]$/,"Key is limited to [a-zA-Z0-9_-] and cant start with a number"),Pp=a.union([a.string().array().min(1),a.number().array().min(1)]),Z=a.record(fe,Ot).describe("Metadata filter for custom properties"),Ce=a.enum(["where","orWhere"]),gg=J(Ce.options),Uo=a.enum(["whereNull","orWhereNull","whereNotNull","orWhereNotNull"]),Fg=J(Uo.options),jo=a.enum(["whereIn","orWhereIn"]),xg=J(jo.options),Vo=a.enum(["whereMetadata","orWhereMetadata"]),Og=J(Vo.options),Lo=a.enum(["whereMetadataNull","orWhereMetadataNull","whereMetadataNotNull","orWhereMetadataNotNull"]),Sg=J(Lo.options),Zo=a.enum(["whereMetadataIn","orWhereMetadataIn"]),bg=J(Zo.options),en=a.enum(["=",">=","<=","<",">","ilike","like"]).default("="),rc=a.object({function:Ce,field:fe,operator:en.optional(),value:Ot}).describe("Filtering for where and orWhere"),nc=a.union([Ot,ec]),yg=a.object({function:Ce,field:fe,operator:en.optional(),value:nc}).describe("Filtering for where and orWhere"),ac=a.union([Ot,tc]),_g=a.object({function:Ce,field:fe,operator:en.optional(),value:ac}).describe("Filtering for where and orWhere"),oc=a.object({function:Vo,field:fe,operator:en.optional(),value:Ot}).required({function:!0,field:!0,value:!0}).describe("Filtering for where and orWhere"),sc=a.object({metadata:Z.optional()}).catchall(Ot),Ig=a.union([Ot,Z]),ic=a.object({function:Ce,value:sc}),pc=a.union([rc,ic]),uc=a.object({function:jo,field:fe,value:Pp}),dc=a.object({function:Zo,field:fe,value:Pp}),lc=a.object({function:Uo,field:fe}).describe("Filtering for whereNull and orWhereNull, whereNotNull and orWhereNotNull"),cc=a.object({function:Lo,field:fe}).describe("Filtering for whereNull and orWhereNull, whereNotNull and orWhereNotNull for metadata"),Up=a.discriminatedUnion("function",[oc,dc,cc]),jp=a.union([pc,uc,lc,Up,a.object({function:Ce,inner:a.lazy(()=>jp.array())})]),kg=a.object({function:Ce,inner:jp.array()}),fc=a.union([Ce,jo,Uo,Vo,Zo,Lo]),mc=a.object({function:fc,field:fe.optional(),operator:en.optional(),value:a.unknown().optional(),inner:a.unknown().array().optional()}),Tc=a.object({function:Ce,inner:a.unknown().array()});function Ut(r,e,t){let o=e.safeParse(r);return o.success||o.error.errors.forEach(n=>{t.addIssue(d({},n))}),o.success}function Ae(r,e){let t=Array.from(new Set([...r.strings,...r.numbers,...r.booleans,...r.nullables,...r.datetimes,...r.foreigns,...r.identifiers])),o=a.enum(t),n=a.object({function:Ce,value:e||a.object({metadata:Z})}),s=(p,u)=>{if(!Ut(p,mc,u))return!1;let l=p;if(l.inner)return Ut(l,Tc,u)?!l.inner.some(c=>{if(s(c,u)===!1)return!0}):!1;if(!l.field)return Ut(l,n,u);if(l.function.toLowerCase().includes("metadata"))return Ut(l,Up,u);if(!Ut(l.field,o,u))return!1};return a.record(fe,a.unknown()).superRefine((p,u)=>e&&!p.function?Ut(p,e,u):s(p,u))}var zo=a.object({tracking_id:a.string().max(64).describe("User provided id added to logs for debugging")}).describe("Tracking flags for input"),F=zo.extend({transaction_id:a.string().max(64).describe("Id of the transaction context to run the query in")}).describe("Generic flags for input"),ne=a.object({limit:a.number().int().nonnegative().default(20).describe("Number of records to return"),offset:a.number().int().nonnegative().default(0).describe("Number of records to omit from the beginning")}).describe("Optional flags for input limiting"),me=a.object({return_metadata_total:a.boolean().describe("Return the total rows count in metadata")}).describe("Metadata flags for input"),Te=a.object({field:a.string().describe("Field to order by"),direction:a.enum(["asc","desc"]).default("asc").describe("Direction to order"),nulls:a.enum(["first","last"]).describe("Should nulls be first or last")}).strict().partial().required({field:!0}).describe("Input for orderBy"),Zp=a.object({order:Te.array().describe("Ordering options")}).describe("Optional flags for input ordering"),Vp=a.object({id:a.number().int().positive().describe("id of the object"),foreign:a.string().max(64).describe("foreign of the object")}).strict().partial(),jt=a.union([Vp.required({id:!0}),Vp.required({foreign:!0})]),Lp=a.object({id:a.number().int().positive().describe("id of the object"),identifier:a.string().max(64).describe("identifier of the object")}).strict().partial(),Pn=a.union([Lp.required({id:!0}),Lp.required({identifier:!0})]),Ee=a.enum(["replace","extend"]).default("replace").describe("Whether to replace or extend current metadata with new value"),St=a.enum(["replace","replace_create_only","replace_cancel_only","extend","extend_create_only","extend_cancel_only"]).default("replace").describe("Whether to replace or extend current metadata with new value"),Ho=a.enum(["keep","random","largest","target"]).describe("Rule for distribution grouping"),Gg=J(Ho.options),be=a.object({total:a.number().int().nonnegative().describe("Total number of records matching the query"),offset:a.number().int().nonnegative().describe("Current query offset"),limit:a.number().int().nonnegative().describe("Current query limit"),more_rows:a.boolean().describe("Boolean showing if there would be more rows to return with a higher offset/limit"),order:Te.array()}).partial().required({offset:!0,limit:!0,more_rows:!0}).describe("Metadata about the search"),Un=a.enum(["count","countDistinct","sum","average","min","max"]).default("count").describe("Function to use for grouping"),qo=a.object({function:Un,field:fe.describe("Field to group by"),alias:fe.describe("Alias to group under")}).partial().describe("Function and field to group"),Qo=a.union([Un,qo]).describe("Aggregator description"),$o=a.enum(["year","month","week","day","hour","minute"]).describe("Time period rows should be grouped by"),zp=J($o.options),hc=a.object({period:$o.default("day"),timezone:a.string()}).strict().required(),gc=a.union([$o,hc]),tn=a.object({type:a.literal("period"),field:gc,alias:a.string()}).strict().partial().required({type:!0,field:!0}),rn=a.object({type:a.literal("field"),field:a.string(),alias:a.string()}).strict().partial().required({type:!0,field:!0}),nn=a.object({type:a.literal("metadata_field"),field:a.string(),alias:a.string()}).strict().partial().required({type:!0,field:!0}),Fc=a.discriminatedUnion("type",[tn,rn,nn]);var xc=Fc.array().max(5),Oc=a.record(a.string(),a.union([a.string(),a.number()]).nullable()).describe("Result of the aggregation"),jn=Oc.array().describe("Results of the aggregation"),Hp=a.object({aggregators:Qo.array(),groups:xc}).partial().required({groups:!0}).describe("Metadata about the aggregation"),Wg=a.object({select:a.string().array()}).describe("Optional flags to select specific fields"),Cg=a.object({deselect:a.string().array()}).describe('Optional flag to remove field from select"'),$e=a.object({start_time:E,end_time:E}).partial().strict();var Vt=a.enum(["active","disabled"]).describe("Current status for the wallet"),qp=J(Vt.options),Lt=a.enum(["token","house","regular"]).describe("Type of the wallet"),Qp=J(Lt.options),P=a.object({id:a.number().int().positive().describe("System defined primary key"),foreign:a.string().min(1).max(255).describe("User provided key for wallet. Must be unique"),name:a.string().min(1).max(255).optional().nullable().describe("User provided key for wallet. Must be unique"),metadata:We.describe("Key/value object describing this wallet").optional(),default_allow_negative:a.boolean().default(!1).describe("Boolean indicating if wallet (pending_amount + finished_amount) can be negative"),default_allow_positive:a.boolean().default(!0).describe("Boolean indicating if wallet (pending_amount + finished_amount) can be positive. Used for token balance to deny positive balance."),created_at:E.describe("Datetime of the initial create"),updated_at:E.describe("Datetime of the last update"),default_dtw_to:a.string().max(3).optional().describe("Bitmap indicating default what types of transfers can originate from wallet"),default_dtw_from:a.string().max(3).optional().describe("Bitmap indicating default what types of transfers can end to wallet"),type:Lt.describe("Type of the wallet").default("regular"),status:Vt.describe("Current status for the wallet").default("active")}).strict().describe("Wallet|Entities who can make transfers in this system");var $p=P.keyof(),Sc=$p.options,bc=$p.exclude(["metadata"]).options,Pg=new Set(bc),Ug=new Set(Sc);var j=a.enum(["pending","finished","cancelled"]).describe("Status of the transfer"),Jp=J(j.options),X=j.exclude(["cancelled"]).describe("Status of the transfer"),Je=a.enum(["transfer","deposit","withdrawal"]).describe("Type of the transfer"),bt=J(Je.options),T=a.object({id:a.number().int().positive().describe("System defined primary key"),identifier:a.string().min(1).max(255).describe("Identifier for this transfer. Must be unique"),control_hash:a.string().max(255).nullable().describe('Hash binding this transfer to the from_wallets transfer chain. It is calculated as sha256(latest_outgoing_hash + "-" + NEW.identifier)'),from_wallet_id:a.number().int().positive().describe("Foreign key to wallet funds originate from"),to_wallet_id:a.number().int().positive().describe("Foreign key to wallet where funds are going"),token_id:a.number().int().positive().describe("Foreign key to token this transfer refers to"),amount:a.number().positive().describe("The transfer amount"),type:Je.describe("Type of the transfer").default("transfer"),status:j.describe("Status of the transfer").default("pending"),force:a.boolean().default(!1).describe("Set to true to force transfer without checking for negative balance constraints"),auto_hash:a.boolean().default(!0).describe("When set to true it will automatically calculate the control_hash"),created_at:E.describe("Datetime of the initial create"),updated_at:E.describe("Datetime of the last update"),metadata:We.describe("Key/value object describing this transfer").optional(),transfer_group_id:a.number().int().positive().nullable().optional().describe("Foreign key pointing to the transfer_group this transfer belongs to"),reverses_id:a.number().int().positive().nullable().optional().describe("Foreign key pointing to the transfer this transfer reverses. Must be unique"),status_finalized_at:E.nullable().optional().describe("DateTime transfer reached final status"),group_validate:a.boolean().nullable().optional().describe("Boolean showing if the transfer_group has validate_final_balance_only")}).strict().describe("A transfer of value from one wallet to another"),zg=T.omit({id:!0}).extend({status:X.default("pending")}).partial().required({identifier:!0,from_wallet_id:!0,to_wallet_id:!0,token_id:!0,amount:!0}),Kp={numbers:["id","amount","from_wallet_id","to_wallet_id","token_id","transfer_group_id","reverses_id"],strings:["identifier","control_hash","type","status"],booleans:["force","auto_hash","group_validate"],nullables:["transfer_group_id","reverses_id","group_validate"],datetimes:["created_at","updated_at","status_finalized_at"],foreigns:[],identifiers:[],metadata:!0},Yp=T.keyof(),yc=Yp.options,_c=Yp.exclude(["metadata"]).options,Hg=new Set(yc),qg=new Set(_c);var G=a.object({id:a.number().int().positive().describe("UNIQUE|System defined primary key"),transfer_id:a.number().int().positive().describe("Foreign key pointing to the transfer this log belongs to"),wallet_id:a.number().int().positive().describe("Foreign key pointing to the wallet this log belongs to"),token_id:a.number().int().positive().describe("Foreign key pointing to the token this log belongs to"),amount:a.number().describe("The amount the wallet balance is changed by"),pending_amount:a.number().describe("The pending balance of wallet after this transfer_log"),finished_amount:a.number().describe("The finished balance of wallet after this transfer_log"),allow_negative:a.boolean().default(!1).describe("Boolean indicating if wallet (pending_amount + finished_amount) can be negative"),allow_positive:a.boolean().default(!0).describe("Boolean indicating if wallet (pending_amount + finished_amount) can be positive. Used for token balance to deny positive balance."),force:a.boolean().default(!1).describe("Boolean indicating if the latest transfer from this wallet was forced to ignore negative balance checks"),created_at:E.describe("Datetime this log was created"),latest_control_hash:a.string().max(255).nullable().describe("Latest hash related to this wallet"),pending_amount_to:a.number().describe("The incoming pending balance"),pending_amount_from:a.number().describe("The outgoing pending balance"),group_balance:a.number().nullable().describe("Running balance for the wallet in this group"),transfer_group_id:a.number().int().positive().nullable().optional().describe("Foreign key pointing to the transfer_group this transfer_log belongs to"),current:a.boolean().describe("Boolean showing if this transfer_log is the latest for this wallet/token combination"),available_balance:a.number().describe("Available balance that is sum of pending_amount_from and finished_amount"),token_limit:a.number().nullable().describe("If wallet = token.belongs_to and token has limit"),status:j.describe("Status of this log - same as Transfer.status"),type:Je.describe("Type of this log - same as Transfer.type")}).strict().describe("TransferLog|Individual parts of a transfer, will be updated internally by db. Immutable");var Xp=G.keyof(),Jo=Xp.options,Ic=Xp.options,Yg=new Set(Ic),Xg=new Set(Jo);var eu=a.enum(["active","dw-only","disabled"]).describe("Current status for the token"),tu=J(eu.options),Ne=a.enum(["value","share","group","contract"]).describe("Type of the token"),ru=J(Ne.options),U=a.object({id:a.number().int().positive().describe("System defined primary key"),foreign:a.string().min(1).max(255).describe("Name of the token, used for name based token transfers. Must be unique"),public:a.boolean().describe("Boolean indicating if token can be traded with outside seed wallet").default(!0),belongs_to:a.number().int().positive().describe("Foreign key to seed wallet"),metadata:We.describe("Key/value object describing the token").optional(),divisor:a.number().nullable().describe("Minimum amount of token that can be transferred").optional(),limit:a.number().nullable().describe("Maximum amount of token that can be issued").optional(),type:Ne.describe("Type of the token").default("value"),status:eu.describe("Current status for the token").default("active"),created_at:E.describe("Datetime when the token was created"),updated_at:E.describe("Datetime when the token was last updated")}).strict().describe("Units of value which can be transferred in this system"),nu={numbers:["id","belongs_to","divisor","limit"],strings:["foreign","type","status"],booleans:["public"],nullables:["divisor","limit"],datetimes:["created_at","updated_at"],foreigns:["belongs_to"],identifiers:[],metadata:!0},au=U.keyof(),Vn=au.options,Ko=au.exclude(["metadata"]).options,aF=new Set(Vn),oF=new Set(Ko);var z=jt.describe("Unique wallet filter"),an=F.extend({ignore_cache:a.boolean().describe("Ignore cached information"),create_if_not_exists:a.boolean().default(!1).describe("If true then the token will be created if not found. Only valid with 'foreign'"),return_only_id:a.boolean().default(!1).describe("If true then the returning object is only guaranteed to have id")}).partial(),Ln=a.object({wallet:z,options:an.optional()}).strict().required({wallet:!0}).describe("Input for getWallet"),Yo=P.extend({balance_token_id:U.shape.id.nullable(),balance_token_foreign:U.shape.foreign.nullable(),balance_transfer_id:G.shape.transfer_id.describe("Latest transfer id").nullable(),balance_pending_amount:G.shape.pending_amount.describe("Current pending balance").nullable(),balance_pending_amount_to:G.shape.pending_amount_to.describe("Sum of incoming pending transfers").nullable(),balance_pending_amount_from:G.shape.pending_amount_from.describe("Sum of outgoing pending transfers").nullable(),balance_finished_amount:G.shape.finished_amount.describe("Current finished balance").nullable(),balance_amount:a.number().describe("Current finished and pending balance sum").nullable(),balance_available_balance:G.shape.available_balance.describe("Available balance that is sum of pending_amount_from and finished_amount").nullable(),balance_latest_control_hash:G.shape.latest_control_hash.describe("Latest control_hash associated with wallet token combination").nullable(),balance_updated_at:G.shape.created_at.describe('"Last modification date of balance').nullable()}),Zn=Yo.keyof(),Xo=P.partial().required({id:!0}),zn=a.object({wallet:Xo.optional()}).describe("Output of getWallet");var ye=a.enum(["open","closed"]).describe("Lifecycle status for transfer group"),Hn=J(ye.options),Ke=a.enum(["regular","exchange","distribution"]).describe("Type of the transfer group"),ou=J(Ke.options),B=a.object({id:a.number().int().positive().describe("UNIQUE|System defined primary key"),identifier:a.string().min(1).max(255).describe("UNIQUE,INPUT|Identifier for this transfer group. Must be unique"),created_at:E.describe("Datetime of the initial create"),updated_at:E.describe("Datetime of the last update"),metadata:We.describe("INPUT|Key/value object describing this transfer_group").optional(),transfer_group_id:a.number().int().positive().nullable().optional().describe("Foreign key pointing to the transfer_group this transfer belongs to"),reverses_id:a.number().int().positive().nullable().optional().describe("Foreign key pointing to the transfer_group this transfer_group reverses. Must be unique"),status_finalized_at:E.nullable().optional().describe("Time transfer_group was closed"),transfer_status_finalized_at:E.nullable().optional().describe("Time transfer_status reached final state"),validate_final_balance_only:a.boolean().nullable().optional().describe("Boolean if only the final balances of wallets should be validated"),transfer_status:a.enum(["pending","finished","cancelled"]).describe("INPUT|Status of the transfers").default("pending"),status:ye.describe("INPUT|Lifecycle status for transfer group").default("open"),type:Ke.describe("INPUT|Type of the transfer group").default("regular")}).strict().describe("TransferGroup|An entity collecting transfers into a group locked by status"),es={numbers:["id","amount","transfer_group_id","reverses_id"],strings:["identifier","transfer_status","type","status"],booleans:["validate_final_balance_only"],nullables:["transfer_group_id","reverses_id","status_finalized_at","transfer_status_finalized_at","validate_final_balance_only"],datetimes:["created_at","updated_at","status_finalized_at","transfer_status_finalized_at"],foreigns:[],identifiers:[],metadata:!0},su=B.keyof(),ts=su.options,kc=su.exclude(["metadata"]).options,hF=new Set(ts),gF=new Set(kc);var yt=Pn.describe("Unique transfer filter"),rs=F.partial(),qn=a.object({transfer:yt,options:rs.optional()}).strict().required({transfer:!0}).describe("Input for getTransfer"),re=T.extend({from_wallet_foreign:P.shape.foreign,to_wallet_foreign:P.shape.foreign,token_foreign:U.shape.foreign,transfer_group_identifier:B.shape.identifier.nullable(),reverses_identifier:T.shape.identifier.nullable()}),iu=re.extend({balance_id:G.shape.id.nullable().describe("Iterator marking the position of the balance in the continuum"),balance_pending:G.shape.pending_amount.nullable().describe("Wallet pending balance after transfer"),balance_pending_to:G.shape.pending_amount_to.nullable().describe("Wallet pending_to balance after transfer"),balance_pending_from:G.shape.pending_amount_from.nullable().describe("Wallet pending_from balance after transfer"),balance_finished:G.shape.finished_amount.nullable().describe("Wallet finished balance after transfer"),signed_amount:G.shape.amount.nullable().describe("amount with a sign according to transfer direction"),status_finalized_at:G.shape.created_at.nullable().describe("DateTime transfer reached final status")}),_e=a.object({transfer:re.optional()}).describe("Output of getTransfer");var K=jt.describe("Unique token filter"),GF=U.partial().required({id:!0}),Qn=U.extend({belongs_to_foreign:P.shape.foreign.describe("Wallet the token belongs to").nullable(),balance_transfer_id:G.shape.transfer_id.nullable().describe("Latest transfer id"),balance_pending_amount:G.shape.pending_amount.nullable().describe("Current pending balance"),balance_pending_amount_to:G.shape.pending_amount_to.nullable().describe("Sum of incoming pending transfers"),balance_pending_amount_from:G.shape.pending_amount_from.nullable().describe("Sum of outgoing pending transfers"),balance_finished_amount:G.shape.finished_amount.nullable().describe("Current finished balance"),balance_amount:a.number().nullable().describe("Current finished and pending balance sum"),balance_available_balance:G.shape.available_balance.nullable().describe("Available balance that is sum of pending_amount_from and finished_amount"),balance_latest_control_hash:G.shape.latest_control_hash.nullable().describe("Latest control_hash associated with wallet token combination"),balance_updated_at:G.shape.created_at.nullable().describe('"Last modification date of balance')}),ns=Qn.keyof(),on=F.extend({ignore_cache:a.boolean().describe("Ignore cached information"),create_if_not_exists:a.boolean().default(!1).describe("If true then the token will be created if not found. Only valid with 'foreign'"),return_only_id:a.boolean().default(!1).describe("If true then the returning object is only guaranteed to have id"),include_balance:a.boolean().default(!1).describe("Return the total system balance of token")}).partial(),$n=a.object({token:K,options:on.optional()}).strict().required({token:!0}).describe("Input for getToken"),as=Qn.partial().required({id:!0}),Jn=a.object({token:as.optional()}).describe("Output of getToken");var ue=Pn.describe("Unique transferGroup filter"),os=F.extend({create_if_not_exists:a.boolean().default(!1).describe("If true then the transfer_group will be created if not found. Only valid with 'identifier'"),return_only_id:a.boolean().default(!1).describe("If true then the returning object is only guaranteed to have id")}).partial(),Kn=a.object({transfer_group:ue,options:os.optional()}).strict().required({transfer_group:!0}).describe("Input for getTransferGroup"),sn=B.extend({reverses_identifier:B.shape.identifier.nullable().describe("Identifier of the transfer group this reverses")}).partial().required({id:!0}).describe("requested transfer_group"),Yn=a.object({transfer_group:sn.optional()}).describe("Output of getTransferGroup");var ss=a.object({return_running_balance_for_wallet:z.describe("Return running balance for each transfer for wallet in question"),return_signed_amount_for_wallet:z.describe("Return amount as signed value for each transfer for wallet in question")}),pn=F.merge(ne).merge(me).merge(ss).extend({order:Te.extend({field:T.keyof()}).array(),select:re.keyof().array(),deselect:re.keyof().array()}).partial(),pu=a.object({id:T.shape.id,identifier:T.shape.identifier,from_wallet:z,to_wallet:z,wallet:z,token:K,status:j,transfer_group:ue,metadata:Z}).partial(),vc=S(d({},Kp),{foreigns:["from_wallet","to_wallet","wallet","token"],identifiers:["transfer_group","reverses"]}),wc=Ae(vc,pu),_t=a.union([pu,wc.array()]),Zt=a.object({transfer:_t,options:pn.optional()}).strict().partial().describe("Input for findTransferMany"),Xn=a.object({transfers:iu.partial().array().describe("Found transfers"),metadata:be}).partial().required({transfers:!0,metadata:!0}).describe("Output of findTransferMany");var Ec=a.object({return_all_intervals:$e.describe("Add empty values for each interval if no matching data")}).partial(),is=F.merge(Ec).partial().optional(),Mc=a.enum(["from.amount","to.amount","amount","abs.amount","transfer_group","from_wallet","to_wallet","wallet","token","id"]).describe("Field to group by"),Rc=qo.extend({field:Mc}).partial(),ps=a.union([Rc,Un]),Gc=a.enum(["type","status","from_wallet","to_wallet","wallet","token","transfer_group"]),us=a.union([tn,rn.extend({field:Gc}),nn]),ea=a.object({transfer:_t,aggregators:ps.array(),groups:us.array(),options:is}).partial().required({aggregators:!0}).describe("Input for aggregateTransferMany"),ta=a.object({rows:jn,metadata:Hp}).partial().describe("Output of getToken");var Wc=F.partial(),ra=a.object({options:Wc}).strict().partial().describe('Input for authenticationCheck"'),uu=a.object({}).describe("Output of authenticationCheck");var Cc=a.object({wallet_foreign:P.shape.foreign,from_wallet_foreign:P.shape.foreign,to_wallet_foreign:P.shape.foreign,token_foreign:U.shape.foreign}).partial().describe("Forced filters for requests"),ds=a.enum(["aggregateTransferMany","exportBalanceHistory","exportTokenMany","exportTransferGroupMany","exportTransferMany","exportWalletMany","findBalanceMany","findTokenMany","findTransferGroupMany","findTransferMany","findWalletMany","getBalance","getBalanceHistory","getExport","getStatistics","getToken","getTokenMany","getTransfer","getTransferGroup","getWallet","getWalletMany","healthcheck","listExportMany"]).describe("Allowed methods"),ls=a.object({type:a.enum(["limited"]).describe("Type of the accessToken"),scopes:ds.array(),expiresIn:a.number().int().positive().describe("JWT expiration time in minutes"),filters:Cc.optional()}).strict(),cs=a.object({type:a.enum(["admin"]).describe("Type of the accessToken"),expiresIn:a.number().int().positive().describe("JWT expiration time in minutes")}).strict(),fs=F.partial(),na=a.object({token:a.union([ls,cs]),options:fs}).strict().partial().required({token:!0}).describe("Input for createAccessToken"),aa=a.object({authToken:a.string().describe("The JWT token")}).describe("Output of createAccessToken");var un=a.object({wallet:z,token:K,datetime:E.describe("Time the balance should be retrieved at").optional()}).strict(),ms=F.extend({ignore_cache:a.boolean().describe("Ignore cached information"),create_wallet_if_not_exists:a.boolean().default(!1).describe("If true then the missing wallet will be created if not found. Only valid with 'foreign'"),create_token_if_not_exists:a.boolean().default(!1).describe("If true then the missing token will be created if not found. Only valid with 'foreign'"),create_if_not_exists:a.boolean().default(!1).describe("If true then the missing balance will be created if not found.")}).partial(),oa=a.object({balance:un,options:ms}).partial().strict().required({balance:!0}).describe("Input for getBalance"),It=G.pick({transfer_id:!0,token_id:!0,wallet_id:!0,pending_amount:!0,pending_amount_from:!0,pending_amount_to:!0,available_balance:!0,finished_amount:!0,latest_control_hash:!0}).extend({token_foreign:U.shape.foreign,wallet_foreign:P.shape.foreign,amount:a.number().describe("Current finished and pending balance sum"),updated_at:G.shape.created_at}).strict().partial().required({token_id:!0,token_foreign:!0,wallet_id:!0,wallet_foreign:!0,pending_amount:!0,finished_amount:!0,amount:!0,latest_control_hash:!0,updated_at:!0}),De=a.object({balance:It.optional()}).strict().describe("Output of getBalance");var Ye=a.object({identifier:T.shape.identifier,latest_control_hash:T.shape.control_hash.nullable().describe("Latest control_hash on the from_wallet"),from_wallet:z.describe("Wallet where funds are debited"),to_wallet:z.describe("Wallet where funds are credited"),token:K.describe("Token that is moved"),amount:T.shape.amount,type:T.shape.type,status:X,force:T.shape.force,metadata:T.shape.metadata,transfer_group:ue.describe("TransferGroup the transfer belongs to"),created_at:T.shape.created_at}).strict(),sa=Ye.extend({type:a.literal("transfer").default("transfer").describe("Type of transfer")}).partial().strict().required({from_wallet:!0,to_wallet:!0,token:!0,amount:!0}),zt=Ye.partial().extend({type:a.literal("deposit").describe("Type of transfer")}).strict().required({to_wallet:!0,token:!0,amount:!0}),Ht=Ye.partial().extend({type:a.literal("withdrawal").describe("Type of transfer")}).strict().required({from_wallet:!0,token:!0,amount:!0}),Ts=a.union([sa,zt,Ht]).pipe(a.union([sa,zt,Ht])),Ze=F.extend({return_from_balance:a.boolean().default(!1).describe("Whether the request should also return from wallet balance"),return_to_balance:a.boolean().default(!1).describe("Whether the request should also return to wallet balance"),create_to_wallet_if_not_exists:a.boolean().default(!1).describe("If true then the wallet will be created if not found. Only valid with 'foreign'")}).partial().optional(),ia=a.object({transfer:Ts,options:Ze}).strict().required({transfer:!0}).describe("Input for createTransfer"),Xe=a.object({transfer:_e.shape.transfer.describe("Created transfer object"),from_balance:De.shape.balance.describe("Debited wallet balance"),to_balance:De.shape.balance.describe("Credited wallet balance")}).partial().strict().required({transfer:!0}).describe("Output of createTransfer");var Ac=sa.omit({status:!0,transfer_group:!0}).strip(),Nc=zt.omit({status:!0,transfer_group:!0}).strip(),Dc=Ht.omit({status:!0,transfer_group:!0}).strip(),Bc=a.union([Ac,Nc,Dc]),hs=a.object({identifier:B.shape.identifier,status:ye,transfer_status:j,metadata:B.shape.metadata,children:Bc.array().describe("Array of children")}).partial(),gs=F.extend({create_to_wallet_if_not_exists:a.boolean().default(!1).describe("If true then the wallet will be created if not found. Only valid with 'foreign'"),validate_final_balance_only:a.boolean().default(!1).describe("If true then transfers within a group will ignore balance restrictions. Only final transfers for wallets are checked. Only valid with transfer_status_lock")}).partial().optional(),pa=a.object({transfer_group:hs,options:gs}).strict().partial().describe("Input for createTransferGroup"),et=a.object({transfer_group:B,transfers:_e.shape.transfer.array().describe("Created transfer objects")}).partial().required({transfer_group:!0}).describe("Output of createTransferGroup");var Fs=F.extend({return_all_intervals:$e.describe("Add empty values for each interval if no matching data")}).partial().optional(),Pc=a.object({from_wallet:z.describe("Wallet the contract will belong to at the end (buyer)"),from_latest_control_hash:T.shape.control_hash.nullable().describe("Latest control_hash on the from_wallet+from_token combo"),from_token:K.describe("Token that is transferred from from_wallet in exchange of the contract"),to_wallet:z.describe("Wallet the payment for the contract is sent to (seller)"),amount:T.shape.amount,status:a.enum(["pending","finished"]).describe("The state at which the exchange is created"),force:T.shape.force,metadata:T.shape.metadata}).partial().strict().required({from_wallet:!0,from_token:!0,amount:!0}),Uc=a.object({foreign:U.shape.foreign,metadata:U.shape.metadata,deposits:a.object({token:K.describe("Token that is transferred"),amount:T.shape.amount}).array().nonempty(),owner:z.describe("The inital owner of the contract, defaults to foreign = 'house'").default({foreign:"house"})}).partial().required({foreign:!0,deposits:!0}),ua=a.object({token:Uc,exchange:Pc,options:Fs}).strict().partial().required({token:!0}).describe("Input for createContract"),da=a.object({token:U,exchange:et}).partial().required({token:!0}).describe("Output of createContract");var jc=Ze,la=a.object({deposit:zt.extend({type:a.literal("deposit").optional()}),options:jc}).strict().required({deposit:!0}).describe("Input for createDeposit"),ca=Xe.describe("Output of createDeposit");var Vc=a.object({wallet:z.describe("Wallet where funds are credited"),portion:a.union([a.string(),a.number()]).describe("Number specifying the portion of funds to be credited"),metadata:T.shape.metadata}).partial().required({wallet:!0}),Lc=K.describe("Wallets will receive funds based on their balance of this token"),Zc=a.object({rule:Ho,target:a.object({wallet:z,metadata:T.shape.metadata}).strict().partial().required({wallet:!0})}).strict().partial().required({rule:!0}),zc=a.object({identifier:B.shape.identifier.describe("Unique identifier for this distribution"),latest_control_hash:T.shape.control_hash.nullable().describe("Latest control_hash on the from_wallet"),from_wallet:z.describe("Wallet where funds are debited"),token:K.describe("Token that is moved"),amount:T.shape.amount,status:j,force:T.shape.force,metadata:T.shape.metadata,copy_wallet_metadata_fields:a.object({from_property:a.string(),to_property:a.string()}).partial().required({from_property:!0}).array().describe("Copy metadata information from Wallet metadata to transfer metadata"),transfer_group:ue.describe("TransferGroup the transfer belongs to"),targets:a.union([Lc,Vc.array().nonempty()]),leftover:Zc}).partial().required({identifier:!0,from_wallet:!0,token:!0,amount:!0,targets:!0,leftover:!0}).describe("Distribute funds from one wallet between multiple wallets"),Hc=F.extend({dryrun:a.boolean().default(!1)}).partial().optional(),fa=a.object({distribution:zc,options:Hc}).strict().partial().required({distribution:!0}).describe("Input for createDistribution"),du=a.object({transfer_group:B,transfers:_e.shape.transfer.array().describe("Created transfer objects")}).partial().required({transfer_group:!0,transfers:!0}).describe("Output of createDistribution");var xs=a.object({foreign:U.shape.foreign,public:U.shape.public,metadata:U.shape.metadata,divisor:U.shape.divisor,limit:U.shape.limit,type:Ne,belongs_to:jt.describe("Wallet this token belongs_to")}).partial().required({foreign:!0}),Os=F.partial(),ma=a.object({token:xs,options:Os.optional()}).strict().required({token:!0}).describe("Input for createToken"),Ta=a.object({token:U,wallet:P}).describe("Output of createToken");var Ss=Ze,ha=a.object({transfers:Ts.array().nonempty().describe("An array of transfers"),options:Ss}).strict().required({transfers:!0}).describe("Input for createTransferMany"),ga=a.object({transfers:_e.shape.transfer.array().describe("Created transfer objects"),from_balances:De.shape.balance.array().describe("Debited wallet balances"),to_balances:De.shape.balance.array().describe("Credited wallet balances")}).partial().strict().required({transfers:!0}).describe("Output of createTransferMany");var bs=a.object({foreign:P.shape.foreign,name:P.shape.name,metadata:P.shape.metadata,type:Lt,status:Vt}).partial().required({foreign:!0}),ys=F.partial(),Fa=a.object({wallet:bs,options:ys}).partial().strict().required({wallet:!0}).describe("Input for createWallet"),xa=a.object({wallet:P}).describe("Output of createWallet");var Oa=a.object({withdrawal:Ht.extend({type:a.literal("withdrawal").optional()}),options:Ze}).strict().required({withdrawal:!0}).describe("Input for createWithdrawal"),Sa=Xe.describe("Output of createWithdrawal");var _s=a.enum(["transfers","transfer_groups","tokens","wallets","balance_history","unknown"]).describe("Type of the export"),qc=a.enum(["started","completed","error"]).describe("Status of the export"),dn=a.object({identifier:a.string().describe("Unique identifier of the export"),status:qc,type:_s,created_at:E.describe("Timestamp when export was initiated"),completed_at:E.describe("Timestamp when export was finished"),fields:a.string().array().describe("The fields selected for this export"),count:a.number().int().positive().describe("The number of entities exported in this file"),signed_url:a.string().describe("Signed URL for downloading the export file"),size:a.string().describe("Size of the exported file"),message:a.string().describe("Extra information about the state of the file")}).partial().required({identifier:!0}).describe("Information about exported file"),Is=F.extend({return_signed_url:a.boolean().describe("Return signed url for downloading the export file, will only be returned if status === 'completed'")}).partial(),ba=a.object({export:a.object({identifier:dn.shape.identifier}),options:Is.optional()}).strict().required({export:!0}).describe("Input for getExport"),he=a.object({export:dn.optional()}).describe("Output of getExport");var Qc=a.object({create_wallet_if_not_exists:a.boolean().default(!1).describe("If true then the missing wallet will be created if not found. Only valid with 'foreign'"),create_token_if_not_exists:a.boolean().default(!1).describe("If true then the missing token will be created if not found. Only valid with 'foreign'")}),lu=a.object({balance_id:G.shape.id.describe("The internal ID of the balance"),token_id:G.shape.token_id.describe("Token ID of balance"),token_foreign:U.shape.foreign.describe("Token Foreign of balance"),wallet_id:G.shape.wallet_id.describe("Wallet ID of balance"),wallet_foreign:P.shape.foreign.describe("Wallet Foreign of balance"),pending_amount:G.shape.pending_amount.describe("Current pending balance"),pending_amount_to:G.shape.pending_amount_to.describe("Sum of incoming pending transfers"),pending_amount_from:G.shape.pending_amount_from.describe("Sum of outgoing pending transfers"),available_balance:G.shape.available_balance.describe("Available balance that is sum of pending_amount_from and finished_amount"),finished_amount:G.shape.finished_amount.describe("Current finished balance"),amount:a.number().describe("Current finished and pending balance sum"),status:a.enum(["pending","finished"]).describe("The status of the change to balance"),latest_control_hash:G.shape.latest_control_hash.describe("Latest control_hash associated with wallet token combination"),updated_at:G.shape.created_at.describe("Last modification date of balance"),transfer_id:T.shape.id,transfer_identifier:T.shape.identifier,transfer_control_hash:T.shape.control_hash,transfer_from_wallet_id:T.shape.from_wallet_id,transfer_from_wallet_foreign:P.shape.foreign,transfer_to_wallet_id:T.shape.to_wallet_id,transfer_to_wallet_foreign:P.shape.foreign,transfer_amount:T.shape.amount,transfer_type:Je,transfer_status:j,transfer_force:T.shape.force,transfer_created_at:T.shape.created_at,transfer_updated_at:T.shape.updated_at,transfer_metadata:T.shape.metadata,transfer_transfer_group_id:T.shape.transfer_group_id,transfer_transfer_group_identifier:B.shape.identifier.optional().nullable().describe("Transfer Group identifier if transfer belongs to a group"),transfer_reverses_id:T.shape.reverses_id,transfer_reverses_identifier:T.shape.identifier.optional().nullable().describe("Reverses identifier if transfer reverses another transfer"),transfer_status_finalized_at:T.shape.status_finalized_at.nullable().describe("DateTime transfer reached final status")}).strict().partial(),ks=a.object({order:a.enum(["asc","desc"])}).describe("Ordering options"),$c=lu.keyof(),vs=a.object({select:$c.array()}).describe("Optional flags to limit search result"),ws=F.merge(ne).merge(me).merge(Qc).merge(ks).merge(vs).extend({return_all_intervals:$e.describe("Add empty values for each interval if no matching data")}).partial(),ya=a.object({balance:un,options:ws.optional()}).strict().required({balance:!0}).describe("Input for getBalanceHistory"),_a=a.object({balances:lu.array().describe("Resolved balance change objects"),metadata:be}).required({balances:!0}).describe("Output of getBalanceHistory");var Es=F.merge(ne).merge(me).merge(vs).merge(ks).partial(),Ia=a.object({balance:un,options:Es}).strict().partial().required({balance:!0}).describe("Input for exportBalanceHistory"),ka=a.object({export:he.shape.export}).describe("Output of exportBalanceHistory");var ln=F.merge(ne).merge(me).extend({include_balance:a.boolean().describe("Return the total system balance of token"),order:Te.extend({field:a.enum(Vn)}).array(),select:ns.array(),deselect:ns.array()}).partial(),jO=a.enum(Vn),VO=a.enum(Ko),cu=a.object({foreign:a.string(),type:Ne,metadata:Z,belongs_to:z}).partial(),Jc=nu,Kc=Ae(Jc,cu),Yc=a.union([cu,Kc.array()]),qt=a.object({token:Yc,options:ln.optional()}).strict().partial().describe("Input for findTokenMany"),va=a.object({tokens:Qn.partial().array().describe("Found tokens"),metadata:be}).partial().required({tokens:!0,metadata:!0}).describe("Output of findTokenMany");var Ms=ln,wa=qt.extend({options:Ms.optional()}).describe("Input of exportTokenMany"),Ea=he.describe("Output of exportTokenMany");var Rs=sn.extend({transfers_count:a.number().describe("Number of transfers in the group").optional()}),cn=F.merge(ne).merge(me).extend({return_transfers_count:a.boolean().default(!1).describe("Return number of transfers in the transfer_group"),order:Te.extend({field:a.enum(ts)}).array(),select:Rs.keyof().array(),deselect:Rs.keyof().array()}).partial(),fu=a.object({identifier:B.shape.identifier,status:ye,type:Ke,transfer_status:j,reverses:ue,metadata:Z}).partial(),Xc=S(d({},es),{identifiers:[...es.identifiers,"transfer_group","reverses"]}),ef=Ae(Xc,fu),fn=a.union([fu,ef.array()]),Qt=a.object({transfer_group:fn,options:cn}).strict().partial().describe("Input for findTransferGroup"),Ma=a.object({transfer_groups:Rs.partial().array().describe("Found transfers"),metadata:be}).partial().required({transfer_groups:!0,metadata:!0}).describe("Output of findTransferGroup");var tf=cn,Ra=Qt.extend({options:tf.optional()}).partial().describe("Input of exportTransferGroupManyMany"),Ga=he.describe("Output of exportTransferGroupMany");var rf=pn.omit({return_running_balance_for_wallet:!0,return_signed_amount_for_wallet:!0}),Wa=Zt.extend({options:rf.optional()}).describe("Input of exportTransferMany"),Ca=he.describe("Output of exportTransferMany");var mn=F.merge(ne).merge(me).extend({include_balance_for_token:K.describe("If specified each wallet will have its balance included"),order:Te.extend({field:Zn}).array(),select:Zn.array(),deselect:Zn.array()}).partial(),mu=a.object({foreign:a.string(),name:a.string(),type:Lt,status:Vt,metadata:Z}).partial(),nf={strings:["name","type","status","foreign"],numbers:["id","balance_pending_amount","balance_finished_amount","balance_available_balance"],datetimes:["created_at","updated_at"],booleans:[],nullables:["name"],foreigns:[],identifiers:[],metadata:!0},af=Ae(nf,mu),of=a.union([mu,af.array()]),$t=a.object({wallet:of,options:mn}).strict().partial().describe("Input for findWalletMany"),Aa=a.object({wallets:Yo.partial().nullable().array().describe("Found wallets"),metadata:be}).partial().required({wallets:!0,metadata:!0}).describe("Output of findWalletMany");var sf=mn,Na=$t.extend({options:sf.optional()}).describe("Input of exportWalletMany"),Da=he.describe("Output of exportWalletMany");var Tu=It.keyof(),Gs=F.merge(ne).merge(me).extend({order:Te.extend({field:a.enum(Jo)}).array(),select:Tu.array(),deselect:Tu.array()}).partial(),hu=a.object({wallet:z,token:K,transfer:yt,type:Je,status:j,amount:G.shape.amount,pending_amount:G.shape.pending_amount,finished_amount:G.shape.finished_amount,metadata:Z}).partial(),pf={strings:["type","status"],numbers:["amount","pending_amount","finished_amount"],booleans:[],datetimes:["updated_at"],foreigns:["wallet","token"],identifiers:[],nullables:[],metadata:!0},uf=Ae(pf,hu),df=a.union([hu,uf.array()]),Ba=a.object({balance:df,options:Gs.optional()}).strict().partial().describe("Input for findBalanceMany"),Pa=a.object({balances:It.partial().array().describe("Found balances"),metadata:be}).partial().required({balances:!0,metadata:!0}).describe("Output of findBalanceMany");var lf=F.partial().required({transaction_id:!0}),Ua=a.object({action:a.enum(["commit","rollback"]).default("commit").describe("Finish transaction with commit/rollback"),options:lf}).strict().required({action:!0,options:!0}).describe("Input for finishTransaction"),gu=a.object({success:a.boolean(),message:a.string().optional().describe("Error message when success is false")}).describe("Output of finishTransaction");var Ws=F.partial(),ja=a.object({options:Ws.optional()}).strict().describe("Input for getFlags"),Va=a.object({flags:Le}).describe("Output of getFlags");var cf=a.enum(["Transfer","TransferGroup","Wallet","Token"]).default("Transfer").describe("Model to return statistics about"),ff=$e.extend({status:j}).strict().partial().describe("Filter to apply to transfers before grouping"),mf=a.enum(["type","status","transfer_status"]).default("type").describe("Field to group statistics about. Only used with group_by_field type"),Tf=rn.extend({field:mf}),hf=a.union([tn,nn,Tf]),Cs=zo.partial(),Jt=a.object({model:cf,groups:hf.array().max(5).describe("Array of grouping definitions"),aggregator:Qo,filter:ff,options:Cs}).strict().partial().describe("Input for getStatistics"),La=a.object({rows:jn}).describe("Output of getStatistics");var gf=on,Za=a.object({tokens:K.array(),options:gf.optional()}).strict().required({tokens:!0}).describe("Input for getTokenMany"),Fu=a.object({tokens:as.nullable().array()}).required({tokens:!0}).describe("Output of getTokenMany");var Ff=an,za=a.object({wallets:z.array(),options:Ff.optional()}).strict().required({wallets:!0}).describe("Input for getWalletMany"),xu=a.object({wallets:Xo.nullable().array()}).required({wallets:!0}).describe("Output of getWalletMany");var As=F.partial(),Ha=a.object({options:As}).strict().partial().describe("Input for healthcheck"),qa=a.object({status:a.enum(["green","yellow","red"]).describe("Status of the service"),message:a.string().describe("Error message if some error occurred"),database_size:a.string().describe("Size of the database in MB"),indexes_size:a.string().describe("Size of all indexes of database in MB"),connection_count:a.number().describe("Number of external connections to this database"),version:a.string().describe("Version the server is running")}).partial().required({status:!0}).describe("Output of healthcheck");var Ns=F.partial(),xf=a.object({target:a.literal("wallet"),data:bs}),Of=a.object({target:a.literal("token"),data:xs}),Sf=hs.extend({created_at:E.optional(),status_finalized_at:E.optional(),transfer_status_finalized_at:E.optional()}),bf=a.object({target:a.literal("transfer_group"),data:Sf}),Ds=a.object({identifier:T.shape.identifier,from_wallet:z,to_wallet:z,token:K,amount:T.shape.amount,metadata:T.shape.metadata,status:j,transfer_group:ue,created_at:E,status_finalized_at:E}),yf=Ds.extend({type:a.literal("regular")}).partial().required({from_wallet:!0,to_wallet:!0,token:!0,amount:!0,type:!0}),_f=Ds.extend({type:a.literal("deposit")}).partial().required({to_wallet:!0,token:!0,amount:!0,type:!0}),If=Ds.extend({type:a.literal("withdrawal")}).partial().required({from_wallet:!0,token:!0,amount:!0,type:!0}),kf=a.union([yf,_f,If]),vf=a.object({target:a.literal("transfer"),data:kf}),wf=a.union([xf,Of,bf,vf]),Kt=a.object({actions:wf.array().describe("Array of actions to import."),options:Ns}).partial().required({actions:!0}).describe("Input for importActions"),Qa=a.object({progress:a.unknown().array(),erroneous:a.unknown().array()}).partial().describe("Output of importActions");var Ef=a.object({order:Te.extend({field:a.enum(["identifier","completed_at","created_at"])}).array()}),Bs=F.merge(ne).merge(Ef).partial(),$a=a.object({export:a.object({date:E.describe("Date the file was created on"),type:dn.shape.type.describe("Entity that was exported")}).partial(),options:Bs}).partial().describe("Input for listExportMany"),Ja=a.object({exports:dn.array()}).describe("Output of listExportMany");var Mf=F.extend({exact_level:a.boolean().describe("Should query be limited to exactly defined level or greater than")}).partial(),Ka=a.object({startTime:E.describe("Log entries start time"),endTime:E.describe("Log entries end time"),tracking_id:a.string(),level:a.enum(["debug","info","warning","error"]),options:Mf}).partial().describe("Input for queryLogs"),Rf=a.object({level:a.enum(["debug","info","warning","error"]),timestamp:a.string(),payload:a.record(a.string(),a.unknown())}),Ou=a.object({logs:Rf.array()}).required({logs:!0}).describe("Output of queryLogs");var Gf=F.partial(),Ya=a.object({confirmation:a.string().describe("hash to confirm database delete"),version:a.string().describe("target semver for the database"),options:Gf}).strict().partial().describe("Input for resetDatabase"),Su=a.object({message:a.string().describe("Message about operation"),confirmation:a.string().describe("confirmation hash to resend")}).partial().describe("Output of resetDatabase");var Yt=T.pick({metadata:!0,status:!0,updated_at:!0}).extend({extend_metadata:T.shape.metadata}).partial(),Ib=Yt.keyof(),Ps=F.extend({return_from_balance:a.boolean().default(!1).describe("Whether the request should also return from wallet balance"),return_to_balance:a.boolean().default(!1).describe("Whether the request should also return to wallet balance"),return_when_not_updated:a.boolean().default(!1).describe("Whether the request should return the transfer object even if it was not updated"),metadata_action:Ee}).partial(),Xa=a.object({transfer:yt,update:Yt,options:Ps.optional()}).strict().describe("Input for updateTransfer"),Xt=a.object({transfer:re.describe("Updated transfer object"),updated:a.boolean().describe("Boolean showing if the transfer was updated"),from_balance:It.describe("Debited wallet balance"),to_balance:It.describe("Credited wallet balance")}).partial().describe("Output of updateTransfer");var Wf=a.object({reverse_deposit:a.boolean().default(!1).describe("Whether to create withdrawal transaction for deposit (will default to pending)"),reverse_withdrawal:a.boolean().default(!1).describe("Whether to create deposit transaction for withdrawal (will default to pending)"),return_from_balance:a.boolean().default(!1).describe("Whether the request should also return from wallet balance"),return_to_balance:a.boolean().default(!1).describe("Whether the request should also return to wallet balance"),metadata_action:St}),Cf=a.object({status:X,identifier:Ye.shape.identifier,force:Ye.shape.force,metadata:Ye.shape.metadata,extend_metadata:Ye.shape.metadata}).strict().partial().describe("In case the transfer will be made then apply these modifications"),Us=F.merge(Wf).partial(),eo=a.object({transfer:yt,reverse:Cf,options:Us}).partial().required({transfer:!0}).describe("Input for reverseTransfer"),to=Xt.describe("Output of reverseTransfer");var Af=a.object({reverse_deposit:a.boolean().default(!1).describe("Whether to create withdrawal transaction for deposits (will default to pending)"),reverse_withdrawal:a.boolean().default(!1).describe("Whether to create deposit transaction for withdrawals (will default to pending)"),return_transfers:a.boolean().describe("Should the update return all transfers belonging to group"),validate_final_balance_only:a.boolean().default(!1).describe("If true then transfers within a group will ignore balance restrictions. Only final transfers for wallets are checked."),metadata_action:St,transfer_metadata_action:St}).strict().partial(),Tn=F.merge(Af).partial(),js=a.object({status:ye,transfer_status:X,identifier:B.shape.identifier,force:T.shape.force,metadata:B.shape.metadata,transfer_metadata:T.shape.metadata,extend_metadata:B.shape.metadata.describe("Key value object to be merged with existing metadata"),transfer_extend_metadata:T.shape.metadata.describe("Key value object to be merged with each transfers existing metadata")}).strict().partial().describe("In case the transferGroup will be made then apply these modifications"),ro=a.object({transfer_group:ue,reverse:js,options:Tn}).partial().required({transfer_group:!0}).describe("Input for reverseTranferGroup"),no=a.object({transfer_group:B,transfers:re.array().describe("Updated transfers")}).partial().describe("Output of reverseTranferGroup");var Nf=js.omit({identifier:!0}),ao=a.object({transfer_group:fn,reverse:Nf,options:Tn}).strict().partial().required({transfer_group:!0}).describe("Input for reverseTranferGroupMany"),bu=a.object({transfer_groups:B.array().describe("Reversed transfer groups"),transfers:re.array().describe("Created transfer objects")}).partial().describe("Output of reverseTranferGroupMany");var Vs=a.object({status:X,force:T.shape.force,metadata:T.shape.metadata}).partial(),Ls=F.extend({reverse_deposit:a.boolean().describe("Whether to create withdrawal transaction for deposit (will default to pending)"),reverse_withdrawal:a.boolean().describe("Whether to create deposit transaction for withdrawal (will default to pending)"),metadata_action:St}).partial(),oo=a.object({transfer:_t,reverse:Vs,options:Ls}).strict().partial().required({transfer:!0}).describe("Input for reverseTranferMany"),so=a.object({transfers:re.array().describe("Created transfer array")}).partial().describe("Output of reverseTranferMany");var Zs=F.partial(),io=a.object({flags:Le.partial(),options:Zs}).strict().partial().required({flags:!0}).describe("Input for setFlags"),po=a.object({flags:Le,message:a.string().describe("optional message")}).strict().partial().required({flags:!0}).describe("Output of setFlags");var Df=F.partial(),uo=a.object({options:Df}).strict().partial().describe("Input for startTransaction"),yu=a.object({transaction_id:a.string().describe("id of the created transaction")}).partial().describe("Output of startTransaction");var zs=F.partial().extend({return_when_not_updated:a.boolean().default(!1).describe("Whether the request should return the token object even if it was not updated")}),_u=U.pick({metadata:!0,status:!0,public:!0}).partial(),dy=_u.keyof(),lo=a.object({token:K,update:_u,options:zs.optional()}).strict().describe("Input for updateToken"),co=a.object({token:U,updated:a.boolean().describe("Boolean showing if the token was updated")}).partial().describe("Output of updateToken");var Hs=a.object({status:ye.describe("Lifecycle status of the TransferGroup"),transfer_status:j.describe("Status all the transfers should be set at."),metadata:B.shape.metadata.describe("Key value object to be replaced or extended with existing TransferGroup metadata"),transfer_metadata:T.shape.metadata.describe("Key value object to be replaced or extended with existing Transfer metadata")}).partial().describe("Changes to be made to the transfer_group"),hn=Hs.refine(r=>Object.values(r).some(e=>e!==void 0),{message:"One of the fields must be defined"}),Fy=Hs.keyof(),gn=F.extend({return_transfers:a.boolean().describe("Should the update return all transfers belonging to group"),return_when_not_updated:a.boolean().default(!1).describe("Whether the request should return the transfer_group object even if it was not updated"),metadata_action:Ee,transfer_metadata_action:Ee}).partial(),fo=a.object({transfer_group:ue,update:hn,options:gn.optional()}).strict().describe("Input for updateTransferGroup"),mo=a.object({transfer_group:B,updated:a.boolean().describe("Boolean showing if the transfer_group was updated"),transfers:re.array().describe("Updated transfers")}).partial().describe("Output of updateTransferGroup");var qs=gn,To=a.object({transfer_group:fn,update:hn,options:qs}).strict().partial().required({transfer_group:!0,update:!0}).describe("Input for updateTransferGroupMany"),ho=a.object({transfer_groups:sn.array().describe("Updated transfer groups"),transfers:re.array().describe("Updated transfers"),updated:a.boolean().describe("Boolean showing if the transfer_group were updated")}).partial().describe("Output of updateTransferGroupMany");var Qs=F.extend({metadata_action:Ee}).partial(),go=a.object({transfer:_t,update:Yt,options:Qs}).strict().partial().required({transfer:!0,update:!0}).describe("Input for updateTransferMany"),Fo=a.object({transfers:re.array().describe("Updated transfers"),updated:a.boolean().describe("Boolean showing if the transfers were updated")}).partial().describe("Output of updateTransferMany");var $s=F.extend({return_when_not_updated:a.boolean().default(!1).describe("Whether the request should return the wallet object even if it was not updated")}).partial(),Iu=P.pick({metadata:!0,status:!0,name:!0}),Ny=Iu.keyof(),xo=a.object({wallet:z,update:Iu.partial(),options:$s.optional()}).strict().describe("Input for updateWallet"),Oo=a.object({wallet:P,updated:a.boolean().describe("Boolean showing if the wallet was updated")}).partial().describe("Output of updateWallet");var Js={aggregateTransferMany:i(ea).validateInputWOptions,authenticationCheck:i(ra).validateInputWOptions,createAccessToken:i(na).validateInputWOptions,createContract:i(ua).validateInputWOptions,createDeposit:i(la).validateInputWOptions,createDistribution:i(fa).validateInputWOptions,createToken:i(ma).validateInputWOptions,createTransfer:i(ia).validateInputWOptions,createTransferGroup:i(pa).validateInputWOptions,createTransferMany:i(ha).validateInputWOptions,createWallet:i(Fa).validateInputWOptions,createWithdrawal:i(Oa).validateInputWOptions,exportBalanceHistory:i(Ia).validateInputWOptions,exportTokenMany:i(wa).validateInputWOptions,exportTransferGroupMany:i(Ra).validateInputWOptions,exportTransferMany:i(Wa).validateInputWOptions,exportWalletMany:i(Na).validateInputWOptions,findBalanceMany:i(Ba).validateInputWOptions,findTokenMany:i(qt).validateInputWOptions,findTransferGroupMany:i(Qt).validateInputWOptions,findTransferMany:i(Zt).validateInputWOptions,findWalletMany:i($t).validateInputWOptions,finishTransaction:i(Ua).validateInputWOptions,getBalance:i(oa).validateInputWOptions,getBalanceHistory:i(ya).validateInputWOptions,getExport:i(ba).validateInputWOptions,getFlags:i(ja).validateInputWOptions,getStatistics:i(Jt).validateInputWOptions,getToken:i($n).validateInputWOptions,getTokenMany:i(Za).validateInputWOptions,getTransfer:i(qn).validateInputWOptions,getTransferGroup:i(Kn).validateInputWOptions,getWallet:i(Ln).validateInputWOptions,getWalletMany:i(za).validateInputWOptions,healthcheck:i(Ha).validateInputWOptions,importActions:i(Kt).validateInputWOptions,listExportMany:i($a).validateInputWOptions,queryLogs:i(Ka).validateInputWOptions,resetDatabase:i(Ya).validateInputWOptions,reverseTransfer:i(eo).validateInputWOptions,reverseTransferGroup:i(ro).validateInputWOptions,reverseTransferGroupMany:i(ao).validateInputWOptions,reverseTransferMany:i(oo).validateInputWOptions,setFlags:i(io).validateInputWOptions,startTransaction:i(uo).validateInputWOptions,updateToken:i(lo).validateInputWOptions,updateTransfer:i(Xa).validateInputWOptions,updateTransferGroup:i(fo).validateInputWOptions,updateTransferGroupMany:i(To).validateInputWOptions,updateTransferMany:i(go).validateInputWOptions,updateWallet:i(xo).validateInputWOptions},Ks=(w=>(w.aggregateTransferMany="aggregateTransferMany",w.authenticationCheck="authenticationCheck",w.createAccessToken="createAccessToken",w.createContract="createContract",w.createDeposit="createDeposit",w.createDistribution="createDistribution",w.createToken="createToken",w.createTransfer="createTransfer",w.createTransferGroup="createTransferGroup",w.createTransferMany="createTransferMany",w.createWallet="createWallet",w.createWithdrawal="createWithdrawal",w.exportBalanceHistory="exportBalanceHistory",w.exportTokenMany="exportTokenMany",w.exportTransferGroupMany="exportTransferGroupMany",w.exportTransferMany="exportTransferMany",w.exportWalletMany="exportWalletMany",w.findBalanceMany="findBalanceMany",w.findTokenMany="findTokenMany",w.findTransferGroupMany="findTransferGroupMany",w.findTransferMany="findTransferMany",w.findWalletMany="findWalletMany",w.finishTransaction="finishTransaction",w.getBalance="getBalance",w.getBalanceHistory="getBalanceHistory",w.getExport="getExport",w.getFlags="getFlags",w.getStatistics="getStatistics",w.getToken="getToken",w.getTokenMany="getTokenMany",w.getTransfer="getTransfer",w.getTransferGroup="getTransferGroup",w.getWallet="getWallet",w.getWalletMany="getWalletMany",w.healthcheck="healthcheck",w.importActions="importActions",w.listExportMany="listExportMany",w.queryLogs="queryLogs",w.resetDatabase="resetDatabase",w.reverseTransfer="reverseTransfer",w.reverseTransferGroup="reverseTransferGroup",w.reverseTransferGroupMany="reverseTransferGroupMany",w.reverseTransferMany="reverseTransferMany",w.setFlags="setFlags",w.startTransaction="startTransaction",w.updateToken="updateToken",w.updateTransfer="updateTransfer",w.updateTransferGroup="updateTransferGroup",w.updateTransferGroupMany="updateTransferGroupMany",w.updateTransferMany="updateTransferMany",w.updateWallet="updateWallet",w))(Ks||{});var Bf=r=>{let{success:e}=Kt.safeParse(r);return e},er=class{constructor(e,t,o){v(this,"type");v(this,"_connection");v(this,"$connect");v(this,"connectionType");v(this,"jwt");v(this,"host");v(this,"isConnected",!1);v(this,"socId");v(this,"hooks",new Proxy({},{set(e,t,o){if(typeof o!="function")throw new TypeError("Hooks can only be functions");return e[t]=o,!0}}));v(this,"_requests",new Map);v(this,"_error",!1);v(this,"_sending",new Map);v(this,"sendingTimeout");this.type=t,this._connection=e,this.connectionType=t,this.$connect=o}_setConnected(e){this.$connect=void 0,e&&this._error!==!1&&(this._error=!1),!this.isConnected&&e&&this.hooks.connected&&this.hooks.connected(this.socId),this.isConnected&&!e&&this.hooks.disconnected&&this.hooks.disconnected(),this.isConnected=e}_setErrored(e){this._error=e,this._setConnected(!1)}_clearError(){this._error=!1}_send(e){throw new Error("This method must be implemented by child class")}_reconnect(e){throw new Error("This method must be implemented by child class")}close(){return Q(this,null,function*(){throw new Error("This method must be implemented by child class")})}_connectionLost(){this._requests.forEach((e,t)=>{"stream"in e&&e.stream.destroy(new ke("CONNECTION_LOST",{method:"connectionLost"})),this._requests.delete(t)}),this.socId=void 0}_handleMessage(e){var u,l,c,f;if(this.hooks.message&&this.hooks.message(e),"method"in e){let x=e;if(x.method==="ping"){this._send({jsonrpc:"2.0",result:"pong",id:x.id});return}W("Unexpected JSONRPCRequest",e);return}let t=e;if(this.hooks.message&&this.hooks.message(t),t.id===null){W("Unexpected JSONRPCResponse",e);return}if(t.result==="ack"){clearTimeout((u=this._sending.get(t.id))==null?void 0:u.timeout),this._sending.delete(t.id);return}let o=this._requests.get(t.id);if(!o){W("No Request found for incoming",e);return}if("handle"in o){o.handle(t),delete o.handle;return}t.error&&"error"in o&&o.error(t.error);let n=t;if(((l=n.result)==null?void 0:l.type)==="streamPause"&&"pause"in o){o.pause();return}if(((c=n.result)==null?void 0:c.type)==="streamResume"&&"resume"in o){o.resume();return}let{stream:s,start:p}=o;if(((f=n.result)==null?void 0:f.type)==="streamChunk"){s.push(n.result);return}s.push(n),s.destroyed||s.push(null),n.id&&this._requests.delete(n.id),this.connectionType==="ws"&&this._send({jsonrpc:"2.0",method:"ack",params:Date.now()-p,id:n.id})}_sendTransaction(e,t){let o=Js[e](t);return this._sendRaw(e,o)}_setSending(e,t){if(e.id===null)throw new Error("JSONRPCMessage should not be null");this._sending.set(e.id,d({},this.sendingTimeout&&{timeout:setTimeout(()=>{this._sending.delete(e.id),t.push({error:new ge("SENDING_TIMEOUT",{timeout:this.sendingTimeout}).toJSON()}),this._requests.delete(e.id)},this.sendingTimeout)}))}_sendRaw(e,t){let o={jsonrpc:"2.0",method:e,params:t,id:nt()};return this.hooks.preflight&&this.hooks.preflight(o)===!1?new Be:new Be(n=>Q(this,null,function*(){if(this._error&&this._reconnect(5),this.isConnected||(yield this.$connect),this._error)throw this._error;this._requests.set(o.id,{stream:n,start:Date.now()}),this._setSending(o,n),this._send(o)}))}_streamTransaction(e,t,o,n){let s=Date.now(),p=nt(),u,l=({stream:I,method:H,params:ae})=>{if(u)return;let V={jsonrpc:"2.0",method:H,params:d({streamId:p},ae),id:nt()};this._setSending(V,I),this._send(V)},c=(I,H)=>{u||(l({stream:I,method:"streamError",params:{error:H}}),u=H,I.push({error:H}))},f=new Rn,x=n?f.pipe(n):f,y={jsonrpc:"2.0",method:"streamStart",params:{method:e,options:o},id:p};return this.hooks.preflight&&this.hooks.preflight(y)===!1?new Qr:new Qr(I=>Q(this,null,function*(){if(this._error&&this._reconnect(5),this.isConnected||(yield this.$connect),this._error)throw this._error;let H=setTimeout(()=>{I.push({error:new ke("INPUT_STREAM_TIMEOUT",{streamId:p})})},3e4);this._requests.set(y.id,{stream:I,start:s,error(ae){u=ae,W("stream:error()>",ae)},pause(){f.pause()},resume(){f.resume()},handle(ae){if(ae.error){I.push(ae);return}x.on("data",V=>{if(!u){if(H&&(clearTimeout(H),H=null),!t(V)){c(I,new ke("INVALID_INPUT_STREAM_CHUNK",{streamId:p,chunk:V}));return}l({stream:I,method:"streamData",params:{data:V}})}}).on("error",V=>{u||(H&&(clearTimeout(H),H=null),l({stream:I,method:"streamError",params:{error:V}}),I.push({error:new ke("INPUT_STREAM_ERROR",{streamId:p,error:V})}))}).on("end",()=>{H&&(clearTimeout(H),H=null),l({stream:I,method:"streamEnd",params:{}})})}}),this._setSending(y,I),this._send(y)}),f)}aggregateTransferMany(e){return this._sendTransaction("aggregateTransferMany",e)}authenticationCheck(e){return this._sendTransaction("authenticationCheck",e!=null?e:{})}createAccessToken(e){return this._sendTransaction("createAccessToken",e)}createContract(e){return this._sendTransaction("createContract",e)}createDeposit(e){return this._sendTransaction("createDeposit",e)}createDistribution(e){return this._sendTransaction("createDistribution",e)}createToken(e){return this._sendTransaction("createToken",e)}createTransfer(e){return this._sendTransaction("createTransfer",e)}createTransferGroup(e){return this._sendTransaction("createTransferGroup",e!=null?e:{})}createTransferMany(e){return this._sendTransaction("createTransferMany",e)}createWallet(e){return this._sendTransaction("createWallet",e)}createWithdrawal(e){return this._sendTransaction("createWithdrawal",e)}exportBalanceHistory(e){return this._sendTransaction("exportBalanceHistory",e)}exportTokenMany(e){return this._sendTransaction("exportTokenMany",e!=null?e:{})}exportTransferGroupMany(e){return this._sendTransaction("exportTransferGroupMany",e!=null?e:{})}exportTransferMany(e){return this._sendTransaction("exportTransferMany",e!=null?e:{})}exportWalletMany(e){return this._sendTransaction("exportWalletMany",e!=null?e:{})}findBalanceMany(e){return this._sendTransaction("findBalanceMany",e!=null?e:{})}findTokenMany(e){return this._sendTransaction("findTokenMany",e!=null?e:{})}findTransferGroupMany(e){return this._sendTransaction("findTransferGroupMany",e!=null?e:{})}findTransferMany(e){return this._sendTransaction("findTransferMany",e!=null?e:{})}findWalletMany(e){return this._sendTransaction("findWalletMany",e!=null?e:{})}finishTransaction(e){return this._sendTransaction("finishTransaction",e)}getBalance(e){return this._sendTransaction("getBalance",e)}getBalanceHistory(e){return this._sendTransaction("getBalanceHistory",e)}getExport(e){return this._sendTransaction("getExport",e)}getFlags(e){return this._sendTransaction("getFlags",e!=null?e:{})}getStatistics(e){return this._sendTransaction("getStatistics",e!=null?e:{})}getToken(e){return this._sendTransaction("getToken",e)}getTokenMany(e){return this._sendTransaction("getTokenMany",e)}getTransfer(e){return this._sendTransaction("getTransfer",e)}getTransferGroup(e){return this._sendTransaction("getTransferGroup",e)}getWallet(e){return this._sendTransaction("getWallet",e)}getWalletMany(e){return this._sendTransaction("getWalletMany",e)}healthcheck(e){return this._sendTransaction("healthcheck",e!=null?e:{})}importActions(e){return this._sendTransaction("importActions",e)}importActionsStream(e,t){return this._streamTransaction("importActions",Bf,e,t)}listExportMany(e){return this._sendTransaction("listExportMany",e!=null?e:{})}queryLogs(e){return this._sendTransaction("queryLogs",e!=null?e:{})}resetDatabase(e){return this._sendTransaction("resetDatabase",e!=null?e:{})}reverseTransfer(e){return this._sendTransaction("reverseTransfer",e)}reverseTransferGroup(e){return this._sendTransaction("reverseTransferGroup",e)}reverseTransferGroupMany(e){return this._sendTransaction("reverseTransferGroupMany",e)}reverseTransferMany(e){return this._sendTransaction("reverseTransferMany",e)}setFlags(e){return this._sendTransaction("setFlags",e)}startTransaction(e){return this._sendTransaction("startTransaction",e!=null?e:{})}updateToken(e){return this._sendTransaction("updateToken",e)}updateTransfer(e){return this._sendTransaction("updateTransfer",e)}updateTransferGroup(e){return this._sendTransaction("updateTransferGroup",e)}updateTransferGroupMany(e){return this._sendTransaction("updateTransferGroupMany",e)}updateTransferMany(e){return this._sendTransaction("updateTransferMany",e)}updateWallet(e){return this._sendTransaction("updateWallet",e)}};var ku,Pf=(ku=window.WAPI_VERSION)!=null?ku:"";function Xs(r,e){let t=vu(r,{timeout:e==null?void 0:e.connectingTimeout});return new Ys(t,r,e)}function vu(r,e){var ae;let t=d({rejectUnauthorized:(ae=r.rejectUnauthorized)!=null?ae:!0,connectionName:e==null?void 0:e.connectionName,clientVersion:Pf},r),o=Op(t),n=new cp(...o),s,p,u=!1,l;n.onclose=c,n.onerror=f,n.onmessage=x;function c(V){if(W(`createConnection>close(reason:${V.reason},code:${V.code},wasClean:${V.wasClean})`),V.code===4030)return I(new Et);I(new Error("WS closed"))}function f(V){W(`createConnection>error(message:${V.message},error:${V.error},type:${V.type})`),I(V.error)}function x(V){W(`createConnection>message(type:${V.type},data:${V.data})`);let{data:tt}=V,bo;try{bo=JSON.parse(tt.toString())}catch(kd){return W("Invalid JSON response",kd),I(new Error("Invalid JSON response"))}if(bo.result!=="ready")return W("Invalid first message"),I(new Error("Invalid first message - "+JSON.stringify(bo)));I()}W(`createConnection>(message:setting up ws connection${e!=null&&e.timeout?" with timeout "+e.timeout:""})`);let y=e!=null&&e.timeout?setTimeout(()=>{I(new ge("CONNECTION_TIMEOUT",{timeout:e.timeout}))},e.timeout):void 0;function I(V){u||(clearTimeout(y),n.onmessage=()=>{},n.onerror=()=>{},n.onclose=()=>{},V?(p(V),n.close()):s(l),u=!0)}let H=new Promise((V,tt)=>{s=V,p=tt});return{ws:n,$connect:H}}var Ys=class extends er{constructor(t,o,n){var s;super(t.ws,"ws",t.$connect);v(this,"_pingTimeout");v(this,"_opts");v(this,"_connectionConfig");v(this,"_tryToReconnect",!0);this._opts=o,this._connectionConfig=n,this.host=o.host,(s=this.$connect)==null||s.then(p=>(this.socId=p,this._ready())).catch(p=>{this.socId||this._setErrored(p)})}_setErrored(t){super._setErrored(t),(t instanceof Et||"code"in t&&t.code===$.AUTH.ERRORS.AUTHENTICATION_ERROR.code)&&(this._tryToReconnect=!1)}_ready(){this._setConnected(!0),this._connection.onmessage=t=>{let{data:o,type:n}=t;if(W(`message(type:${n},data:$0)`,o),n==="message"){let s=JSON.parse(o.toString());this._handleMessage(s),this._heartbeat()}},this._connection.onerror=t=>{let{message:o,error:n,type:s}=t;W(`error(message:$0,error:$1,type:${s})`,o,n)},this._connection.onclose=t=>{let{reason:o,code:n,wasClean:s}=t;W(`close(reason:$0,code:${n},wasClean:${s})`,o),this._setConnected(!1),clearTimeout(this._pingTimeout),this._connectionLost(),this._reconnect()},this._heartbeat()}_reconnect(t){if(W("reconnect(),tryToReconnect:",this._tryToReconnect),!this._tryToReconnect)return;if(this.hooks.reconnect&&this.hooks.reconnect()===!1){W("reconnect hook returned false");return}if(this.$connect){W("already connecting");return}super._clearError(),t!=null||(t=window.WAPI_RECONNECT_ATTEMPTS&&parseInt(window.WAPI_RECONNECT_ATTEMPTS)||10);let o=window.WAPI_MAX_RECONNECT_WAIT&&parseInt(window.WAPI_MAX_RECONNECT_WAIT)||1e4;this.$connect=Q(this,null,function*(){var s,p,u;let n;for(let l=0;l<t+1;l++)try{W("Trying to connect, attempt:",l);let{ws:c,$connect:f}=vu(this._opts,{timeout:(s=this._connectionConfig)==null?void 0:s.reconnectingTimeout});n=yield f,this.socId=n,this._connection=c,this._ready();break}catch(c){let f=c.code===$.AUTH.ERRORS.AUTHENTICATION_ERROR.code,x=l>t-1;if(f||x){this._setErrored(c),(u=(p=this.hooks).reconnectError)==null||u.call(p,c);break}yield Fp(Math.min(Math.pow(1.5,l)*1e3,o))}return n})}_heartbeat(){W("heartbeat"),clearTimeout(this._pingTimeout),this._pingTimeout=setTimeout(()=>{if(this._sending.size)return W("pingTimeout reached, but sending.size:",this._sending.size),this._heartbeat();W("timeout"),this._connection.close(),this._setConnected(!1),this._reconnect()},31e3)}_send(t){W("send()",t),this._connection.send(JSON.stringify(t))}close(){return Q(this,null,function*(){return W("close()"),this._tryToReconnect=!1,clearTimeout(this._pingTimeout),this._setConnected(!1),this._connection.close()})}};var ei=typeof globalThis!="undefined"&&globalThis||typeof self!="undefined"&&self||typeof ei!="undefined"&&ei,ti=ei.fetch;function ni(r,e){let t=Uf(r,{timeout:e==null?void 0:e.connectingTimeout,skipInit:e==null?void 0:e.httpSkipInitialAuthConnection,connectionName:e==null?void 0:e.connectionName});return new ri(t,r)}function Uf(r,e){let t=r.host.replace(/^wss:/,"https:"),o="x-wapi-req-id",n="x-wapi-conn-name";function s(c){return Q(this,null,function*(){W("http_createConnection>message(body:$0)",c)})}function p(c,f){return Q(this,null,function*(){let x=JSON.parse(c),I=yield(yield ti(`${t}/api`,{keepalive:!0,method:"POST",headers:d({Authorization:`Bearer ${f}`,"content-type":"application/json",[o]:x==null?void 0:x.id},e!=null&&e.connectionName?{[n]:e==null?void 0:e.connectionName}:{}),body:c})).json();this.onmessage(S(d({},I),{id:x.id}))})}let u=nt(),l=new Promise((c,f)=>{if(e!=null&&e.skipInit)return c(void 0);let x=new AbortController;W(`createConnection(sending http auth request${e!=null&&e.timeout?" with timeout "+e.timeout:""})`);let y=e!=null&&e.timeout?setTimeout(()=>{x.abort(),f(new ge("CONNECTION_TIMEOUT",{timeout:e.timeout}))},e.timeout):void 0;ti(`${t}/api`,{method:"POST",headers:d({Authorization:`Bearer ${r.jwt}`,"content-type":"application/json",[o]:u},e!=null&&e.connectionName?{[n]:e==null?void 0:e.connectionName}:{}),body:JSON.stringify({jsonrpc:"2.0",method:"authenticationCheck",params:{},id:u}),signal:x.signal}).then(I=>I.json()).then(I=>{if(clearTimeout(y),I.error)throw new Error(I.error.message);c(void 0)}).catch(f)});return{send:p,onmessage:s,$connect:l}}var ri=class extends er{constructor(e,t){var o;super(e,"https",e.$connect),this.host=t.host,this.jwt=t.jwt,(o=this.$connect)==null||o.then(()=>{this._ready()}).catch(n=>{this._setErrored(n)})}_send(e){W("send()",e),this._connection.send(JSON.stringify(e),this.jwt)}_ready(){this._setConnected(!0),this._connection.onmessage=e=>Q(this,null,function*(){W("http_message($0)>",e),this._handleMessage(e)})}close(){return Q(this,null,function*(){W("close()"),this._setConnected(!1)})}_reconnect(){return Q(this,null,function*(){W("reconnect()")})}};var oi=class r{constructor(e){v(this,"filter",[]);v(this,"modifierFn");this.modifierFn=e}add(e){return this.filter.push(e),this}addWhere(e,t,o,n){if(typeof t=="object"){let s={};for(let[p,u]of Object.entries(t))s[p]=this.modifierFn?this.modifierFn(p,u):u;return this.add({function:e,value:s})}if(typeof t=="function"){let s=new r(this.modifierFn);return t.call(s,s),this.add({function:e,inner:s.toJSON().filter})}if(n!==void 0)return this.add({function:e,field:t,operator:o,value:n});if(typeof o=="object")return this.add({function:e,value:{[t]:o}});if(o!==void 0){let s=this.modifierFn?this.modifierFn(t,o):o;return this.add({function:e,field:t,value:s})}throw TypeError("Invalid input")}where(e,t,o){return this.addWhere("where",e,t,o)}orWhere(e,t,o){return this.addWhere("orWhere",e,t,o)}whereIn(e,t){return this.add({function:"whereIn",field:e,value:t})}orWhereIn(e,t){return this.add({function:"orWhereIn",field:e,value:t})}whereNull(e){return this.add({function:"whereNull",field:e})}orWhereNull(e){return this.add({function:"orWhereNull",field:e})}whereNotNull(e){return this.add({function:"whereNotNull",field:e})}orWhereNotNull(e){return this.add({function:"orWhereNotNull",field:e})}whereMetadata(e,t,o){return o===void 0?this.add({function:"whereMetadata",field:e,operator:"=",value:t}):this.add({function:"whereMetadata",field:e,operator:t,value:o})}orWhereMetadata(e,t,o){return o===void 0?this.add({function:"orWhereMetadata",field:e,operator:"=",value:t}):this.add({function:"orWhereMetadata",field:e,operator:t,value:o})}whereMetadataIn(e,t){return this.add({function:"whereMetadataIn",field:e,value:t})}orWhereMetadataIn(e,t){return this.add({function:"orWhereMetadataIn",field:e,value:t})}whereMetadataNull(e){return this.add({function:"whereMetadataNull",field:e})}orWhereMetadataNull(e){return this.add({function:"orWhereMetadataNull",field:e})}whereMetadataNotNull(e){return this.add({function:"whereMetadataNotNull",field:e})}orWhereMetadataNotNull(e){return this.add({function:"orWhereMetadataNotNull",field:e})}toJSON(){return{filter:JSON.parse(JSON.stringify(this.filter))}}};function ai(r){return r.map(e=>{if(typeof e=="string"){if(e.includes(" "))throw new TypeError("invalid order option: "+e);return{field:e,direction:"asc"}}return{field:e.column,direction:e.order,nulls:e.nulls}})}var kt=class extends oi{constructor({start:t,modifiers:o,optionsModifiers:n}){super(o);v(this,"execFn");v(this,"optionsObject",{});v(this,"optionsModifiers");this.execFn=t,this.optionsModifiers=n}start(){return this.execFn(this.toJSON())}toJSON(){return S(d({},super.toJSON()),{options:d({},this.optionsObject)})}options(t){if(this.optionsModifiers===void 0)return this.optionsObject=d(d({},this.optionsObject),t),this;this.optionsObject=d({},this.optionsObject);for(let[o,n]of Object.entries(t))this.optionsObject[o]=this.optionsModifiers(o,n);return this}then(t,o){return this.start().then(t,o)}catch(t){return this.start().catch(t)}stream(){return this.start().stream()}},ee=class extends kt{constructor({start:e,modifiers:t,optionsModifiers:o}){super({start:n=>e(n),modifiers:t,optionsModifiers:o})}limit(e){return this.optionsObject.limit=e,this}offset(e){return this.optionsObject.offset=e,this}orderBy(e,t,o){if(!Array.isArray(e)&&typeof e!="string")throw new TypeError("invalid input");if(Array.isArray(e))return this.optionsObject.order=ai(e),this;if(!e.includes(" "))return this.optionsObject.order=ai([{column:e,order:t||"asc",nulls:o}]),this;let[n,s,p,u]=e.split(" ");if(s!=="asc"&&s!=="desc")throw new TypeError("invalid order");let l={column:n,order:s};if(p==="nulls"){if(!["first","last"].includes(u))throw new TypeError("invalid nulls order");l.nulls=u}return this.optionsObject.order=ai([e]),this}select(...e){return this.optionsObject.select=e,this}deselect(...e){return this.optionsObject.deselect=e,this}};function tr(r,e){if(!e)return{function:r,alias:r};if(!e.includes(" "))return{function:r,field:e,alias:r};if(!e.includes(" as "))throw new q("UNCLEAR_AGGREGATOR",{input:e});let[t,o]=e.split(" as ");return{function:r,field:t,alias:o||t}}var Fn=class extends kt{constructor({start:t,modifiers:o,optionsModifiers:n}){super({start:s=>t(s),modifiers:o,optionsModifiers:n});v(this,"aggregatorObject",{aggregators:[]});v(this,"timezoneString","")}toJSON(){return S(d({},super.toJSON()),{aggregators:JSON.parse(JSON.stringify(this.aggregatorObject.aggregators)),groups:JSON.parse(JSON.stringify(this.aggregatorObject.groups||[]))})}timezone(t){return this.timezoneString=t,this.aggregatorObject.groups&&Array.isArray(this.aggregatorObject.groups)&&this.aggregatorObject.groups.forEach(o=>{o.type==="period"&&(o.field={period:o.field,timezone:t})}),this}groupBy(t,...o){let n={};if(typeof t!="string")throw new TypeError("expected string as input, got"+typeof t);let[s,p]=t.split(" as ");if(zp.hasOwnProperty(s))n.type="period",n.alias=p||s,this.timezoneString?n.field={period:s,timezone:this.timezoneString}:n.field=s;else if(s.startsWith("metadata.")){let[,u]=s.split(".");n.type="metadata_field",n.field=u,n.alias=p||u}else n.type="field",n.field=s,n.alias=p||s;return this.aggregatorObject.groups?this.aggregatorObject.groups.push(n):this.aggregatorObject.groups=[n],o.length&&o.forEach(u=>this.groupBy(u)),this}count(t){return this.aggregatorObject.aggregators.push(tr("count",t)),this}distinct(t){return this.aggregatorObject.aggregators.push(tr("countDistinct",t)),this}avg(t){return this.aggregatorObject.aggregators.push(tr("average",t)),this}min(t){return this.aggregatorObject.aggregators.push(tr("min",t)),this}max(t){return this.aggregatorObject.aggregators.push(tr("max",t)),this}sum(t){return this.aggregatorObject.aggregators.push(tr("sum",t)),this}},vt=class extends kt{constructor({start:t,modifiers:o,optionsModifiers:n}){super({start:s=>t(s),modifiers:o,optionsModifiers:n});v(this,"updateObject",{})}toJSON(){return S(d({},super.toJSON()),{update:JSON.parse(JSON.stringify(this.updateObject))})}update(t){return this.updateObject=Object.assign(this.updateObject,t),this}},xn=class extends kt{constructor({start:t,modifiers:o,optionsModifiers:n}){super({start:s=>t(s),modifiers:o,optionsModifiers:n});v(this,"reverseModifications",{})}toJSON(){return S(d({},super.toJSON()),{reverse:JSON.parse(JSON.stringify(this.reverseModifications))})}reverse(t){return this.reverseModifications=Object.assign(this.reverseModifications,t),this}};var de=a.object({order_by:a.string().describe("Ordering options in string format")}).describe("extra find options for client functions"),bI=ne.merge(Zp).merge(de).describe("extended find options for client functions"),rr=a.union([a.number().positive(),a.string().regex(/^((0\.\d+)|([1-9]\d*(\.\d+){0,1}))$/,"invalid number")]),m=a.union([a.string(),a.number().int()]),si=a.union([a.string(),a.number()]);var jf=is.describe("Optional flags for input"),nr=a.object({wallet:m.describe("Foreign of the wallet connected to transfers"),token:m.describe("Foreign of the token transferred"),from_wallet:m.describe("Foreign of the wallet transfers are made from"),to_wallet:m.describe("Foreign of the wallet transfers are made to"),transfer_group:m.describe("Foreign of the transfer_group the transfers are a part of"),status:j.describe("Status of the transfers"),metadata:Z.describe("Metadata filter"),aggregators:ps.array().describe("Array of aggregators to apply"),groups:us.array().describe("Specifications on grouping the data"),options:jf}).partial().strict().describe("Input for aggregateTransfers"),wu=ta.describe("Output of aggregateTransfers");var Vf=i(nr);function ii(r,e,t){var I;let{client:o}=r;if(e===void 0)return new Fn({start(H){return o.api.aggregateTransferMany({transfer:H.filter,options:H.options,groups:H.groups,aggregators:H.aggregators})},modifiers(H,ae){return["token","wallet","from_wallet","to_wallet"].includes(H)?g(ae):H==="transfer_group"?A(ae):ae}});let n=Vf.validateInputWOptions(e,t),{token:s,wallet:p,from_wallet:u,to_wallet:l,transfer_group:c,status:f,metadata:x}=n,y={token:g(s),wallet:g(p),from_wallet:g(u),to_wallet:g(l),transfer_group:A(c),status:f,metadata:x};return o.api.aggregateTransferMany({transfer:y,groups:n.groups,aggregators:(I=n.aggregators)!=null?I:["sum"]})}var Lf=fs.describe("Optional flags for input"),Zf=a.enum([...ds.options,"aggregateTransfers","exportBalanceHistory","exportTokens","exportTransferGroups","exportTransfers","exportWallets","findBalances","findTokens","findTransferGroups","findTransfers","findWallets","listExports"]),zf=ls.extend({scopes:Zf.array()}),ar=a.object({token:a.union([zf,cs]),options:Lf}).partial().strict().describe("Input for createAccessToken"),Eu=aa.describe("Output of createAccessToken");var Hf=new Map(Object.entries({aggregateTransfers:"aggregateTransferMany",exportTokens:"exportTokenMany",exportTransferGroups:"exportTransferGroupMany",exportTransfers:"exportTransferMany",exportWallets:"exportWalletMany",findBalances:"findBalanceMany",findTokens:"findTokenMany",findTransferGroups:"findTransferGroupMany",findTransfers:"findTransferMany",findWallets:"findWalletMany",listExports:"listExportMany"})),qf=i(ar);function pi(r,e,t){var s;let{client:o}=r,n=qf.validateInputWOptions(e,t);return n.token&&"scopes"in n.token&&(n.token.scopes=Array.from(new Set((s=n.token)==null?void 0:s.scopes.map(p=>{var u;return(u=Hf.get(p))!=null?u:p})))),o.api.createAccessToken({token:n.token,options:t})}var Qf=Fs.describe("Optional flags for input"),$f=a.object({wallet:m.describe("Foreign of the wallet buying this contract"),token:m.describe("Foreign of the token buyer will buy with, defaults to Contract value token"),amount:a.number().describe("Amount the buyer will pay, defaults to contract value amount"),metadata:T.shape.metadata,latest_control_hash:T.shape.control_hash.nullable().optional().describe("Latest control_hash on the buyer wallet")}).partial().required({wallet:!0}).describe("The properties of the contract from buyer side"),Jf=a.object({foreign:si.describe("Unique foreign of the created Contract"),metadata:U.shape.metadata,value_token:m.describe("Foreign of the token this contract is valued in"),value_amount:a.number().positive().describe("Amount of value this Contract has"),owner:si.describe("Foreign of the wallet this contract should initially belong to"),buyer:$f}).partial().required({foreign:!0,value_amount:!0,value_token:!0}).describe("Contract description"),or=Jf.extend({options:Qf.optional()}).strict().describe("Input for createContract"),Mu=da.describe("Output of createContract");var Kf=i(or);function ui(r,e,t){var p;let{client:o}=r,n=Kf.validateInputWOptions(e,t),s={token:{foreign:n.foreign+"",metadata:n.metadata,owner:g((p=n.owner)!=null?p:"house"),deposits:[{token:g(n.value_token),amount:n.value_amount}]}};return n.buyer&&(n.buyer.latest_control_hash&&console.warn("deprecated: latest_control_hash is deprecated and will be ignored"),s.exchange={from_wallet:g(n.buyer.wallet),amount:n.buyer.amount||n.value_amount,from_token:g(n.buyer.token||n.value_token),metadata:n.buyer.metadata}),o.api.createContract(s)}var Yf=F.extend({return_balance:a.boolean().describe("return balance after deposit"),create_wallet_if_not_exists:a.boolean().describe("If true then the wallet will be created if not found. Only valid with 'foreign'")}).partial().describe("Optional flags for input"),Xf=a.object({identifier:T.shape.identifier,token:m.describe("Id of the token to deposit as"),wallet:m.describe("Id of the wallet to deposit to"),amount:rr.describe("amount to deposit"),metadata:T.shape.metadata,status:X,transfer_group:m.describe("Id of the transfer_group this deposit is linked to"),created_at:T.shape.created_at}).partial().required({wallet:!0,amount:!0}),sr=Xf.extend({options:Yf.optional()}).strict().describe("Input for createDeposit"),Ru=ca.describe("Output of createDeposit");var em=i(sr);function di(r,e,t){let{client:o}=r,n=Me(e,"token",o.getConfig("token")),s=em.validateInputWOptions(n,t),p=s.token||o.getConfig("token");if(p===void 0)throw new q("INPUT_NEEDS_TOKEN",{input:e});let y=s,{wallet:u,metadata:l,options:c}=y,f=Y(y,["wallet","metadata","options"]),x=d(S(d({},f),{amount:Rt(f.amount),transfer_group:A(s.transfer_group),token:g(p),to_wallet:g(u),type:"deposit"}),l?{metadata:l}:{});return x.identifier||(x.identifier=ie(x)),o.api.createTransfer({transfer:x,options:Mn(c,{return_balance:"return_to_balance",create_wallet_if_not_exists:"create_to_wallet_if_not_exists"})})}var tm=F.partial().describe("Optional flags for input"),rm=a.object({identifier:B.shape.identifier,from_identifier:T.shape.identifier,from_wallet:m.describe("Foreign of Wallet where from_token is debited from/to_token is credited to"),from_token:m.describe("Foreign of Token that is transferred from->to"),from_amount:T.shape.amount.describe("Amount of from_token transferred"),to_identifier:T.shape.identifier,to_wallet:m.describe("Foreign of Wallet where from_token is credited to/to_token is debited from. If not specified then to_token.belongs_to is used"),to_token:m.describe("Foreign of Token that is transferred to->from"),to_amount:T.shape.amount.describe("Amount of to_token transferred. If not specified then from_amount is used"),status:X.describe("The state at which the exchange is created"),force:T.shape.force,metadata:T.shape.metadata}).partial().required({from_wallet:!0,from_token:!0,from_amount:!0,to_token:!0,to_wallet:!0}),ir=rm.extend({options:tm.optional()}).strict().describe("Input for createExchange"),Gu=et.describe("Output of createExchange");var nm=i(ir);function li(r,e,t){var l,c,f,x,y;let{client:o}=r,u=nm.validateInputWOptions(e,t),{options:s}=u,p=Y(u,["options"]);return(l=p.identifier)!=null||(p.identifier=ie(p)),o.api.createTransferGroup({transfer_group:{identifier:p.identifier,status:Hn.closed,transfer_status:(c=p.status)!=null?c:"pending",metadata:p.metadata,children:[{identifier:(f=p.from_identifier)!=null?f:ie(),from_wallet:g(p.from_wallet),to_wallet:g(p.to_wallet),token:g(p.from_token),type:p.from_wallet?bt.transfer:bt.deposit,amount:p.from_amount,metadata:p.metadata,force:p.force},{identifier:(x=p.to_identifier)!=null?x:ie(),from_wallet:g(p.to_wallet),to_wallet:g(p.from_wallet),token:g(p.to_token),type:p.to_wallet?bt.transfer:bt.deposit,amount:(y=p.to_amount)!=null?y:p.from_amount,metadata:p.metadata,force:p.force}]},options:s})}var am=Os.describe("Optional flags for input"),ci=U.pick({foreign:!0,public:!0,metadata:!0,divisor:!0,limit:!0}).extend({belongs_to:m.describe("Id of the wallet this token belongs_to")}).partial().required({foreign:!0}),pr=ci.extend({options:am.optional()}).strict().describe("Input for createToken"),Wu=Ta.describe("Output of createToken");var om=i(pr);function fi(r,e,t){let{client:o}=r,c=om.validateInputWOptions(e,t),{options:s,belongs_to:p,metadata:u}=c,l=Y(c,["options","belongs_to","metadata"]);return o.api.createToken({token:d(S(d({},l),{belongs_to:g(p)}),u?{metadata:u}:{}),options:s})}var sm=Ze.describe("Optional flags for input"),mi=a.object({identifier:T.shape.identifier,token:m.describe("Id of the token to transfer as"),from_wallet:m.describe("Foreign of the wallet to withdraw from"),to_wallet:m.describe("Foreign of the wallet to deposit to"),latest_control_hash:T.shape.control_hash,amount:rr.describe("amount to withdraw"),metadata:T.shape.metadata,status:X.describe("status of the transfer"),transfer_group:m.describe("Id of the transfer_group this transfer is linked to"),created_at:T.shape.created_at,type:a.literal("transfer")}),On=mi.extend({type:a.literal("transfer")}).partial().required({from_wallet:!0,to_wallet:!0,amount:!0}),Sn=mi.omit({from_wallet:!0,to_wallet:!0}).extend({wallet:m.describe("Foreign of the wallet to withdraw from"),type:a.literal("withdrawal")}).partial().required({wallet:!0,amount:!0,type:!0}),bn=mi.omit({from_wallet:!0,to_wallet:!0}).extend({wallet:m.describe("Foreign of the wallet to deposit to"),type:a.literal("deposit")}).partial().required({wallet:!0,amount:!0,type:!0}),Ti=a.union([On,bn,Sn]),ur=Ti.and(a.object({options:sm.optional()})).describe("Input for createTransfer"),Cu=Xe.describe("Output of createTransfer");var im=i(ur);function hi(r,e,t){let{client:o}=r,n=Me(e,"token",o.getConfig("token")),s=im.validateInputWOptions(n,t),p=yn(s,o.getConfig("token"));return p.identifier||(p.identifier=ie(p)),o.api.createTransfer({transfer:p,options:s.options})}function yn(r,e){r.type=r.type||"transfer";let t={identifier:r.identifier,token:g(r.token||e),amount:Rt(r.amount),metadata:r.metadata,status:r.status,type:r.type,transfer_group:A(r.transfer_group),created_at:r.created_at};if(r.type==="transfer")return r.latest_control_hash&&console.warn("deprecated: latest_control_hash is deprecated"),S(d({},t),{from_wallet:g(r.from_wallet),to_wallet:g(r.to_wallet)});if(r.type==="withdrawal")return r.latest_control_hash&&console.warn("deprecated: latest_control_hash is deprecated"),S(d({},t),{from_wallet:g(r.wallet)});if(r.type==="deposit")return S(d({},t),{to_wallet:g(r.wallet)});throw new Error("Should not be here")}var pm=gs.describe("Optional flags for input"),um=On.omit({transfer_group:!0}),dm=bn.omit({transfer_group:!0}),lm=Sn.omit({transfer_group:!0}),cm=a.union([dm,um,lm]),gi=B.pick({identifier:!0,status:!0,transfer_status:!0,metadata:!0}).extend({children:cm.array()}).partial(),dr=gi.extend({options:pm.optional()}).describe("Input for createTransferGroup"),Au=et.describe("Output of createTransferGroup");var fm=i(dr);function Fi(r,e,t){let{client:o}=r,u=fm.validateInputWOptions(e,t),{options:s}=u,p=Y(u,["options"]);return p.children&&(p.children=p.children.map(l=>yn(l,o.getConfig("token")))),p.identifier||(p.identifier=ie(p)),o.api.createTransferGroup({transfer_group:p,options:s})}var mm=Ss.describe("Optional flags for input"),lr=a.object({transfers:Ti.array().min(1).describe("Array of transfer objects to create"),options:mm.optional()}).describe("Input for createTransfers"),Nu=ga.describe("Output of createTransfers");var Tm=i(lr);function xi(r,e,t){let{client:o}=r,n=Tm.validateInputWOptions(e,t),s=n.transfers.map(p=>yn(p,o.getConfig("token")));for(let p of s)p.identifier||(p.identifier=ie(p));return o.api.createTransferMany({transfers:s,options:n.options})}var hm=ys.describe("Optional flags for input"),Oi=P.pick({foreign:!0,name:!0,metadata:!0,status:!0}).partial().required({foreign:!0}),cr=Oi.extend({options:hm.optional()}).strict().describe("Input for createWallet"),Du=xa.describe("Output of createWallet");var gm=i(cr);function Si(r,e,t){let{client:o}=r,l=gm.validateInputWOptions(e,t),{options:s,metadata:p}=l,u=Y(l,["options","metadata"]);return o.api.createWallet({wallet:d(d({},u),p?{metadata:p}:{}),options:s})}var Fm=F.extend({return_balance:a.boolean().describe("Return balance after withdrawal")}).partial().describe("Optional flags for input"),xm=a.object({identifier:T.shape.identifier,token:m.describe("Id of the token to withdrawal as"),wallet:m.describe("Id of the wallet to withdraw from"),latest_control_hash:T.shape.control_hash,amount:rr.describe("amount to withdraw"),metadata:T.shape.metadata,status:X.describe("status of the withdrawal"),transfer_group:m.describe("Id of the transfer_group this withdrawal is linked to"),created_at:T.shape.created_at}).partial().required({wallet:!0,amount:!0}),fr=xm.extend({options:Fm.optional()}).strict().describe("Input for createWithdrawal"),Bu=Sa.describe("Output of createWithdrawal");var Om=i(fr);function bi(r,e,t){let{client:o}=r,n=Me(e,"token",o.getConfig("token")),s=Om.validateInputWOptions(n,t),I=s,{wallet:p,metadata:u,options:l,latest_control_hash:c}=I,f=Y(I,["wallet","metadata","options","latest_control_hash"]);c&&console.warn("deprecated: latest_control_hash is deprecated");let x=s.token||o.getConfig("token");if(x===void 0)throw new q("INPUT_NEEDS_TOKEN",{input:e});let y=d(S(d({},f),{amount:Rt(f.amount),transfer_group:A(s.transfer_group),token:g(x),from_wallet:g(p),type:"withdrawal"}),u?{metadata:u}:{});return y.identifier||(y.identifier=ie(y)),o.api.createTransfer({transfer:y,options:Mn(l,{return_balance:"return_from_balance"})})}var Sm=Es.partial().describe("Optional flags for input"),bm=a.object({token:m.describe("Id of the token to withdrawal as"),wallet:m.describe("Id of the wallet to withdraw from")}).partial().required({wallet:!0}),mr=bm.extend({options:Sm.optional()}).strict().describe("Input for exportBalanceHistory"),Pu=ka.describe("Output of exportBalanceHistory");var ym=i(mr);function yi(r,e,t){let{client:o}=r,n=ym.validateInputWOptions(e,t),s=n.token||o.getConfig("token");if(s===void 0)throw new q("INPUT_NEEDS_TOKEN",{input:e});return o.api.exportBalanceHistory({balance:{wallet:g(n.wallet),token:g(s)},options:t})}var _m=Ms.merge(de).partial().describe("Optional flags for input"),Im=a.object({foreign:m.describe("Foreign of the token"),type:Ne,belongs_to:m.describe("Foreign of the wallet connected to token"),metadata:Z}).partial(),Tr=Im.extend({options:_m.optional()}).strict().describe("Input for exportTokens"),Uu=Ea.describe("Output of exportTokens");var km=i(Tr);function _i(r,e,t){let{client:o}=r;if(e===void 0)return new ee({start(u){return o.api.exportTokenMany({token:u.filter,options:u.options})},modifiers(u,l){return["belongs_to"].includes(u)?g(l):l}});let n=km.validateInputWOptions(e,t),s={foreign:n.foreign?n.foreign+"":void 0,type:n.type,metadata:n.metadata};n.belongs_to&&(s.belongs_to=g(n.belongs_to));let p=te(n.options);return o.api.exportTokenMany({token:s,options:p})}var Ii=cn.merge(de).partial().describe("Optional flags for input"),ki=a.object({identifier:m.describe("Identifier of the transfer_group"),transfer_status:B.shape.transfer_status.describe("Status of the transfers"),status:B.shape.status.describe("Status of the transfer_group"),reverses:m.describe("Identifier of the transfer_group the transfer_group reverses"),type:Ke.describe("Type of the transfer group"),metadata:Z}).partial(),hr=ki.extend({options:Ii.optional()}).strict().describe("Input for findTransferGroups"),ju=Ma.describe("Output of findTransferGroups");var vm=Ii.partial().describe("Optional flags for input"),wm=ki.partial(),gr=wm.extend({options:vm.optional()}).strict().describe("Input for exportTransferGroups"),Vu=Ga.describe("Output of exportTransferGroups");var Em=i(gr);function vi(r,e,t){let{client:o}=r;if(e===void 0)return new ee({start(y){return o.api.exportTransferGroupMany({transfer_group:y.filter,options:y.options})},modifiers(y,I){return["transfer_group","reverses"].includes(y)?A(I):I}});let n=Em.validateInputWOptions(e,t),{identifier:s,transfer_status:p,status:u,metadata:l,type:c}=n,f={identifier:s,transfer_status:p,status:u,metadata:l,type:c};n.reverses&&(f.reverses=A(n.reverses));let x=te(n.options);return o.api.exportTransferGroupMany({transfer_group:f,options:x})}var Mm=a.object({return_running_balance:a.boolean().describe("return running balance for specified wallet under filter"),return_signed_amount:a.boolean().describe("return running balance for specified wallet under filter"),return_running_balance_for_wallet:m.describe("foreign key for which wallet should running balance be returned for"),return_signed_amount_for_wallet:m.describe("foreign key for which wallet should signed amounts be returned for")}),Rm=ss.keyof().options.reduce((r,e)=>S(d({},r),{[e]:!0}),{}),wi=pn.omit(Rm).merge(Mm).merge(de).partial().describe("Optional flags for input"),Ei=a.object({wallet:m.describe("Foreign of the wallet connected to transfers"),token:m.describe("Foreign of the token transferred"),from_wallet:m.describe("Foreign of the wallet transfers are made from"),to_wallet:m.describe("Foreign of the wallet transfers are made to"),transfer_group:m.describe("Foreign of the transfer_group the transfers are a part of"),status:j.describe("Status of the transfers"),metadata:Z}).partial(),Fr=Ei.extend({options:wi.optional()}).strict().describe("Input for findTransfers"),Lu=Xn.describe("Output of findTransfers");var Gm=wi.partial().describe("Optional flags for input"),Wm=Ei,xr=Wm.extend({options:Gm.optional()}).strict().describe("Input for exportTransfers"),Zu=Ca.describe("Output of exportTransfers");var Cm=i(xr);function Mi(r,e,t){var x;let{client:o}=r;if(e===void 0)return new ee({start(y){return o.api.exportTransferMany({transfer:y.filter,options:y.options})},modifiers(y,I){return["token","wallet","from_wallet","to_wallet"].includes(y)?g(I):y==="transfer_group"?A(I):I}});let n=Cm.validateInputWOptions(e,t),{token:s,wallet:p,from_wallet:u,to_wallet:l}=n,c={token:g(s),wallet:g(p),from_wallet:g(u),to_wallet:g(l)};n.transfer_group&&(c.transfer_group=A(n.transfer_group)),n.status&&(c.status=n.status),n.metadata&&(c.metadata=n.metadata),(x=n.options)!=null||(n.options={});let f=te(n.options);return o.api.exportTransferMany({transfer:c,options:f})}var Am=a.object({include_balance_for_token:m.describe("Foreign of token to include balance for")}),Ri=mn.merge(de).merge(Am).partial().describe("Optional flags for input"),Gi=P.pick({foreign:!0,name:!0,type:!0,status:!0}).extend({metadata:Z}).partial(),Or=Gi.extend({options:Ri.optional()}).strict().describe("Input for findWallets"),zu=Aa.describe("Output of findWallets");var Gw=a.object({include_balance_for_token:m.describe("Foreign of token to include balance for")}),Nm=Ri.partial().describe("Optional flags for input"),Dm=Gi.partial(),Sr=Dm.extend({options:Nm.optional()}).strict().describe("Input for exportWallets"),Hu=Da.describe("Output of exportWallets");var Bm=i(Sr);function Wi(r,e,t){let{client:o}=r;if(e===void 0)return new ee({start(y){return o.api.exportWalletMany({wallet:y.filter,options:y.options})},optionsModifiers(y,I){return y==="include_balance_for_token"&&typeof I!="object"?g(I):I}});let f=Bm.validateInputWOptions(e,t),{options:s}=f,p=Y(f,["options"]),x=s,{include_balance_for_token:u}=x,l=Y(x,["include_balance_for_token"]),c=te(d(d({},l),u?{include_balance_for_token:g(u)}:{}));return o.api.exportWalletMany({wallet:p,options:c})}var Pm=Gs.merge(de).partial().describe("Optional flags for input"),Um=a.object({token:m.describe("Id of the token to withdrawal as"),wallet:m.describe("Id of the wallet to withdraw from")}).partial(),br=Um.extend({options:Pm.optional()}).strict().describe("Input for findBalances"),qu=Pa.describe("Output of findBalances");var jm=i(br);function Ci(r,e,t){let{client:o}=r;if(e===void 0)return new ee({start(u){return o.api.findBalanceMany({balance:u.filter,options:u.options})},modifiers(u,l){return["wallet","token"].includes(u)?g(l):l}});let n=jm.validateInputWOptions(e,t),s={};n.wallet&&(s.wallet=g(n.wallet)),n.token&&(s.token=g(n.token));let p=te(n.options);return o.api.findBalanceMany({balance:s,options:p})}var Vm=ln.merge(de).partial().describe("Optional flags for input"),Lm=a.object({foreign:m.describe("Foreign of the token"),type:Ne,belongs_to:m.describe("Foreign of the wallet connected to token"),metadata:Z}).partial(),yr=Lm.extend({options:Vm.optional()}).strict().describe("Input for findTokens"),Qu=va.describe("Output of findTokens");var Zm=i(yr);function Ai(r,e,t){let{client:o}=r;if(e===void 0)return new ee({start(u){return o.api.findTokenMany({token:u.filter,options:u.options})},modifiers(u,l){return["belongs_to"].includes(u)?g(l):l}});let n=Zm.validateInputWOptions(e,t),s={foreign:n.foreign?n.foreign+"":void 0,type:n.type,metadata:n.metadata};n.belongs_to&&(s.belongs_to=g(n.belongs_to));let p=te(n.options);return o.api.findTokenMany({token:s,options:p})}var zm=i(hr);function Ni(r,e,t){let{client:o}=r;if(e===void 0)return new ee({start(y){return o.api.findTransferGroupMany({transfer_group:y.filter,options:y.options})},modifiers(y,I){return["transfer_group","reverses"].includes(y)?A(I):I}});let n=zm.validateInputWOptions(e,t),{identifier:s,transfer_status:p,status:u,metadata:l,type:c}=n,f={identifier:s,transfer_status:p,status:u,metadata:l,type:c};n.reverses&&(f.reverses=A(n.reverses));let x=te(n.options);return o.api.findTransferGroupMany({transfer_group:f,options:x})}var Hm=i(Fr);function Di(r,e,t){var H;let{client:o}=r;if(e===void 0)return new ee({start(V){return o.api.findTransferMany({transfer:V.filter,options:V.options})},modifiers(V,tt){return["token","wallet","from_wallet","to_wallet"].includes(V)?g(tt):V==="transfer_group"?A(tt):tt}});let n=Hm.validateInputWOptions(e,t),{token:s,wallet:p,from_wallet:u,to_wallet:l}=n,c={token:g(s),wallet:g(p),from_wallet:g(u),to_wallet:g(l)};if(n.transfer_group&&(c.transfer_group=A(n.transfer_group)),n.status&&(c.status=n.status),n.metadata&&(c.metadata=n.metadata),(H=n.options)!=null||(n.options={}),n.options.return_running_balance){if(n.options.return_running_balance_for_wallet)throw new q("CONFLICTING_OPTIONS_FOR_BALANCE",{options:n.options});if(!c.wallet)throw new q("RUNNING_BALANCE_WITHOUT_WALLET",{input:n});n.options.return_running_balance_for_wallet=n.wallet}if(n.options.return_signed_amount){if(n.options.return_signed_amount_for_wallet)throw new q("CONFLICTING_OPTIONS_FOR_SIGNED_AMOUNT",{options:n.options});if(!c.wallet)throw new q("SIGNED_AMOUNT_WITHOUT_WALLET",{input:n});n.options.return_signed_amount_for_wallet=n.wallet}let ae=n.options,{return_signed_amount_for_wallet:f,return_running_balance_for_wallet:x}=ae,y=Y(ae,["return_signed_amount_for_wallet","return_running_balance_for_wallet"]),I=te(d(d(d({},y),x?{return_running_balance_for_wallet:g(x)}:{}),f?{return_signed_amount_for_wallet:g(f)}:{}));return o.api.findTransferMany({transfer:c,options:I})}var qm=i(Or);function Bi(r,e,t){let{client:o}=r;if(e===void 0)return new ee({start(y){return o.api.findWalletMany({wallet:y.filter,options:y.options})},optionsModifiers(y,I){return y==="include_balance_for_token"&&typeof I!="object"?g(I):I}});let f=qm.validateInputWOptions(e,t),{options:s}=f,p=Y(f,["options"]),x=s,{include_balance_for_token:u}=x,l=Y(x,["include_balance_for_token"]),c=te(d(d({},l),u?{include_balance_for_token:g(u)}:{}));return o.api.findWalletMany({wallet:p,options:c})}var Qm=ms.describe("Optional flags for input"),$m=a.object({token:m.describe("Id of the token to get balance in"),wallet:m.describe("Id of the wallet to get balance for"),datetime:E.describe("Date and time this balance should be got")}).partial().required({wallet:!0}),_r=$m.extend({options:Qm.optional()}).strict().describe("Input for getBalance"),$u=De.describe("Output of getBalance");var Jm=i(_r);function Pi(r,e,t){let{client:o}=r,n=Me(e,"token",o.getConfig("token")),s=Jm.validateInputWOptions(n,t);if(s.datetime&&bp(s.datetime))throw new q("BAL_FUTURE_DATETIME",{input:s});let p=s.token||o.getConfig("token");if(p===void 0)throw new q("INPUT_NEEDS_TOKEN",{input:s});return o.api.getBalance({balance:{wallet:g(s.wallet),token:g(p),datetime:s.datetime},options:s.options})}var Km=ws.describe("Optional flags for input"),Ym=a.object({token:m.describe("Id of the token to get balance in"),wallet:m.describe("Id of the wallet to get balance for"),datetime:E.describe("Select entries older than")}).partial().required({wallet:!0}),Ir=Ym.extend({options:Km.optional()}).strict().describe("Input for getBalanceHistory"),Ju=_a.describe("Output of getBalanceHistory");var Xm=i(Ir);function Ui(r,e,t){let{client:o}=r,n=Xm.validateInputWOptions(e,t),s=n.token||o.getConfig("token");if(s===void 0)throw new q("INPUT_NEEDS_TOKEN",{input:e});return o.api.getBalanceHistory({balance:{wallet:g(n.wallet),token:g(s),datetime:n.datetime},options:n.options})}var eT=Is.describe("Optional flags for input"),tT=a.object({identifier:a.string().describe("File name of the export to get")}),kr=tT.extend({options:eT.optional()}).strict().describe("Input for getExport"),Ku=he.describe("Output of getExport");var rT=i(kr);function ji(r,e,t){let{client:o}=r,n=rT.validateInputWOptions(e,t);return o.api.getExport({export:{identifier:n.identifier},options:n.options})}var nT=Ws.describe("Optional flags for input"),vr=a.object({options:nT.optional()}).strict().describe("Input for getFlags"),Yu=Va.describe("Output of getFlags");var aT=i(vr);function Vi(r,e,t){let{client:o}=r,n=aT.validateInputWOptions(e,t);return o.api.getFlags({options:n.options})}var oT=Cs.describe("Optional flags for input"),wr=Jt.extend({options:oT.optional()}).strict().describe("Input for getStatistics"),Xu=La.describe("Output of getStatistics");var sT=i(wr);function Li(r,e,t){let{client:o}=r,n=sT.validateInputWOptions(e,t);return o.api.getStatistics({model:n.model||"Transfer",aggregator:n.aggregator||"count",groups:n.groups,filter:n.filter,options:n.options})}var iT=on.describe("Optional flags for input"),pT=a.object({foreign:m.describe("Foreign of the token")}).partial(),Er=pT.extend({options:iT.optional()}).strict().describe("Input for getToken"),ed=Jn.describe("Output of getToken");var uT=i(Er);function Zi(r,e={},t){let{client:o}=r,n=Me(e,"foreign",o.getConfig("token")),s=uT.validateInputWOptions(n,t),p=s.foreign||o.getConfig("token");if(p===void 0)throw new q("INPUT_NEEDS_TOKEN",{input:e});return o.api.getToken({token:g(p),options:s.options})}var dT=rs.describe("Optional flags for input"),lT=a.object({transfer:m.describe("Transfer identifier")}).partial().required({transfer:!0}),Mr=lT.extend({options:dT.optional()}).strict().describe("Input for getTransfer"),td=_e.describe("Output of getTransfer");var cT=i(Mr);function zi(r,e,t){let{client:o}=r,n=cT.validateInputWOptions(e,t);return o.api.getTransfer({transfer:A(n.transfer),options:n.options})}var fT=os.describe("Optional flags for input"),mT=a.object({transfer_group:m.describe("identifier of the transfer group to reverse")}).partial().required({transfer_group:!0}),Rr=mT.extend({options:fT.optional()}).strict().describe("Input for getTransferGroup"),rd=Yn.describe("Output of getTransferGroup");var TT=i(Rr);function Hi(r,e,t){let{client:o}=r,n=TT.validateInputWOptions(e,t);return o.api.getTransferGroup({transfer_group:A(n.transfer_group),options:n.options})}var hT=an.describe("Optional flags for input"),gT=a.object({wallet:m.describe("Wallet foreign")}).partial().required({wallet:!0}),Gr=gT.extend({options:hT.optional()}).strict().describe("Input for getWallet"),nd=zn.describe("Output of getWallet");var FT=i(Gr);function qi(r,e,t){let{client:o}=r,n=FT.validateInputWOptions(e,t);return o.api.getWallet({wallet:g(n.wallet),options:n.options})}var xT=As.describe("Optional flags for input"),Wr=a.object({options:xT.optional()}).strict().describe("Input for healthcheck"),ad=qa.describe("Output of healthcheck");var OT=i(Wr);function Qi(r,e,t){let{client:o}=r,n=OT.validateInputWOptions(e,t);return o.api.healthcheck({options:d(d({},n.options),t)})}function $i(){throw new Error("import-data available only in node client")}var ST=Us.describe("Optional flags for input"),Ji=a.object({transfer:m.describe("Transfer identifier"),status:X.describe("Status of the created transfer"),identifier:T.shape.identifier.describe("Identifier for the created transfer"),force:T.shape.force.describe("Force create the reverse transfer ignoring balance"),metadata:T.shape.metadata.describe("Metadata for the reversed transfers"),extend_metadata:T.shape.metadata.describe("Key value object to extend metadata with on created transfer")}).partial().required({transfer:!0}),Cr=Ji.extend({options:ST.optional()}).strict().describe("Input for reverseTransfer"),od=to.describe("Output of reverseTransfer");var bT=Tn.describe("Optional flags for input"),Ki=a.object({transfer_group:m.describe("identifier of the transfer group to reverse"),status:ye,transfer_status:X,identifier:B.shape.identifier,force:T.shape.force,metadata:B.shape.metadata,transfer_metadata:T.shape.metadata,extend_metadata:B.shape.metadata.describe("Key value object to extend metadata with on created transfer"),transfer_extend_metadata:T.shape.metadata.describe("Key value object to extend metadata with on created transfer")}).partial().required({transfer_group:!0}),Ar=Ki.extend({options:bT.optional()}).strict().describe("Input for reverseTransferGroup"),sd=no.describe("Output of reverseTransferGroup");var yT=Ns.describe("Optional flags for input"),_T=a.object({target:a.literal("wallet").describe("Target of the action"),data:Oi}),IT=a.object({target:a.literal("token").describe("Target of the action"),data:ci}),kT=a.object({target:a.literal("transfer_group").describe("Target of the action"),data:gi.extend({created_at:E,status_finalized_at:E,transfer_status_finalized_at:E})}),vT=On.extend({status_finalized_at:E.optional(),status:j.optional()}),wT=bn.extend({status_finalized_at:E.optional(),status:j.optional()}),ET=Sn.extend({status_finalized_at:E.optional(),status:j.optional()}),MT=a.union([vT,wT,ET]),RT=a.object({target:a.literal("transfer").describe("Target of the action"),data:MT}),GT=a.object({target:a.literal("reverse_transfer").describe("Target of the action"),data:Ji.extend({options:a.object({metadata_action:Ee})})}),WT=a.object({target:a.literal("reverse_transfer_group").describe("Target of the action"),data:Ki.extend({options:a.object({metadata_action:Ee,transfer_metadata_action:Ee})})}),CT=a.union([_T,IT,kT,RT,GT,WT]),AT=a.object({actions:CT.array()}).partial().required({actions:!0}),So=AT.extend({options:yT.optional()}).strict().describe("Input for importData"),id=Qa.describe("Output of importData");var NT=Bs.merge(de).partial().describe("Optional flags for input"),DT=a.object({type:_s.describe("type of the export"),date:a.string().date().describe("Date of the export")}).partial(),Nr=DT.extend({options:NT.optional()}).strict().describe("Input for listExports"),pd=Ja.describe("Output of listExports");var BT=i(Nr);function Yi(r,e,t){let{client:o}=r,n=BT.validateInputWOptions(e,t),s=Sp(n==null?void 0:n.date),p=te(n.options);return o.api.listExportMany({export:d(d({},s?{date:s}:{}),n.type?{type:n.type}:{}),options:p})}var PT=i(Cr);function Xi(r,e,t){let{client:o}=r,n=PT.validateInputWOptions(e,t);return n.extend_metadata&&console.warn("deprecated: extend_metadata is deprecated. Use metadata_action instead"),o.api.reverseTransfer({transfer:A(n.transfer),reverse:{force:n.force,metadata:n.metadata,extend_metadata:n.extend_metadata,identifier:n.identifier,status:n.status},options:n.options})}var UT=i(Ar);function ep(r,e,t){let{client:o}=r,n=UT.validateInputWOptions(e,t);return n.extend_metadata&&console.warn("deprecated: extend_metadata is deprecated. Use metadata_action instead"),o.api.reverseTransferGroup({transfer_group:A(n.transfer_group),reverse:{status:n.status,force:n.force,transfer_status:n.transfer_status,identifier:n.identifier,metadata:n.metadata,transfer_metadata:n.transfer_metadata,extend_metadata:n.extend_metadata,transfer_extend_metadata:n.transfer_extend_metadata},options:n.options})}var jT=Ls.describe("Optional flags for input"),VT=Vs.describe("In case the transfer will be made then apply these modifications"),LT=a.object({wallet:m.describe("Foreign of the wallet connected to transfers"),token:m.describe("Foreign of the token transferred"),from_wallet:m.describe("Foreign of the wallet transfers are made from"),to_wallet:m.describe("Foreign of the wallet transfers are made to"),transfer_group:m.describe("Foreign of the transfer_group the transfers are a part of"),status:j.describe("Status of the transfers"),metadata:Z,reverse:VT}).partial(),Dr=LT.extend({options:jT.optional()}).strict().describe("Input for reverseTransfers"),ud=so.describe("Output of reverseTransfers");var ZT=i(Dr);function tp(r,e,t){let{client:o}=r;if(e===void 0)return new xn({start(f){return o.api.reverseTransferMany({transfer:f.filter,reverse:f.reverse,options:f.options})},modifiers(f,x){return["token","wallet","from_wallet","to_wallet"].includes(f)?g(x):f==="transfer_group"?A(x):x}});let n=ZT.validateInputWOptions(e,t),{token:s,wallet:p,from_wallet:u,to_wallet:l}=n,c={token:g(s),wallet:g(p),from_wallet:g(u),to_wallet:g(l)};return n.transfer_group&&(c.transfer_group=A(n.transfer_group)),n.status&&(c.status=n.status),n.metadata&&(c.metadata=n.metadata),o.api.reverseTransferMany({transfer:c,reverse:n.reverse,options:n.options})}var zT=Zs.describe("Optional flags for input"),Br=Le.extend({options:zT.optional()}).strict().describe("Input for setFlags"),dd=po.describe("Output of setFlags");var HT=i(Br);function rp(r,e,t){let{client:o}=r,n=HT.validateInputWOptions(e,t),s=Le.keyof().options,p={};if(s.forEach(u=>{u in n&&(p[u]=n[u])}),Object.keys(p).length<1)throw new q("REQUIRED_INPUT_MISSING",{requiredOneOf:s,input:e});return o.api.setFlags({flags:p,options:n.options})}var qT=zs.describe("Optional flags for input"),QT=a.object({token:m.describe("Token foreign"),metadata:U.shape.metadata,public:U.shape.public,status:U.shape.status}).partial().required({token:!0}),Pr=QT.extend({options:qT.optional()}).strict().describe("Input for updateToken"),ld=co.describe("Output of updateToken");var $T=i(Pr);function np(r,e,t){let{client:o}=r,n=$T.validateInputWOptions(e,t);return o.api.updateToken({token:g(n.token),update:{public:n.public,metadata:n.metadata,status:n.status},options:n.options})}var JT=Ps.describe("Optional flags for input"),_n=a.enum(["finished","cancelled"]).describe("Status the transfer should be set to"),KT=a.object({transfer:m.describe("Transfer identifier"),metadata:T.shape.metadata,extend_metadata:T.shape.metadata,status:_n}).partial().required({transfer:!0}),Ur=KT.extend({options:JT.optional()}).strict().describe("Input for updateTransfer"),cd=Xt.describe("Output of updateTransfer");var YT=i(Ur);function ap(r,e,t){let{client:o}=r,n=YT.validateInputWOptions(e,t);return o.api.updateTransfer({transfer:A(n.transfer),update:{status:n.status,metadata:n.metadata,extend_metadata:n.extend_metadata},options:n.options})}var XT=gn.describe("Optional flags for input"),eh=a.object({transfer_group:m.describe("TransferGroup identifier"),status:a.enum(["closed"]).describe("Lifecycle status of the TransferGroup"),transfer_status:_n.describe("Status all the transfers should be set at."),metadata:B.shape.metadata.describe("Key value object to be replaced or extended with existing TransferGroup metadata")}).partial().required({transfer_group:!0}),jr=eh.extend({options:XT.optional()}).strict().describe("Input for updateTransferGroup"),fd=mo.describe("Output of updateTransferGroup");var th=i(jr);function op(r,e,t){let{client:o}=r,n=th.validateInputWOptions(e,t);return o.api.updateTransferGroup({transfer_group:A(n.transfer_group),update:{transfer_status:n.transfer_status,status:n.status,metadata:n.metadata},options:n.options})}var rh=qs.describe("Optional flags for input");var nh=a.object({transfer_status:_n.describe("Status of the transfers"),status:B.shape.status.describe("Status of the transfer_group"),reverses:m.describe("Identifier of the transfer_group the transfer_group reverses"),type:Ke.describe("Type of the transfer group"),metadata:Z,update:hn}).partial(),Vr=nh.extend({options:rh.optional()}).strict().describe("Input for updateTransferGroups"),md=ho.describe("Output of updateTransferGroups");var ah=i(Vr);function sp(r,e,t){let{client:o}=r;if(e===void 0)return new vt({start(x){return o.api.updateTransferGroupMany({transfer_group:x.filter,update:x.update,options:x.options})},modifiers(x,y){return["transfer_group","reverses"].includes(x)?A(y):y}});let n=ah.validateInputWOptions(e,t),{transfer_status:s,status:p,metadata:u,type:l,update:c}=n,f={transfer_status:s,status:p,metadata:u,type:l};return n.reverses&&(f.reverses=A(n.reverses)),o.api.updateTransferGroupMany({transfer_group:f,update:c,options:n.options})}var oh=Qs.describe("Optional flags for input"),qG=a.enum(["finished","cancelled"]).describe("Status the transfer should be set to");var sh=a.object({wallet:m.describe("Foreign of the wallet connected to transfers"),token:m.describe("Foreign of the token transferred"),from_wallet:m.describe("Foreign of the wallet transfers are made from"),to_wallet:m.describe("Foreign of the wallet transfers are made to"),transfer_group:m.describe("Foreign of the transfer_group the transfers are a part of"),status:j.describe("Status of the transfers"),metadata:Z,update:Yt}).partial(),Lr=sh.extend({options:oh.optional()}).strict().describe("Input for updateTransfers"),Td=Fo.describe("Output of updateTransfers");var ih=i(Lr);function ip(r,e,t){let{client:o}=r;if(e===void 0)return new vt({start(x){return o.api.updateTransferMany({transfer:x.filter,update:x.update,options:x.options})},modifiers(x,y){return["token","wallet","from_wallet","to_wallet"].includes(x)?g(y):x==="transfer_group"?A(y):y}});let n=ih.validateInputWOptions(e,t),{token:s,wallet:p,from_wallet:u,to_wallet:l,update:c}=n;if(!c)throw new ve({message:"Update parameter cant be empty",data:{update:c}});let f={token:g(s),wallet:g(p),from_wallet:g(u),to_wallet:g(l)};return n.transfer_group&&(f.transfer_group=A(n.transfer_group)),n.status&&(f.status=n.status),n.metadata&&(f.metadata=n.metadata),o.api.updateTransferMany({transfer:f,update:c,options:n.options})}var ph=$s.describe("Optional flags for input"),uh=a.object({wallet:m.describe("Wallet foreign"),metadata:P.shape.metadata,name:P.shape.name,status:P.shape.status}).partial().required({wallet:!0}),Zr=uh.extend({options:ph.optional()}).strict().describe("Input for updateWallet"),hd=Oo.describe("Output of updateWallet");var dh=i(Zr);function pp(r,e,t){let{client:o}=r,n=dh.validateInputWOptions(e,t);return o.api.updateWallet({wallet:g(n.wallet),update:{metadata:n.metadata,status:n.status,name:n.name},options:n.options})}var gd=(C=>(C.aggregateTransfers="aggregateTransfers",C.createAccessToken="createAccessToken",C.createContract="createContract",C.createDeposit="createDeposit",C.createExchange="createExchange",C.createToken="createToken",C.createTransfer="createTransfer",C.createTransferGroup="createTransferGroup",C.createTransfers="createTransfers",C.createWallet="createWallet",C.createWithdrawal="createWithdrawal",C.exportBalanceHistory="exportBalanceHistory",C.exportTokens="exportTokens",C.exportTransferGroups="exportTransferGroups",C.exportTransfers="exportTransfers",C.exportWallets="exportWallets",C.findBalances="findBalances",C.findTokens="findTokens",C.findTransferGroups="findTransferGroups",C.findTransfers="findTransfers",C.findWallets="findWallets",C.getBalance="getBalance",C.getBalanceHistory="getBalanceHistory",C.getExport="getExport",C.getFlags="getFlags",C.getStatistics="getStatistics",C.getToken="getToken",C.getTransfer="getTransfer",C.getTransferGroup="getTransferGroup",C.getWallet="getWallet",C.healthcheck="healthcheck",C.importData="importData",C.listExports="listExports",C.reverseTransfer="reverseTransfer",C.reverseTransferGroup="reverseTransferGroup",C.reverseTransfers="reverseTransfers",C.setFlags="setFlags",C.updateToken="updateToken",C.updateTransfer="updateTransfer",C.updateTransferGroup="updateTransferGroup",C.updateTransferGroups="updateTransferGroups",C.updateTransfers="updateTransfers",C.updateWallet="updateWallet",C))(gd||{}),k={aggregateTransfers:ii,createAccessToken:pi,createContract:ui,createDeposit:di,createExchange:li,createToken:fi,createTransfer:hi,createTransferGroup:Fi,createTransfers:xi,createWallet:Si,createWithdrawal:bi,exportBalanceHistory:yi,exportTokens:_i,exportTransferGroups:vi,exportTransfers:Mi,exportWallets:Wi,findBalances:Ci,findTokens:Ai,findTransferGroups:Ni,findTransfers:Di,findWallets:Bi,getBalance:Pi,getBalanceHistory:Ui,getExport:ji,getFlags:Vi,getStatistics:Li,getToken:Zi,getTransfer:zi,getTransferGroup:Hi,getWallet:qi,healthcheck:Qi,importData:$i,listExports:Yi,reverseTransfer:Xi,reverseTransferGroup:ep,reverseTransfers:tp,setFlags:rp,updateToken:np,updateTransfer:ap,updateTransferGroup:op,updateTransferGroups:sp,updateTransfers:ip,updateWallet:pp},lh={aggregateTransfers:i(nr),createAccessToken:i(ar),createContract:i(or),createDeposit:i(sr),createExchange:i(ir),createToken:i(pr),createTransfer:i(ur),createTransferGroup:i(dr),createTransfers:i(lr),createWallet:i(cr),createWithdrawal:i(fr),exportBalanceHistory:i(mr),exportTokens:i(Tr),exportTransferGroups:i(gr),exportTransfers:i(xr),exportWallets:i(Sr),findBalances:i(br),findTokens:i(yr),findTransferGroups:i(hr),findTransfers:i(Fr),findWallets:i(Or),getBalance:i(_r),getBalanceHistory:i(Ir),getExport:i(kr),getFlags:i(vr),getStatistics:i(wr),getToken:i(Er),getTransfer:i(Mr),getTransferGroup:i(Rr),getWallet:i(Gr),healthcheck:i(Wr),importData:i(So),listExports:i(Nr),reverseTransfer:i(Cr),reverseTransferGroup:i(Ar),reverseTransfers:i(Dr),setFlags:i(Br),updateToken:i(Pr),updateTransfer:i(Ur),updateTransferGroup:i(jr),updateTransferGroups:i(Vr),updateTransfers:i(Lr),updateWallet:i(Zr)};var Fd,ch=(Fd=window.WAPI_VERSION)!=null?Fd:"",zr=class{constructor(e,t){v(this,"api");v(this,"$connect");v(this,"config",{});this.api=e,this.$connect=e.$connect,t&&this.configure(d(d(d(d(d(d(d({},t.token&&{token:t.token}),t.sendingTimeout&&{sendingTimeout:t.sendingTimeout}),t.connectingTimeout&&{connectingTimeout:t.connectingTimeout}),t.reconnectingTimeout&&{reconnectingTimeout:t.reconnectingTimeout}),t.hooks&&{hooks:t.hooks}),t.connectionName&&{connectionName:t.connectionName}),t.httpSkipInitialAuthConnection&&{httpSkipInitialAuthConnection:t.httpSkipInitialAuthConnection}))}close(){return Q(this,null,function*(){return this.api.close()})}version(){return ch}setHook(e,t){if(typeof t!="function")throw new TypeError("Hooks can only be functions");return this.api.hooks[e]=t,this}configure(e){if(e.token&&typeof e.token!="string"&&typeof e.token!="number")throw new ge("CONFIG_INVALID",{field:"token",error:`Must be a string|number, '${e.token}' provided`});["sendingTimeout","connectingTimeout","reconnectingTimeout"].forEach(o=>{if(e[o]&&typeof e[o]!="number")throw new ge("CONFIG_INVALID",{field:o,error:`Must be a number, '${e[o]}' provided`})});let t=e.hooks;if(delete e.hooks,this.config=d(d({},this.config),e),this.config.sendingTimeout&&(this.api.sendingTimeout=this.config.sendingTimeout),t)for(let[o,n]of Object.entries(t))this.setHook(o,n);return this}getConfig(e){return this.config[e]}aggregateTransfers(e,t){return e===void 0?k.aggregateTransfers({client:this}):k.aggregateTransfers({client:this},e,t)}createAccessToken(e,t){return k.createAccessToken({client:this},e!=null?e:{},t)}createContract(e,t){return k.createContract({client:this},e,t)}createDeposit(e,t){return k.createDeposit({client:this},e,t)}createExchange(e,t){return k.createExchange({client:this},e,t)}createToken(e,t){return k.createToken({client:this},e,t)}createTransfer(e,t){return k.createTransfer({client:this},e,t)}createTransferGroup(e,t){return k.createTransferGroup({client:this},e!=null?e:{},t)}createTransfers(e,t){return k.createTransfers({client:this},e,t)}createWallet(e,t){return k.createWallet({client:this},e,t)}createWithdrawal(e,t){return k.createWithdrawal({client:this},e,t)}exportBalanceHistory(e,t){return k.exportBalanceHistory({client:this},e,t)}exportTokens(e,t){return e===void 0?k.exportTokens({client:this}):k.exportTokens({client:this},e,t)}exportTransferGroups(e,t){return e===void 0?k.exportTransferGroups({client:this}):k.exportTransferGroups({client:this},e,t)}exportTransfers(e,t){return e===void 0?k.exportTransfers({client:this}):k.exportTransfers({client:this},e,t)}exportWallets(e,t){return e===void 0?k.exportWallets({client:this}):k.exportWallets({client:this},e,t)}findBalances(e,t){return e===void 0?k.findBalances({client:this}):k.findBalances({client:this},e,t)}findTokens(e,t){return e===void 0?k.findTokens({client:this}):k.findTokens({client:this},e,t)}findTransferGroups(e,t){return e===void 0?k.findTransferGroups({client:this}):k.findTransferGroups({client:this},e,t)}findTransfers(e,t){return e===void 0?k.findTransfers({client:this}):k.findTransfers({client:this},e,t)}findWallets(e,t){return e===void 0?k.findWallets({client:this}):k.findWallets({client:this},e,t)}getBalance(e,t){return k.getBalance({client:this},e,t)}getBalanceHistory(e,t){return k.getBalanceHistory({client:this},e,t)}getExport(e,t){return k.getExport({client:this},e,t)}getFlags(e,t){return k.getFlags({client:this},e!=null?e:{},t)}getStatistics(e,t){return k.getStatistics({client:this},e!=null?e:{},t)}getToken(e,t){return k.getToken({client:this},e!=null?e:{},t)}getTransfer(e,t){return k.getTransfer({client:this},e,t)}getTransferGroup(e,t){return k.getTransferGroup({client:this},e,t)}getWallet(e,t){return k.getWallet({client:this},e,t)}healthcheck(e,t){return k.healthcheck({client:this},e!=null?e:{},t)}listExports(e,t){return k.listExports({client:this},e!=null?e:{},t)}reverseTransfer(e,t){return k.reverseTransfer({client:this},e,t)}reverseTransferGroup(e,t){return k.reverseTransferGroup({client:this},e,t)}reverseTransfers(e,t){return e===void 0?k.reverseTransfers({client:this}):k.reverseTransfers({client:this},e,t)}setFlags(e,t){return k.setFlags({client:this},e!=null?e:{},t)}updateToken(e,t){return k.updateToken({client:this},e,t)}updateTransfer(e,t){return k.updateTransfer({client:this},e,t)}updateTransferGroup(e,t){return k.updateTransferGroup({client:this},e,t)}updateTransferGroups(e,t){return e===void 0?k.updateTransferGroups({client:this}):k.updateTransferGroups({client:this},e,t)}updateTransfers(e,t){return e===void 0?k.updateTransfers({client:this}):k.updateTransfers({client:this},e,t)}updateWallet(e,t){return k.updateWallet({client:this},e,t)}};function xd(r,e){let t=Xs(r,{connectingTimeout:e==null?void 0:e.connectingTimeout,reconnectingTimeout:e==null?void 0:e.reconnectingTimeout});return new zr(t,e)}function Od(r,e){let t=ni(r,{connectingTimeout:e==null?void 0:e.connectingTimeout,reconnectingTimeout:e==null?void 0:e.reconnectingTimeout,httpSkipInitialAuthConnection:e==null?void 0:e.httpSkipInitialAuthConnection,connectionName:e==null?void 0:e.connectionName});return new zr(t,e)}var tA=a.enum(["ws","https"]),up=a.object({host:a.string().describe("URL of the API"),apikey:a.string().describe("API key for the client"),apisecret:a.string().describe("API secret for the client")}).passthrough(),fh=a.object({client:a.literal("ws"),connection:up}),dp=a.object({host:a.string().describe("URL of the API"),jwt:a.string().describe("Auth token for calling api")}).passthrough(),mh=a.object({client:a.literal("https"),connection:dp}),rA=a.union([fh,mh]);var Sd={aggregateTransfersFnInput:i(nr),aggregateTransfersFnOutput:i(wu),createAccessTokenFnInput:i(ar),createAccessTokenFnOutput:i(Eu),createContractFnInput:i(or),createContractFnOutput:i(Mu),createDepositFnInput:i(sr),createDepositFnOutput:i(Ru),createExchangeFnInput:i(ir),createExchangeFnOutput:i(Gu),createTokenFnInput:i(pr),createTokenFnOutput:i(Wu),createTransferFnInput:i(ur),createTransferFnOutput:i(Cu),createTransferGroupFnInput:i(dr),createTransferGroupFnOutput:i(Au),createTransfersFnInput:i(lr),createTransfersFnOutput:i(Nu),createWalletFnInput:i(cr),createWalletFnOutput:i(Du),createWithdrawalFnInput:i(fr),createWithdrawalFnOutput:i(Bu),exportBalanceHistoryFnInput:i(mr),exportBalanceHistoryFnOutput:i(Pu),exportTokensFnInput:i(Tr),exportTokensFnOutput:i(Uu),exportTransferGroupsFnInput:i(gr),exportTransferGroupsFnOutput:i(Vu),exportTransfersFnInput:i(xr),exportTransfersFnOutput:i(Zu),exportWalletsFnInput:i(Sr),exportWalletsFnOutput:i(Hu),findBalancesFnInput:i(br),findBalancesFnOutput:i(qu),findTokensFnInput:i(yr),findTokensFnOutput:i(Qu),findTransferGroupsFnInput:i(hr),findTransferGroupsFnOutput:i(ju),findTransfersFnInput:i(Fr),findTransfersFnOutput:i(Lu),findWalletsFnInput:i(Or),findWalletsFnOutput:i(zu),getBalanceFnInput:i(_r),getBalanceFnOutput:i($u),getBalanceHistoryFnInput:i(Ir),getBalanceHistoryFnOutput:i(Ju),getExportFnInput:i(kr),getExportFnOutput:i(Ku),getFlagsFnInput:i(vr),getFlagsFnOutput:i(Yu),getStatisticsFnInput:i(wr),getStatisticsFnOutput:i(Xu),getTokenFnInput:i(Er),getTokenFnOutput:i(ed),getTransferFnInput:i(Mr),getTransferFnOutput:i(td),getTransferGroupFnInput:i(Rr),getTransferGroupFnOutput:i(rd),getWalletFnInput:i(Gr),getWalletFnOutput:i(nd),healthcheckFnInput:i(Wr),healthcheckFnOutput:i(ad),importDataFnInput:i(So),importDataFnOutput:i(id),listExportsFnInput:i(Nr),listExportsFnOutput:i(pd),reverseTransferFnInput:i(Cr),reverseTransferFnOutput:i(od),reverseTransferGroupFnInput:i(Ar),reverseTransferGroupFnOutput:i(sd),reverseTransfersFnInput:i(Dr),reverseTransfersFnOutput:i(ud),setFlagsFnInput:i(Br),setFlagsFnOutput:i(dd),updateTokenFnInput:i(Pr),updateTokenFnOutput:i(ld),updateTransferFnInput:i(Ur),updateTransferFnOutput:i(cd),updateTransferGroupFnInput:i(jr),updateTransferGroupFnOutput:i(fd),updateTransferGroupsFnInput:i(Vr),updateTransferGroupsFnOutput:i(md),updateTransfersFnInput:i(Lr),updateTransfersFnOutput:i(Td),updateWalletFnInput:i(Zr),updateWalletFnOutput:i(hd),aggregateTransferManyTxInput:i(ea),aggregateTransferManyTxOutput:i(ta),authenticationCheckTxInput:i(ra),authenticationCheckTxOutput:i(uu),createAccessTokenTxInput:i(na),createAccessTokenTxOutput:i(aa),createContractTxInput:i(ua),createContractTxOutput:i(da),createDepositTxInput:i(la),createDepositTxOutput:i(ca),createDistributionTxInput:i(fa),createDistributionTxOutput:i(du),createTokenTxInput:i(ma),createTokenTxOutput:i(Ta),createTransferTxInput:i(ia),createTransferTxOutput:i(Xe),createTransferGroupTxInput:i(pa),createTransferGroupTxOutput:i(et),createTransferManyTxInput:i(ha),createTransferManyTxOutput:i(ga),createWalletTxInput:i(Fa),createWalletTxOutput:i(xa),createWithdrawalTxInput:i(Oa),createWithdrawalTxOutput:i(Sa),exportBalanceHistoryTxInput:i(Ia),exportBalanceHistoryTxOutput:i(ka),exportTokenManyTxInput:i(wa),exportTokenManyTxOutput:i(Ea),exportTransferGroupManyTxInput:i(Ra),exportTransferGroupManyTxOutput:i(Ga),exportTransferManyTxInput:i(Wa),exportTransferManyTxOutput:i(Ca),exportWalletManyTxInput:i(Na),exportWalletManyTxOutput:i(Da),findBalanceManyTxInput:i(Ba),findBalanceManyTxOutput:i(Pa),findTokenManyTxInput:i(qt),findTokenManyTxOutput:i(va),findTransferGroupManyTxInput:i(Qt),findTransferGroupManyTxOutput:i(Ma),findTransferManyTxInput:i(Zt),findTransferManyTxOutput:i(Xn),findWalletManyTxInput:i($t),findWalletManyTxOutput:i(Aa),finishTransactionTxInput:i(Ua),finishTransactionTxOutput:i(gu),getBalanceTxInput:i(oa),getBalanceTxOutput:i(De),getBalanceHistoryTxInput:i(ya),getBalanceHistoryTxOutput:i(_a),getExportTxInput:i(ba),getExportTxOutput:i(he),getFlagsTxInput:i(ja),getFlagsTxOutput:i(Va),getStatisticsTxInput:i(Jt),getStatisticsTxOutput:i(La),getTokenTxInput:i($n),getTokenTxOutput:i(Jn),getTokenManyTxInput:i(Za),getTokenManyTxOutput:i(Fu),getTransferTxInput:i(qn),getTransferTxOutput:i(_e),getTransferGroupTxInput:i(Kn),getTransferGroupTxOutput:i(Yn),getWalletTxInput:i(Ln),getWalletTxOutput:i(zn),getWalletManyTxInput:i(za),getWalletManyTxOutput:i(xu),healthcheckTxInput:i(Ha),healthcheckTxOutput:i(qa),importActionsTxInput:i(Kt),importActionsTxOutput:i(Qa),listExportManyTxInput:i($a),listExportManyTxOutput:i(Ja),queryLogsTxInput:i(Ka),queryLogsTxOutput:i(Ou),resetDatabaseTxInput:i(Ya),resetDatabaseTxOutput:i(Su),reverseTransferTxInput:i(eo),reverseTransferTxOutput:i(to),reverseTransferGroupTxInput:i(ro),reverseTransferGroupTxOutput:i(no),reverseTransferGroupManyTxInput:i(ao),reverseTransferGroupManyTxOutput:i(bu),reverseTransferManyTxInput:i(oo),reverseTransferManyTxOutput:i(so),setFlagsTxInput:i(io),setFlagsTxOutput:i(po),startTransactionTxInput:i(uo),startTransactionTxOutput:i(yu),updateTokenTxInput:i(lo),updateTokenTxOutput:i(co),updateTransferTxInput:i(Xa),updateTransferTxOutput:i(Xt),updateTransferGroupTxInput:i(fo),updateTransferGroupTxOutput:i(mo),updateTransferGroupManyTxInput:i(To),updateTransferGroupManyTxOutput:i(ho),updateTransferManyTxInput:i(go),updateTransferManyTxOutput:i(Fo),updateWalletTxInput:i(xo),updateWalletTxOutput:i(Oo)};var bd=a.enum(["flag","setting"]).describe("Type of the setting"),yd=J(bd.options),Th=a.object({id:a.number().int().positive().describe("System defined primary key"),name:a.string().min(1).max(255).describe("name of setting. Must be unique"),value:a.string().describe("value of setting"),applied:a.boolean().describe("is setting applied"),created_at:E.describe("Datetime of the initial create"),updated_at:E.describe("Datetime of the last update"),type:bd}).strict().describe("WapiSetting|Database settings");var _d=Th.keyof(),hh=_d.options,gh=_d.options,JN=new Set(gh),KN=new Set(hh);var Fh=i(up),xh=i(dp),Id=(t=>(t.ws="ws",t.https="https",t))(Id||{});function Oh(r){let{config:e,client:t,connection:o}=r;if((t!=null?t:"ws")==="ws"){let n=Fh.validateInput(o);return xd(n,e)}if(t==="https"){let n=xh.validateInput(o);return Od(n,e)}throw new TypeError("Invalid client type")}var Sh={getIdentifier:Ro};return Wd(bh);})();
|