<?php

namespace App\Http\Requests;

use App\Models\Client;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;

class ProfileUpdateRequest extends FormRequest
{
    /**
     * Get the validation rules that apply to the request.
     *
     * @return array<string, \Illuminate\Contracts\Validation\Rule|array|string>
     */
    public function rules(): array
    {
        return [
            'name' => ['string', 'max:255'],
            'email' => ['email', 'max:255', Rule::unique(Client::class)->ignore($this->user()->id)],

            // Notification channel IDs
            'phone' => ['nullable', 'string', 'max:20'],
            'slack_user_id' => ['nullable', 'string', 'max:255'],
            'telegram_user_id' => ['nullable', 'string', 'max:255'],
            'discord_webhook' => ['nullable', 'url', 'max:500'],
            'teams_webhook' => ['nullable', 'url', 'max:2048'], // PRC-782 — Workflows SAS URL 1000+ char
            'pushover_user_key' => ['nullable', 'string', 'max:255'],

            // Per-admin notification preferences
            'notification_preferences' => ['nullable', 'array'],
            'notification_preferences.*' => ['nullable', 'array'],
            'notification_preferences.*.*' => ['string', 'in:email,slack,telegram,discord,teams,whatsapp,pushover,sms'],
        ];
    }
}
