{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/ostrov-center/json-schema/ostrov-center-save-estimate-request-schema.json",
  "title": "SaveEstimateRequest",
  "x-generated": "2026-11-20",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/ostrov-center-openapi.yml#/components/schemas/SaveEstimateRequest",
  "type": "object",
  "properties": {
    "kind": {
      "type": "string",
      "enum": [
        "group",
        "biggroup",
        "resident"
      ]
    },
    "plan": {
      "oneOf": [
        {
          "$ref": "#/$defs/SavedGroupPlan"
        },
        {
          "$ref": "#/$defs/SavedResidentPlan"
        }
      ]
    },
    "catalogVersion": {
      "type": "integer",
      "minimum": 1,
      "maximum": 1000000000
    },
    "requestKey": {
      "type": "string",
      "pattern": "^[A-Za-z0-9._:-]{16,120}$",
      "description": "Unique key for one intended write; reuse exactly after an uncertain result. Use a new key for changed input."
    },
    "userConfirmed": {
      "type": "boolean",
      "const": true,
      "description": "Set only after the person explicitly requests this action."
    }
  },
  "required": [
    "kind",
    "plan",
    "catalogVersion",
    "requestKey",
    "userConfirmed"
  ],
  "additionalProperties": false,
  "$defs": {
    "SavedGroupPlan": {
      "type": "object",
      "properties": {
        "arrival": {
          "type": "string",
          "format": "date",
          "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
        },
        "departure": {
          "type": "string",
          "format": "date",
          "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
        },
        "adults": {
          "type": "integer",
          "minimum": 0,
          "maximum": 100
        },
        "youngChildrenAges": {
          "type": "array",
          "maxItems": 30,
          "items": {
            "type": "integer",
            "minimum": 0,
            "maximum": 5
          },
          "description": "Information only; does not change any guest count, accommodation, food or price."
        },
        "policyVersion": {
          "type": "integer",
          "const": 4
        },
        "teens": {
          "type": "integer",
          "minimum": 0,
          "maximum": 100,
          "description": "Children eligible for the child discount (currently 6–12). Despite the field name, full-rate children (currently 13+) belong in adults. Check the live catalogue."
        },
        "team": {
          "type": "integer",
          "minimum": 0,
          "maximum": 100,
          "description": "Adult organizers and team, separate from participants. Ordinary tariff charges the team fully; all-inclusive benefits are calculated by the server."
        },
        "youngChildren": {
          "type": "integer",
          "const": 0,
          "description": "Legacy counter kept at zero; use youngChildrenAges for information."
        },
        "organizer": {
          "type": "string",
          "maxLength": 100,
          "description": "Display name; required and nonempty when saving.",
          "minLength": 1
        },
        "title": {
          "type": "string",
          "maxLength": 150,
          "description": "Retreat name; required and nonempty when saving.",
          "minLength": 1
        },
        "housing": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "resource": {
                "type": "string",
                "maxLength": 100
              },
              "occupancy": {
                "type": "integer",
                "minimum": 1,
                "maximum": 3
              },
              "quantity": {
                "type": "integer",
                "minimum": 1,
                "maximum": 100
              }
            },
            "required": [
              "resource",
              "occupancy",
              "quantity"
            ],
            "additionalProperties": false
          },
          "maxItems": 100
        },
        "activities": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "resource": {
                "type": "string",
                "maxLength": 100
              },
              "day": {
                "type": "integer",
                "minimum": 0,
                "maximum": 364
              },
              "slot": {
                "type": "string",
                "maxLength": 100
              },
              "options": {
                "type": "array",
                "items": {
                  "type": "string",
                  "maxLength": 100
                },
                "maxItems": 20
              }
            },
            "required": [
              "resource",
              "day",
              "slot",
              "options"
            ],
            "additionalProperties": false
          },
          "maxItems": 2000
        },
        "food": {
          "type": "boolean"
        }
      },
      "required": [
        "policyVersion",
        "arrival",
        "departure",
        "adults",
        "teens",
        "team",
        "housing",
        "activities",
        "food",
        "organizer",
        "title"
      ],
      "additionalProperties": false
    },
    "SavedResidentPlan": {
      "type": "object",
      "properties": {
        "arrival": {
          "type": "string",
          "format": "date",
          "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
        },
        "departure": {
          "type": "string",
          "format": "date",
          "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
        },
        "adults": {
          "type": "integer",
          "minimum": 1,
          "maximum": 20
        },
        "youngChildrenAges": {
          "type": "array",
          "maxItems": 30,
          "items": {
            "type": "integer",
            "minimum": 0,
            "maximum": 5
          },
          "description": "Information only; does not change any guest count, accommodation, food or price."
        },
        "name": {
          "type": "string",
          "maxLength": 100,
          "description": "Required and nonempty when saving.",
          "minLength": 1
        },
        "children": {
          "type": "array",
          "maxItems": 20,
          "items": {
            "type": "integer",
            "minimum": 6,
            "maximum": 17
          },
          "description": "Children counted in accommodation; current rules permit ages 6–17. Put younger ages in youngChildrenAges."
        },
        "housing": {
          "type": "array",
          "minItems": 1,
          "maxItems": 30,
          "items": {
            "type": "object",
            "properties": {
              "resource": {
                "type": "string",
                "maxLength": 100
              },
              "occupancy": {
                "type": "integer",
                "minimum": 1,
                "maximum": 3
              }
            },
            "required": [
              "resource",
              "occupancy"
            ],
            "additionalProperties": false
          }
        },
        "bathVisits": {
          "type": "integer",
          "minimum": 0,
          "maximum": 100
        }
      },
      "required": [
        "arrival",
        "departure",
        "adults",
        "children",
        "housing",
        "bathVisits",
        "name"
      ],
      "additionalProperties": false
    }
  }
}