<?php

namespace App\Modules\Room\Application\ListAllNoRoomCount;

use App\Http\Controllers\Owner\Room\RoomListOrderBy;
use App\Http\Controllers\Owner\Room\RoomListOrderType;
use App\Modules\DefinedService\Location\Domain\IdLocation;
use App\Modules\Room\Domain\CountListAllNoRoom;
use App\Modules\Room\Domain\RoomRepository;
use App\Modules\Shared\Domain\DateEnd;
use App\Modules\Shared\Domain\DateStart;

final class RoomAllCountNoRoomLister
{
    public function __construct(private RoomRepository $repository) {}

    public function __invoke(
        string $dateStart,
        string $dateEnd,
        string $orderBy,
        string $orderType,
        array $idExtras,
        array $idTours,
        array $UpgradeStatuses,
        bool $allExtras,
        bool $allTours,
        bool $allUpgradeStatuses,
        int $idLocation,
        ?string $search,
    ): int {
        $result = $this->repository->search(new CountListAllNoRoom(
            new DateStart($dateStart),
            new DateEnd($dateEnd),
            new RoomListOrderBy($orderBy),
            new RoomListOrderType($orderType),
            [],
            $idExtras,
            $idTours,
            $UpgradeStatuses,
            $allExtras,
            $allTours,
            $allUpgradeStatuses,
            new IdLocation($idLocation),
            $search,
        ));

        return $result[0]->total ?? 0;
    }
}
