{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://docs.lumio.vision/schemas/cockpit/v1.json",
  "title": "Lumio Cockpit document, version 1",
  "description": "Payload of a saved `cockpit` setting preset and of a Cockpit export code or file. Readers ignore unknown keys inside a section and keep them when they write the section back.",
  "type": "object",
  "required": ["format", "version", "layout"],
  "additionalProperties": false,
  "properties": {
    "format": { "const": "lumio.cockpit" },
    "version": { "const": 1 },
    "name": {
      "type": "string",
      "description": "Preset name. Present only in an export code or file; a stored preset keeps its name on the setting-preset row."
    },
    "layout": {
      "type": "object",
      "required": ["root"],
      "properties": {
        "root": { "$ref": "#/$defs/layoutNode" },
        "gap": { "enum": ["none", "tight", "normal"] }
      }
    },
    "chat": { "$ref": "#/$defs/displaySection" },
    "events": { "$ref": "#/$defs/displaySection" },
    "music": { "$ref": "#/$defs/displaySection" },
    "chatters": { "$ref": "#/$defs/displaySection" }
  },
  "$defs": {
    "moduleId": {
      "type": "string",
      "description": "Known ids: chat, events, music, obs, test_events, chatters. Readers render any other id as an unavailable tile and keep it in the layout.",
      "examples": ["chat", "events", "music", "obs", "test_events", "chatters"]
    },
    "layoutNode": {
      "oneOf": [
        {
          "type": "object",
          "required": ["kind", "dir", "sizes", "children"],
          "properties": {
            "kind": { "const": "split" },
            "dir": { "enum": ["row", "column"] },
            "sizes": {
              "type": "array",
              "items": { "type": "number", "minimum": 0 },
              "description": "Share of each child in percent; the values add up to 100."
            },
            "children": { "type": "array", "minItems": 2, "items": { "$ref": "#/$defs/layoutNode" } }
          }
        },
        {
          "type": "object",
          "required": ["kind", "modules"],
          "properties": {
            "kind": { "const": "stack" },
            "modules": { "type": "array", "minItems": 1, "items": { "$ref": "#/$defs/moduleId" } },
            "active": { "type": "integer", "minimum": 0 }
          }
        }
      ]
    },
    "displaySection": {
      "type": "object",
      "properties": {
        "display": {
          "type": "object",
          "description": "Display preferences, keys stored verbatim in camelCase (for example fontSize, showHeader). The server does not interpret them."
        }
      }
    }
  }
}
