<?php
if ( ! defined( 'ABSPATH' ) ) {
    exit;
}

/**
 * Minimální PHP závislosti pro plné Elementor widget controls v editoru.
 * Bez database.php, automation, elementor-sync a dalších těžkých modulů.
 *
 * @return void
 */
function elementsell_boot_elementor_editor_dependencies() {
    $dependencies = [
        'includes/billing/billing-functions.php'          => 'elementsell_billing_get_required_sales_count',
        'includes/pages/course-roles.php'                 => 'elementsell_get_role_select2_options',
        'includes/widget-custom-fields.php'               => 'elementsell_get_custom_fields_from_widget_settings',
        'includes/upsell/upsell-functions.php'            => 'elementsell_upsell_is_enabled',
        'includes/pages/privacy-page.php'                 => 'elementsell_render_payment_consent_notice',
        'includes/payments/payment-widget-credentials.php'=> 'elementsell_get_payment_widget_global_defaults',
    ];

    foreach ( $dependencies as $relative_path => $function_name ) {
        if ( function_exists( $function_name ) ) {
            if ( function_exists( 'elementsell_boot_debug_log' ) ) {
                elementsell_boot_debug_log( 'editor deps skipped ' . $relative_path . ' (' . $function_name . ' already loaded)' );
            }

            continue;
        }

        if ( function_exists( 'elementsell_boot_debug_require' ) ) {
            elementsell_boot_debug_require( $relative_path );
        } else {
            require_once PF_PLUGIN_DIR . $relative_path;
        }
    }

    if ( function_exists( 'elementsell_boot_debug_log' ) ) {
        elementsell_boot_debug_log( 'editor deps: minimal set loaded for full widget controls' );
    }
}
