{
    "$schema": "http://json-schema.org/draft-07/schema",
    "$id": "https://schemas.acrobits.net/core/conditions/condition.json",
    "$defs": {
        "string-pattern-matcher": {
            "type": "object",
            "properties": {
                "matchType": {
                    "type": "string",
                    "enum": [
                        "startWith",
                        "endWith",
                        "contain",
                        "equal"
                    ]
                },
                "matchPattern": {
                    "type": "string",
                    "minLength": 1
                }
            },
            "required": [
                "matchType",
                "matchPattern"
            ]
        },
        "accountkey": {
            "type": "object",
            "allOf": [
                {
                    "type": "object",
                    "properties": {
                        "@": {
                            "const": "accountKey"
                        },
                        "key": {
                            "type": "string",
                            "minLength": 2
                        },
                        "matchType": {
                            "type": "string"
                        },
                        "matchPattern": {
                            "type": "string"
                        }
                    },
                    "required": [
                        "@",
                        "key",
                        "matchType",
                        "matchPattern"
                    ],
                    "additionalProperties": false
                },
                {
                    "$ref": "#/$defs/string-pattern-matcher"
                }
            ]
        },
        "always-false": {
            "type": "object",
            "properties": {
                "@": {
                    "const": "alwaysFalse"
                }
            },
            "required": [
                "@"
            ],
            "additionalProperties": false
        },
        "always-true": {
            "type": "object",
            "properties": {
                "@": {
                    "const": "alwaysTrue"
                }
            },
            "required": [
                "@"
            ],
            "additionalProperties": false
        },
        "and": {
            "type": "object",
            "properties": {
                "@": {
                    "const": "and"
                },
                "operands": {
                    "type": "array",
                    "items": {
                        "$ref": "#"
                    },
                    "minItems": 2
                }
            },
            "required": [
                "@",
                "operands"
            ],
            "additionalProperties": false
        },
        "call-direction": {
            "type": "object",
            "properties": {
                "@": {
                    "const": "callDirection"
                },
                "direction": {
                    "type": "string",
                    "enum": [
                        "incoming",
                        "outgoing"
                    ]
                }
            },
            "required": [
                "@",
                "direction"
            ],
            "additionalProperties": false
        },
        "caller-display-name": {
            "type": "object",
            "allOf": [
                {
                    "type": "object",
                    "properties": {
                        "@": {
                            "const": "callerDisplayName"
                        },
                        "matchType": {
                            "type": "string"
                        },
                        "matchPattern": {
                            "type": "string"
                        }
                    },
                    "required": [
                        "@",
                        "matchType",
                        "matchPattern"
                    ],
                    "additionalProperties": false
                },
                {
                    "$ref": "#/$defs/string-pattern-matcher"
                }
            ]
        },
        "caller-transport-uri": {
            "type": "object",
            "allOf": [
                {
                    "type": "object",
                    "properties": {
                        "@": {
                            "const": "callerTransportUri"
                        },
                        "matchType": {
                            "type": "string"
                        },
                        "matchPattern": {
                            "type": "string"
                        }
                    },
                    "required": [
                        "@",
                        "matchType",
                        "matchPattern"
                    ],
                    "additionalProperties": false
                },
                {
                    "$ref": "#/$defs/string-pattern-matcher"
                }
            ]
        },
        "call-state": {
            "type": "object",
            "properties": {
                "@": {
                    "const": "callState"
                },
                "states": {
                    "type": "array",
                    "items": {
                        "$ref": "https://schemas.acrobits.net/core/data/call-state.json"
                    },
                    "minItems": 1,
                    "uniqueItems": true
                }
            },
            "required": [
                "@",
                "states"
            ],
            "additionalProperties": false
        },
        "group-size": {
            "type": "object",
            "description": "Condition evaluating group size against a specified value using a comparison operator.",
            "properties": {
                "@": {
                    "const": "groupSize"
                },
                "size": {
                    "type": "integer",
                    "minimum": 0
                },
                "op": {
                    "description": "Comparison operator to use for evaluating group size. Default is '>='.",
                    "$ref": "https://schemas.acrobits.net/core/data/comparison-operator.json"
                }
            },
            "required": [
                "@",
                "size"
            ],
            "additionalProperties": false
        },
        "implication": {
            "type": "object",
            "properties": {
                "@": {
                    "const": "implication"
                },
                "if": {
                    "$ref": "#"
                },
                "then": {
                    "$ref": "#"
                }
            },
            "required": [
                "@",
                "if",
                "then"
            ],
            "additionalProperties": false
        },
        "not": {
            "type": "object",
            "properties": {
                "@": {
                    "const": "not"
                },
                "operand": {
                    "$ref": "#"
                }
            },
            "required": [
                "@",
                "operand"
            ],
            "additionalProperties": false
        },
        "or": {
            "type": "object",
            "properties": {
                "@": {
                    "const": "or"
                },
                "operands": {
                    "type": "array",
                    "items": {
                        "$ref": "#"
                    },
                    "minItems": 2
                }
            },
            "required": [
                "@",
                "operands"
            ],
            "additionalProperties": false
        },
        "prefkey": {
            "type": "object",
            "allOf": [
                {
                    "type": "object",
                    "properties": {
                        "@": {
                            "const": "prefKey"
                        },
                        "key": {
                            "type": "string",
                            "minLength": 2
                        },
                        "matchType": {
                            "type": "string"
                        },
                        "matchPattern": {
                            "type": "string"
                        }
                    },
                    "required": [
                        "@",
                        "key",
                        "matchType",
                        "matchPattern"
                    ],
                    "additionalProperties": false
                },
                {
                    "$ref": "#/$defs/string-pattern-matcher"
                }
            ]
        },
        "random": {
            "type": "object",
            "properties": {
                "@": {
                    "const": "random"
                }
            },
            "required": [
                "@"
            ],
            "additionalProperties": false
        },
        "version": {
            "type": "object",
            "properties": {
                "@": {
                    "const": "version"
                },
                "minimum": {
                    "type": "string",
                    "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+$"
                },
                "maximum": {
                    "type": "string",
                    "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+$"
                }
            },
            "anyOf": [
                {
                    "required": [
                        "@",
                        "minimum"
                    ]
                },
                {
                    "required": [
                        "@",
                        "maximum"
                    ]
                }
            ],
            "additionalProperties": false
        },
        "platform": {
            "type": "object",
            "properties": {
                "@": {
                    "const": "platform"
                },
                "platform": {
                    "enum": [
                        "Android",
                        "iOS",
                        "Windows",
                        "Mac",
                        "Linux",
                        "Desktop",
                        "Mobile",
                        "Shared"
                    ]
                }
            },
            "required": [
                "@",
                "platform"
            ],
            "additionalProperties": false
        },
        "variable": {
            "type": "object",
            "allOf": [
                {
                    "type": "object",
                    "properties": {
                        "@": {
                            "const": "variable"
                        },
                        "name": {
                            "type": "string",
                            "minLength": 2
                        },
                        "matchType": {
                            "type": "string"
                        },
                        "matchPattern": {
                            "type": "string"
                        }
                    },
                    "required": [
                        "@",
                        "name",
                        "matchType",
                        "matchPattern"
                    ],
                    "additionalProperties": false
                },
                {
                    "$ref": "#/$defs/string-pattern-matcher"
                }
            ]
        },
        "isNativeMessagingEnabled": {
            "type": "object",
            "properties": {
                "@": {
                    "const": "isNativeMessagingEnabled"
                }
            },
            "required": [
                "@"
            ],
            "additionalProperties": false
        },
        "isConferencingEnabled": {
            "type": "object",
            "properties": {
                "@": {
                    "const": "isConferencingEnabled"
                }
            },
            "required": [
                "@"
            ],
            "additionalProperties": false
        }
    },
    "oneOf": [
        {
            "$ref": "#/$defs/accountkey"
        },
        {
            "$ref": "#/$defs/always-false"
        },
        {
            "$ref": "#/$defs/always-true"
        },
        {
            "$ref": "#/$defs/and"
        },
        {
            "$ref": "#/$defs/call-direction"
        },
        {
            "$ref": "#/$defs/caller-display-name"
        },
        {
            "$ref": "#/$defs/caller-transport-uri"
        },
        {
            "$ref": "#/$defs/call-state"
        },
        {
            "$ref": "#/$defs/group-size"
        },
        {
            "$ref": "#/$defs/implication"
        },
        {
            "$ref": "#/$defs/not"
        },
        {
            "$ref": "#/$defs/or"
        },
        {
            "$ref": "#/$defs/prefkey"
        },
        {
            "$ref": "#/$defs/random"
        },
        {
            "$ref": "#/$defs/version"
        },
        {
            "$ref": "#/$defs/platform"
        },
        {
            "$ref": "#/$defs/variable"
        },
        {
            "$ref": "#/$defs/isNativeMessagingEnabled"
        },
        {
            "$ref": "#/$defs/isConferencingEnabled"
        }
    ]
}