/** @odoo-module **/

import { WebClient } from "@web/webclient/webclient";
import { patch } from "@web/core/utils/patch";
import { onMounted } from "@odoo/owl";

patch(WebClient.prototype, {
    setup() {
        super.setup();
        try {
            this.title.setParts({ brand: "Shivasakthi" });
        } catch (e) {
            // title service not ready yet, ignore
        }

        onMounted(() => {
            try {
                // Only redirect to home dashboard if the URL has no meaningful hash
                // (i.e., user just typed /web or /web# directly)
                const hash = window.location.hash;
                const path = window.location.pathname;
                if (path === "/web" && (!hash || hash === "#" || hash === "#home")) {
                    window.location.href = "/";
                }
            } catch (e) {
                // ignore redirect errors
            }
        });
    }
});

