(()=>{if(window.embiInterstitialLoaded)return void console.warn("EMBI Interstitial script ya estΓ‘ cargado. Abortando ejecuciΓ³n duplicada.");window.embiInterstitialLoaded=!0;const e=(window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth)<=768,t=3e4,n="100% 0px",i=!1,s={fetchMarginPercent:200,renderMarginPercent:100,mobileScaling:1},r={enabled:!0,loadDelay:100},o=(...e)=>i&&console.log(...e),d=(...e)=>console.warn(...e),a=(...e)=>console.error(...e);let l,c=null;function h(){if(!c||!c.parentNode)return;const e=c.parentNode;e.lastElementChild!==c&&e.appendChild(c)}const p=[{slot:"/22562061343/0492-01_netfla-com-br_footer__",tagId:"embi_footer_intop_afb2b05f",type:"FOOTER_INTOP",ubication:"",position:"FOOTER",manualInsertion:!1,mobileSizes:[[320,50],[320,100],[300,50]],desktopSizes:[[728,90],[970,90]],offset:null,tbLoaderURL:"",loadImmediately:!1,adunitMobile:{code:"embi_footer_intop_afb2b05f",mediaTypes:{banner:{sizes:[[320,50],[320,100],[300,50]]}},bids:[],ortb2Imp:{ext:{gpid:"/22562061343/0492-01_netfla-com-br_footer__",data:{pbadslot:"/22562061343/0492-01_netfla-com-br_footer__",divId:"embi_footer_intop_afb2b05f"},instl:0,rwdd:0}}},adunitDesktop:{code:"embi_footer_intop_afb2b05f",mediaTypes:{banner:{sizes:[[728,90],[970,90]]}},bids:[],ortb2Imp:{ext:{gpid:"/22562061343/0492-01_netfla-com-br_footer__",data:{pbadslot:"/22562061343/0492-01_netfla-com-br_footer__",divId:"embi_footer_intop_afb2b05f"},instl:0,rwdd:0}}}}];function f(e){try{const t=e.split(",");for(const e of t){const t=m(e);if(t)return t}return null}catch(t){return a("Error getting first location available with selectors:",e,t),null}}function m(e){try{return document.querySelector(e)}catch(t){return a("Error getting element with selector:",e,t),null}}function g(){const e=[];return p.forEach(t=>{t.tagId&&e.push(t.tagId),t.tagId2&&e.push(t.tagId2)}),e}function u(t,n=null){let i=0,s=0;if(t&&t.length>0&&t.forEach(e=>{if(Array.isArray(e)&&2===e.length){const[t,n]=e;t>i&&(i=t),n>s&&(s=n)}}),n){const t=e?n.adunitMobile:n.adunitDesktop;if(t&&t.mediaTypes&&t.mediaTypes.video&&t.mediaTypes.video.playerSize){t.mediaTypes.video.playerSize.forEach(e=>{if(Array.isArray(e)&&2===e.length){const[t,n]=e;t>i&&(i=t),n>s&&(s=n)}})}}return{maxWidth:i>0?`${i}px`:"none",maxHeight:s>0?`${s}px`:"none"}}!function(e,t){if(!document.querySelector(`script[src='${e}']`)){const n=document.createElement("script");n.async=t,n.type="text/javascript",n.src=e,document.head.appendChild(n)}}("https://securepubads.g.doubleclick.net/tag/js/gpt.js");var y=window.googletag=window.googletag||{};y.cmd=y.cmd||[];const b={visibleAds:new Set,hiddenAdsInViewport:new Set,sentinelObserver:null,refreshInterval:null,sentinels:new Map,lastRefreshTime:new Map,displayedAds:new Set,createSentinel(e,t){try{const n=document.createElement("div");return n.id=`sentinel_${e}`,n.className="ad-sentinel",n.style.cssText="\n position: absolute;\n width: 1px;\n height: 1px;\n opacity: 0;\n pointer-events: none;\n ",t.parentNode.insertBefore(n,t.nextSibling),this.sentinels.set(e,n),o(`Created sentinel for: ${e}`),n}catch(t){return a(`Error creating sentinel for ${e}:`,t),null}},shouldRefreshAd(e){const n=p.find(t=>t.tagId===e),i=n&&("HIGH_IMPACT"===n.type||"FOOTER_INTOP"===n.type||"DISPLAY_VIDEO_STICKY"===n.type);if(!(this.visibleAds.has(e)||this.hiddenAdsInViewport.has(e)||i))return o(` ❌ ${e} not in viewport (visible or hidden)`),!1;if(i)o(` πŸ“ ${e} is ${n.type} overlay`);else{const t=this.hiddenAdsInViewport.has(e);o(` πŸ“ ${e} is ${t?"hidden":"visible"} in viewport`)}const s=this.lastRefreshTime.get(e);if(!s)return o(` βœ… ${e} ready for first refresh (never refreshed before)`),!0;const r=Date.now()-s,d=r>=t;return o(` ${d?"βœ…":"⏳"} ${e} time since refresh: ${Math.round(r/1e3)}s / ${t/1e3}s`),d},markDisplayed(e){if(!this.displayedAds.has(e)){this.displayedAds.add(e),o(`πŸ“Ί Ad marked as displayed: ${e}`);const t=document.getElementById(e);if(t){const n=t.getBoundingClientRect(),i=n.top0,s=0===n.width&&0===n.height;o(` - In viewport: ${i}, Hidden: ${s}, Size: ${n.width}x${n.height}`),i&&!s?(this.visibleAds.add(e),o(" - Added to visible ads immediately")):i&&s&&(this.hiddenAdsInViewport.add(e),o(" - Added to hidden ads in viewport"))}}},triggerAdRefresh(e,t="entered viewport"){try{p.find(t=>t.tagId===e);if(this.shouldRefreshAd(e)){o(`🎯 Triggering immediate refresh for ${e} (${t})`);const n=p.find(t=>t.tagId===e||t.tagId2===e);n&&(e===n.tagId&&n.adSlot?(y.pubads().refresh([n.adSlot]),this.lastRefreshTime.set(e,Date.now())):e===n.tagId2&&n.adSlotB&&(y.pubads().refresh([n.adSlotB]),this.lastRefreshTime.set(e,Date.now())))}else if(this.displayedAds.has(e)){const t=this.lastRefreshTime.get(e),n=Math.round((Date.now()-t)/1e3);o(`⏭️ Skipping refresh for ${e} (refreshed ${n}s ago)`)}else o(`⏭️ Skipping refresh for ${e} (not displayed yet)`)}catch(t){a(`Error triggering refresh for ${e}:`,t)}},initialize(){try{this.sentinelObserver=new IntersectionObserver(e=>{e.forEach(e=>{const t=e.target.id.replace("sentinel_","");if(o(`πŸ” Sentinel check: ${t}, intersecting: ${e.isIntersecting}`),e.isIntersecting){const e=document.getElementById(t);if(e){const n=e.getBoundingClientRect(),i=0===n.width&&0===n.height;if(o(` - Ad dimensions: ${n.width}x${n.height}, isHidden: ${i}`),i){const e=this.hiddenAdsInViewport.has(t);this.hiddenAdsInViewport.add(t),this.visibleAds.delete(t),o(`πŸ” Hidden ad in viewport: ${t}`),!e&&this.shouldRefreshAd(t)&&this.triggerAdRefresh(t,"hidden ad entered viewport")}else{const e=this.visibleAds.has(t);this.visibleAds.add(t),this.hiddenAdsInViewport.delete(t),o(`πŸ” Visible ad in viewport: ${t}`),!e&&this.shouldRefreshAd(t)&&this.triggerAdRefresh(t,"visible ad entered viewport")}}}else this.hiddenAdsInViewport.delete(t),this.visibleAds.delete(t),o(`πŸ” Ad left viewport: ${t}`)}),o(`βœ… Visible ads: ${this.visibleAds.size}, Hidden in viewport: ${this.hiddenAdsInViewport.size}`)},{rootMargin:n,threshold:0});const e=g();let i=0;e.forEach(e=>{const t=document.getElementById(e);if(t){const n=this.createSentinel(e,t);n&&(this.sentinelObserver.observe(n),i++,o(`πŸ‘οΈ Observing sentinel for: ${e}`))}else d(`⚠️ Element not found for observation: ${e}`)}),this.startRefreshTimer(),o(`βœ… Fast refresh system initialized: ${i}/${e.length} ad units observed (GPT-only, sentinel-only)`),o(` - Refresh interval: ${t/1e3}s`),o(` - Observer margin: ${n}`)}catch(e){a("Error initializing refresh manager:",e)}},startRefreshTimer(){this.refreshInterval=setInterval(()=>{this.refreshVisibleAds()},t)},refreshVisibleAds(){try{const e=new Set;if(this.visibleAds.forEach(t=>e.add(t)),this.hiddenAdsInViewport.forEach(t=>e.add(t)),p.forEach(t=>{"FOOTER_INTOP"===t.type&&e.add(t.tagId)}),0===e.size)return void o("⏭️ No ads in refresh range");o(`πŸ”„ Periodic refresh: ${e.size} ad(s) (${this.visibleAds.size} visible + ${this.hiddenAdsInViewport.size} hidden + overlays)`),e.forEach(e=>{try{const n=document.getElementById(e),i=this.shouldRefreshAd(e);if(o(`πŸ” Checking ${e}: element=${!!n}, shouldRefresh=${i}, displayed=${this.displayedAds.has(e)}`),n&&i){o(`βœ… Refreshing ad: ${e}`);const t=p.find(t=>t.tagId===e||t.tagId2===e);t?e===t.tagId&&t.adSlot?(y.pubads().refresh([t.adSlot]),this.lastRefreshTime.set(e,Date.now()),o(`βœ… Refreshed successfully: ${e} (slot 1)`)):e===t.tagId2&&t.adSlotB?(y.pubads().refresh([t.adSlotB]),this.lastRefreshTime.set(e,Date.now()),o(`βœ… Refreshed successfully: ${e} (slot 2)`)):d(`⚠️ No matching adSlot found for ${e}`):d(`⚠️ No product found for ${e}`)}else if(n)if(this.displayedAds.has(e)){const n=this.lastRefreshTime.get(e),i=Math.round((Date.now()-n)/1e3);o(`⏭️ Skipping ${e} (refreshed ${i}s ago, interval: ${t/1e3}s)`)}else o(`⏭️ Skipping ${e} (not displayed yet)`);else d(`⚠️ Element not found: ${e}`)}catch(t){a(`Error refreshing ${e}:`,t)}})}catch(e){a("Error in refreshVisibleAds:",e)}},destroy(){this.sentinelObserver&&this.sentinelObserver.disconnect(),this.refreshInterval&&clearInterval(this.refreshInterval),this.sentinels.forEach(e=>{try{e&&e.parentNode&&e.parentNode.removeChild(e)}catch(e){a("Error removing sentinel:",e)}}),this.sentinels.clear(),this.lastRefreshTime.clear(),this.displayedAds.clear(),this.visibleAds.clear(),this.hiddenAdsInViewport.clear(),o("RefreshManager cleanup complete")}};function I(t,n="TOP"){const i=(c&&c.isConnected||(c=document.getElementById("embi-overlay-root"),c||(c=document.createElement("div"),c.id="embi-overlay-root",Object.assign(c.style,{position:"fixed",inset:"0",pointerEvents:"none",zIndex:"2147483647"}),document.body.appendChild(c))),c),s=document.createElement("div");s.id="embi-footer-intop-ad-container",Object.assign(s.style,{position:"fixed",left:e?"0":"50%",transform:e?"":"translateX(-50%)",width:e?"100vw":"auto",height:"auto",background:e?"rgba(0,0,0,0.75)":"transparent",bottom:"FOOTER"===n?"0px":"auto",top:"TOP"===n?"0px":"auto",zIndex:"1",boxShadow:"black 0 3px 10px 0",display:"none",transition:"bottom 0.3s ease-in-out",pointerEvents:"auto",textAlign:"center"});const r=document.createElement("div");r.id=t;const o=document.createElement("script");return o.textContent=`\n googletag.cmd.push(function() {\n googletag.display('${t}');\n });\n `,r.appendChild(o),s.appendChild(r),s.appendChild(function(e,t){const n=document.createElement("button");n.innerHTML="Γ—",n.title="Close ad";const i="rgba(0, 0, 0, 0.6)",s="FOOTER"===t?"translate(50%, -50%)":"translate(50%, 50%)";return Object.assign(n.style,{position:"absolute",right:"0px",top:"FOOTER"===t?"0px":"auto",bottom:"TOP"===t?"0px":"auto",width:"16px",height:"16px",background:i,opacity:"1",padding:"0px",border:"none",borderRadius:"50%",color:"#fff",fontSize:"18px",fontWeight:"bold",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",zIndex:"2147483648",transform:s,transition:"background 0.2s ease, transform 0.2s ease",boxShadow:"0 2px 8px rgba(0,0,0,0.3)"}),n.addEventListener("mouseenter",()=>{n.style.background="rgba(0, 0, 0, 0.8)",n.style.transform=`${s} scale(1.1)`,n.style.boxShadow="0 4px 12px rgba(0,0,0,0.4)"}),n.addEventListener("mouseleave",()=>{n.style.background=i,n.style.transform=s,n.style.boxShadow="0 2px 8px rgba(0,0,0,0.3)"}),n.addEventListener("click",()=>{e.style.display="none"}),n}(s,n)),i.appendChild(s),h(),s}function E(t){try{if(t.manualInsertion&&"TABOOLA_INTEGRATION"!==t.type){const s=t.tagId;new MutationObserver((e,t)=>{document.getElementById(s)&&(y.cmd.push(function(){y.display(s)}),t.disconnect())}).observe(document.body,{childList:!0,subtree:!0})}else{const r=t.type,o=t.position,c=t.ubication,h=t.tagId,p=t.offset;function n(e,t){const n=document.createElement("script");n.textContent=`\n googletag.cmd.push(function() {\n googletag.display('${t}');\n });\n `,e.appendChild(n)}try{if("TABOOLA_INTEGRATION"===r)createTaboolaContainer(t);else if("HIGH_IMPACT"===r)INTERSTITIAL_CONTAINER=createInterstitialContainer(h);else if("DISPLAY_VIDEO_STICKY"===r)cornerContainer=createCornerContainer(h,o,p);else if("FOOTER_INTOP"===r)l=I(h,o);else if("DOUBLE_BOX"===r){const m=f(`${c}`);if(!m)return a(`Elemento con clase '${c}' no encontrado en el DOM para el anuncio ${h}. No se pudo insertar el DIV.`),!1;const g=t.tagId2,b=e?t.mobileSizes:t.desktopSizes,{maxWidth:E,maxHeight:v}=u(b,t),$=document.createElement("div");$.id=`container_${h}`,(i=$).style.display="flex",i.style.flexDirection=e?"column":"row",i.style.gap="24px",i.style.marginBottom="24px",i.style.background="transparent",i.style.justifyContent="center";const w=document.createElement("div");w.id=`wrapper_${h}`,w.className="ad-slot-wrapper",w.style.maxWidth=E,w.style.maxHeight=v,w.style.overflow="hidden",w.style.display="flex",w.style.justifyContent="center",w.style.alignItems="center";const A=document.createElement("div");A.id=h,A.className="ad-slot",A.style.minHeight="1px";const T=document.createElement("script");T.textContent=`\n googletag.cmd.push(function() {\n googletag.display('${h}');\n });\n `,A.appendChild(T),w.appendChild(A),$.appendChild(w);const x=document.createElement("div");x.id=`wrapper_${g}`,x.className="ad-slot-wrapper",x.style.maxWidth=E,x.style.maxHeight=v,x.style.overflow="hidden",x.style.display="flex",x.style.justifyContent="center",x.style.alignItems="center";const S=document.createElement("div");S.id=g,S.className="ad-slot",S.style.minHeight="1px";const _=document.createElement("script");switch(_.textContent=`\n googletag.cmd.push(function() {\n googletag.display('${g}');\n });\n `,S.appendChild(_),x.appendChild(S),$.appendChild(x),o){case"INSERT_BEFORE":m.insertAdjacentElement("beforebegin",$);break;case"INSERT_AFTER":m.insertAdjacentElement("afterend",$);break;default:m.appendChild($)}}else if("DISPLAY_VIDEO"===r){const O=f(`${c}`);if(!O)return void a(`Elemento con clase '${c}' no encontrado en el DOM para el anuncio ${h}.`);const R=e?t.mobileSizes:t.desktopSizes,{maxWidth:C,maxHeight:N}=u(R,t),k=document.createElement("div");k.id=`wrapper_${h}`,k.className="ad-slot-wrapper",k.style.maxWidth=C,k.style.maxHeight=N,k.style.overflow="hidden",k.style.margin="0 auto 24px",k.style.display="flex",k.style.justifyContent="center",k.style.alignItems="center";const z=document.createElement("div");switch(z.id=h,z.className="ad-slot",z.style.minHeight="1px",n(z,h),k.appendChild(z),o){case"INSERT_BEFORE":O.insertAdjacentElement("beforebegin",k);break;case"INSERT_AFTER":O.insertAdjacentElement("afterend",k);break;default:O.appendChild(k)}}else if(t.isSticky)cornerContainer=createCornerContainer(h,o),n(cornerContainer,h);else{const D=f(`${c}`);if(!D)return void a(`Elemento con clase '${c}' no encontrado en el DOM para el anuncio ${h}.`);const B=e?t.mobileSizes:t.desktopSizes,{maxWidth:L,maxHeight:P}=u(B,t),H=document.createElement("div");H.id=`wrapper_${h}`,H.className="ad-slot-wrapper",H.style.maxWidth=L,H.style.maxHeight=P,H.style.overflow="hidden",H.style.margin="0 auto 24px",H.style.display="flex",H.style.justifyContent="center",H.style.alignItems="center";const M=document.createElement("div");switch(M.id=h,M.className="ad-slot",M.style.minHeight="1px",n(M,h),H.appendChild(M),o){case"INSERT_BEFORE":D.insertAdjacentElement("beforebegin",H);break;case"INSERT_AFTER":D.insertAdjacentElement("afterend",H);break;default:D.appendChild(H)}}}catch(V){a(`Error procesando el anuncio ${h}:`,V)}}}catch(F){d("Error rendering adunit for product",t.tagId,F)}var i}function v(){try{p.map(e=>{E(e)}),y.cmd.push(function(){const e=p.filter(e=>"HIGH_IMPACT"===e.type||"FOOTER_INTOP"===e.type||"DISPLAY_VIDEO_STICKY"===e.type);e.length>0&&(o("🎯 Loading overlay ads immediately..."),e.forEach(e=>{try{o(` - Displaying ${e.type} ad: ${e.tagId}`),y.display(e.tagId)}catch(t){a(`Error displaying ${e.type} ad ${e.tagId}:`,t)}}))}),setTimeout(()=>{o("πŸ”„ Initializing fast refresh system (GPT-only)..."),b.initialize()},r.loadDelay)}catch(e){a("Error in mainInitialization:",e)}finally{o("βœ… EMBI ad system initialized successfully (GPT-only)")}}y.cmd.push(function(){if(p.filter(e=>"TABOOLA_INTEGRATION"!==e.type).forEach(t=>{try{const n=e?t.mobileSizes:t.desktopSizes;t.adSlot=y.defineSlot(t.slot,n,t.tagId).setForceSafeFrame(!1).addService(y.pubads()),"DOUBLE_BOX"===t.type&&(t.adSlotB=y.defineSlot(t.slot2,n,t.tagId2).setForceSafeFrame(!1).addService(y.pubads())),o(`GPT slot defined: ${t.tagId}`)}catch(e){a("Error creating GPT slot for product",t.tagId,e)}}),r.enabled){p.some(e=>e.loadImmediately)&&(y.pubads().enableSingleRequest(),o("Single Request enabled for priority ads"))}y.pubads().enableLazyLoad(s),y.pubads().collapseEmptyDivs(!0),y.pubads().setCentering(!0),y.pubads().addEventListener("slotRenderEnded",function(e){try{const t=e.slot.getSlotElementId();if(!g().find(e=>e===t))return;const n=e.isEmpty;o(`πŸ“Ί Ad render event: ${t}, isEmpty: ${n}`),void 0!==b&&(b.lastRefreshTime.set(t,Date.now()),n?o(` ⚠️ Ad slot ${t} rendered empty - will retry on next refresh cycle`):b.markDisplayed(t))}catch(e){a("Error in slotRenderEnded event:",e)}const t=e.slot.getSlotElementId();p.forEach(n=>{try{t===n.tagId&&"FOOTER_INTOP"===n.type&&(i=l,s=e.isEmpty,i&&(i.style.display=s?"none":"block",s||h()))}catch(e){a("Error rendering slot for product",n.tagId,e)}var i,s})}),y.enableServices(),o("GPT configuration complete")}),"loading"===document.readyState?document.addEventListener("DOMContentLoaded",v):v()})();