/* OK ITHAKI V249490 - PROFESSIONAL SIX HOME ACTIONS / CREATION-ONLY PLUS / STORY THUMBNAILS / STORY TO FEED */
(function(){'use strict';if(window.__ITHAKI_V249490__)return;window.__ITHAKI_V249490__=true;
const $=id=>document.getElementById(id),I=()=>window.ITH||{},S=()=>I().state||window.state||{};
function css(){if($('ithV249490Css'))return;const s=document.createElement('style');s.id='ithV249490Css';s.textContent=`
#ith489PublishGrid{display:none!important}
.ithActionV249461{position:relative!important;overflow:hidden!important;min-height:112px!important;border-radius:24px!important;transform:translateZ(0)!important;background:linear-gradient(145deg,rgba(24,59,84,.98),rgba(5,20,34,.98))!important;border:1px solid rgba(255,224,151,.28)!important;box-shadow:inset 0 1px 0 rgba(255,255,255,.14),inset 0 -10px 22px rgba(0,0,0,.20),0 14px 28px rgba(0,0,0,.30)!important;transition:transform .16s ease,box-shadow .16s ease!important}
.ithActionV249461:before{content:"";position:absolute;inset:0;background:linear-gradient(125deg,rgba(255,255,255,.14),transparent 36%,transparent 70%,rgba(86,218,255,.08));pointer-events:none}.ithActionV249461:hover{transform:translateY(-3px) scale(1.015)!important;box-shadow:inset 0 1px 0 rgba(255,255,255,.18),0 20px 38px rgba(0,0,0,.38),0 0 24px rgba(85,215,255,.12)!important}.ithActionV249461:active{transform:translateY(1px) scale(.985)!important}.ithActionIconV249461{filter:drop-shadow(0 6px 9px rgba(0,0,0,.38))!important}
#plusSheet.ith490CreateOnly{grid-template-columns:repeat(3,minmax(0,1fr))!important;padding:16px!important;gap:12px!important;background:linear-gradient(160deg,rgba(8,26,43,.985),rgba(3,12,22,.985))!important}.ith490CreateTitle{grid-column:1/-1;text-align:center;font-weight:900;color:#ffe39d;font-size:16px;padding:4px}.ith490CreateOnly .tile{min-height:88px!important;border-radius:20px!important;background:linear-gradient(145deg,rgba(34,72,97,.96),rgba(8,28,44,.96))!important;border:1px solid rgba(255,224,151,.22)!important;box-shadow:inset 0 1px 0 rgba(255,255,255,.12),0 10px 22px rgba(0,0,0,.28)!important;text-align:center!important}.ith490CreateOnly .tile b{font-size:27px!important;margin-bottom:5px!important}
#ith490StoryHistory{margin:12px 0 4px;padding:12px;border-radius:20px;background:rgba(4,17,29,.78);border:1px solid rgba(255,255,255,.10)}.ith490StoryHistoryTitle{font-weight:850;color:#ffe39d;margin-bottom:9px}.ith490StoryThumbs{display:flex;gap:10px;overflow-x:auto;padding:2px 1px 7px}.ith490StoryThumb{position:relative;flex:0 0 112px;height:150px;border-radius:17px;overflow:hidden;background:#000;border:2px solid rgba(255,211,105,.65);box-shadow:0 8px 20px rgba(0,0,0,.35)}.ith490StoryThumb video,.ith490StoryThumb img{width:100%;height:100%;object-fit:cover;display:block}.ith490StoryThumb span{position:absolute;left:5px;right:5px;bottom:5px;padding:4px 6px;border-radius:9px;background:rgba(0,0,0,.68);font-size:10px;color:#fff;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
#feedPage .avatar,#feedPage .postAvatar,#feedPage [class*="Avatar"]{filter:none!important;opacity:1!important}.ith477StoryRing,.ith481StoryAvatar{width:74px!important;height:74px!important;min-width:74px!important;filter:none!important;opacity:1!important}
@media(max-width:760px){.ithActionsV249461{grid-template-columns:repeat(2,minmax(0,1fr))!important;gap:11px!important}.ithActionV249461{min-height:108px!important;border-radius:22px!important}.ithActionV249461:hover{transform:none!important}#plusSheet.ith490CreateOnly{grid-template-columns:repeat(2,minmax(0,1fr))!important;left:8px!important;right:8px!important}.ith490CreateOnly .tile{min-height:84px!important}.ith490StoryThumb{flex-basis:104px;height:140px}}
`;document.head.appendChild(s)}
function openCreateMenu(){const sh=$('plusSheet');if(!sh)return false;sh.className='plusSheet show ith490CreateOnly';sh.innerHTML=`<div class="ith490CreateTitle">＋ Δημιουργία δημοσίευσης</div><button class="tile" data-ith490-create="camera_photo"><b>📷</b>Λήψη φωτογραφίας</button><button class="tile" data-ith490-create="camera_video"><b>🎥</b>Λήψη βίντεο</button><button class="tile" data-ith490-create="gallery_photo"><b>🖼️</b>Φωτογραφία</button><button class="tile" data-ith490-create="gallery_video"><b>📼</b>Βίντεο</button><button class="tile" data-ith490-create="file"><b>📎</b>Αρχείο</button><button class="tile" data-ith490-create="audio"><b>🎙️</b>Ήχος</button><button class="tile" data-ith490-create="text"><b>📝</b>Κείμενο</button><button class="tile" data-ith490-create="poll"><b>📊</b>Ψηφοφορία</button><button class="tile" data-ith490-create="story"><b>⭕</b>Story 24 ωρών</button>`;return false}
function ensureSixHome(){if(window.__ITHAKI_V249500_HOME_OWNER__)return true;document.querySelectorAll('#ith489PublishGrid').forEach(x=>x.remove());const box=document.querySelector('.ithActionsV249461');if(!box)return;const old=[...box.children];if(old.length<3)return;const by=a=>old.find(x=>x.getAttribute('data-v249461-action')===a),route=r=>old.find(x=>x.getAttribute('data-v249461-route')===r);const feed=route('feed'),dm=route('dm'),video=by('video'),external=by('external'),why=by('why');if(!feed||!dm||!video)return;let pub=box.querySelector('[data-ith490-home-publish]');if(!pub){pub=document.createElement('button');pub.type='button';pub.className='ithActionV249461';pub.setAttribute('data-ith490-home-publish','1');pub.setAttribute('data-ith-sun-color','gold');pub.innerHTML='<span class="ithActionIconV249461" aria-hidden="true">＋</span><b>Δημοσίευση</b><small>Όλες οι επιλογές δημιουργίας</small>'}box.replaceChildren(feed,dm,video,pub,...[external,why].filter(Boolean));pub.onclick=e=>{e.preventDefault();e.stopPropagation();openCreateMenu()}}
function storyPanel(){return $('ith477StorySelectionV249485')||document.querySelector('[id*="StorySelection"],.ith477StorySelection')}
async function storyHistory(){const panel=storyPanel();if(!panel||panel.querySelector('#ith490StoryHistory'))return;const holder=document.createElement('section');holder.id='ith490StoryHistory';holder.innerHTML='<div class="ith490StoryHistoryTitle">Προηγούμενα ενεργά Stories</div><div class="ith490StoryThumbs"><small>Φόρτωση…</small></div>';const input=$('ith477StoryFile');(input&&input.parentNode?input.parentNode:panel).insertBefore(holder,input||null);try{const s=S(),r=await fetch('/api/professional/stories/v249477/list?room_id='+encodeURIComponent(s.room||'ithaki-phone-test')+'&limit=40',{credentials:'same-origin'}),j=await r.json(),list=(j.stories||[]).filter(x=>!s.device||String(x.device_id||'')===String(s.device));const row=holder.querySelector('.ith490StoryThumbs');if(!list.length){row.innerHTML='<small>Δεν υπάρχουν ενεργά προηγούμενα Stories.</small>';return}row.innerHTML=list.map((x,i)=>{const url=String(x.media_url||'');const media=String(x.media_kind||'')==='video'?`<video src="${url}" muted playsinline preload="metadata"></video>`:`<img src="${url}" alt="Story">`;return `<button class="ith490StoryThumb" type="button" data-ith490-story-index="${i}">${media}<span>${String(x.caption||x.filename||'Story')}</span></button>`}).join('');window.__ITHAKI_V249490_STORIES__=list}catch(e){holder.querySelector('.ith490StoryThumbs').innerHTML='<small>Δεν ήταν δυνατή η φόρτωση των προηγούμενων Stories.</small>'}}
function openStory(){const a=I();$('plusSheet')?.classList.remove('show');if(typeof a.openProfessionalCenterV249477==='function')a.openProfessionalCenterV249477();setTimeout(()=>{if(typeof a.openProfessionalStoriesV249477==='function')a.openProfessionalStoriesV249477();setTimeout(storyHistory,120)},80);return false}
function dispatchCreate(act){const a=I(),sh=$('plusSheet');sh&&sh.classList.remove('show');if(act==='story')return openStory();if(act==='poll')return a.openPoll?a.openPoll():false;if(act==='text')return a.page?a.page('create'):false;const map={camera_photo:'camera_photo',camera_video:'camera_video',gallery_photo:'gallery_photo',gallery_video:'gallery_video',file:'file',audio:'audio'};const core=map[act];if(!core)return false;const tmp=document.createElement('button');tmp.dataset.act=core;sh&&sh.appendChild(tmp);tmp.click();tmp.remove();return false}
document.addEventListener('click',e=>{const p=e.target.closest('[data-ith490-home-publish]');if(p){e.preventDefault();e.stopPropagation();return openCreateMenu()}const c=e.target.closest('[data-ith490-create]');if(c){e.preventDefault();e.stopPropagation();return dispatchCreate(c.dataset.ith490Create)}const th=e.target.closest('[data-ith490-story-index]');if(th){const v=th.querySelector('video');if(v){v.paused?v.play():v.pause()}return}},true);
window.addEventListener('ithaki:page-changed',e=>{if(String(e.detail&&e.detail.page)==='home')setTimeout(ensureSixHome,80);if(String(e.detail&&e.detail.page)==='feed')setTimeout(()=>{try{I().loadProfessionalStoryBarV249477&&I().loadProfessionalStoryBarV249477(true)}catch(e){}},100)});
function run(){css();I().openCreateMenuV249490=openCreateMenu;I().openCreateMenuV249500=openCreateMenu;ensureSixHome();document.querySelectorAll('#ith489PublishGrid').forEach(x=>x.remove());if(storyPanel())storyHistory();try{const u=new URL(location.href);/* canonical owner moved to V249491 */}catch(e){}document.documentElement.setAttribute('data-ithaki-v249490','six-home-create-only-story-thumbnails')}
new MutationObserver(()=>{clearTimeout(window.__ith490mo);window.__ith490mo=setTimeout(run,90)}).observe(document.documentElement,{subtree:true,childList:true});if(document.readyState==='loading')document.addEventListener('DOMContentLoaded',run,{once:true});else run();setTimeout(run,800)
})();
