import html from "../../../services/html.js";
export function startMainUiLoading(saveButton) {
    saveButton.innerHTML = html `<eden-icon
    code="loader"
    class="button__spinner"
  ></eden-icon>`;
}
export function stopMainUiLoading(saveButton) {
    saveButton.innerHTML = html `<eden-icon
    code="floppy_disk"
    class="button__icon"
  ></eden-icon>`;
}
export function editMainUi(ui, toggleActive) {
    ui.unsavedChanges = true;
    window.Eden.hideInfo();
    window.Eden.activate();
    toggleActive();
}
export function infoMainUi(ui, toggleInfo) {
    const isInfo = ui.getAttribute("info") !== null;
    if (!isInfo) {
        ui.unsavedChanges = false;
        window.Eden.desactivate();
        window.Eden.displayInfo();
    }
    else {
        window.Eden.hideInfo();
    }
    toggleInfo();
}
export async function saveMainUi(ui, updateUpdatedByTooltip) {
    ui.unsavedChanges = false;
    ui.startLoading();
    await window.Eden.save();
    ui.stopLoading();
    ui.toggleActive();
    updateUpdatedByTooltip();
}
export function cancelMainUi(ui, toggleActive) {
    ui.unsavedChanges = false;
    window.Eden.desactivate();
    toggleActive();
}
export function logoutMainUi(ui) {
    ui.unsavedChanges = false;
    window.Eden.logout();
}
export function toggleMainUiActive(host) {
    const isActive = host.getAttribute("active") !== null;
    if (isActive) {
        host.removeAttribute("active");
        return;
    }
    host.setAttribute("active", "");
    host.removeAttribute("info");
}
export function toggleMainUiInfo(host) {
    const isInfo = host.getAttribute("info") !== null;
    if (isInfo) {
        host.removeAttribute("info");
        return;
    }
    host.setAttribute("info", "");
    host.removeAttribute("active");
}
