import { Schema } from "effect";
// ============================================================================
// Blueprint Preamble
// ============================================================================
export const BlueprintCompiler = /*#__PURE__*/Schema.Struct({
  name: Schema.String,
  version: Schema.String
});
export const BlueprintPreamble = /*#__PURE__*/Schema.Struct({
  title: Schema.String,
  description: /*#__PURE__*/Schema.optional(Schema.String),
  version: Schema.String,
  plutusVersion: /*#__PURE__*/Schema.Literal("v1", "v2", "v3"),
  compiler: /*#__PURE__*/Schema.optional(BlueprintCompiler),
  license: /*#__PURE__*/Schema.optional(Schema.String)
});
// export interface BlueprintPreamble extends Schema.Schema.Type<typeof BlueprintPreamble> {}
// ============================================================================
// Schema Definitions (JSON structure, not Effect Schema)
// ============================================================================
export const SchemaRef = /*#__PURE__*/Schema.Struct({
  $ref: Schema.String
});
export const BaseSchemaDefinition = /*#__PURE__*/Schema.Struct({
  title: /*#__PURE__*/Schema.optional(Schema.String),
  description: /*#__PURE__*/Schema.optional(Schema.String)
});
export const BytesDefinition = /*#__PURE__*/Schema.Struct({
  ...BaseSchemaDefinition.fields,
  dataType: /*#__PURE__*/Schema.Literal("bytes")
});
export const IntegerDefinition = /*#__PURE__*/Schema.Struct({
  ...BaseSchemaDefinition.fields,
  dataType: /*#__PURE__*/Schema.Literal("integer")
});
export const DataDefinition = /*#__PURE__*/Schema.Struct({
  title: /*#__PURE__*/Schema.Literal("Data"),
  description: /*#__PURE__*/Schema.optional(Schema.String)
});
export const EmptySchema = /*#__PURE__*/Schema.Struct({});
// ============================================================================
// Schema Definition Types (with proper recursive type handling)
// ============================================================================
/**
 * Constructor field with optional schema reference (recursive)
 */
export class ConstructorField extends /*#__PURE__*/Schema.Class("ConstructorField")({
  title: /*#__PURE__*/Schema.optional(Schema.String),
  description: /*#__PURE__*/Schema.optional(Schema.String),
  $ref: /*#__PURE__*/Schema.optional(Schema.String),
  schema: /*#__PURE__*/Schema.optional(/*#__PURE__*/Schema.suspend(() => SchemaDefinition))
}) {}
/**
 * Constructor definition (recursive)
 */
export class ConstructorDefinition extends /*#__PURE__*/Schema.Class("ConstructorDefinition")({
  title: /*#__PURE__*/Schema.optional(Schema.String),
  description: /*#__PURE__*/Schema.optional(Schema.String),
  dataType: /*#__PURE__*/Schema.Literal("constructor"),
  index: Schema.Number,
  fields: /*#__PURE__*/Schema.Array(/*#__PURE__*/Schema.suspend(() => ConstructorField))
}) {}
/**
 * Union/Enum definition (recursive)
 */
export class UnionDefinition extends /*#__PURE__*/Schema.Class("UnionDefinition")({
  title: /*#__PURE__*/Schema.optional(Schema.String),
  anyOf: /*#__PURE__*/Schema.Array(/*#__PURE__*/Schema.suspend(() => SchemaDefinition))
}) {}
/**
 * List definition (recursive)
 */
export class ListDefinition extends /*#__PURE__*/Schema.Class("ListDefinition")({
  title: /*#__PURE__*/Schema.optional(Schema.String),
  description: /*#__PURE__*/Schema.optional(Schema.String),
  dataType: /*#__PURE__*/Schema.Literal("list"),
  items: /*#__PURE__*/Schema.Union(/*#__PURE__*/Schema.suspend(() => SchemaDefinition), SchemaRef)
}) {}
/**
 * Map definition (recursive)
 */
export class MapDefinition extends /*#__PURE__*/Schema.Class("MapDefinition")({
  title: /*#__PURE__*/Schema.optional(Schema.String),
  description: /*#__PURE__*/Schema.optional(Schema.String),
  dataType: /*#__PURE__*/Schema.Literal("map"),
  keys: /*#__PURE__*/Schema.Union(/*#__PURE__*/Schema.suspend(() => SchemaDefinition), SchemaRef),
  values: /*#__PURE__*/Schema.Union(/*#__PURE__*/Schema.suspend(() => SchemaDefinition), SchemaRef)
}) {}
export const SchemaDefinition = /*#__PURE__*/Schema.Union(BytesDefinition, IntegerDefinition, ConstructorDefinition, UnionDefinition, DataDefinition, SchemaRef, EmptySchema, ListDefinition, MapDefinition);
// ============================================================================
// Validator Definitions
// ============================================================================
export const ParameterSchema = /*#__PURE__*/Schema.Struct({
  title: /*#__PURE__*/Schema.optional(Schema.String),
  schema: SchemaDefinition
});
export const ValidatorDefinition = /*#__PURE__*/Schema.Struct({
  title: Schema.String,
  description: /*#__PURE__*/Schema.optional(Schema.String),
  datum: /*#__PURE__*/Schema.optional(ParameterSchema),
  redeemer: /*#__PURE__*/Schema.optional(ParameterSchema),
  parameters: /*#__PURE__*/Schema.optional(/*#__PURE__*/Schema.Array(ParameterSchema)),
  compiledCode: Schema.String,
  hash: Schema.String
});
// ============================================================================
// Complete Blueprint
// ============================================================================
export const PlutusBlueprint = /*#__PURE__*/Schema.Struct({
  preamble: BlueprintPreamble,
  validators: /*#__PURE__*/Schema.Array(ValidatorDefinition),
  definitions: /*#__PURE__*/Schema.Record({
    key: Schema.String,
    value: SchemaDefinition
  })
});
//# sourceMappingURL=Types.js.map