<?php

namespace Database\Factories;

use App\Enums\MediaClassification;
use App\Enums\MediaType;
use App\Models\Company;
use App\Models\PartnerMedia;
use Illuminate\Database\Eloquent\Factories\Factory;

/**
 * @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\PartnerMedia>
 */
class PartnerMediaFactory extends Factory
{
    protected $model = PartnerMedia::class;

    /**
     * Define the model's default state.
     *
     * @return array<string, mixed>
     */
    public function definition(): array
    {
        $mediaNames = [
            'Kompas.com',
            'Detik.com',
            'Tribun News',
            'Liputan6',
            'CNN Indonesia',
            'ANTARA News',
            'Tempo.co',
            'Okezone',
            'Suara.com',
            'Bisnis.com',
            'Media Indonesia',
            'Republika',
            'Koran Sindo',
            'Pikiran Rakyat',
        ];

        return [
            'company_id' => Company::factory(),
            'name' => $this->faker->randomElement($mediaNames),
            'address' => $this->faker->address(),
            'link' => $this->faker->optional(0.8)->url(),
            'type' => $this->faker->randomElement(MediaType::cases())->value,
            'classification' => $this->faker->randomElement(MediaClassification::cases())->value,
            'journalism_organization' => $this->faker->optional(0.6)->randomElement([
                'Persatuan Wartawan Indonesia (PWI)',
                'Aliansi Jurnalis Independen (AJI)',
                'Ikatan Jurnalis Televisi Indonesia (IJTI)',
                'Persatuan Jurnalis Online Indonesia (PJOI)',
            ]),
            'press_council_certificate' => $this->faker->optional(0.7)->numerify('DEP-###/####/KP'),
        ];
    }

    /**
     * Indicate that the partner media is online type.
     */
    public function online(): static
    {
        return $this->state(fn (array $attributes) => [
            'type' => MediaType::ONLINE->value,
            'link' => $this->faker->url(),
        ]);
    }

    /**
     * Indicate that the partner media is print type.
     */
    public function print(): static
    {
        return $this->state(fn (array $attributes) => [
            'type' => MediaType::PRINT->value,
            'link' => null,
        ]);
    }

    /**
     * Indicate that the partner media is television type.
     */
    public function television(): static
    {
        return $this->state(fn (array $attributes) => [
            'type' => MediaType::TELEVISION->value,
        ]);
    }

    /**
     * Indicate that the partner media is radio type.
     */
    public function radio(): static
    {
        return $this->state(fn (array $attributes) => [
            'type' => MediaType::RADIO->value,
        ]);
    }

    /**
     * Indicate that the partner media is national classification.
     */
    public function national(): static
    {
        return $this->state(fn (array $attributes) => [
            'classification' => MediaClassification::NATIONAL->value,
        ]);
    }

    /**
     * Indicate that the partner media is local classification.
     */
    public function local(): static
    {
        return $this->state(fn (array $attributes) => [
            'classification' => MediaClassification::LOCAL->value,
        ]);
    }
}
