<?php

if (!defined('ABSPATH')) {
    exit; // Exit if accessed directly.
}

class INTEGRAZO_WZ_Fields_Details
{
    /**
     * Return event or form field list based on the plugin type.
     *
     * @param array $integration_details
     * @return mixed|null
     */
    public static function render($integration_details)
    {
        $integration_data = json_decode($integration_details['integration_data'] ?? '', true);
        $from_plugin = $integration_details['from_plugin'] ?? '';
        $form_id = $integration_data['integrazo_wz_form_id'] ?? $integration_data['integrazo_wz_event_name'] ?? null;
        switch ($from_plugin) {
            case 'woocommerce':
                return INTEGRAZO_WZ_WooCommerce_Helper::get_form_fields($form_id);
            case 'wordpress_org':
                return INTEGRAZO_WZ_WordPressCom_Helper::get_form_fields($form_id);
            case 'contact_form_7':
                return INTEGRAZO_WZ_CF7_Helper::get_form_fields($form_id);

            case 'elementor_form':
                return INTEGRAZO_WZ_Elementor_Helper::get_form_fields($form_id);

            case 'wp_form':
                return INTEGRAZO_WZ_WPForms_Helper::get_form_fields($form_id);

            case 'gravity_form':
                return INTEGRAZO_WZ_GravityForms_Helper::get_form_fields($form_id);
            case 'ninja_form':
                return INTEGRAZO_WZ_NinjaForms_Helper::get_form_fields($form_id);
            case 'formidable_form':
                return INTEGRAZO_WZ_FormidableForms_Helper::get_form_fields($form_id);
            case 'everest_form':
                return INTEGRAZO_WZ_EverestForms_Helper::get_form_fields($form_id);
            case 'fluent_form':
                return INTEGRAZO_WZ_FluentForms_Helper::get_form_fields($form_id);
            case 'forminator_form':
                return INTEGRAZO_WZ_Forminator_Helper::get_form_fields($form_id);
            case 'met_form':
                return INTEGRAZO_WZ_MetForm_Helper::get_form_fields($form_id);
            case 'jet_form':
                return INTEGRAZO_WZ_JetFormBuilder_Helper::get_form_fields($form_id);
            case 'sure_form':
                return INTEGRAZO_WZ_SureForms_Helper::get_form_fields($form_id);
            case 'happy_form':
                return INTEGRAZO_WZ_HappyForms_Helper::get_form_fields($form_id);
            case 'we_form':
                return INTEGRAZO_WZ_weForms_Helper::get_form_fields($form_id);
            case 'ws_form':
                return INTEGRAZO_WZ_WSForm_Helper::get_form_fields($form_id);
            case 'nex_forms':
                return INTEGRAZO_WZ_NEXForms_Helper::get_form_fields($form_id);
            case 'kali_forms':
                return INTEGRAZO_WZ_KaliForms_Helper::get_form_fields($form_id);
            case 'ar_forms':
                return INTEGRAZO_WZ_ARForms_Helper::get_form_fields($form_id);

            // Still Pro-only — their handlers remain in the Pro plugin.
            case 'form_maker':
            case 'quill_forms':
                if (integrazo_wz_is_pro_active()) {
                    return self::get_pro_form_fields($from_plugin, $form_id);
                }
                return null;

            default:
                return null;
        }
    }
    /**
     * Helper for Pro-only form field helpers.
     *
     * @param string $from_plugin
     * @param int|null $form_id
     * @return mixed|null
     */
    private static function get_pro_form_fields($from_plugin, $form_id)
    {
        switch ($from_plugin) {
            case 'form_maker':
                return INTEGRAZO_WZ_FormMaker_Helper::get_form_fields($form_id);
            case 'quill_forms':
                return INTEGRAZO_WZ_QuillForm_Helper::get_form_fields($form_id);
            default:
                return null;
        }
    }
}
