// Copyright (c) 2009-2026 SAP SE, All Rights Reserved
/**
 * @fileoverview This module provides a function for loading and execute the bootstrap extension.
 */
sap.ui.define([
    "sap/base/util/ObjectPath",
    "sap/ushell/bootstrap/Config"
], (
    ObjectPath,
    BootstrapConfig
) => {
    "use strict";

    class LoadBootstrapExtension {
        async run () {
            const oUshellConfig = BootstrapConfig.get();
            let sPath = ObjectPath.get("bootstrap.extensionModule", oUshellConfig);
            if (!sPath || typeof sPath !== "string") {
                return;
            }
            sPath = sPath.replace(/\./g, "/");
            sap.ui.require([sPath], (oExtensionModule) => {
                if (oExtensionModule && typeof oExtensionModule === "function") {
                    oExtensionModule();
                }
            });
        }
    }

    return new LoadBootstrapExtension();
});
