<?php

declare(strict_types=1);

namespace Drupal\ffmpeg_media\Form\SettingsTab;

use Drupal\Core\Config\Config;
use Drupal\Core\StringTranslation\StringTranslationTrait;

/**
 * Builds the Whisper transcription tab for the FFmpeg Media settings form.
 *
 * @internal
 */
final class WhisperSettingsBuilder {

  use StringTranslationTrait;

  /**
   * Builds the Whisper section render array.
   *
   * @param array<string, mixed> $form
   *   Form structure, passed by reference.
   * @param \Drupal\Core\Config\Config $config
   *   Module configuration.
   */
  public function build(array &$form, Config $config): void {
    $form['whisper'] = [
      '#type' => 'details',
      '#title' => $this->t('Transcription'),
      '#description' => $this->t('Whisper settings are configured in the <a href=":url">Whisper settings</a> page when the ffmpeg_media_whisper submodule is enabled.', [
        ':url' => '/admin/config/media/ffmpeg-media/whisper',
      ]),
      '#group' => 'settings_tabs',
      '#open' => FALSE,
      '#states' => [
        'visible' => [
          ':input[name="enabled_processors[whisper]"]' => ['checked' => TRUE],
        ],
      ],
    ];
  }

}
