// Copyright (c) 2009-2026 SAP SE, All Rights Reserved

/**
 * @fileOverview Numeric Tile
 * This SAP Smart Business module is only used for SAP Business Suite hub deployments.
 *
 * @deprecated since 1.96. Deprecated without successor. SAP Smart Business KPI tiles are only used for SAP Business Suite hub deployments.
 */
sap.ui.define([
    "sap/ui/core/mvc/JSView", // Do not remove
    "sap/ui/model/analytics/odata4analytics", // Do not remove
    "sap/ushell/components/tiles/indicatorTileUtils/smartBusinessUtil", // Do not remove
    "sap/m/library",
    "sap/m/NumericContent",
    "sap/m/GenericTile",
    "sap/ui/model/json/JSONModel",
    // "sap/ushell/components/tiles/sbtilecontent" // do not migrate
    "sap/ushell/utils/DeprecationLog"
], (
    JSView,
    odata4analytics,
    smartBusinessUtil,
    mobileLibrary,
    NumericContent,
    GenericTile,
    JSONModel,
    // sbtilecontent // do not migrate
    DeprecationLog
) => {
    "use strict";

    DeprecationLog.logModuleDeprecation({
        module: "sap.ushell.components.tiles.indicatornumeric.NumericTile",
        since: "1.96",
        reason: "Deprecated without successor. SAP Smart Business KPI tiles are only used for SAP Business Suite hub deployments."
    });

    // shortcut for sap.m.DeviationIndicator
    const DeviationIndicator = mobileLibrary.DeviationIndicator;

    // shortcut for sap.m.ValueColor
    const ValueColor = mobileLibrary.ValueColor;

    // shortcut for sap.m.LoadState
    const LoadState = mobileLibrary.LoadState;

    sap.ui.getCore().loadLibrary("sap.suite.ui.commons");

    sap.ui.jsview("sap.ushell.components.tiles.indicatornumeric.NumericTile", {
        getControllerName: function () {
            return "sap.ushell.components.tiles.indicatornumeric.NumericTile";
        },
        createContent: function () {
            let header = "Lorem ipsum";
            let subheader = "Lorem ipsum";

            const titleObj = sap.ushell.components.tiles.indicatorTileUtils.util.getTileTitleSubtitle(this.getViewData().chip);
            if (titleObj.title && titleObj.subTitle) {
                header = titleObj.title;
                subheader = titleObj.subTitle;
            }
            const oGenericTileData = {
                subheader: subheader,
                header: header,
                footerNum: "",
                footerComp: "",
                scale: "",
                unit: "",
                value: "",
                size: "Auto",
                frameType: "OneByOne",
                state: LoadState.Loading,
                valueColor: ValueColor.Neutral,
                indicator: DeviationIndicator.None,
                title: "",
                footer: "",
                description: ""
            };

            this.oNVConfContS = new NumericContent({
                value: "{/value}",
                scale: "{/scale}",
                unit: "{/unit}",
                indicator: "{/indicator}",
                valueColor: "{/valueColor}",
                size: "{/size}",
                formatterValue: true,
                truncateValueTo: 5,
                nullifyValue: false
            });

            this.oNVConfS = new sap.ushell.components.tiles.sbtilecontent({
                unit: "{/unit}",
                size: "{/size}",
                footer: "{/footerNum}",
                content: this.oNVConfContS
            });

            this.oGenericTile = new GenericTile({
                subheader: "{/subheader}",
                frameType: "{/frameType}",
                size: "{/size}",
                header: "{/header}",
                tileContent: [this.oNVConfS]
            });

            const oGenericTileModel = new JSONModel();
            oGenericTileModel.setData(oGenericTileData);
            this.oGenericTile.setModel(oGenericTileModel);

            return this.oGenericTile;
        }
    });
}, /* bExport= */ true);
