/**
 * DEPRECATED: Use i18n_manager.js instead
 *
 * This file is kept for backwards compatibility only.
 * All translation logic has been moved to i18n_manager.js which
 * fetches translations from the server endpoint /eskaera/i18n
 *
 * Migration guide:
 * OLD: window.getCheckoutLabels()
 * NEW: i18nManager.getAll()
 *
 * OLD: window.formatCurrency(amount)
 * NEW: i18nManager.formatCurrency(amount)
 *
 * Copyright 2025 Criptomart
 * License AGPL-3.0 or later
 */

(function () {
    "use strict";

    // Keep legacy functions as wrappers for backwards compatibility

    /**
     * DEPRECATED - Use i18nManager.getAll() or i18nManager.get(key) instead
     */
    window.getCheckoutLabels = function (key) {
        if (window.i18nManager && window.i18nManager.initialized) {
            if (key) {
                return window.i18nManager.get(key);
            }
            return window.i18nManager.getAll();
        }
        // Fallback if i18nManager not yet initialized
        return key ? key : {};
    };

    /**
     * DEPRECATED - Use i18nManager.getAll() instead
     */
    window.getSearchLabels = function () {
        if (window.i18nManager && window.i18nManager.initialized) {
            return {
                searchPlaceholder: window.i18nManager.get("search_products"),
                noResults: window.i18nManager.get("no_results"),
            };
        }
        return {
            searchPlaceholder: "Search products...",
            noResults: "No products found",
        };
    };

    /**
     * DEPRECATED - Use i18nManager.formatCurrency(amount) instead
     */
    window.formatCurrency = function (amount) {
        if (window.i18nManager) {
            return window.i18nManager.formatCurrency(amount);
        }
        // Fallback
        return "€" + parseFloat(amount).toFixed(2);
    };

    console.log("[i18n_helpers] DEPRECATED - Use i18n_manager.js instead");
})();
