{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "type": "object",
    "additionalProperties": false,
    "properties": {
        "label": {
            "type": "string",
            "description": "The field label displayed in the edit screen",
            "minLength": 1
        },
        "type": {
            "type": "string",
            "enum": [
                "flexible_content"
            ],
            "description": "Field type identifier. Must be \"flexible_content\" for this field type."
        },
        "name": {
            "type": "string",
            "description": "The field name used to save/load data. Auto-generated from label if not provided.",
            "pattern": "^[a-z_][a-z0-9_]*$"
        },
        "key": {
            "type": "string",
            "description": "Unique field key. Auto-generated if not provided.",
            "pattern": "^field_[a-z0-9]+$"
        },
        "instructions": {
            "type": "string",
            "description": "Instructions displayed to editors below the field label"
        },
        "required": {
            "type": "boolean",
            "description": "Whether this field is required",
            "default": false
        },
        "conditional_logic": {
            "type": [
                "boolean",
                "array"
            ],
            "description": "Conditional logic rules. Set to false to disable, or provide an array of rule groups. Groups are combined with OR logic, rules within a group with AND logic.",
            "items": {
                "type": "array",
                "description": "Group of rules that must all match (AND logic)",
                "items": {
                    "type": "object",
                    "properties": {
                        "field": {
                            "type": "string",
                            "description": "The key of the field to compare against, e.g. field_123abc"
                        },
                        "operator": {
                            "type": "string",
                            "description": "Comparison operator, e.g. ==, !=, ==empty, !=empty, ==pattern, ==contains, >, <"
                        },
                        "value": {
                            "type": [
                                "string",
                                "number",
                                "integer",
                                "boolean"
                            ],
                            "description": "Value to compare against. Omit for ==empty and !=empty."
                        }
                    },
                    "required": [
                        "field",
                        "operator"
                    ]
                }
            },
            "default": false
        },
        "wrapper": {
            "type": "object",
            "description": "HTML wrapper attributes",
            "properties": {
                "width": {
                    "type": "string",
                    "description": "Width percentage (e.g., \"50\")"
                },
                "class": {
                    "type": "string",
                    "description": "Custom CSS classes"
                },
                "id": {
                    "type": "string",
                    "description": "Custom HTML ID"
                }
            }
        },
        "default_value": {
            "type": [
                "string",
                "number",
                "boolean",
                "null"
            ],
            "description": "Default value when creating new content"
        },
        "placeholder": {
            "type": "string",
            "description": "Placeholder text shown in empty fields"
        },
        "prepend": {
            "type": "string",
            "description": "Text to prepend before the input"
        },
        "append": {
            "type": "string",
            "description": "Text to append after the input"
        },
        "maxlength": {
            "type": "integer",
            "description": "Maximum character length (if applicable)",
            "minimum": 1
        },
        "allow_in_bindings": {
            "type": "boolean",
            "description": "Whether this field can be used in block bindings",
            "default": false
        },
        "layouts": {
            "type": "array",
            "description": "Array of layout configuration objects. Each layout represents a different content structure that editors can choose from. Each layout object should have: \"label\" (display name), \"name\" (machine name), \"sub_fields\" (array of field objects for this layout), \"display\" (layout style: \"table\", \"block\", or \"row\"), \"min\" (minimum instances of this layout), and \"max\" (maximum instances of this layout).",
            "items": {
                "type": "object",
                "properties": {
                    "label": {
                        "type": "string",
                        "description": "The display name for the layout",
                        "minLength": 1
                    },
                    "name": {
                        "type": "string",
                        "description": "The machine name for the layout. Generated from the label if omitted."
                    },
                    "display": {
                        "type": "string",
                        "enum": [
                            "table",
                            "block",
                            "row"
                        ],
                        "description": "The layout style",
                        "default": "block"
                    },
                    "sub_fields": {
                        "type": "array",
                        "description": "Fields shown in this layout",
                        "items": {
                            "type": "object",
                            "description": "A sub field definition. Accepts the same settings as a top-level field of the chosen type, including nested sub_fields or layouts.",
                            "properties": {
                                "label": {
                                    "type": "string",
                                    "description": "The label for the sub field",
                                    "minLength": 1
                                },
                                "name": {
                                    "type": "string",
                                    "description": "The name used to save and load the value. Generated from the label if omitted."
                                },
                                "type": {
                                    "type": "string",
                                    "description": "The field type, e.g. text, textarea, number, select, image, repeater"
                                }
                            },
                            "required": [
                                "label",
                                "type"
                            ]
                        },
                        "default": []
                    },
                    "min": {
                        "type": [
                            "integer",
                            "string"
                        ],
                        "description": "Minimum instances of this layout. Leave empty for no limit."
                    },
                    "max": {
                        "type": [
                            "integer",
                            "string"
                        ],
                        "description": "Maximum instances of this layout. Leave empty for no limit."
                    }
                },
                "required": [
                    "label"
                ]
            },
            "default": []
        },
        "min": {
            "type": "integer",
            "description": "Minimum total number of layouts required",
            "default": 0,
            "minimum": 0
        },
        "max": {
            "type": "integer",
            "description": "Maximum total number of layouts allowed (0 for unlimited)",
            "default": 0,
            "minimum": 0
        },
        "button_label": {
            "type": "string",
            "description": "Custom text for the \"Add Row\" button",
            "default": "Add Row"
        }
    },
    "required": [
        "label",
        "type"
    ]
}