<?php

namespace GriffinForms\Includes\Integrations\Klaviyo;

class Main extends \GriffinForms\Includes\Integrations\Format
{
    protected function setMeta(): void
    {
        $this->meta = 'klaviyo';
        $this->id   = 'klaviyo';
    }

    protected function buildInfo(): array
    {
        return [
            'id'          => 'klaviyo',
            'name'        => 'Klaviyo',
            'category'    => 'Marketing',
            'description' => __('Push contacts into Klaviyo lists and profiles. Requires GriffinForms Pro.', 'griffinforms-form-builder'),
            'scope'       => [
                'is_global'      => true,
                'allow_override' => true,
            ],
        ];
    }

    public function getStatus(): array
    {
        return [
            'configured'         => false,
            'active'             => false,
            'requires_extension' => true,
            'message'            => __('Requires GriffinForms Pro', 'griffinforms-form-builder'),
        ];
    }

    public function isConfigured(): bool
    {
        return false;
    }

    public function getConfigFields(): array
    {
        return [];
    }

    protected function saveConfiguration(array $config): bool
    {
        return false;
    }

    protected function validateConnection(): array
    {
        return ['success' => false, 'message' => __('Requires GriffinForms Pro.', 'griffinforms-form-builder')];
    }

    public function isLibraryInstalled(): bool
    {
        return true;
    }

    public function getLibraryInstructions(): string
    {
        return '';
    }

    public function getConfigurationFormHtml(): string
    {
        $message = '<div class="gf-notice gf-notice-info">' .
            esc_html__('Activate GriffinForms Pro to configure Klaviyo.', 'griffinforms-form-builder') .
            '</div>';

        return $this->renderConfigurationFormTemplate(
            'griffinforms-klaviyo-config',
            $this->id,
            $message
        );
    }
}
