<?php

namespace App\Modules\BookingEquipmentPassenger\Application\List;

use App\Modules\BookingEquipmentPassenger\Application\BookingEquipmentPassengerResponse;
use App\Modules\BookingEquipmentPassenger\Application\BookingEquipmentPassengerResponses;
use App\Modules\Shared\Domain\Bus\Query\QueryHandler;

final class ListBookingEquipmentPassengerQueryHandler implements QueryHandler
{
    public function __construct(private BookingEquipmentPassengerLister $lister) {}



    public function __invoke(ListBookingEquipmentPassengerQuery $query): BookingEquipmentPassengerResponses
    {
        return new BookingEquipmentPassengerResponses(...array_map(
            fn($index) => new BookingEquipmentPassengerResponse(
                $index->id()->value(),
                $index->status()->value(),
                $index->idBookingEquipment()->value(),
                $index->idBookingTourPassenger()->value(),
                $index->idPassenger()->value(),
                $index->passengerGender()->value(),
                $index->passengerName()->value(),
                $index->passengerLastName()->value(),
                $index->idBookingTour()->value(),
                $index->bookingTourTourName()->value(),
                $index->bookingTourDateStart()->value(),
                $index->bookingTourTourDuration()->value(),
                $index->idBooking()->value(),
                $index->bookingCode()->value(),
                $index->bookingInternalRemark()->value(),
                $index->bookingObservation()->value(),
                $index->idUserCountry()->value(),
                config('var.PATH_PUBLIC') . config('var.USER_COUNTRY_THUMB') . $index->userCountryImg()->value(),
                $index->userCountryName()->value()
            ),
            $this->lister->__invoke($query->ids, $query->idBookingEquipments, $query->idBookingTourPassengers)
        ));
    }
}
