{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "type": "object",
    "additionalProperties": false,
    "properties": {
        "header": {
            "$ref": "#/definitions/Header",
            "description": "Nagłówek zawierający metadane paragonu"
        },
        "stat": {
            "$ref": "#/definitions/Stat",
            "description": "Dane statystyczne"
        },
        "content": {
            "type": "array",
            "items": {
                "$ref": "#/definitions/Content",
                "description": "Dane"
            }
        }
    },
    "required": [
        "content",
        "header"
    ],
    "definitions": {
        "Header": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
                "version": {
                    "type": "string",
                    "minLength": 25,
                    "maxLength": 25,
                    "pattern": "^JPK_KASA_PARAGON_INF_v1-0$",
                    "description": "Nazwa i oznaczenie wersji schematu dodatkowych treści paragonu"
                },
                "reference": {
                    "$ref": "#/definitions/Reference"
                }
            },
            "required": [                
                "version",
                "reference"
            ],
            "title": "Header"
        },
        "Reference": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
                "nrUnik": {
                    "type": "string",
                    "minLength": 13,
                    "maxLength": 13,
					"pattern": "^[A-Z]{3}[0-9]{10}$",
                    "description": "Numer unikatowy kasy w postaci: XXXYYYYYYYYYY X-Litery duże, Y cyfry."
                },
                "JPKID": {
                    "type": "string",
                    "minLength": 18,
                    "maxLength": 18,
                    "pattern": "^[0-9]+$",
                    "description": "Identyfikator paragonu zawierający trzycyfrowy numer pamięci chronionej i jego piętnastocyfrowy JPKID"
                }
            },
            "required": [
                "JPKID",
                "nrUnik"
            ],
            "title": "Reference"
        },
        "Stat": {
            "type": "object",
            "additionalProperties": true,
            "title": "Stat",
            "description": ""
        },
        "Content": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
                "type": {
                    "type": "string",
                    "enum": [
                        "png",
                        "jpg",
                        "gif",
                        "txt"
                    ]
                },
                "onlyPar": { 
                    "type": "boolean",
                    "description": "Jeśli true - objekt zawiera wizualizację paragonu. Odróżnienie wizualizacji od innych danych niefiskalnych"
                },
                "onlyLogo": { 
                    "type": "boolean",
                    "description": "Jeśli true - objekt zawiera logo sprzedawcy. Odróżnienie wizualizacji od innych danych niefiskalnych"
                },
                "title": {
                    "type": "string"
                },
                "aria-label": {
                    "type": "string"
                },
                "value": {}
            },
            "if": {
                "properties": {
                    "type": {
                        "enum": [
                            "txt"
                        ]
                    }
                }
            },
            "then": {
                "properties": {
                    "value": {
                        "$ref": "#/definitions/TxtValues"
                    }
                }
            },
            "else": {
                "properties": {
                    "value": {
                        "type": "string"
                    }
                }
            },
            "required": [
                "aria-label",
                "title",
                "type",
                "value"
            ],
            "title": "Content"
        },
        "TxtValues": {
            "type": "array",
            "items": {
                "type": "array",
                "items": {
                    "$ref": "#/definitions/ColumnDescriptor"
                }
            },
            "title": "TxtValues"
        },        
        "ColumnDescriptor": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
                "f": {
                    "$ref": "#/definitions/F",
                    "description": "Format elementu"
                },
                "w": {
                    "$ref": "#/definitions/W",
                    "description": "Względna szerokość kolumny"
                },
                "t": {
                    "type": "array",
                    "items": {
                        "type":"string"
                    },
                    "description": "Zawartość"
                }
            },
            "required": [
                "f",
                "t",
                "w"
            ],
            "title": "ColumnDescriptor"
        },
        "F": {
            "type": "array",
            "items": {
                "type": "string",
                "enum": [
                    "C",
                    "R",
                    "L",
                    "W2",
                    "W4",
                    "H2",
                    "H4",
                    "I"
                ]
            },
            "uniqueItems": true,
            "description": "Format kolumny. [C]enter, [R]ight, [L]eft, W2, W4, H2, H4, I",
            "title": "F"
        },
        "W": {
            "type": "string",
            "title": "W",
            "description": "Szerokośc kolumny, 6x12 - szerokość kolumny 6 jednostek z 12"
        }
    }
}