+c.toFixed(2)+''+(isFinite(o)&&o>c?'
+o.toFixed(2)+'
':'')+(pct>0?'(-'+pct+'%)':''); } if((c===0||c==null)&&isFinite(o)&&o>0) return '$0.00
+o.toFixed(2)+'
(-100%)'; if(d===100||(c===0&&o===0)) return 'FREE'; if(isFinite(d)&&d>0) return '-'+Math.round(d)+'%'; return ''; } function parsePayload(){ var n=document.getElementById(FEED_ID); if(!n) return null; try { var p=JSON.parse(n.textContent||''); if(!p||!isFinite(p.generatedAt)||!Array.isArray(p.rows)||!p.rows.length) return null; var age=Date.now()-p.generatedAt; if(age<0||age>MAX_AGE) return null; return p; } catch (_) { return null; } } function renderShell(payload){ if(document.getElementById(SHELL_ID)) return true; var root=document.getElementById('root'); if(!root) return false; var l=lang(); var heading=l==='ru'?'Лучшие скидки сегодня':l==='es'?'Mejores ofertas de hoy':'Best Daily Deals & Discounts'; var hot=l==='ru'?'Горячие':l==='es'?'Populares':'Hot'; var cards=payload.rows.slice(0,8).map(function(row,i){ var tt=title(row,l), img=typeof row.image_url==='string'?row.image_url.trim():'', store=row.store_name||(row.stores&&row.stores.name)||''; return '
'+(img?''+esc(tt)+'':'')+'
'+esc(relTime(row.created_at))+(row.is_pinned?' PINNED':'')+''+(store?''+esc(store)+'':'')+'
'+esc(tt)+'
'+price(row)+'
'; }).join(''); var shell=document.createElement('div'); shell.id=SHELL_ID; shell.style.cssText='min-height:100vh;background:#111827;color:#fff;font-family:Arial,sans-serif'; shell.innerHTML='

'+esc(heading)+'

'+esc(hot)+'
'+cards+'
'; root.style.display='none'; root.parentNode.insertBefore(shell,root); performance.mark('edge_shell_painted'); return true; } function cleanup(){ if(observer){observer.disconnect();observer=null;} if(fallback){clearTimeout(fallback);fallback=null;} ['pointerdown','keydown','touchstart','wheel'].forEach(function(e){window.removeEventListener(e,start,true);}); } function revealWhenReady(){ var root=document.getElementById('root'), startAt=performance.now(); function check(){ if(performance.getEntriesByName('items_set').length||performance.now()-startAt>5000){ requestAnimationFrame(function(){ if(root) root.style.display=''; var s=document.getElementById(SHELL_ID); if(s) s.remove(); }); } else setTimeout(check,50); } check(); } function start(){ if(started) return; started=true; cleanup(); import(ENTRY).then(revealWhenReady).catch(function(){ location.reload(); }); } if(!eligible()) { start(); return; } function tryShell(){ var p=parsePayload(); if(!p) return false; if(!renderShell(p)) return false; cleanup(); ['pointerdown','keydown','touchstart','wheel'].forEach(function(e){window.addEventListener(e,start,{capture:true,passive:true});}); fallback=setTimeout(start,60000); return true; } if(tryShell()) return; observer=new MutationObserver(function(){ if(tryShell()) observer&&observer.disconnect(); }); observer.observe(document.documentElement,{childList:true,subtree:true}); document.addEventListener('DOMContentLoaded',function(){ setTimeout(function(){ if(!document.getElementById(SHELL_ID)) start(); },0); },{once:true}); })();