<?php

declare(strict_types=1);

namespace PHPMax\Domain\Events;

use PHPMax\Domain\ReactionCounter;
use PHPMax\Support\Model;

class ReactionUpdateEvent extends Model
{
     
    public $messageId;
     
    public $chatId;
     
    public $counters = [];
     
    public $totalCount;

    protected static function schema(): array
    {
        return [
            'messageId' => ['type' => 'string', 'required' => true],
            'chatId' => ['type' => 'int', 'required' => true],
            'counters' => ['type' => 'list<' . ReactionCounter::class . '>', 'default' => static function (): array {
                return [];
            }],
            'totalCount' => ['type' => 'int', 'required' => true],
        ];
    }

    protected static function normalizeInput(array $data): array
    {
         
         
        if (array_key_exists('messageId', $data) && (is_int($data['messageId']) || is_float($data['messageId']))) {
            $data['messageId'] = (string)$data['messageId'];
        }
        if (array_key_exists('message_id', $data) && (is_int($data['message_id']) || is_float($data['message_id']))) {
            $data['message_id'] = (string)$data['message_id'];
        }

        return $data;
    }
}
