{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "editorial": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "kind": {
              "type": "string",
              "const": "recommendations"
            },
            "count": {
              "type": "integer",
              "minimum": 1,
              "maximum": 6
            },
            "priority": {
              "type": "integer",
              "minimum": 0,
              "maximum": 10
            },
            "magazine": {
              "type": "boolean"
            }
          },
          "required": [
            "kind",
            "count"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "kind": {
              "type": "string",
              "const": "order"
            },
            "linkSelector": {
              "type": "string",
              "minLength": 1,
              "maxLength": 500
            },
            "pinnedSelector": {
              "type": "string",
              "minLength": 1,
              "maxLength": 500
            }
          },
          "required": [
            "kind",
            "linkSelector",
            "pinnedSelector"
          ],
          "additionalProperties": false
        }
      ]
    },
    "id": {
      "type": "string",
      "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._-]{0,100}$"
    },
    "label": {
      "type": "string",
      "minLength": 1,
      "maxLength": 120
    },
    "selector": {
      "type": "string",
      "minLength": 1,
      "maxLength": 500
    },
    "description": {
      "type": "string",
      "minLength": 1,
      "maxLength": 2000
    },
    "mode": {
      "type": "string",
      "enum": [
        "text",
        "component",
        "order",
        "control"
      ]
    },
    "placement": {
      "type": "string",
      "enum": [
        "replace",
        "after"
      ]
    },
    "order": {
      "type": "object",
      "properties": {
        "items": {
          "minItems": 2,
          "maxItems": 50,
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._-]{0,100}$"
              },
              "selector": {
                "type": "string",
                "minLength": 1,
                "maxLength": 500
              }
            },
            "required": [
              "id",
              "selector"
            ],
            "additionalProperties": false
          }
        }
      },
      "required": [
        "items"
      ],
      "additionalProperties": false
    },
    "control": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "kind": {
              "type": "string",
              "const": "select"
            }
          },
          "required": [
            "kind"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "kind": {
              "type": "string",
              "const": "buttons"
            },
            "optionSelector": {
              "type": "string",
              "minLength": 1,
              "maxLength": 500
            },
            "valueAttribute": {
              "type": "string",
              "pattern": "^(data-[a-z][a-z0-9-]*|value)$"
            }
          },
          "required": [
            "kind",
            "optionSelector",
            "valueAttribute"
          ],
          "additionalProperties": false
        }
      ]
    },
    "defaultVariant": {
      "type": "string",
      "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._-]{0,100}$"
    },
    "variants": {
      "minItems": 1,
      "maxItems": 40,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "demoIdentityEntry": {
            "type": "boolean"
          },
          "demoIdentitySegments": {
            "maxItems": 12,
            "type": "array",
            "items": {
              "type": "string",
              "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._-]{0,100}$"
            }
          },
          "contentTag": {
            "type": "string",
            "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._-]{0,100}$"
          },
          "editorialPolicy": {
            "type": "string",
            "enum": [
              "personalized",
              "contextual",
              "discovery"
            ]
          },
          "id": {
            "type": "string",
            "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._-]{0,100}$"
          },
          "description": {
            "type": "string",
            "minLength": 1,
            "maxLength": 2000
          },
          "hypothesis": {
            "type": "string",
            "maxLength": 2000
          },
          "audiences": {
            "maxItems": 20,
            "type": "array",
            "items": {
              "type": "string",
              "maxLength": 100
            }
          },
          "when": {
            "type": "string",
            "maxLength": 500
          },
          "value": {
            "type": "string",
            "maxLength": 24000
          },
          "componentId": {
            "type": "string",
            "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._-]{0,100}$"
          },
          "requiresFacts": {
            "maxItems": 20,
            "type": "array",
            "items": {
              "type": "string",
              "maxLength": 100
            }
          },
          "requiresAttention": {
            "type": "object",
            "properties": {
              "tag": {
                "type": "string",
                "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._-]{0,100}$"
              },
              "durationMs": {
                "type": "integer",
                "minimum": 1000,
                "maximum": 3600000
              }
            },
            "required": [
              "tag",
              "durationMs"
            ],
            "additionalProperties": false
          },
          "requiresPurchasedProduct": {
            "type": "string",
            "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._-]{0,100}$"
          },
          "requiresDaysSincePurchase": {
            "type": "integer",
            "minimum": 0,
            "maximum": 365
          },
          "requiresInterest": {
            "type": "object",
            "properties": {
              "tag": {
                "type": "string",
                "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._-]{0,100}$"
              },
              "distinctProducts": {
                "type": "integer",
                "minimum": 1,
                "maximum": 50
              }
            },
            "required": [
              "tag",
              "distinctProducts"
            ],
            "additionalProperties": false
          }
        },
        "required": [
          "id",
          "description",
          "hypothesis",
          "audiences",
          "value"
        ],
        "additionalProperties": false
      }
    }
  },
  "required": [
    "id",
    "selector",
    "description",
    "mode",
    "defaultVariant",
    "variants"
  ],
  "additionalProperties": false
}
