import{c as e,it as t,p as n,rt as r,tt as i}from"./button-cHQg_W3T.js";import{a,i as o}from"./shared-styles-CHEAAivb.js";function s(e){return e===`magic`?`magic`:e===`hymofs`?`hymofs`:e===`ignore`?`ignore`:`overlay`}var c=r(()=>{let[r,c]=o([]),[l,u]=t(!1),[d,f]=t(!1),p=null,m=!1;function h(e){return{...e,mode:s(e.mode),rules:{...e.rules,default_mode:s(e.rules.default_mode)}}}let g=i(()=>{let e={overlay:0,magic:0,hymofs:0};return r.forEach(t=>{if(!t.is_mounted)return;let n=s(t.mode);n===`overlay`?e.overlay++:n===`magic`?e.magic++:n===`hymofs`&&e.hymofs++}),e});async function _(){return p||(u(!0),p=(async()=>{try{c(a((await e.scanModules()).map(e=>h(e)))),m=!0}catch{n.showToast(n.L.modules?.scanError||`Failed to load modules`,`error`)}finally{u(!1),p=null}})(),p)}function v(){return m?Promise.resolve():_()}async function y(){f(!0);try{await e.saveModules(r),n.showToast(n.L.common?.saved||`Saved`,`success`)}catch{n.showToast(n.L.modules?.saveFailed||`Failed to save module modes`,`error`)}f(!1)}return{get modules(){return r},set modules(e){c(a(e.map(h)))},get loading(){return l()},get saving(){return d()},get hasLoaded(){return m},get modeStats(){return g()},ensureModulesLoaded:v,loadModules:_,saveModules:y}});export{s as n,c as t};