package Cpanel::Config::ConfigObj::Driver::Sitejet::META;

# cpanel - Cpanel/Config/ConfigObj/Driver/Sitejet/META.pm
#                                      Copyright 2024 WebPros International, LLC
#                                                            All rights reserved.
# copyright@cpanel.net                                         http://cpanel.net
# This code is subject to the cPanel license. Unauthorized copying is prohibited.

use cPstrict;

=encoding utf-8

=head1 NAME

Cpanel::Config::ConfigObj::Driver::Sitejet::META

=head1 DESCRIPTION

Feature Showcase metadata for Sitejet

=cut

use parent qw(Cpanel::Config::ConfigObj::Interface::Config::Version::v1);

our $VERSION = "2.0";

=head1 FUNCTIONS

=head2 translatable 

Returns the string. Provides the string to the locale tool. ## no extract maketext

=cut

sub translatable ($string) { return $string; } ## no extract maketext

=head2 get_driver_name()

Returns the driver name. This name is used as the filename for the touchfile
put in the C</var/cpanel/activate/features/> directory.

=cut

use constant get_driver_name => 'sitejet_builder_campaign_08_2025';
use constant top_line        => translatable("Create websites faster with the new AI-powered generator in Sitejet — [output,strong,now available for new website creation alongside the existing standard templates]. Just enter a company name, select a business type, and provide a few details. Sitejet AI Website Generator will generate a personalized site with optimized content, layout, colors, and fonts.");
use constant bullet_point_strings => (
    translatable("AI-driven design and content"),
    translatable("Faster time to first website"),
    translatable("Custom templates, SEO-friendly and responsive"),
);
use constant note     => translatable("Note: The AI Generator is only available when creating new websites — it cannot be used on existing sites.");

my ( $short, $long );
$short = $long = translatable('Sitejet AI Website Generator');

=head2 content

Defines the content used in the Feature Showcase entry

=cut

sub content {
    my ($locale) = @_;
    my $topline  = top_line;
    my $note     = note;
    my $abstract;

    if ($locale) {
        $short   = $locale->makevar($short);
        $long    = $locale->makevar($long);
        $topline = $locale->makevar($topline);
        my $bullet_points = "";
        foreach my $bullet_point (bullet_point_strings) {
            $bullet_points .= "<li style=\"list-style-type:disc;\">" . $locale->makevar($bullet_point) . "</li>";
        }

        $abstract = join(
            "",
            "<p>" . $topline . "</p>",
            "<ol>",
            $bullet_points,
            "<br>",
            "</ol>",
            "<em>" . $locale->makevar($note) . "</em>",
        );
    }

    else {
        $topline =~ s/\[.+,([^]]*)\]/<strong>$1<\/strong>/;
        my $bullet_points  = "";
        foreach my $bullet_point (bullet_point_strings) {
            $bullet_points .= "<li style=\"list-style-type:disc;\">$bullet_point</li>";
        }
        $abstract = join(
            "",
            "<p>$topline</p>",
            "<ol>",
            $bullet_points,
            "<br>",
            "</ol>",
            "<em>$note</em>",
        );
    }

    return {
        'vendor' => 'WebPros International, LLC',
        'url'    => 'https://go.cpanel.net/sitejet-builder',
        'name'   => {
            'short'  => $short,
            'long'   => $long,
            'driver' => get_driver_name(),
        },
        'first_appears_in' => '110',
        'version'          => $Cpanel::Config::ConfigObj::Driver::Sitejet::META::VERSION,
        'readonly'         => 1,                                                            # 0 uses default html for options
        'abstract'         => $abstract,
    };
}

=head2 showcase()

Determine how and if an item should appear in the showcase

=cut

sub showcase {

    # do not display on 110
    require Cpanel::Plugins::Components::Rules::CpanelVersion;
    return 0 if Cpanel::Plugins::Components::Rules::CpanelVersion->new('11.110')->is_allowed();

    return { 'is_recommended' => 0, 'is_spotlight_feature' => 1 };
}
1;
