<?php

declare(strict_types=1);

namespace App\Support\Tenants;

use App\Models\Tenant;
use App\Models\TenantOnboardingSession;
use App\Models\User;

final readonly class TenantOperabilityContext
{
    public function __construct(
        public Tenant $tenant,
        public ?User $actor,
        public ?int $workspaceId,
        public TenantInteractionLane $lane,
        public ?TenantPageCategory $pageCategory = null,
        public ?string $linkedRecordType = null,
        public ?int $linkedRecordId = null,
        public ?TenantOnboardingSession $onboardingDraft = null,
        public ?string $requiredCapability = null,
        public ?Tenant $selectedTenant = null,
    ) {}

    public static function forTenant(
        Tenant $tenant,
        ?User $actor = null,
        ?int $workspaceId = null,
        TenantInteractionLane $lane = TenantInteractionLane::AdministrativeManagement,
        ?TenantPageCategory $pageCategory = null,
        ?TenantOnboardingSession $onboardingDraft = null,
        ?string $requiredCapability = null,
        ?Tenant $selectedTenant = null,
        ?string $linkedRecordType = null,
        ?int $linkedRecordId = null,
    ): self {
        return new self(
            tenant: $tenant,
            actor: $actor,
            workspaceId: $workspaceId,
            lane: $lane,
            pageCategory: $pageCategory,
            linkedRecordType: $linkedRecordType,
            linkedRecordId: $linkedRecordId,
            onboardingDraft: $onboardingDraft,
            requiredCapability: $requiredCapability,
            selectedTenant: $selectedTenant,
        );
    }
}
