{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://wahlstups.schnick-schnack.info/static/mitmachen/seed.schema.json",
  "title": "Wahlstups Seed",
  "description": "Kompletter Stammdatensatz einer Wahl für Wahlstups. Scores sind redaktionelle Einschätzungen (−2…+2) mit Quellenpflicht — kein Datensatz geht ohne menschlichen Review live.",
  "type": "object",
  "required": [
    "schema_version",
    "election",
    "parties",
    "parameters",
    "topics"
  ],
  "properties": {
    "schema_version": {
      "const": 1
    },
    "election": {
      "type": "object",
      "required": [
        "slug",
        "name"
      ],
      "properties": {
        "slug": {
          "type": "string",
          "pattern": "^[a-z0-9][a-z0-9-]{1,62}$"
        },
        "name": {
          "type": "string",
          "minLength": 1
        },
        "date": {
          "type": "string",
          "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
        },
        "region": {
          "type": "string"
        },
        "description": {
          "type": "string"
        },
        "config": {
          "type": "object",
          "properties": {
            "topics_offered": {
              "type": "integer",
              "minimum": 1
            },
            "topics_min": {
              "type": "integer",
              "minimum": 1
            },
            "topics_max": {
              "type": "integer",
              "minimum": 1
            },
            "max_param_questions": {
              "type": "integer",
              "minimum": 0
            },
            "result_ttl_days": {
              "type": "integer",
              "minimum": 1
            }
          }
        }
      }
    },
    "parties": {
      "type": "array",
      "minItems": 2,
      "items": {
        "type": "object",
        "required": [
          "key",
          "name"
        ],
        "properties": {
          "key": {
            "$ref": "#/$defs/key"
          },
          "name": {
            "type": "string",
            "minLength": 1
          },
          "long_name": {
            "type": "string"
          },
          "color": {
            "type": "string",
            "pattern": "^#[0-9a-fA-F]{6}$"
          },
          "note": {
            "type": "string"
          }
        }
      }
    },
    "parameters": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "key",
          "label",
          "question",
          "options"
        ],
        "properties": {
          "key": {
            "$ref": "#/$defs/key"
          },
          "label": {
            "type": "string",
            "minLength": 1
          },
          "question": {
            "type": "string",
            "minLength": 1
          },
          "options": {
            "type": "array",
            "minItems": 2,
            "items": {
              "type": "object",
              "required": [
                "key",
                "label"
              ],
              "properties": {
                "key": {
                  "$ref": "#/$defs/key",
                  "not": {
                    "const": "na"
                  }
                },
                "label": {
                  "type": "string",
                  "minLength": 1
                }
              }
            }
          }
        }
      }
    },
    "topics": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "required": [
          "key",
          "title",
          "rank"
        ],
        "properties": {
          "key": {
            "$ref": "#/$defs/key"
          },
          "title": {
            "type": "string",
            "minLength": 1
          },
          "teaser": {
            "type": "string",
            "description": "Genau ein prägnanter Satz, max. ~70 Zeichen — wird einzeilig angezeigt und sonst abgeschnitten."
          },
          "rank": {
            "type": "integer",
            "minimum": 1
          },
          "evidence": {
            "type": "string"
          },
          "parameters": {
            "type": "array",
            "maxItems": 4,
            "items": {
              "type": "object",
              "required": [
                "key"
              ],
              "properties": {
                "key": {
                  "$ref": "#/$defs/key"
                },
                "weight": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 3
                }
              }
            }
          },
          "positions": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "party",
                "score",
                "explanation",
                "confidence",
                "sources"
              ],
              "properties": {
                "party": {
                  "$ref": "#/$defs/key"
                },
                "score": {
                  "type": "number",
                  "minimum": -2,
                  "maximum": 2,
                  "multipleOf": 0.5,
                  "description": "Redaktionelle Einschätzung in 0,5-Schritten; innerhalb eines Themas relativ spreizen."
                },
                "explanation": {
                  "type": "string",
                  "minLength": 1
                },
                "confidence": {
                  "enum": [
                    "high",
                    "medium",
                    "low"
                  ]
                },
                "sources": {
                  "type": "array",
                  "minItems": 1,
                  "items": {
                    "type": "object",
                    "required": [
                      "url"
                    ],
                    "properties": {
                      "url": {
                        "type": "string",
                        "pattern": "^https?://"
                      },
                      "title": {
                        "type": "string"
                      },
                      "note": {
                        "type": "string"
                      }
                    }
                  }
                },
                "modifiers": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "required": [
                      "parameter",
                      "option",
                      "delta"
                    ],
                    "properties": {
                      "parameter": {
                        "$ref": "#/$defs/key"
                      },
                      "option": {
                        "$ref": "#/$defs/key"
                      },
                      "delta": {
                        "type": "number",
                        "minimum": -2,
                        "maximum": 2,
                        "multipleOf": 0.5
                      },
                      "note": {
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "$defs": {
    "key": {
      "type": "string",
      "pattern": "^[a-z0-9][a-z0-9_]{0,46}$"
    }
  }
}