<?php
namespace EasyChat\Library\Messenger\Marketplace;

class MarketplaceStream {
    public const BUYER_CHAT = 'buyer_chat';
    public const QUESTION = 'question';
    public const REVIEW = 'review';
    public const RETURN_CLAIM = 'return_claim';

    public static function all(): array {
        return [self::BUYER_CHAT, self::QUESTION, self::REVIEW, self::RETURN_CLAIM];
    }

    public static function normalize($stream): string {
        $stream = strtolower(preg_replace('/[^a-z0-9_\-]/i', '', (string)$stream));
        return in_array($stream, self::all(), true) ? $stream : '';
    }

    public static function label(string $stream): string {
        return [
            self::BUYER_CHAT => 'Чаты с покупателями',
            self::QUESTION => 'Вопросы о товарах',
            self::REVIEW => 'Отзывы',
            self::RETURN_CLAIM => 'Возвраты',
        ][self::normalize($stream)] ?? 'Обращения';
    }
}
