(()=>{'use strict';
window.ITHAKI_R10F31_PROFILE_TRANSLATION_LEXICON=true;
window.ITHAKI_R10F31F7_PRO_PROFILE_CREATOR_LEXICON=true;
const $=id=>document.getElementById(id);
const esc=s=>String(s??'').replace(/[&<>"']/g,m=>({'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;',"'":'&#39;'}[m]));
const norm=s=>String(s||'').replace(/\s+/g,' ').trim().toLowerCase();
function apiBase(){try{return String((window.state&&state.api)||localStorage.getItem('ith_server_base')||location.origin).replace(/\/$/,'')}catch(_){return location.origin}}
function room(){try{return String((window.state&&state.room)||localStorage.getItem('ith_room')||'ithaki-phone-test')}catch(_){return'ithaki-phone-test'}}
function device(){try{return String((window.state&&state.device)||localStorage.getItem('ith_device')||'')}catch(_){return''}}
function nickname(){try{return String((window.state&&state.name)||localStorage.getItem('ith_name')||'Μέλος')}catch(_){return'Μέλος'}}
function css(){if($('ithR31F7Css'))return;let s=document.createElement('style');s.id='ithR31F7Css';s.textContent=`
[data-r31f7-hidden="1"]{display:none!important}.r31f7Shell{display:grid;gap:12px;max-width:880px;margin:auto}.r31f7Hero{padding:18px;border:1px solid rgba(236,194,84,.55);border-radius:22px;background:linear-gradient(145deg,rgba(7,19,38,.98),rgba(15,48,75,.96));box-shadow:0 18px 42px rgba(0,0,0,.3)}.r31f7Top{display:flex;align-items:center;gap:14px}.r31f7Top .avatar{width:74px;height:74px;font-size:34px}.r31f7Top h2{margin:0;color:#f4d36d}.r31f7Sub{color:#bcd0df;margin-top:4px}.r31f7Field{display:grid;gap:6px;margin-top:12px}.r31f7Field input,.r31f7Field textarea,.r31f7Field select{width:100%;border:1px solid rgba(244,211,109,.38);border-radius:14px;padding:12px;background:#0b2339;color:#fff}.r31f7Field textarea{min-height:78px;resize:vertical}.r31f7Actions{display:flex;gap:8px;flex-wrap:wrap;margin-top:12px}.r31f7Actions button,.r31f7LangButton{border:1px solid rgba(244,211,109,.5);border-radius:13px;padding:11px 14px;background:#123758;color:#fff;font-weight:800}.r31f7Gold{background:linear-gradient(135deg,#b88724,#f2d77b)!important;color:#152033!important}.r31f7Panel{padding:15px;border-radius:18px;background:rgba(10,31,52,.96);border:1px solid rgba(255,255,255,.10)}.r31f7Panel h3{margin:0 0 10px;color:#f3d477}.r31f7Modes{display:flex;gap:8px;flex-wrap:wrap}.r31f7Modes button.on{background:linear-gradient(135deg,#d9ad3f,#fff0a2);color:#102033}.r31f7AdminModal{position:fixed;inset:0;z-index:2147483000;background:rgba(0,0,0,.76);display:grid;place-items:center;padding:14px}.r31f7AdminCard{width:min(680px,100%);max-height:92vh;overflow:auto;border-radius:22px;padding:17px;background:#071a2c;border:1px solid rgba(240,199,83,.6);box-shadow:0 24px 70px rgba(0,0,0,.5)}.r31f7AdminCard textarea{width:100%;min-height:130px}.r31f7Thread{display:grid;gap:8px;margin-top:12px}.r31f7Msg{padding:11px;border-radius:14px;background:rgba(255,255,255,.06)}.r31f7Reply{margin-top:7px;padding:9px;border-left:3px solid #e3bd52;background:rgba(227,189,82,.09)}
`;document.head.appendChild(s)}
function avatarHtml(){try{if(window.avatarHtml)return window.avatarHtml({nickname:nickname(),avatar:(window.avatarValue?window.avatarValue():'')})}catch(_){}return '<span class="avatar">'+esc((nickname()[0]||'Μ'))+'</span>'}
function mode(){return localStorage.getItem('ith_translation_mode_r10f31')||'manual'}
function target(){return localStorage.getItem('ith_translation_target_r10f31')||'en'}
function saveMode(v){localStorage.setItem('ith_translation_mode_r10f31',v);localStorage.setItem('ith_auto_translate_content_r10f8',v==='auto'?'1':'0');renderLanguagePanel()}
function saveTarget(v){localStorage.setItem('ith_translation_target_r10f31',v);localStorage.setItem('ith_translation_target_lang',v)}
function toggleLanguage(){let p=$('r31f7LanguagePanel');if(p)p.hidden=!p.hidden}
function saveAbout(){let x=$('r31f7About');if(x)localStorage.setItem('ith_profile_about_r10f31f7',String(x.value||'').slice(0,240))}
function renderLanguagePanel(){let p=$('r31f7LanguagePanel');if(!p)return;let m=mode(),t=target();p.innerHTML=`<h3>🌐 Γλώσσα και μετάφραση</h3><div class="r31f7Modes"><button class="${m==='auto'?'on':''}" data-mode="auto">Αυτόματη μετάφραση</button><button class="${m==='manual'?'on':''}" data-mode="manual">Χειροκίνητη μετάφραση</button></div><div class="r31f7Field"><label>Γλώσσα μετάφρασης</label><select id="r31f7Target"><option value="el" ${t==='el'?'selected':''}>Ελληνικά</option><option value="en" ${t==='en'?'selected':''}>English</option></select></div><small>Εσωτερικό λεξικό Ελληνικά ↔ Αγγλικά. Η γλώσσα των μενού αλλάζει ανεξάρτητα.</small><div class="r31f7Modes" style="margin-top:10px"><button data-ui="el">Μενού Ελληνικά</button><button data-ui="en">Menu English</button></div>`;p.querySelectorAll('[data-mode]').forEach(b=>b.onclick=()=>saveMode(b.dataset.mode));$('r31f7Target').onchange=e=>saveTarget(e.target.value);p.querySelectorAll('[data-ui]').forEach(b=>b.onclick=()=>{try{ITH.setUiLang(b.dataset.ui)}catch(_){localStorage.setItem('ith_ui_lang',b.dataset.ui);location.reload()}})}
async function adminRequest(path,opt={}){let r=await fetch(apiBase()+path,{credentials:'same-origin',headers:{'Content-Type':'application/json'},...opt});let text=await r.text(),d={};try{d=JSON.parse(text)}catch(_){d={message:text}}if(!r.ok)throw Error(d.detail||d.error||d.message||('HTTP '+r.status));return d}
async function loadAdminThread(){let box=$('r31f7Thread');if(!box)return;box.innerHTML='<div class="date">Φόρτωση…</div>';try{let q=`?room_id=${encodeURIComponent(room())}&device_id=${encodeURIComponent(device())}&limit=80&_v=${Date.now()}`,d=await adminRequest('/api/feedback/status'+q),items=Array.isArray(d.feedback)?d.feedback:[];box.innerHTML=items.length?items.map(x=>`<div class="r31f7Msg"><b>${esc(x.nickname||nickname())}</b><div>${esc(x.message||'')}</div>${x.admin_reply?`<div class="r31f7Reply"><b>Απάντηση διαχειριστή</b><div>${esc(x.admin_reply)}</div></div>`:'<small>Αναμονή απάντησης</small>'}</div>`).join(''):'<div class="date">Δεν υπάρχει ακόμη επικοινωνία.</div>'}catch(e){box.innerHTML='<div class="date">'+esc(e.message)+'</div>'}}
async function sendAdmin(){let ta=$('r31f7AdminText'),txt=String(ta&&ta.value||'').trim();if(!txt)return;let b=$('r31f7AdminSend');if(b)b.disabled=true;try{await adminRequest('/api/feedback/send',{method:'POST',body:JSON.stringify({room_id:room(),device_id:device(),nickname:nickname(),screen:'profile-r10f31f7',message:txt,user_agent:navigator.userAgent||'',professional_member:true})});ta.value='';await loadAdminThread()}catch(e){alert(e.message)}finally{if(b)b.disabled=false}}
function closeAdmin(){let m=$('r31f7AdminModal');if(m)m.remove()}
function openAdmin(){closeAdmin();let m=document.createElement('section');m.id='r31f7AdminModal';m.className='r31f7AdminModal';m.innerHTML=`<div class="r31f7AdminCard"><div class="row"><div><h3 style="margin:0;color:#f3d477">💬 Άμεση επαφή διαχειριστή</h3><div class="date">Μήνυμα χωρίς αίτημα φιλίας. Ο διαχειριστής απαντά στο ίδιο σημείο.</div></div><button class="icon" id="r31f7AdminClose">×</button></div><textarea id="r31f7AdminText" placeholder="Γράψε το μήνυμά σου…"></textarea><div class="r31f7Actions"><button class="r31f7Gold" id="r31f7AdminSend">Αποστολή</button><button id="r31f7AdminRefresh">Ανανέωση</button></div><div id="r31f7Thread" class="r31f7Thread"></div></div>`;document.body.appendChild(m);$('r31f7AdminClose').onclick=closeAdmin;$('r31f7AdminSend').onclick=sendAdmin;$('r31f7AdminRefresh').onclick=loadAdminThread;m.onclick=e=>{if(e.target===m)closeAdmin()};loadAdminThread()}
function buildProfile(){let p=$('profilePage');if(!p||String(document.body&&document.body.dataset.page)!=='profile')return;if(p.dataset.r31f7Built==='1')return;p.dataset.r31f7Built='1';let about=localStorage.getItem('ith_profile_about_r10f31f7')||'';p.innerHTML=`<div class="r31f7Shell"><section class="r31f7Hero"><div class="r31f7Top"><button class="icon" id="r31f7Back">‹</button>${avatarHtml()}<div><h2>Επαγγελματικό προφίλ</h2><div class="r31f7Sub">Όνομα, εικόνα, λίγα λόγια και βασικές επιλογές με μία ματιά.</div></div></div><div class="r31f7Field"><label>Όνομα / ψευδώνυμο</label><input id="profName" value="${esc(nickname())}" autocomplete="nickname"></div><div class="r31f7Actions"><button id="r31f7Camera">📷 Κάμερα</button><button id="r31f7Photo">🖼️ Φωτογραφία</button><button id="r31f7Avatar">🐾 Avatar</button></div><div id="animalBox" class="row" style="display:none"></div><button class="r31f7LangButton" id="r31f7LangOpen" style="margin-top:12px">🌐 Επιλογή γλώσσας και μετάφρασης</button><section id="r31f7LanguagePanel" class="r31f7Panel" hidden style="margin-top:10px"></section><div class="r31f7Field"><label>Λίγα λόγια για εσένα <small>(προαιρετικά)</small></label><textarea id="r31f7About" maxlength="240" placeholder="Γράψε μία σύντομη σειρά για εσένα…">${esc(about)}</textarea></div><label class="card row"><input id="age16" type="checkbox" ${(window.state&&state.age16)?'checked':''}><span>Είμαι άνω των 16 ετών.</span></label><label class="card row"><input id="policyOk" type="checkbox" ${(window.state&&state.policyOk)?'checked':''}><span>Συμφωνώ με την πολιτική και τους όρους χρήσης.</span></label><div class="r31f7Actions"><button class="r31f7Gold" id="r31f7Save">💾 Αποθήκευση προφίλ</button></div></section><section class="r31f7Panel"><h3>Επικοινωνία και δημιουργία</h3><div class="r31f7Actions"><button id="r31f7Admin">💬 Άμεση επαφή διαχειριστή</button><button id="r31f7Pro">🛠️ Εργαλεία δημιουργού</button></div></section></div>`;
$('r31f7Back').onclick=()=>ITH.page('home');$('r31f7Camera').onclick=()=>ITH.avatarPick('camera');$('r31f7Photo').onclick=()=>ITH.avatarPick('file');$('r31f7Avatar').onclick=()=>ITH.showAnimals();$('r31f7LangOpen').onclick=toggleLanguage;$('r31f7About').oninput=saveAbout;$('r31f7Save').onclick=()=>{saveAbout();return ITH.saveProfile()};$('r31f7Admin').onclick=openAdmin;$('r31f7Pro').onclick=()=>{let f=ITH.openProfessionalCenterFastV249392||ITH.openProfessionalCenterV249386||ITH.openProfessionalCenterV249384||ITH.openProfessionalCenterV249383;if(typeof f==='function')f();else document.getElementById('ithProQuick384')?.click()};renderLanguagePanel()}
function creatorOnly(){document.querySelectorAll('#ithProCenterV249477,.ithAccountOverlay383,.ithModal383').forEach(root=>{let all=[...root.querySelectorAll('.card,section,details,li,.ithToolCard383,.ithToolGrid383>*')],keeper=all.find(el=>/εργαλεία δημιουργού|creator tools/i.test(el.textContent||''));if(!keeper)return;let top=keeper;while(top.parentElement&&top.parentElement!==root&&!top.classList.contains('ithToolGrid383')){if(top.parentElement.children.length>1)break;top=top.parentElement}all.forEach(el=>{if(el===keeper||el.contains(keeper)||keeper.contains(el)){el.removeAttribute('data-r10f31-hidden');el.removeAttribute('data-r31f7-hidden');el.style.removeProperty('display')}else if(el.parentElement===root||el.parentElement?.classList.contains('ithToolGrid383'))el.dataset.r31f7Hidden='1'});keeper.querySelectorAll('*').forEach(el=>{el.removeAttribute('data-r10f31-hidden');el.removeAttribute('data-r31f7-hidden');el.style.removeProperty('display')})})}
function maintain(){css();buildProfile();creatorOnly();document.documentElement.dataset.ithakiR10f31f7='professional-profile-creator-lexicon'}
new MutationObserver(()=>requestAnimationFrame(maintain)).observe(document.documentElement,{subtree:true,childList:true});addEventListener('DOMContentLoaded',maintain);addEventListener('load',maintain);setInterval(maintain,1200);Object.assign(window.ITH||{}, {openAdministratorContactR10F31F7:openAdmin});maintain();
})();