<?php
namespace lucidpen;

use core\OptionAbstract;

// Prevent direct access
if (!defined('ABSPATH')) {
    exit;
}

class OpenAIOption extends OptionAbstract
{
    public function __construct()
    {
        $options = [
            LCPN_OPT_OPENAI_API_ENDPOINT => [
                'label' => 'API Endpoint',
                'type' => 'string',
                'description' => 'The endpoint for the OpenAI API, e.g., https://api.openai.com/v1/',
            ],
            LCPN_OPT_OPENAI_API_KEY => [
                'label' => 'API Key',
                'type' => 'string',
                'description' => 'Your OpenAI API key',
            ],
            LCPN_OPT_OPENAI_DEPLOYMENT => [
                'label' => 'Deployment Name',
                'type' => 'string',
                'description' => 'The name of the OpenAI deployment to use',
            ],
            LCPN_OPT_OPENAI_API_VERSION => [
                'label' => 'API Version',
                'type' => 'string',
                'description' => 'The version of the OpenAI API to use',
            ],
            LCPN_OPT_SLUG_PRAYER => [
                'label' => 'Prayer Assistant Slug',
                'type' => 'string',
                'description' => 'The slug for the Prayer Assistant',
                // 'sanitize_callback' => [$this, 'on_updated'],
                'default' => PrayerAssistant::get_default_slug(),
            ],
            LCPN_OPT_SLUG_BLOG => [
                'label' => 'Blog Assistant Slug',
                'type' => 'string',
                'description' => 'The slug for the Blog Assistant',
                'default' => Reporter::get_default_slug(),
            ],
        ];

        parent::__construct(
            LCPN_APP,
            ['menu' => 'LucidPen', 'page' => 'LucidPen Settings'],
            LCPN_OPTION_GROUP,
            $options
        );
    }

    protected function init_internal(): void
    {
    }

    protected function shutdown_internal(): void
    {
        $session = OpenAiChatSession::get_instance();
        $session->getComposerManager()->ensureSlugRegistered(false);
    }


    protected function enqueue_scripts_internal($hook): void
    {
        // For child class override if needed
    }

    // The actual admin page HTML
    public function render_page_internal()
    {
        include LCPN_PLUGIN_DIR . 'template/openai-settings.php';
    }

}
