{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/vedika-io/json-schema/vedika-io-vastu-plan-optimize-request-schema.json",
  "title": "VastuPlanOptimizeRequest",
  "description": "Optimizes exactly one caller-supplied rooms or layout array. Requires real plot width, length (or depth/height) and facing, nested under plot or at the root. No synthetic plot is created. Fields not listed here are ignored. With constraints or locked rooms, accepts 1-16 rooms with IDs and current polygons, plot.units=m and a buildable polygon/dimensions. Deterministic feasible move/atomic-swap/minimum-size-resize search. All sizes are metres; width/height minima refer to axis-aligned extents. Declared plot.setbacks/setback are applied with the existing cardinal/relative setback rules; relative setbacks require plot.facing. Locked room coordinates are preserved without rescaling. No random or global-optimality claim. Explicit units/inputUnits is recommended for interchange. Omitted units retain legacy coordinate behavior.",
  "x-generated": "2026-11-23",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/vedika-io-openapi.json#/components/schemas/VastuPlanOptimizeRequest",
  "type": "object",
  "properties": {
    "rooms": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "pattern": "\\S"
          },
          "roomType": {
            "type": "string"
          },
          "zone": {
            "anyOf": [
              {
                "$ref": "#/$defs/VastuPlanFacing"
              },
              {
                "type": "string",
                "pattern": "[\\s\\S]*(?:[cC][^A-Za-z]*[eE][^A-Za-z]*[nN][^A-Za-z]*[tT][^A-Za-z]*[eE][^A-Za-z]*[rR]|[cC][^A-Za-z]*[eE][^A-Za-z]*[nN][^A-Za-z]*[tT][^A-Za-z]*[rR][^A-Za-z]*[eE]|[bB][^A-Za-z]*[rR][^A-Za-z]*[aA][^A-Za-z]*[hH][^A-Za-z]*[mM][^A-Za-z]*[aA]|[mM][^A-Za-z]*[aA][^A-Za-z]*[dD][^A-Za-z]*[hH][^A-Za-z]*[yY][^A-Za-z]*[aA])[\\s\\S]*"
              }
            ]
          },
          "direction": {
            "type": "string"
          },
          "polygon": {
            "$ref": "#/$defs/VastuPlanPolygon"
          },
          "area": {
            "anyOf": [
              {
                "$ref": "#/$defs/VastuPlanDimension"
              },
              {
                "type": [
                  "number",
                  "null"
                ],
                "enum": [
                  null
                ]
              }
            ]
          },
          "type": {
            "type": "string"
          },
          "floor": {
            "$ref": "#/$defs/VastuPlanRoomFloor"
          },
          "headingErrorDeg": {
            "type": "number",
            "minimum": 0,
            "maximum": 180,
            "description": "Symmetric heading bound in degrees. Optional; absent preserves existing output exactly."
          },
          "positionErrorM": {
            "type": "number",
            "minimum": 0,
            "maximum": 10000,
            "description": "Euclidean position-disc radius in metres. Requires point geometry and an explicit plot frame. Metre geometry is the default; plot.units=ft converts coordinates using the international foot. The plot frame is held fixed."
          },
          "id": {
            "type": "string"
          },
          "locked": {
            "type": "boolean"
          },
          "holes": {
            "type": "array",
            "maxItems": 64,
            "items": {
              "$ref": "#/$defs/VastuPlanPolygon"
            }
          },
          "multipolygons": {
            "type": "array",
            "minItems": 1,
            "maxItems": 32,
            "items": {
              "$ref": "#/$defs/VastuPlanRegion"
            },
            "description": "Disjoint filled wings. Send either polygon with holes or multipolygons."
          }
        },
        "additionalProperties": false
      }
    },
    "plot": {
      "anyOf": [
        {
          "$ref": "#/$defs/VastuPlanPhysicalPlot"
        },
        {
          "type": "object",
          "properties": {
            "units": {
              "type": "string",
              "enum": [
                "m"
              ]
            },
            "width": {
              "type": "number",
              "exclusiveMinimum": true,
              "minimum": 0
            },
            "length": {
              "type": "number",
              "exclusiveMinimum": true,
              "minimum": 0
            },
            "polygon": {
              "$ref": "#/$defs/VastuPlanPolygon"
            },
            "facing": {
              "type": "string"
            },
            "setbacks": {
              "type": "object",
              "additionalProperties": {
                "type": "number",
                "minimum": 0
              }
            }
          },
          "required": [
            "units"
          ],
          "additionalProperties": true,
          "description": "Measured constrained layout plot. Declare polygons or both dimensions."
        }
      ]
    },
    "includeSvg": {
      "type": "boolean",
      "default": true,
      "description": "Set false to skip rendering and returning all SVG drawings while keeping geometry, openings, scores and ranking unchanged."
    },
    "width": {
      "$ref": "#/$defs/VastuPlanDimension"
    },
    "length": {
      "$ref": "#/$defs/VastuPlanDimension"
    },
    "facing": {
      "$ref": "#/$defs/VastuPlanFacing"
    },
    "polygon": {
      "$ref": "#/$defs/VastuPlanPolygon"
    },
    "setbacks": {
      "$ref": "#/$defs/VastuPlanSetbacks"
    },
    "depth": {
      "$ref": "#/$defs/VastuPlanDimension"
    },
    "height": {
      "$ref": "#/$defs/VastuPlanDimension"
    },
    "corners": {
      "$ref": "#/$defs/VastuPlanPolygon"
    },
    "plotPolygon": {
      "$ref": "#/$defs/VastuPlanPolygon"
    },
    "setback": {
      "$ref": "#/$defs/VastuPlanSetbacks"
    },
    "layout": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "pattern": "\\S"
          },
          "roomType": {
            "type": "string"
          },
          "zone": {
            "anyOf": [
              {
                "$ref": "#/$defs/VastuPlanFacing"
              },
              {
                "type": "string",
                "pattern": "[\\s\\S]*(?:[cC][^A-Za-z]*[eE][^A-Za-z]*[nN][^A-Za-z]*[tT][^A-Za-z]*[eE][^A-Za-z]*[rR]|[cC][^A-Za-z]*[eE][^A-Za-z]*[nN][^A-Za-z]*[tT][^A-Za-z]*[rR][^A-Za-z]*[eE]|[bB][^A-Za-z]*[rR][^A-Za-z]*[aA][^A-Za-z]*[hH][^A-Za-z]*[mM][^A-Za-z]*[aA]|[mM][^A-Za-z]*[aA][^A-Za-z]*[dD][^A-Za-z]*[hH][^A-Za-z]*[yY][^A-Za-z]*[aA])[\\s\\S]*"
              }
            ]
          },
          "direction": {
            "type": "string"
          },
          "polygon": {
            "$ref": "#/$defs/VastuPlanPolygon"
          },
          "area": {
            "anyOf": [
              {
                "$ref": "#/$defs/VastuPlanDimension"
              },
              {
                "type": [
                  "number",
                  "null"
                ],
                "enum": [
                  null
                ]
              }
            ]
          },
          "type": {
            "type": "string"
          },
          "floor": {
            "$ref": "#/$defs/VastuPlanRoomFloor"
          },
          "headingErrorDeg": {
            "type": "number",
            "minimum": 0,
            "maximum": 180,
            "description": "Symmetric heading bound in degrees. Optional; absent preserves existing output exactly."
          },
          "positionErrorM": {
            "type": "number",
            "minimum": 0,
            "maximum": 10000,
            "description": "Euclidean position-disc radius in metres. Requires point geometry and an explicit plot frame. Metre geometry is the default; plot.units=ft converts coordinates using the international foot. The plot frame is held fixed."
          },
          "id": {
            "type": "string"
          },
          "locked": {
            "type": "boolean"
          },
          "holes": {
            "type": "array",
            "maxItems": 64,
            "items": {
              "$ref": "#/$defs/VastuPlanPolygon"
            }
          },
          "multipolygons": {
            "type": "array",
            "minItems": 1,
            "maxItems": 32,
            "items": {
              "$ref": "#/$defs/VastuPlanRegion"
            },
            "description": "Disjoint filled wings. Send either polygon with holes or multipolygons."
          }
        },
        "additionalProperties": false
      },
      "description": "The current rooms of a single storey. Each entry may carry floor (default 0); every entry must name the same floor, because plan/optimize re-plans one storey at a time. A layout that spans storeys is a 400: send each storey in its own call, or use plan/generate with floors[]."
    },
    "headingErrorDeg": {
      "type": "number",
      "minimum": 0,
      "maximum": 180,
      "description": "Symmetric heading bound in degrees. Optional; absent preserves existing output exactly."
    },
    "positionErrorM": {
      "type": "number",
      "minimum": 0,
      "maximum": 10000,
      "description": "Euclidean position-disc radius in metres. Requires point geometry and an explicit plot frame. Metre geometry is the default; plot.units=ft converts coordinates using the international foot. The plot frame is held fixed."
    },
    "constraints": {
      "$ref": "#/$defs/VastuOptimizationConstraints"
    },
    "lockedRooms": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "wetShafts": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "polygon": {
            "type": "array",
            "items": {
              "type": "array",
              "items": {
                "type": "number"
              },
              "maxItems": 2,
              "minItems": 2
            },
            "maxItems": 256,
            "minItems": 3
          },
          "roomIds": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "maxDistanceM": {
            "type": "number",
            "minimum": 0
          },
          "holes": {
            "type": "array",
            "maxItems": 64,
            "items": {
              "$ref": "#/$defs/VastuPlanPolygon"
            }
          },
          "multipolygons": {
            "type": "array",
            "minItems": 1,
            "maxItems": 32,
            "items": {
              "$ref": "#/$defs/VastuPlanRegion"
            },
            "description": "Disjoint filled wings. Send either polygon with holes or multipolygons."
          }
        },
        "required": [
          "id"
        ],
        "additionalProperties": false,
        "anyOf": [
          {
            "required": [
              "polygon"
            ]
          },
          {
            "required": [
              "multipolygons"
            ]
          }
        ]
      },
      "maxItems": 64
    },
    "plumbingStacks": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "polygon": {
            "type": "array",
            "items": {
              "type": "array",
              "items": {
                "type": "number"
              },
              "maxItems": 2,
              "minItems": 2
            },
            "maxItems": 256,
            "minItems": 3
          },
          "roomIds": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "maxDistanceM": {
            "type": "number",
            "minimum": 0
          },
          "holes": {
            "type": "array",
            "maxItems": 64,
            "items": {
              "$ref": "#/$defs/VastuPlanPolygon"
            }
          },
          "multipolygons": {
            "type": "array",
            "minItems": 1,
            "maxItems": 32,
            "items": {
              "$ref": "#/$defs/VastuPlanRegion"
            },
            "description": "Disjoint filled wings. Send either polygon with holes or multipolygons."
          }
        },
        "required": [
          "id"
        ],
        "additionalProperties": false,
        "anyOf": [
          {
            "required": [
              "polygon"
            ]
          },
          {
            "required": [
              "multipolygons"
            ]
          }
        ]
      },
      "maxItems": 64
    },
    "loadBearingWalls": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "polygon": {
            "type": "array",
            "items": {
              "type": "array",
              "items": {
                "type": "number"
              },
              "maxItems": 2,
              "minItems": 2
            },
            "maxItems": 256,
            "minItems": 3
          },
          "holes": {
            "type": "array",
            "maxItems": 64,
            "items": {
              "$ref": "#/$defs/VastuPlanPolygon"
            }
          },
          "multipolygons": {
            "type": "array",
            "minItems": 1,
            "maxItems": 32,
            "items": {
              "$ref": "#/$defs/VastuPlanRegion"
            },
            "description": "Disjoint filled wings. Send either polygon with holes or multipolygons."
          }
        },
        "required": [],
        "additionalProperties": false,
        "anyOf": [
          {
            "required": [
              "polygon"
            ]
          },
          {
            "required": [
              "multipolygons"
            ]
          }
        ]
      },
      "maxItems": 128
    },
    "columns": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "polygon": {
            "type": "array",
            "items": {
              "type": "array",
              "items": {
                "type": "number"
              },
              "maxItems": 2,
              "minItems": 2
            },
            "maxItems": 256,
            "minItems": 3
          },
          "holes": {
            "type": "array",
            "maxItems": 64,
            "items": {
              "$ref": "#/$defs/VastuPlanPolygon"
            }
          },
          "multipolygons": {
            "type": "array",
            "minItems": 1,
            "maxItems": 32,
            "items": {
              "$ref": "#/$defs/VastuPlanRegion"
            },
            "description": "Disjoint filled wings. Send either polygon with holes or multipolygons."
          }
        },
        "required": [],
        "additionalProperties": false,
        "anyOf": [
          {
            "required": [
              "polygon"
            ]
          },
          {
            "required": [
              "multipolygons"
            ]
          }
        ]
      },
      "maxItems": 128
    },
    "minSizes": {
      "type": "object",
      "additionalProperties": {
        "type": "object",
        "properties": {
          "minAreaM2": {
            "type": "number",
            "minimum": 0
          },
          "minWidthM": {
            "type": "number",
            "minimum": 0
          },
          "minHeightM": {
            "type": "number",
            "minimum": 0
          }
        },
        "required": [],
        "additionalProperties": false
      }
    },
    "merchantCatalogId": {
      "type": "string",
      "minLength": 1,
      "maxLength": 128,
      "pattern": "^[A-Za-z0-9_-]{1,128}$"
    },
    "propertyId": {
      "type": "string",
      "minLength": 1,
      "maxLength": 128,
      "pattern": "^[A-Za-z0-9_.\\-/]+$",
      "description": "Buyer-supplied non-secret attribution identifier. Account-scoped; does not grant property access."
    },
    "tenantRef": {
      "type": "string",
      "minLength": 1,
      "maxLength": 128,
      "pattern": "^[A-Za-z0-9_.\\-/]+$",
      "description": "Buyer-supplied non-secret attribution identifier. Account-scoped; does not grant property access."
    },
    "holes": {
      "type": "array",
      "maxItems": 64,
      "items": {
        "$ref": "#/$defs/VastuPlanPolygon"
      }
    },
    "multipolygons": {
      "type": "array",
      "minItems": 1,
      "maxItems": 32,
      "items": {
        "$ref": "#/$defs/VastuPlanRegion"
      },
      "description": "Disjoint filled wings. Send either polygon with holes or multipolygons."
    },
    "units": {
      "type": "string",
      "enum": [
        "m",
        "ft",
        "mm",
        "in"
      ],
      "description": "Linear plan coordinates and unsuffixed dimensions use this unit. area fields use its square. Internally normalized once to metres; fields explicitly suffixed M/M2 remain metres."
    },
    "inputUnits": {
      "type": "string",
      "enum": [
        "m",
        "ft",
        "mm",
        "in"
      ],
      "description": "Linear plan coordinates and unsuffixed dimensions use this unit. area fields use its square. Internally normalized once to metres; fields explicitly suffixed M/M2 remain metres."
    }
  },
  "additionalProperties": true,
  "allOf": [
    {
      "anyOf": [
        {
          "required": [
            "plot"
          ]
        },
        {
          "allOf": [
            {
              "not": {
                "required": [
                  "plot"
                ]
              }
            },
            {
              "required": [
                "width",
                "facing"
              ]
            },
            {
              "anyOf": [
                {
                  "required": [
                    "length"
                  ]
                },
                {
                  "required": [
                    "depth"
                  ]
                },
                {
                  "required": [
                    "height"
                  ]
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "oneOf": [
        {
          "allOf": [
            {
              "required": [
                "rooms"
              ]
            },
            {
              "not": {
                "required": [
                  "layout"
                ]
              }
            }
          ]
        },
        {
          "allOf": [
            {
              "required": [
                "layout"
              ]
            },
            {
              "not": {
                "required": [
                  "rooms"
                ]
              }
            }
          ]
        }
      ]
    },
    {
      "oneOf": [
        {
          "allOf": [
            {
              "not": {
                "anyOf": [
                  {
                    "required": [
                      "constraints"
                    ]
                  },
                  {
                    "required": [
                      "lockedRooms"
                    ]
                  },
                  {
                    "required": [
                      "wetShafts"
                    ]
                  },
                  {
                    "required": [
                      "plumbingStacks"
                    ]
                  },
                  {
                    "required": [
                      "loadBearingWalls"
                    ]
                  },
                  {
                    "required": [
                      "columns"
                    ]
                  },
                  {
                    "required": [
                      "minSizes"
                    ]
                  },
                  {
                    "required": [
                      "rooms"
                    ],
                    "properties": {
                      "rooms": {
                        "not": {
                          "items": {
                            "not": {
                              "required": [
                                "locked"
                              ]
                            }
                          }
                        }
                      }
                    }
                  },
                  {
                    "required": [
                      "layout"
                    ],
                    "properties": {
                      "layout": {
                        "not": {
                          "items": {
                            "not": {
                              "required": [
                                "locked"
                              ]
                            }
                          }
                        }
                      }
                    }
                  }
                ]
              }
            },
            {
              "properties": {
                "rooms": {
                  "items": {
                    "required": [
                      "name",
                      "zone"
                    ]
                  }
                },
                "layout": {
                  "items": {
                    "required": [
                      "name",
                      "zone"
                    ]
                  }
                }
              }
            }
          ]
        },
        {
          "allOf": [
            {
              "anyOf": [
                {
                  "required": [
                    "constraints"
                  ]
                },
                {
                  "required": [
                    "lockedRooms"
                  ]
                },
                {
                  "required": [
                    "wetShafts"
                  ]
                },
                {
                  "required": [
                    "plumbingStacks"
                  ]
                },
                {
                  "required": [
                    "loadBearingWalls"
                  ]
                },
                {
                  "required": [
                    "columns"
                  ]
                },
                {
                  "required": [
                    "minSizes"
                  ]
                },
                {
                  "required": [
                    "rooms"
                  ],
                  "properties": {
                    "rooms": {
                      "not": {
                        "items": {
                          "not": {
                            "required": [
                              "locked"
                            ]
                          }
                        }
                      }
                    }
                  }
                },
                {
                  "required": [
                    "layout"
                  ],
                  "properties": {
                    "layout": {
                      "not": {
                        "items": {
                          "not": {
                            "required": [
                              "locked"
                            ]
                          }
                        }
                      }
                    }
                  }
                }
              ]
            },
            {
              "required": [
                "plot"
              ],
              "properties": {
                "plot": {
                  "required": [
                    "units"
                  ],
                  "properties": {
                    "units": {
                      "enum": [
                        "m"
                      ]
                    }
                  }
                },
                "rooms": {
                  "maxItems": 16,
                  "items": {
                    "required": [
                      "polygon"
                    ],
                    "anyOf": [
                      {
                        "required": [
                          "id"
                        ]
                      },
                      {
                        "required": [
                          "name"
                        ]
                      }
                    ],
                    "properties": {
                      "id": {
                        "type": "string",
                        "minLength": 1,
                        "pattern": "\\S"
                      }
                    }
                  }
                },
                "layout": {
                  "maxItems": 16,
                  "items": {
                    "required": [
                      "polygon"
                    ],
                    "anyOf": [
                      {
                        "required": [
                          "id"
                        ]
                      },
                      {
                        "required": [
                          "name"
                        ]
                      }
                    ],
                    "properties": {
                      "id": {
                        "type": "string",
                        "minLength": 1,
                        "pattern": "\\S"
                      }
                    }
                  }
                }
              }
            }
          ]
        }
      ]
    }
  ],
  "$defs": {
    "VastuOptimizationConstraints": {
      "type": "object",
      "properties": {
        "lockedRooms": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "wetShafts": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "polygon": {
                "type": "array",
                "items": {
                  "type": "array",
                  "items": {
                    "type": "number"
                  },
                  "maxItems": 2,
                  "minItems": 2
                },
                "maxItems": 256,
                "minItems": 3
              },
              "roomIds": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "maxDistanceM": {
                "type": "number",
                "minimum": 0
              }
            },
            "required": [
              "id",
              "polygon"
            ],
            "additionalProperties": false
          },
          "maxItems": 64
        },
        "plumbingStacks": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "polygon": {
                "type": "array",
                "items": {
                  "type": "array",
                  "items": {
                    "type": "number"
                  },
                  "maxItems": 2,
                  "minItems": 2
                },
                "maxItems": 256,
                "minItems": 3
              },
              "roomIds": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "maxDistanceM": {
                "type": "number",
                "minimum": 0
              }
            },
            "required": [
              "id",
              "polygon"
            ],
            "additionalProperties": false
          },
          "maxItems": 64
        },
        "loadBearingWalls": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "polygon": {
                "type": "array",
                "items": {
                  "type": "array",
                  "items": {
                    "type": "number"
                  },
                  "maxItems": 2,
                  "minItems": 2
                },
                "maxItems": 256,
                "minItems": 3
              }
            },
            "required": [
              "polygon"
            ],
            "additionalProperties": false
          },
          "maxItems": 128
        },
        "columns": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "polygon": {
                "type": "array",
                "items": {
                  "type": "array",
                  "items": {
                    "type": "number"
                  },
                  "maxItems": 2,
                  "minItems": 2
                },
                "maxItems": 256,
                "minItems": 3
              }
            },
            "required": [
              "polygon"
            ],
            "additionalProperties": false
          },
          "maxItems": 128
        },
        "minSizes": {
          "type": "object",
          "additionalProperties": {
            "type": "object",
            "properties": {
              "minAreaM2": {
                "type": "number",
                "minimum": 0
              },
              "minWidthM": {
                "type": "number",
                "minimum": 0
              },
              "minHeightM": {
                "type": "number",
                "minimum": 0
              }
            },
            "required": [],
            "additionalProperties": false
          }
        }
      },
      "required": [],
      "additionalProperties": false
    },
    "VastuPlanDimension": {
      "oneOf": [
        {
          "type": "number",
          "minimum": 0,
          "exclusiveMinimum": true
        },
        {
          "type": "string",
          "pattern": "^\\s*[+]?(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)(?:[eE][+-]?[0-9]+)?\\s*$",
          "description": "Numeric string parsed as a finite number; must be > 0."
        }
      ]
    },
    "VastuPlanFacing": {
      "type": "string",
      "pattern": "^(?:[^A-Za-z]*(?:[nN][^A-Za-z]*[eE]|[eE][^A-Za-z]*[nN][^A-Za-z]*[eE]|[nN][^A-Za-z]*[nN][^A-Za-z]*[eE]|[nN][^A-Za-z]*[wW]|[wW][^A-Za-z]*[nN][^A-Za-z]*[wW]|[nN][^A-Za-z]*[nN][^A-Za-z]*[wW]|[sS][^A-Za-z]*[wW]|[wW][^A-Za-z]*[sS][^A-Za-z]*[wW]|[sS][^A-Za-z]*[sS][^A-Za-z]*[wW]|[sS][^A-Za-z]*[eE]|[eE][^A-Za-z]*[sS][^A-Za-z]*[eE]|[sS][^A-Za-z]*[sS][^A-Za-z]*[eE]|[nN]|[nN][^A-Za-z]*[oO][^A-Za-z]*[rR][^A-Za-z]*[tT][^A-Za-z]*[hH]|[sS]|[sS][^A-Za-z]*[oO][^A-Za-z]*[uU][^A-Za-z]*[tT][^A-Za-z]*[hH]|[yY][^A-Za-z]*[aA][^A-Za-z]*[mM][^A-Za-z]*[aA]|[eE]|[eE][^A-Za-z]*[aA][^A-Za-z]*[sS][^A-Za-z]*[tT]|[iI][^A-Za-z]*[nN][^A-Za-z]*[dD][^A-Za-z]*[rR][^A-Za-z]*[aA]|[wW]|[wW][^A-Za-z]*[eE][^A-Za-z]*[sS][^A-Za-z]*[tT])[^A-Za-z]*|[\\s\\S]*(?:[nN][^A-Za-z]*[oO][^A-Za-z]*[rR][^A-Za-z]*[tT][^A-Za-z]*[hH][^A-Za-z]*[eE][^A-Za-z]*[aA][^A-Za-z]*[sS][^A-Za-z]*[tT]|[iI][^A-Za-z]*[sS][^A-Za-z]*[hH][^A-Za-z]*[aA][^A-Za-z]*[nN]|[nN][^A-Za-z]*[oO][^A-Za-z]*[rR][^A-Za-z]*[tT][^A-Za-z]*[hH][^A-Za-z]*[wW][^A-Za-z]*[eE][^A-Za-z]*[sS][^A-Za-z]*[tT]|[vV][^A-Za-z]*[aA][^A-Za-z]*[yY][^A-Za-z]*[aA][^A-Za-z]*[vV]|[sS][^A-Za-z]*[oO][^A-Za-z]*[uU][^A-Za-z]*[tT][^A-Za-z]*[hH][^A-Za-z]*[wW][^A-Za-z]*[eE][^A-Za-z]*[sS][^A-Za-z]*[tT]|[nN][^A-Za-z]*[aA][^A-Za-z]*[iI][^A-Za-z]*[rR][^A-Za-z]*[uU]|[pP][^A-Za-z]*[iI][^A-Za-z]*[tT][^A-Za-z]*[rR][^A-Za-z]*[uU]|[sS][^A-Za-z]*[oO][^A-Za-z]*[uU][^A-Za-z]*[tT][^A-Za-z]*[hH][^A-Za-z]*[eE][^A-Za-z]*[aA][^A-Za-z]*[sS][^A-Za-z]*[tT]|[aA][^A-Za-z]*[gG][^A-Za-z]*[nN][^A-Za-z]*[eE][^A-Za-z]*[yY]|[aA][^A-Za-z]*[gG][^A-Za-z]*[nN][^A-Za-z]*[iI]|[kK][^A-Za-z]*[uU][^A-Za-z]*[bB][^A-Za-z]*[eE][^A-Za-z]*[rR]|[uU][^A-Za-z]*[tT][^A-Za-z]*[tT][^A-Za-z]*[aA][^A-Za-z]*[rR]|[dD][^A-Za-z]*[aA][^A-Za-z]*[kK][^A-Za-z]*[sS][^A-Za-z]*[hH][^A-Za-z]*[iI][^A-Za-z]*[nN]|[pP][^A-Za-z]*[uU][^A-Za-z]*[rR][^A-Za-z]*[vV][^A-Za-z]*[aA]|[vV][^A-Za-z]*[aA][^A-Za-z]*[rR][^A-Za-z]*[uU][^A-Za-z]*[nN]|[pP][^A-Za-z]*[aA][^A-Za-z]*[sS][^A-Za-z]*[cC][^A-Za-z]*[hH][^A-Za-z]*[iI][^A-Za-z]*[mM])[\\s\\S]*)$",
      "description": "Caller-supplied compass direction. Accepts normalized English and Sanskrit direction aliases; CENTER and unknown directions are invalid."
    },
    "VastuPlanFloorCount": {
      "oneOf": [
        {
          "type": "integer",
          "minimum": 1,
          "maximum": 5
        },
        {
          "type": "string",
          "pattern": "^\\s*[+]?(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)(?:[eE][+-]?[0-9]+)?\\s*$",
          "description": "Numeric string parsed as a finite integer; must be >= 1 and <= 5."
        }
      ]
    },
    "VastuPlanNonnegativeNumber": {
      "oneOf": [
        {
          "type": "number",
          "minimum": 0
        },
        {
          "type": "string",
          "pattern": "^\\s*[+]?(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)(?:[eE][+-]?[0-9]+)?\\s*$",
          "description": "Numeric string parsed as a finite number; must be >= 0."
        }
      ]
    },
    "VastuPlanPhysicalPlot": {
      "type": "object",
      "properties": {
        "width": {
          "$ref": "#/$defs/VastuPlanDimension"
        },
        "length": {
          "$ref": "#/$defs/VastuPlanDimension"
        },
        "facing": {
          "$ref": "#/$defs/VastuPlanFacing"
        },
        "polygon": {
          "$ref": "#/$defs/VastuPlanPolygon"
        },
        "setbacks": {
          "$ref": "#/$defs/VastuPlanSetbacks"
        },
        "depth": {
          "$ref": "#/$defs/VastuPlanDimension"
        },
        "height": {
          "$ref": "#/$defs/VastuPlanDimension"
        },
        "corners": {
          "$ref": "#/$defs/VastuPlanPolygon"
        },
        "plotPolygon": {
          "$ref": "#/$defs/VastuPlanPolygon"
        },
        "setback": {
          "$ref": "#/$defs/VastuPlanSetbacks"
        },
        "shape": {
          "type": "string",
          "description": "Optional shape label. \"rectangle\" (or \"rectangular\", \"square\", \"regular\") needs only width and length. \"irregular\" (or \"polygon\", \"custom\", \"l-shape\", \"cut\", \"triangle\", \"trapezoid\") requires the traced corners in polygon; without them the request is rejected instead of silently drawing a rectangle.",
          "enum": [
            "rectangle",
            "rectangular",
            "square",
            "regular",
            "irregular",
            "polygon",
            "custom",
            "l-shape",
            "l-shaped",
            "cut",
            "triangle",
            "triangular",
            "trapezoid",
            "trapezium"
          ]
        },
        "plotShape": {
          "type": "string",
          "description": "Optional shape label. \"rectangle\" (or \"rectangular\", \"square\", \"regular\") needs only width and length. \"irregular\" (or \"polygon\", \"custom\", \"l-shape\", \"cut\", \"triangle\", \"trapezoid\") requires the traced corners in polygon; without them the request is rejected instead of silently drawing a rectangle.",
          "enum": [
            "rectangle",
            "rectangular",
            "square",
            "regular",
            "irregular",
            "polygon",
            "custom",
            "l-shape",
            "l-shaped",
            "cut",
            "triangle",
            "triangular",
            "trapezoid",
            "trapezium"
          ]
        },
        "units": {
          "type": "string",
          "enum": [
            "m",
            "ft"
          ]
        },
        "floors": {
          "allOf": [
            {
              "$ref": "#/$defs/VastuPlanFloorCount"
            }
          ],
          "description": "Storeys in the building, 1 to 5. Optional. On plan/generate and plan/from-requirements the plan returns exactly this many storeys; when the brief or floors[] also gives a storey count the two must match (a mismatch is a 400 naming both fields), and when the brief omits floors this value is used. On plan/optimize the layout's floor must be below it."
        }
      },
      "additionalProperties": false,
      "required": [
        "facing"
      ],
      "anyOf": [
        {
          "required": [
            "width",
            "length"
          ]
        },
        {
          "required": [
            "width",
            "depth"
          ]
        },
        {
          "required": [
            "width",
            "height"
          ]
        },
        {
          "required": [
            "polygon"
          ]
        },
        {
          "required": [
            "corners"
          ]
        },
        {
          "required": [
            "plotPolygon"
          ]
        }
      ],
      "description": "Plot dimensions and facing. With traced corners (polygon, corners or plotPolygon) width and length are optional: a missing one is taken from the outline's bounding box, and a single stated side scales the other by the outline's proportions. Corners may be in any units; they are normalised onto width x length."
    },
    "VastuPlanPolygon": {
      "type": "array",
      "minItems": 3,
      "items": {
        "oneOf": [
          {
            "type": "array",
            "minItems": 2,
            "maxItems": 2,
            "items": {
              "type": "number"
            }
          },
          {
            "type": "object",
            "required": [
              "x",
              "y"
            ],
            "properties": {
              "x": {
                "type": "number"
              },
              "y": {
                "type": "number"
              }
            },
            "additionalProperties": true
          }
        ]
      },
      "description": "Traced ring as [x, y] pairs or {x, y} objects. Coordinates must be finite numbers. Runtime also requires at least three distinct corners enclosing nonzero area."
    },
    "VastuPlanRegion": {
      "type": "object",
      "required": [
        "polygon"
      ],
      "properties": {
        "polygon": {
          "$ref": "#/$defs/VastuPlanPolygon"
        },
        "holes": {
          "type": "array",
          "maxItems": 64,
          "items": {
            "$ref": "#/$defs/VastuPlanPolygon"
          }
        }
      },
      "description": "Filled outer boundary minus disjoint interior rings. Voids must lie strictly inside."
    },
    "VastuPlanRoomFloor": {
      "oneOf": [
        {
          "type": "integer",
          "minimum": 0,
          "maximum": 20
        },
        {
          "type": "string",
          "pattern": "^\\s*[+]?(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)(?:[eE][+-]?[0-9]+)?\\s*$",
          "description": "Numeric string parsed as a finite integer; must be >= 0 and <= 20."
        }
      ]
    },
    "VastuPlanSetbacks": {
      "type": "object",
      "properties": {
        "front": {
          "$ref": "#/$defs/VastuPlanNonnegativeNumber"
        },
        "rear": {
          "$ref": "#/$defs/VastuPlanNonnegativeNumber"
        },
        "left": {
          "$ref": "#/$defs/VastuPlanNonnegativeNumber"
        },
        "right": {
          "$ref": "#/$defs/VastuPlanNonnegativeNumber"
        },
        "back": {
          "$ref": "#/$defs/VastuPlanNonnegativeNumber"
        },
        "north": {
          "$ref": "#/$defs/VastuPlanNonnegativeNumber"
        },
        "east": {
          "$ref": "#/$defs/VastuPlanNonnegativeNumber"
        },
        "south": {
          "$ref": "#/$defs/VastuPlanNonnegativeNumber"
        },
        "west": {
          "$ref": "#/$defs/VastuPlanNonnegativeNumber"
        }
      },
      "additionalProperties": false
    }
  }
}