<?php

declare(strict_types=1);

namespace App\Notifications\Auth;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;

class LegalConsentConfirmation extends Notification implements ShouldQueue
{
    use Queueable;

    public function __construct(
        protected array $consents
    ) {}

    /**
     * @return array<int, string>
     */
    public function via(object $notifiable): array
    {
        return ['mail', 'database'];
    }

    public function toMail(object $notifiable): MailMessage
    {
        $appName = config('app.name');
        $tosVersion = $this->consents['tos'] ?? 1;
        $privacyVersion = $this->consents['privacy'] ?? 1;
        $signedAt = now()->format('d M Y, H:i T');

        return (new MailMessage)
            ->subject(__(':app — Official Confirmation of Legal Consents and Agreements', ['app' => $appName]))
            ->greeting(__('Dear :name,', ['name' => $notifiable->name]))
            ->line(__('Welcome to :app. This communication serves as the official and legally binding confirmation of the agreements executed during your account provisioning process.', ['app' => $appName]))
            ->line('**'.__('Executed Legal Documents Portfolio').'**')
            ->line('• '.__('Terms of Use — version :version', ['version' => $tosVersion]))
            ->line('• '.__('Privacy Policy — version :version', ['version' => $privacyVersion]))
            ->line(__('Timestamp of Execution: :date.', ['date' => $signedAt]))
            ->action(__('Access Official Documentation'), route('legal.show', 'privacy'))
            ->line(__('Please be advised that a cryptographically hashed record of this consent has been securely archived within our immutable audit trail, ensuring strict adherence to regulatory compliance frameworks, notably **UU PDP No. 27/2022**.'))
            ->line(__('Should you require further clarification regarding your data privacy rights—including formal requests for data portability, rectification, or erasure—please direct your inquiries to our designated Data Protection Officer via return correspondence. Our standard SLA for such requests is 7 business days.'))
            ->salutation(__('Sincerely,')."\n**".$appName." Legal & Compliance Division**");
    }

    /**
     * @return array<string, mixed>
     */
    public function toArray(object $notifiable): array
    {
        return [];
    }
}
