
#                                      Copyright 2025 WebPros International, LLC
#                                                           All rights reserved.
# copyright@cpanel.net                                         http://cpanel.net
# This code is subject to the cPanel license. Unauthorized copying is prohibited.

package Cpanel::Sitejet::Beta::Setup;

=encoding utf8

=head1 NAME

Cpanel::Sitejet::Beta::Setup

=head1 DESCRIPTION

Setup related functionality for the Sitejet Beta release.

=cut

use cPstrict;
use Cpanel::FeatureFlags ();

=head1 FUNCTIONS

=head2 local_disable()

This function disables the Sitejet Beta feature locally.

=cut

sub local_disable {

    # remove the enable flag
    Cpanel::FeatureFlags::disable('cpanel.sitejet-beta.plugin.local.enable');
    Cpanel::FeatureFlags::enable('cpanel.sitejet-beta.plugin.local.disable');
}

=head2 local_enable()

This function enables the Sitejet Beta feature locally.

=cut

sub local_enable {

    # remove the disable flag
    Cpanel::FeatureFlags::disable('cpanel.sitejet-beta.plugin.local.disable');
    Cpanel::FeatureFlags::enable('cpanel.sitejet-beta.plugin.local.enable');
}

=head2 local_reset()

This function clears the Sitejet Beta flags and restores control to WebPros shipped rules.

=cut

sub local_reset {
    foreach my $flag_name (
        'cpanel.sitejet-beta.plugin.local.enable',
        'cpanel.sitejet-beta.plugin.local.disable',
    ) {
        _unlink_flag($flag_name);
    }
}

=head2 _unlink_flag()

Private helper function to unlink a feature flag.

=cut

sub _unlink_flag($flag_name) {

    # This is a little hacky, but we want to use the internal capabilities so
    # we dont have to rewrite the logic for unlinking a feature flag.
    Cpanel::FeatureFlags::_unlink( Cpanel::FeatureFlags::_path($flag_name) );
}

1;
