{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://wp-content.ru/schemas/px320-private-visual-evidence-1.0.0.json",
  "title": "320px Site Audit private masked visual evidence",
  "type": "object",
  "additionalProperties": false,
  "required": ["schema", "schema_version", "evidence_id", "created_at", "generator", "scope", "pages", "limitations"],
  "properties": {
    "schema": {"const": "px320-private-visual-evidence"},
    "schema_version": {"const": "1.0.0"},
    "evidence_id": {"type": "string", "format": "uuid"},
    "created_at": {"type": "string", "format": "date-time"},
    "generator": {
      "type": "object",
      "additionalProperties": false,
      "required": ["name", "version", "engine", "browser", "redaction_profile"],
      "properties": {
        "name": {"const": "320px Site Audit browser CLI"},
        "version": {"const": "0.1.1"},
        "engine": {"const": "playwright-chromium-1.62.1"},
        "browser": {"oneOf": [{"const": "chromium-151.0.7922.34"}, {"type": "null"}]},
        "redaction_profile": {"const": "masked-layout-1.0.0"}
      }
    },
    "scope": {
      "type": "object",
      "additionalProperties": false,
      "required": ["target_count", "viewport_widths", "screenshot_count", "screenshot_bytes", "screenshot_limit_per_target", "excerpt_limit_per_viewport", "screenshot_byte_limit", "bundle_byte_limit"],
      "properties": {
        "target_count": {"type": "integer", "minimum": 1, "maximum": 5},
        "viewport_widths": {"const": [360, 390, 768, 1024, 1440]},
        "screenshot_count": {"type": "integer", "minimum": 0, "maximum": 25},
        "screenshot_bytes": {"type": "integer", "minimum": 0, "maximum": 134217728},
        "screenshot_limit_per_target": {"const": 5},
        "excerpt_limit_per_viewport": {"const": 20},
        "screenshot_byte_limit": {"const": 5242880},
        "bundle_byte_limit": {"const": 134217728}
      }
    },
    "pages": {
      "type": "array",
      "minItems": 1,
      "maxItems": 5,
      "items": {"$ref": "#/$defs/pageResult"}
    },
    "limitations": {
      "const": ["cooperative_page_only", "masked_layout_not_raw_page", "no_visible_text_or_field_values", "media_and_custom_elements_hidden", "viewport_only", "no_manual_interaction", "not_in_main_report", "inspect_before_sharing"]
    }
  },
  "$defs": {
    "capability": {
      "type": "object",
      "additionalProperties": false,
      "required": ["state", "reason"],
      "properties": {
        "state": {"enum": ["available", "blocked"]},
        "reason": {"enum": ["available", "browser_unavailable", "browser_version_mismatch", "inspection_failed", "navigation_blocked", "navigation_failed", "navigation_timeout", "request_budget_exceeded", "target_timeout", "transfer_budget_exceeded"]}
      }
    },
    "pageResult": {
      "type": "object",
      "additionalProperties": false,
      "required": ["page_ref", "capability", "captures"],
      "properties": {
        "page_ref": {"oneOf": [{"type": "string", "pattern": "^page:[a-f0-9]{24}$"}, {"type": "null"}]},
        "capability": {"$ref": "#/$defs/capability"},
        "captures": {
          "oneOf": [
            {"type": "array", "maxItems": 0},
            {
              "type": "array",
              "minItems": 5,
              "maxItems": 5,
              "prefixItems": [
                {"allOf": [{"$ref": "#/$defs/capture"}, {"type": "object", "properties": {"width": {"const": 360}}}]},
                {"allOf": [{"$ref": "#/$defs/capture"}, {"type": "object", "properties": {"width": {"const": 390}}}]},
                {"allOf": [{"$ref": "#/$defs/capture"}, {"type": "object", "properties": {"width": {"const": 768}}}]},
                {"allOf": [{"$ref": "#/$defs/capture"}, {"type": "object", "properties": {"width": {"const": 1024}}}]},
                {"allOf": [{"$ref": "#/$defs/capture"}, {"type": "object", "properties": {"width": {"const": 1440}}}]}
              ],
              "items": false
            }
          ]
        }
      },
      "allOf": [
        {
          "if": {"properties": {"capability": {"type": "object", "properties": {"state": {"const": "available"}}}}},
          "then": {"properties": {"page_ref": {"type": "string"}, "captures": {"type": "array", "minItems": 5, "maxItems": 5}}},
          "else": {"properties": {"captures": {"type": "array", "maxItems": 0}}}
        }
      ]
    },
    "capture": {
      "type": "object",
      "additionalProperties": false,
      "required": ["width", "height", "scroll_y", "structural_excerpts", "truncated", "screenshot"],
      "properties": {
        "width": {"enum": [360, 390, 768, 1024, 1440]},
        "height": {"const": 900},
        "scroll_y": {"type": "integer", "minimum": 0, "maximum": 10000000},
        "structural_excerpts": {"type": "array", "maxItems": 20, "items": {"$ref": "#/$defs/excerpt"}},
        "truncated": {"type": "boolean"},
        "screenshot": {
          "type": "object",
          "additionalProperties": false,
          "required": ["file", "bytes", "sha256"],
          "properties": {
            "file": {"type": "string", "pattern": "^page-0[1-5]-(0360|0390|0768|1024|1440)\\.png$"},
            "bytes": {"type": "integer", "minimum": 1, "maximum": 5242880},
            "sha256": {"type": "string", "pattern": "^[a-f0-9]{64}$"}
          }
        }
      }
    },
    "excerpt": {
      "type": "object",
      "additionalProperties": false,
      "required": ["node_ref", "tag", "role", "ancestor_tags", "rectangle", "issues"],
      "properties": {
        "node_ref": {"type": "string", "pattern": "^node:[a-f0-9]{24}$"},
        "tag": {"enum": ["a", "article", "aside", "blockquote", "body", "button", "code", "custom-element", "dd", "details", "dialog", "div", "dl", "dt", "fieldset", "figcaption", "figure", "footer", "form", "h1", "h2", "h3", "h4", "h5", "h6", "header", "html", "img", "input", "label", "li", "main", "nav", "ol", "p", "picture", "pre", "section", "select", "span", "summary", "table", "tbody", "td", "textarea", "tfoot", "th", "thead", "tr", "ul", "video"]},
        "role": {"oneOf": [{"enum": ["alert", "alertdialog", "article", "banner", "button", "cell", "checkbox", "columnheader", "combobox", "complementary", "contentinfo", "dialog", "document", "feed", "form", "grid", "gridcell", "group", "heading", "link", "list", "listbox", "listitem", "main", "menu", "menubar", "menuitem", "navigation", "option", "progressbar", "radio", "radiogroup", "region", "row", "rowgroup", "rowheader", "search", "separator", "slider", "spinbutton", "status", "switch", "tab", "table", "tabpanel", "textbox", "timer", "toolbar", "tooltip", "tree", "treeitem"]}, {"type": "null"}]},
        "ancestor_tags": {"type": "array", "maxItems": 4, "items": {"enum": ["a", "article", "aside", "blockquote", "body", "button", "code", "custom-element", "dd", "details", "dialog", "div", "dl", "dt", "fieldset", "figcaption", "figure", "footer", "form", "h1", "h2", "h3", "h4", "h5", "h6", "header", "html", "img", "input", "label", "li", "main", "nav", "ol", "p", "picture", "pre", "section", "select", "span", "summary", "table", "tbody", "td", "textarea", "tfoot", "th", "thead", "tr", "ul", "video"]}},
        "rectangle": {
          "type": "object",
          "additionalProperties": false,
          "required": ["x", "y", "width", "height"],
          "properties": {
            "x": {"type": "integer", "minimum": -10000000, "maximum": 10000000},
            "y": {"type": "integer", "minimum": -10000000, "maximum": 10000000},
            "width": {"type": "integer", "minimum": 0, "maximum": 10000000},
            "height": {"type": "integer", "minimum": 0, "maximum": 10000000}
          }
        },
        "issues": {"type": "array", "minItems": 1, "maxItems": 3, "uniqueItems": true, "items": {"enum": ["inline_start_overflow", "inline_end_overflow", "fixed_width_overflow"]}}
      }
    }
  }
}
