{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "tg4.today.v1.schema.json",
  "title": "TG4 Today (tg4.today.v1)",
  "description": "Snapshot of all 11 Malaysian 4D operator results for a single draw date.",
  "type": "object",
  "required": [
    "schema",
    "license",
    "source",
    "generated_at",
    "draw_date",
    "operators"
  ],
  "properties": {
    "schema": {
      "const": "tg4.today.v1"
    },
    "license": {
      "const": "CC0-1.0"
    },
    "source": {
      "type": "string",
      "format": "uri"
    },
    "generated_at": {
      "type": "string",
      "format": "date-time"
    },
    "draw_date": {
      "type": "string"
    },
    "status": {
      "type": [
        "string",
        "null"
      ]
    },
    "updated": {
      "type": [
        "string",
        "null"
      ]
    },
    "operators": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "slug",
          "name",
          "state"
        ],
        "properties": {
          "slug": {
            "type": "string",
            "pattern": "^[a-z0-9-]+$"
          },
          "name": {
            "type": "string"
          },
          "state": {
            "type": "string",
            "enum": [
              "Final",
              "Live",
              "Updating",
              "Waiting",
              "Corrected"
            ]
          },
          "first": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^[0-9]{4}$|^$"
          },
          "second": {
            "type": [
              "string",
              "null"
            ]
          },
          "third": {
            "type": [
              "string",
              "null"
            ]
          },
          "special": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "consolation": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "draw_days": {
            "type": [
              "string",
              "null"
            ]
          },
          "est_jackpot": {
            "type": [
              "string",
              "null"
            ]
          },
          "source": {
            "type": [
              "string",
              "null"
            ]
          },
          "draw_date": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$|^$"
          },
          "draw_date_pretty": {
            "type": [
              "string",
              "null"
            ]
          },
          "draw_session": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "main",
              "afternoon",
              "evening",
              null
            ]
          },
          "livePhase": {
            "type": [
              "string",
              "null"
            ]
          },
          "specialPool": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "specialSlots": {
            "type": "array",
            "items": {
              "type": [
                "string",
                "null"
              ]
            }
          },
          "top3Slots": {
            "type": "array",
            "items": {
              "type": [
                "string",
                "null"
              ]
            },
            "minItems": 3,
            "maxItems": 3
          },
          "consolationSlots": {
            "type": "array",
            "items": {
              "type": [
                "string",
                "null"
              ]
            },
            "minItems": 10,
            "maxItems": 10
          },
          "sessions": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "session"
              ],
              "properties": {
                "session": {
                  "type": "string",
                  "enum": [
                    "afternoon",
                    "evening"
                  ]
                },
                "time": {
                  "type": "string"
                },
                "state": {
                  "type": "string"
                },
                "livePhase": {
                  "type": "string"
                },
                "draw_date": {
                  "type": "string",
                  "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
                },
                "draw_date_pretty": {
                  "type": "string"
                },
                "first": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "second": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "third": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "special": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                "specialPool": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                "specialSlots": {
                  "type": "array",
                  "items": {
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                },
                "top3Slots": {
                  "type": "array",
                  "items": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "minItems": 3,
                  "maxItems": 3
                },
                "consolation": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                "consolationSlots": {
                  "type": "array",
                  "items": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "minItems": 10,
                  "maxItems": 10
                }
              }
            }
          }
        }
      }
    },
    "next_special_draw": {
      "type": "object",
      "properties": {
        "date": {
          "type": "string",
          "format": "date-time"
        },
        "label": {
          "type": "string"
        },
        "operator": {
          "type": "string"
        }
      }
    },
    "lunar": {
      "type": "object",
      "properties": {
        "date": {
          "type": "string"
        },
        "lunar_short": {
          "type": "string"
        },
        "lunar_long": {
          "type": "string"
        },
        "zodiac": {
          "type": "string"
        },
        "zodiac_emoji": {
          "type": "string"
        },
        "lucky_digits": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      }
    }
  }
}