package io.xpipe.app.core;

import io.xpipe.app.browser.BrowserFullSessionModel;
import io.xpipe.app.core.mode.AppOperationMode;
import io.xpipe.app.storage.DataStorage;
import io.xpipe.app.util.ThreadHelper;
import io.xpipe.app.util.OsType;

public class AppAotTrain {

    public static void runTrainingMode() throws Throwable {
        // Linux runners don't support graphics
        if (OsType.ofLocal() == OsType.LINUX) {
            return;
        }

        AppOperationMode.switchToSyncOrThrow(AppOperationMode.GUI);
        ThreadHelper.sleep(5000);
        BrowserFullSessionModel.DEFAULT.openFileSystemSync(
                DataStorage.get().local().ref(),
                null,
                m -> m.getFileSystem().getShell().orElseThrow().view().userHome(),
                null,
                true);
        AppLayoutModel.get().selectSettings();
        ThreadHelper.sleep(1000);
        AppLayoutModel.get().selectLicense();
        ThreadHelper.sleep(1000);
        AppLayoutModel.get().selectBrowser();
        ThreadHelper.sleep(5000);
    }
}
