<?php

namespace App\Providers;

use App\Repositories\PaymentSettingsRepository;
use App\Services\Analytics\StatsService;
use App\Services\Api\API;
use App\Services\Character\CharacterActionService;
use App\Services\Character\CharacterInventoryService;
use App\Services\Character\CharacterService;
use App\Services\Commerce\PaymentService;
use App\Services\Gaming\IngameService;
use App\Services\ItemDataService;
use App\Services\ItemDecodeService;
use Illuminate\Support\ServiceProvider;
use Illuminate\Validation\Rules\Password;

class AppServiceProvider extends ServiceProvider
{
    public function register(): void
    {
        $this->app->singleton(API::class, function ($app) {
            return new API;
        });

        $this->app->singleton(CharacterService::class, function ($app) {
            return new CharacterService($app->make(API::class));
        });

        $this->app->singleton(CharacterInventoryService::class, function ($app) {
            return new CharacterInventoryService($app->make(API::class));
        });

        $this->app->singleton(CharacterActionService::class, function ($app) {
            return new CharacterActionService($app->make(API::class));
        });

        $this->app->singleton(ItemDecodeService::class);

        $this->app->singleton(ItemDataService::class);

        $this->app->singleton(StatsService::class, function ($app) {
            return new StatsService($app->make(API::class));
        });

        $this->app->singleton(PaymentSettingsRepository::class);
        $this->app->singleton(PaymentService::class);
        $this->app->singleton(IngameService::class, function ($app) {
            return new IngameService($app->make(API::class));
        });
    }

    public function boot(): void
    {
        Password::defaults(function () {
            return Password::min(6);
        });
    }
}
