<?php

declare(strict_types=1);

/** POST /api/v1/design/creative-library/navigation/clear */
final class MyronClearCreativeLibraryNavStyleAction implements MyronAction
{
    public function __construct(private readonly MyronSiteSettingsRepository $settings) {}

    public function metadata(): MyronActionMetadata
    {
        return new MyronActionMetadata(
            uri: '/api/v1/design/creative-library/navigation/clear', method: 'POST',
            domain: 'design', resource: 'creative_library', verb: 'clear-navigation',
            inputSchema: ['type' => 'object', 'properties' => []],
            outputSchema: ['type' => 'object', 'properties' => ['navStyle' => ['type' => ['string', 'null']], 'navParams' => ['type' => 'object'], 'btnStyle' => ['type' => ['string', 'null']]]],
            requiredScope: MyronApiScopes::DESIGN_WRITE,
            summary: 'Clear the active site-level navigation creative.',
            sideEffects: ['clears site_settings.creative_nav_style', 'clears site_settings.creative_nav_params_json'], audienceClass: 4,
            adminAliases: ['clear-nav-style'], snapshotInclude: false, exposeToMcp: true,
        );
    }

    public function execute(array $input, MyronActionCallerContext $caller): MyronActionResult
    {
        $current = $this->settings->creativeSettings();
        return MyronActionResult::ok($this->settings->saveCreativeSettings(null, $current['btnStyle'] ?? null, []));
    }
}
