{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "oneOf": [
    {
      "type": "object",
      "properties": {
        "version": {
          "type": "number",
          "const": 1
        },
        "id": {
          "type": "string",
          "pattern": "^[a-z][a-z0-9_-]{0,47}$"
        },
        "game": {
          "type": "string",
          "enum": [
            "blackjack",
            "blackjack_group",
            "baccarat",
            "dice",
            "mines",
            "keno",
            "dragontower",
            "limbo",
            "plinko",
            "coinflip",
            "videopoker",
            "roulette",
            "crash",
            "slots"
          ]
        },
        "contract": {
          "type": "string",
          "pattern": "^[a-f0-9]{16}$"
        },
        "body": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        },
        "bindings": {
          "maxItems": 32,
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "slot": {
                "type": "string",
                "pattern": "^(?:control|part)\\.[a-z0-9_]{1,64}$"
              },
              "asset": {
                "type": "string",
                "pattern": "^[a-f0-9]{64}$"
              }
            },
            "required": [
              "slot",
              "asset"
            ],
            "additionalProperties": false
          }
        }
      },
      "required": [
        "version",
        "id",
        "game",
        "contract",
        "body",
        "bindings"
      ],
      "additionalProperties": false
    },
    {
      "type": "object",
      "properties": {
        "version": {
          "type": "number",
          "const": 2
        },
        "id": {
          "type": "string",
          "pattern": "^[a-z][a-z0-9_-]{0,47}$"
        },
        "game": {
          "type": "string",
          "enum": [
            "blackjack",
            "blackjack_group",
            "baccarat",
            "dice",
            "mines",
            "keno",
            "dragontower",
            "limbo",
            "plinko",
            "coinflip",
            "videopoker",
            "roulette",
            "crash",
            "slots"
          ]
        },
        "contract": {
          "type": "string",
          "pattern": "^[a-f0-9]{16}$"
        },
        "body": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        },
        "bindings": {
          "maxItems": 32,
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "slot": {
                "type": "string",
                "pattern": "^(?:control|part)\\.[a-z0-9_]{1,64}$"
              },
              "asset": {
                "type": "string",
                "pattern": "^[a-f0-9]{64}$"
              }
            },
            "required": [
              "slot",
              "asset"
            ],
            "additionalProperties": false
          }
        },
        "placements": {
          "default": [],
          "maxItems": 34,
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "target": {
                "type": "string",
                "pattern": "^(?:body|display|control\\.[a-z0-9_]{1,64})$"
              },
              "position": {
                "type": "array",
                "prefixItems": [
                  {
                    "type": "number",
                    "minimum": -4,
                    "maximum": 4
                  },
                  {
                    "type": "number",
                    "minimum": -4,
                    "maximum": 4
                  },
                  {
                    "type": "number",
                    "minimum": -4,
                    "maximum": 4
                  }
                ],
                "items": false,
                "minItems": 3,
                "maxItems": 3
              },
              "rotation": {
                "type": "array",
                "prefixItems": [
                  {
                    "type": "number",
                    "minimum": -12.566370614359172,
                    "maximum": 12.566370614359172
                  },
                  {
                    "type": "number",
                    "minimum": -12.566370614359172,
                    "maximum": 12.566370614359172
                  },
                  {
                    "type": "number",
                    "minimum": -12.566370614359172,
                    "maximum": 12.566370614359172
                  }
                ],
                "items": false,
                "minItems": 3,
                "maxItems": 3
              },
              "scale": {
                "type": "array",
                "prefixItems": [
                  {
                    "type": "number",
                    "minimum": 0.5,
                    "maximum": 2
                  },
                  {
                    "type": "number",
                    "minimum": 0.5,
                    "maximum": 2
                  },
                  {
                    "type": "number",
                    "minimum": 0.5,
                    "maximum": 2
                  }
                ],
                "items": false,
                "minItems": 3,
                "maxItems": 3
              }
            },
            "required": [
              "target",
              "position",
              "rotation",
              "scale"
            ],
            "additionalProperties": false
          }
        },
        "clips": {
          "default": [],
          "maxItems": 16,
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "target": {
                "type": "string",
                "pattern": "^(?:body|display|control\\.[a-z0-9_]{1,64})$"
              },
              "trigger": {
                "type": "string",
                "enum": [
                  "idle",
                  "result"
                ]
              },
              "durationMs": {
                "type": "integer",
                "minimum": 200,
                "maximum": 5000
              },
              "keyframes": {
                "minItems": 2,
                "maxItems": 32,
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "time": {
                      "type": "number",
                      "minimum": 0,
                      "maximum": 1
                    },
                    "position": {
                      "type": "array",
                      "prefixItems": [
                        {
                          "type": "number",
                          "minimum": -4,
                          "maximum": 4
                        },
                        {
                          "type": "number",
                          "minimum": -4,
                          "maximum": 4
                        },
                        {
                          "type": "number",
                          "minimum": -4,
                          "maximum": 4
                        }
                      ],
                      "items": false,
                      "minItems": 3,
                      "maxItems": 3
                    },
                    "rotation": {
                      "type": "array",
                      "prefixItems": [
                        {
                          "type": "number",
                          "minimum": -12.566370614359172,
                          "maximum": 12.566370614359172
                        },
                        {
                          "type": "number",
                          "minimum": -12.566370614359172,
                          "maximum": 12.566370614359172
                        },
                        {
                          "type": "number",
                          "minimum": -12.566370614359172,
                          "maximum": 12.566370614359172
                        }
                      ],
                      "items": false,
                      "minItems": 3,
                      "maxItems": 3
                    },
                    "scale": {
                      "type": "array",
                      "prefixItems": [
                        {
                          "type": "number",
                          "minimum": 0.5,
                          "maximum": 2
                        },
                        {
                          "type": "number",
                          "minimum": 0.5,
                          "maximum": 2
                        },
                        {
                          "type": "number",
                          "minimum": 0.5,
                          "maximum": 2
                        }
                      ],
                      "items": false,
                      "minItems": 3,
                      "maxItems": 3
                    }
                  },
                  "required": [
                    "time",
                    "position",
                    "rotation",
                    "scale"
                  ],
                  "additionalProperties": false
                }
              }
            },
            "required": [
              "target",
              "trigger",
              "durationMs",
              "keyframes"
            ],
            "additionalProperties": false
          }
        },
        "motions": {
          "default": [],
          "maxItems": 4,
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "channel": {
                "type": "string",
                "enum": [
                  "card_deal",
                  "card_flip",
                  "coin_flip",
                  "plinko_drop"
                ]
              },
              "keyframes": {
                "minItems": 2,
                "maxItems": 32,
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "time": {
                      "type": "number",
                      "minimum": 0,
                      "maximum": 1
                    },
                    "progress": {
                      "type": "number",
                      "minimum": 0,
                      "maximum": 1
                    },
                    "position": {
                      "type": "array",
                      "prefixItems": [
                        {
                          "type": "number",
                          "minimum": -2,
                          "maximum": 2
                        },
                        {
                          "type": "number",
                          "minimum": -2,
                          "maximum": 2
                        },
                        {
                          "type": "number",
                          "minimum": -2,
                          "maximum": 2
                        }
                      ],
                      "items": false,
                      "minItems": 3,
                      "maxItems": 3
                    },
                    "rotation": {
                      "type": "array",
                      "prefixItems": [
                        {
                          "type": "number",
                          "minimum": -25.132741228718345,
                          "maximum": 25.132741228718345
                        },
                        {
                          "type": "number",
                          "minimum": -25.132741228718345,
                          "maximum": 25.132741228718345
                        },
                        {
                          "type": "number",
                          "minimum": -25.132741228718345,
                          "maximum": 25.132741228718345
                        }
                      ],
                      "items": false,
                      "minItems": 3,
                      "maxItems": 3
                    }
                  },
                  "required": [
                    "time",
                    "progress",
                    "position",
                    "rotation"
                  ],
                  "additionalProperties": false
                }
              }
            },
            "required": [
              "channel",
              "keyframes"
            ],
            "additionalProperties": false
          }
        }
      },
      "required": [
        "version",
        "id",
        "game",
        "contract",
        "body",
        "bindings",
        "placements",
        "clips",
        "motions"
      ],
      "additionalProperties": false
    }
  ]
}
