{
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "$id": "https://audoryx.local/schemas/theme-v3.json",
    "title": "Audoryx Theme Manifest",
    "type": "object",
    "additionalProperties": false,
    "required": ["schema_version", "key", "name", "version", "entrypoints", "supports_frontend", "supports_dashboard"],
    "properties": {
        "schema_version": { "const": 3 },
        "key": { "type": "string", "pattern": "^[a-z0-9][a-z0-9._-]{1,63}$" },
        "name": { "type": "string", "minLength": 1, "maxLength": 120 },
        "version": { "type": "string", "pattern": "^v?[0-9]+\\.[0-9]+\\.[0-9]+(?:-[0-9A-Za-z.-]+)?$" },
        "description": { "type": "string", "minLength": 1, "maxLength": 500 },
        "author": { "type": "string", "minLength": 1, "maxLength": 120 },
        "preview": { "$ref": "#/$defs/path" },
        "entrypoints": {
            "type": "object",
            "minProperties": 1,
            "maxProperties": 2,
            "additionalProperties": false,
            "properties": {
                "frontend": { "$ref": "#/$defs/cssPath" },
                "dashboard": { "$ref": "#/$defs/cssPath" }
            }
        },
        "tokens": {
            "type": "object",
            "maxProperties": 50,
            "propertyNames": { "pattern": "^[a-z][a-z0-9_-]{0,63}$" },
            "additionalProperties": { "type": "string", "minLength": 1, "maxLength": 120 }
        },
        "pages": { "$ref": "#/$defs/overrides" },
        "components": { "$ref": "#/$defs/overrides" },
        "supports_frontend": { "type": "boolean" },
        "supports_dashboard": { "type": "boolean" }
    },
    "$defs": {
        "path": {
            "type": "string",
            "minLength": 1,
            "maxLength": 255,
            "pattern": "^(?![A-Za-z]:|/)(?!.*(?:^|/)\\.\\.(?:/|$))(?!.*//).+$"
        },
        "cssPath": {
            "allOf": [
                { "$ref": "#/$defs/path" },
                { "pattern": "\\.css$" }
            ]
        },
        "overrides": {
            "type": "object",
            "maxProperties": 100,
            "propertyNames": { "pattern": "^[A-Za-z0-9][A-Za-z0-9/_.:-]{0,119}$" },
            "additionalProperties": {
                "type": "object",
                "maxProperties": 50
            }
        }
    }
}
