<?php
/**
 * Global class write ability schemas.
 *
 * @package LolaCoreForBricks
 */

declare(strict_types=1);

namespace LolaCoreForBricks\Schemas;

use LolaCoreForBricks\AbilitiesProvider;

/**
 * Door 1 schemas for global class writes.
 */
class ClassWriteSchemas
{
    /**
     * @return array<string, array<string, mixed>>
     */
    public static function define(): array
    {
        $dryRun = [
            'dry_run' => [
                'type'        => 'boolean',
                'description' => 'Preview the write without saving changes.',
            ],
        ];

        return [
            'createGlobalClass' => [
                'description' => 'Create a Bricks global class with name, category, and initial settings. Warns when a near-duplicate already exists.',
                'category'    => AbilitiesProvider::CATEGORY,
                'keywords'    => [
                    'exact' => ['create global class', 'new bricks class', 'crear clase global'],
                    'stem'  => ['create', 'class', 'clase'],
                ],
                'parameters'  => [
                    'type'       => 'object',
                    'properties' => array_merge($dryRun, [
                        'name'     => ['type' => 'string'],
                        'category' => ['type' => 'string'],
                        'settings' => ['type' => 'object'],
                    ]),
                    'required'   => ['name'],
                ],
            ],
            'updateGlobalClassSettings' => [
                'description' => 'Update Bricks global class settings with full breakpoint and state grammar support.',
                'category'    => AbilitiesProvider::CATEGORY,
                'keywords'    => [
                    'exact' => ['update global class', 'edit class settings', 'editar clase global'],
                    'stem'  => ['update', 'settings', 'class'],
                ],
                'parameters'  => [
                    'type'       => 'object',
                    'properties' => array_merge($dryRun, [
                        'class'    => ['type' => 'string', 'description' => 'Global class id or name.'],
                        'settings' => ['type' => 'object'],
                    ]),
                    'required'   => ['class', 'settings'],
                ],
            ],
            'renameGlobalClass' => [
                'description' => 'Rename a Bricks global class. Call with dry_run first to see affected pages and elements.',
                'category'    => AbilitiesProvider::CATEGORY,
                'keywords'    => [
                    'exact' => ['rename global class', 'renombrar clase global'],
                    'stem'  => ['rename', 'class'],
                ],
                'parameters'  => [
                    'type'       => 'object',
                    'properties' => array_merge($dryRun, [
                        'class'    => ['type' => 'string', 'description' => 'Global class id or name.'],
                        'new_name' => ['type' => 'string'],
                    ]),
                    'required'   => ['class', 'new_name'],
                ],
            ],
            'mergeGlobalClasses' => [
                'description' => 'Replace one global class with another everywhere and move the source class to trash. Call with dry_run first to review impact.',
                'category'    => AbilitiesProvider::CATEGORY,
                'keywords'    => [
                    'exact' => ['merge global classes', 'fusionar clases globales'],
                    'stem'  => ['merge', 'class'],
                ],
                'parameters'  => [
                    'type'       => 'object',
                    'properties' => array_merge($dryRun, [
                        'source_class' => ['type' => 'string'],
                        'target_class' => ['type' => 'string'],
                    ]),
                    'required'   => ['source_class', 'target_class'],
                ],
            ],
            'trashGlobalClasses' => [
                'description' => 'Move Bricks global classes to the native trash (reversible). Call with dry_run first to review impact.',
                'category'    => AbilitiesProvider::CATEGORY,
                'keywords'    => [
                    'exact' => ['trash global class', 'delete global class', 'papelera clase global'],
                    'stem'  => ['trash', 'class'],
                ],
                'parameters'  => [
                    'type'       => 'object',
                    'properties' => array_merge($dryRun, [
                        'classes' => [
                            'type'        => 'array',
                            'items'       => ['type' => 'string'],
                            'description' => 'Global class ids or names.',
                        ],
                    ]),
                    'required'   => ['classes'],
                ],
            ],
            'restoreGlobalClass' => [
                'description' => 'Restore a Bricks global class from the native trash.',
                'category'    => AbilitiesProvider::CATEGORY,
                'keywords'    => [
                    'exact' => ['restore global class', 'restaurar clase global'],
                    'stem'  => ['restore', 'class'],
                ],
                'parameters'  => [
                    'type'       => 'object',
                    'properties' => array_merge($dryRun, [
                        'class' => ['type' => 'string', 'description' => 'Trashed global class id or name.'],
                    ]),
                    'required'   => ['class'],
                ],
            ],
        ];
    }
}
