/* Server-backed model management. Legacy browser drafts remain untouched. */
const Studio=(()=>{
let section='discover',category='';
const labels={chat:'Sprachmodelle / Chat',image:'Bildgenerierung',audio:'Audio',video:'Video'};
function render(page,force=false,modelId=null){
if(!force&&document.querySelector('#studio')?.dataset.page===page)return;
if(category!==page){category=page;section='discover';}
if(modelId)section='profiles';
const body=page==='runtime'?RuntimeUI.html():`
ATHENA / MODELLVERWALTUNG
${labels[page]} Modelle entdecken, herunterladen und mit gespeicherten Profilen konfigurieren.
${[['discover','Entdecken'],['library','Bibliothek'],['downloads','Downloads'],['profiles','Profile'],['running','Laufend']].map(([id,label])=>`${label} `).join('')}
${section==='profiles'?ProfilesUI.html():section==='running'?'
Keine von Deck gestarteten Modelle Profile werden auf Athena gespeichert. Bild-, Audio- und Video-Worker sind noch nicht eingerichtet. Fehlende Komponenten stehen beim jeweiligen Profil.
llama.cpp-Builds verwalten → ':CatalogUI.html(section==='library',section==='downloads')}
`;
document.querySelector('#view').innerHTML=`${body}
`;
if(page==='runtime'){RuntimeUI.bind();return;}
if(section==='profiles')ProfilesUI.bind(page,modelId);
else if(section!=='running')CatalogUI.bind(page,section==='library',section==='downloads');
document.querySelectorAll('[data-section]').forEach(b=>b.onclick=()=>{section=b.dataset.section;render(page,true);});
}
function openProfile(page,modelId){render(page,true,modelId);}
return {render,openProfile};
})();