{
	"$schema": "http://json-schema.org/draft-07/schema#",
	"$id": "https://cdn.jsdelivr.net/npm/create-wp-reactor/schema/block-contract.schema.json",
	"title": "WP Reactor — contrat de schéma de bloc",
	"description": "Schéma des fichiers schemas/<slug>.json consommés par gen-block.",
	"type": "object",
	"required": ["slug", "attributes"],
	"additionalProperties": false,
	"properties": {
		"$schema": { "type": "string" },
		"schemaVersion": {
			"type": "string",
			"description": "Version du contrat. Supportée : 1.0.0."
		},
		"slug": {
			"type": "string",
			"minLength": 1,
			"description": "Identifiant kebab-case du bloc (ex. cta-banner)."
		},
		"title": { "type": "string" },
		"category": { "type": "string" },
		"icon": { "type": "string" },
		"description": { "type": "string" },
		"supports": { "type": "object" },
		"attributes": {
			"type": "object",
			"minProperties": 1,
			"description": "camelCase → définition de champ.",
			"propertyNames": { "pattern": "^[a-z][a-zA-Z0-9]*$" },
			"additionalProperties": { "$ref": "#/$defs/attribute" }
		}
	},
	"$defs": {
		"attribute": {
			"type": "object",
			"additionalProperties": false,
			"properties": {
				"ui": {
					"description": "UI éditeur (détermine le type WP + TS). Casse/alias tolérés par gen-block.",
					"enum": [
						"TextInput",
						"Textarea",
						"RichText",
						"Title",
						"Select",
						"Toggle",
						"Number",
						"Image",
						"Video",
						"Cta",
						"Object",
						"Query",
						"ArrayRepeater",
						"QueryIds",
						"TermSelect"
					]
				},
				"type": {
					"type": "string",
					"description": "Type WP brut (legacy/compat ; `ui` suffit normalement)."
				},
				"default": {},
				"label": { "type": "string" },
				"placeholder": { "type": "string" },
				"rows": { "type": "number" },
				"postType": { "type": "string" },
				"taxonomy": {
					"type": "string",
					"description": "Base REST de la taxonomie pour l'UI TermSelect (ex. product_cat)."
				},
				"options": {
					"type": "array",
					"items": {
						"type": "object",
						"required": ["label", "value"],
						"properties": {
							"label": { "type": "string" },
							"value": { "type": "string" }
						}
					}
				},
				"enum": { "type": "array", "items": { "type": "string" } },
				"fields": {
					"type": "array",
					"description": "Sous-champs (Object / Query / ArrayRepeater).",
					"items": {
						"allOf": [
							{ "$ref": "#/$defs/attribute" },
							{ "properties": { "key": { "type": "string" } } }
						]
					}
				},
				"key": { "type": "string" },
				"conditional": { "$ref": "#/$defs/conditional" }
			},
			"anyOf": [{ "required": ["ui"] }, { "required": ["type"] }]
		},
		"conditional": {
			"type": "object",
			"additionalProperties": false,
			"description": "N'afficher ce champ dans l'éditeur que si context[field] === value. Dans un ArrayRepeater/Object, `field` cible un champ frère de la même ligne.",
			"required": ["field", "value"],
			"properties": {
				"field": {
					"type": "string",
					"description": "Nom (camelCase) de l'attribut dont dépend l'affichage."
				},
				"value": {
					"type": "string",
					"description": "Valeur attendue pour afficher ce champ."
				}
			}
		}
	}
}
