/* OK ITHAKI V249526R5 — COMMUNITY PANELS / MENU DEDUP / VIDEO LABELS / BELL DEDUP / BIL VOICE */
(function(){
'use strict';
if(window.__ITHAKI_V249526R5_OWNER__)return;
window.__ITHAKI_V249526R5_OWNER__={version:'V249526R5',communityPanelsStayOpen:true,communityMenuDedup:true,videoActionLabels:true,notificationSemanticDedup:true,bilVoice:true,at:Date.now()};
const COMMUNITY_PANEL_STAYS_OPEN_R5=true;
const COMMUNITY_MENU_DEDUP_R5=true;
const COMMUNITY_VIDEO_ACTION_LABELS_R5=true;
const NOTIFICATION_SEMANTIC_DEDUP_R5=true;
const BIL_VISIBLE_AND_VOICE_R5=true;
const $=id=>document.getElementById(id);
const norm=s=>String(s||'').normalize('NFD').replace(/[\u0300-\u036f]/g,'').replace(/[^a-zA-Z0-9\u0370-\u03ff]+/g,' ').replace(/\s+/g,' ').trim().toLocaleLowerCase('el');
function buttonKey(b){return String(b.id||b.dataset.ith516Action||b.dataset.ith519Cmd||b.dataset.ith518Action||b.dataset.action||b.dataset.a||b.dataset.tab||b.getAttribute('name')||norm(b.textContent||b.title||b.getAttribute('aria-label')))}
function uniqueButtons(root,selector='button'){if(!root)return;const seen=new Set();[...root.querySelectorAll(selector)].forEach(b=>{const k=buttonKey(b);if(!k)return;if(seen.has(k)){b.remove();return}seen.add(k)})}
function dedupeCommunityMenus(){const m=$('memberMenu');if(m)uniqueButtons(m,'.ith517ToolGrid button,.ith516PanelList button,#ith519CommunityCommandBar button,.ith516ChatScreen .chatHead button');document.querySelectorAll('#memberMenu .ith517ToolGrid,#memberMenu .ith516PanelList,#ith519CommunityCommandBar,#ith516ChatScreen .chatHead').forEach(g=>uniqueButtons(g,':scope > button'))}
const labels={heart:'Καρδιά',reply:'Απάντηση',share:'Κοινοποίηση',download:'Λήψη',full:'Οθόνη',more:'Επιλογές'};
function labelCommunityVideoActions(){document.querySelectorAll('.ith518Rail button[data-ith518-action]').forEach(b=>{if(b.querySelector('.ith518RailLabel'))return;const a=String(b.dataset.ith518Action||''),icon=String(b.textContent||'').trim();b.textContent='';const i=document.createElement('span');i.className='ith518RailIcon';i.textContent=icon||'•';const l=document.createElement('span');l.className='ith518RailLabel';l.textContent=labels[a]||b.title||'Επιλογή';b.append(i,l)})}
function notificationKey(x){const explicit=String(x.dataset.key||'');if(explicit)return explicit;const title=norm(x.querySelector('header b,b')?.textContent||x.textContent);const time=norm(x.querySelector('header small,time,small')?.textContent||'');const peer=String(x.querySelector('[data-peer]')?.getAttribute('data-peer')||'');return title+'|'+time+'|'+peer}
function dedupeNotificationCenter(){document.querySelectorAll('#ith526NotificationCenter').forEach(root=>{const seen=new Set();root.querySelectorAll('.ith526Notice').forEach(x=>{const k=notificationKey(x);if(k&&seen.has(k))x.remove();else if(k)seen.add(k)});const tabs=root.querySelector('.ith526Tabs');if(tabs)uniqueButtons(tabs,':scope > button')});const bells=[...document.querySelectorAll('#ithNotifyFabV249238,.ithNotifyFabV249238,[data-notifications-fab]')];const keep=bells.find(x=>x.id==='ithNotifyFabV249238')||bells[0];bells.forEach(x=>{if(x!==keep)x.remove()});if(keep){const badges=[...keep.querySelectorAll('.badge')];badges.slice(1).forEach(x=>x.remove())}}
function keepActiveCommunityPanel(){if(String(document.body?.dataset.page||'')!=='spaces')return;const m=$('memberMenu');if(m&&m.children.length&&m.classList.contains('show')){m.setAttribute('aria-hidden','false');m.classList.add('fullAvatarMenuV249231')}}
function ensureBil(){const copies=[...document.querySelectorAll('#ith526BilDock')];copies.slice(1).forEach(x=>x.remove());const d=copies[0];if(!d)return;const on=localStorage.getItem('ith525_bil_enabled')!=='0'&&localStorage.getItem('ith_bil_enabled_v249461')!=='0';const page=String(document.body?.dataset.page||window.state?.page||'home');const center=!!document.querySelector('#ith526NotificationCenter,#ith526NotificationSettings');d.hidden=!on||!(page==='home'||center);if(!d.hidden){d.style.removeProperty('display');d.style.removeProperty('visibility');d.style.removeProperty('opacity');d.style.removeProperty('pointer-events')}}
function css(){if($('ith526R5Css'))return;const s=document.createElement('style');s.id='ith526R5Css';s.textContent=`.ith518Rail{right:6px!important}.ith518Rail button{width:62px!important;min-height:48px!important;height:auto!important;border-radius:15px!important}.ith518RailLabel{display:block!important;color:#fff!important;font-size:9px!important;font-weight:900!important;line-height:1.05!important}.ith518RailIcon{display:block!important;font-size:17px!important;line-height:1!important}#memberMenu .ith517ToolGrid button{white-space:normal!important}body[data-page="home"] #ith526BilDock,body.ith526NotificationsOpen #ith526BilDock{display:block!important;visibility:visible!important;opacity:1!important;pointer-events:auto!important}body:not([data-page="home"]):not(.ith526NotificationsOpen) #ith526BilDock{display:none!important}`;document.head.appendChild(s)}
function maintain(){css();dedupeCommunityMenus();labelCommunityVideoActions();dedupeNotificationCenter();keepActiveCommunityPanel();ensureBil();try{localStorage.setItem('ith_frontend_build','V249526R5-community-menu-video-bell-bil');document.documentElement.setAttribute('data-ithaki-v249526r5','community-menu-video-bell-bil')}catch(e){}}
function install(){maintain();new MutationObserver(()=>{clearTimeout(install._m);install._m=setTimeout(maintain,45)}).observe(document.body,{subtree:true,childList:true});window.addEventListener('ithaki:page-changed',()=>setTimeout(maintain,30));['focus','pageshow'].forEach(n=>window.addEventListener(n,maintain));setInterval(maintain,900)}
if(document.readyState==='loading')document.addEventListener('DOMContentLoaded',install,{once:true});else install();
})();
