<?php

declare(strict_types=1);

namespace Database\Factories;

use App\Models\BasicBasketProduct;
use App\Models\Store;
use App\Models\StoreProductTarget;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;

/**
 * @extends Factory<StoreProductTarget>
 */
class StoreProductTargetFactory extends Factory
{
    protected $model = StoreProductTarget::class;

    /**
     * @return array<string, mixed>
     */
    public function definition(): array
    {
        $storeName = $this->faker->company();
        $productName = ucfirst($this->faker->words(3, true));
        $slugBase = Str::slug($productName.'-'.$storeName);

        return [
            'basic_basket_product_id' => BasicBasketProduct::factory(),
            'store_id' => Store::factory(),
            'slug' => $slugBase.'-'.$this->faker->unique()->numberBetween(1, 9999),
            'name' => $productName.' - '.$storeName,
            'provider' => 'dataforseo_merchant_google_products',
            'search_query' => Str::lower($storeName.' '.$productName),
            'expected_url' => null,
            'store_product_url' => null,
            'expected_url_contains' => [Str::slug($productName), Str::slug($storeName)],
            'expected_title' => $productName,
            'expected_seller' => $storeName,
            'expected_domain' => Str::slug($storeName).'.com.mx',
            'expected_position' => null,
            'required_keywords' => explode('-', Str::slug($productName)),
            'optional_keywords' => [],
            'negative_keywords' => [],
            'selection_strategy' => 'url_weighted_match',
            'min_match_score' => 80,
            'location_name' => 'Mexico',
            'language_code' => 'es',
            'is_active' => true,
        ];
    }
}
