{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://recit.dev/schema/v1/docs.json",
  "x-recit-stability": "preview",
  "type": "object",
  "properties": {
    "$schema": {
      "type": "string"
    },
    "kind": {
      "type": "string",
      "const": "story"
    },
    "version": {
      "type": "number",
      "const": 1
    },
    "syntax": {
      "type": "string",
      "enum": [
        "md",
        "mdx"
      ]
    },
    "preamble": {
      "type": "string"
    },
    "meta": {
      "type": "object",
      "properties": {
        "title": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "object",
              "propertyNames": {
                "type": "string"
              },
              "additionalProperties": {
                "type": "string"
              }
            }
          ]
        },
        "subtitle": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "object",
              "propertyNames": {
                "type": "string"
              },
              "additionalProperties": {
                "type": "string"
              }
            }
          ]
        },
        "description": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "object",
              "propertyNames": {
                "type": "string"
              },
              "additionalProperties": {
                "type": "string"
              }
            }
          ]
        },
        "author": {
          "type": "string"
        },
        "date": {
          "type": "string"
        },
        "lang": {
          "type": "string"
        },
        "duration": {
          "anyOf": [
            {
              "type": "number",
              "exclusiveMinimum": 0
            },
            {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "object",
                  "propertyNames": {
                    "type": "string"
                  },
                  "additionalProperties": {
                    "type": "string"
                  }
                }
              ]
            }
          ],
          "description": "Duration of the story: minutes as a positive number, or a short text (optionally per language)."
        },
        "audience": {
          "description": "Target audience of the story (string or per-language map).",
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "object",
              "propertyNames": {
                "type": "string"
              },
              "additionalProperties": {
                "type": "string"
              }
            }
          ]
        },
        "level": {
          "type": "string",
          "enum": [
            "flash",
            "talk",
            "deep-dive"
          ],
          "description": "Format or depth level of the story: flash, talk, or deep-dive."
        }
      },
      "additionalProperties": false
    },
    "data": {
      "type": "object",
      "propertyNames": {
        "type": "string",
        "pattern": "^[a-z][a-z0-9_-]*$"
      },
      "additionalProperties": {
        "anyOf": [
          {
            "type": "string",
            "minLength": 1
          },
          {
            "type": "object",
            "properties": {
              "src": {
                "type": "string",
                "minLength": 1
              },
              "format": {
                "type": "string",
                "enum": [
                  "csv",
                  "json",
                  "yaml"
                ]
              },
              "columns": {
                "type": "object",
                "propertyNames": {
                  "type": "string"
                },
                "additionalProperties": {
                  "type": "string",
                  "enum": [
                    "string",
                    "number",
                    "date",
                    "boolean"
                  ]
                }
              }
            },
            "required": [
              "src"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "rows": {
                "type": "array",
                "items": {
                  "type": "object",
                  "propertyNames": {
                    "type": "string"
                  },
                  "additionalProperties": {
                    "type": [
                      "string",
                      "number",
                      "boolean",
                      "null"
                    ]
                  }
                }
              },
              "columns": {
                "type": "object",
                "propertyNames": {
                  "type": "string"
                },
                "additionalProperties": {
                  "type": "string",
                  "enum": [
                    "string",
                    "number",
                    "date",
                    "boolean"
                  ]
                }
              },
              "meta": {
                "type": "object",
                "properties": {
                  "title": {
                    "type": "string",
                    "description": "Title of the dataset (DCAT `title`)."
                  },
                  "url": {
                    "type": "string",
                    "format": "uri",
                    "description": "HTTP or HTTPS address of the dataset (`https:` or `http:`)."
                  },
                  "publisher": {
                    "type": "string",
                    "description": "Organisation or author publishing the dataset (DCAT `publisher`)."
                  },
                  "license": {
                    "type": "string",
                    "description": "Name or URL of the dataset's license (DCAT `license`)."
                  },
                  "modified": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "date",
                        "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$"
                      },
                      {
                        "type": "string",
                        "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d))|(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?)$"
                      }
                    ],
                    "description": "Last modification date (`YYYY-MM-DD`) or ISO 8601 date-time (DCAT `modified`)."
                  }
                },
                "additionalProperties": false,
                "description": "Provenance metadata of a data source (DCAT field names), used by `::chart` when `source=` is omitted."
              }
            },
            "required": [
              "rows"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "chart": {
                "type": "string",
                "minLength": 1
              }
            },
            "required": [
              "chart"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "source": {
                "type": "string",
                "pattern": "^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$"
              }
            },
            "required": [
              "source"
            ],
            "additionalProperties": {},
            "x-recit-stability": "stable",
            "description": "A data source of a Récit plugin: its other keys are checked by the plugin."
          }
        ]
      }
    },
    "format": {
      "type": "string",
      "const": "docs"
    },
    "settings": {
      "type": "object",
      "properties": {
        "forms": {
          "type": "object",
          "properties": {
            "endpoint": {
              "type": "string",
              "minLength": 1
            },
            "contract": {
              "type": "string",
              "enum": [
                "recit",
                "openapi",
                "formspree"
              ]
            },
            "submit": {
              "type": "string",
              "enum": [
                "fetch",
                "native",
                "mock"
              ]
            },
            "encoding": {
              "type": "string",
              "enum": [
                "form",
                "json"
              ]
            },
            "antispam": {
              "type": "string",
              "enum": [
                "honeypot",
                "turnstile",
                "none"
              ]
            },
            "auth": {
              "type": "string",
              "enum": [
                "none",
                "publishable-key",
                "bearer"
              ]
            },
            "publishableKey": {
              "type": "string",
              "minLength": 1
            },
            "turnstileSiteKey": {
              "type": "string",
              "minLength": 1
            },
            "privacy": {
              "type": "string",
              "minLength": 1
            },
            "retention": {
              "type": "integer",
              "minimum": 1,
              "maximum": 3650
            },
            "upload": {
              "type": "string",
              "enum": [
                "multipart",
                "presigned"
              ]
            }
          },
          "additionalProperties": false
        }
      },
      "additionalProperties": {}
    },
    "scenes": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1
          },
          "attrs": {
            "type": "object",
            "propertyNames": {
              "type": "string"
            },
            "additionalProperties": {
              "type": [
                "string",
                "number",
                "boolean"
              ]
            }
          },
          "body": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "object",
                "propertyNames": {
                  "type": "string"
                },
                "additionalProperties": {
                  "type": "string"
                }
              }
            ]
          },
          "notes": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "object",
                "propertyNames": {
                  "type": "string"
                },
                "additionalProperties": {
                  "type": "string"
                }
              }
            ]
          },
          "title": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "object",
                "propertyNames": {
                  "type": "string"
                },
                "additionalProperties": {
                  "type": "string"
                }
              }
            ]
          },
          "sidebar": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "object",
                "properties": {
                  "label": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "object",
                        "propertyNames": {
                          "type": "string"
                        },
                        "additionalProperties": {
                          "type": "string"
                        }
                      }
                    ]
                  },
                  "order": {
                    "type": "number"
                  }
                },
                "additionalProperties": false
              }
            ]
          }
        },
        "required": [
          "id"
        ],
        "additionalProperties": false
      }
    }
  },
  "required": [
    "kind",
    "version",
    "meta",
    "format",
    "scenes"
  ],
  "additionalProperties": false
}
