{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/aginera-ai/json-schema/aginera-ai-takeoff-item-schema.json",
  "title": "TakeoffItem",
  "x-generated": "2026-11-01",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/aginera-ai-openapi.json#/components/schemas/TakeoffItem",
  "type": "object",
  "properties": {
    "id": {
      "$ref": "#/$defs/ItemId"
    },
    "takeoff_id": {
      "$ref": "#/$defs/TakeoffId"
    },
    "group_id": {
      "type": [
        "string",
        "null"
      ]
    },
    "description": {
      "type": "string"
    },
    "trade": {
      "$ref": "#/$defs/Trade"
    },
    "category": {
      "type": "string"
    },
    "item_type": {
      "type": "string"
    },
    "measure_type": {
      "$ref": "#/$defs/MeasureType"
    },
    "extracted_quantity": {
      "type": "number"
    },
    "quantity_override": {
      "type": [
        "number",
        "null"
      ]
    },
    "effective_quantity": {
      "type": "number"
    },
    "unit": {
      "$ref": "#/$defs/Unit"
    },
    "tag": {
      "type": [
        "string",
        "null"
      ]
    },
    "attributes": {
      "type": "object",
      "additionalProperties": {
        "anyOf": [
          {
            "type": "string"
          },
          {
            "type": "number"
          },
          {
            "type": "boolean"
          }
        ]
      }
    },
    "sheet": {
      "type": "object",
      "properties": {
        "number": {
          "type": [
            "string",
            "null"
          ]
        },
        "title": {
          "type": [
            "string",
            "null"
          ]
        }
      },
      "required": [
        "number",
        "title"
      ]
    },
    "page_number": {
      "type": "integer"
    },
    "geometry": {
      "$ref": "#/$defs/Geometry"
    },
    "evidence": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/Evidence"
      }
    },
    "confidence": {
      "$ref": "#/$defs/ConfidenceBand"
    },
    "review_status": {
      "$ref": "#/$defs/ReviewStatus"
    },
    "source": {
      "type": "string",
      "enum": [
        "plan",
        "schedule",
        "legend",
        "manual"
      ]
    },
    "note": {
      "type": [
        "string",
        "null"
      ]
    }
  },
  "required": [
    "id",
    "takeoff_id",
    "description",
    "trade",
    "category",
    "item_type",
    "measure_type",
    "extracted_quantity",
    "quantity_override",
    "effective_quantity",
    "unit",
    "tag",
    "attributes",
    "sheet",
    "page_number",
    "evidence",
    "confidence",
    "review_status",
    "source",
    "note"
  ],
  "$defs": {
    "ConfidenceBand": {
      "type": "string",
      "enum": [
        "high",
        "medium",
        "low"
      ]
    },
    "Evidence": {
      "type": "object",
      "properties": {
        "page_number": {
          "type": "integer",
          "minimum": 1
        },
        "bbox": {
          "type": "array",
          "prefixItems": [
            {
              "type": "number"
            },
            {
              "type": "number"
            },
            {
              "type": "number"
            },
            {
              "type": "number"
            }
          ],
          "description": "[x_min, y_min, x_max, y_max] normalised to page size, origin top-left."
        }
      },
      "required": [
        "page_number",
        "bbox"
      ]
    },
    "Geometry": {
      "oneOf": [
        {
          "type": "object",
          "properties": {
            "type": {
              "type": "string",
              "enum": [
                "point"
              ]
            },
            "page_number": {
              "type": "integer",
              "minimum": 1
            },
            "coordinate_space": {
              "type": "string",
              "enum": [
                "page_normalized"
              ]
            },
            "coordinates": {
              "$ref": "#/$defs/NormPoint"
            }
          },
          "required": [
            "type",
            "page_number",
            "coordinate_space",
            "coordinates"
          ]
        },
        {
          "type": "object",
          "properties": {
            "type": {
              "type": "string",
              "enum": [
                "bbox"
              ]
            },
            "page_number": {
              "type": "integer",
              "minimum": 1
            },
            "coordinate_space": {
              "type": "string",
              "enum": [
                "page_normalized"
              ]
            },
            "coordinates": {
              "type": "array",
              "prefixItems": [
                {
                  "type": "number"
                },
                {
                  "type": "number"
                },
                {
                  "type": "number"
                },
                {
                  "type": "number"
                }
              ]
            }
          },
          "required": [
            "type",
            "page_number",
            "coordinate_space",
            "coordinates"
          ]
        },
        {
          "type": "object",
          "properties": {
            "type": {
              "type": "string",
              "enum": [
                "polyline"
              ]
            },
            "page_number": {
              "type": "integer",
              "minimum": 1
            },
            "coordinate_space": {
              "type": "string",
              "enum": [
                "page_normalized"
              ]
            },
            "coordinates": {
              "type": "array",
              "items": {
                "$ref": "#/$defs/NormPoint"
              },
              "minItems": 2
            },
            "scale": {
              "$ref": "#/$defs/Scale"
            }
          },
          "required": [
            "type",
            "page_number",
            "coordinate_space",
            "coordinates"
          ]
        },
        {
          "type": "object",
          "properties": {
            "type": {
              "type": "string",
              "enum": [
                "polygon"
              ]
            },
            "page_number": {
              "type": "integer",
              "minimum": 1
            },
            "coordinate_space": {
              "type": "string",
              "enum": [
                "page_normalized"
              ]
            },
            "coordinates": {
              "type": "array",
              "items": {
                "$ref": "#/$defs/NormPoint"
              },
              "minItems": 3
            },
            "holes": {
              "type": "array",
              "items": {
                "type": "array",
                "items": {
                  "$ref": "#/$defs/NormPoint"
                },
                "minItems": 3
              }
            },
            "scale": {
              "$ref": "#/$defs/Scale"
            }
          },
          "required": [
            "type",
            "page_number",
            "coordinate_space",
            "coordinates"
          ]
        }
      ],
      "description": "Measured shape in page_normalized space (x, y in 0..1, origin top-left, page as displayed after rotation). bbox = [x_min, y_min, x_max, y_max]."
    },
    "ItemId": {
      "type": "string",
      "pattern": "^itm_[0-9A-Za-z]{22}$"
    },
    "MeasureType": {
      "type": "string",
      "enum": [
        "count",
        "length",
        "area",
        "volume",
        "weight",
        "time"
      ]
    },
    "NormPoint": {
      "type": "array",
      "prefixItems": [
        {
          "type": "number",
          "minimum": 0,
          "maximum": 1
        },
        {
          "type": "number",
          "minimum": 0,
          "maximum": 1
        }
      ]
    },
    "ReviewStatus": {
      "type": "string",
      "enum": [
        "extracted",
        "accepted",
        "rejected",
        "modified"
      ]
    },
    "Scale": {
      "type": "object",
      "properties": {
        "units_per_normalized_x": {
          "type": "number",
          "description": "Real-world units spanned by the full normalized page width."
        },
        "unit": {
          "$ref": "#/$defs/Unit"
        },
        "source": {
          "type": "string",
          "enum": [
            "title_block",
            "scale_bar",
            "declared"
          ]
        }
      },
      "required": [
        "units_per_normalized_x",
        "unit",
        "source"
      ]
    },
    "TakeoffId": {
      "type": "string",
      "pattern": "^tko_[0-9A-Za-z]{22}$"
    },
    "Trade": {
      "type": "string",
      "enum": [
        "electrical",
        "mechanical",
        "plumbing",
        "fire_protection",
        "structural",
        "architectural",
        "civil",
        "process",
        "other"
      ]
    },
    "Unit": {
      "type": "string",
      "pattern": "^[A-Z0-9]{1,6}$",
      "description": "Canonical unit code from /reference/units (extensible; not a closed enum). Examples EA, LF, FT, IN, SF, SY, CF, CY, LB, TON, HR, GAL, M, MM, M2, M3, KG, T, L, LS."
    }
  }
}