<?php
namespace NeoDuplicateFull\NeoFreemius; if (!defined("ABSPATH")) { die("neoWP direct access not allowed"); }


























































function freemius_product_id() {
    $hardcoded_value = "12083";
    if (isset(\NeoDuplicateFull\NeoGlobal\val("custom")["license_settings"]) && (\NeoDuplicateFull\NeoGlobal\val("custom")["license_settings"]["freemius_product_id"] ?? null) !== $hardcoded_value) { \NeoDuplicateFull\NeoGlobal\admin_error("Freemius product ID mismatch: " . (\NeoDuplicateFull\NeoGlobal\val("custom")["license_settings"]["freemius_product_id"] ?? "[MISSING]") . " != " . $hardcoded_value . ". Update hardcoded value in " . basename(__FILE__) . "."); }
    return $hardcoded_value;
}
function freemius_product_public_key() {
    $hardcoded_value = "pk_01093f748756a4db76d7003ade4ab";
    if (isset(\NeoDuplicateFull\NeoGlobal\val("custom")["license_settings"]) && (\NeoDuplicateFull\NeoGlobal\val("custom")["license_settings"]["freemius_product_public_key"] ?? null) !== $hardcoded_value) { \NeoDuplicateFull\NeoGlobal\admin_error("Freemius public key mismatch: " . (\NeoDuplicateFull\NeoGlobal\val("custom")["license_settings"]["freemius_product_public_key"] ?? "[MISSING]") . " != " . $hardcoded_value . ". Update hardcoded value in " . basename(__FILE__) . "."); }
    return $hardcoded_value;
}
function freemius_slug_free() {

    $hardcoded_value = "neo-media";
    if (isset(\NeoDuplicateFull\NeoGlobal\val("custom")["license_settings"]) && (\NeoDuplicateFull\NeoGlobal\val("custom")["license_settings"]["freemius_slug_free"] ?? null) !== $hardcoded_value) { \NeoDuplicateFull\NeoGlobal\admin_error("Freemius free slug mismatch: " . (\NeoDuplicateFull\NeoGlobal\val("custom")["license_settings"]["freemius_slug_free"] ?? "[MISSING]") . " != " . $hardcoded_value . ". Update hardcoded value in " . basename(__FILE__) . "."); }
    return $hardcoded_value;
}
function freemius_slug_pro()  {

    $hardcoded_value = "neo-media-pro";
    if (isset(\NeoDuplicateFull\NeoGlobal\val("custom")["license_settings"]) && (\NeoDuplicateFull\NeoGlobal\val("custom")["license_settings"]["freemius_slug_pro"] ?? null) !== $hardcoded_value) { \NeoDuplicateFull\NeoGlobal\admin_error("Freemius pro slug mismatch: " . (\NeoDuplicateFull\NeoGlobal\val("custom")["license_settings"]["freemius_slug_pro"] ?? "[MISSING]") . " != " . $hardcoded_value . ". Update hardcoded value in " . basename(__FILE__) . "."); }
    return $hardcoded_value;
}


function init_freemius_once_and_get_instance() {
    static $neo_fs = null; if ($neo_fs === null) {

        if (get_option("fs_accounts")) {
            $fs_accounts = get_option("fs_accounts");
            $freemius_main_file = plugin_basename(\NeoDuplicateFull\NeoGlobal\plugin_entry_file_path()); foreach (\NeoDuplicateFull\NeoEntrypoint\get_neo_active_plugins() as $active_plugin) { if ($active_plugin["slug"] === "neo-media") { $freemius_main_file = plugin_basename($active_plugin["plugin_entry_file_path"]); break; } }
            if (($fs_accounts["id_slug_type_path_map"][freemius_product_id()]["path"] ?? null) !== $freemius_main_file) {
                $fs_accounts["id_slug_type_path_map"][freemius_product_id()]["path"] = $freemius_main_file;
                update_option("fs_accounts", $fs_accounts);
            }
        }

        [$freemius_secret_key, $interface_ok] = \NeoDuplicateFull\NeoGlobal\call_interface_func_implemented('\NeoDuplicateFull\NeoDebug\interface_set_up_debug_mode_and_get_freemius_debug_secret_key_20260205')(freemius_slug_free(), freemius_slug_pro()); if (!$interface_ok) { $freemius_secret_key = null; }

        (fn () => require_once(\NeoDuplicateFull\NeoGlobal\plugin_path() . "/" . "neo-freemius--thirdparty/start.php"))();
        $neo_fs = fs_dynamic_init([
            "id"                  => freemius_product_id(),
            "slug"                => freemius_slug_free(),
            "premium_slug"        => freemius_slug_pro(),
            "type"                => "plugin",
            "public_key"          => freemius_product_public_key(),
            "premium_suffix"      => "Pro",
            "is_org_compliant" => true, "has_premium_version" => false,
            "has_addons"          => false,
            "has_paid_plans"      => true,
            "is_premium"          => true,
            "is_premium_only"     => \NeoDuplicateFull\NeoGlobal\plugin_slug() === "neo-media" && wp_strip_all_tags(wp_unslash($_GET["require_license"] ?? "")) !== "false", /* phpcs:ignore WordPress.Security.NonceVerification.Recommended */ /* There is no nonce to verify */
            "trial" => [
                "days"               => 14,
                "is_require_payment" => true,
            ],
            "menu" => [
                "slug"    => \NeoDuplicateFull\NeoGlobal\plugin_settings_page_slug(),
                "contact" => false,
                "support" => false,
            ],
            "has_affiliation" => false,

            "secret_key" => $freemius_secret_key,

            "is_live" => $freemius_secret_key !== null ? null : true,
        ]);
        $neo_fs->add_filter("plugin_icon", fn () => \NeoDuplicateFull\NeoGlobal\plugin_path_no_symlink_follow() . "/img/_global--logo-icon.svg");
        $neo_fs->add_filter("pricing/discounts_model",  function ($model) { return "relative"; });
        $neo_fs->add_filter("redirect_on_activation",   function () { return false; });
        $neo_fs->add_filter("deactivate_on_activation", function () { return false; });

        foreach (\NeoDuplicateFull\NeoEntrypoint\get_neo_active_plugins() as $active_plugin) {
            if (plugin_basename($active_plugin["plugin_entry_file_path"]) === (isset($freemius_main_file) ? $freemius_main_file : null)) { continue; }
            \NeoDuplicateFull\NeoGlobal\add_filter_hook("plugin_action_links_" . plugin_basename($active_plugin["plugin_entry_file_path"]), function ($actions, $plugin_file) use ($neo_fs) { return $neo_fs->_modify_plugin_action_links_hook($actions, $plugin_file); });
        }
    }
    return $neo_fs;
}
\NeoDuplicateFull\NeoGlobal\add_action_hook("neo_init", function () { init_freemius_once_and_get_instance(); });


function interface_freemius_get_site_id_20260211()                                     { return init_freemius_once_and_get_instance()->get_site()?->id ?? null; }
function interface_freemius_get_anonymous_id_20260211()                                { return init_freemius_once_and_get_instance()->get_anonymous_id(); }
function interface_freemius_can_use_premium_code__premium_only_20260211()              { return init_freemius_once_and_get_instance()->can_use_premium_code__premium_only(); }
function interface_freemius_add_action_connect_after_license_input_20260211($callback) { init_freemius_once_and_get_instance()->add_action("connect/after_license_input", $callback); }
function interface_freemius_delete_account_event_20260211()                            { init_freemius_once_and_get_instance()->delete_account_event(); }
function interface_freemius_get_eula_url_20260211()                                    { return init_freemius_once_and_get_instance()->get_eula_url(); }
function interface_freemius_get_license_activation_terms_url_20260211()                { return init_freemius_once_and_get_instance()->get_license_activation_terms_url(); }
function interface_freemius_get_usage_tracking_terms_url_20260211()                    { return init_freemius_once_and_get_instance()->get_usage_tracking_terms_url(); }
function interface_freemius_get_pricing_json_20260211() {
    return init_freemius_once_and_get_instance()->get_api_plugin_scope()->get("pricing.json?" . http_build_query([
        "is_enriched" => true, "trial" => false, "sandbox" => false, "s_ctx_type" => false, "s_ctx_id" => false, "s_ctx_ts" => false, "s_ctx_secure" => false,
        "plugin_id" => init_freemius_once_and_get_instance()->get_id(), "plugin_public_key" => init_freemius_once_and_get_instance()->get_public_key(),
    ]), flush: true);
}

function interface_freemius_activate_hook_20260210  ($plugin_slug, $plugin_edition, $plugin_version) { static $first_run = true; if (!$first_run) { return; } $first_run = false; \NeoDuplicateFull\NeoGlobal\global_log_with_module_name("neo-freemius", "Running freemius activate hook");   init_freemius_once_and_get_instance()->_activate_plugin_event_hook(); }
function interface_freemius_deactivate_hook_20260210($plugin_slug, $plugin_edition, $plugin_version) { static $first_run = true; if (!$first_run) { return; } $first_run = false; \NeoDuplicateFull\NeoGlobal\global_log_with_module_name("neo-freemius", "Running freemius deactivate hook"); init_freemius_once_and_get_instance()->_deactivate_plugin_hook(); }
function interface_freemius_uninstall_hook_20260210 ($plugin_slug, $plugin_edition, $plugin_version) { static $first_run = true; if (!$first_run) { return; } $first_run = false; \NeoDuplicateFull\NeoGlobal\global_log_with_module_name("neo-freemius", "Running freemius uninstall hook");  init_freemius_once_and_get_instance()->_uninstall_plugin_hook(); }

function freemius_license() {
    static $cache = null; return $cache ??= (function () {
        $license_id = init_freemius_once_and_get_instance()?->get_account_option("sites")[freemius_slug_free()]->license_id ?? null;
        $all_licenses = init_freemius_once_and_get_instance()?->get_account_option("all_licenses")[freemius_product_id()] ?? [];
        $license = null; foreach ($all_licenses as $l) { if ($l->id === $license_id) { $license = $l; break; } }
        return $license;
    })();
}

function interface_freemius_license_id_20260211()         { return freemius_license()?->id         ?? null; }
function interface_freemius_license_secret_key_20260211() { return freemius_license()?->secret_key ?? null; }


function remove_all_license_data() {

    global $wpdb;
    $option_names = $wpdb->get_col($wpdb->prepare("SELECT option_name FROM $wpdb->options WHERE option_name LIKE %s OR option_name LIKE %s", "fs_%", "_site_transient_fs_%")); /* phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching */ /* Direct database call to clean up not only autoloaded WP options and prevent leaving behind any lingering database junk. */
    foreach ($option_names as $option_name) { delete_option($option_name); }

    \NeoDuplicateFull\NeoGlobal\call_interface_func_implemented('\NeoDuplicateFull\NeoGlobal\interface_all_bundles_clear_license_cache_20260131', throw_if_interface_not_ok: true)();
}
\NeoDuplicateFull\NeoGlobal\register_rest_endpoint("/wp-json/neo/remove-freemius-license-data", "POST", fn () => \NeoDuplicateFull\NeoGlobal\current_user_can__neo_freemius__delete_license_data(), function ($get_param) {
    remove_all_license_data();
    return "OKAY";
});


\NeoDuplicateFull\NeoGlobal\add_action_hook("neo_init", function () {
    \NeoDuplicateFull\NeoGlobal\call_interface_func_implemented('\NeoDuplicateFull\NeoReset\interface_register_neo_reset_action_20260410')(
        id: "neo-freemius--delete-license",  button_text: \NeoDuplicateFull\NeoGlobal\neo__("Delete all license data", "Alle Lizenzdaten löschen"), confirm_title: \NeoDuplicateFull\NeoGlobal\neo__("Reset license?", "Lizenz zurücksetzen?"), confirm_text: \NeoDuplicateFull\NeoGlobal\neo__("Are you sure you want to remove all license data? You will need to enter the license key again.", "Möchtest du wirklich alle Lizenzdaten entfernen? Der Lizenzschlüssel muss erneut eingegeben werden."),
        action_callback: fn () => remove_all_license_data()
    );
});



(function () {
    foreach (\NeoDuplicateFull\NeoEntrypoint\get_neo_active_plugins() as $active_plugin) {
        \NeoDuplicateFull\NeoGlobal\add_filter_hook("plugin_action_links_" . plugin_basename($active_plugin["plugin_entry_file_path"]) . ":11", function ($actions, $plugin_file, $plugin_data, $context) {
            if (!str_starts_with($plugin_file, "neo-")) { return $actions; }

            $premium_url = interface_freemius_pricing_page_url_20260131() ?? ("https://" . \NeoDuplicateFull\NeoGlobal\option__neo_wp_com() . "/pricing/?ref=wp-backend-get-premium#pricing-table");
            $premium_url_target = (($premium_url_host = wp_parse_url($premium_url, PHP_URL_HOST)) !== null && ($wp_instance_host = wp_parse_url(home_url("/"), PHP_URL_HOST)) !== null && strtolower($premium_url_host) !== strtolower($wp_instance_host)) ? " target=\"_blank\" rel=\"noopener noreferrer\"" : "";
            $actions["upgrade"] = "<a href=\"" . esc_url($premium_url) . "\"" . $premium_url_target . " style=\"font-weight: bold; color: #a03b1f;\">" . \NeoDuplicateFull\NeoGlobal\neo__("Get Premium", "Premium holen") . "</a>";
            $actions = ["upgrade" => $actions["upgrade"]] + $actions;

            return $actions;
        });
    }
})();
