<?php

namespace App\Manager\Toolbar\Definition;

use App\Manager\Toolbar\Element\ToolbarButton;
use App\Manager\Toolbar\Element\ToolbarDivider;

class ChapterListToolbar extends Toolbar
{
    public function __construct(array $contextData = [])
    {
        $monitoredTitle = $contextData['isMonitored'] ? 'Monitored' : 'Monitoring';
        $monitoredColor = $contextData['isMonitored'] ? 'text-green-500' : 'text-white';

        $this
            ->addToLeftGroup(new ToolbarButton('arrows-rotate', 'Refresh metadata', 'toolbar#refreshMetadata', $contextData))
            ->addToLeftGroup(new ToolbarDivider())
            ->addToLeftGroup(new ToolbarButton('keyboard', 'Rename chapters', 'toolbar#renameChapters'))
            ->addToLeftGroup(new ToolbarButton('file-zipper', 'Manage cbz', 'toolbar#manageCbz', $contextData))
            ->addToLeftGroup(new ToolbarButton('gear', 'Preferred Sources', 'toolbar#editPreferredSources', $contextData))


            ->addToRightGroup(new ToolbarButton('bookmark', $monitoredTitle, 'toolbar#monitoring', array_merge($contextData, ['buttonClass' => $monitoredColor])))
            ->addToRightGroup(new ToolbarButton('wrench', 'Edit', 'toolbar#editManga', $contextData))
            ->addToRightGroup(new ToolbarButton('trash-can', 'Delete', 'toolbar#deleteManga', $contextData))
            ->addToRightGroup(new ToolbarDivider())
            ->addToRightGroup(new ToolbarButton('chevron-down', 'Expand all', 'toolbar#expandAll'));
    }
}
