<?php

namespace App\Http\Controllers;

use App\Helpers\FirstParty\AI\OpenAI;
use App\Helpers\FirstParty\AI\RunwareAI;
use App\Helpers\FirstParty\AspectRatio;
use App\Helpers\FirstParty\Meme\MemeGenerator;
use App\Helpers\FirstParty\Purchase\PurchaseHelper;
use App\Models\Category;
use App\Models\Meme;
use App\Models\MemeMedia;
use Str;

class TestController extends Controller
{
    public function index()
    {
        //
    }

    public function testPurchase()
    {
        $subscriptions = PurchaseHelper::getPricingPageSubscriptions();

        $one_time = PurchaseHelper::getPricingPageOneTime();

        dump($subscriptions);
        dump($one_time);
    }

    public function getSuitableMemeMedia()
    {
        $meme = Meme::inRandomOrder()->first();
        $meme_media = MemeGenerator::getSuitableMemeMedia($meme);

        dd($meme_media);
    }

    public function getMemeKeywords()
    {

        $meme_media = MemeMedia::whereNull('action_keywords')->first();

        $meme_keywords_response = OpenAI::getMemeKeywords($meme_media->name, $meme_media->description);

        $meme_keywords_output = json_decode(OpenAI::getOpenAIOutput($meme_keywords_response));

        $meme_media->description = $meme_keywords_output->description;
        $meme_media->action_keywords = $meme_keywords_output->action_keywords;
        $meme_media->emotion_keywords = $meme_keywords_output->emotion_keywords;
        $meme_media->misc_keywords = $meme_keywords_output->misc_keywords;

        $meme_media->save();
    }

    public function aspectRatio()
    {
        $aspect_ratio = AspectRatio::get(1024, 1024);

        dd($aspect_ratio);
    }

    public function generateMeme()
    {
        $category = Category::inRandomOrder()->first();

        $meme = MemeGenerator::generateMemeByCategory($category);

        dd($meme);
    }

    public function populateDuration()
    {
        \App\Helpers\FirstParty\Maintenance\MemeMediaMaintenance::populateDurations();
    }

    public function writeMeme()
    {
        $meme_response = OpenAI::getSingleMemeGenerator('Write me 1 meme about adult life');

        // dump($meme_response);

        $meme_output = json_decode(OpenAI::getOpenAIOutput($meme_response));

        dd($meme_output);
    }

    public function generateSchnellImage()
    {
        $uuid = Str::uuid();
        $image_url = RunwareAI::generateSchnellImage($uuid, 'office desk cluttered with papers and a computer', 1024, 1024);

        dd($image_url);
    }
}
