/**
 * Basic LLM Chain Node - Version 1.7 - Zod Validation Schemas
 *
 * These schemas validate node configuration at runtime.
 * Use .parse() for strict validation or .safeParse() for error handling.
 *
 * Schema helpers (z, expressionSchema, etc.) are passed as parameters
 * by the schema-validator, not imported from external files.
 *
 * @generated - CommonJS JavaScript for runtime loading
 */

module.exports = function getSchema({ parameters, z, expressionSchema, stringOrExpression, numberOrExpression, booleanOrExpression, resourceLocatorValueSchema, resourceMapperValueSchema, filterValueSchema, assignmentCollectionValueSchema, iDataObjectSchema, resolveSchema, languageModelInstanceSchema, outputParserInstanceSchema }) {

  // Helper function for conditional subnode schema
  function getSubnodesSchema() {
    return z.object({
      model: z.union([languageModelInstanceSchema, z.array(languageModelInstanceSchema)]),
      outputParser: resolveSchema({ parameters, schema: outputParserInstanceSchema, required: false, displayOptions: {"show":{"hasOutputParser":[true]}}, defaults: {"hasOutputParser":false} }),
    }).strict();
  }

  // Parameters schema
  const parametersSchema = z.object({
    promptType: z.union([z.literal('auto'), z.literal('guardrails'), z.literal('define'), expressionSchema]).optional(),
    text: resolveSchema({ parameters, schema: stringOrExpression, required: false, displayOptions: {"show":{"promptType":["guardrails","auto","define"]}}, defaults: {"promptType":"auto"} }),
    hasOutputParser: z.boolean().optional(),
    needsFallback: z.boolean().optional(),
    messages: z.object({ messageValues: z.array(z.object({ type: z.union([z.literal('AIMessagePromptTemplate'), z.literal('SystemMessagePromptTemplate'), z.literal('HumanMessagePromptTemplate'), expressionSchema]).optional(), messageType: z.union([z.literal('text'), z.literal('imageBinary'), z.literal('imageUrl'), expressionSchema]).optional(), binaryImageDataKey: stringOrExpression.optional(), imageUrl: stringOrExpression.optional(), imageDetail: z.union([z.literal('auto'), z.literal('low'), z.literal('high'), expressionSchema]).optional(), message: stringOrExpression.optional() })).optional() }).optional(),
    batching: z.object({ batchSize: numberOrExpression.optional(), delayBetweenBatches: numberOrExpression.optional() }).optional(),
  });

  // Return combined config schema
  return z.object({
    parameters: parametersSchema.nullable().optional(),
    subnodes: getSubnodesSchema(),
  });
};