{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://a2ui.dev/specification/0.9/common_types.json",
  "title": "A2UI Common Types",
  "description": "Common type definitions used across A2UI schemas.",
  "$defs": {
    "stringOrPath": {
      "description": "Represents a value that can be either a literal string or a path to a value in the data model.",
      "oneOf": [
        { "type": "string" },
        {
          "type": "object",
          "properties": {
            "path": { "type": "string" }
          },
          "required": ["path"],
          "additionalProperties": false
        }
      ]
    },
    "numberOrPath": {
      "description": "Represents a value that can be either a literal number or a path to a value in the data model.",
      "oneOf": [
        { "type": "number" },
        {
          "type": "object",
          "properties": {
            "path": { "type": "string" }
          },
          "required": ["path"],
          "additionalProperties": false
        }
      ]
    },
    "booleanOrPath": {
      "description": "Represents a value that can be either a literal boolean or a path to a value in the data model.",
      "oneOf": [
        { "type": "boolean" },
        {
          "type": "object",
          "properties": {
            "path": { "type": "string" }
          },
          "required": ["path"],
          "additionalProperties": false
        }
      ]
    },
    "stringArrayOrPath": {
      "description": "Represents a value that can be either a literal array of strings or a path to a value in the data model.",
      "oneOf": [
        {
          "type": "array",
          "items": { "type": "string" }
        },
        {
          "type": "object",
          "properties": {
            "path": { "type": "string" }
          },
          "required": ["path"],
          "additionalProperties": false
        }
      ]
    },
    "id": {
      "type": "string",
      "description": "The unique identifier for this component."
    },
    "ComponentCommon": {
      "type": "object",
      "properties": {
        "id": { "$ref": "#/$defs/id" },
        "weight": {
          "type": "number",
          "description": "The relative weight of this component within a Row or Column. This is similar to the CSS 'flex-grow' property."
        }
      },
      "required": ["id"]
    },
    "contextValue": {
      "description": "A value that can be a string, number, boolean, or a path to a value.",
      "oneOf": [
        { "type": "string" },
        { "type": "number" },
        { "type": "boolean" },
        {
          "type": "object",
          "properties": { "path": { "type": "string" } },
          "required": ["path"],
          "additionalProperties": false
        }
      ]
    },
    "childrenProperty": {
      "oneOf": [
        {
          "type": "array",
          "items": { "type": "string" },
          "description": "A static list of child component IDs."
        },
        {
          "type": "object",
          "description": "A template for generating a dynamic list of children from a data model list. The `componentId` is the component to use as a template.",
          "properties": {
            "componentId": {
              "$ref": "#/$defs/id"
            },
            "path": {
              "type": "string",
              "description": "The path to the list of component property objects in the data model."
            }
          },
          "required": ["componentId", "path"],
          "additionalProperties": false
        }
      ]
    }
  }
}
