<?php

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

class INTEGRAZO_WCZO_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);

    // For WooCommerce, event/form id may be order, customer, product, etc.
    $event = $integration_data['integrazo_wczo_event_name'] ?? null;

    return INTEGRAZO_WCZO_WooCommerce_Helper::get_form_fields($event);
}

    /**
     * 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 'gravity_form':
                return INTEGRAZO_WCZO_GravityForms_Helper::get_form_fields($form_id);
            case 'ninja_form':
                return INTEGRAZO_WCZO_NinjaForms_Helper::get_form_fields($form_id);
            case 'formidable_form':
                return INTEGRAZO_WCZO_FormidableForms_Helper::get_form_fields($form_id);
            case 'everest_form':
                return INTEGRAZO_WCZO_EverestForms_Helper::get_form_fields($form_id);
            case 'fluent_form':
                return INTEGRAZO_WCZO_FluentForms_Helper::get_form_fields($form_id);
            case 'forminator_form':
                return INTEGRAZO_WCZO_Forminator_Helper::get_form_fields($form_id);
            case 'met_form':
                return INTEGRAZO_WCZO_MetForm_Helper::get_form_fields($form_id);
            case 'jet_form':
                return INTEGRAZO_WCZO_JetFormBuilder_Helper::get_form_fields($form_id);
            case 'sure_form':
                return INTEGRAZO_WCZO_SureForms_Helper::get_form_fields($form_id);
            case 'form_maker':
                return INTEGRAZO_WCZO_FormMaker_Helper::get_form_fields($form_id);
            case 'happy_form':
                return INTEGRAZO_WCZO_HappyForms_Helper::get_form_fields($form_id);
            case 'we_form':
                return INTEGRAZO_WCZO_weForms_Helper::get_form_fields($form_id);
            case 'ws_form':
                return INTEGRAZO_WCZO_WSForm_Helper::get_form_fields($form_id);
            case 'quill_forms':
                return INTEGRAZO_WCZO_QuillForm_Helper::get_form_fields($form_id);
            case 'nex_forms':
                return INTEGRAZO_WCZO_NEXForms_Helper::get_form_fields($form_id);
            case 'kali_forms':
                return INTEGRAZO_WCZO_KaliForms_Helper::get_form_fields($form_id);
            case 'ar_forms':
                return INTEGRAZO_WCZO_ARForms_Helper::get_form_fields($form_id);
            default:
                return null;
        }
    }
}
