/* OK ITHAKI R10F37F1F2 — one URL owner + professional footer owner */
(()=>{'use strict';
const VERSION='249526r10f37f1f2';
const MARK='ITHAKI_R10F37F1F2_VERSION_OWNER_READY';
const FOOTER_EL='OK ITHAKI · Ιδιωτικότητα · Ανθρώπινη επικοινωνία';
const FOOTER_EN='OK ITHAKI · Privacy · Human communication';
window.ITHAKI_ACTIVE_VERSION=VERSION;
window[MARK]=true;
function sameApp(u){
  try{return u.origin===location.origin && (u.pathname==='/' || u.pathname==='/index.html' || u.protocol==='https:' && /appassets\.androidplatform\.net$/i.test(u.hostname));}
  catch(_e){return false;}
}
function canonical(input){
  const u=new URL(input==null?location.href:String(input),location.href);
  if(sameApp(u)){
    u.searchParams.set('v',VERSION);
    const l=u.searchParams.get('lang');
    if(l && l!=='el' && l!=='en')u.searchParams.set('lang','el');
  }
  return u.toString();
}
const rawReplace=history.replaceState.bind(history);
const rawPush=history.pushState.bind(history);
history.replaceState=function(state,title,url){if(url!=null){try{url=canonical(url)}catch(_e){}}return rawReplace(state,title,url)};
history.pushState=function(state,title,url){if(url!=null){try{url=canonical(url)}catch(_e){}}return rawPush(state,title,url)};
function lang(){try{return (localStorage.getItem('ith_ui_lang_v249141')||localStorage.getItem('ith_ui_lang')||new URL(location.href).searchParams.get('lang')||'el')==='en'?'en':'el'}catch(_e){return 'el'}}
function ownFooter(){
  document.querySelectorAll('.proFooter').forEach(f=>{
    f.textContent=lang()==='en'?FOOTER_EN:FOOTER_EL;
    f.setAttribute('data-r10f37f1f2-footer-owner','1');
    f.style.display=(document.body && document.body.dataset && document.body.dataset.page==='profile')?'none':'';
  });
}
function repair(){
  try{
    const u=new URL(location.href);
    if(sameApp(u) && u.searchParams.get('v')!==VERSION)rawReplace(history.state,'',canonical(u.toString()));
    document.documentElement.setAttribute('data-ithaki-version',VERSION);
    document.documentElement.setAttribute('data-r10f37f1f2-ui-owner','1');
    let m=document.querySelector('meta[name="ok-ithaki-active-version"]');
    if(!m){m=document.createElement('meta');m.name='ok-ithaki-active-version';document.head.appendChild(m)}
    m.content=VERSION;
    ownFooter();
  }catch(_e){}
}
window.ITHAKI_CANONICAL_APP_URL_R10F37F1F2=function(extra){
  const u=new URL(location.href);
  if(extra && typeof extra==='object')Object.keys(extra).forEach(k=>{const v=extra[k];if(v===undefined||v===null||v==='')u.searchParams.delete(k);else u.searchParams.set(k,String(v))});
  return canonical(u.toString());
};
repair();
document.addEventListener('DOMContentLoaded',repair,{once:true});
addEventListener('pageshow',repair);addEventListener('popstate',repair);
new MutationObserver(()=>{clearTimeout(window.__ithakiFooterF2Timer);window.__ithakiFooterF2Timer=setTimeout(repair,25)}).observe(document.documentElement,{subtree:true,childList:true,characterData:true,attributes:true,attributeFilter:['data-page','class']});
setInterval(repair,900);
})();
