{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://detectable.design/data/schema.json",
  "title": "Detectable Design public recommendation data",
  "description": "Machine-readable local visibility recommendations generated from street-scene color analysis.",
  "type": "object",
  "properties": {
    "schema_version": {
      "type": "string"
    },
    "slug": {
      "type": "string"
    },
    "area": {
      "type": "object",
      "properties": {
        "slug": {
          "type": "string"
        },
        "name": {
          "type": "string"
        }
      },
      "required": [
        "slug",
        "name"
      ]
    },
    "light_condition": {
      "enum": [
        "daytime",
        "low_light"
      ]
    },
    "confidence": {
      "enum": [
        "low",
        "medium",
        "high"
      ]
    },
    "best_common_color": {
      "$ref": "#/$defs/colorChoice"
    },
    "best_high_visibility_colors": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/colorChoice"
      }
    },
    "hardest_common_colors_to_see": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/colorChoice"
      }
    },
    "common_color_comparison": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/colorComparison"
      }
    },
    "local_backdrop_elements": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/localBackdropElement"
      }
    },
    "action_summary": {
      "type": "string"
    },
    "citation_text": {
      "type": "string"
    },
    "page_url": {
      "type": "string",
      "format": "uri"
    },
    "data_url": {
      "type": "string",
      "format": "uri"
    },
    "methodology_url": {
      "type": "string",
      "format": "uri"
    },
    "last_updated": {
      "type": "string"
    }
  },
  "required": [
    "schema_version",
    "slug",
    "area",
    "light_condition",
    "confidence",
    "best_common_color",
    "page_url",
    "citation_text"
  ],
  "$defs": {
    "colorChoice": {
      "type": "object",
      "properties": {
        "label": {
          "type": "string"
        },
        "hex": {
          "type": "string",
          "pattern": "^#[0-9A-Fa-f]{6}$"
        }
      },
      "required": [
        "label",
        "hex"
      ]
    },
    "colorComparison": {
      "type": "object",
      "properties": {
        "label": {
          "type": "string"
        },
        "hex": {
          "type": "string"
        },
        "mean_score": {
          "type": "number"
        },
        "relative_to_average_high_vis": {
          "type": [
            "number",
            "null"
          ]
        },
        "relative_to_average_high_vis_percent": {
          "type": "number"
        }
      },
      "required": [
        "label",
        "hex",
        "mean_score"
      ]
    },
    "localBackdropElement": {
      "type": "object",
      "properties": {
        "label": {
          "type": "string"
        },
        "hex": {
          "type": "string"
        },
        "photo_share": {
          "type": "number"
        },
        "percent_of_photos": {
          "type": "number"
        }
      },
      "required": [
        "label",
        "hex",
        "photo_share",
        "percent_of_photos"
      ]
    }
  }
}
