/* OK ITHAKI V249397 — professional preview delivery, visible DM security selector,
 * and one unified Home Wall with V411 live reactions.
 * This module does not create a second wall database and does not weaken the
 * existing V249396 security modes. It binds the UI to the already-installed APIs.
 */
(function(){
  'use strict';
  if(window.__ITHAKI_V249397_PRO_FLOW__) return;
  window.__ITHAKI_V249397_PRO_FLOW__=1;

  const BUILD='V249413-professional-security-wall-no-preview';
  const $=id=>document.getElementById(id);
  const esc=v=>String(v==null?'':v).replace(/[&<>"']/g,c=>({'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;',"'":'&#39;'}[c]));
  const delay=ms=>new Promise(r=>setTimeout(r,ms));
  const REACTIONS=[['🤍','Στήριξη'],['🫂','Αγκαλιά'],['🙏','Σε ακούω'],['🌊','Μαζί σου'],['🕯️','Κατανόηση'],['🌱','Ελπίδα']];
  let wallSocket=null;
  let wallRefreshTimer=0;

  function stateNow(){try{return window.state||state||{}}catch(e){return window.state||{}}}
  function room(){const s=stateNow();return String(s.room||localStorage.getItem('ith_room')||'ithaki-phone-test')}
  function device(){const s=stateNow();return String(localStorage.getItem('ith_device')||localStorage.getItem('device_id')||s.device||'').trim()}
  function activeChannel(){return String(stateNow().activeChannel||'')}
  function api(path){try{if(typeof window.api==='function')return window.api(path)}catch(e){}return path}
  function notify(text,ms=6500){try{if(typeof window.toast==='function')return window.toast(String(text),ms);if(window.ITH&&typeof ITH.notifyAppEvent==='function')return ITH.notifyAppEvent(String(text))}catch(e){}console.log(text)}
  async function request(path,opt){const r=await fetch(api(path),Object.assign({cache:'no-store',credentials:'same-origin',headers:{'Content-Type':'application/json'}},opt||{}));let d={};try{d=await r.json()}catch(e){}if(!r.ok||d.ok===false){const detail=d.detail||d.message||d.reason||('HTTP '+r.status);const er=new Error(typeof detail==='string'?detail:JSON.stringify(detail));er.status=r.status;throw er}return d}
  function channelFor(peer){return 'dm:'+ [device(),String(peer||'')].sort().join(':')}
  function fileKind(file){const t=String(file&&file.type||'').toLowerCase(),n=String(file&&file.name||'').toLowerCase();if(t.startsWith('video/')||/\.(mp4|mov|m4v|webm|3gp|avi|mkv)$/.test(n))return'video';if(t.startsWith('image/')||/\.(jpg|jpeg|png|webp|gif|heic)$/.test(n))return'photo';if(t.startsWith('audio/'))return'audio';return'file'}

  function injectCss(){if($('ithProfessionalFlowCss397'))return;const st=document.createElement('style');st.id='ithProfessionalFlowCss397';st.textContent=`
    #ithSecurityBar397{flex:0 0 auto;display:grid;grid-template-columns:minmax(0,1fr) auto;gap:8px;align-items:center;margin:0 8px 7px;padding:9px 10px;border-radius:16px;border:1px solid rgba(83,224,166,.34);background:linear-gradient(135deg,rgba(13,83,63,.28),rgba(5,19,31,.94));box-shadow:0 10px 30px rgba(0,0,0,.2)}
    #ithSecurityBar397 button{min-width:0;display:flex;align-items:center;gap:7px;text-align:left;border:0;background:transparent;color:#dfffee;font-weight:1000;font-size:12px;padding:3px;white-space:normal}#ithSecurityBar397 small{color:rgba(225,244,255,.72);font-size:10px;text-align:right;line-height:1.25}
    #ithSecurityBar397[data-mode="standard_aes"]{border-color:rgba(105,174,255,.45);background:linear-gradient(135deg,rgba(31,93,165,.27),rgba(5,19,31,.94))}#ithSecurityBar397[data-mode="no_encryption"]{border-color:rgba(255,112,82,.5);background:linear-gradient(135deg,rgba(155,42,23,.29),rgba(5,19,31,.94))}
    #ithUnifiedWall397{position:fixed;z-index:2147483647;inset:0;background:radial-gradient(circle at 50% 0,rgba(218,171,72,.12),transparent 35%),#02070d;color:#fff;display:flex;flex-direction:column;font-family:system-ui;overflow:hidden}
    .ithWallTop397{flex:0 0 auto;display:grid;grid-template-columns:auto minmax(0,1fr) auto;align-items:center;gap:9px;padding:calc(env(safe-area-inset-top,0px) + 8px) 10px 9px;border-bottom:1px solid rgba(255,215,112,.18);background:rgba(3,11,19,.94);backdrop-filter:blur(16px)}.ithWallTop397 button{width:43px;height:43px;border-radius:14px;border:1px solid rgba(255,255,255,.14);background:rgba(255,255,255,.06);color:#fff;font-size:21px}.ithWallTop397 h2{margin:0;text-align:center;color:#ffe09a;font-size:19px}.ithWallTop397 small{display:block;text-align:center;color:rgba(255,255,255,.62);font-size:10px;margin-top:2px}
    .ithWallBody397{flex:1 1 auto;min-height:0;overflow:auto;padding:10px 10px 130px;-webkit-overflow-scrolling:touch}.ithWallHero397{display:flex;justify-content:space-between;gap:10px;align-items:center;padding:10px 12px;margin-bottom:10px;border-radius:17px;border:1px solid rgba(255,215,112,.18);background:rgba(255,255,255,.045);font-size:11px;color:#cbd5df}.ithWallList397{display:grid;gap:10px;max-width:850px;margin:auto}.ithWallCard397{padding:13px;border-radius:20px;border:1px solid rgba(255,255,255,.12);background:linear-gradient(155deg,rgba(255,255,255,.065),rgba(255,255,255,.025));box-shadow:0 15px 40px rgba(0,0,0,.22)}.ithWallMeta397{display:flex;justify-content:space-between;color:#aeb9c7;font-size:11px}.ithWallMeta397 b{color:#f6d888}.ithWallText397{font-size:16px;line-height:1.46;white-space:pre-wrap;overflow-wrap:anywhere;margin:12px 0}.ithWallReactions397{display:grid;grid-template-columns:repeat(6,minmax(0,1fr));gap:5px}.ithWallReaction397{min-width:0;height:43px;border-radius:14px;border:1px solid rgba(255,255,255,.12);background:rgba(0,0,0,.24);color:#fff;display:flex;justify-content:center;align-items:center;gap:3px;font-size:18px}.ithWallReaction397 b{font-size:10px;color:#bcc7d3}.ithWallReaction397.active{border-color:rgba(255,217,120,.72);background:rgba(216,170,69,.22)}.ithWallFoot397{display:flex;justify-content:flex-end;margin-top:7px}.ithWallFoot397 button{border:0;background:transparent;color:#8f9cac;padding:5px;font-size:10px}.ithWallEmpty397{padding:34px 16px;text-align:center;border-radius:20px;border:1px dashed rgba(255,215,112,.24);color:#bdc8d6}
    .ithWallComposer397{position:absolute;left:0;right:0;bottom:0;padding:9px 10px calc(env(safe-area-inset-bottom,0px) + 9px);display:grid;grid-template-columns:minmax(0,1fr) auto;gap:8px;background:rgba(2,7,13,.92);border-top:1px solid rgba(255,215,112,.18);backdrop-filter:blur(18px)}.ithWallComposer397 textarea{min-height:49px;max-height:125px;resize:none;border-radius:17px;border:1px solid rgba(255,255,255,.14);background:rgba(255,255,255,.055);color:#fff;padding:11px;font:500 15px/1.35 system-ui}.ithWallComposer397 button{width:51px;height:51px;border-radius:17px;border:0;background:linear-gradient(145deg,#d3a242,#f0cb78);color:#07101a;font-size:22px;font-weight:1000}
    #previewModal.ithPreviewFront397{z-index:2147483647!important}#ithPublicationWorkspace387.ithWorkspaceBehind397{z-index:2147483645!important}
    @media(max-width:620px){#ithSecurityBar397{grid-template-columns:1fr;margin:0 5px 6px}#ithSecurityBar397 small{text-align:left}.ithWallReactions397{gap:3px}.ithWallReaction397{height:41px;font-size:17px}}
  `;document.head.appendChild(st)}

  function securityLabel(mode){if(mode==='standard_aes')return'🔒 Προσωπική συνομιλία · AES-GCM γρήγορη';if(mode==='no_encryption')return'⚠️ Προσωπική συνομιλία · Χωρίς E2EE';return'🔐 Προσωπική συνομιλία · Πλήρης E2EE'}
  async function refreshSecurityBar(){
    const ch=activeChannel(),screen=$('dmChatScreen'),pane=screen&&screen.querySelector('.chatPane'),msgs=$('messages');
    if(!pane||!msgs||!ch.startsWith('dm:')){$('ithSecurityBar397')?.remove();return}
    let bar=$('ithSecurityBar397');if(!bar){bar=document.createElement('div');bar.id='ithSecurityBar397';bar.innerHTML='<button type="button">🔐 Προστασία συνομιλίας</button><small>FCM: μόνο σήμα αφύπνισης<br>χωρίς περιεχόμενο</small>';msgs.parentNode.insertBefore(bar,msgs);bar.querySelector('button').onclick=()=>openSecurityPanel()}
    let mode='full_e2ee';try{if(window.ITH&&typeof ITH.getConversationModeV249396==='function')mode=await ITH.getConversationModeV249396(ch,false)}catch(e){}
    bar.dataset.mode=mode;bar.querySelector('button').textContent=securityLabel(mode)+' · Επιλογή';
    const old=document.querySelector('#dmChatScreen button[title*="Private lock"],#dmChatScreen button[title*="κλειδαρ" i]');if(old){old.title='Επιλογή κρυπτογράφησης συνομιλίας';old.onclick=()=>openSecurityPanel()}
  }
  function openSecurityPanel(){const ch=activeChannel();if(!ch.startsWith('dm:')){notify('Επίλεξε πρώτα φίλο και άνοιξε την προσωπική συνομιλία.');return false}try{if(window.ITH&&typeof ITH.openProfessionalSecurityV249396==='function')return ITH.openProfessionalSecurityV249396(ch)}catch(e){}try{if(window.ITHAKI_SECURE_V249389&&typeof ITHAKI_SECURE_V249389.openPanel==='function')return ITHAKI_SECURE_V249389.openPanel(ch)}catch(e){}notify('Η κλειδαριά συνομιλίας δεν φορτώθηκε.');return false}
  function bindSecurityEntry(){window.ITH=window.ITH||{};ITH.openE2EPanel=openSecurityPanel;ITH.openConversationSecurityV249397=openSecurityPanel;refreshSecurityBar().catch(()=>{})}

  function workspaceValues(){const file=$('ithPublicationFile387')?.files?.[0]||null;return{file,destination:$('ithPublicationDestination387')?.value||'feed',friend:$('ithPublicationFriend387')?.value||'',schedule:$('ithPublicationSchedule387')?.value||'',source:$('ithPublicationSource387')?.value||'original',caption:$('ithPublicationCaption387')?.value||''}}
  function restoreWorkspace(){const ws=$('ithPublicationWorkspace387');if(ws){ws.hidden=false;ws.classList.remove('ithWorkspaceBehind397')}const pm=$('previewModal');if(pm){pm.classList.remove('ithPreviewFront397')}return false}
  function patchPreviewReturn(){const pm=$('previewModal');if(!pm||!pm.classList.contains('show'))return;pm.classList.add('ithPreviewFront397');const box=pm.querySelector('.previewBox');if(!box)return;const row=box.querySelector('.row');if(row&&!row.querySelector('[data-return-workspace397]')){const first=row.querySelector('button');if(first){first.setAttribute('data-return-workspace397','1');first.onclick=()=>{try{window.ITH&&ITH.closePreview&&ITH.closePreview()}finally{restoreWorkspace()}}}row.querySelectorAll('button').forEach(b=>{if(/Άκυρο|Cancel/i.test(b.textContent||''))b.onclick=()=>{try{window.ITH&&ITH.closePreview&&ITH.closePreview()}finally{restoreWorkspace()}}})}}
  function launchProfessionalPreview(forceStudio){
    const v=workspaceValues();if(!v.file){notify('Επίλεξε πρώτα φωτογραφία, βίντεο ή αρχείο.');return false}if(v.destination==='dm'&&!v.friend){notify('Επίλεξε αποδεκμένο φίλο.');return false}if(v.destination==='scheduled'&&(!v.schedule||new Date(v.schedule).getTime()<Date.now()+60000)){notify('Η προγραμματισμένη ώρα πρέπει να είναι τουλάχιστον 1 λεπτό στο μέλλον.');return false}
    const fn=(typeof window.openPreview==='function')?window.openPreview:(window.ITH&&typeof ITH.openPreview==='function'?ITH.openPreview:null);if(!fn){notify('Η βασική προεπισκόπηση δεν φορτώθηκε.');return false}
    const ctx=v.destination==='dm'?'dm':'feed',target=v.destination==='dm'?channelFor(v.friend):'';
    try{fn(ctx,v.file,fileKind(v.file),target)}catch(e){notify('Η προεπισκόπηση δεν άνοιξε: '+String(e.message||e));return false}
    const s=stateNow(),pm=$('previewModal');if(!pm||!pm.classList.contains('show')||!s.preview||!s.preview.file){notify('Η προεπισκόπηση δεν δημιουργήθηκε.');return false}
    Object.assign(s.preview,{__workspace387:true,__workspace397:true,__destination387:v.destination,__destination397:v.destination,__friend387:v.friend,__friend397:v.friend,__schedule387:v.schedule,__schedule397:v.schedule,__source387:forceStudio?'studio':v.source,__source397:forceStudio?'studio':v.source,__caption387:v.caption,__caption397:v.caption});
    const ws=$('ithPublicationWorkspace387');if(ws){ws.hidden=true;ws.classList.add('ithWorkspaceBehind397')}pm.classList.add('ithPreviewFront397');
    requestAnimationFrame(()=>requestAnimationFrame(()=>{const cap=$('previewCaption');if(cap)cap.value=v.caption;patchPreviewReturn();const send=$('previewSend');if(send){send.disabled=false;send.textContent=v.destination==='scheduled'?'Αποστολή στον προγραμματισμό V410':v.destination==='dm'?'Αποστολή στον φίλο':'Δημοσίευση στη Ροή'}try{if(window.ITH&&typeof ITH.refreshScrollableFormsV249392==='function')ITH.refreshScrollableFormsV249392()}catch(e){}if(forceStudio||v.source==='studio')setTimeout(()=>{try{if(window.ITH&&typeof ITH.openPreviewStudio==='function')ITH.openPreviewStudio();else notify('Το Studio δεν φορτώθηκε.')}catch(e){notify('Το Studio δεν άνοιξε: '+String(e.message||e))}},80)}));
    return false
  }
  function patchWorkspace(){const preview=$('ithPublicationPreview387'),studio=$('ithPublicationStudio387');if(preview&&!preview.dataset.v249397){preview.dataset.v249397='1';preview.addEventListener('click',e=>{e.preventDefault();e.stopImmediatePropagation();launchProfessionalPreview(false)},true)}if(studio&&!studio.dataset.v249397){studio.dataset.v249397='1';studio.addEventListener('click',e=>{e.preventDefault();e.stopImmediatePropagation();launchProfessionalPreview(true)},true)}const session=$('ithPublicationSession387');if(session&&!session.dataset.v249397){session.dataset.v249397='1';session.textContent='✓ Τοπική προεπισκόπηση και Studio έτοιμα. Επιλέγεις αρχείο → Προεπισκόπηση → Δημοσίευση.';session.style.color='#bfffe4'}window.ITH=window.ITH||{};if(typeof window.openPreview==='function')ITH.openPreview=window.openPreview}

  function removeProfessionalWall(){document.querySelectorAll('[data-pro-tool383="v411"],#ithV411ProfessionalTool397').forEach(x=>x.remove());document.querySelectorAll('.ithAccountHead383 .date').forEach(x=>{if(/Ζωντανός Τοίχος|V411/.test(x.textContent||''))x.textContent='V405–V410 · Studio · Δημόσιο link δημιουργού'});}
  function wallTime(ts){try{return new Date(Number(ts||0)*1000).toLocaleString('el-GR',{day:'2-digit',month:'2-digit',hour:'2-digit',minute:'2-digit'})}catch(e){return''}}
  function closeUnifiedWall(){try{wallSocket&&wallSocket.close()}catch(e){}wallSocket=null;clearTimeout(wallRefreshTimer);$('ithUnifiedWall397')?.remove();document.removeEventListener('keydown',wallEscape397);return false}
  function wallEscape397(e){if(e.key==='Escape'||e.key==='Esc')closeUnifiedWall()}
  function wallCard(post){const id=String(post.post_id||post.id||'');return `<article class="ithWallCard397" data-wall-post397="${esc(id)}"><div class="ithWallMeta397"><b>🎭 Ανώνυμος</b><span>${esc(wallTime(post.created_at||post.timestamp))}</span></div><div class="ithWallText397">${esc(post.text||post.message||'')}</div><div class="ithWallReactions397">${REACTIONS.map(r=>`<button type="button" class="ithWallReaction397" data-wall-reaction397="${esc(r[0])}" title="${esc(r[1])}"><span>${r[0]}</span><b>0</b></button>`).join('')}</div><div class="ithWallFoot397"><button type="button" data-wall-report397>⚑ Αναφορά</button></div></article>`}
  async function hydrateWallReactions(ids){if(!ids.length)return;try{const d=await request('/api/v411/wall/reactions?room_id='+encodeURIComponent(room())+'&post_ids='+encodeURIComponent(ids.join(','))+'&device_id='+encodeURIComponent(device()));if($('ithWallLive397'))$('ithWallLive397').textContent=String(Number(d.live_now||0));(d.items||[]).forEach(item=>applyWallReaction(item))}catch(e){}}
  function applyWallReaction(item){const safe=String(item.post_id||'').replace(/\\/g,'\\\\').replace(/"/g,'\\"');const card=document.querySelector('[data-wall-post397="'+safe+'"]');if(!card)return;const counts=item.counts||{},mine=Array.isArray(item.mine)?item.mine:[];card.querySelectorAll('[data-wall-reaction397]').forEach(b=>{const em=b.dataset.wallReaction397;b.querySelector('b').textContent=String(Number(counts[em]||0));b.classList.toggle('active',mine.includes(em))})}
  async function loadUnifiedWall(keep){const body=$('ithWallBody397'),list=$('ithWallList397');if(!body||!list)return;const top=keep?body.scrollTop:0;let d=null;for(const path of ['/api/wall/list_v249345?room_id='+encodeURIComponent(room())+'&limit=180&_v='+Date.now(),'/api/wall/list_v249344?room_id='+encodeURIComponent(room())+'&limit=180&_v='+Date.now(),'/api/wall/list?room_id='+encodeURIComponent(room())+'&limit=180&_v='+Date.now()]){try{d=await request(path);break}catch(e){}}if(!d){list.innerHTML='<div class="ithWallEmpty397">Ο ενιαίος Τοίχος δεν φορτώθηκε.</div>';return}const posts=Array.isArray(d.posts)?d.posts:(Array.isArray(d.items)?d.items:[]);list.innerHTML=posts.length?posts.map(wallCard).join(''):'<div class="ithWallEmpty397">Ο Τοίχος περιμένει την πρώτη ανώνυμη σκέψη.</div>';if($('ithWallLive397'))$('ithWallLive397').textContent=String(Number(d.live_now||0));if(keep)body.scrollTop=top;await hydrateWallReactions(posts.map(p=>String(p.post_id||p.id||'')).filter(Boolean))}
  async function sendUnifiedWall(){const ta=$('ithWallText397'),btn=$('ithWallSend397'),text=String(ta&&ta.value||'').trim();if(!text)return notify('Γράψε πρώτα τη σκέψη σου.');if(text.length>500)return notify('Το κείμενο είναι πάνω από 500 χαρακτήρες.');btn.disabled=true;let ok=false,last=null;for(const path of ['/api/wall/post_v249345','/api/wall/post_v249344','/api/wall/post']){try{await request(path,{method:'POST',body:JSON.stringify({room_id:room(),owner_token:device(),text})});ok=true;break}catch(e){last=e}}btn.disabled=false;if(!ok)return notify('Δεν στάλθηκε: '+String(last&&last.message||'σφάλμα'));ta.value='';await loadUnifiedWall(false);notify('Η ανώνυμη σκέψη δημοσιεύτηκε.')}
  async function toggleUnifiedReaction(card,button){const id=card.dataset.wallPost397,emoji=button.dataset.wallReaction397;if(!id||!emoji||button.disabled)return;button.disabled=true;try{const d=await request('/api/v411/wall/reaction',{method:'POST',body:JSON.stringify({room_id:room(),post_id:id,device_id:device(),emoji})});applyWallReaction(d);if($('ithWallLive397'))$('ithWallLive397').textContent=String(Number(d.live_now||0))}catch(e){notify('Η αντίδραση δεν καταχωρήθηκε.')}finally{setTimeout(()=>button.disabled=false,220)}}
  async function reportUnifiedWall(card){let ok=false;for(const path of ['/api/wall/report_v249345','/api/wall/report']){try{await request(path,{method:'POST',body:JSON.stringify({room_id:room(),owner_token:device(),post_id:card.dataset.wallPost397,reason:'user_report'})});ok=true;break}catch(e){}}notify(ok?'Η αναφορά καταγράφηκε.':'Η αναφορά δεν στάλθηκε.')}
  function connectUnifiedWall(){try{const base=new URL(location.origin),proto=base.protocol==='https:'?'wss:':'ws:';wallSocket=new WebSocket(proto+'//'+base.host+'/ws/live_v249345');wallSocket.onopen=()=>{const c=$('ithWallConn397');if(c)c.textContent='● Ζωντανή σύνδεση'};wallSocket.onmessage=e=>{try{const m=JSON.parse(e.data);if(String(m.type||'').startsWith('wall_')){clearTimeout(wallRefreshTimer);wallRefreshTimer=setTimeout(()=>loadUnifiedWall(true),100)}}catch(_){}}}catch(e){}}
  function openUnifiedWall(){closeUnifiedWall();document.querySelectorAll('#ithWall357,#v411Overlay,#v411WallRoot,.v411Overlay').forEach(x=>x.remove());const root=document.createElement('div');root.id='ithUnifiedWall397';root.innerHTML=`<header class="ithWallTop397"><button type="button" id="ithWallBack397">‹</button><div><h2>🧱 Ενιαίος Τοίχος ΙΘΑΚΗΣ</h2><small>Ο Τοίχος της Αρχικής με τις ζωντανές αντιδράσεις V411</small></div><button type="button" id="ithWallReload397">↻</button></header><main id="ithWallBody397" class="ithWallBody397"><section class="ithWallHero397"><span id="ithWallConn397">● Σύνδεση…</span><span>Ζωντανά τώρα: <b id="ithWallLive397">0</b></span></section><div id="ithWallList397" class="ithWallList397"><div class="ithWallEmpty397">Φόρτωση…</div></div></main><footer class="ithWallComposer397"><textarea id="ithWallText397" maxlength="500" placeholder="Γράψε ανώνυμα τη σκέψη σου…"></textarea><button type="button" id="ithWallSend397">➤</button></footer>`;document.body.appendChild(root);$('ithWallBack397').onclick=closeUnifiedWall;$('ithWallReload397').onclick=()=>loadUnifiedWall(true);$('ithWallSend397').onclick=sendUnifiedWall;$('ithWallList397').onclick=e=>{const card=e.target.closest('[data-wall-post397]');if(!card)return;const react=e.target.closest('[data-wall-reaction397]');if(react)return toggleUnifiedReaction(card,react);if(e.target.closest('[data-wall-report397]'))return reportUnifiedWall(card)};document.addEventListener('keydown',wallEscape397);loadUnifiedWall(false);connectUnifiedWall();return false}
  function bindWallAliases(){window.ITH=window.ITH||{};['openWallV249357','openAnonymousWallV249357','openZeroSupportWallV249270','openAnonymousWallV249283','openAnonymousWallV249342','openAnonymousWallV249346','openWallV249339','openWallV249342','openWallV249346','openV411LiveWall'].forEach(k=>ITH[k]=openUnifiedWall);ITH.openUnifiedWallV249397=openUnifiedWall;window.openWallV249357=openUnifiedWall}
  function captureWallClick(e){const b=e.target&&e.target.closest&&e.target.closest('button,a');if(!b||b.closest('#ithUnifiedWall397')||b.closest('#ithLexicon357'))return;const id=String(b.id||''),tool=String(b.getAttribute('data-pro-tool383')||''),txt=((b.textContent||'')+' '+(b.title||'')+' '+(b.getAttribute('aria-label')||'')).toLowerCase();if(tool==='v411'||id==='ithWallHome397'||txt.includes('ζωντανός τοίχος')||txt.includes('πραγματικός τοίχος')||txt.includes('ανώνυμος τοίχος')||txt.includes('🧱 τοίχος')||txt.trim()==='τοίχος'){e.preventDefault();e.stopPropagation();e.stopImmediatePropagation();openUnifiedWall()}}

  function removeProfessionalPublishing413(){
    ['ithPublicationWorkspace387','ithPreviewDestination387','ithPublicationTool388','ithPublicationTool387'].forEach(id=>{const x=$(id);if(x)x.remove()});
    const v410=document.querySelector('[data-pro-tool383="v410"]');if(v410)v410.remove();
    document.documentElement.setAttribute('data-ithaki-professional-publishing','removed-v249413');
    return false
  }
  function install(){injectCss();bindSecurityEntry();bindWallAliases();removeProfessionalWall();removeProfessionalPublishing413();window.addEventListener('click',captureWallClick,true);let t=0;const ob=new MutationObserver(list=>{if(!list.some(m=>m.addedNodes&&m.addedNodes.length))return;clearTimeout(t);t=setTimeout(()=>{bindSecurityEntry();removeProfessionalWall();removeProfessionalPublishing413()},180)});ob.observe(document.documentElement,{childList:true,subtree:true});setInterval(()=>{bindSecurityEntry();removeProfessionalWall();removeProfessionalPublishing413();bindWallAliases()},5000);document.documentElement.setAttribute('data-ithaki-professional-flow',BUILD);document.documentElement.setAttribute('data-ithaki-wall','one-unified-home-v411');document.documentElement.setAttribute('data-ithaki-security-selector','visible-in-dm');document.documentElement.setAttribute('data-ithaki-preview','professional-preview-removed-v249413')}

  if(document.readyState==='loading')document.addEventListener('DOMContentLoaded',install,{once:true});else install();
})();
