@xpert-ai/plugin-sdk 3.18.5 → 3.18.7

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.
Files changed (37) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/README.md +44 -0
  3. package/data-workbench.cjs.default.js +1 -0
  4. package/data-workbench.cjs.js +669 -0
  5. package/data-workbench.cjs.mjs +2 -0
  6. package/data-workbench.d.ts +1 -0
  7. package/data-workbench.esm.js +663 -0
  8. package/index.cjs.js +3118 -33
  9. package/index.esm.js +3109 -39
  10. package/model-provider.cjs.js +9 -0
  11. package/model-provider.esm.js +8 -2
  12. package/package.json +33 -27
  13. package/src/data-workbench.d.ts +3 -0
  14. package/src/lib/core/runtime-capability.d.ts +4 -0
  15. package/src/lib/core/strategy-bus.d.ts +3 -0
  16. package/src/lib/data/datasource/index.d.ts +3 -0
  17. package/src/lib/data/datasource/types.d.ts +2 -0
  18. package/src/lib/data/datasource/workbench-adapter.d.ts +39 -0
  19. package/src/lib/data/datasource/workbench-pagination.d.ts +6 -0
  20. package/src/lib/data/datasource/workbench-sql-lexer.d.ts +11 -0
  21. package/src/lib/data/datasource/workbench-sql-syntax.d.ts +3 -0
  22. package/src/lib/data/datasource/workbench-sql.d.ts +12 -0
  23. package/src/lib/data/datasource/workbench.d.ts +133 -0
  24. package/src/lib/rag/analyzer/index.d.ts +3 -0
  25. package/src/lib/rag/analyzer/strategy.decorator.d.ts +2 -0
  26. package/src/lib/rag/analyzer/strategy.interface.d.ts +11 -0
  27. package/src/lib/rag/analyzer/strategy.registry.d.ts +8 -0
  28. package/src/lib/rag/index.d.ts +1 -0
  29. package/src/lib/runtime/capabilities/index.d.ts +1 -0
  30. package/src/lib/runtime/capabilities/knowledge-graph.d.ts +59 -0
  31. package/src/lib/tool-provider/component.d.ts +2 -0
  32. package/src/lib/tool-provider/decorators.d.ts +1 -1
  33. package/src/lib/tool-provider/index.d.ts +3 -0
  34. package/src/lib/tool-provider/mcp-methods.d.ts +39 -0
  35. package/src/lib/tool-provider/provider-methods.d.ts +5 -0
  36. package/src/lib/tool-provider/tool-result.d.ts +1 -1
  37. package/src/lib/tool-provider/types.d.ts +12 -1
package/index.esm.js CHANGED
@@ -4,19 +4,19 @@ import { pick } from 'lodash-es';
4
4
  import { _ as _extends } from './_extends.esm.js';
5
5
  import { DiscoveryService, Reflector } from '@nestjs/core';
6
6
  import { Subject, filter } from 'rxjs';
7
- import { LanguagesEnum, ParameterType, AiModelTypeEnum, PriceType, FetchFrom, ModelFeature, ModelPropertyKey, MCP_CAPABILITY_APPROVAL_MODES, MCP_TOOL_RISKS, MCP_TOOL_SIDE_EFFECTS, MCP_TOOL_IDEMPOTENCY, MCP_REQUIRED_CONTEXTS, MCP_CAPABILITY_VISIBILITIES } from '@xpert-ai/contracts';
7
+ import { LanguagesEnum, ParameterType, AiModelTypeEnum, PriceType, FetchFrom, ModelFeature, ModelPropertyKey, MCP_REQUIRED_CONTEXTS, MCP_CAPABILITY_APPROVAL_MODES, MCP_TOOL_RISKS, MCP_TOOL_SIDE_EFFECTS, MCP_TOOL_IDEMPOTENCY, MCP_CAPABILITY_VISIBILITIES, PLUGIN_COMPONENT_TYPE } from '@xpert-ai/contracts';
8
8
  export { ASSISTANT_CHAT_SEND_MESSAGE_COMMAND, ASSISTANT_CONTEXT_SET_COMMAND } from '@xpert-ai/contracts';
9
9
  import { AsyncLocalStorage } from 'node:async_hooks';
10
10
  import { ExtractJwt } from 'passport-jwt';
11
11
  import { verify, JsonWebTokenError } from 'jsonwebtoken';
12
- import { randomUUID } from 'node:crypto';
12
+ import { randomUUID, createHash } from 'node:crypto';
13
13
  import { Command } from '@nestjs/cqrs';
14
14
  import * as fs from 'fs';
15
15
  import fs__default from 'fs';
16
16
  import http from 'http';
17
17
  import https from 'https';
18
- import { c as createRuntimeCapability, B as BuiltinToolset } from './model-provider.esm.js';
19
- export { A as ActorTokenRuntimeCapability, a as ActorTokenRuntimeFactoryCapability, b as ArtifactsRuntimeCapability, d as BaseTool, e as BaseToolset, D as DefaultAgentMiddlewareRuntimeCapabilityRegistry, D as DefaultRuntimeCapabilityRegistry, K as KnowledgeDocumentVisualAssetsRuntimeCapability, f as KnowledgeDocumentVisualAssetsRuntimeFactoryCapability, g as KnowledgebaseDocumentsRuntimeCapability, h as KnowledgebaseProvisioningRuntimeCapability, i as KnowledgebaseRuntimeCapability, M as ModelProviderBuiltinToolset, P as ProjectAccessRuntimeCapability, j as ProjectProvisioningRuntimeCapability, S as SANDBOX_JOB_ERROR_CODES, k as SANDBOX_JOB_PROGRESS_PREFIX, l as SandboxJobRuntimeError, m as SandboxJobsRuntimeCapability, W as WORKSPACE_FILES_SOURCE, n as WorkspaceFilesRuntimeCapability, X as XPERT_RUNTIME_CAPABILITIES_TOKEN, o as isSandboxJobRuntimeError } from './model-provider.esm.js';
18
+ import { c as createRuntimeCapability, B as BuiltinToolset, W as WorkspaceFilesRuntimeCapability } from './model-provider.esm.js';
19
+ export { A as ActorTokenRuntimeCapability, a as ActorTokenRuntimeFactoryCapability, b as ArtifactsRuntimeCapability, d as BaseTool, e as BaseToolset, D as DefaultAgentMiddlewareRuntimeCapabilityRegistry, D as DefaultRuntimeCapabilityRegistry, K as KnowledgeDocumentVisualAssetsRuntimeCapability, f as KnowledgeDocumentVisualAssetsRuntimeFactoryCapability, g as KnowledgeGraphRuntimeCapability, h as KnowledgebaseDocumentsRuntimeCapability, i as KnowledgebaseProvisioningRuntimeCapability, j as KnowledgebaseRuntimeCapability, M as ModelProviderBuiltinToolset, P as ProjectAccessRuntimeCapability, k as ProjectProvisioningRuntimeCapability, R as RUNTIME_CAPABILITY_PROVIDER, l as RuntimeCapabilityProvider, S as SANDBOX_JOB_ERROR_CODES, m as SANDBOX_JOB_PROGRESS_PREFIX, n as SandboxJobRuntimeError, o as SandboxJobsRuntimeCapability, p as WORKSPACE_FILES_SOURCE, X as XPERT_RUNTIME_CAPABILITIES_TOKEN, q as isSandboxJobRuntimeError } from './model-provider.esm.js';
20
20
  import fsPromises from 'fs/promises';
21
21
  import * as path from 'path';
22
22
  import path__default, { join } from 'path';
@@ -27,6 +27,7 @@ import yaml__default from 'yaml';
27
27
  import Ajv from 'ajv';
28
28
  import schemaDraft04 from 'ajv/dist/refs/json-schema-draft-06.json';
29
29
  import * as _axios from 'axios';
30
+ export { DataSourceRuntimeCapability, SqlDatabaseWorkbenchAdapter, quoteDatabaseIdentifier, requireReadStatement, splitWorkbenchSql } from './data-workbench.esm.js';
30
31
  import { BaseCallbackHandler } from '@langchain/core/callbacks/base';
31
32
  import { ChatGenerationChunk } from '@langchain/core/outputs';
32
33
  import { isAIMessageChunk, AIMessage } from '@langchain/core/messages';
@@ -41,7 +42,7 @@ import { assertConnectorDefinition } from './connector.esm.js';
41
42
  export { CONNECTOR_AUTHORIZATION_MODES, CONNECTOR_SCOPE_TYPES, getConnectorAuthMethods, getConnectorAuthorizationModes } from './connector.esm.js';
42
43
  export { base64ToBytes, bytesToBase64, createCollaborationClient, createCollaborationPresenceStore, createSocketIoTransportAdapter, createYjsDocumentAdapter } from './collaboration-client.esm.js';
43
44
  import { tool } from '@langchain/core/tools';
44
- import { ZodError, z } from 'zod/v3';
45
+ import { ZodError, z, ZodFirstPartyTypeKind } from 'zod/v3';
45
46
 
46
47
  /**
47
48
  * Metadata keys used in plugins for defining various aspects like entities, subscribers, and configurations.
@@ -496,6 +497,15 @@ function runWithRequestContext(req, res, next) {
496
497
  }
497
498
 
498
499
  let StrategyBus = class StrategyBus {
500
+ registerRemovalGuard(guard) {
501
+ this.removalGuards.add(guard);
502
+ return ()=>{
503
+ this.removalGuards.delete(guard);
504
+ };
505
+ }
506
+ async assertCanRemove(scopeKey, pluginNames) {
507
+ for (const guard of this.removalGuards)await guard(scopeKey, pluginNames);
508
+ }
499
509
  upsert(strategyType, entry) {
500
510
  this.subject.next({
501
511
  type: 'UPSERT',
@@ -513,6 +523,7 @@ let StrategyBus = class StrategyBus {
513
523
  } : {}));
514
524
  }
515
525
  constructor(){
526
+ this.removalGuards = new Set();
516
527
  this.subject = new Subject();
517
528
  this.events$ = this.subject.asObservable();
518
529
  }
@@ -1012,6 +1023,34 @@ KnowledgeStrategyRegistry = __decorate([
1012
1023
  ])
1013
1024
  ], KnowledgeStrategyRegistry);
1014
1025
 
1026
+ const KEYWORD_ANALYZER_STRATEGY = 'KEYWORD_ANALYZER_STRATEGY';
1027
+ const KeywordAnalyzerStrategy = (provider)=>applyDecorators(SetMetadata(KEYWORD_ANALYZER_STRATEGY, provider), SetMetadata(STRATEGY_META_KEY, KEYWORD_ANALYZER_STRATEGY));
1028
+
1029
+ let KeywordAnalyzerRegistry = class KeywordAnalyzerRegistry extends BaseStrategyRegistry {
1030
+ /** Resolve a pinned source without allowing a higher-priority scope to shadow it. */ getBySource(provider, source, organizationId) {
1031
+ var _this_strategies_get;
1032
+ if (!this.resolveStrategyScopeKeys(organizationId).includes(source.scopeKey)) return undefined;
1033
+ const strategy = (_this_strategies_get = this.strategies.get(source.scopeKey)) == null ? void 0 : _this_strategies_get.get(provider);
1034
+ if (!strategy) return undefined;
1035
+ const registered = this.getSource(strategy);
1036
+ if (registered.kind !== source.kind || registered.scopeKey !== source.scopeKey) return undefined;
1037
+ if (source.kind === 'plugin' && (registered.kind !== 'plugin' || registered.pluginName !== source.pluginName)) {
1038
+ return undefined;
1039
+ }
1040
+ return strategy;
1041
+ }
1042
+ constructor(discoveryService, reflector){
1043
+ super(KEYWORD_ANALYZER_STRATEGY, discoveryService, reflector);
1044
+ }
1045
+ };
1046
+ KeywordAnalyzerRegistry = __decorate([
1047
+ Injectable(),
1048
+ __metadata("design:paramtypes", [
1049
+ DiscoveryService,
1050
+ Reflector
1051
+ ])
1052
+ ], KeywordAnalyzerRegistry);
1053
+
1015
1054
  const TOOLSET_STRATEGY = 'TOOLSET_STRATEGY';
1016
1055
  /**
1017
1056
  * Decorator to mark a provider as a Toolset Strategy
@@ -5948,9 +5987,164 @@ function freezeItems(items) {
5948
5987
  const XPERT_TOOL_PROVIDER = 'XPERT_TOOL_PROVIDER';
5949
5988
  const XPERT_TOOL_PROVIDER_METADATA = 'XPERT_TOOL_PROVIDER_METADATA';
5950
5989
  const XPERT_TOOL_METHOD_METADATA = 'XPERT_TOOL_METHOD_METADATA';
5951
- /** Marks one injectable business service as a reusable Tool provider and one native MCP service. */ const XpertToolProvider = (options)=>applyDecorators(Injectable(), SetMetadata(XPERT_TOOL_PROVIDER, options.provider), SetMetadata(XPERT_TOOL_PROVIDER_METADATA, Object.freeze(_extends({}, options))), SetMetadata(STRATEGY_META_KEY, XPERT_TOOL_PROVIDER));
5990
+ /** Marks one injectable business service as a shared Tool, Resource and Prompt provider. */ const XpertToolProvider = (options)=>applyDecorators(Injectable(), SetMetadata(XPERT_TOOL_PROVIDER, options.provider), SetMetadata(XPERT_TOOL_PROVIDER_METADATA, Object.freeze(_extends({}, options))), SetMetadata(STRATEGY_META_KEY, XPERT_TOOL_PROVIDER));
5952
5991
  /** Exposes one business method through an Agent Middleware, native MCP, or both. */ const XpertTool = (options)=>SetMetadata(XPERT_TOOL_METHOD_METADATA, Object.freeze(_extends({}, options)));
5953
5992
 
5993
+ /** Child overrides hide parent declarations, including undecorated overrides and accessors. */ function collectProviderMethods(instance) {
5994
+ const methods = [];
5995
+ const seen = new Set();
5996
+ let prototype = Object.getPrototypeOf(instance);
5997
+ while(prototype && prototype !== Object.prototype){
5998
+ for (const methodName of Object.getOwnPropertyNames(prototype)){
5999
+ var _Object_getOwnPropertyDescriptor;
6000
+ if (methodName === 'constructor' || seen.has(methodName)) continue;
6001
+ seen.add(methodName);
6002
+ const method = (_Object_getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor(prototype, methodName)) == null ? void 0 : _Object_getOwnPropertyDescriptor.value;
6003
+ if (typeof method === 'function') methods.push({
6004
+ methodName,
6005
+ method
6006
+ });
6007
+ }
6008
+ prototype = Object.getPrototypeOf(prototype);
6009
+ }
6010
+ return methods;
6011
+ }
6012
+
6013
+ function _object_without_properties_loose$2(source, excluded) {
6014
+ if (source == null) return {};
6015
+ var target = {};
6016
+ var sourceKeys = Object.keys(source);
6017
+ var key, i;
6018
+ for(i = 0; i < sourceKeys.length; i++){
6019
+ key = sourceKeys[i];
6020
+ if (excluded.indexOf(key) >= 0) continue;
6021
+ target[key] = source[key];
6022
+ }
6023
+ return target;
6024
+ }
6025
+
6026
+ const MCP_METHOD_METADATA = 'XPERT_MCP_METHOD_METADATA';
6027
+ /** The decorated method receives ResourceReadContext and returns McpResourceReadResult. */ const XpertResource = (options)=>SetMetadata(MCP_METHOD_METADATA, {
6028
+ kind: 'resource',
6029
+ options: Object.freeze(_extends({}, options))
6030
+ });
6031
+ /** The decorated method receives URI arguments and ResourceReadContext. */ const XpertResourceTemplate = (options)=>SetMetadata(MCP_METHOD_METADATA, {
6032
+ kind: 'resource-template',
6033
+ options: Object.freeze(_extends({}, options))
6034
+ });
6035
+ /** The decorated method receives prompt arguments and ToolExecutionContext. */ const XpertPrompt = (options)=>SetMetadata(MCP_METHOD_METADATA, {
6036
+ kind: 'prompt',
6037
+ options: Object.freeze(_extends({}, options))
6038
+ });
6039
+ function describeXpertMcpMethods(instance) {
6040
+ const result = [];
6041
+ for (const { methodName, method } of collectProviderMethods(instance)){
6042
+ var _metadata_options_uri, _metadata_options_uriTemplate, _metadata_options_name;
6043
+ const metadata = Reflect.getMetadata(MCP_METHOD_METADATA, method);
6044
+ if (!metadata) continue;
6045
+ const { options } = metadata;
6046
+ if (!/^[A-Za-z0-9_-]{1,191}$/.test(options.key)) throw new Error(`Invalid MCP capability key '${options.key}'.`);
6047
+ var _options_requiredContext;
6048
+ const contexts = (_options_requiredContext = options.requiredContext) != null ? _options_requiredContext : [];
6049
+ if (new Set(contexts).size !== contexts.length || contexts.some((context)=>!MCP_REQUIRED_CONTEXTS.includes(context))) {
6050
+ throw new Error(`MCP capability '${options.key}' declares invalid execution contexts.`);
6051
+ }
6052
+ if (metadata.kind === 'resource' && !((_metadata_options_uri = metadata.options.uri) == null ? void 0 : _metadata_options_uri.trim())) {
6053
+ throw new Error(`Resource '${options.key}' requires a URI.`);
6054
+ }
6055
+ if (metadata.kind === 'resource-template' && !((_metadata_options_uriTemplate = metadata.options.uriTemplate) == null ? void 0 : _metadata_options_uriTemplate.trim())) {
6056
+ throw new Error(`Resource template '${options.key}' requires a URI template.`);
6057
+ }
6058
+ if (metadata.kind === 'prompt' && !((_metadata_options_name = metadata.options.name) == null ? void 0 : _metadata_options_name.trim())) {
6059
+ throw new Error(`Prompt '${options.key}' requires a name.`);
6060
+ }
6061
+ if (metadata.kind !== 'resource' && metadata.options.completionMethod) {
6062
+ callable(instance, metadata.options.completionMethod);
6063
+ }
6064
+ result.push(Object.freeze(_extends({}, metadata, {
6065
+ methodName
6066
+ })));
6067
+ }
6068
+ return Object.freeze(result);
6069
+ }
6070
+ /** One catalog for runtime publication and fingerprinting; legacy declarations remain supported. */ function resolveXpertMcpExtensions(instance, descriptor) {
6071
+ const legacy = 'getMcpExtensions' in instance && typeof instance.getMcpExtensions === 'function' ? instance.getMcpExtensions == null ? void 0 : instance.getMcpExtensions.call(instance) : undefined;
6072
+ var _legacy_resources;
6073
+ const resources = [
6074
+ ...(_legacy_resources = legacy == null ? void 0 : legacy.resources) != null ? _legacy_resources : []
6075
+ ];
6076
+ var _legacy_resourceTemplates;
6077
+ const resourceTemplates = [
6078
+ ...(_legacy_resourceTemplates = legacy == null ? void 0 : legacy.resourceTemplates) != null ? _legacy_resourceTemplates : []
6079
+ ];
6080
+ var _legacy_prompts;
6081
+ const prompts = [
6082
+ ...(_legacy_prompts = legacy == null ? void 0 : legacy.prompts) != null ? _legacy_prompts : []
6083
+ ];
6084
+ var _descriptor_mcpMethods;
6085
+ for (const _ref of (_descriptor_mcpMethods = descriptor == null ? void 0 : descriptor.mcpMethods) != null ? _descriptor_mcpMethods : describeXpertMcpMethods(instance)){
6086
+ let definition = _ref;
6087
+ const method = callable(instance, definition.methodName);
6088
+ switch(definition.kind){
6089
+ case 'resource':
6090
+ resources.push(_extends({}, definition.options, {
6091
+ read: method
6092
+ }));
6093
+ break;
6094
+ case 'resource-template':
6095
+ {
6096
+ const _definition_options = definition.options, { completionMethod } = _definition_options, options = _object_without_properties_loose$2(_definition_options, [
6097
+ "completionMethod"
6098
+ ]);
6099
+ resourceTemplates.push(_extends({}, options, {
6100
+ read: method
6101
+ }, completionMethod ? {
6102
+ complete: callable(instance, completionMethod)
6103
+ } : {}));
6104
+ break;
6105
+ }
6106
+ case 'prompt':
6107
+ {
6108
+ const _definition_options = definition.options, { completionMethod } = _definition_options, options = _object_without_properties_loose$2(_definition_options, [
6109
+ "completionMethod"
6110
+ ]);
6111
+ prompts.push(_extends({}, options, {
6112
+ get: method
6113
+ }, completionMethod ? {
6114
+ complete: callable(instance, completionMethod)
6115
+ } : {}));
6116
+ break;
6117
+ }
6118
+ }
6119
+ }
6120
+ assertUnique(resources, (item)=>item.key, 'resource key');
6121
+ assertUnique(resources, (item)=>item.uri, 'resource URI');
6122
+ assertUnique(resourceTemplates, (item)=>item.key, 'resource template key');
6123
+ assertUnique(resourceTemplates, (item)=>item.uriTemplate, 'resource template URI');
6124
+ assertUnique(prompts, (item)=>item.key, 'prompt key');
6125
+ assertUnique(prompts, (item)=>item.name, 'prompt name');
6126
+ return {
6127
+ resources,
6128
+ resourceTemplates,
6129
+ prompts
6130
+ };
6131
+ }
6132
+ function callable(instance, name) {
6133
+ var _collectProviderMethods_find;
6134
+ // Match discovery semantics: accessors and non-method overrides are not executable handlers.
6135
+ const method = (_collectProviderMethods_find = collectProviderMethods(instance).find((item)=>item.methodName === name)) == null ? void 0 : _collectProviderMethods_find.method;
6136
+ if (typeof method !== 'function') throw new Error(`MCP method '${name}' is not callable.`);
6137
+ return method.bind(instance);
6138
+ }
6139
+ function assertUnique(items, key, label) {
6140
+ const seen = new Set();
6141
+ for (const item of items){
6142
+ const value = key(item);
6143
+ if (seen.has(value)) throw new Error(`MCP ${label} '${value}' is declared more than once.`);
6144
+ seen.add(value);
6145
+ }
6146
+ }
6147
+
5954
6148
  const PROVIDER_PATTERN = /^[a-z][a-z0-9_]*$/;
5955
6149
  const MIDDLEWARE_PROVIDER_PATTERN = /^[A-Za-z][A-Za-z0-9_]*$/;
5956
6150
  const COMPONENT_KEY_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
@@ -5993,31 +6187,24 @@ function describeXpertToolProvider(instance) {
5993
6187
  options: toolOptions
5994
6188
  });
5995
6189
  });
5996
- if (!tools.length) {
5997
- throw new Error(`Provider '${options.provider}' does not declare any @XpertTool methods.`);
6190
+ const mcpMethods = describeXpertMcpMethods(instance);
6191
+ if (!tools.length && !mcpMethods.length) {
6192
+ throw new Error(`Provider '${options.provider}' does not declare any decorated capability methods.`);
5998
6193
  }
5999
6194
  return Object.freeze({
6000
6195
  options: Object.freeze(_extends({}, options)),
6001
- tools: Object.freeze(tools)
6196
+ tools: Object.freeze(tools),
6197
+ mcpMethods
6002
6198
  });
6003
6199
  }
6004
6200
  function collectDecoratedMethods(instance) {
6005
6201
  const result = [];
6006
- const seen = new Set();
6007
- let prototype = Object.getPrototypeOf(instance);
6008
- while(prototype && prototype !== Object.prototype){
6009
- for (const methodName of Object.getOwnPropertyNames(prototype)){
6010
- if (methodName === 'constructor' || seen.has(methodName)) continue;
6011
- seen.add(methodName);
6012
- const method = Reflect.get(prototype, methodName);
6013
- if (typeof method !== 'function') continue;
6014
- const options = Reflect.getMetadata(XPERT_TOOL_METHOD_METADATA, method);
6015
- if (options) result.push({
6016
- methodName,
6017
- options
6018
- });
6019
- }
6020
- prototype = Object.getPrototypeOf(prototype);
6202
+ for (const { methodName, method } of collectProviderMethods(instance)){
6203
+ const options = Reflect.getMetadata(XPERT_TOOL_METHOD_METADATA, method);
6204
+ if (options) result.push({
6205
+ methodName,
6206
+ options
6207
+ });
6021
6208
  }
6022
6209
  return result;
6023
6210
  }
@@ -6070,15 +6257,12 @@ function validateToolOptions(options, methodName) {
6070
6257
  if (options.resultFormat && options.resultFormat !== 'dto' && options.resultFormat !== 'tool_result') {
6071
6258
  throw new Error(`Tool '${options.name}' declares an invalid resultFormat.`);
6072
6259
  }
6073
- if (options.resultFormat === 'tool_result' && !options.outputSchema) {
6074
- throw new Error(`Tool '${options.name}' requires outputSchema for tool_result.`);
6075
- }
6076
6260
  if (!TOOL_NAME_PATTERN.test(options.name) || options.name.length > 191) {
6077
6261
  throw new Error(`Method '${methodName}' declares invalid Tool name '${options.name}'.`);
6078
6262
  }
6079
6263
  if (!((_options_description = options.description) == null ? void 0 : _options_description.trim())) throw new Error(`Tool '${options.name}' requires a description.`);
6080
6264
  assertStrictObjectSchema(options.inputSchema, options.name, 'input');
6081
- if (options.mcp && !options.outputSchema) {
6265
+ if (options.mcp && !options.outputSchema && options.resultFormat !== 'tool_result') {
6082
6266
  throw new Error(`MCP Tool '${options.name}' requires an outputSchema.`);
6083
6267
  }
6084
6268
  if (options.mcp && options.outputSchema) {
@@ -6088,6 +6272,14 @@ function validateToolOptions(options, methodName) {
6088
6272
  throw new Error(`MCP Tool '${options.name}' requires at least one execution context.`);
6089
6273
  }
6090
6274
  if (options.mcp) {
6275
+ const transportSchema = options.mcp.inputSchema;
6276
+ if (transportSchema && typeof transportSchema.parseAsync !== 'function') {
6277
+ throw new Error(`MCP Tool '${options.name}' requires a Zod transport input schema.`);
6278
+ }
6279
+ const task = options.mcp.task;
6280
+ if (task && (task.mode !== 'optional' && task.mode !== 'required' || task.maxLifetimeMs !== undefined && (!Number.isSafeInteger(task.maxLifetimeMs) || task.maxLifetimeMs <= 0))) {
6281
+ throw new Error(`MCP Tool '${options.name}' declares invalid task execution policy.`);
6282
+ }
6091
6283
  if (options.mcp.defaultApprovalMode !== undefined && !includesValue(MCP_CAPABILITY_APPROVAL_MODES, options.mcp.defaultApprovalMode)) {
6092
6284
  throw new Error(`MCP Tool '${options.name}' declares invalid defaultApprovalMode.`);
6093
6285
  }
@@ -6270,7 +6462,7 @@ const contentSchema = z.discriminatedUnion('type', [
6270
6462
  var _result_content;
6271
6463
  const envelope = z.object({
6272
6464
  content: z.array(contentSchema).max(32).optional(),
6273
- structuredContent: outputSchema,
6465
+ structuredContent: outputSchema != null ? outputSchema : z.unknown().optional(),
6274
6466
  isError: z.boolean().optional()
6275
6467
  }).strict();
6276
6468
  const result = await envelope.parseAsync(value);
@@ -6306,7 +6498,7 @@ const contentSchema = z.discriminatedUnion('type', [
6306
6498
  // MCP clients may expose only content to the model. Keep the validated DTO
6307
6499
  // readable there too, while retaining binary blocks and App structured data.
6308
6500
  const text = JSON.stringify(result.structuredContent);
6309
- if (!content.some((item)=>item.type === 'text' && item.text === text)) content.push({
6501
+ if (text !== undefined && !content.some((item)=>item.type === 'text' && item.text === text)) content.push({
6310
6502
  type: 'text',
6311
6503
  text
6312
6504
  });
@@ -6427,7 +6619,11 @@ let DecoratedBuiltinToolset = class DecoratedBuiltinToolset extends BuiltinTools
6427
6619
  this.pluginName = pluginName;
6428
6620
  this.pluginVersion = pluginVersion;
6429
6621
  this.tools = [];
6622
+ const extensions = resolveXpertMcpExtensions(instance, descriptor);
6430
6623
  _class_private_field_loose_base(this, _definitions)[_definitions] = _extends({
6624
+ resources: extensions == null ? void 0 : extensions.resources,
6625
+ resourceTemplates: extensions == null ? void 0 : extensions.resourceTemplates,
6626
+ prompts: extensions == null ? void 0 : extensions.prompts,
6431
6627
  instructions: descriptor.options.instructions,
6432
6628
  tools: descriptor.tools.filter((item)=>!!item.options.mcp).map((item)=>createMcpTool(instance, item))
6433
6629
  }, ((_descriptor_options_apps = descriptor.options.apps) == null ? void 0 : _descriptor_options_apps.length) ? {
@@ -6442,7 +6638,7 @@ function createAgentTool(instance, descriptor, middlewareContext, middlewareOpti
6442
6638
  return tool(async (input, config)=>{
6443
6639
  const parsedInput = await descriptor.options.inputSchema.parseAsync(input);
6444
6640
  const output = await invoke(parsedInput, agentExecutionContext(middlewareContext, middlewareOptions, config));
6445
- if (descriptor.options.resultFormat === 'tool_result' && descriptor.options.outputSchema) {
6641
+ if (descriptor.options.resultFormat === 'tool_result') {
6446
6642
  const result = await resolveToolResult(output, (value)=>parseDecoratedToolResult(value, descriptor.options.outputSchema));
6447
6643
  var _result_isError;
6448
6644
  return [
@@ -6470,24 +6666,28 @@ function createAgentTool(instance, descriptor, middlewareContext, middlewareOpti
6470
6666
  function createMcpTool(instance, descriptor) {
6471
6667
  const mcp = descriptor.options.mcp;
6472
6668
  const outputSchema = descriptor.options.outputSchema;
6473
- if (!mcp || !outputSchema) throw new Error(`MCP Tool '${descriptor.options.name}' is incomplete.`);
6669
+ if (!mcp) throw new Error(`MCP Tool '${descriptor.options.name}' is incomplete.`);
6474
6670
  const invoke = getXpertToolMethod(instance, descriptor);
6475
- var _mcp_visibility;
6671
+ var _mcp_inputSchema, _mcp_visibility;
6476
6672
  return _extends({
6477
6673
  name: descriptor.options.name
6478
6674
  }, descriptor.options.title ? {
6479
6675
  title: descriptor.options.title
6480
6676
  } : {}, {
6481
6677
  description: descriptor.options.description,
6482
- inputSchema: descriptor.options.inputSchema,
6483
- outputSchema,
6678
+ inputSchema: (_mcp_inputSchema = mcp.inputSchema) != null ? _mcp_inputSchema : descriptor.options.inputSchema
6679
+ }, outputSchema ? {
6680
+ outputSchema
6681
+ } : {}, {
6484
6682
  exposure: {
6485
6683
  mcp: {
6486
6684
  eligible: true
6487
6685
  }
6488
6686
  },
6489
6687
  behavior: mcp.behavior
6490
- }, mcp.defaultApprovalMode ? {
6688
+ }, mcp.task ? {
6689
+ task: mcp.task
6690
+ } : {}, mcp.defaultApprovalMode ? {
6491
6691
  defaultApprovalMode: mcp.defaultApprovalMode
6492
6692
  } : {}, {
6493
6693
  requiredContext: [
@@ -6508,12 +6708,13 @@ function createMcpTool(instance, descriptor) {
6508
6708
  } : {}, {
6509
6709
  execute: async (input, context)=>{
6510
6710
  const parsedInput = await descriptor.options.inputSchema.parseAsync(input);
6511
- const output = await invoke(parsedInput, mcpExecutionContext(context));
6711
+ const transportInput = mcp.inputSchema ? await mcp.inputSchema.parseAsync(parsedInput) : parsedInput;
6712
+ const output = await invoke(transportInput, mcpExecutionContext(context));
6512
6713
  if (descriptor.options.resultFormat === 'tool_result') {
6513
6714
  return resolveToolResult(output, (value)=>parseDecoratedToolResult(value, outputSchema));
6514
6715
  }
6515
6716
  return resolveToolResult(output, async (value)=>{
6516
- const parsedOutput = await outputSchema.parseAsync(value);
6717
+ const parsedOutput = outputSchema ? await outputSchema.parseAsync(value) : value;
6517
6718
  // Serialize once so text-only clients and MCP Apps receive the same JSON-safe DTO.
6518
6719
  const text = stringifyDto(parsedOutput, descriptor.options.name);
6519
6720
  return {
@@ -6530,6 +6731,7 @@ function createMcpTool(instance, descriptor) {
6530
6731
  });
6531
6732
  }
6532
6733
  function agentExecutionContext(context, middlewareOptions, config) {
6734
+ var _context_runtime_capabilities;
6533
6735
  const configurable = config.configurable;
6534
6736
  const requestId = readString(configurable, 'tool_call_id');
6535
6737
  const executionId = readString(configurable, 'executionId');
@@ -6558,11 +6760,13 @@ function agentExecutionContext(context, middlewareOptions, config) {
6558
6760
  } : {}, {
6559
6761
  signal: config.signal,
6560
6762
  host: {
6763
+ files: (_context_runtime_capabilities = context.runtime.capabilities) == null ? void 0 : _context_runtime_capabilities.get(WorkspaceFilesRuntimeCapability),
6561
6764
  models: {
6562
6765
  createModelClient: context.runtime.createModelClient,
6563
6766
  getModelProvider: context.runtime.getModelProvider
6564
6767
  }
6565
6768
  },
6769
+ xpertFeatures: context.xpertFeatures,
6566
6770
  middlewareOptions
6567
6771
  });
6568
6772
  }
@@ -6669,4 +6873,2870 @@ XpertToolProviderCoordinator = __decorate([
6669
6873
  ])
6670
6874
  ], XpertToolProviderCoordinator);
6671
6875
 
6672
- export { ACCOUNT_BINDING_PERMISSION_SERVICE_TOKEN, AGENT_CHAT_DISPATCH_ERROR_STEER_TARGET_NOT_RUNNING, AGENT_CHAT_DISPATCH_MESSAGE_TYPE, AGENT_MIDDLEWARE_STRATEGY, AIModel, AIModelProviderNotFoundException, AIModelProviderRegistry, AIModelProviderStrategy, AI_MODEL_PROVIDER, AdapterDataSourceStrategy, AgentMiddlewareRegistry, AgentMiddlewareStrategy, AiModelNotFoundException, AssistantTaskRuntimeCapability, BOUND_IDENTITY_LOGIN_PERMISSION_SERVICE_TOKEN, BUILTIN_GLOBAL_SCOPE, BaseHTTPQueryRunner, BaseQueryRunner, BaseSQLQueryRunner, BaseSandbox, BaseStrategyRegistry, BuiltinToolset, CHAT_CHANNEL, CHAT_CHANNEL_TEXT_LIMITS, COLLABORATION_DOCUMENT_PROVIDER, CONNECTION_COMMAND_ROUTER_TOKEN, CONNECTOR_STRATEGY, CancelConversationCommand, ChatChannel, ChatChannelRegistry, ChatOAICompatReasoningModel, CollaborationDocumentProvider, CollaborationDocumentProviderRegistry, CollaborationRuntimeCapability, CommonParameterRules, ConnectorRuntimeCapability, ConnectorRuntimeFactoryCapability, ConnectorStrategyKey, ConnectorStrategyRegistry, CreateModelClientCommand, CredentialsValidateFailedError, DATASOURCE_STRATEGY, DBCreateTableMode, DBProtocolEnum, DBSyntaxEnum, DBTableAction, DBTableDataAction, DEFAULT_EXECUTION_CONFIG, DEFAULT_SANDBOX_EXECUTION_MAX_OUTPUT_BYTES, DEFAULT_SANDBOX_FILE_OPERATION_EXECUTION_OPTIONS, DEFAULT_SANDBOX_FILE_OPERATION_TIMEOUT_MS, DEFAULT_SANDBOX_FILE_OPERATION_TIMEOUT_SEC, DEFAULT_SANDBOX_FILE_SEARCH_EXECUTION_OPTIONS, DEFAULT_SANDBOX_FILE_SEARCH_TIMEOUT_MS, DEFAULT_SANDBOX_FILE_SEARCH_TIMEOUT_SEC, DEFAULT_SANDBOX_SHELL_EXECUTION_OPTIONS, DEFAULT_SANDBOX_SHELL_TIMEOUT_MS, DEFAULT_SANDBOX_SHELL_TIMEOUT_SEC, DOCUMENT_SOURCE_STRATEGY, DOCUMENT_TRANSFORMER_STRATEGY, DataSourceStrategy, DataSourceStrategyRegistry, DecoratedAgentMiddlewareStrategy, DecoratedToolsetStrategy, DocumentSourceRegistry, DocumentSourceStrategy, DocumentTransformerRegistry, DocumentTransformerStrategy, EVOLUTION_RUNTIME_SERVICE_TOKEN, EVOLUTION_TARGET_PROVIDER, EvolutionChangeRuntimeCapability, EvolutionRuntimeCapability, EvolutionTargetProviderRegistry, EvolutionTargetProviderStrategy, FILE_STORAGE_PROVIDER, FILE_UPLOAD_TARGET_STRATEGY, FileRuntimeCapability, FileStorageProvider, FileStorageProviderRegistry, FileUploadTargetRegistry, FileUploadTargetStrategy, GLOBAL_ORGANIZATION_SCOPE, HANDOFF_PERMISSION_SERVICE_TOKEN, HANDOFF_PROCESSOR_STRATEGY, HANDOFF_QUEUE_SERVICE_TOKEN, HandoffProcessorRegistry, HandoffProcessorStrategy, IMAGE_UNDERSTANDING_STRATEGY, INTEGRATION_PERMISSION_SERVICE_TOKEN, INTEGRATION_STRATEGY, ImageGenerationModel, ImageUnderstandingRegistry, ImageUnderstandingStrategy, IntegrationStrategyKey, IntegrationStrategyRegistry, JUMP_TO_TARGETS, JsonSchemaValidator, KNOWLEDGE_STRATEGY, KnowledgeStrategyKey, KnowledgeStrategyRegistry, LLMUsage, LargeLanguageModel, MANAGED_CONNECTION_REGISTRY_TOKEN, MANAGED_QUEUE_HANDLER_REGISTRY_TOKEN, MANAGED_QUEUE_SERVICE_TOKEN, MCP_CAPABILITY_CHANGE_EVENT_TYPES, MODEL_OUTPUT_VALIDATION_ERROR_CODE, ModelOutputValidationError, ModelProvider, ORGANIZATION_METADATA_KEY, OpenAICompatibleReranker, PERMISSION_OPERATION_METADATA_KEY, PLUGIN_CONFIG_RESOLVER_TOKEN, PLUGIN_JOB_PROCESSOR_METADATA, PLUGIN_METADATA, PLUGIN_METADATA_KEY, PLUGIN_VERSION_METADATA_KEY, PLUGIN_WEBHOOK_AUTH_METADATA_KEY, PLUGIN_WEBHOOK_AUTH_SERVICE_TOKEN, PROVIDE_AI_MODEL_LLM, PROVIDE_AI_MODEL_MODERATION, PROVIDE_AI_MODEL_RERANK, PROVIDE_AI_MODEL_SPEECH2TEXT, PROVIDE_AI_MODEL_TEXT_EMBEDDING, PROVIDE_AI_MODEL_TTS, PluginJobProcessor, PluginWebhookAuth, PluginWebhookAuthGuard, RETRIEVER_STRATEGY, RequestContext, RequestContextMiddleware, RequirePermissionOperation, RerankModel, RetrieverRegistry, RetrieverStrategy, SANDBOX_PROVIDER, SANDBOX_RUNTIME_PROVIDER, SANDBOX_SHELL_TIMEOUT_LIMITS_SEC, SANDBOX_WORKSPACE_MAPPER, SKILL_SOURCE_PROVIDER, SPEECH_TO_TEXT_PERMISSION_SERVICE_TOKEN, SPEECH_TO_TEXT_SERVICE_TOKEN, SSOProviderRegistry, SSOProviderStrategyKey, SSO_BINDING_PERMISSION_SERVICE_TOKEN, SSO_PROVIDER, STRATEGY_META_KEY, SYSTEM_GLOBAL_SCOPE, SandboxProviderRegistry, SandboxProviderStrategy, SandboxRuntimeProviderRegistry, SandboxRuntimeProviderStrategy, SandboxWorkspaceMapperRegistry, SandboxWorkspaceMapperStrategy, SkillSourceProviderRegistry, SkillSourceProviderStrategy, Speech2TextChatModel, SpeechToTextModel, StrategyBus, TENANT_GLOBAL_SCOPE_PREFIX, TENANT_GLOBAL_SCOPE_SUFFIX, TEXT_SPLITTER_STRATEGY, TOOLSET_STRATEGY, TextEmbeddingModelManager, TextSplitterRegistry, TextSplitterStrategy, TextToSpeechModel, ToolsetRegistry, ToolsetStrategy, USER_PERMISSION_SERVICE_TOKEN, VECTOR_STORE_STRATEGY, VIDEO_GENERATION_PERMISSION_SERVICE_TOKEN, VIDEO_GENERATION_SERVICE_TOKEN, VIDEO_GENERATOR_FAMILIES, VIEW_EXTENSION_CACHE_SERVICE_TOKEN, VIEW_EXTENSION_PROVIDER, VectorStoreRegistry, VectorStoreStrategy, VideoGenerationModel, ViewExtensionProvider, ViewExtensionProviderRegistry, WORKFLOW_NODE_STRATEGY, WORKFLOW_TRIGGER_STRATEGY, WorkflowNodeRegistry, WorkflowNodeStrategy, WorkflowTriggerRegistry, WorkflowTriggerStrategy, WrapWorkflowNodeExecutionCommand, XPERT_AGENT_MIDDLEWARE_RUNTIME_TOKEN, XPERT_TOOL_METHOD_METADATA, XPERT_TOOL_PROVIDER, XPERT_TOOL_PROVIDER_METADATA, XPERT_TOOL_RESULT_FORMAT_VERSION, XpFileSystem, XpertServerPlugin, XpertTool, XpertToolProvider, XpertToolProviderCoordinator, XpertToolProviderRegistry, als, appendSandboxMessage, assertConnectorDefinition, buildSandboxTimeoutMessage, calcTokenUsage, calculateLLMUsagePrice, calculateModelPrice, calculateModelUsageCharge, chunkText, countTextTokens, countTokensSafe, createI18nInstance, createPluginLogger, createRuntimeCapability, defineAgentMessageType, defineChannelMessageType, defineMcpApp, defineMcpCapabilities, defineMcpPrompt, defineMcpResource, defineMcpResourceTemplate, defineXpertTool, derivePluginArtifactNamespace, describeXpertToolProvider, downloadRemoteFile, formatSandboxTimeout, getDefaultTenantId, getErrorMessage, getModelContextSize, getPermissionOperationMetadata, getPositionList, getPositionMap, getRequestContext, getRequiredPermissionOperation, getTenantGlobalScopeKey, getXpertToolMethod, isDevelopmentSandboxRuntimeEnvironment, isModelOutputValidationError, isModelUsagePricingConfig, isRemoteFile, isSandboxBackend, isSandboxManagedServiceAdapter, isSandboxServiceProxyAdapter, isSandboxTerminalAdapter, isStrategyInstance, isStructuredMessageType, isTenantGlobalScopeKey, loadYamlFile, mergeCredentials, mergeParentChildChunks, normalizeContextSize, pluginArtifactTableName, prepareToolResult, processAsyncAIGCManagedJob, renderRemoteModuleIframeHtml, renderRemoteReactIframeHtml, renderRemoteVueIframeHtml, resolveModelUsagePricingSnapshot, resolveSandboxBackend, resolveSandboxExecutionOptions, resolveSandboxManagedServiceAdapter, resolveSandboxServiceProxyAdapter, resolveSandboxTerminalAdapter, resolveStrategyMetadataTarget, resolveTenantGlobalScopeKey, resolveTokenUsage, runWithRequestContext, secondsToMilliseconds, setDefaultTenantId, sumTokenUsage, textTokenBoundaries };
6876
+ function _define_property$h(obj, key, value) {
6877
+ if (key in obj) {
6878
+ Object.defineProperty(obj, key, {
6879
+ value: value,
6880
+ enumerable: true,
6881
+ configurable: true,
6882
+ writable: true
6883
+ });
6884
+ } else {
6885
+ obj[key] = value;
6886
+ }
6887
+ return obj;
6888
+ }
6889
+ function _object_spread$h(target) {
6890
+ for(var i = 1; i < arguments.length; i++){
6891
+ var source = arguments[i] != null ? arguments[i] : {};
6892
+ var ownKeys = Object.keys(source);
6893
+ if (typeof Object.getOwnPropertySymbols === "function") {
6894
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
6895
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
6896
+ }));
6897
+ }
6898
+ ownKeys.forEach(function(key) {
6899
+ _define_property$h(target, key, source[key]);
6900
+ });
6901
+ }
6902
+ return target;
6903
+ }
6904
+ var ignoreOverride = Symbol("Let zodToJsonSchema decide on which parser to use");
6905
+ var defaultOptions = {
6906
+ name: undefined,
6907
+ $refStrategy: "root",
6908
+ basePath: [
6909
+ "#"
6910
+ ],
6911
+ effectStrategy: "input",
6912
+ pipeStrategy: "all",
6913
+ dateStrategy: "format:date-time",
6914
+ mapStrategy: "entries",
6915
+ removeAdditionalStrategy: "passthrough",
6916
+ allowedAdditionalProperties: true,
6917
+ rejectedAdditionalProperties: false,
6918
+ definitionPath: "definitions",
6919
+ target: "jsonSchema7",
6920
+ strictUnions: false,
6921
+ definitions: {},
6922
+ errorMessages: false,
6923
+ markdownDescription: false,
6924
+ patternStrategy: "escape",
6925
+ applyRegexFlags: false,
6926
+ emailStrategy: "format:email",
6927
+ base64Strategy: "contentEncoding:base64",
6928
+ nameStrategy: "ref",
6929
+ openAiAnyTypeName: "OpenAiAnyType"
6930
+ };
6931
+ var getDefaultOptions = function(options) {
6932
+ return _object_spread$h({}, defaultOptions, options);
6933
+ };
6934
+
6935
+ function _array_like_to_array$f(arr, len) {
6936
+ if (len == null || len > arr.length) len = arr.length;
6937
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
6938
+ return arr2;
6939
+ }
6940
+ function _array_with_holes(arr) {
6941
+ if (Array.isArray(arr)) return arr;
6942
+ }
6943
+ function _array_without_holes$f(arr) {
6944
+ if (Array.isArray(arr)) return _array_like_to_array$f(arr);
6945
+ }
6946
+ function _define_property$g(obj, key, value) {
6947
+ if (key in obj) {
6948
+ Object.defineProperty(obj, key, {
6949
+ value: value,
6950
+ enumerable: true,
6951
+ configurable: true,
6952
+ writable: true
6953
+ });
6954
+ } else {
6955
+ obj[key] = value;
6956
+ }
6957
+ return obj;
6958
+ }
6959
+ function _iterable_to_array$f(iter) {
6960
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
6961
+ }
6962
+ function _iterable_to_array_limit(arr, i) {
6963
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
6964
+ if (_i == null) return;
6965
+ var _arr = [];
6966
+ var _n = true;
6967
+ var _d = false;
6968
+ var _s, _e;
6969
+ try {
6970
+ for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
6971
+ _arr.push(_s.value);
6972
+ if (i && _arr.length === i) break;
6973
+ }
6974
+ } catch (err) {
6975
+ _d = true;
6976
+ _e = err;
6977
+ } finally{
6978
+ try {
6979
+ if (!_n && _i["return"] != null) _i["return"]();
6980
+ } finally{
6981
+ if (_d) throw _e;
6982
+ }
6983
+ }
6984
+ return _arr;
6985
+ }
6986
+ function _non_iterable_rest() {
6987
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
6988
+ }
6989
+ function _non_iterable_spread$f() {
6990
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
6991
+ }
6992
+ function _object_spread$g(target) {
6993
+ for(var i = 1; i < arguments.length; i++){
6994
+ var source = arguments[i] != null ? arguments[i] : {};
6995
+ var ownKeys = Object.keys(source);
6996
+ if (typeof Object.getOwnPropertySymbols === "function") {
6997
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
6998
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
6999
+ }));
7000
+ }
7001
+ ownKeys.forEach(function(key) {
7002
+ _define_property$g(target, key, source[key]);
7003
+ });
7004
+ }
7005
+ return target;
7006
+ }
7007
+ function ownKeys$f(object, enumerableOnly) {
7008
+ var keys = Object.keys(object);
7009
+ if (Object.getOwnPropertySymbols) {
7010
+ var symbols = Object.getOwnPropertySymbols(object);
7011
+ keys.push.apply(keys, symbols);
7012
+ }
7013
+ return keys;
7014
+ }
7015
+ function _object_spread_props$f(target, source) {
7016
+ source = source != null ? source : {};
7017
+ if (Object.getOwnPropertyDescriptors) {
7018
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
7019
+ } else {
7020
+ ownKeys$f(Object(source)).forEach(function(key) {
7021
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
7022
+ });
7023
+ }
7024
+ return target;
7025
+ }
7026
+ function _sliced_to_array(arr, i) {
7027
+ return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array$f(arr, i) || _non_iterable_rest();
7028
+ }
7029
+ function _to_consumable_array$f(arr) {
7030
+ return _array_without_holes$f(arr) || _iterable_to_array$f(arr) || _unsupported_iterable_to_array$f(arr) || _non_iterable_spread$f();
7031
+ }
7032
+ function _unsupported_iterable_to_array$f(o, minLen) {
7033
+ if (!o) return;
7034
+ if (typeof o === "string") return _array_like_to_array$f(o, minLen);
7035
+ var n = Object.prototype.toString.call(o).slice(8, -1);
7036
+ if (n === "Object" && o.constructor) n = o.constructor.name;
7037
+ if (n === "Map" || n === "Set") return Array.from(n);
7038
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$f(o, minLen);
7039
+ }
7040
+ var getRefs = function(options) {
7041
+ var _options = getDefaultOptions(options);
7042
+ var currentPath = _options.name !== undefined ? _to_consumable_array$f(_options.basePath).concat([
7043
+ _options.definitionPath,
7044
+ _options.name
7045
+ ]) : _options.basePath;
7046
+ return _object_spread_props$f(_object_spread$g({}, _options), {
7047
+ flags: {
7048
+ hasReferencedOpenAiAnyType: false
7049
+ },
7050
+ currentPath: currentPath,
7051
+ propertyPath: undefined,
7052
+ seen: new Map(Object.entries(_options.definitions).map(function(param) {
7053
+ var _param = _sliced_to_array(param, 2), name = _param[0], def = _param[1];
7054
+ return [
7055
+ def._def,
7056
+ {
7057
+ def: def._def,
7058
+ path: _to_consumable_array$f(_options.basePath).concat([
7059
+ _options.definitionPath,
7060
+ name
7061
+ ]),
7062
+ // Resolution of references will be forced even though seen, so it's ok that the schema is undefined here for now.
7063
+ jsonSchema: undefined
7064
+ }
7065
+ ];
7066
+ }))
7067
+ });
7068
+ };
7069
+
7070
+ function _define_property$f(obj, key, value) {
7071
+ if (key in obj) {
7072
+ Object.defineProperty(obj, key, {
7073
+ value: value,
7074
+ enumerable: true,
7075
+ configurable: true,
7076
+ writable: true
7077
+ });
7078
+ } else {
7079
+ obj[key] = value;
7080
+ }
7081
+ return obj;
7082
+ }
7083
+ function _object_spread$f(target) {
7084
+ for(var i = 1; i < arguments.length; i++){
7085
+ var source = arguments[i] != null ? arguments[i] : {};
7086
+ var ownKeys = Object.keys(source);
7087
+ if (typeof Object.getOwnPropertySymbols === "function") {
7088
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
7089
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
7090
+ }));
7091
+ }
7092
+ ownKeys.forEach(function(key) {
7093
+ _define_property$f(target, key, source[key]);
7094
+ });
7095
+ }
7096
+ return target;
7097
+ }
7098
+ function ownKeys$e(object, enumerableOnly) {
7099
+ var keys = Object.keys(object);
7100
+ if (Object.getOwnPropertySymbols) {
7101
+ var symbols = Object.getOwnPropertySymbols(object);
7102
+ keys.push.apply(keys, symbols);
7103
+ }
7104
+ return keys;
7105
+ }
7106
+ function _object_spread_props$e(target, source) {
7107
+ source = source != null ? source : {};
7108
+ if (Object.getOwnPropertyDescriptors) {
7109
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
7110
+ } else {
7111
+ ownKeys$e(Object(source)).forEach(function(key) {
7112
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
7113
+ });
7114
+ }
7115
+ return target;
7116
+ }
7117
+ function addErrorMessage(res, key, errorMessage, refs) {
7118
+ if (!(refs === null || refs === void 0 ? void 0 : refs.errorMessages)) return;
7119
+ if (errorMessage) {
7120
+ res.errorMessage = _object_spread_props$e(_object_spread$f({}, res.errorMessage), _define_property$f({}, key, errorMessage));
7121
+ }
7122
+ }
7123
+ function setResponseValueAndErrors(res, key, value, errorMessage, refs) {
7124
+ res[key] = value;
7125
+ addErrorMessage(res, key, errorMessage, refs);
7126
+ }
7127
+
7128
+ function _array_like_to_array$e(arr, len) {
7129
+ if (len == null || len > arr.length) len = arr.length;
7130
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
7131
+ return arr2;
7132
+ }
7133
+ function _array_without_holes$e(arr) {
7134
+ if (Array.isArray(arr)) return _array_like_to_array$e(arr);
7135
+ }
7136
+ function _iterable_to_array$e(iter) {
7137
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
7138
+ }
7139
+ function _non_iterable_spread$e() {
7140
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
7141
+ }
7142
+ function _to_consumable_array$e(arr) {
7143
+ return _array_without_holes$e(arr) || _iterable_to_array$e(arr) || _unsupported_iterable_to_array$e(arr) || _non_iterable_spread$e();
7144
+ }
7145
+ function _unsupported_iterable_to_array$e(o, minLen) {
7146
+ if (!o) return;
7147
+ if (typeof o === "string") return _array_like_to_array$e(o, minLen);
7148
+ var n = Object.prototype.toString.call(o).slice(8, -1);
7149
+ if (n === "Object" && o.constructor) n = o.constructor.name;
7150
+ if (n === "Map" || n === "Set") return Array.from(n);
7151
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$e(o, minLen);
7152
+ }
7153
+ var getRelativePath = function(pathA, pathB) {
7154
+ var i = 0;
7155
+ for(; i < pathA.length && i < pathB.length; i++){
7156
+ if (pathA[i] !== pathB[i]) break;
7157
+ }
7158
+ return [
7159
+ (pathA.length - i).toString()
7160
+ ].concat(_to_consumable_array$e(pathB.slice(i))).join("/");
7161
+ };
7162
+
7163
+ function _array_like_to_array$d(arr, len) {
7164
+ if (len == null || len > arr.length) len = arr.length;
7165
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
7166
+ return arr2;
7167
+ }
7168
+ function _array_without_holes$d(arr) {
7169
+ if (Array.isArray(arr)) return _array_like_to_array$d(arr);
7170
+ }
7171
+ function _iterable_to_array$d(iter) {
7172
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
7173
+ }
7174
+ function _non_iterable_spread$d() {
7175
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
7176
+ }
7177
+ function _to_consumable_array$d(arr) {
7178
+ return _array_without_holes$d(arr) || _iterable_to_array$d(arr) || _unsupported_iterable_to_array$d(arr) || _non_iterable_spread$d();
7179
+ }
7180
+ function _unsupported_iterable_to_array$d(o, minLen) {
7181
+ if (!o) return;
7182
+ if (typeof o === "string") return _array_like_to_array$d(o, minLen);
7183
+ var n = Object.prototype.toString.call(o).slice(8, -1);
7184
+ if (n === "Object" && o.constructor) n = o.constructor.name;
7185
+ if (n === "Map" || n === "Set") return Array.from(n);
7186
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$d(o, minLen);
7187
+ }
7188
+ function parseAnyDef(refs) {
7189
+ if (refs.target !== "openAi") {
7190
+ return {};
7191
+ }
7192
+ var anyDefinitionPath = _to_consumable_array$d(refs.basePath).concat([
7193
+ refs.definitionPath,
7194
+ refs.openAiAnyTypeName
7195
+ ]);
7196
+ refs.flags.hasReferencedOpenAiAnyType = true;
7197
+ return {
7198
+ $ref: refs.$refStrategy === "relative" ? getRelativePath(anyDefinitionPath, refs.currentPath) : anyDefinitionPath.join("/")
7199
+ };
7200
+ }
7201
+
7202
+ function _array_like_to_array$c(arr, len) {
7203
+ if (len == null || len > arr.length) len = arr.length;
7204
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
7205
+ return arr2;
7206
+ }
7207
+ function _array_without_holes$c(arr) {
7208
+ if (Array.isArray(arr)) return _array_like_to_array$c(arr);
7209
+ }
7210
+ function _define_property$e(obj, key, value) {
7211
+ if (key in obj) {
7212
+ Object.defineProperty(obj, key, {
7213
+ value: value,
7214
+ enumerable: true,
7215
+ configurable: true,
7216
+ writable: true
7217
+ });
7218
+ } else {
7219
+ obj[key] = value;
7220
+ }
7221
+ return obj;
7222
+ }
7223
+ function _iterable_to_array$c(iter) {
7224
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
7225
+ }
7226
+ function _non_iterable_spread$c() {
7227
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
7228
+ }
7229
+ function _object_spread$e(target) {
7230
+ for(var i = 1; i < arguments.length; i++){
7231
+ var source = arguments[i] != null ? arguments[i] : {};
7232
+ var ownKeys = Object.keys(source);
7233
+ if (typeof Object.getOwnPropertySymbols === "function") {
7234
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
7235
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
7236
+ }));
7237
+ }
7238
+ ownKeys.forEach(function(key) {
7239
+ _define_property$e(target, key, source[key]);
7240
+ });
7241
+ }
7242
+ return target;
7243
+ }
7244
+ function ownKeys$d(object, enumerableOnly) {
7245
+ var keys = Object.keys(object);
7246
+ if (Object.getOwnPropertySymbols) {
7247
+ var symbols = Object.getOwnPropertySymbols(object);
7248
+ keys.push.apply(keys, symbols);
7249
+ }
7250
+ return keys;
7251
+ }
7252
+ function _object_spread_props$d(target, source) {
7253
+ source = source != null ? source : {};
7254
+ if (Object.getOwnPropertyDescriptors) {
7255
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
7256
+ } else {
7257
+ ownKeys$d(Object(source)).forEach(function(key) {
7258
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
7259
+ });
7260
+ }
7261
+ return target;
7262
+ }
7263
+ function _to_consumable_array$c(arr) {
7264
+ return _array_without_holes$c(arr) || _iterable_to_array$c(arr) || _unsupported_iterable_to_array$c(arr) || _non_iterable_spread$c();
7265
+ }
7266
+ function _unsupported_iterable_to_array$c(o, minLen) {
7267
+ if (!o) return;
7268
+ if (typeof o === "string") return _array_like_to_array$c(o, minLen);
7269
+ var n = Object.prototype.toString.call(o).slice(8, -1);
7270
+ if (n === "Object" && o.constructor) n = o.constructor.name;
7271
+ if (n === "Map" || n === "Set") return Array.from(n);
7272
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$c(o, minLen);
7273
+ }
7274
+ function parseArrayDef(def, refs) {
7275
+ var _def_type, _def_type__def, _def_type1;
7276
+ var res = {
7277
+ type: "array"
7278
+ };
7279
+ if (((_def_type = def.type) === null || _def_type === void 0 ? void 0 : _def_type._def) && ((_def_type1 = def.type) === null || _def_type1 === void 0 ? void 0 : (_def_type__def = _def_type1._def) === null || _def_type__def === void 0 ? void 0 : _def_type__def.typeName) !== ZodFirstPartyTypeKind.ZodAny) {
7280
+ res.items = parseDef(def.type._def, _object_spread_props$d(_object_spread$e({}, refs), {
7281
+ currentPath: _to_consumable_array$c(refs.currentPath).concat([
7282
+ "items"
7283
+ ])
7284
+ }));
7285
+ }
7286
+ if (def.minLength) {
7287
+ setResponseValueAndErrors(res, "minItems", def.minLength.value, def.minLength.message, refs);
7288
+ }
7289
+ if (def.maxLength) {
7290
+ setResponseValueAndErrors(res, "maxItems", def.maxLength.value, def.maxLength.message, refs);
7291
+ }
7292
+ if (def.exactLength) {
7293
+ setResponseValueAndErrors(res, "minItems", def.exactLength.value, def.exactLength.message, refs);
7294
+ setResponseValueAndErrors(res, "maxItems", def.exactLength.value, def.exactLength.message, refs);
7295
+ }
7296
+ return res;
7297
+ }
7298
+
7299
+ function parseBigintDef(def, refs) {
7300
+ var res = {
7301
+ type: "integer",
7302
+ format: "int64"
7303
+ };
7304
+ if (!def.checks) return res;
7305
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
7306
+ try {
7307
+ for(var _iterator = def.checks[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
7308
+ var check = _step.value;
7309
+ switch(check.kind){
7310
+ case "min":
7311
+ if (refs.target === "jsonSchema7") {
7312
+ if (check.inclusive) {
7313
+ setResponseValueAndErrors(res, "minimum", check.value, check.message, refs);
7314
+ } else {
7315
+ setResponseValueAndErrors(res, "exclusiveMinimum", check.value, check.message, refs);
7316
+ }
7317
+ } else {
7318
+ if (!check.inclusive) {
7319
+ res.exclusiveMinimum = true;
7320
+ }
7321
+ setResponseValueAndErrors(res, "minimum", check.value, check.message, refs);
7322
+ }
7323
+ break;
7324
+ case "max":
7325
+ if (refs.target === "jsonSchema7") {
7326
+ if (check.inclusive) {
7327
+ setResponseValueAndErrors(res, "maximum", check.value, check.message, refs);
7328
+ } else {
7329
+ setResponseValueAndErrors(res, "exclusiveMaximum", check.value, check.message, refs);
7330
+ }
7331
+ } else {
7332
+ if (!check.inclusive) {
7333
+ res.exclusiveMaximum = true;
7334
+ }
7335
+ setResponseValueAndErrors(res, "maximum", check.value, check.message, refs);
7336
+ }
7337
+ break;
7338
+ case "multipleOf":
7339
+ setResponseValueAndErrors(res, "multipleOf", check.value, check.message, refs);
7340
+ break;
7341
+ }
7342
+ }
7343
+ } catch (err) {
7344
+ _didIteratorError = true;
7345
+ _iteratorError = err;
7346
+ } finally{
7347
+ try {
7348
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
7349
+ _iterator.return();
7350
+ }
7351
+ } finally{
7352
+ if (_didIteratorError) {
7353
+ throw _iteratorError;
7354
+ }
7355
+ }
7356
+ }
7357
+ return res;
7358
+ }
7359
+
7360
+ function parseBooleanDef() {
7361
+ return {
7362
+ type: "boolean"
7363
+ };
7364
+ }
7365
+
7366
+ function parseBrandedDef(_def, refs) {
7367
+ return parseDef(_def.type._def, refs);
7368
+ }
7369
+
7370
+ var parseCatchDef = function(def, refs) {
7371
+ return parseDef(def.innerType._def, refs);
7372
+ };
7373
+
7374
+ function parseDateDef(def, refs, overrideDateStrategy) {
7375
+ var strategy = overrideDateStrategy !== null && overrideDateStrategy !== void 0 ? overrideDateStrategy : refs.dateStrategy;
7376
+ if (Array.isArray(strategy)) {
7377
+ return {
7378
+ anyOf: strategy.map(function(item, i) {
7379
+ return parseDateDef(def, refs, item);
7380
+ })
7381
+ };
7382
+ }
7383
+ switch(strategy){
7384
+ case "string":
7385
+ case "format:date-time":
7386
+ return {
7387
+ type: "string",
7388
+ format: "date-time"
7389
+ };
7390
+ case "format:date":
7391
+ return {
7392
+ type: "string",
7393
+ format: "date"
7394
+ };
7395
+ case "integer":
7396
+ return integerDateParser(def, refs);
7397
+ }
7398
+ }
7399
+ var integerDateParser = function(def, refs) {
7400
+ var res = {
7401
+ type: "integer",
7402
+ format: "unix-time"
7403
+ };
7404
+ if (refs.target === "openApi3") {
7405
+ return res;
7406
+ }
7407
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
7408
+ try {
7409
+ for(var _iterator = def.checks[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
7410
+ var check = _step.value;
7411
+ switch(check.kind){
7412
+ case "min":
7413
+ setResponseValueAndErrors(res, "minimum", check.value, check.message, refs);
7414
+ break;
7415
+ case "max":
7416
+ setResponseValueAndErrors(res, "maximum", check.value, check.message, refs);
7417
+ break;
7418
+ }
7419
+ }
7420
+ } catch (err) {
7421
+ _didIteratorError = true;
7422
+ _iteratorError = err;
7423
+ } finally{
7424
+ try {
7425
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
7426
+ _iterator.return();
7427
+ }
7428
+ } finally{
7429
+ if (_didIteratorError) {
7430
+ throw _iteratorError;
7431
+ }
7432
+ }
7433
+ }
7434
+ return res;
7435
+ };
7436
+
7437
+ function _define_property$d(obj, key, value) {
7438
+ if (key in obj) {
7439
+ Object.defineProperty(obj, key, {
7440
+ value: value,
7441
+ enumerable: true,
7442
+ configurable: true,
7443
+ writable: true
7444
+ });
7445
+ } else {
7446
+ obj[key] = value;
7447
+ }
7448
+ return obj;
7449
+ }
7450
+ function _object_spread$d(target) {
7451
+ for(var i = 1; i < arguments.length; i++){
7452
+ var source = arguments[i] != null ? arguments[i] : {};
7453
+ var ownKeys = Object.keys(source);
7454
+ if (typeof Object.getOwnPropertySymbols === "function") {
7455
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
7456
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
7457
+ }));
7458
+ }
7459
+ ownKeys.forEach(function(key) {
7460
+ _define_property$d(target, key, source[key]);
7461
+ });
7462
+ }
7463
+ return target;
7464
+ }
7465
+ function ownKeys$c(object, enumerableOnly) {
7466
+ var keys = Object.keys(object);
7467
+ if (Object.getOwnPropertySymbols) {
7468
+ var symbols = Object.getOwnPropertySymbols(object);
7469
+ keys.push.apply(keys, symbols);
7470
+ }
7471
+ return keys;
7472
+ }
7473
+ function _object_spread_props$c(target, source) {
7474
+ source = source != null ? source : {};
7475
+ if (Object.getOwnPropertyDescriptors) {
7476
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
7477
+ } else {
7478
+ ownKeys$c(Object(source)).forEach(function(key) {
7479
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
7480
+ });
7481
+ }
7482
+ return target;
7483
+ }
7484
+ function parseDefaultDef(_def, refs) {
7485
+ return _object_spread_props$c(_object_spread$d({}, parseDef(_def.innerType._def, refs)), {
7486
+ default: _def.defaultValue()
7487
+ });
7488
+ }
7489
+
7490
+ function parseEffectsDef(_def, refs) {
7491
+ return refs.effectStrategy === "input" ? parseDef(_def.schema._def, refs) : parseAnyDef(refs);
7492
+ }
7493
+
7494
+ function parseEnumDef(def) {
7495
+ return {
7496
+ type: "string",
7497
+ enum: Array.from(def.values)
7498
+ };
7499
+ }
7500
+
7501
+ function _array_like_to_array$b(arr, len) {
7502
+ if (len == null || len > arr.length) len = arr.length;
7503
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
7504
+ return arr2;
7505
+ }
7506
+ function _array_without_holes$b(arr) {
7507
+ if (Array.isArray(arr)) return _array_like_to_array$b(arr);
7508
+ }
7509
+ function _define_property$c(obj, key, value) {
7510
+ if (key in obj) {
7511
+ Object.defineProperty(obj, key, {
7512
+ value: value,
7513
+ enumerable: true,
7514
+ configurable: true,
7515
+ writable: true
7516
+ });
7517
+ } else {
7518
+ obj[key] = value;
7519
+ }
7520
+ return obj;
7521
+ }
7522
+ function _iterable_to_array$b(iter) {
7523
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
7524
+ }
7525
+ function _non_iterable_spread$b() {
7526
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
7527
+ }
7528
+ function _object_spread$c(target) {
7529
+ for(var i = 1; i < arguments.length; i++){
7530
+ var source = arguments[i] != null ? arguments[i] : {};
7531
+ var ownKeys = Object.keys(source);
7532
+ if (typeof Object.getOwnPropertySymbols === "function") {
7533
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
7534
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
7535
+ }));
7536
+ }
7537
+ ownKeys.forEach(function(key) {
7538
+ _define_property$c(target, key, source[key]);
7539
+ });
7540
+ }
7541
+ return target;
7542
+ }
7543
+ function ownKeys$b(object, enumerableOnly) {
7544
+ var keys = Object.keys(object);
7545
+ if (Object.getOwnPropertySymbols) {
7546
+ var symbols = Object.getOwnPropertySymbols(object);
7547
+ keys.push.apply(keys, symbols);
7548
+ }
7549
+ return keys;
7550
+ }
7551
+ function _object_spread_props$b(target, source) {
7552
+ source = source != null ? source : {};
7553
+ if (Object.getOwnPropertyDescriptors) {
7554
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
7555
+ } else {
7556
+ ownKeys$b(Object(source)).forEach(function(key) {
7557
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
7558
+ });
7559
+ }
7560
+ return target;
7561
+ }
7562
+ function _object_without_properties$1(source, excluded) {
7563
+ if (source == null) return {};
7564
+ var target = _object_without_properties_loose$1(source, excluded);
7565
+ var key, i;
7566
+ if (Object.getOwnPropertySymbols) {
7567
+ var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
7568
+ for(i = 0; i < sourceSymbolKeys.length; i++){
7569
+ key = sourceSymbolKeys[i];
7570
+ if (excluded.indexOf(key) >= 0) continue;
7571
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
7572
+ target[key] = source[key];
7573
+ }
7574
+ }
7575
+ return target;
7576
+ }
7577
+ function _object_without_properties_loose$1(source, excluded) {
7578
+ if (source == null) return {};
7579
+ var target = {};
7580
+ var sourceKeys = Object.keys(source);
7581
+ var key, i;
7582
+ for(i = 0; i < sourceKeys.length; i++){
7583
+ key = sourceKeys[i];
7584
+ if (excluded.indexOf(key) >= 0) continue;
7585
+ target[key] = source[key];
7586
+ }
7587
+ return target;
7588
+ }
7589
+ function _to_consumable_array$b(arr) {
7590
+ return _array_without_holes$b(arr) || _iterable_to_array$b(arr) || _unsupported_iterable_to_array$b(arr) || _non_iterable_spread$b();
7591
+ }
7592
+ function _unsupported_iterable_to_array$b(o, minLen) {
7593
+ if (!o) return;
7594
+ if (typeof o === "string") return _array_like_to_array$b(o, minLen);
7595
+ var n = Object.prototype.toString.call(o).slice(8, -1);
7596
+ if (n === "Object" && o.constructor) n = o.constructor.name;
7597
+ if (n === "Map" || n === "Set") return Array.from(n);
7598
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$b(o, minLen);
7599
+ }
7600
+ var isJsonSchema7AllOfType = function(type) {
7601
+ if ("type" in type && type.type === "string") return false;
7602
+ return "allOf" in type;
7603
+ };
7604
+ function parseIntersectionDef(def, refs) {
7605
+ var allOf = [
7606
+ parseDef(def.left._def, _object_spread_props$b(_object_spread$c({}, refs), {
7607
+ currentPath: _to_consumable_array$b(refs.currentPath).concat([
7608
+ "allOf",
7609
+ "0"
7610
+ ])
7611
+ })),
7612
+ parseDef(def.right._def, _object_spread_props$b(_object_spread$c({}, refs), {
7613
+ currentPath: _to_consumable_array$b(refs.currentPath).concat([
7614
+ "allOf",
7615
+ "1"
7616
+ ])
7617
+ }))
7618
+ ].filter(function(x) {
7619
+ return !!x;
7620
+ });
7621
+ var unevaluatedProperties = refs.target === "jsonSchema2019-09" ? {
7622
+ unevaluatedProperties: false
7623
+ } : undefined;
7624
+ var mergedAllOf = [];
7625
+ // If either of the schemas is an allOf, merge them into a single allOf
7626
+ allOf.forEach(function(schema) {
7627
+ if (isJsonSchema7AllOfType(schema)) {
7628
+ var _mergedAllOf;
7629
+ (_mergedAllOf = mergedAllOf).push.apply(_mergedAllOf, _to_consumable_array$b(schema.allOf));
7630
+ if (schema.unevaluatedProperties === undefined) {
7631
+ // If one of the schemas has no unevaluatedProperties set,
7632
+ // the merged schema should also have no unevaluatedProperties set
7633
+ unevaluatedProperties = undefined;
7634
+ }
7635
+ } else {
7636
+ var nestedSchema = schema;
7637
+ if ("additionalProperties" in schema && schema.additionalProperties === false) {
7638
+ schema.additionalProperties; var rest = _object_without_properties$1(schema, [
7639
+ "additionalProperties"
7640
+ ]);
7641
+ nestedSchema = rest;
7642
+ } else {
7643
+ // As soon as one of the schemas has additionalProperties set not to false, we allow unevaluatedProperties
7644
+ unevaluatedProperties = undefined;
7645
+ }
7646
+ mergedAllOf.push(nestedSchema);
7647
+ }
7648
+ });
7649
+ return mergedAllOf.length ? _object_spread$c({
7650
+ allOf: mergedAllOf
7651
+ }, unevaluatedProperties) : undefined;
7652
+ }
7653
+
7654
+ function _type_of$2(obj) {
7655
+ "@swc/helpers - typeof";
7656
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
7657
+ }
7658
+ function parseLiteralDef(def, refs) {
7659
+ var parsedType = _type_of$2(def.value);
7660
+ if (parsedType !== "bigint" && parsedType !== "number" && parsedType !== "boolean" && parsedType !== "string") {
7661
+ return {
7662
+ type: Array.isArray(def.value) ? "array" : "object"
7663
+ };
7664
+ }
7665
+ if (refs.target === "openApi3") {
7666
+ return {
7667
+ type: parsedType === "bigint" ? "integer" : parsedType,
7668
+ enum: [
7669
+ def.value
7670
+ ]
7671
+ };
7672
+ }
7673
+ return {
7674
+ type: parsedType === "bigint" ? "integer" : parsedType,
7675
+ const: def.value
7676
+ };
7677
+ }
7678
+
7679
+ function _define_property$b(obj, key, value) {
7680
+ if (key in obj) {
7681
+ Object.defineProperty(obj, key, {
7682
+ value: value,
7683
+ enumerable: true,
7684
+ configurable: true,
7685
+ writable: true
7686
+ });
7687
+ } else {
7688
+ obj[key] = value;
7689
+ }
7690
+ return obj;
7691
+ }
7692
+ function _object_spread$b(target) {
7693
+ for(var i = 1; i < arguments.length; i++){
7694
+ var source = arguments[i] != null ? arguments[i] : {};
7695
+ var ownKeys = Object.keys(source);
7696
+ if (typeof Object.getOwnPropertySymbols === "function") {
7697
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
7698
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
7699
+ }));
7700
+ }
7701
+ ownKeys.forEach(function(key) {
7702
+ _define_property$b(target, key, source[key]);
7703
+ });
7704
+ }
7705
+ return target;
7706
+ }
7707
+ var emojiRegex = undefined;
7708
+ /**
7709
+ * Generated from the regular expressions found here as of 2024-05-22:
7710
+ * https://github.com/colinhacks/zod/blob/master/src/types.ts.
7711
+ *
7712
+ * Expressions with /i flag have been changed accordingly.
7713
+ */ var zodPatterns = {
7714
+ /**
7715
+ * `c` was changed to `[cC]` to replicate /i flag
7716
+ */ cuid: /^[cC][^\s-]{8,}$/,
7717
+ cuid2: /^[0-9a-z]+$/,
7718
+ ulid: /^[0-9A-HJKMNP-TV-Z]{26}$/,
7719
+ /**
7720
+ * `a-z` was added to replicate /i flag
7721
+ */ email: /^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,
7722
+ /**
7723
+ * Constructed a valid Unicode RegExp
7724
+ *
7725
+ * Lazily instantiate since this type of regex isn't supported
7726
+ * in all envs (e.g. React Native).
7727
+ *
7728
+ * See:
7729
+ * https://github.com/colinhacks/zod/issues/2433
7730
+ * Fix in Zod:
7731
+ * https://github.com/colinhacks/zod/commit/9340fd51e48576a75adc919bff65dbc4a5d4c99b
7732
+ */ emoji: function() {
7733
+ if (emojiRegex === undefined) {
7734
+ emojiRegex = RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$", "u");
7735
+ }
7736
+ return emojiRegex;
7737
+ },
7738
+ /**
7739
+ * Unused
7740
+ */ uuid: /^[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}$/,
7741
+ /**
7742
+ * Unused
7743
+ */ ipv4: /^(?:(?: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])$/,
7744
+ ipv4Cidr: /^(?:(?: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])$/,
7745
+ /**
7746
+ * Unused
7747
+ */ ipv6: /^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,
7748
+ ipv6Cidr: /^(([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])$/,
7749
+ base64: /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,
7750
+ base64url: /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,
7751
+ nanoid: /^[a-zA-Z0-9_-]{21}$/,
7752
+ jwt: /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/
7753
+ };
7754
+ function parseStringDef(def, refs) {
7755
+ var res = {
7756
+ type: "string"
7757
+ };
7758
+ if (def.checks) {
7759
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
7760
+ try {
7761
+ for(var _iterator = def.checks[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
7762
+ var check = _step.value;
7763
+ switch(check.kind){
7764
+ case "min":
7765
+ setResponseValueAndErrors(res, "minLength", typeof res.minLength === "number" ? Math.max(res.minLength, check.value) : check.value, check.message, refs);
7766
+ break;
7767
+ case "max":
7768
+ setResponseValueAndErrors(res, "maxLength", typeof res.maxLength === "number" ? Math.min(res.maxLength, check.value) : check.value, check.message, refs);
7769
+ break;
7770
+ case "email":
7771
+ switch(refs.emailStrategy){
7772
+ case "format:email":
7773
+ addFormat(res, "email", check.message, refs);
7774
+ break;
7775
+ case "format:idn-email":
7776
+ addFormat(res, "idn-email", check.message, refs);
7777
+ break;
7778
+ case "pattern:zod":
7779
+ addPattern(res, zodPatterns.email, check.message, refs);
7780
+ break;
7781
+ }
7782
+ break;
7783
+ case "url":
7784
+ addFormat(res, "uri", check.message, refs);
7785
+ break;
7786
+ case "uuid":
7787
+ addFormat(res, "uuid", check.message, refs);
7788
+ break;
7789
+ case "regex":
7790
+ addPattern(res, check.regex, check.message, refs);
7791
+ break;
7792
+ case "cuid":
7793
+ addPattern(res, zodPatterns.cuid, check.message, refs);
7794
+ break;
7795
+ case "cuid2":
7796
+ addPattern(res, zodPatterns.cuid2, check.message, refs);
7797
+ break;
7798
+ case "startsWith":
7799
+ addPattern(res, RegExp("^".concat(escapeLiteralCheckValue(check.value, refs))), check.message, refs);
7800
+ break;
7801
+ case "endsWith":
7802
+ addPattern(res, RegExp("".concat(escapeLiteralCheckValue(check.value, refs), "$")), check.message, refs);
7803
+ break;
7804
+ case "datetime":
7805
+ addFormat(res, "date-time", check.message, refs);
7806
+ break;
7807
+ case "date":
7808
+ addFormat(res, "date", check.message, refs);
7809
+ break;
7810
+ case "time":
7811
+ addFormat(res, "time", check.message, refs);
7812
+ break;
7813
+ case "duration":
7814
+ addFormat(res, "duration", check.message, refs);
7815
+ break;
7816
+ case "length":
7817
+ setResponseValueAndErrors(res, "minLength", typeof res.minLength === "number" ? Math.max(res.minLength, check.value) : check.value, check.message, refs);
7818
+ setResponseValueAndErrors(res, "maxLength", typeof res.maxLength === "number" ? Math.min(res.maxLength, check.value) : check.value, check.message, refs);
7819
+ break;
7820
+ case "includes":
7821
+ {
7822
+ addPattern(res, RegExp(escapeLiteralCheckValue(check.value, refs)), check.message, refs);
7823
+ break;
7824
+ }
7825
+ case "ip":
7826
+ {
7827
+ if (check.version !== "v6") {
7828
+ addFormat(res, "ipv4", check.message, refs);
7829
+ }
7830
+ if (check.version !== "v4") {
7831
+ addFormat(res, "ipv6", check.message, refs);
7832
+ }
7833
+ break;
7834
+ }
7835
+ case "base64url":
7836
+ addPattern(res, zodPatterns.base64url, check.message, refs);
7837
+ break;
7838
+ case "jwt":
7839
+ addPattern(res, zodPatterns.jwt, check.message, refs);
7840
+ break;
7841
+ case "cidr":
7842
+ {
7843
+ if (check.version !== "v6") {
7844
+ addPattern(res, zodPatterns.ipv4Cidr, check.message, refs);
7845
+ }
7846
+ if (check.version !== "v4") {
7847
+ addPattern(res, zodPatterns.ipv6Cidr, check.message, refs);
7848
+ }
7849
+ break;
7850
+ }
7851
+ case "emoji":
7852
+ addPattern(res, zodPatterns.emoji(), check.message, refs);
7853
+ break;
7854
+ case "ulid":
7855
+ {
7856
+ addPattern(res, zodPatterns.ulid, check.message, refs);
7857
+ break;
7858
+ }
7859
+ case "base64":
7860
+ {
7861
+ switch(refs.base64Strategy){
7862
+ case "format:binary":
7863
+ {
7864
+ addFormat(res, "binary", check.message, refs);
7865
+ break;
7866
+ }
7867
+ case "contentEncoding:base64":
7868
+ {
7869
+ setResponseValueAndErrors(res, "contentEncoding", "base64", check.message, refs);
7870
+ break;
7871
+ }
7872
+ case "pattern:zod":
7873
+ {
7874
+ addPattern(res, zodPatterns.base64, check.message, refs);
7875
+ break;
7876
+ }
7877
+ }
7878
+ break;
7879
+ }
7880
+ case "nanoid":
7881
+ {
7882
+ addPattern(res, zodPatterns.nanoid, check.message, refs);
7883
+ }
7884
+ case "toLowerCase":
7885
+ case "toUpperCase":
7886
+ case "trim":
7887
+ break;
7888
+ default:
7889
+ (function(_) {})(check);
7890
+ }
7891
+ }
7892
+ } catch (err) {
7893
+ _didIteratorError = true;
7894
+ _iteratorError = err;
7895
+ } finally{
7896
+ try {
7897
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
7898
+ _iterator.return();
7899
+ }
7900
+ } finally{
7901
+ if (_didIteratorError) {
7902
+ throw _iteratorError;
7903
+ }
7904
+ }
7905
+ }
7906
+ }
7907
+ return res;
7908
+ }
7909
+ function escapeLiteralCheckValue(literal, refs) {
7910
+ return refs.patternStrategy === "escape" ? escapeNonAlphaNumeric(literal) : literal;
7911
+ }
7912
+ var ALPHA_NUMERIC = new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");
7913
+ function escapeNonAlphaNumeric(source) {
7914
+ var result = "";
7915
+ for(var i = 0; i < source.length; i++){
7916
+ if (!ALPHA_NUMERIC.has(source[i])) {
7917
+ result += "\\";
7918
+ }
7919
+ result += source[i];
7920
+ }
7921
+ return result;
7922
+ }
7923
+ // Adds a "format" keyword to the schema. If a format exists, both formats will be joined in an allOf-node, along with subsequent ones.
7924
+ function addFormat(schema, value, message, refs) {
7925
+ var _schema_anyOf;
7926
+ if (schema.format || ((_schema_anyOf = schema.anyOf) === null || _schema_anyOf === void 0 ? void 0 : _schema_anyOf.some(function(x) {
7927
+ return x.format;
7928
+ }))) {
7929
+ if (!schema.anyOf) {
7930
+ schema.anyOf = [];
7931
+ }
7932
+ if (schema.format) {
7933
+ schema.anyOf.push(_object_spread$b({
7934
+ format: schema.format
7935
+ }, schema.errorMessage && refs.errorMessages && {
7936
+ errorMessage: {
7937
+ format: schema.errorMessage.format
7938
+ }
7939
+ }));
7940
+ delete schema.format;
7941
+ if (schema.errorMessage) {
7942
+ delete schema.errorMessage.format;
7943
+ if (Object.keys(schema.errorMessage).length === 0) {
7944
+ delete schema.errorMessage;
7945
+ }
7946
+ }
7947
+ }
7948
+ schema.anyOf.push(_object_spread$b({
7949
+ format: value
7950
+ }, message && refs.errorMessages && {
7951
+ errorMessage: {
7952
+ format: message
7953
+ }
7954
+ }));
7955
+ } else {
7956
+ setResponseValueAndErrors(schema, "format", value, message, refs);
7957
+ }
7958
+ }
7959
+ // Adds a "pattern" keyword to the schema. If a pattern exists, both patterns will be joined in an allOf-node, along with subsequent ones.
7960
+ function addPattern(schema, regex, message, refs) {
7961
+ var _schema_allOf;
7962
+ if (schema.pattern || ((_schema_allOf = schema.allOf) === null || _schema_allOf === void 0 ? void 0 : _schema_allOf.some(function(x) {
7963
+ return x.pattern;
7964
+ }))) {
7965
+ if (!schema.allOf) {
7966
+ schema.allOf = [];
7967
+ }
7968
+ if (schema.pattern) {
7969
+ schema.allOf.push(_object_spread$b({
7970
+ pattern: schema.pattern
7971
+ }, schema.errorMessage && refs.errorMessages && {
7972
+ errorMessage: {
7973
+ pattern: schema.errorMessage.pattern
7974
+ }
7975
+ }));
7976
+ delete schema.pattern;
7977
+ if (schema.errorMessage) {
7978
+ delete schema.errorMessage.pattern;
7979
+ if (Object.keys(schema.errorMessage).length === 0) {
7980
+ delete schema.errorMessage;
7981
+ }
7982
+ }
7983
+ }
7984
+ schema.allOf.push(_object_spread$b({
7985
+ pattern: stringifyRegExpWithFlags(regex, refs)
7986
+ }, message && refs.errorMessages && {
7987
+ errorMessage: {
7988
+ pattern: message
7989
+ }
7990
+ }));
7991
+ } else {
7992
+ setResponseValueAndErrors(schema, "pattern", stringifyRegExpWithFlags(regex, refs), message, refs);
7993
+ }
7994
+ }
7995
+ // Mutate z.string.regex() in a best attempt to accommodate for regex flags when applyRegexFlags is true
7996
+ function stringifyRegExpWithFlags(regex, refs) {
7997
+ if (!refs.applyRegexFlags || !regex.flags) {
7998
+ return regex.source;
7999
+ }
8000
+ // Currently handled flags
8001
+ var flags = {
8002
+ i: regex.flags.includes("i"),
8003
+ m: regex.flags.includes("m"),
8004
+ s: regex.flags.includes("s")
8005
+ };
8006
+ // The general principle here is to step through each character, one at a time, applying mutations as flags require. We keep track when the current character is escaped, and when it's inside a group /like [this]/ or (also) a range like /[a-z]/. The following is fairly brittle imperative code; edit at your peril!
8007
+ var source = flags.i ? regex.source.toLowerCase() : regex.source;
8008
+ var pattern = "";
8009
+ var isEscaped = false;
8010
+ var inCharGroup = false;
8011
+ var inCharRange = false;
8012
+ for(var i = 0; i < source.length; i++){
8013
+ if (isEscaped) {
8014
+ pattern += source[i];
8015
+ isEscaped = false;
8016
+ continue;
8017
+ }
8018
+ if (flags.i) {
8019
+ if (inCharGroup) {
8020
+ if (source[i].match(/[a-z]/)) {
8021
+ var _source_;
8022
+ if (inCharRange) {
8023
+ pattern += source[i];
8024
+ pattern += "".concat(source[i - 2], "-").concat(source[i]).toUpperCase();
8025
+ inCharRange = false;
8026
+ } else if (source[i + 1] === "-" && ((_source_ = source[i + 2]) === null || _source_ === void 0 ? void 0 : _source_.match(/[a-z]/))) {
8027
+ pattern += source[i];
8028
+ inCharRange = true;
8029
+ } else {
8030
+ pattern += "".concat(source[i]).concat(source[i].toUpperCase());
8031
+ }
8032
+ continue;
8033
+ }
8034
+ } else if (source[i].match(/[a-z]/)) {
8035
+ pattern += "[".concat(source[i]).concat(source[i].toUpperCase(), "]");
8036
+ continue;
8037
+ }
8038
+ }
8039
+ if (flags.m) {
8040
+ if (source[i] === "^") {
8041
+ pattern += "(^|(?<=[\r\n]))";
8042
+ continue;
8043
+ } else if (source[i] === "$") {
8044
+ pattern += "($|(?=[\r\n]))";
8045
+ continue;
8046
+ }
8047
+ }
8048
+ if (flags.s && source[i] === ".") {
8049
+ pattern += inCharGroup ? "".concat(source[i], "\r\n") : "[".concat(source[i], "\r\n]");
8050
+ continue;
8051
+ }
8052
+ pattern += source[i];
8053
+ if (source[i] === "\\") {
8054
+ isEscaped = true;
8055
+ } else if (inCharGroup && source[i] === "]") {
8056
+ inCharGroup = false;
8057
+ } else if (!inCharGroup && source[i] === "[") {
8058
+ inCharGroup = true;
8059
+ }
8060
+ }
8061
+ try {
8062
+ new RegExp(pattern);
8063
+ } catch (e) {
8064
+ console.warn("Could not convert regex pattern at ".concat(refs.currentPath.join("/"), " to a flag-independent form! Falling back to the flag-ignorant source"));
8065
+ return regex.source;
8066
+ }
8067
+ return pattern;
8068
+ }
8069
+
8070
+ function _array_like_to_array$a(arr, len) {
8071
+ if (len == null || len > arr.length) len = arr.length;
8072
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
8073
+ return arr2;
8074
+ }
8075
+ function _array_without_holes$a(arr) {
8076
+ if (Array.isArray(arr)) return _array_like_to_array$a(arr);
8077
+ }
8078
+ function _define_property$a(obj, key, value) {
8079
+ if (key in obj) {
8080
+ Object.defineProperty(obj, key, {
8081
+ value: value,
8082
+ enumerable: true,
8083
+ configurable: true,
8084
+ writable: true
8085
+ });
8086
+ } else {
8087
+ obj[key] = value;
8088
+ }
8089
+ return obj;
8090
+ }
8091
+ function _iterable_to_array$a(iter) {
8092
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
8093
+ }
8094
+ function _non_iterable_spread$a() {
8095
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
8096
+ }
8097
+ function _object_spread$a(target) {
8098
+ for(var i = 1; i < arguments.length; i++){
8099
+ var source = arguments[i] != null ? arguments[i] : {};
8100
+ var ownKeys = Object.keys(source);
8101
+ if (typeof Object.getOwnPropertySymbols === "function") {
8102
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
8103
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
8104
+ }));
8105
+ }
8106
+ ownKeys.forEach(function(key) {
8107
+ _define_property$a(target, key, source[key]);
8108
+ });
8109
+ }
8110
+ return target;
8111
+ }
8112
+ function ownKeys$a(object, enumerableOnly) {
8113
+ var keys = Object.keys(object);
8114
+ if (Object.getOwnPropertySymbols) {
8115
+ var symbols = Object.getOwnPropertySymbols(object);
8116
+ keys.push.apply(keys, symbols);
8117
+ }
8118
+ return keys;
8119
+ }
8120
+ function _object_spread_props$a(target, source) {
8121
+ source = source != null ? source : {};
8122
+ if (Object.getOwnPropertyDescriptors) {
8123
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
8124
+ } else {
8125
+ ownKeys$a(Object(source)).forEach(function(key) {
8126
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
8127
+ });
8128
+ }
8129
+ return target;
8130
+ }
8131
+ function _object_without_properties(source, excluded) {
8132
+ if (source == null) return {};
8133
+ var target = _object_without_properties_loose(source, excluded);
8134
+ var key, i;
8135
+ if (Object.getOwnPropertySymbols) {
8136
+ var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
8137
+ for(i = 0; i < sourceSymbolKeys.length; i++){
8138
+ key = sourceSymbolKeys[i];
8139
+ if (excluded.indexOf(key) >= 0) continue;
8140
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
8141
+ target[key] = source[key];
8142
+ }
8143
+ }
8144
+ return target;
8145
+ }
8146
+ function _object_without_properties_loose(source, excluded) {
8147
+ if (source == null) return {};
8148
+ var target = {};
8149
+ var sourceKeys = Object.keys(source);
8150
+ var key, i;
8151
+ for(i = 0; i < sourceKeys.length; i++){
8152
+ key = sourceKeys[i];
8153
+ if (excluded.indexOf(key) >= 0) continue;
8154
+ target[key] = source[key];
8155
+ }
8156
+ return target;
8157
+ }
8158
+ function _to_consumable_array$a(arr) {
8159
+ return _array_without_holes$a(arr) || _iterable_to_array$a(arr) || _unsupported_iterable_to_array$a(arr) || _non_iterable_spread$a();
8160
+ }
8161
+ function _unsupported_iterable_to_array$a(o, minLen) {
8162
+ if (!o) return;
8163
+ if (typeof o === "string") return _array_like_to_array$a(o, minLen);
8164
+ var n = Object.prototype.toString.call(o).slice(8, -1);
8165
+ if (n === "Object" && o.constructor) n = o.constructor.name;
8166
+ if (n === "Map" || n === "Set") return Array.from(n);
8167
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$a(o, minLen);
8168
+ }
8169
+ function parseRecordDef(def, refs) {
8170
+ var _def_keyType, _def_keyType1, _def_keyType__def_checks, _def_keyType2, _def_keyType3, _def_keyType__def_type__def_checks;
8171
+ if (refs.target === "openAi") {
8172
+ console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead.");
8173
+ }
8174
+ if (refs.target === "openApi3" && ((_def_keyType = def.keyType) === null || _def_keyType === void 0 ? void 0 : _def_keyType._def.typeName) === ZodFirstPartyTypeKind.ZodEnum) {
8175
+ return {
8176
+ type: "object",
8177
+ required: def.keyType._def.values,
8178
+ properties: def.keyType._def.values.reduce(function(acc, key) {
8179
+ var _parseDef;
8180
+ return _object_spread_props$a(_object_spread$a({}, acc), _define_property$a({}, key, (_parseDef = parseDef(def.valueType._def, _object_spread_props$a(_object_spread$a({}, refs), {
8181
+ currentPath: _to_consumable_array$a(refs.currentPath).concat([
8182
+ "properties",
8183
+ key
8184
+ ])
8185
+ }))) !== null && _parseDef !== void 0 ? _parseDef : parseAnyDef(refs)));
8186
+ }, {}),
8187
+ additionalProperties: refs.rejectedAdditionalProperties
8188
+ };
8189
+ }
8190
+ var _parseDef;
8191
+ var schema = {
8192
+ type: "object",
8193
+ additionalProperties: (_parseDef = parseDef(def.valueType._def, _object_spread_props$a(_object_spread$a({}, refs), {
8194
+ currentPath: _to_consumable_array$a(refs.currentPath).concat([
8195
+ "additionalProperties"
8196
+ ])
8197
+ }))) !== null && _parseDef !== void 0 ? _parseDef : refs.allowedAdditionalProperties
8198
+ };
8199
+ if (refs.target === "openApi3") {
8200
+ return schema;
8201
+ }
8202
+ if (((_def_keyType1 = def.keyType) === null || _def_keyType1 === void 0 ? void 0 : _def_keyType1._def.typeName) === ZodFirstPartyTypeKind.ZodString && ((_def_keyType__def_checks = def.keyType._def.checks) === null || _def_keyType__def_checks === void 0 ? void 0 : _def_keyType__def_checks.length)) {
8203
+ var _parseStringDef = parseStringDef(def.keyType._def, refs); _parseStringDef.type; var keyType = _object_without_properties(_parseStringDef, [
8204
+ "type"
8205
+ ]);
8206
+ return _object_spread_props$a(_object_spread$a({}, schema), {
8207
+ propertyNames: keyType
8208
+ });
8209
+ } else if (((_def_keyType2 = def.keyType) === null || _def_keyType2 === void 0 ? void 0 : _def_keyType2._def.typeName) === ZodFirstPartyTypeKind.ZodEnum) {
8210
+ return _object_spread_props$a(_object_spread$a({}, schema), {
8211
+ propertyNames: {
8212
+ enum: def.keyType._def.values
8213
+ }
8214
+ });
8215
+ } else if (((_def_keyType3 = def.keyType) === null || _def_keyType3 === void 0 ? void 0 : _def_keyType3._def.typeName) === ZodFirstPartyTypeKind.ZodBranded && def.keyType._def.type._def.typeName === ZodFirstPartyTypeKind.ZodString && ((_def_keyType__def_type__def_checks = def.keyType._def.type._def.checks) === null || _def_keyType__def_type__def_checks === void 0 ? void 0 : _def_keyType__def_type__def_checks.length)) {
8216
+ var _parseBrandedDef = parseBrandedDef(def.keyType._def, refs); _parseBrandedDef.type; var keyType1 = _object_without_properties(_parseBrandedDef, [
8217
+ "type"
8218
+ ]);
8219
+ return _object_spread_props$a(_object_spread$a({}, schema), {
8220
+ propertyNames: keyType1
8221
+ });
8222
+ }
8223
+ return schema;
8224
+ }
8225
+
8226
+ function _array_like_to_array$9(arr, len) {
8227
+ if (len == null || len > arr.length) len = arr.length;
8228
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
8229
+ return arr2;
8230
+ }
8231
+ function _array_without_holes$9(arr) {
8232
+ if (Array.isArray(arr)) return _array_like_to_array$9(arr);
8233
+ }
8234
+ function _define_property$9(obj, key, value) {
8235
+ if (key in obj) {
8236
+ Object.defineProperty(obj, key, {
8237
+ value: value,
8238
+ enumerable: true,
8239
+ configurable: true,
8240
+ writable: true
8241
+ });
8242
+ } else {
8243
+ obj[key] = value;
8244
+ }
8245
+ return obj;
8246
+ }
8247
+ function _iterable_to_array$9(iter) {
8248
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
8249
+ }
8250
+ function _non_iterable_spread$9() {
8251
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
8252
+ }
8253
+ function _object_spread$9(target) {
8254
+ for(var i = 1; i < arguments.length; i++){
8255
+ var source = arguments[i] != null ? arguments[i] : {};
8256
+ var ownKeys = Object.keys(source);
8257
+ if (typeof Object.getOwnPropertySymbols === "function") {
8258
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
8259
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
8260
+ }));
8261
+ }
8262
+ ownKeys.forEach(function(key) {
8263
+ _define_property$9(target, key, source[key]);
8264
+ });
8265
+ }
8266
+ return target;
8267
+ }
8268
+ function ownKeys$9(object, enumerableOnly) {
8269
+ var keys = Object.keys(object);
8270
+ if (Object.getOwnPropertySymbols) {
8271
+ var symbols = Object.getOwnPropertySymbols(object);
8272
+ keys.push.apply(keys, symbols);
8273
+ }
8274
+ return keys;
8275
+ }
8276
+ function _object_spread_props$9(target, source) {
8277
+ source = source != null ? source : {};
8278
+ if (Object.getOwnPropertyDescriptors) {
8279
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
8280
+ } else {
8281
+ ownKeys$9(Object(source)).forEach(function(key) {
8282
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
8283
+ });
8284
+ }
8285
+ return target;
8286
+ }
8287
+ function _to_consumable_array$9(arr) {
8288
+ return _array_without_holes$9(arr) || _iterable_to_array$9(arr) || _unsupported_iterable_to_array$9(arr) || _non_iterable_spread$9();
8289
+ }
8290
+ function _unsupported_iterable_to_array$9(o, minLen) {
8291
+ if (!o) return;
8292
+ if (typeof o === "string") return _array_like_to_array$9(o, minLen);
8293
+ var n = Object.prototype.toString.call(o).slice(8, -1);
8294
+ if (n === "Object" && o.constructor) n = o.constructor.name;
8295
+ if (n === "Map" || n === "Set") return Array.from(n);
8296
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$9(o, minLen);
8297
+ }
8298
+ function parseMapDef(def, refs) {
8299
+ if (refs.mapStrategy === "record") {
8300
+ return parseRecordDef(def, refs);
8301
+ }
8302
+ var keys = parseDef(def.keyType._def, _object_spread_props$9(_object_spread$9({}, refs), {
8303
+ currentPath: _to_consumable_array$9(refs.currentPath).concat([
8304
+ "items",
8305
+ "items",
8306
+ "0"
8307
+ ])
8308
+ })) || parseAnyDef(refs);
8309
+ var values = parseDef(def.valueType._def, _object_spread_props$9(_object_spread$9({}, refs), {
8310
+ currentPath: _to_consumable_array$9(refs.currentPath).concat([
8311
+ "items",
8312
+ "items",
8313
+ "1"
8314
+ ])
8315
+ })) || parseAnyDef(refs);
8316
+ return {
8317
+ type: "array",
8318
+ maxItems: 125,
8319
+ items: {
8320
+ type: "array",
8321
+ items: [
8322
+ keys,
8323
+ values
8324
+ ],
8325
+ minItems: 2,
8326
+ maxItems: 2
8327
+ }
8328
+ };
8329
+ }
8330
+
8331
+ function _type_of$1(obj) {
8332
+ "@swc/helpers - typeof";
8333
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
8334
+ }
8335
+ function parseNativeEnumDef(def) {
8336
+ var object = def.values;
8337
+ var actualKeys = Object.keys(def.values).filter(function(key) {
8338
+ return typeof object[object[key]] !== "number";
8339
+ });
8340
+ var actualValues = actualKeys.map(function(key) {
8341
+ return object[key];
8342
+ });
8343
+ var parsedTypes = Array.from(new Set(actualValues.map(function(values) {
8344
+ return typeof values === "undefined" ? "undefined" : _type_of$1(values);
8345
+ })));
8346
+ return {
8347
+ type: parsedTypes.length === 1 ? parsedTypes[0] === "string" ? "string" : "number" : [
8348
+ "string",
8349
+ "number"
8350
+ ],
8351
+ enum: actualValues
8352
+ };
8353
+ }
8354
+
8355
+ function _array_like_to_array$8(arr, len) {
8356
+ if (len == null || len > arr.length) len = arr.length;
8357
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
8358
+ return arr2;
8359
+ }
8360
+ function _array_without_holes$8(arr) {
8361
+ if (Array.isArray(arr)) return _array_like_to_array$8(arr);
8362
+ }
8363
+ function _define_property$8(obj, key, value) {
8364
+ if (key in obj) {
8365
+ Object.defineProperty(obj, key, {
8366
+ value: value,
8367
+ enumerable: true,
8368
+ configurable: true,
8369
+ writable: true
8370
+ });
8371
+ } else {
8372
+ obj[key] = value;
8373
+ }
8374
+ return obj;
8375
+ }
8376
+ function _iterable_to_array$8(iter) {
8377
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
8378
+ }
8379
+ function _non_iterable_spread$8() {
8380
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
8381
+ }
8382
+ function _object_spread$8(target) {
8383
+ for(var i = 1; i < arguments.length; i++){
8384
+ var source = arguments[i] != null ? arguments[i] : {};
8385
+ var ownKeys = Object.keys(source);
8386
+ if (typeof Object.getOwnPropertySymbols === "function") {
8387
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
8388
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
8389
+ }));
8390
+ }
8391
+ ownKeys.forEach(function(key) {
8392
+ _define_property$8(target, key, source[key]);
8393
+ });
8394
+ }
8395
+ return target;
8396
+ }
8397
+ function ownKeys$8(object, enumerableOnly) {
8398
+ var keys = Object.keys(object);
8399
+ if (Object.getOwnPropertySymbols) {
8400
+ var symbols = Object.getOwnPropertySymbols(object);
8401
+ keys.push.apply(keys, symbols);
8402
+ }
8403
+ return keys;
8404
+ }
8405
+ function _object_spread_props$8(target, source) {
8406
+ source = source != null ? source : {};
8407
+ if (Object.getOwnPropertyDescriptors) {
8408
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
8409
+ } else {
8410
+ ownKeys$8(Object(source)).forEach(function(key) {
8411
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
8412
+ });
8413
+ }
8414
+ return target;
8415
+ }
8416
+ function _to_consumable_array$8(arr) {
8417
+ return _array_without_holes$8(arr) || _iterable_to_array$8(arr) || _unsupported_iterable_to_array$8(arr) || _non_iterable_spread$8();
8418
+ }
8419
+ function _unsupported_iterable_to_array$8(o, minLen) {
8420
+ if (!o) return;
8421
+ if (typeof o === "string") return _array_like_to_array$8(o, minLen);
8422
+ var n = Object.prototype.toString.call(o).slice(8, -1);
8423
+ if (n === "Object" && o.constructor) n = o.constructor.name;
8424
+ if (n === "Map" || n === "Set") return Array.from(n);
8425
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$8(o, minLen);
8426
+ }
8427
+ function parseNeverDef(refs) {
8428
+ return refs.target === "openAi" ? undefined : {
8429
+ not: parseAnyDef(_object_spread_props$8(_object_spread$8({}, refs), {
8430
+ currentPath: _to_consumable_array$8(refs.currentPath).concat([
8431
+ "not"
8432
+ ])
8433
+ }))
8434
+ };
8435
+ }
8436
+
8437
+ function parseNullDef(refs) {
8438
+ return refs.target === "openApi3" ? {
8439
+ enum: [
8440
+ "null"
8441
+ ],
8442
+ nullable: true
8443
+ } : {
8444
+ type: "null"
8445
+ };
8446
+ }
8447
+
8448
+ function _array_like_to_array$7(arr, len) {
8449
+ if (len == null || len > arr.length) len = arr.length;
8450
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
8451
+ return arr2;
8452
+ }
8453
+ function _array_without_holes$7(arr) {
8454
+ if (Array.isArray(arr)) return _array_like_to_array$7(arr);
8455
+ }
8456
+ function _define_property$7(obj, key, value) {
8457
+ if (key in obj) {
8458
+ Object.defineProperty(obj, key, {
8459
+ value: value,
8460
+ enumerable: true,
8461
+ configurable: true,
8462
+ writable: true
8463
+ });
8464
+ } else {
8465
+ obj[key] = value;
8466
+ }
8467
+ return obj;
8468
+ }
8469
+ function _instanceof(left, right) {
8470
+ if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
8471
+ return !!right[Symbol.hasInstance](left);
8472
+ } else {
8473
+ return left instanceof right;
8474
+ }
8475
+ }
8476
+ function _iterable_to_array$7(iter) {
8477
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
8478
+ }
8479
+ function _non_iterable_spread$7() {
8480
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
8481
+ }
8482
+ function _object_spread$7(target) {
8483
+ for(var i = 1; i < arguments.length; i++){
8484
+ var source = arguments[i] != null ? arguments[i] : {};
8485
+ var ownKeys = Object.keys(source);
8486
+ if (typeof Object.getOwnPropertySymbols === "function") {
8487
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
8488
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
8489
+ }));
8490
+ }
8491
+ ownKeys.forEach(function(key) {
8492
+ _define_property$7(target, key, source[key]);
8493
+ });
8494
+ }
8495
+ return target;
8496
+ }
8497
+ function ownKeys$7(object, enumerableOnly) {
8498
+ var keys = Object.keys(object);
8499
+ if (Object.getOwnPropertySymbols) {
8500
+ var symbols = Object.getOwnPropertySymbols(object);
8501
+ keys.push.apply(keys, symbols);
8502
+ }
8503
+ return keys;
8504
+ }
8505
+ function _object_spread_props$7(target, source) {
8506
+ source = source != null ? source : {};
8507
+ if (Object.getOwnPropertyDescriptors) {
8508
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
8509
+ } else {
8510
+ ownKeys$7(Object(source)).forEach(function(key) {
8511
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
8512
+ });
8513
+ }
8514
+ return target;
8515
+ }
8516
+ function _to_consumable_array$7(arr) {
8517
+ return _array_without_holes$7(arr) || _iterable_to_array$7(arr) || _unsupported_iterable_to_array$7(arr) || _non_iterable_spread$7();
8518
+ }
8519
+ function _type_of(obj) {
8520
+ "@swc/helpers - typeof";
8521
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
8522
+ }
8523
+ function _unsupported_iterable_to_array$7(o, minLen) {
8524
+ if (!o) return;
8525
+ if (typeof o === "string") return _array_like_to_array$7(o, minLen);
8526
+ var n = Object.prototype.toString.call(o).slice(8, -1);
8527
+ if (n === "Object" && o.constructor) n = o.constructor.name;
8528
+ if (n === "Map" || n === "Set") return Array.from(n);
8529
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$7(o, minLen);
8530
+ }
8531
+ var primitiveMappings = {
8532
+ ZodString: "string",
8533
+ ZodNumber: "number",
8534
+ ZodBigInt: "integer",
8535
+ ZodBoolean: "boolean",
8536
+ ZodNull: "null"
8537
+ };
8538
+ function parseUnionDef(def, refs) {
8539
+ if (refs.target === "openApi3") return asAnyOf(def, refs);
8540
+ var options = _instanceof(def.options, Map) ? Array.from(def.options.values()) : def.options;
8541
+ // This blocks tries to look ahead a bit to produce nicer looking schemas with type array instead of anyOf.
8542
+ if (options.every(function(x) {
8543
+ return x._def.typeName in primitiveMappings && (!x._def.checks || !x._def.checks.length);
8544
+ })) {
8545
+ // all types in union are primitive and lack checks, so might as well squash into {type: [...]}
8546
+ var types = options.reduce(function(types, x) {
8547
+ var type = primitiveMappings[x._def.typeName]; //Can be safely casted due to row 43
8548
+ return type && !types.includes(type) ? _to_consumable_array$7(types).concat([
8549
+ type
8550
+ ]) : types;
8551
+ }, []);
8552
+ return {
8553
+ type: types.length > 1 ? types : types[0]
8554
+ };
8555
+ } else if (options.every(function(x) {
8556
+ return x._def.typeName === "ZodLiteral" && !x.description;
8557
+ })) {
8558
+ // all options literals
8559
+ var types1 = options.reduce(function(acc, x) {
8560
+ var type = _type_of(x._def.value);
8561
+ switch(type){
8562
+ case "string":
8563
+ case "number":
8564
+ case "boolean":
8565
+ return _to_consumable_array$7(acc).concat([
8566
+ type
8567
+ ]);
8568
+ case "bigint":
8569
+ return _to_consumable_array$7(acc).concat([
8570
+ "integer"
8571
+ ]);
8572
+ case "object":
8573
+ if (x._def.value === null) return _to_consumable_array$7(acc).concat([
8574
+ "null"
8575
+ ]);
8576
+ case "symbol":
8577
+ case "undefined":
8578
+ case "function":
8579
+ default:
8580
+ return acc;
8581
+ }
8582
+ }, []);
8583
+ if (types1.length === options.length) {
8584
+ // all the literals are primitive, as far as null can be considered primitive
8585
+ var uniqueTypes = types1.filter(function(x, i, a) {
8586
+ return a.indexOf(x) === i;
8587
+ });
8588
+ return {
8589
+ type: uniqueTypes.length > 1 ? uniqueTypes : uniqueTypes[0],
8590
+ enum: options.reduce(function(acc, x) {
8591
+ return acc.includes(x._def.value) ? acc : _to_consumable_array$7(acc).concat([
8592
+ x._def.value
8593
+ ]);
8594
+ }, [])
8595
+ };
8596
+ }
8597
+ } else if (options.every(function(x) {
8598
+ return x._def.typeName === "ZodEnum";
8599
+ })) {
8600
+ return {
8601
+ type: "string",
8602
+ enum: options.reduce(function(acc, x) {
8603
+ return _to_consumable_array$7(acc).concat(_to_consumable_array$7(x._def.values.filter(function(x) {
8604
+ return !acc.includes(x);
8605
+ })));
8606
+ }, [])
8607
+ };
8608
+ }
8609
+ return asAnyOf(def, refs);
8610
+ }
8611
+ var asAnyOf = function(def, refs) {
8612
+ var anyOf = (_instanceof(def.options, Map) ? Array.from(def.options.values()) : def.options).map(function(x, i) {
8613
+ return parseDef(x._def, _object_spread_props$7(_object_spread$7({}, refs), {
8614
+ currentPath: _to_consumable_array$7(refs.currentPath).concat([
8615
+ "anyOf",
8616
+ "".concat(i)
8617
+ ])
8618
+ }));
8619
+ }).filter(function(x) {
8620
+ return !!x && (!refs.strictUnions || typeof x === "object" && Object.keys(x).length > 0);
8621
+ });
8622
+ return anyOf.length ? {
8623
+ anyOf: anyOf
8624
+ } : undefined;
8625
+ };
8626
+
8627
+ function _array_like_to_array$6(arr, len) {
8628
+ if (len == null || len > arr.length) len = arr.length;
8629
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
8630
+ return arr2;
8631
+ }
8632
+ function _array_without_holes$6(arr) {
8633
+ if (Array.isArray(arr)) return _array_like_to_array$6(arr);
8634
+ }
8635
+ function _define_property$6(obj, key, value) {
8636
+ if (key in obj) {
8637
+ Object.defineProperty(obj, key, {
8638
+ value: value,
8639
+ enumerable: true,
8640
+ configurable: true,
8641
+ writable: true
8642
+ });
8643
+ } else {
8644
+ obj[key] = value;
8645
+ }
8646
+ return obj;
8647
+ }
8648
+ function _iterable_to_array$6(iter) {
8649
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
8650
+ }
8651
+ function _non_iterable_spread$6() {
8652
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
8653
+ }
8654
+ function _object_spread$6(target) {
8655
+ for(var i = 1; i < arguments.length; i++){
8656
+ var source = arguments[i] != null ? arguments[i] : {};
8657
+ var ownKeys = Object.keys(source);
8658
+ if (typeof Object.getOwnPropertySymbols === "function") {
8659
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
8660
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
8661
+ }));
8662
+ }
8663
+ ownKeys.forEach(function(key) {
8664
+ _define_property$6(target, key, source[key]);
8665
+ });
8666
+ }
8667
+ return target;
8668
+ }
8669
+ function ownKeys$6(object, enumerableOnly) {
8670
+ var keys = Object.keys(object);
8671
+ if (Object.getOwnPropertySymbols) {
8672
+ var symbols = Object.getOwnPropertySymbols(object);
8673
+ keys.push.apply(keys, symbols);
8674
+ }
8675
+ return keys;
8676
+ }
8677
+ function _object_spread_props$6(target, source) {
8678
+ source = source != null ? source : {};
8679
+ if (Object.getOwnPropertyDescriptors) {
8680
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
8681
+ } else {
8682
+ ownKeys$6(Object(source)).forEach(function(key) {
8683
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
8684
+ });
8685
+ }
8686
+ return target;
8687
+ }
8688
+ function _to_consumable_array$6(arr) {
8689
+ return _array_without_holes$6(arr) || _iterable_to_array$6(arr) || _unsupported_iterable_to_array$6(arr) || _non_iterable_spread$6();
8690
+ }
8691
+ function _unsupported_iterable_to_array$6(o, minLen) {
8692
+ if (!o) return;
8693
+ if (typeof o === "string") return _array_like_to_array$6(o, minLen);
8694
+ var n = Object.prototype.toString.call(o).slice(8, -1);
8695
+ if (n === "Object" && o.constructor) n = o.constructor.name;
8696
+ if (n === "Map" || n === "Set") return Array.from(n);
8697
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$6(o, minLen);
8698
+ }
8699
+ function parseNullableDef(def, refs) {
8700
+ if ([
8701
+ "ZodString",
8702
+ "ZodNumber",
8703
+ "ZodBigInt",
8704
+ "ZodBoolean",
8705
+ "ZodNull"
8706
+ ].includes(def.innerType._def.typeName) && (!def.innerType._def.checks || !def.innerType._def.checks.length)) {
8707
+ if (refs.target === "openApi3") {
8708
+ return {
8709
+ type: primitiveMappings[def.innerType._def.typeName],
8710
+ nullable: true
8711
+ };
8712
+ }
8713
+ return {
8714
+ type: [
8715
+ primitiveMappings[def.innerType._def.typeName],
8716
+ "null"
8717
+ ]
8718
+ };
8719
+ }
8720
+ if (refs.target === "openApi3") {
8721
+ var base = parseDef(def.innerType._def, _object_spread_props$6(_object_spread$6({}, refs), {
8722
+ currentPath: _to_consumable_array$6(refs.currentPath)
8723
+ }));
8724
+ if (base && "$ref" in base) return {
8725
+ allOf: [
8726
+ base
8727
+ ],
8728
+ nullable: true
8729
+ };
8730
+ return base && _object_spread_props$6(_object_spread$6({}, base), {
8731
+ nullable: true
8732
+ });
8733
+ }
8734
+ var base1 = parseDef(def.innerType._def, _object_spread_props$6(_object_spread$6({}, refs), {
8735
+ currentPath: _to_consumable_array$6(refs.currentPath).concat([
8736
+ "anyOf",
8737
+ "0"
8738
+ ])
8739
+ }));
8740
+ return base1 && {
8741
+ anyOf: [
8742
+ base1,
8743
+ {
8744
+ type: "null"
8745
+ }
8746
+ ]
8747
+ };
8748
+ }
8749
+
8750
+ function parseNumberDef(def, refs) {
8751
+ var res = {
8752
+ type: "number"
8753
+ };
8754
+ if (!def.checks) return res;
8755
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
8756
+ try {
8757
+ for(var _iterator = def.checks[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
8758
+ var check = _step.value;
8759
+ switch(check.kind){
8760
+ case "int":
8761
+ res.type = "integer";
8762
+ addErrorMessage(res, "type", check.message, refs);
8763
+ break;
8764
+ case "min":
8765
+ if (refs.target === "jsonSchema7") {
8766
+ if (check.inclusive) {
8767
+ setResponseValueAndErrors(res, "minimum", check.value, check.message, refs);
8768
+ } else {
8769
+ setResponseValueAndErrors(res, "exclusiveMinimum", check.value, check.message, refs);
8770
+ }
8771
+ } else {
8772
+ if (!check.inclusive) {
8773
+ res.exclusiveMinimum = true;
8774
+ }
8775
+ setResponseValueAndErrors(res, "minimum", check.value, check.message, refs);
8776
+ }
8777
+ break;
8778
+ case "max":
8779
+ if (refs.target === "jsonSchema7") {
8780
+ if (check.inclusive) {
8781
+ setResponseValueAndErrors(res, "maximum", check.value, check.message, refs);
8782
+ } else {
8783
+ setResponseValueAndErrors(res, "exclusiveMaximum", check.value, check.message, refs);
8784
+ }
8785
+ } else {
8786
+ if (!check.inclusive) {
8787
+ res.exclusiveMaximum = true;
8788
+ }
8789
+ setResponseValueAndErrors(res, "maximum", check.value, check.message, refs);
8790
+ }
8791
+ break;
8792
+ case "multipleOf":
8793
+ setResponseValueAndErrors(res, "multipleOf", check.value, check.message, refs);
8794
+ break;
8795
+ }
8796
+ }
8797
+ } catch (err) {
8798
+ _didIteratorError = true;
8799
+ _iteratorError = err;
8800
+ } finally{
8801
+ try {
8802
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
8803
+ _iterator.return();
8804
+ }
8805
+ } finally{
8806
+ if (_didIteratorError) {
8807
+ throw _iteratorError;
8808
+ }
8809
+ }
8810
+ }
8811
+ return res;
8812
+ }
8813
+
8814
+ function _array_like_to_array$5(arr, len) {
8815
+ if (len == null || len > arr.length) len = arr.length;
8816
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
8817
+ return arr2;
8818
+ }
8819
+ function _array_without_holes$5(arr) {
8820
+ if (Array.isArray(arr)) return _array_like_to_array$5(arr);
8821
+ }
8822
+ function _define_property$5(obj, key, value) {
8823
+ if (key in obj) {
8824
+ Object.defineProperty(obj, key, {
8825
+ value: value,
8826
+ enumerable: true,
8827
+ configurable: true,
8828
+ writable: true
8829
+ });
8830
+ } else {
8831
+ obj[key] = value;
8832
+ }
8833
+ return obj;
8834
+ }
8835
+ function _iterable_to_array$5(iter) {
8836
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
8837
+ }
8838
+ function _non_iterable_spread$5() {
8839
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
8840
+ }
8841
+ function _object_spread$5(target) {
8842
+ for(var i = 1; i < arguments.length; i++){
8843
+ var source = arguments[i] != null ? arguments[i] : {};
8844
+ var ownKeys = Object.keys(source);
8845
+ if (typeof Object.getOwnPropertySymbols === "function") {
8846
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
8847
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
8848
+ }));
8849
+ }
8850
+ ownKeys.forEach(function(key) {
8851
+ _define_property$5(target, key, source[key]);
8852
+ });
8853
+ }
8854
+ return target;
8855
+ }
8856
+ function ownKeys$5(object, enumerableOnly) {
8857
+ var keys = Object.keys(object);
8858
+ if (Object.getOwnPropertySymbols) {
8859
+ var symbols = Object.getOwnPropertySymbols(object);
8860
+ keys.push.apply(keys, symbols);
8861
+ }
8862
+ return keys;
8863
+ }
8864
+ function _object_spread_props$5(target, source) {
8865
+ source = source != null ? source : {};
8866
+ if (Object.getOwnPropertyDescriptors) {
8867
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
8868
+ } else {
8869
+ ownKeys$5(Object(source)).forEach(function(key) {
8870
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
8871
+ });
8872
+ }
8873
+ return target;
8874
+ }
8875
+ function _to_consumable_array$5(arr) {
8876
+ return _array_without_holes$5(arr) || _iterable_to_array$5(arr) || _unsupported_iterable_to_array$5(arr) || _non_iterable_spread$5();
8877
+ }
8878
+ function _unsupported_iterable_to_array$5(o, minLen) {
8879
+ if (!o) return;
8880
+ if (typeof o === "string") return _array_like_to_array$5(o, minLen);
8881
+ var n = Object.prototype.toString.call(o).slice(8, -1);
8882
+ if (n === "Object" && o.constructor) n = o.constructor.name;
8883
+ if (n === "Map" || n === "Set") return Array.from(n);
8884
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$5(o, minLen);
8885
+ }
8886
+ function parseObjectDef(def, refs) {
8887
+ var forceOptionalIntoNullable = refs.target === "openAi";
8888
+ var result = {
8889
+ type: "object",
8890
+ properties: {}
8891
+ };
8892
+ var required = [];
8893
+ var shape = def.shape();
8894
+ for(var propName in shape){
8895
+ var propDef = shape[propName];
8896
+ if (propDef === undefined || propDef._def === undefined) {
8897
+ continue;
8898
+ }
8899
+ var propOptional = safeIsOptional(propDef);
8900
+ if (propOptional && forceOptionalIntoNullable) {
8901
+ if (propDef._def.typeName === "ZodOptional") {
8902
+ propDef = propDef._def.innerType;
8903
+ }
8904
+ if (!propDef.isNullable()) {
8905
+ propDef = propDef.nullable();
8906
+ }
8907
+ propOptional = false;
8908
+ }
8909
+ var parsedDef = parseDef(propDef._def, _object_spread_props$5(_object_spread$5({}, refs), {
8910
+ currentPath: _to_consumable_array$5(refs.currentPath).concat([
8911
+ "properties",
8912
+ propName
8913
+ ]),
8914
+ propertyPath: _to_consumable_array$5(refs.currentPath).concat([
8915
+ "properties",
8916
+ propName
8917
+ ])
8918
+ }));
8919
+ if (parsedDef === undefined) {
8920
+ continue;
8921
+ }
8922
+ result.properties[propName] = parsedDef;
8923
+ if (!propOptional) {
8924
+ required.push(propName);
8925
+ }
8926
+ }
8927
+ if (required.length) {
8928
+ result.required = required;
8929
+ }
8930
+ var additionalProperties = decideAdditionalProperties(def, refs);
8931
+ if (additionalProperties !== undefined) {
8932
+ result.additionalProperties = additionalProperties;
8933
+ }
8934
+ return result;
8935
+ }
8936
+ function decideAdditionalProperties(def, refs) {
8937
+ if (def.catchall._def.typeName !== "ZodNever") {
8938
+ return parseDef(def.catchall._def, _object_spread_props$5(_object_spread$5({}, refs), {
8939
+ currentPath: _to_consumable_array$5(refs.currentPath).concat([
8940
+ "additionalProperties"
8941
+ ])
8942
+ }));
8943
+ }
8944
+ switch(def.unknownKeys){
8945
+ case "passthrough":
8946
+ return refs.allowedAdditionalProperties;
8947
+ case "strict":
8948
+ return refs.rejectedAdditionalProperties;
8949
+ case "strip":
8950
+ return refs.removeAdditionalStrategy === "strict" ? refs.allowedAdditionalProperties : refs.rejectedAdditionalProperties;
8951
+ }
8952
+ }
8953
+ function safeIsOptional(schema) {
8954
+ try {
8955
+ return schema.isOptional();
8956
+ } catch (e) {
8957
+ return true;
8958
+ }
8959
+ }
8960
+
8961
+ function _array_like_to_array$4(arr, len) {
8962
+ if (len == null || len > arr.length) len = arr.length;
8963
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
8964
+ return arr2;
8965
+ }
8966
+ function _array_without_holes$4(arr) {
8967
+ if (Array.isArray(arr)) return _array_like_to_array$4(arr);
8968
+ }
8969
+ function _define_property$4(obj, key, value) {
8970
+ if (key in obj) {
8971
+ Object.defineProperty(obj, key, {
8972
+ value: value,
8973
+ enumerable: true,
8974
+ configurable: true,
8975
+ writable: true
8976
+ });
8977
+ } else {
8978
+ obj[key] = value;
8979
+ }
8980
+ return obj;
8981
+ }
8982
+ function _iterable_to_array$4(iter) {
8983
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
8984
+ }
8985
+ function _non_iterable_spread$4() {
8986
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
8987
+ }
8988
+ function _object_spread$4(target) {
8989
+ for(var i = 1; i < arguments.length; i++){
8990
+ var source = arguments[i] != null ? arguments[i] : {};
8991
+ var ownKeys = Object.keys(source);
8992
+ if (typeof Object.getOwnPropertySymbols === "function") {
8993
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
8994
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
8995
+ }));
8996
+ }
8997
+ ownKeys.forEach(function(key) {
8998
+ _define_property$4(target, key, source[key]);
8999
+ });
9000
+ }
9001
+ return target;
9002
+ }
9003
+ function ownKeys$4(object, enumerableOnly) {
9004
+ var keys = Object.keys(object);
9005
+ if (Object.getOwnPropertySymbols) {
9006
+ var symbols = Object.getOwnPropertySymbols(object);
9007
+ keys.push.apply(keys, symbols);
9008
+ }
9009
+ return keys;
9010
+ }
9011
+ function _object_spread_props$4(target, source) {
9012
+ source = source != null ? source : {};
9013
+ if (Object.getOwnPropertyDescriptors) {
9014
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
9015
+ } else {
9016
+ ownKeys$4(Object(source)).forEach(function(key) {
9017
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
9018
+ });
9019
+ }
9020
+ return target;
9021
+ }
9022
+ function _to_consumable_array$4(arr) {
9023
+ return _array_without_holes$4(arr) || _iterable_to_array$4(arr) || _unsupported_iterable_to_array$4(arr) || _non_iterable_spread$4();
9024
+ }
9025
+ function _unsupported_iterable_to_array$4(o, minLen) {
9026
+ if (!o) return;
9027
+ if (typeof o === "string") return _array_like_to_array$4(o, minLen);
9028
+ var n = Object.prototype.toString.call(o).slice(8, -1);
9029
+ if (n === "Object" && o.constructor) n = o.constructor.name;
9030
+ if (n === "Map" || n === "Set") return Array.from(n);
9031
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$4(o, minLen);
9032
+ }
9033
+ var parseOptionalDef = function(def, refs) {
9034
+ var _refs_propertyPath;
9035
+ if (refs.currentPath.toString() === ((_refs_propertyPath = refs.propertyPath) === null || _refs_propertyPath === void 0 ? void 0 : _refs_propertyPath.toString())) {
9036
+ return parseDef(def.innerType._def, refs);
9037
+ }
9038
+ var innerSchema = parseDef(def.innerType._def, _object_spread_props$4(_object_spread$4({}, refs), {
9039
+ currentPath: _to_consumable_array$4(refs.currentPath).concat([
9040
+ "anyOf",
9041
+ "1"
9042
+ ])
9043
+ }));
9044
+ return innerSchema ? {
9045
+ anyOf: [
9046
+ {
9047
+ not: parseAnyDef(refs)
9048
+ },
9049
+ innerSchema
9050
+ ]
9051
+ } : parseAnyDef(refs);
9052
+ };
9053
+
9054
+ function _array_like_to_array$3(arr, len) {
9055
+ if (len == null || len > arr.length) len = arr.length;
9056
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
9057
+ return arr2;
9058
+ }
9059
+ function _array_without_holes$3(arr) {
9060
+ if (Array.isArray(arr)) return _array_like_to_array$3(arr);
9061
+ }
9062
+ function _define_property$3(obj, key, value) {
9063
+ if (key in obj) {
9064
+ Object.defineProperty(obj, key, {
9065
+ value: value,
9066
+ enumerable: true,
9067
+ configurable: true,
9068
+ writable: true
9069
+ });
9070
+ } else {
9071
+ obj[key] = value;
9072
+ }
9073
+ return obj;
9074
+ }
9075
+ function _iterable_to_array$3(iter) {
9076
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
9077
+ }
9078
+ function _non_iterable_spread$3() {
9079
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
9080
+ }
9081
+ function _object_spread$3(target) {
9082
+ for(var i = 1; i < arguments.length; i++){
9083
+ var source = arguments[i] != null ? arguments[i] : {};
9084
+ var ownKeys = Object.keys(source);
9085
+ if (typeof Object.getOwnPropertySymbols === "function") {
9086
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
9087
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
9088
+ }));
9089
+ }
9090
+ ownKeys.forEach(function(key) {
9091
+ _define_property$3(target, key, source[key]);
9092
+ });
9093
+ }
9094
+ return target;
9095
+ }
9096
+ function ownKeys$3(object, enumerableOnly) {
9097
+ var keys = Object.keys(object);
9098
+ if (Object.getOwnPropertySymbols) {
9099
+ var symbols = Object.getOwnPropertySymbols(object);
9100
+ keys.push.apply(keys, symbols);
9101
+ }
9102
+ return keys;
9103
+ }
9104
+ function _object_spread_props$3(target, source) {
9105
+ source = source != null ? source : {};
9106
+ if (Object.getOwnPropertyDescriptors) {
9107
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
9108
+ } else {
9109
+ ownKeys$3(Object(source)).forEach(function(key) {
9110
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
9111
+ });
9112
+ }
9113
+ return target;
9114
+ }
9115
+ function _to_consumable_array$3(arr) {
9116
+ return _array_without_holes$3(arr) || _iterable_to_array$3(arr) || _unsupported_iterable_to_array$3(arr) || _non_iterable_spread$3();
9117
+ }
9118
+ function _unsupported_iterable_to_array$3(o, minLen) {
9119
+ if (!o) return;
9120
+ if (typeof o === "string") return _array_like_to_array$3(o, minLen);
9121
+ var n = Object.prototype.toString.call(o).slice(8, -1);
9122
+ if (n === "Object" && o.constructor) n = o.constructor.name;
9123
+ if (n === "Map" || n === "Set") return Array.from(n);
9124
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$3(o, minLen);
9125
+ }
9126
+ var parsePipelineDef = function(def, refs) {
9127
+ if (refs.pipeStrategy === "input") {
9128
+ return parseDef(def.in._def, refs);
9129
+ } else if (refs.pipeStrategy === "output") {
9130
+ return parseDef(def.out._def, refs);
9131
+ }
9132
+ var a = parseDef(def.in._def, _object_spread_props$3(_object_spread$3({}, refs), {
9133
+ currentPath: _to_consumable_array$3(refs.currentPath).concat([
9134
+ "allOf",
9135
+ "0"
9136
+ ])
9137
+ }));
9138
+ var b = parseDef(def.out._def, _object_spread_props$3(_object_spread$3({}, refs), {
9139
+ currentPath: _to_consumable_array$3(refs.currentPath).concat([
9140
+ "allOf",
9141
+ a ? "1" : "0"
9142
+ ])
9143
+ }));
9144
+ return {
9145
+ allOf: [
9146
+ a,
9147
+ b
9148
+ ].filter(function(x) {
9149
+ return x !== undefined;
9150
+ })
9151
+ };
9152
+ };
9153
+
9154
+ function parsePromiseDef(def, refs) {
9155
+ return parseDef(def.type._def, refs);
9156
+ }
9157
+
9158
+ function _array_like_to_array$2(arr, len) {
9159
+ if (len == null || len > arr.length) len = arr.length;
9160
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
9161
+ return arr2;
9162
+ }
9163
+ function _array_without_holes$2(arr) {
9164
+ if (Array.isArray(arr)) return _array_like_to_array$2(arr);
9165
+ }
9166
+ function _define_property$2(obj, key, value) {
9167
+ if (key in obj) {
9168
+ Object.defineProperty(obj, key, {
9169
+ value: value,
9170
+ enumerable: true,
9171
+ configurable: true,
9172
+ writable: true
9173
+ });
9174
+ } else {
9175
+ obj[key] = value;
9176
+ }
9177
+ return obj;
9178
+ }
9179
+ function _iterable_to_array$2(iter) {
9180
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
9181
+ }
9182
+ function _non_iterable_spread$2() {
9183
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
9184
+ }
9185
+ function _object_spread$2(target) {
9186
+ for(var i = 1; i < arguments.length; i++){
9187
+ var source = arguments[i] != null ? arguments[i] : {};
9188
+ var ownKeys = Object.keys(source);
9189
+ if (typeof Object.getOwnPropertySymbols === "function") {
9190
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
9191
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
9192
+ }));
9193
+ }
9194
+ ownKeys.forEach(function(key) {
9195
+ _define_property$2(target, key, source[key]);
9196
+ });
9197
+ }
9198
+ return target;
9199
+ }
9200
+ function ownKeys$2(object, enumerableOnly) {
9201
+ var keys = Object.keys(object);
9202
+ if (Object.getOwnPropertySymbols) {
9203
+ var symbols = Object.getOwnPropertySymbols(object);
9204
+ keys.push.apply(keys, symbols);
9205
+ }
9206
+ return keys;
9207
+ }
9208
+ function _object_spread_props$2(target, source) {
9209
+ source = source != null ? source : {};
9210
+ if (Object.getOwnPropertyDescriptors) {
9211
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
9212
+ } else {
9213
+ ownKeys$2(Object(source)).forEach(function(key) {
9214
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
9215
+ });
9216
+ }
9217
+ return target;
9218
+ }
9219
+ function _to_consumable_array$2(arr) {
9220
+ return _array_without_holes$2(arr) || _iterable_to_array$2(arr) || _unsupported_iterable_to_array$2(arr) || _non_iterable_spread$2();
9221
+ }
9222
+ function _unsupported_iterable_to_array$2(o, minLen) {
9223
+ if (!o) return;
9224
+ if (typeof o === "string") return _array_like_to_array$2(o, minLen);
9225
+ var n = Object.prototype.toString.call(o).slice(8, -1);
9226
+ if (n === "Object" && o.constructor) n = o.constructor.name;
9227
+ if (n === "Map" || n === "Set") return Array.from(n);
9228
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$2(o, minLen);
9229
+ }
9230
+ function parseSetDef(def, refs) {
9231
+ var items = parseDef(def.valueType._def, _object_spread_props$2(_object_spread$2({}, refs), {
9232
+ currentPath: _to_consumable_array$2(refs.currentPath).concat([
9233
+ "items"
9234
+ ])
9235
+ }));
9236
+ var schema = {
9237
+ type: "array",
9238
+ uniqueItems: true,
9239
+ items: items
9240
+ };
9241
+ if (def.minSize) {
9242
+ setResponseValueAndErrors(schema, "minItems", def.minSize.value, def.minSize.message, refs);
9243
+ }
9244
+ if (def.maxSize) {
9245
+ setResponseValueAndErrors(schema, "maxItems", def.maxSize.value, def.maxSize.message, refs);
9246
+ }
9247
+ return schema;
9248
+ }
9249
+
9250
+ function _array_like_to_array$1(arr, len) {
9251
+ if (len == null || len > arr.length) len = arr.length;
9252
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
9253
+ return arr2;
9254
+ }
9255
+ function _array_without_holes$1(arr) {
9256
+ if (Array.isArray(arr)) return _array_like_to_array$1(arr);
9257
+ }
9258
+ function _define_property$1(obj, key, value) {
9259
+ if (key in obj) {
9260
+ Object.defineProperty(obj, key, {
9261
+ value: value,
9262
+ enumerable: true,
9263
+ configurable: true,
9264
+ writable: true
9265
+ });
9266
+ } else {
9267
+ obj[key] = value;
9268
+ }
9269
+ return obj;
9270
+ }
9271
+ function _iterable_to_array$1(iter) {
9272
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
9273
+ }
9274
+ function _non_iterable_spread$1() {
9275
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
9276
+ }
9277
+ function _object_spread$1(target) {
9278
+ for(var i = 1; i < arguments.length; i++){
9279
+ var source = arguments[i] != null ? arguments[i] : {};
9280
+ var ownKeys = Object.keys(source);
9281
+ if (typeof Object.getOwnPropertySymbols === "function") {
9282
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
9283
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
9284
+ }));
9285
+ }
9286
+ ownKeys.forEach(function(key) {
9287
+ _define_property$1(target, key, source[key]);
9288
+ });
9289
+ }
9290
+ return target;
9291
+ }
9292
+ function ownKeys$1(object, enumerableOnly) {
9293
+ var keys = Object.keys(object);
9294
+ if (Object.getOwnPropertySymbols) {
9295
+ var symbols = Object.getOwnPropertySymbols(object);
9296
+ keys.push.apply(keys, symbols);
9297
+ }
9298
+ return keys;
9299
+ }
9300
+ function _object_spread_props$1(target, source) {
9301
+ source = source != null ? source : {};
9302
+ if (Object.getOwnPropertyDescriptors) {
9303
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
9304
+ } else {
9305
+ ownKeys$1(Object(source)).forEach(function(key) {
9306
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
9307
+ });
9308
+ }
9309
+ return target;
9310
+ }
9311
+ function _to_consumable_array$1(arr) {
9312
+ return _array_without_holes$1(arr) || _iterable_to_array$1(arr) || _unsupported_iterable_to_array$1(arr) || _non_iterable_spread$1();
9313
+ }
9314
+ function _unsupported_iterable_to_array$1(o, minLen) {
9315
+ if (!o) return;
9316
+ if (typeof o === "string") return _array_like_to_array$1(o, minLen);
9317
+ var n = Object.prototype.toString.call(o).slice(8, -1);
9318
+ if (n === "Object" && o.constructor) n = o.constructor.name;
9319
+ if (n === "Map" || n === "Set") return Array.from(n);
9320
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$1(o, minLen);
9321
+ }
9322
+ function parseTupleDef(def, refs) {
9323
+ if (def.rest) {
9324
+ return {
9325
+ type: "array",
9326
+ minItems: def.items.length,
9327
+ items: def.items.map(function(x, i) {
9328
+ return parseDef(x._def, _object_spread_props$1(_object_spread$1({}, refs), {
9329
+ currentPath: _to_consumable_array$1(refs.currentPath).concat([
9330
+ "items",
9331
+ "".concat(i)
9332
+ ])
9333
+ }));
9334
+ }).reduce(function(acc, x) {
9335
+ return x === undefined ? acc : _to_consumable_array$1(acc).concat([
9336
+ x
9337
+ ]);
9338
+ }, []),
9339
+ additionalItems: parseDef(def.rest._def, _object_spread_props$1(_object_spread$1({}, refs), {
9340
+ currentPath: _to_consumable_array$1(refs.currentPath).concat([
9341
+ "additionalItems"
9342
+ ])
9343
+ }))
9344
+ };
9345
+ } else {
9346
+ return {
9347
+ type: "array",
9348
+ minItems: def.items.length,
9349
+ maxItems: def.items.length,
9350
+ items: def.items.map(function(x, i) {
9351
+ return parseDef(x._def, _object_spread_props$1(_object_spread$1({}, refs), {
9352
+ currentPath: _to_consumable_array$1(refs.currentPath).concat([
9353
+ "items",
9354
+ "".concat(i)
9355
+ ])
9356
+ }));
9357
+ }).reduce(function(acc, x) {
9358
+ return x === undefined ? acc : _to_consumable_array$1(acc).concat([
9359
+ x
9360
+ ]);
9361
+ }, [])
9362
+ };
9363
+ }
9364
+ }
9365
+
9366
+ function parseUndefinedDef(refs) {
9367
+ return {
9368
+ not: parseAnyDef(refs)
9369
+ };
9370
+ }
9371
+
9372
+ function parseUnknownDef(refs) {
9373
+ return parseAnyDef(refs);
9374
+ }
9375
+
9376
+ var parseReadonlyDef = function(def, refs) {
9377
+ return parseDef(def.innerType._def, refs);
9378
+ };
9379
+
9380
+ var selectParser = function(def, typeName, refs) {
9381
+ switch(typeName){
9382
+ case ZodFirstPartyTypeKind.ZodString:
9383
+ return parseStringDef(def, refs);
9384
+ case ZodFirstPartyTypeKind.ZodNumber:
9385
+ return parseNumberDef(def, refs);
9386
+ case ZodFirstPartyTypeKind.ZodObject:
9387
+ return parseObjectDef(def, refs);
9388
+ case ZodFirstPartyTypeKind.ZodBigInt:
9389
+ return parseBigintDef(def, refs);
9390
+ case ZodFirstPartyTypeKind.ZodBoolean:
9391
+ return parseBooleanDef();
9392
+ case ZodFirstPartyTypeKind.ZodDate:
9393
+ return parseDateDef(def, refs);
9394
+ case ZodFirstPartyTypeKind.ZodUndefined:
9395
+ return parseUndefinedDef(refs);
9396
+ case ZodFirstPartyTypeKind.ZodNull:
9397
+ return parseNullDef(refs);
9398
+ case ZodFirstPartyTypeKind.ZodArray:
9399
+ return parseArrayDef(def, refs);
9400
+ case ZodFirstPartyTypeKind.ZodUnion:
9401
+ case ZodFirstPartyTypeKind.ZodDiscriminatedUnion:
9402
+ return parseUnionDef(def, refs);
9403
+ case ZodFirstPartyTypeKind.ZodIntersection:
9404
+ return parseIntersectionDef(def, refs);
9405
+ case ZodFirstPartyTypeKind.ZodTuple:
9406
+ return parseTupleDef(def, refs);
9407
+ case ZodFirstPartyTypeKind.ZodRecord:
9408
+ return parseRecordDef(def, refs);
9409
+ case ZodFirstPartyTypeKind.ZodLiteral:
9410
+ return parseLiteralDef(def, refs);
9411
+ case ZodFirstPartyTypeKind.ZodEnum:
9412
+ return parseEnumDef(def);
9413
+ case ZodFirstPartyTypeKind.ZodNativeEnum:
9414
+ return parseNativeEnumDef(def);
9415
+ case ZodFirstPartyTypeKind.ZodNullable:
9416
+ return parseNullableDef(def, refs);
9417
+ case ZodFirstPartyTypeKind.ZodOptional:
9418
+ return parseOptionalDef(def, refs);
9419
+ case ZodFirstPartyTypeKind.ZodMap:
9420
+ return parseMapDef(def, refs);
9421
+ case ZodFirstPartyTypeKind.ZodSet:
9422
+ return parseSetDef(def, refs);
9423
+ case ZodFirstPartyTypeKind.ZodLazy:
9424
+ return function() {
9425
+ return def.getter()._def;
9426
+ };
9427
+ case ZodFirstPartyTypeKind.ZodPromise:
9428
+ return parsePromiseDef(def, refs);
9429
+ case ZodFirstPartyTypeKind.ZodNaN:
9430
+ case ZodFirstPartyTypeKind.ZodNever:
9431
+ return parseNeverDef(refs);
9432
+ case ZodFirstPartyTypeKind.ZodEffects:
9433
+ return parseEffectsDef(def, refs);
9434
+ case ZodFirstPartyTypeKind.ZodAny:
9435
+ return parseAnyDef(refs);
9436
+ case ZodFirstPartyTypeKind.ZodUnknown:
9437
+ return parseUnknownDef(refs);
9438
+ case ZodFirstPartyTypeKind.ZodDefault:
9439
+ return parseDefaultDef(def, refs);
9440
+ case ZodFirstPartyTypeKind.ZodBranded:
9441
+ return parseBrandedDef(def, refs);
9442
+ case ZodFirstPartyTypeKind.ZodReadonly:
9443
+ return parseReadonlyDef(def, refs);
9444
+ case ZodFirstPartyTypeKind.ZodCatch:
9445
+ return parseCatchDef(def, refs);
9446
+ case ZodFirstPartyTypeKind.ZodPipeline:
9447
+ return parsePipelineDef(def, refs);
9448
+ case ZodFirstPartyTypeKind.ZodFunction:
9449
+ case ZodFirstPartyTypeKind.ZodVoid:
9450
+ case ZodFirstPartyTypeKind.ZodSymbol:
9451
+ return undefined;
9452
+ default:
9453
+ return function(_) {
9454
+ return undefined;
9455
+ }();
9456
+ }
9457
+ };
9458
+
9459
+ function parseDef(def, refs) {
9460
+ var forceResolution = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false;
9461
+ var seenItem = refs.seen.get(def);
9462
+ if (refs.override) {
9463
+ var _refs_override;
9464
+ var overrideResult = (_refs_override = refs.override) === null || _refs_override === void 0 ? void 0 : _refs_override.call(refs, def, refs, seenItem, forceResolution);
9465
+ if (overrideResult !== ignoreOverride) {
9466
+ return overrideResult;
9467
+ }
9468
+ }
9469
+ if (seenItem && !forceResolution) {
9470
+ var seenSchema = get$ref(seenItem, refs);
9471
+ if (seenSchema !== undefined) {
9472
+ return seenSchema;
9473
+ }
9474
+ }
9475
+ var newItem = {
9476
+ def: def,
9477
+ path: refs.currentPath,
9478
+ jsonSchema: undefined
9479
+ };
9480
+ refs.seen.set(def, newItem);
9481
+ var jsonSchemaOrGetter = selectParser(def, def.typeName, refs);
9482
+ // If the return was a function, then the inner definition needs to be extracted before a call to parseDef (recursive)
9483
+ var jsonSchema = typeof jsonSchemaOrGetter === "function" ? parseDef(jsonSchemaOrGetter(), refs) : jsonSchemaOrGetter;
9484
+ if (jsonSchema) {
9485
+ addMeta(def, refs, jsonSchema);
9486
+ }
9487
+ if (refs.postProcess) {
9488
+ var postProcessResult = refs.postProcess(jsonSchema, def, refs);
9489
+ newItem.jsonSchema = jsonSchema;
9490
+ return postProcessResult;
9491
+ }
9492
+ newItem.jsonSchema = jsonSchema;
9493
+ return jsonSchema;
9494
+ }
9495
+ var get$ref = function(item, refs) {
9496
+ switch(refs.$refStrategy){
9497
+ case "root":
9498
+ return {
9499
+ $ref: item.path.join("/")
9500
+ };
9501
+ case "relative":
9502
+ return {
9503
+ $ref: getRelativePath(refs.currentPath, item.path)
9504
+ };
9505
+ case "none":
9506
+ case "seen":
9507
+ {
9508
+ if (item.path.length < refs.currentPath.length && item.path.every(function(value, index) {
9509
+ return refs.currentPath[index] === value;
9510
+ })) {
9511
+ console.warn("Recursive reference detected at ".concat(refs.currentPath.join("/"), "! Defaulting to any"));
9512
+ return parseAnyDef(refs);
9513
+ }
9514
+ return refs.$refStrategy === "seen" ? parseAnyDef(refs) : undefined;
9515
+ }
9516
+ }
9517
+ };
9518
+ var addMeta = function(def, refs, jsonSchema) {
9519
+ if (def.description) {
9520
+ jsonSchema.description = def.description;
9521
+ if (refs.markdownDescription) {
9522
+ jsonSchema.markdownDescription = def.description;
9523
+ }
9524
+ }
9525
+ return jsonSchema;
9526
+ };
9527
+
9528
+ function _array_like_to_array(arr, len) {
9529
+ if (len == null || len > arr.length) len = arr.length;
9530
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
9531
+ return arr2;
9532
+ }
9533
+ function _array_without_holes(arr) {
9534
+ if (Array.isArray(arr)) return _array_like_to_array(arr);
9535
+ }
9536
+ function _define_property(obj, key, value) {
9537
+ if (key in obj) {
9538
+ Object.defineProperty(obj, key, {
9539
+ value: value,
9540
+ enumerable: true,
9541
+ configurable: true,
9542
+ writable: true
9543
+ });
9544
+ } else {
9545
+ obj[key] = value;
9546
+ }
9547
+ return obj;
9548
+ }
9549
+ function _iterable_to_array(iter) {
9550
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
9551
+ }
9552
+ function _non_iterable_spread() {
9553
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
9554
+ }
9555
+ function _object_spread(target) {
9556
+ for(var i = 1; i < arguments.length; i++){
9557
+ var source = arguments[i] != null ? arguments[i] : {};
9558
+ var ownKeys = Object.keys(source);
9559
+ if (typeof Object.getOwnPropertySymbols === "function") {
9560
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
9561
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
9562
+ }));
9563
+ }
9564
+ ownKeys.forEach(function(key) {
9565
+ _define_property(target, key, source[key]);
9566
+ });
9567
+ }
9568
+ return target;
9569
+ }
9570
+ function ownKeys(object, enumerableOnly) {
9571
+ var keys = Object.keys(object);
9572
+ if (Object.getOwnPropertySymbols) {
9573
+ var symbols = Object.getOwnPropertySymbols(object);
9574
+ keys.push.apply(keys, symbols);
9575
+ }
9576
+ return keys;
9577
+ }
9578
+ function _object_spread_props(target, source) {
9579
+ source = source != null ? source : {};
9580
+ if (Object.getOwnPropertyDescriptors) {
9581
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
9582
+ } else {
9583
+ ownKeys(Object(source)).forEach(function(key) {
9584
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
9585
+ });
9586
+ }
9587
+ return target;
9588
+ }
9589
+ function _to_consumable_array(arr) {
9590
+ return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
9591
+ }
9592
+ function _unsupported_iterable_to_array(o, minLen) {
9593
+ if (!o) return;
9594
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
9595
+ var n = Object.prototype.toString.call(o).slice(8, -1);
9596
+ if (n === "Object" && o.constructor) n = o.constructor.name;
9597
+ if (n === "Map" || n === "Set") return Array.from(n);
9598
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
9599
+ }
9600
+ var zodToJsonSchema = function(schema, options) {
9601
+ var refs = getRefs(options);
9602
+ var definitions = undefined;
9603
+ var name = void 0 ;
9604
+ var _parseDef;
9605
+ var main = (_parseDef = parseDef(schema._def, refs , false)) !== null && _parseDef !== void 0 ? _parseDef : parseAnyDef(refs);
9606
+ if (refs.flags.hasReferencedOpenAiAnyType) {
9607
+ if (!definitions) {
9608
+ definitions = {};
9609
+ }
9610
+ if (!definitions[refs.openAiAnyTypeName]) {
9611
+ definitions[refs.openAiAnyTypeName] = {
9612
+ // Skipping "object" as no properties can be defined and additionalProperties must be "false"
9613
+ type: [
9614
+ "string",
9615
+ "number",
9616
+ "integer",
9617
+ "boolean",
9618
+ "array",
9619
+ "null"
9620
+ ],
9621
+ items: {
9622
+ $ref: refs.$refStrategy === "relative" ? "1" : _to_consumable_array(refs.basePath).concat([
9623
+ refs.definitionPath,
9624
+ refs.openAiAnyTypeName
9625
+ ]).join("/")
9626
+ }
9627
+ };
9628
+ }
9629
+ }
9630
+ var combined = name === undefined ? definitions ? _object_spread_props(_object_spread({}, main), _define_property({}, refs.definitionPath, definitions)) : main : _define_property({
9631
+ $ref: _to_consumable_array(refs.$refStrategy === "relative" ? [] : refs.basePath).concat([
9632
+ refs.definitionPath,
9633
+ name
9634
+ ]).join("/")
9635
+ }, refs.definitionPath, _object_spread_props(_object_spread({}, definitions), _define_property({}, name, main)));
9636
+ if (refs.target === "jsonSchema7") {
9637
+ combined.$schema = "http://json-schema.org/draft-07/schema#";
9638
+ } else if (refs.target === "jsonSchema2019-09" || refs.target === "openAi") {
9639
+ combined.$schema = "https://json-schema.org/draft/2019-09/schema#";
9640
+ }
9641
+ if (refs.target === "openAi" && ("anyOf" in combined || "oneOf" in combined || "allOf" in combined || "type" in combined && Array.isArray(combined.type))) {
9642
+ console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property.");
9643
+ }
9644
+ return combined;
9645
+ };
9646
+
9647
+ function runtimeToolProviderComponent(provider) {
9648
+ var _extensions_resources, _extensions_resourceTemplates, _extensions_prompts;
9649
+ const descriptor = describeXpertToolProvider(provider);
9650
+ const options = descriptor.options;
9651
+ const extensions = resolveXpertMcpExtensions(provider, descriptor);
9652
+ // Fingerprint declarations only; never execute resource, prompt or completion handlers.
9653
+ const capabilities = _extends({}, (extensions == null ? void 0 : (_extensions_resources = extensions.resources) == null ? void 0 : _extensions_resources.length) ? {
9654
+ resources: extensions.resources.map((_param)=>{
9655
+ var { read } = _param, definition = _object_without_properties_loose$2(_param, [
9656
+ "read"
9657
+ ]);
9658
+ return definition;
9659
+ })
9660
+ } : {}, (extensions == null ? void 0 : (_extensions_resourceTemplates = extensions.resourceTemplates) == null ? void 0 : _extensions_resourceTemplates.length) ? {
9661
+ resourceTemplates: extensions.resourceTemplates.map((_param)=>{
9662
+ var { read, complete } = _param, definition = _object_without_properties_loose$2(_param, [
9663
+ "read",
9664
+ "complete"
9665
+ ]);
9666
+ return _extends({}, definition, {
9667
+ supportsCompletion: !!complete
9668
+ });
9669
+ })
9670
+ } : {}, (extensions == null ? void 0 : (_extensions_prompts = extensions.prompts) == null ? void 0 : _extensions_prompts.length) ? {
9671
+ prompts: extensions.prompts.map((_param)=>{
9672
+ var { get, complete } = _param, definition = _object_without_properties_loose$2(_param, [
9673
+ "get",
9674
+ "complete"
9675
+ ]);
9676
+ return _extends({}, definition, {
9677
+ hasCompletionHandler: !!complete
9678
+ });
9679
+ })
9680
+ } : {});
9681
+ const tools = descriptor.tools.map((tool)=>{
9682
+ var _tool_options_title, _tool_middlewareProvider, _tool_options_mcp_visibility;
9683
+ return {
9684
+ name: tool.options.name,
9685
+ title: (_tool_options_title = tool.options.title) != null ? _tool_options_title : null,
9686
+ description: tool.options.description,
9687
+ middleware: (_tool_middlewareProvider = tool.middlewareProvider) != null ? _tool_middlewareProvider : null,
9688
+ mcp: tool.options.mcp ? _extends({}, tool.options.mcp.inputSchema ? {
9689
+ transportInputSchema: JSON.parse(JSON.stringify(zodToJsonSchema(tool.options.mcp.inputSchema)))
9690
+ } : {}, tool.options.mcp.task ? {
9691
+ task: tool.options.mcp.task
9692
+ } : {}, {
9693
+ behavior: tool.options.mcp.behavior,
9694
+ requiredContext: [
9695
+ ...tool.options.mcp.requiredContext
9696
+ ],
9697
+ visibility: [
9698
+ ...(_tool_options_mcp_visibility = tool.options.mcp.visibility) != null ? _tool_options_mcp_visibility : [
9699
+ 'model'
9700
+ ]
9701
+ ],
9702
+ inputSchema: JSON.parse(JSON.stringify(zodToJsonSchema(tool.options.inputSchema))),
9703
+ outputSchema: tool.options.outputSchema ? JSON.parse(JSON.stringify(zodToJsonSchema(tool.options.outputSchema))) : null
9704
+ }) : null
9705
+ };
9706
+ });
9707
+ var _options_description, _options_instructions;
9708
+ const config = {
9709
+ provider: options.provider,
9710
+ name: options.name,
9711
+ description: (_options_description = options.description) != null ? _options_description : null,
9712
+ instructions: (_options_instructions = options.instructions) != null ? _options_instructions : null,
9713
+ runtimeDiscovered: true,
9714
+ nativeMcp: true,
9715
+ toolCount: tools.filter((tool)=>!!tool.mcp).length
9716
+ };
9717
+ const metadata = {
9718
+ runtimeDiscovered: true,
9719
+ nativeMcp: true,
9720
+ toolNames: tools.filter((tool)=>!!tool.mcp).map((tool)=>tool.name)
9721
+ };
9722
+ return {
9723
+ componentType: PLUGIN_COMPONENT_TYPE.TOOLSET,
9724
+ componentKey: options.componentKey,
9725
+ config,
9726
+ metadata,
9727
+ definitionHash: createHash('sha256').update(stableJson(_extends({
9728
+ config,
9729
+ metadata,
9730
+ tools
9731
+ }, capabilities))).digest('hex')
9732
+ };
9733
+ }
9734
+ function stableJson(value) {
9735
+ if (value === undefined) return 'null';
9736
+ if (value === null || typeof value !== 'object') return JSON.stringify(value);
9737
+ if (Array.isArray(value)) return `[${value.map((item)=>stableJson(item)).join(',')}]`;
9738
+ const entries = Object.entries(value).sort(([left], [right])=>left.localeCompare(right));
9739
+ return `{${entries.map(([key, item])=>`${JSON.stringify(key)}:${stableJson(item)}`).join(',')}}`;
9740
+ }
9741
+
9742
+ export { ACCOUNT_BINDING_PERMISSION_SERVICE_TOKEN, AGENT_CHAT_DISPATCH_ERROR_STEER_TARGET_NOT_RUNNING, AGENT_CHAT_DISPATCH_MESSAGE_TYPE, AGENT_MIDDLEWARE_STRATEGY, AIModel, AIModelProviderNotFoundException, AIModelProviderRegistry, AIModelProviderStrategy, AI_MODEL_PROVIDER, AdapterDataSourceStrategy, AgentMiddlewareRegistry, AgentMiddlewareStrategy, AiModelNotFoundException, AssistantTaskRuntimeCapability, BOUND_IDENTITY_LOGIN_PERMISSION_SERVICE_TOKEN, BUILTIN_GLOBAL_SCOPE, BaseHTTPQueryRunner, BaseQueryRunner, BaseSQLQueryRunner, BaseSandbox, BaseStrategyRegistry, BuiltinToolset, CHAT_CHANNEL, CHAT_CHANNEL_TEXT_LIMITS, COLLABORATION_DOCUMENT_PROVIDER, CONNECTION_COMMAND_ROUTER_TOKEN, CONNECTOR_STRATEGY, CancelConversationCommand, ChatChannel, ChatChannelRegistry, ChatOAICompatReasoningModel, CollaborationDocumentProvider, CollaborationDocumentProviderRegistry, CollaborationRuntimeCapability, CommonParameterRules, ConnectorRuntimeCapability, ConnectorRuntimeFactoryCapability, ConnectorStrategyKey, ConnectorStrategyRegistry, CreateModelClientCommand, CredentialsValidateFailedError, DATASOURCE_STRATEGY, DBCreateTableMode, DBProtocolEnum, DBSyntaxEnum, DBTableAction, DBTableDataAction, DEFAULT_EXECUTION_CONFIG, DEFAULT_SANDBOX_EXECUTION_MAX_OUTPUT_BYTES, DEFAULT_SANDBOX_FILE_OPERATION_EXECUTION_OPTIONS, DEFAULT_SANDBOX_FILE_OPERATION_TIMEOUT_MS, DEFAULT_SANDBOX_FILE_OPERATION_TIMEOUT_SEC, DEFAULT_SANDBOX_FILE_SEARCH_EXECUTION_OPTIONS, DEFAULT_SANDBOX_FILE_SEARCH_TIMEOUT_MS, DEFAULT_SANDBOX_FILE_SEARCH_TIMEOUT_SEC, DEFAULT_SANDBOX_SHELL_EXECUTION_OPTIONS, DEFAULT_SANDBOX_SHELL_TIMEOUT_MS, DEFAULT_SANDBOX_SHELL_TIMEOUT_SEC, DOCUMENT_SOURCE_STRATEGY, DOCUMENT_TRANSFORMER_STRATEGY, DataSourceStrategy, DataSourceStrategyRegistry, DecoratedAgentMiddlewareStrategy, DecoratedToolsetStrategy, DocumentSourceRegistry, DocumentSourceStrategy, DocumentTransformerRegistry, DocumentTransformerStrategy, EVOLUTION_RUNTIME_SERVICE_TOKEN, EVOLUTION_TARGET_PROVIDER, EvolutionChangeRuntimeCapability, EvolutionRuntimeCapability, EvolutionTargetProviderRegistry, EvolutionTargetProviderStrategy, FILE_STORAGE_PROVIDER, FILE_UPLOAD_TARGET_STRATEGY, FileRuntimeCapability, FileStorageProvider, FileStorageProviderRegistry, FileUploadTargetRegistry, FileUploadTargetStrategy, GLOBAL_ORGANIZATION_SCOPE, HANDOFF_PERMISSION_SERVICE_TOKEN, HANDOFF_PROCESSOR_STRATEGY, HANDOFF_QUEUE_SERVICE_TOKEN, HandoffProcessorRegistry, HandoffProcessorStrategy, IMAGE_UNDERSTANDING_STRATEGY, INTEGRATION_PERMISSION_SERVICE_TOKEN, INTEGRATION_STRATEGY, ImageGenerationModel, ImageUnderstandingRegistry, ImageUnderstandingStrategy, IntegrationStrategyKey, IntegrationStrategyRegistry, JUMP_TO_TARGETS, JsonSchemaValidator, KEYWORD_ANALYZER_STRATEGY, KNOWLEDGE_STRATEGY, KeywordAnalyzerRegistry, KeywordAnalyzerStrategy, KnowledgeStrategyKey, KnowledgeStrategyRegistry, LLMUsage, LargeLanguageModel, MANAGED_CONNECTION_REGISTRY_TOKEN, MANAGED_QUEUE_HANDLER_REGISTRY_TOKEN, MANAGED_QUEUE_SERVICE_TOKEN, MCP_CAPABILITY_CHANGE_EVENT_TYPES, MODEL_OUTPUT_VALIDATION_ERROR_CODE, ModelOutputValidationError, ModelProvider, ORGANIZATION_METADATA_KEY, OpenAICompatibleReranker, PERMISSION_OPERATION_METADATA_KEY, PLUGIN_CONFIG_RESOLVER_TOKEN, PLUGIN_JOB_PROCESSOR_METADATA, PLUGIN_METADATA, PLUGIN_METADATA_KEY, PLUGIN_VERSION_METADATA_KEY, PLUGIN_WEBHOOK_AUTH_METADATA_KEY, PLUGIN_WEBHOOK_AUTH_SERVICE_TOKEN, PROVIDE_AI_MODEL_LLM, PROVIDE_AI_MODEL_MODERATION, PROVIDE_AI_MODEL_RERANK, PROVIDE_AI_MODEL_SPEECH2TEXT, PROVIDE_AI_MODEL_TEXT_EMBEDDING, PROVIDE_AI_MODEL_TTS, PluginJobProcessor, PluginWebhookAuth, PluginWebhookAuthGuard, RETRIEVER_STRATEGY, RequestContext, RequestContextMiddleware, RequirePermissionOperation, RerankModel, RetrieverRegistry, RetrieverStrategy, SANDBOX_PROVIDER, SANDBOX_RUNTIME_PROVIDER, SANDBOX_SHELL_TIMEOUT_LIMITS_SEC, SANDBOX_WORKSPACE_MAPPER, SKILL_SOURCE_PROVIDER, SPEECH_TO_TEXT_PERMISSION_SERVICE_TOKEN, SPEECH_TO_TEXT_SERVICE_TOKEN, SSOProviderRegistry, SSOProviderStrategyKey, SSO_BINDING_PERMISSION_SERVICE_TOKEN, SSO_PROVIDER, STRATEGY_META_KEY, SYSTEM_GLOBAL_SCOPE, SandboxProviderRegistry, SandboxProviderStrategy, SandboxRuntimeProviderRegistry, SandboxRuntimeProviderStrategy, SandboxWorkspaceMapperRegistry, SandboxWorkspaceMapperStrategy, SkillSourceProviderRegistry, SkillSourceProviderStrategy, Speech2TextChatModel, SpeechToTextModel, StrategyBus, TENANT_GLOBAL_SCOPE_PREFIX, TENANT_GLOBAL_SCOPE_SUFFIX, TEXT_SPLITTER_STRATEGY, TOOLSET_STRATEGY, TextEmbeddingModelManager, TextSplitterRegistry, TextSplitterStrategy, TextToSpeechModel, ToolsetRegistry, ToolsetStrategy, USER_PERMISSION_SERVICE_TOKEN, VECTOR_STORE_STRATEGY, VIDEO_GENERATION_PERMISSION_SERVICE_TOKEN, VIDEO_GENERATION_SERVICE_TOKEN, VIDEO_GENERATOR_FAMILIES, VIEW_EXTENSION_CACHE_SERVICE_TOKEN, VIEW_EXTENSION_PROVIDER, VectorStoreRegistry, VectorStoreStrategy, VideoGenerationModel, ViewExtensionProvider, ViewExtensionProviderRegistry, WORKFLOW_NODE_STRATEGY, WORKFLOW_TRIGGER_STRATEGY, WorkflowNodeRegistry, WorkflowNodeStrategy, WorkflowTriggerRegistry, WorkflowTriggerStrategy, WorkspaceFilesRuntimeCapability, WrapWorkflowNodeExecutionCommand, XPERT_AGENT_MIDDLEWARE_RUNTIME_TOKEN, XPERT_TOOL_METHOD_METADATA, XPERT_TOOL_PROVIDER, XPERT_TOOL_PROVIDER_METADATA, XPERT_TOOL_RESULT_FORMAT_VERSION, XpFileSystem, XpertPrompt, XpertResource, XpertResourceTemplate, XpertServerPlugin, XpertTool, XpertToolProvider, XpertToolProviderCoordinator, XpertToolProviderRegistry, als, appendSandboxMessage, assertConnectorDefinition, buildSandboxTimeoutMessage, calcTokenUsage, calculateLLMUsagePrice, calculateModelPrice, calculateModelUsageCharge, chunkText, countTextTokens, countTokensSafe, createI18nInstance, createPluginLogger, createRuntimeCapability, defineAgentMessageType, defineChannelMessageType, defineMcpApp, defineMcpCapabilities, defineMcpPrompt, defineMcpResource, defineMcpResourceTemplate, defineXpertTool, derivePluginArtifactNamespace, describeXpertToolProvider, downloadRemoteFile, formatSandboxTimeout, getDefaultTenantId, getErrorMessage, getModelContextSize, getPermissionOperationMetadata, getPositionList, getPositionMap, getRequestContext, getRequiredPermissionOperation, getTenantGlobalScopeKey, getXpertToolMethod, isDevelopmentSandboxRuntimeEnvironment, isModelOutputValidationError, isModelUsagePricingConfig, isRemoteFile, isSandboxBackend, isSandboxManagedServiceAdapter, isSandboxServiceProxyAdapter, isSandboxTerminalAdapter, isStrategyInstance, isStructuredMessageType, isTenantGlobalScopeKey, loadYamlFile, mergeCredentials, mergeParentChildChunks, normalizeContextSize, pluginArtifactTableName, prepareToolResult, processAsyncAIGCManagedJob, renderRemoteModuleIframeHtml, renderRemoteReactIframeHtml, renderRemoteVueIframeHtml, resolveModelUsagePricingSnapshot, resolveSandboxBackend, resolveSandboxExecutionOptions, resolveSandboxManagedServiceAdapter, resolveSandboxServiceProxyAdapter, resolveSandboxTerminalAdapter, resolveStrategyMetadataTarget, resolveTenantGlobalScopeKey, resolveTokenUsage, resolveXpertMcpExtensions, runWithRequestContext, runtimeToolProviderComponent, secondsToMilliseconds, setDefaultTenantId, sumTokenUsage, textTokenBoundaries };