/* OK ITHAKI V249526R10F8 — LEXICON 1 / ENGLISH REFERENCE / ARGOS / UNKNOWN WORDS */
(()=>{'use strict';
if(window.__ITHAKI_LEXICON1_R10F8__)return;
window.__ITHAKI_LEXICON1_R10F8__={version:'V249526R10F8',englishReference:true,argosPairs:true,unknownLearning:true,mobile:true};
window.LEXICON1_ENGLISH_REFERENCE_R10F8=true;
window.ARGOS_REFERENCE_PAIR_MANAGER_R10F8=true;
window.UNKNOWN_WORD_COMPLETION_R10F8=true;
window.LEXICON1_MOBILE_UI_R10F8=true;
window.LEXICON_OLD_PLUS_NEW_MOBILE_R10F17=true;
window.LEXICON_UNKNOWN_FIRST_IMMEDIATE_R10F21=true;
window.LEXICON_QUICK_CORRECTION_R10F17=true;
const BTN='ithRedBook374', MODAL='ithLexicon1R10F8';
const $=id=>document.getElementById(id);
const esc=s=>String(s??'').replace(/[&<>"']/g,c=>({'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;',"'":'&#39;'}[c]));
const LANGS=[
 ['el','Ελληνικά','🇬🇷'],['en','English','🇬🇧']
];
const LM=Object.fromEntries(LANGS.map(x=>[x[0],{code:x[0],name:x[1],flag:x[2]}]));
const T={
 el:{title:'Λεξικό 1',sub:'Παλιό Λεξικό + νέα εργαλεία · Ελληνικά ↔ Αγγλικά',translator:'Μετάφραση',unknown:'Άγνωστες λέξεις',learned:'Αποθηκευμένες',models:'Argos μοντέλα',settings:'Ρυθμίσεις',other:'Άλλη γλώσσα',direction:'Κατεύθυνση',toEnglish:'Προς Αγγλικά',fromEnglish:'Από Αγγλικά',translate:'Μετάφραση',install:'Εγκατάσταση offline ζεύγους',ready:'Offline ζεύγος έτοιμο',missing:'Το offline ζεύγος δεν είναι εγκατεστημένο',loading:'Φόρτωση…',source:'Κείμενο',result:'Αποτέλεσμα',save:'Αποθήκευση',correction:'Σωστή μετάφραση',word:'Λέξη',phrase:'Φράση',none:'Δεν υπάρχουν καταχωρίσεις.',auto:'Αυτόματη μετάφραση μηνυμάτων και αναρτήσεων',autoSub:'Όταν είναι κλειστή, τα κείμενα μένουν στο πρωτότυπο και χρησιμοποιείς το Λεξικό 1 χειροκίνητα.',appLanguage:'Γλώσσα εφαρμογής',changeApp:'Αλλαγή γλώσσας εφαρμογής',reference:'Η μετάφραση και το προσωπικό λεξικό λειτουργούν μόνο Ελληνικά ↔ Αγγλικά.',unknownNote:'Λέξεις που το Argos αφήνει αμετάφραστες καταγράφονται εδώ και, μόλις διορθωθούν, χρησιμοποιούνται αυτόματα.',installing:'Εγκατάσταση Argos και μοντέλων… Μην κλείσεις την οθόνη.',installed:'Το offline ζεύγος εγκαταστάθηκε.',notAvailable:'Δεν υπάρχει διαθέσιμο Argos ζεύγος για αυτή τη γλώσσα. Το προσωπικό λεξικό και ο εξωτερικός πάροχος παραμένουν διαθέσιμα.',originalKept:'Δεν βρέθηκε πλήρης μετάφραση. Το πρωτότυπο διατηρήθηκε και η άγνωστη λέξη καταγράφηκε.'},
 en:{title:'Lexicon 1',sub:'Classic dictionary + new tools · Greek ↔ English',translator:'Translate',unknown:'Unknown words',learned:'Saved words',models:'Argos models',settings:'Settings',other:'Other language',direction:'Direction',toEnglish:'To English',fromEnglish:'From English',translate:'Translate',install:'Install offline pair',ready:'Offline pair ready',missing:'Offline pair is not installed',loading:'Loading…',source:'Text',result:'Result',save:'Save',correction:'Correct translation',word:'Word',phrase:'Phrase',none:'No entries.',auto:'Automatically translate messages and posts',autoSub:'When disabled, content stays original and you use Lexicon 1 manually.',appLanguage:'App language',changeApp:'Change app language',reference:'Translation and the personal dictionary work only between Greek and English.',unknownNote:'Words left untranslated by Argos are collected here. Once corrected, they are reused automatically.',installing:'Installing Argos and models… Keep this screen open.',installed:'The offline pair was installed.',notAvailable:'No Argos pair is available for this language. The personal dictionary and external provider remain available.',originalKept:'No complete translation was found. The original was kept and the unknown word was logged.'}
};
let tab='unknown', query='', installing=false;
window.LEXICON1_BENEFACTORS_DOWNLOAD_R10F9=true;
window.LEXICON1_PUBLIC_CREDIT_R10F9=true;
function appLang(){return String(localStorage.getItem('ith_global_language_r10f7')||localStorage.getItem('ith_ui_lang_v249141')||'el').toLowerCase().split('-')[0]}
function ui(){return appLang()==='el'?'el':'en'}
function t(k){return (T[ui()]||T.en)[k]||T.en[k]||k}
function otherLang(){let c=String(localStorage.getItem('ith_lexicon1_other_language_r10f8')||appLang()||'el').toLowerCase();if(c==='en'||!LM[c])c='el';return c}
function direction(){return localStorage.getItem('ith_lexicon1_direction_r10f8')==='from_en'?'from_en':'to_en'}
function pair(){const o=otherLang(),d=direction();return d==='to_en'?{src:o,dst:'en'}:{src:'en',dst:o}}
function apiBase(){let b=String(window.state?.api||window.ITH?.state?.api||'').replace(/\/+$/,'');if(!b||/appassets\.androidplatform\.net/i.test(b))b='https://ok-ithaki.gr';return b}
async function api(path,opt={}){const r=await fetch(/^https?:/i.test(path)?path:apiBase()+path,{cache:'no-store',credentials:'include',headers:{'Content-Type':'application/json',...(opt.headers||{})},...opt});let d={};try{d=await r.json()}catch(_e){throw new Error('Invalid server response')};if(!r.ok||d.ok===false)throw new Error(d.note||d.detail||`HTTP ${r.status}`);return d}
function toast(msg){try{if(window.ITH?.toast)return ITH.toast(msg,5200)}catch(_e){}let e=$('ithLexToastR10F8');if(!e){e=document.createElement('div');e.id='ithLexToastR10F8';e.className='ithLexToastR10F8';document.body.appendChild(e)}e.textContent=msg;e.classList.add('show');clearTimeout(e._x);e._x=setTimeout(()=>e.classList.remove('show'),4200)}
function identity(){return{id:String(window.state?.device||localStorage.getItem('ithaki_device_id')||localStorage.getItem('device_id')||''),name:String(window.state?.name||localStorage.getItem('ith_name')||'Member'),avatar:String(window.state?.avatar||localStorage.getItem('ith_avatar')||'')}}
function close(){const e=$(MODAL);if(e)e.remove();document.removeEventListener('keydown',key);ensureButton()}
function key(e){if(e.key==='Escape')close()}
function cleanDuplicates(){document.querySelectorAll('#lexiconHome357,[id^="lexiconTop"],button,a').forEach(e=>{if(e.id===BTN||e.closest('#'+MODAL))return;const s=((e.textContent||'')+' '+(e.title||'')+' '+(e.getAttribute('aria-label')||'')).toLowerCase();if(/λεξικ|dictionary|translation book|βιβλίο μετάφρασης/.test(s)){e.style.setProperty('display','none','important');e.setAttribute('aria-hidden','true')}})}
function ensureButton(){let b=$(BTN);if(!b){b=document.createElement('button');b.id=BTN;b.type='button';b.innerHTML='<span>📕</span><small>1</small>';b.title=t('title');b.setAttribute('aria-label',t('title'));const h=document.querySelector('header.top,.top');const logo=h?.querySelector('.logoText');if(logo)logo.insertAdjacentElement('afterend',b);else if(h)h.prepend(b);else document.body.appendChild(b)}b.style.display=(document.getElementById('homePage')?.classList.contains('active')&&!$(MODAL))?'grid':'none';cleanDuplicates();return b}
function options(selected){return LANGS.filter(x=>x[0]!=='en').map(([c,n,f])=>`<option value="${c}"${c===selected?' selected':''}>${f} ${esc(n)}</option>`).join('')}
function modelBadge(status){const ready=!!status?.pair_ready;return `<div class="lexModelBadge ${ready?'ready':'missing'}"><b>${ready?'✓ '+t('ready'):'⚠ '+t('missing')}</b><small>English ↔ ${esc(LM[otherLang()]?.name||otherLang())}</small>${ready?'':`<button type="button" data-install-model>${t('install')}</button>`}</div>`}
function shell(){close();const e=document.createElement('section');e.id=MODAL;e.innerHTML=`<header class="lexR8Top"><button type="button" data-close>‹</button><div><h1>📕 ${t('title')} · Classic+</h1><small>${t('sub')}</small></div><button type="button" data-close>×</button></header><main class="lexR8Wrap"><section class="lexR8Hero"><div class="book">📕<small>1</small></div><div><b>${t('reference')}</b><p>${t('unknownNote')}</p></div></section><nav class="lexR8Tabs"><button data-tab="unknown">❓ ${t('unknown')}</button><button data-tab="learned">✓ ${t('learned')}</button><button data-tab="translator">🌐 ${t('translator')}</button><button data-tab="models">⬇ ${t('models')}</button><button data-tab="benefactors">🏅 Ευεργέτες</button><button data-tab="download">⬇ Λήψη</button><button data-tab="settings">⚙ ${t('settings')}</button></nav><div id="lexR8Content"></div></main>`;document.body.appendChild(e);e.querySelectorAll('[data-close]').forEach(b=>b.onclick=close);e.querySelectorAll('[data-tab]').forEach(b=>b.onclick=()=>switchTab(b.dataset.tab));document.addEventListener('keydown',key);switchTab(tab)}
function switchTab(next){tab=next;document.querySelectorAll('#'+MODAL+' [data-tab]').forEach(b=>b.classList.toggle('on',b.dataset.tab===tab));if(tab==='translator')renderTranslator();else if(tab==='unknown')loadEntries('pending');else if(tab==='learned')loadEntries('translated');else if(tab==='models')renderModels();else if(tab==='benefactors')renderBenefactors();else if(tab==='download')renderDownloads();else renderSettings()}
async function renderTranslator(){const c=$('lexR8Content');c.innerHTML=`<div class="lexR8Loading">${t('loading')}</div>`;let status={};try{status=await api('/api/argos/reference/status_v249526r10f8?language='+encodeURIComponent(otherLang()))}catch(_e){}const p=pair();c.innerHTML=`<section class="lexTranslator">${modelBadge(status)}<div class="lexPairPicker"><label><span>${t('other')}</span><select id="lexR8Other">${options(otherLang())}</select></label><label><span>${t('direction')}</span><select id="lexR8Direction"><option value="to_en"${direction()==='to_en'?' selected':''}>${t('toEnglish')}</option><option value="from_en"${direction()==='from_en'?' selected':''}>${t('fromEnglish')}</option></select></label></div><div class="lexRoute"><b>${esc((LM[p.src]||{}).flag||'🌐')} ${esc((LM[p.src]||{}).name||p.src)}</b><span>→</span><b>${esc((LM[p.dst]||{}).flag||'🌐')} ${esc((LM[p.dst]||{}).name||p.dst)}</b></div><textarea id="lexR8Input" rows="6" placeholder="${t('source')}"></textarea><button class="lexPrimary" id="lexR8Translate" type="button">🌐 ${t('translate')}</button><textarea id="lexR8Output" rows="6" placeholder="${t('result')}"></textarea><div id="lexR8Provider" class="lexProvider"></div><section class="lexLegacyQuickR10F17"><h3>🛠️ ${ui()==='el'?'Παλιό Λεξικό · διόρθωση άγνωστης λέξης':'Classic dictionary · correct an unknown word'}</h3><p>${ui()==='el'?'Διόρθωσε λέξη ή φράση που δεν μετέφρασε σωστά το Argos. Η διόρθωση περνά αμέσως στο βοηθητικό λεξικό.':'Correct a word or phrase Argos did not translate correctly. The correction is immediately added to the helper dictionary.'}</p><div class="lexLegacyQuickGridR10F17"><label><span>${ui()==='el'?'Λέξη / φράση':'Word / phrase'}</span><input id="lexR17Source" value=""></label><label><span>${ui()==='el'?'Σωστή μετάφραση':'Correct translation'}</span><input id="lexR17Target" value=""></label><label><span>${ui()==='el'?'Τύπος':'Type'}</span><select id="lexR17Kind"><option value="word">${t('word')}</option><option value="phrase">${t('phrase')}</option></select></label><label><span>${ui()==='el'?'Κατεύθυνση':'Direction'}</span><input value="${esc(p.src.toUpperCase()+' → '+p.dst.toUpperCase())}" readonly></label></div><div class="lexLegacyQuickActionsR10F17"><label><input id="lexR17Credit" type="checkbox"> 🏅 ${ui()==='el'?'Δημόσια αναφορά στους Ευεργέτες':'Public Benefactor credit'}</label><button id="lexR17Save" type="button">💾 ${ui()==='el'?'Ενημέρωση Λεξικού':'Update dictionary'}</button></div></section></section>`;c.querySelector('#lexR8Other').onchange=e=>{localStorage.setItem('ith_lexicon1_other_language_r10f8',e.target.value);renderTranslator()};c.querySelector('#lexR8Direction').onchange=e=>{localStorage.setItem('ith_lexicon1_direction_r10f8',e.target.value);renderTranslator()};c.querySelector('[data-install-model]')?.addEventListener('click',installModel);c.querySelector('#lexR8Translate').onclick=translateNow;c.querySelector('#lexR17Save').onclick=saveQuickCorrectionR10F17}
async function saveQuickCorrectionR10F17(){const src=String($('lexR17Source')?.value||$('lexR8Input')?.value||'').trim(),target=String($('lexR17Target')?.value||$('lexR8Output')?.value||'').trim(),p=pair();if(!src||!target)return toast(ui()==='el'?'Χρειάζεται λέξη/φράση και σωστή μετάφραση.':'Enter a word/phrase and the correct translation.');const who=identity();try{const d=await api('/api/lexicon/v249374/save',{method:'POST',body:JSON.stringify({source:src,target,src_lang:p.src,dst_lang:p.dst,kind:$('lexR17Kind')?.value||'word',context:'lexicon1-mobile-r10f17',editor_id:who.id,editor_name:who.name,editor_avatar:who.avatar,public_credit:!!$('lexR17Credit')?.checked,notes:'classic-plus-mobile-r10f17'})});toast(d.note||(ui()==='el'?'Το Λεξικό ενημερώθηκε.':'Dictionary updated.'));$('lexR17Source').value='';$('lexR17Target').value=''}catch(e){toast(e.message)}}
async function translateNow(){const input=$('lexR8Input'),out=$('lexR8Output'),meta=$('lexR8Provider'),text=input.value.trim();if(!text)return;const p=pair();out.value='';meta.textContent=t('loading');try{const d=await api('/api/bridge/translate/reference_v249526r10f8',{method:'POST',body:JSON.stringify({text,source_lang:p.src,target_lang:p.dst,log_unknown:true})});out.value=d.translated||text;const qs=$('lexR17Source'),qt=$('lexR17Target');if(qs)qs.value=text;if(qt)qt.value=d.translated||'';meta.textContent=`${(d.route||[p.src,p.dst]).join(' → ')} · ${d.provider||'Lexicon 1'}`+(d.unknown_terms_added?` · +${d.unknown_terms_added} ${t('unknown')}`:'');if((d.translated||'').trim()===text.trim()&&p.src!==p.dst)toast(t('originalKept'))}catch(e){out.value=text;meta.textContent=e.message}}
async function installModel(){if(installing)return;installing=true;toast(t('installing'));const b=document.querySelector('#'+MODAL+' [data-install-model]');if(b){b.disabled=true;b.textContent=t('loading')}try{const d=await api('/api/argos/reference/install_v249526r10f8',{method:'POST',body:JSON.stringify({language:otherLang(),install_runtime:true})});toast(d.pair_ready?t('installed'):(d.note||t('notAvailable')))}catch(e){toast(e.message)}finally{installing=false;renderTranslator()}}
async function saveImmediateUnknownR10F21(){const source=String($('lexR21UnknownSource')?.value||'').trim(),target=String($('lexR21UnknownTarget')?.value||'').trim(),p=pair();if(!source||!target)return toast(ui()==='el'?'Συμπλήρωσε την άγνωστη λέξη και τη σωστή μετάφραση.':'Enter the unknown word and the correct translation.');const who=identity();try{await api('/api/lexicon/v249374/save',{method:'POST',body:JSON.stringify({source,target,src_lang:p.src,dst_lang:p.dst,kind:$('lexR21UnknownKind')?.value||'word',context:'lexicon1-unknown-first-r10f21',editor_id:who.id,editor_name:who.name,editor_avatar:who.avatar,public_credit:!!$('lexR21UnknownCredit')?.checked,notes:'unknown-first-immediate-r10f21'})});toast(ui()==='el'?'Η λέξη αποθηκεύτηκε και θα χρησιμοποιείται άμεσα.':'The word was saved and will be reused immediately.');query='';await loadEntries('pending')}catch(e){toast(e.message)}}
function immediateUnknownCardR10F21(){const p=pair();return `<section class="lexUnknownFirstR10F21"><h2>❓ ${ui()==='el'?'Άγνωστες λέξεις · άμεση συμπλήρωση':'Unknown words · immediate completion'}</h2><p>${ui()==='el'?'Πρώτα βλέπεις ό,τι δεν μετέφρασε το Argos. Μπορείς να γράψεις αμέσως τη σωστή μετάφραση και το Λεξικό ενημερώνεται.':'First you see what Argos could not translate. Add the correct translation immediately and the dictionary updates.'}</p><div class="lexUnknownFirstGridR10F21"><label><span>${t('word')} / ${t('phrase')}</span><input id="lexR21UnknownSource" placeholder="${t('word')}"></label><label><span>${t('correction')}</span><input id="lexR21UnknownTarget" placeholder="${t('correction')}"></label><label><span>${t('direction')}</span><input value="${esc(p.src.toUpperCase()+' → '+p.dst.toUpperCase())}" readonly></label><label><span>${ui()==='el'?'Τύπος':'Type'}</span><select id="lexR21UnknownKind"><option value="word">${t('word')}</option><option value="phrase">${t('phrase')}</option></select></label></div><label class="lexPublicCredit"><input id="lexR21UnknownCredit" type="checkbox"> <span>🏅 ${ui()==='el'?'Δημόσια αναφορά στους Ευεργέτες':'Public Benefactor credit'}</span></label><button class="lexPrimary" id="lexR21UnknownSave" type="button">💾 ${ui()==='el'?'Άμεση ενημέρωση Λεξικού':'Update dictionary now'}</button></section>`}
async function loadEntries(status){const c=$('lexR8Content');c.innerHTML=`<div class="lexR8Loading">${t('loading')}</div>`;try{const d=await api(`/api/lexicon/v249374/entries?status=${status}&q=${encodeURIComponent(query)}&limit=200&_=${Date.now()}`);const selected=otherLang();const rows=(d.items||[]).filter(x=>{const a=String(x.src_lang||''),b=String(x.dst_lang||'');return (a===selected&&b==='en')||(a==='en'&&b===selected)});c.innerHTML=`${status==='pending'?immediateUnknownCardR10F21():''}<div class="lexSearch"><input id="lexR8Search" value="${esc(query)}" placeholder="${t('unknown')}"><button type="button" id="lexR8Refresh">↻</button></div><div class="lexEntries">${rows.length?rows.map(entryCard).join(''):`<div class="lexR8Empty">${t('none')}</div>`}</div>`;c.querySelector('#lexR21UnknownSave')?.addEventListener('click',saveImmediateUnknownR10F21);c.querySelector('#lexR8Search').oninput=e=>{query=e.target.value;clearTimeout(e.target._t);e.target._t=setTimeout(()=>loadEntries(status),300)};c.querySelector('#lexR8Refresh').onclick=()=>loadEntries(status);wireEntries(status)}catch(e){c.innerHTML=`<div class="lexR8Empty">${esc(e.message)}</div>`}}
function entryCard(x){const done=x.status==='translated';return `<article class="lexEntry" data-key="${esc(x.entry_key)}" data-src="${esc(x.src_lang)}" data-dst="${esc(x.dst_lang)}" data-source="${esc(x.source)}"><header><b>${esc(x.source)}</b><span>${esc(String(x.src_lang).toUpperCase())} → ${esc(String(x.dst_lang).toUpperCase())}</span></header>${x.context?`<p>${esc(x.context)}</p>`:''}${done?`<div class="lexSaved">✓ ${esc(x.current_target||'')}</div>`:''}<div class="lexCorrection"><input data-target value="${esc(x.current_target||'')}" placeholder="${t('correction')}"><select data-kind><option value="word"${x.kind==='word'?' selected':''}>${t('word')}</option><option value="phrase"${x.kind==='phrase'?' selected':''}>${t('phrase')}</option></select><button type="button" data-save>💾 ${t('save')}</button></div><label class="lexPublicCredit"><input type="checkbox" data-credit> <span>🏅 Δημόσια αναφορά στους Ευεργέτες</span></label></article>`}
function wireEntries(status){document.querySelectorAll('#'+MODAL+' .lexEntry').forEach(el=>{el.querySelector('[data-save]').onclick=async()=>{const target=el.querySelector('[data-target]').value.trim();if(!target)return;const id=identity();try{await api('/api/lexicon/v249374/save',{method:'POST',body:JSON.stringify({entry_key:el.dataset.key,source:el.dataset.source,target,src_lang:el.dataset.src,dst_lang:el.dataset.dst,kind:el.querySelector('[data-kind]').value,editor_id:id.id,editor_name:id.name,editor_avatar:id.avatar,public_credit:!!el.querySelector('[data-credit]')?.checked})});toast(t('save'));loadEntries(status)}catch(e){toast(e.message)}}})}
async function renderModels(){const c=$('lexR8Content');c.innerHTML=`<div class="lexR8Loading">${t('loading')}</div>`;try{const d=await api('/api/lexicon/v249526r10f8/languages?_='+Date.now());const by=Object.fromEntries((d.items||[]).map(x=>[x.code,x]));c.innerHTML=`<section class="lexModels"><div class="lexModelSummary"><b>English reference</b><span>${d.status?.installed?'Argos runtime ✓':'Argos runtime —'}</span><small>${esc(d.status?.package_dir||'')}</small></div><div class="lexModelGrid">${LANGS.filter(x=>x[0]!=='en').map(([code,name,flag])=>{const x=by[code]||{};return `<button type="button" data-model-lang="${code}" class="${x.pair_ready?'ready':''}"><span>${flag}</span><b>${esc(name)}</b><small>${x.pair_ready?'✓ offline':'⬇ install'}</small></button>`}).join('')}</div></section>`;c.querySelectorAll('[data-model-lang]').forEach(b=>b.onclick=()=>{localStorage.setItem('ith_lexicon1_other_language_r10f8',b.dataset.modelLang);installModel()})}catch(e){c.innerHTML=`<div class="lexR8Empty">${esc(e.message)}</div>`}}

async function renderBenefactors(){const c=$('lexR8Content');c.innerHTML=`<div class="lexR8Loading">${t('loading')}</div>`;try{const d=await api('/api/lexicon/v249374/contributors?limit=200&_='+Date.now());const rows=d.items||d.contributors||[];c.innerHTML=`<section class="lexBenefactors"><div class="lexInfo"><b>🏅 Ευεργέτες του Λεξικού</b><p>Εμφανίζονται μόνο όσοι επέλεξαν δημόσια αναφορά όταν διόρθωσαν άγνωστες λέξεις.</p></div>${rows.length?rows.map((x,i)=>`<article class="lexBenefactor"><b>${i+1}. ${esc(x.editor_name||x.name||'Ανώνυμος')}</b><span>${Number(x.contributions||x.count||0)} διορθώσεις</span></article>`).join(''):`<div class="lexR8Empty">Δεν υπάρχουν ακόμη δημόσιοι Ευεργέτες.</div>`}</section>`}catch(e){c.innerHTML=`<div class="lexR8Empty">${esc(e.message)}</div>`}}
function downloadUrl(url,name){const a=document.createElement('a');a.href=url;a.download=name||'';a.rel='noopener';document.body.appendChild(a);a.click();a.remove()}
async function downloadJson(){try{const pending=await api('/api/lexicon/v249374/entries?status=pending&limit=1000'),translated=await api('/api/lexicon/v249374/entries?status=translated&limit=5000'),contributors=await api('/api/lexicon/v249374/contributors?limit=500');const blob=new Blob([JSON.stringify({version:'V249526R10F9',exported_at:new Date().toISOString(),pending:pending.items||[],translated:translated.items||[],benefactors:contributors.items||contributors.contributors||[]},null,2)],{type:'application/json'});const u=URL.createObjectURL(blob);downloadUrl(u,'OK_ITHAKI_LEXICON1_'+new Date().toISOString().slice(0,10)+'.json');setTimeout(()=>URL.revokeObjectURL(u),2000)}catch(e){toast(e.message)}}
function renderDownloads(){const c=$('lexR8Content');c.innerHTML=`<section class="lexDownloads"><div class="lexInfo"><b>⬇ Λήψη Λεξικού 1</b><p>Κατέβασε τις διορθωμένες και άγνωστες λέξεις για προσωπικό αντίγραφο ή μεταφορά.</p></div><button class="lexPrimary" id="lexDownloadCsv">📄 Λήψη CSV</button><button class="lexPrimary" id="lexDownloadJson">🧾 Λήψη πλήρους JSON</button></section>`;c.querySelector('#lexDownloadCsv').onclick=()=>downloadUrl('/api/lexicon/v249374/export.csv','OK_ITHAKI_LEXICON1.csv');c.querySelector('#lexDownloadJson').onclick=downloadJson}

function renderSettings(){const c=$('lexR8Content'),auto=localStorage.getItem('ith_auto_translate_content_r10f8')!=='0',m=LM[appLang()]||LM.el;c.innerHTML=`<section class="lexSettings"><label class="lexToggle"><input id="lexR8Auto" type="checkbox"${auto?' checked':''}><span><b>${t('auto')}</b><small>${t('autoSub')}</small></span></label><div class="lexAppLanguage"><div><b>${t('appLanguage')}</b><small>${m.flag} ${esc(m.name)}</small></div><button type="button" id="lexR8AppLanguage">🌍 ${t('changeApp')}</button></div><div class="lexInfo">${t('reference')}</div></section>`;c.querySelector('#lexR8Auto').onchange=e=>{localStorage.setItem('ith_auto_translate_content_r10f8',e.target.checked?'1':'0');document.dispatchEvent(new CustomEvent('ithaki:auto-content-translation-changed',{detail:{enabled:e.target.checked}}));toast(e.target.checked?t('auto'):t('autoSub'))};c.querySelector('#lexR8AppLanguage').onclick=()=>{close();if(window.ITH?.openGlobalLanguageR10F7)ITH.openGlobalLanguageR10F7();else document.getElementById('ith537TopLanguage')?.click()}}
function style(){if($('ithLexiconR10F8Style'))return;const s=document.createElement('style');s.id='ithLexiconR10F8Style';s.textContent=`
#${BTN}{position:relative!important;width:42px!important;height:42px!important;min-width:42px!important;display:grid;place-items:center;border-radius:14px!important;background:linear-gradient(145deg,color-mix(in srgb,var(--gold,#f5c451) 28%,var(--panel,#0b2030)),color-mix(in srgb,var(--accent,#55d7ff) 13%,var(--panel,#0b2030)))!important;border:1px solid color-mix(in srgb,var(--gold,#f5c451) 58%,var(--line,#29485a))!important;color:var(--text,#fff)!important;font-size:22px!important;box-shadow:0 8px 24px rgba(0,0,0,.25)!important;margin-left:6px!important;z-index:2147481000!important}#${BTN} small{position:absolute;right:3px;bottom:1px;font-size:9px;color:var(--gold,#f5c451)}
#${MODAL}{position:fixed;inset:0;z-index:2147483500;background:var(--bg,#06131e);color:var(--text,#fff);overflow:auto;padding-bottom:max(30px,env(safe-area-inset-bottom));font-family:system-ui,-apple-system,Segoe UI,Roboto,sans-serif}#${MODAL} *{box-sizing:border-box}.lexR8Top{position:sticky;top:0;z-index:8;min-height:64px;display:grid;grid-template-columns:46px 1fr 46px;align-items:center;gap:8px;padding:max(8px,env(safe-area-inset-top)) 9px 8px;background:color-mix(in srgb,var(--panel,#0b2030) 92%,transparent);border-bottom:1px solid var(--line,#29485a);backdrop-filter:blur(18px)}.lexR8Top button{height:43px;border-radius:14px}.lexR8Top h1{margin:0;color:var(--gold,#f5c451);font-size:18px;text-align:center}.lexR8Top small{display:block;text-align:center;color:var(--muted,#a9bfcc);font-size:10px}.lexR8Wrap{width:min(980px,calc(100vw - 16px));margin:10px auto;display:grid;gap:10px}.lexR8Hero{display:grid;grid-template-columns:66px 1fr;gap:12px;align-items:center;padding:14px;border-radius:22px;background:linear-gradient(145deg,color-mix(in srgb,var(--gold,#f5c451) 12%,var(--panel,#0b2030)),var(--panel,#0b2030));border:1px solid color-mix(in srgb,var(--gold,#f5c451) 35%,var(--line,#29485a))}.lexR8Hero .book{position:relative;width:62px;height:62px;border-radius:19px;display:grid;place-items:center;font-size:38px;background:color-mix(in srgb,var(--gold,#f5c451) 22%,var(--bg,#06131e))}.lexR8Hero .book small{position:absolute;right:7px;bottom:3px;font-size:11px}.lexR8Hero b{color:var(--gold,#f5c451)}.lexR8Hero p{margin:5px 0 0;color:var(--muted,#a9bfcc);font-size:12px}.lexR8Tabs{display:flex;gap:7px;overflow:auto;scrollbar-width:none;padding:2px}.lexR8Tabs::-webkit-scrollbar{display:none}.lexR8Tabs button{flex:0 0 auto;min-height:41px;border-radius:999px;padding:0 14px;background:color-mix(in srgb,var(--panel,#0b2030) 92%,#fff 8%);border:1px solid var(--line,#29485a);color:var(--text,#fff);font-weight:850}.lexR8Tabs button.on{background:color-mix(in srgb,var(--accent,#55d7ff) 20%,var(--panel,#0b2030));border-color:var(--accent,#55d7ff)}#lexR8Content{display:grid;gap:10px}.lexTranslator,.lexSettings,.lexModels{display:grid;gap:10px}.lexModelBadge{display:flex;align-items:center;gap:10px;flex-wrap:wrap;padding:12px;border-radius:18px;border:1px solid var(--line,#29485a);background:var(--panel,#0b2030)}.lexModelBadge.ready{border-color:var(--green,#36f0a0)}.lexModelBadge.missing{border-color:#ffb24d}.lexModelBadge b{flex:1 1 220px}.lexModelBadge small{color:var(--muted,#a9bfcc)}.lexModelBadge button{margin-left:auto}.lexPairPicker{display:grid;grid-template-columns:1fr 1fr;gap:9px}.lexPairPicker label{display:grid;gap:5px}.lexPairPicker span{font-size:11px;color:var(--muted,#a9bfcc);font-weight:850}.lexPairPicker select,.lexTranslator textarea,.lexSearch input,.lexCorrection input,.lexCorrection select{width:100%;background:color-mix(in srgb,var(--panel,#0b2030) 90%,#000 10%);color:var(--text,#fff);border:1px solid var(--line,#29485a);border-radius:15px;padding:12px;font:inherit}.lexTranslator textarea{resize:vertical;min-height:120px}.lexRoute{display:grid;grid-template-columns:1fr auto 1fr;gap:9px;align-items:center;text-align:center;padding:10px;border-radius:17px;background:color-mix(in srgb,var(--accent,#55d7ff) 8%,var(--panel,#0b2030));border:1px solid var(--line,#29485a)}.lexPrimary{min-height:48px;border-radius:16px;background:color-mix(in srgb,var(--green,#36f0a0) 22%,var(--panel,#0b2030));border:1px solid var(--green,#36f0a0);font-weight:950}.lexProvider{font-size:11px;color:var(--muted,#a9bfcc);overflow-wrap:anywhere}.lexSearch{display:grid;grid-template-columns:1fr 46px;gap:8px}.lexEntries{display:grid;gap:9px}.lexEntry{display:grid;gap:8px;padding:12px;border-radius:19px;background:var(--panel,#0b2030);border:1px solid var(--line,#29485a)}.lexEntry header{display:flex;justify-content:space-between;gap:9px}.lexEntry header b{font-size:19px;color:var(--gold,#f5c451);overflow-wrap:anywhere}.lexEntry header span{white-space:nowrap;font-size:10px;color:var(--muted,#a9bfcc)}.lexEntry p{margin:0;color:var(--muted,#a9bfcc);font-size:12px}.lexSaved{color:var(--green,#36f0a0);font-weight:850}.lexCorrection{display:grid;grid-template-columns:1fr 105px auto;gap:7px}.lexCorrection button{border-color:var(--green,#36f0a0)}.lexPublicCredit{display:flex;align-items:center;gap:8px;font-size:12px;color:var(--muted,#a9bfcc)}.lexPublicCredit input{width:20px;height:20px}.lexUnknownFirstR10F21{display:grid;gap:9px;padding:14px;border-radius:21px;background:linear-gradient(145deg,color-mix(in srgb,var(--gold,#f5c451) 16%,var(--panel,#0b2030)),var(--panel,#0b2030));border:1px solid color-mix(in srgb,var(--gold,#f5c451) 50%,var(--line,#29485a));box-shadow:0 12px 30px rgba(0,0,0,.22)}.lexUnknownFirstR10F21 h2{margin:0;color:var(--gold,#f5c451);font-size:18px}.lexUnknownFirstR10F21 p{margin:0;color:var(--muted,#a9bfcc);font-size:12px}.lexUnknownFirstGridR10F21{display:grid;grid-template-columns:1fr 1fr;gap:8px}.lexUnknownFirstGridR10F21 label{display:grid;gap:5px}.lexUnknownFirstGridR10F21 span{font-size:11px;color:var(--muted,#a9bfcc);font-weight:850}.lexUnknownFirstGridR10F21 input,.lexUnknownFirstGridR10F21 select{width:100%;min-height:45px;border-radius:14px;padding:10px;background:color-mix(in srgb,var(--panel,#0b2030) 90%,#000 10%);color:var(--text,#fff);border:1px solid var(--line,#29485a)}.lexBenefactors,.lexDownloads{display:grid;gap:9px}.lexBenefactor{display:flex;justify-content:space-between;gap:12px;padding:13px;border-radius:17px;background:var(--panel,#0b2030);border:1px solid var(--line,#29485a)}.lexBenefactor b{color:var(--gold,#f5c451)}.lexBenefactor span{color:var(--muted,#a9bfcc)}.lexModelSummary,.lexAppLanguage,.lexToggle,.lexInfo{padding:13px;border-radius:18px;background:var(--panel,#0b2030);border:1px solid var(--line,#29485a)}.lexModelSummary{display:grid}.lexModelSummary small{color:var(--muted,#a9bfcc);overflow-wrap:anywhere}.lexModelGrid{display:grid;grid-template-columns:repeat(auto-fit,minmax(145px,1fr));gap:8px}.lexModelGrid button{display:grid;grid-template-columns:auto 1fr;column-gap:8px;align-items:center;text-align:left;padding:10px;border-radius:16px;background:var(--panel,#0b2030);border:1px solid var(--line,#29485a)}.lexModelGrid button.ready{border-color:var(--green,#36f0a0)}.lexModelGrid button span{grid-row:1/3;font-size:25px}.lexModelGrid button small{color:var(--muted,#a9bfcc)}.lexToggle{display:flex;gap:11px;align-items:flex-start}.lexToggle input{width:23px;height:23px}.lexToggle span{display:grid}.lexToggle small{color:var(--muted,#a9bfcc)}.lexAppLanguage{display:flex;justify-content:space-between;gap:10px;align-items:center}.lexAppLanguage div{display:grid}.lexAppLanguage small{color:var(--muted,#a9bfcc)}.lexR8Loading,.lexR8Empty{padding:30px;text-align:center;border:1px dashed var(--line,#29485a);border-radius:18px;color:var(--muted,#a9bfcc)}.ithLexToastR10F8{position:fixed;left:50%;bottom:86px;transform:translate(-50%,20px);opacity:0;pointer-events:none;z-index:2147483700;max-width:calc(100vw - 24px);padding:11px 15px;border-radius:999px;background:var(--panel,#0b2030);border:1px solid var(--gold,#f5c451);color:var(--text,#fff);transition:.2s}.ithLexToastR10F8.show{opacity:1;transform:translate(-50%,0)}
@media(max-width:620px){.lexUnknownFirstGridR10F21{grid-template-columns:1fr}.lexR8Wrap{width:calc(100vw - 10px);margin:6px auto}.lexR8Hero{grid-template-columns:52px 1fr;padding:11px}.lexR8Hero .book{width:50px;height:50px;font-size:31px}.lexPairPicker{grid-template-columns:1fr}.lexCorrection{grid-template-columns:1fr}.lexCorrection button{min-height:44px}.lexModelGrid{grid-template-columns:1fr 1fr}.lexAppLanguage{align-items:stretch;flex-direction:column}.lexAppLanguage button{width:100%}}
`;document.head.appendChild(s)}
function open(){style();shell();return false}
function install(){style();ensureButton();window.ITHAKI_OPEN_COMMUNITY_LEXICON_V249374=open;window.ITHAKI_OPEN_LEXICON1_R10F8=open;window.ITH=window.ITH||{};ITH.openLexicon1R10F8=open;const mo=new MutationObserver(()=>ensureButton());mo.observe(document.documentElement,{subtree:true,childList:true,attributes:true,attributeFilter:['class','data-page']});document.addEventListener('click',e=>{const b=e.target.closest?.('#'+BTN);if(!b)return;e.preventDefault();e.stopPropagation();e.stopImmediatePropagation();open()},true);window.addEventListener('ithaki:global-language-changed',()=>{$(MODAL)&&shell();ensureButton()});setInterval(ensureButton,2200)}
if(document.readyState==='loading')document.addEventListener('DOMContentLoaded',install,{once:true});else install();
})();
