{
  "$schema": "https://json-schema.org/draft/2019-09/schema",
  "$id": "file:///ExtensionDoorhanger.schema.json",
  "title": "ExtensionDoorhanger",
  "description": "A template with a heading, addon icon, title and description. No markup allowed.",
  "allOf": [{ "$ref": "file:///FxMSCommon.schema.json#/$defs/Message" }],
  "type": "object",
  "properties": {
    "content": {
      "type": "object",
      "properties": {
        "category": {
          "type": "string",
          "description": "Attribute used for different groups of messages from the same provider"
        },
        "layout": {
          "type": "string",
          "description": "Attribute used for different groups of messages from the same provider",
          "enum": ["short_message", "icon_and_message", "addon_recommendation"]
        },
        "anchor_id": {
          "type": "string",
          "description": "A DOM element ID that the pop-over will be anchored."
        },
        "alt_anchor_id": {
          "type": "string",
          "description": "An alternate DOM element ID that the pop-over will be anchored."
        },
        "bucket_id": {
          "type": "string",
          "description": "A bucket identifier for the addon. This is used in order to anonymize telemetry for history-sensitive targeting."
        },
        "skip_address_bar_notifier": {
          "type": "boolean",
          "description": "Skip the 'Recommend' notifier and show directly."
        },
        "persistent_doorhanger": {
          "type": "boolean",
          "description": "Prevent the doorhanger from being dismissed if user interacts with the page or switches between applications."
        },
        "show_in_private_browsing": {
          "type": "boolean",
          "description": "Whether to allow the message to be shown in private browsing mode. Defaults to false."
        },
        "notification_text": {
          "$ref": "file:///FxMSCommon.schema.json#/$defs/localizableText",
          "description": "The text in the small blue chicklet that appears in the URL bar. This can be a reference to a localized string in Firefox or just a plain string."
        },
        "info_icon": {
          "type": "object",
          "description": "The small icon displayed in the top right corner of the pop-over. Should be 19x19px, svg or png. Defaults to a small question mark.",
          "properties": {
            "label": {
              "oneOf": [
                {
                  "type": "object",
                  "properties": {
                    "attributes": {
                      "type": "object",
                      "properties": {
                        "tooltiptext": {
                          "$ref": "file:///FxMSCommon.schema.json#/$defs/localizableText",
                          "description": "Text for button tooltip used to provide information about the doorhanger."
                        }
                      },
                      "required": ["tooltiptext"]
                    }
                  },
                  "required": ["attributes"]
                },
                {
                  "$ref": "file:///FxMSCommon.schema.json#/$defs/localizedText"
                }
              ]
            },
            "sumo_path": {
              "type": "string",
              "description": "Last part of the path in the URL to the support page with the information about the doorhanger.",
              "examples": ["extensionpromotions", "extensionrecommendations"]
            }
          }
        },
        "learn_more": {
          "type": "string",
          "description": "Last part of the path in the SUMO URL to the support page with the information about the doorhanger.",
          "examples": ["extensionpromotions", "extensionrecommendations"]
        },
        "heading_text": {
          "$ref": "file:///FxMSCommon.schema.json#/$defs/localizableText",
          "description": "The larger heading text displayed in the pop-over. This can be a reference to a localized string in Firefox or just a plain string."
        },
        "icon": {
          "$ref": "#/$defs/linkUrl",
          "description": "The icon displayed in the pop-over. Should be 32x32px or 64x64px and png/svg."
        },
        "icon_dark_theme": {
          "type": "string",
          "description": "Pop-over icon, dark theme variant. Should be 32x32px or 64x64px and png/svg."
        },
        "icon_class": {
          "type": "string",
          "description": "CSS class of the pop-over icon."
        },
        "addon": {
          "description": "Addon information including AMO URL.",
          "type": "object",
          "properties": {
            "id": {
              "$ref": "#/$defs/plainText",
              "description": "Unique addon ID"
            },
            "title": {
              "$ref": "#/$defs/plainText",
              "description": "Addon name"
            },
            "author": {
              "$ref": "#/$defs/plainText",
              "description": "Addon author"
            },
            "icon": {
              "$ref": "#/$defs/linkUrl",
              "description": "The icon displayed in the pop-over. Should be 64x64px and png/svg."
            },
            "rating": {
              "type": "string",
              "description": "Star rating"
            },
            "users": {
              "type": "string",
              "description": "Installed users"
            },
            "amo_url": {
              "$ref": "#/$defs/linkUrl",
              "description": "Link that offers more information related to the addon."
            }
          },
          "required": ["title", "author", "icon", "amo_url"]
        },
        "text": {
          "$ref": "file:///FxMSCommon.schema.json#/$defs/localizableText",
          "description": "The body text displayed in the pop-over. This can be a reference to a localized string in Firefox or just a plain string."
        },
        "descriptionDetails": {
          "description": "Additional information and steps on how to use",
          "type": "object",
          "properties": {
            "steps": {
              "description": "Array of string_ids",
              "type": "array",
              "items": {
                "$ref": "file:///FxMSCommon.schema.json#/$defs/localizedText",
                "description": "Id of string to localized addon description"
              }
            }
          },
          "required": ["steps"]
        },
        "buttons": {
          "description": "The label and functionality for the buttons in the pop-over.",
          "type": "object",
          "properties": {
            "primary": {
              "type": "object",
              "properties": {
                "label": {
                  "type": "object",
                  "oneOf": [
                    {
                      "properties": {
                        "value": {
                          "$ref": "#/$defs/plainText",
                          "description": "Button label override used when a localized version is not available."
                        },
                        "attributes": {
                          "type": "object",
                          "properties": {
                            "accesskey": {
                              "type": "string",
                              "description": "A single character to be used as a shortcut key for the secondary button. This should be one of the characters that appears in the button label."
                            }
                          },
                          "required": ["accesskey"],
                          "description": "Button attributes."
                        }
                      },
                      "required": ["value", "attributes"]
                    },
                    {
                      "$ref": "file:///FxMSCommon.schema.json#/$defs/localizedText"
                    }
                  ],
                  "description": "Id of localized string or message override."
                },
                "action": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "description": "Action dispatched by the button."
                    },
                    "data": {
                      "properties": {
                        "url": {
                          "type": "string",
                          "$comment": "This is dynamically generated from the addon.id. See CFRPageActions.sys.mjs",
                          "description": "URL used in combination with the primary action dispatched."
                        }
                      }
                    }
                  }
                }
              }
            },
            "secondary": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "label": {
                    "type": "object",
                    "oneOf": [
                      {
                        "properties": {
                          "value": {
                            "allOf": [
                              { "$ref": "#/$defs/plainText" },
                              {
                                "description": "Button label override used when a localized version is not available."
                              }
                            ]
                          },
                          "attributes": {
                            "type": "object",
                            "properties": {
                              "accesskey": {
                                "type": "string",
                                "description": "A single character to be used as a shortcut key for the secondary button. This should be one of the characters that appears in the button label."
                              }
                            },
                            "required": ["accesskey"],
                            "description": "Button attributes."
                          }
                        },
                        "required": ["value", "attributes"]
                      },
                      {
                        "properties": {
                          "string_id": {
                            "allOf": [
                              { "$ref": "#/$defs/plainText" },
                              {
                                "description": "Id of localized string for button"
                              }
                            ]
                          }
                        },
                        "required": ["string_id"]
                      }
                    ],
                    "description": "Id of localized string or message override."
                  },
                  "action": {
                    "type": "object",
                    "properties": {
                      "type": {
                        "type": "string",
                        "description": "Action dispatched by the button."
                      },
                      "data": {
                        "properties": {
                          "url": {
                            "allOf": [
                              { "$ref": "#/$defs/linkUrl" },
                              {
                                "description": "URL used in combination with the primary action dispatched."
                              }
                            ]
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      },
      "additionalProperties": true,
      "required": ["layout", "bucket_id", "heading_text", "text", "buttons"],
      "if": {
        "properties": {
          "skip_address_bar_notifier": {
            "anyOf": [{ "const": "false" }, { "const": null }]
          }
        }
      },
      "then": {
        "required": ["category", "notification_text"]
      }
    },
    "template": {
      "type": "string",
      "enum": ["cfr_doorhanger", "milestone_message"]
    }
  },
  "additionalProperties": true,
  "required": ["targeting", "trigger"],
  "$defs": {
    "plainText": {
      "description": "Plain text (no HTML allowed)",
      "type": "string"
    },
    "linkUrl": {
      "description": "Target for links or buttons",
      "type": "string",
      "format": "uri"
    }
  }
}
