@xpert-ai/plugin-sdk 3.18.5 → 3.18.6

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