/** * ROI APU Search Handler * * Handles AJAX search requests with debouncing and pagination * * @package ROI_APU_Search */ (function() { 'use strict'; // Configuration from WordPress const config = window.roiApuSearch || { ajaxUrl: '/wp-admin/admin-ajax.php', apiUrl: '', clickUrl: '', nonce: '', ads: { enabled: false } }; // State management per instance const instances = new Map(); // ============================================================================= // FUNCIONES DE ADSENSE // ============================================================================= /** * Genera HTML de anuncio AdSense * @param {string} format - Formato del anuncio (auto, in-article, autorelaxed, display) * @param {string|number} position - Posicion del anuncio para identificacion * @returns {string} HTML del anuncio o string vacio si hay error */ function generateAdHtml(format, position) { try { var ads = config.ads; if (!ads || !ads.enabled) return ''; var slotInfo = getSlotAndFormatByType(format, ads.slots); if (!slotInfo.slot || !ads.publisherId) return ''; // Determinar tipo de script segun delay var scriptType = ads.delay && ads.delay.enabled ? 'text/plain' : 'text/javascript'; var dataAttr = ads.delay && ads.delay.enabled ? ' data-adsense-push' : ''; // Generar atributos segun formato var formatAttrs = getAdFormatAttributes(format); return '