function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }

function _possibleConstructorReturn(t, e) { if (e && ("object" == typeof e || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }

function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }

function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }

function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }

function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }

function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }

function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }

function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }

function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }

function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }

function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }

function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }

function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }

function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }

function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }

function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }

function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }

(window["webpackJsonp"] = window["webpackJsonp"] || []).push([["cc-actions-cc-actions-module"], {
  /***/
  "./node_modules/raw-loader/dist/cjs.js!./src/app/pages/home/cloud-cost/cc-actions/cc-actions.component.html":
  /*!******************************************************************************************************************!*\
    !*** ./node_modules/raw-loader/dist/cjs.js!./src/app/pages/home/cloud-cost/cc-actions/cc-actions.component.html ***!
    \******************************************************************************************************************/

  /*! exports provided: default */

  /***/
  function _node_modules_rawLoader_dist_cjsJs_src_app_pages_home_cloudCost_ccActions_ccActionsComponentHtml(module, __webpack_exports__, __webpack_require__) {
    "use strict";

    __webpack_require__.r(__webpack_exports__);
    /* harmony default export */


    __webpack_exports__["default"] = "<div class=\"action-container\">\n     <app-cav-toolbar [heading]=\"'Action status'\" [showHeading]=\"true\" [showNumber]=\"false\"></app-cav-toolbar>\n\n    <div class=\"p-grid p-align-center p-justify-between border-all border-4 rounded-3 my-6 bg-neutral-100 d-bg-neutral-1100\">\n    \n    \n        <div class=\"inlind-flex p-col-fixed\">\n        <button pButton class=\"ui-button-secondary\" [class.active]=\"activeTab === 'Executed'\" (click)=\"setActiveTab('Executed')\">\n            Executed ({{ getCount('Executed') }})\n        </button>\n        <button pButton class=\"ui-button-secondary mx-6\" [class.active]=\"activeTab === 'Pending'\" (click)=\"setActiveTab('Pending')\">\n            Pending ({{ getCount('Pending') }})\n        </button>\n        <button pButton class=\"ui-button-secondary\" [class.active]=\"activeTab === 'Scheduled'\" (click)=\"setActiveTab('Scheduled')\">\n            Scheduled ({{ getCount('Scheduled') }})\n        </button>\n    </div>\n    \n    <div class=\"p-col-fixed inline-flex\">\n    <p-dropdown \n        [options]=\"cloudOptions\" \n        [(ngModel)]=\"selectedCloud\" \n        (onChange)=\"filterData()\" \n        placeholder=\"All Clouds\" \n        [style]=\"{'width':'220px'}\"\n        class=\"mr-6\"\n        appendTo=\"body\">\n    </p-dropdown>\n    \n    <p-dropdown \n        [options]=\"actionTypeOptions\" \n        [(ngModel)]=\"selectedActionType\" \n        (onChange)=\"filterData()\" \n        placeholder=\"All Actions\" \n        [style]=\"{'width':'220px'}\" \n        appendTo=\"body\">\n    </p-dropdown>\n    </div>\n\n    <div class=\"inline-flex font-14 p-col-fixed\">\n        <strong>Savings:  </strong> \n        <span>  $ {{ currentSavings }}/month</span>\n    </div>\n</div>\n\n    <div class=\"p-card\">\n        <div *ngIf=\"isLoading\" class=\"p-grid p-justify-center p-align-center\" style=\"height: calc(100vh - 280px); width: 100%;\">\n        <div class=\"text-center\">\n            <!-- PrimeNG Spinner Icon -->\n            <i class=\"pi pi-spin pi-spinner\" style=\"font-size: 3rem; color: #1C5391;\"></i>\n            <div class=\"mt-3 font-14\">Loading Actions...</div>\n        </div>\n    </div>\n        <cav-table *ngIf=\"!isLoading\" #ct \n            [value]=\"displayActions\" \n            [headers]=\"headers\" \n            [totalRecords]=\"displayActions?.length\" \n            [scrollHeight]=\"'calc(100vh - 280px)'\"\n            [tableConfig]=\"tableConfig\"\n            [paginator]=\"true\"\n            [first]=\"first\"\n            [rows]=\"rows\"\n            [rowsPerPageOptions]=\"[20,50,100,200,500]\"\n            [showCurrentPageReport]=\"true\" \n            (clickButtonEvent)=\"clickButtonEvent($event)\"\n            (clickRefresh)=\"onRefreshData()\">\n        </cav-table>\n    </div>\n\n</div>\n\n\n<app-cc-action-sidebar\n        [(visible)]=\"showDetailsDialog\"\n        [isVpa]=\"sidebarData.isVpa\"\n        [vpaRecommendations]=\"sidebarData.vpaRecommendations\"\n        [vpaConfig]=\"sidebarData.vpaConfig\"\n        [instanceScale]=\"sidebarData.instanceScale\"\n        [instanceDelete]=\"sidebarData.instanceDelete\"\n        [volumeScale]=\"sidebarData.volumeScale\"\n        [volumeDelete]=\"sidebarData.volumeDelete\"\n        \n        [instanceActionHeader]=\"sidebarData.header\"\n        [volumeActionHeader]=\"sidebarData.header\" \n        \n        [action]=\"sidebarData.actionEssentials\"\n        \n        [instanceDetails]=\"sidebarData.details\"\n        [volumeDetails]=\"sidebarData.details\"\n        \n        [instanceCost]=\"sidebarData.costImpact\"\n        [volumeCost]=\"sidebarData.costImpact\"\n        \n        [instanceResource]=\"sidebarData.resourceImpact\"\n        [volumeResource]=\"sidebarData.resourceImpact\"\n        \n        [chartOptions]=\"chartOptions\"\n        [enableActionExecute]=\"enableActionExecute\"\n        (executeAction)=\"onSidebarExecute()\">\n    </app-cc-action-sidebar>\n";
    /***/
  },

  /***/
  "./node_modules/raw-loader/dist/cjs.js!./src/app/pages/home/cloud-cost/common-component/cc-action-sidebar/cc-action-sidebar.component.html":
  /*!*************************************************************************************************************************************************!*\
    !*** ./node_modules/raw-loader/dist/cjs.js!./src/app/pages/home/cloud-cost/common-component/cc-action-sidebar/cc-action-sidebar.component.html ***!
    \*************************************************************************************************************************************************/

  /*! exports provided: default */

  /***/
  function _node_modules_rawLoader_dist_cjsJs_src_app_pages_home_cloudCost_commonComponent_ccActionSidebar_ccActionSidebarComponentHtml(module, __webpack_exports__, __webpack_require__) {
    "use strict";

    __webpack_require__.r(__webpack_exports__);
    /* harmony default export */


    __webpack_exports__["default"] = "<p-sidebar [(visible)]=\"visible\" appendTo=\"body\" [baseZIndex]=\"99999\" position=\"right\" [showCloseIcon]=\"false\"\n  [style]=\"{ width: '75%' }\">\n  <div class=\"sidebar-header\">\n    <div class=\"sidebar-title p-grid p-align-center p-justify-between\">\n      <div class=\"text-lg font-semibold\" style=\"border-bottom: 1px gray;\">Action event</div>\n      <button type=\"button\" (click)=\"onClose()\" pButton class=\"btn-icon btn-white\" icon=\"pi pi-times\">\n      </button>\n    </div>\n  </div>\n\n  <div class=\"sidebar-body-content p-6 p-grid\" style=\"max-height: calc(100vh - 90px); overflow-y: auto;\">\n    <div *ngIf=\"instanceScale && !isVpa\"\n      class=\"p-grid w-100-p p-10 bg-secondary-100 d-bg-secondary-1200 bottom-border border-5 font-weight-600 font-14\">\n      Scale Instance {{instanceActionHeader?.name || ''}} from {{instanceActionHeader?.from || ''}} to\n      {{instanceActionHeader?.to || ''}} , cost Impact: ${{instanceActionHeader?.saving||' '}}\n\n    </div>\n    <div *ngIf=\"instanceDelete\"\n      class=\"p-grid w-100-p p-10 bg-secondary-100 d-bg-secondary-1200 bottom-border border-5 font-weight-600 font-14\">\n      Delete Instance {{instanceActionHeader?.name || ''}} , cost Saving: ${{instanceActionHeader?.saving||' '}}\n\n    </div>\n    <div *ngIf=\"volumeScale\"\n      class=\"p-grid w-100-p p-10 bg-secondary-100 d-bg-secondary-1200 bottom-border border-5 font-weight-600 font-14\">\n      Scale Volume {{volumeActionHeader?.name || ''}} from {{volumeActionHeader?.from || ''}} to\n      {{volumeActionHeader?.to || ''}} , cost Saving: ${{volumeActionHeader?.saving||' '}}\n\n    </div>\n    <div *ngIf=\"volumeDelete\"\n      class=\"p-grid w-100-p p-10 bg-secondary-100 d-bg-secondary-1200 bottom-border border-5 font-weight-600 font-14\">\n      Delete Volume {{volumeActionHeader?.name || ''}} , cost Saving: ${{volumeActionHeader?.saving||' '}}\n\n    </div>\n\n    <div *ngIf=\"(instanceScale) && chartOptions\" class=\"sidebar-body p-col overflow-y-auto\">\n      <p class=\"text-sm text-gray-600 mb-3\">\n        CPU Utilization\n      </p>\n\n      <div class=\"p-card p-4 shadow-md rounded-xl\">\n        <highcharts-chart [Highcharts]=\"Highcharts\" [options]=\"chartOptions\"\n          style=\"width: 100%; height: 400px; display: block;\">\n        </highcharts-chart>\n      </div>\n    </div>\n    <div *ngIf=\"(volumeScale) && chartOptions\" class=\"sidebar-body p-col overflow-y-auto\">\n      <p class=\"text-sm text-gray-600 mb-3\">\n        IOPS percentile and avg. utilization\n      </p>\n\n      <div class=\"p-card p-4 shadow-md rounded-xl\">\n        <highcharts-chart [Highcharts]=\"Highcharts\" [options]=\"chartOptions\"\n          style=\"width: 100%; height: 400px; display: block;\">\n        </highcharts-chart>\n      </div>\n    </div>\n    <div class=\"p-col\" style=\"max-height: calc(100vh - 130px); overflow:auto\">\n\n\n      <div class=\"mb-6\">\n        <!-- <div class=\"ui-table-caption ui-widget-header height-32 p-grid p-align-center\">\n          Action Essentials\n          </div> -->\n          <div *ngIf=\"!isVpa\">\n        <cav-table [value]=\"action\" [headerRelativePath]=\"'cloud_cost_visibility/cc-recommendationAction.json'\"\n          [scrollable]=\"true\" scrollHeight=\"flex\"></cav-table>\n          </div>\n      </div>\n\n      <div class=\"mb-6\" *ngIf=\"volumeScale || volumeDelete\">\n        <!-- <div class=\"ui-table-caption ui-widget-header height-32 p-grid p-align-center\">\n            Volume Details\n            </div> -->\n        <cav-table [value]=\"volumeDetails\"\n          [headerRelativePath]=\"'cloud_cost_visibility/ccRecommendationActionDetails.json'\"\n          [scrollable]=\"true\"></cav-table>\n      </div>\n\n      <div class=\"mb-6\" *ngIf=\"(instanceScale || instanceDelete)&&!isVpa\">\n        <!-- <div class=\"ui-table-caption ui-widget-header height-32 p-grid p-align-center\">\n            Instance Details\n        </div> -->\n        <cav-table [value]=\"instanceDetails\"\n          [headerRelativePath]=\"'cloud_cost_visibility/ccRecommendationActionDetails.json'\"\n          [scrollable]=\"true\"></cav-table>\n      </div>\n    </div>\n\n    <div class=\"mb-6\">\n      <!-- <div class=\"ui-table-caption ui-widget-header height-32 p-grid p-align-center\">\n            Resource Impact\n          </div> -->\n      <div *ngIf=\"volumeScale || volumeDelete\">\n        <cav-table [value]=\"volumeResource\"\n          [headerRelativePath]=\"'cloud_cost_visibility/ccRecommendationActionResourceImpact.json'\"\n          [scrollable]=\"true\"></cav-table>\n      </div>\n\n      <div *ngIf=\"(instanceScale || instanceDelete) && !isVpa\">\n        <cav-table [value]=\"instanceResource\"\n          [headerRelativePath]=\"'cloud_cost_visibility/ccRecommendationActionResourceImpact.json'\"\n          [scrollable]=\"true\"></cav-table>\n      </div>\n    </div>\n\n    <div class=\"mb-6\">\n      <!-- <div class=\"ui-table-caption ui-widget-header height-32 p-grid p-align-center\">\n            Cost Impact\n          </div> -->\n      <div *ngIf=\"volumeScale || volumeDelete\">\n        <cav-table [value]=\"volumeCost\" [headerRelativePath]=\"'cloud_cost_visibility/ccRecommendationActionCost.json'\"\n          [scrollable]=\"true\"></cav-table>\n      </div>\n\n      <div *ngIf=\"(instanceScale || instanceDelete) && !isVpa\">\n        <cav-table [value]=\"instanceCost\" [headerRelativePath]=\"'cloud_cost_visibility/ccRecommendationActionCost.json'\"\n          [scrollable]=\"true\"></cav-table>\n      </div>\n    </div>\n    <div *ngIf=\"isVpa\" class=\"p-grid mb-6\">\n      <!-- <div class=\"p-grid mb-6\"> -->\n        <div class=\"p-col-6\">\n          <!-- <div class=\"ui-table-caption ui-widget-header height-32 p-grid p-align-center\">Action Essentials</div> -->\n          <cav-table [value]=\"action\" [headerRelativePath]=\"'cloud_cost_visibility/cc-recommendationAction.json'\" [scrollable]=\"true\" scrollHeight=\"flex\"></cav-table>\n        </div>\n\n        <div class=\"p-col-6\">\n          <!-- <div class=\"ui-table-caption ui-widget-header height-32 p-grid p-align-center\">Details</div> -->\n          <div *ngIf=\"volumeScale || volumeDelete\">\n            <cav-table [value]=\"volumeDetails\" [headerRelativePath]=\"'cloud_cost_visibility/ccRecommendationActionDetails.json'\" [scrollable]=\"true\"></cav-table>\n          </div>\n          <div *ngIf=\"instanceScale || instanceDelete\">\n            <cav-table [value]=\"instanceDetails\" [headerRelativePath]=\"'cloud_cost_visibility/ccRecommendationActionDetails.json'\" [scrollable]=\"true\"></cav-table>\n          </div>\n        </div>\n        <div class=\"p-col-12\">\n          <!-- <div class=\"ui-table-caption ui-widget-header height-32 p-grid p-align-center\">VPA Recommendations</div> -->\n          <cav-table [value]=\"vpaRecommendations\"\n            [headerRelativePath]=\"'cloud_cost_visibility/ccVpaRecommendationHeader.json'\"\n            [scrollable]=\"true\"></cav-table>\n        </div>\n      <!-- </div> -->\n      <!-- <div *ngIf=\"(instanceScale || instanceDelete) && !isVpa\">\n        <div class=\"ui-table-caption ui-widget-header height-32 p-grid p-align-center\">Resource Impact</div>\n        <cav-table [value]=\"instanceResource\"\n          [headerRelativePath]=\"'cloud_cost_visibility/ccRecommendationActionResourceImpact.json'\"\n          [scrollable]=\"true\"></cav-table>\n      </div> -->\n\n        <!-- <div class=\"mb-4\">\n          <div class=\"ui-table-caption ui-widget-header height-32 p-grid p-align-center\">VPA Configuration</div>\n          <cav-table [value]=\"vpaConfig\" [headerRelativePath]=\"'cloud_cost_visibility/ccVpaConfigHeader.json'\"\n            [scrollable]=\"true\"></cav-table>\n        </div> -->\n    </div>\n  </div>\n  <!-- </div> -->\n\n  <div *ngIf=\"!isVpa && enableActionExecute\" class=\"sidebar-footer p-3 p-grid p-justify-end top-border border-3 bg-neutral-100 d-bg-neutral-1500\">\n    <button pButton type=\"button\" label=\"Execute Action\" (click)=\"onExecuteAction()\" class=\"p-button-success\"\n      icon=\"pi pi-check\"></button>\n  </div>\n</p-sidebar>";
    /***/
  },

  /***/
  "./src/app/pages/home/cloud-cost/cc-actions/cc-actions.component.scss":
  /*!****************************************************************************!*\
    !*** ./src/app/pages/home/cloud-cost/cc-actions/cc-actions.component.scss ***!
    \****************************************************************************/

  /*! exports provided: default */

  /***/
  function _src_app_pages_home_cloudCost_ccActions_ccActionsComponentScss(module, __webpack_exports__, __webpack_require__) {
    "use strict";

    __webpack_require__.r(__webpack_exports__);
    /* harmony default export */


    __webpack_exports__["default"] = "";
    /***/
  },

  /***/
  "./src/app/pages/home/cloud-cost/cc-actions/cc-actions.component.ts":
  /*!**************************************************************************!*\
    !*** ./src/app/pages/home/cloud-cost/cc-actions/cc-actions.component.ts ***!
    \**************************************************************************/

  /*! exports provided: CcActionsComponent */

  /***/
  function _src_app_pages_home_cloudCost_ccActions_ccActionsComponentTs(module, __webpack_exports__, __webpack_require__) {
    "use strict";

    __webpack_require__.r(__webpack_exports__);
    /* harmony export (binding) */


    __webpack_require__.d(__webpack_exports__, "CcActionsComponent", function () {
      return CcActionsComponent;
    });
    /* harmony import */


    var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(
    /*! tslib */
    "./node_modules/tslib/tslib.es6.js");
    /* harmony import */


    var _angular_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(
    /*! @angular/core */
    "./node_modules/@angular/core/__ivy_ngcc__/fesm2015/core.js");
    /* harmony import */


    var src_app_shared_cav_table_service_cav_table_constant__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(
    /*! src/app/shared/cav-table/service/cav-table.constant */
    "./src/app/shared/cav-table/service/cav-table.constant.ts");
    /* harmony import */


    var src_app_shared_cav_toast_service_cav_message_service__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(
    /*! src/app/shared/cav-toast/service/cav-message.service */
    "./src/app/shared/cav-toast/service/cav-message.service.ts");
    /* harmony import */


    var _service_cc_actions_state__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(
    /*! ./service/cc-actions.state */
    "./src/app/pages/home/cloud-cost/cc-actions/service/cc-actions.state.ts");
    /* harmony import */


    var highcharts__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(
    /*! highcharts */
    "./node_modules/highcharts/highcharts.js");
    /* harmony import */


    var highcharts__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(highcharts__WEBPACK_IMPORTED_MODULE_5__);
    /* harmony import */


    var _service_cc_actions_service__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(
    /*! ./service/cc-actions.service */
    "./src/app/pages/home/cloud-cost/cc-actions/service/cc-actions.service.ts");
    /* harmony import */


    var src_app_core_session_session_service__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(
    /*! src/app/core/session/session.service */
    "./src/app/core/session/session.service.ts"); // Ensure these are imported
    // 1. IMPORT SERVICE AND STATE


    var CcActionsComponent = /*#__PURE__*/function () {
      // 2. INJECT SERVICE (Must use 'private')
      function CcActionsComponent(ccActionsService, messageService, sessionService) {
        _classCallCheck(this, CcActionsComponent);

        this.ccActionsService = ccActionsService;
        this.messageService = messageService;
        this.sessionService = sessionService; // Data Variables

        this.allActions = [];
        this.displayActions = [];
        this.headers = [];
        this.isLoading = false; // State

        this.activeTab = 'Executed';
        this.selectedCloud = null;
        this.selectedActionType = null;
        this.searchQuery = ''; // Dropdown Options
        // 1. Initialize with ONLY the default option

        this.cloudOptions = [{
          label: 'All Clouds',
          value: null
        }];
        this.actionTypeOptions = [{
          label: 'All Actions',
          value: null
        }]; // Modal State

        this.showDetailsDialog = false;
        this.selectedAction = null; // Sidebar Data State

        this.Highcharts = highcharts__WEBPACK_IMPORTED_MODULE_5__;
        this.chartOptions = null;
        this.selectedRowForSidebar = null;
        this.first = {
          first: 0
        };
        this.rows = {
          rows: 20
        };
        this.sidebarData = {
          instanceScale: false,
          instanceDelete: false,
          volumeScale: false,
          volumeDelete: false,
          isVpa: false,
          header: {},
          actionEssentials: [],
          details: [],
          resourceImpact: [],
          costImpact: [],
          vpaRecommendations: [],
          vpaConfig: [] // Table 2: name, min, max

        };
        this.enableActionExecute = true;
      }

      return _createClass(CcActionsComponent, [{
        key: "populateFilters",
        value: function populateFilters() {
          var _this = this;

          // --- FIX: Use 'uiStatus' instead of 'status' ---
          // Your tabs are based on uiStatus (Pending, Scheduled, Executed)
          var tabData = this.allActions.filter(function (item) {
            return item.uiStatus === _this.activeTab;
          }); // 2. Extract Unique Clouds from THIS tab's data

          var uniqueClouds = _toConsumableArray(new Set(tabData.map(function (item) {
            return item.cloud;
          }).filter(function (c) {
            return c;
          })));

          this.cloudOptions = [{
            label: 'All Clouds',
            value: null
          }].concat(_toConsumableArray(uniqueClouds.map(function (cloud) {
            return {
              label: cloud,
              value: cloud
            };
          }))); // 3. Extract Unique Actions from THIS tab's data

          var uniqueActions = _toConsumableArray(new Set(tabData.map(function (item) {
            return item.action;
          }).filter(function (a) {
            return a;
          })));

          this.actionTypeOptions = [{
            label: 'All Actions',
            value: null
          }].concat(_toConsumableArray(uniqueActions.map(function (action) {
            return {
              label: action,
              value: action
            };
          })));
        }
      }, {
        key: "ngOnInit",
        value: function ngOnInit() {
          // 3. FETCH REAL DATA INSTEAD OF MOCK
          this.fetchDataFromDB(false);
          this.updateColumns('Executed');
          this.updateTableConfig('Executed');
          console.log("==========================================", this.allActions);
        } // --- DATA FETCHING ---

      }, {
        key: "fetchDataFromDB",
        value: function fetchDataFromDB() {
          var _this2 = this;

          var isSilent = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
          this.ccActionsService.getActions().subscribe(function (state) {
            // 1. Handle LOADING
            if (state instanceof _service_cc_actions_state__WEBPACK_IMPORTED_MODULE_4__["CcActionsLoadingState"]) {
              if (!isSilent) {
                _this2.isLoading = true; //[cite: 1]
              }

              return; // Stop here, wait for next emission
            } // 2. Handle LOADED (Success)


            if (state instanceof _service_cc_actions_state__WEBPACK_IMPORTED_MODULE_4__["CcActionsLoadedState"]) {
              // this.isLoading = false;
              _this2.allActions = state.data;

              _this2.allActions.forEach(function (item) {
                var _a;

                if (item.actionMode === 'PENDING') item.uiStatus = 'Pending';
                if (item.actionMode === 'EXECUTED') item.uiStatus = 'Executed';
                if (item.actionMode === 'SCHEDULED') item.uiStatus = 'Scheduled';

                if (item.action === "DeleteInstance") {
                  item.description = 'Recommendation: Delete Instance';
                } else if (item.action === "StopVm") {
                  item.description = 'Recommendation: Stop Instance';
                } else {
                  var recommendation = _this2.createRecommendation((_a = item === null || item === void 0 ? void 0 : item.details) === null || _a === void 0 ? void 0 : _a.optimalConfig);

                  recommendation = recommendation.replace(/[{}]/g, '');
                  item.description = 'Recommendation: ' + recommendation;
                }

                item.timestamp = _this2.sessionService.convertFormattedStringIntoTimestamp(item.timestamp, 'YYYY-MM-DD “T” hh:mm:ss.SSSZ');
              });

              _this2.ccActionsService.getKubOptActions().subscribe(function (state) {
                if (state instanceof _service_cc_actions_state__WEBPACK_IMPORTED_MODULE_4__["CcActionsLoadedState"]) {
                  // Merge Kubernetes data into allActions
                  var data = state.data.map(function (item) {
                    var _a, _b;

                    if (item.source === 'VPA_RECOMMENDER' && item.recommendation) {
                      var cpuTarget = ((_a = item.recommendation.cpu) === null || _a === void 0 ? void 0 : _a.target) || '--';
                      var memTarget = ((_b = item.recommendation.memory) === null || _b === void 0 ? void 0 : _b.target) || '--'; // Format the recommendation into a readable string for the table

                      item.description = "VPA Recommendation: CPU Target: ".concat(cpuTarget, ", Memory Target: ").concat(memTarget);
                    }

                    item.timestamp = _this2.sessionService.convertFormattedStringIntoTimestamp(item.timestamp, 'YYYY-MM-DD “T” hh:mm:ss.SSSZ');
                    return item;
                  }); // Merge formatted Kubernetes data into allActions

                  _this2.allActions = [].concat(_toConsumableArray(_this2.allActions), _toConsumableArray(data)); //this.allActions = [...this.allActions, ...state.data];

                  _this2.populateFilters();

                  if (_this2.activeTab === 'Scheduled') {
                    _this2.updateColumns('Scheduled');

                    _this2.updateTableConfig('Scheduled');
                  }

                  _this2.filterData();

                  if (!isSilent) {
                    _this2.isLoading = false; //[cite: 1]
                  }
                }
              }); // this.populateFilters();
              // if (this.activeTab === 'Scheduled') {
              //     this.updateColumns('Scheduled');
              //     this.updateTableConfig('Scheduled');
              // }
              // this.filterData();

            }
          }, function (errorState) {
            // 3. Handle ERROR
            _this2.isLoading = false; // If the service sends CcActionsErrorState via the error channel

            if (errorState instanceof _service_cc_actions_state__WEBPACK_IMPORTED_MODULE_4__["CcActionsErrorState"]) {
              _this2.messageService.add({
                severity: 'error',
                summary: 'Error',
                detail: 'Failed to fetch actions'
              });
            } else {
              console.error(errorState);
            }
          });
        } // --- COLUMNS CONFIG ---

      }, {
        key: "updateColumns",
        value: function updateColumns(tabName) {
          var cols = [{
            label: 'Time',
            key: 'timestamp',
            type: src_app_shared_cav_table_service_cav_table_constant__WEBPACK_IMPORTED_MODULE_2__["Type"].TIME_STAMP,
            width: '10%'
          }, {
            label: 'ResourceId',
            key: 'resourceId',
            type: src_app_shared_cav_table_service_cav_table_constant__WEBPACK_IMPORTED_MODULE_2__["Type"].STRING,
            width: '15%'
          }, //{ label: 'Cloud', key: 'cloud', type: Type.STRING, width: '10%' },
          {
            label: 'Datasource',
            key: 'dataSourceName',
            type: src_app_shared_cav_table_service_cav_table_constant__WEBPACK_IMPORTED_MODULE_2__["Type"].STRING,
            width: '12%'
          }, {
            label: 'Resource',
            key: 'resource',
            type: src_app_shared_cav_table_service_cav_table_constant__WEBPACK_IMPORTED_MODULE_2__["Type"].STRING,
            width: '12%'
          }, {
            label: 'Description',
            key: 'description',
            type: src_app_shared_cav_table_service_cav_table_constant__WEBPACK_IMPORTED_MODULE_2__["Type"].STRING,
            width: '20%'
          }, {
            label: 'Action',
            key: 'action',
            type: src_app_shared_cav_table_service_cav_table_constant__WEBPACK_IMPORTED_MODULE_2__["Type"].STRING,
            width: '15%'
          }, {
            label: 'Status',
            key: 'status',
            type: src_app_shared_cav_table_service_cav_table_constant__WEBPACK_IMPORTED_MODULE_2__["Type"].STRING,
            width: '10%'
          }];

          if (tabName === 'Scheduled') {
            cols.push({
              label: 'Scheduled Time',
              key: 'scheduledTime',
              type: src_app_shared_cav_table_service_cav_table_constant__WEBPACK_IMPORTED_MODULE_2__["Type"].STRING,
              width: '15%'
            });
          }

          cols.push({
            label: 'Savings ($)',
            key: 'savings',
            type: src_app_shared_cav_table_service_cav_table_constant__WEBPACK_IMPORTED_MODULE_2__["Type"].NUMBER,
            width: '10%'
          });
          cols.push({
            label: 'Actions',
            key: 'actions',
            type: src_app_shared_cav_table_service_cav_table_constant__WEBPACK_IMPORTED_MODULE_2__["Type"].ACTION,
            width: '160px'
          });
          this.headers = [{
            cols: cols
          }];
        } // --- BUTTONS CONFIG ---

      }, {
        key: "updateTableConfig",
        value: function updateTableConfig(tabName) {
          var actions = [];

          if (tabName === 'Executed') {
            this.enableActionExecute = false;
            actions = [{
              iconType: 'icon',
              iconClass: 'pi pi-file',
              toolTip: 'View Details',
              action: 'openActionSidebar',
              needRowData: true
            }];
          } else if (tabName === 'Pending') {
            this.enableActionExecute = true;
            actions = [{
              iconType: 'icon',
              iconClass: 'pi pi-check',
              toolTip: 'Approve',
              action: 'approve',
              needRowData: true
            }, {
              iconType: 'icon',
              iconClass: 'pi pi-times',
              toolTip: 'Reject',
              action: 'reject',
              needRowData: true
            }, {
              iconType: 'icon',
              iconClass: 'pi pi-file',
              toolTip: 'View Details',
              action: 'openActionSidebar',
              needRowData: true
            }];
          } else if (tabName === 'Scheduled') {
            this.enableActionExecute = false;
            actions = [{
              iconType: 'icon',
              iconClass: 'pi pi-play',
              toolTip: 'Execute Now',
              action: 'executeNow',
              needRowData: true
            }, {
              iconType: 'icon',
              iconClass: 'pi pi-times',
              toolTip: 'Cancel',
              action: 'cancel',
              needRowData: true
            }, {
              iconType: 'icon',
              iconClass: 'pi pi-file',
              toolTip: 'View Details',
              action: 'openActionSidebar',
              needRowData: true
            }];
          }

          this.tableConfig = {
            config: {
              globalFilter: true,
              toggleFilter: true,
              toggleColumn: true,
              tableName: 'Actions Table'
            },
            rowAction: {
              rightAction: actions
            },
            tableAction: [{
              iconType: 'icon',
              iconClass: 'icons8 icons8-synchronize',
              toolTip: 'Refresh Data',
              action: 'refresh',
              needRowData: false
            }]
          };
        } // --- TABS & EVENTS ---

      }, {
        key: "setActiveTab",
        value: function setActiveTab(tab) {
          this.activeTab = tab; // 1. RESET Filters when switching tabs (Important!)

          this.selectedCloud = null;
          this.selectedActionType = null;
          this.searchQuery = ''; // Optional: clear search text too
          // 2. Recalculate Dropdown Options for the new tab

          this.populateFilters(); // 3. Standard updates

          this.updateColumns(tab);
          this.updateTableConfig(tab);
          this.filterData();
        }
      }, {
        key: "clickButtonEvent",
        value: function clickButtonEvent(event) {
          var actionName = event.cavEventExt.actionConfig.action;
          var rowData = event.cavEventExt.row;
          console.log("Action Clicked:", actionName); // Debug log

          console.log("rowData :", rowData); // Debug log
          // 1. UPDATE THIS CHECK

          if (actionName === 'openActionSidebar') {
            this.openDetails(rowData);
          } // 2. Existing logic for Approve/Execute
          else if (actionName === 'approve' || actionName === 'executeNow') {
            this.onExecuteAction(rowData);
          }
        }
      }, {
        key: "onExecuteAction",
        value: function onExecuteAction(row) {
          var _this3 = this;

          if (!row || !row.id) return; // Remove manual logic: this.isLoading = true; 

          this.ccActionsService.executeAction(row.id).subscribe(function (state) {
            // 1. Use the State for Loading
            if (state instanceof _service_cc_actions_state__WEBPACK_IMPORTED_MODULE_4__["CcActionsLoadingState"]) {
              _this3.isLoading = true;
              return;
            } // 2. Use the State for Success


            if (state instanceof _service_cc_actions_state__WEBPACK_IMPORTED_MODULE_4__["CcActionsLoadedState"]) {
              _this3.isLoading = false;

              _this3.messageService.add({
                severity: 'success',
                summary: 'Success',
                detail: 'Action Executed'
              });

              _this3.fetchDataFromDB();
            }
          }, function (error) {
            // 3. Handle Error
            _this3.isLoading = false;

            _this3.messageService.add({
              severity: 'error',
              summary: 'Error',
              detail: 'Failed to execute action'
            });
          });
        }
      }, {
        key: "filterData",
        value: function filterData() {
          var _this4 = this;

          this.displayActions = this.allActions.filter(function (item) {
            if (item.uiStatus !== _this4.activeTab) return false;
            if (_this4.selectedCloud && item.cloud !== _this4.selectedCloud) return false;
            if (_this4.selectedActionType && item.action !== _this4.selectedActionType) return false; //item.timestamp = (this.sessionService.convertFormattedStringIntoTimestamp(item.timestamp, 'YYYY-MM-DD “T” hh:mm:ss.SSSZ'));

            return true;
          });
        }
      }, {
        key: "getCount",
        value: function getCount(status) {
          return this.allActions.filter(function (a) {
            return a.uiStatus === status;
          }).length;
        }
      }, {
        key: "currentSavings",
        get: function get() {
          return this.displayActions.reduce(function (acc, curr) {
            return acc + (curr.savings || 0);
          }, 0).toFixed(3);
        } // --- 1. Helper Methods for Formatting ---

      }, {
        key: "formatDisplayName",
        value: function formatDisplayName(baseName) {
          return baseName.replace(/_/g, ' ').replace(/([a-z0-9])([A-Z])/g, '$1 $2').replace(/^./, function (s) {
            return s.toUpperCase();
          });
        }
      }, {
        key: "formatDisplayValue",
        value: function formatDisplayValue(key, value) {
          if (value === 'null' || value === undefined || value === '') return '--';
          var strValue = String(value);
          var lowerKey = key.toLowerCase(); // Add $ for cost fields if not already present

          if ((lowerKey.includes('cost') || lowerKey.includes('price') || lowerKey.includes('rate')) && !lowerKey.includes('type')) {
            return strValue.startsWith('$') ? strValue : '$' + strValue;
          }

          return strValue;
        } // --- 2. Logic for "Resource Impact" Table (Matches keys: name, current, after) ---
        // private HandleConfigClick(row: any) {
        //     const currentConf = row.details?.currentConfig || {};
        //     const recommendConf = row.details?.optimalConfig || {};
        //     const processedData = new Map<string, { name: string, current: string, after: string }>();
        //     // Process Current
        //     for (const key in currentConf) {
        //         const baseName = key.replace(/^(current_|core_|current)/, '');
        //         const displayName = this.formatDisplayName(baseName);
        //         const value = this.formatDisplayValue(key, currentConf[key]);
        //         processedData.set(baseName, {
        //             name: displayName,
        //             current: value,
        //             after: '--'
        //         });
        //     }
        //     // Process Recommended
        //     for (const key in recommendConf) {
        //         const baseName = key.replace(/^(recommend_|recommended_|recommend|target)/, '');
        //         const value = this.formatDisplayValue(key, recommendConf[key]);
        //         if (processedData.has(baseName)) {
        //             const entry = processedData.get(baseName)!;
        //             entry.after = value;
        //         } else {
        //             processedData.set(baseName, {
        //                 name: this.formatDisplayName(baseName),
        //                 current: '--',
        //                 after: value
        //             });
        //         }
        //     }
        //     return Array.from(processedData.values());
        // }

      }, {
        key: "HandleConfigClick",
        value: function HandleConfigClick(row) {
          var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p; // --- NEW: Handle VPA Specific Data ---


          if (row.source === 'VPA' || row.recommendation) {
            return [{
              name: "CPU Request",
              current: ((_a = row.vpaConfig) === null || _a === void 0 ? void 0 : _a.minCpu) || '--',
              after: ((_c = (_b = row.recommendation) === null || _b === void 0 ? void 0 : _b.cpu) === null || _c === void 0 ? void 0 : _c.target) || '--'
            }, {
              name: "Memory Request",
              current: ((_d = row.vpaConfig) === null || _d === void 0 ? void 0 : _d.minMemory) || '--',
              after: ((_f = (_e = row.recommendation) === null || _e === void 0 ? void 0 : _e.memory) === null || _f === void 0 ? void 0 : _f.target) || '--'
            }, {
              name: "CPU Upper Bound",
              current: ((_g = row.vpaConfig) === null || _g === void 0 ? void 0 : _g.maxCpu) || '--',
              after: ((_j = (_h = row.recommendation) === null || _h === void 0 ? void 0 : _h.cpu) === null || _j === void 0 ? void 0 : _j.upper) || '--'
            }, {
              name: "Memory Upper Bound",
              current: ((_k = row.vpaConfig) === null || _k === void 0 ? void 0 : _k.maxMemory) || '--',
              after: ((_m = (_l = row.recommendation) === null || _l === void 0 ? void 0 : _l.memory) === null || _m === void 0 ? void 0 : _m.upper) || '--'
            }];
          } // --- Existing Cloud Logic ---


          var currentConf = ((_o = row.details) === null || _o === void 0 ? void 0 : _o.currentConfig) || {};
          var recommendConf = ((_p = row.details) === null || _p === void 0 ? void 0 : _p.optimalConfig) || {};
          var processedData = new Map();

          for (var key in currentConf) {
            var baseName = key.replace(/^(current_|core_|current)/, '');
            var displayName = this.formatDisplayName(baseName);
            var value = this.formatDisplayValue(key, currentConf[key]);
            processedData.set(baseName, {
              name: displayName,
              current: value,
              after: '--'
            });
          }

          for (var _key in recommendConf) {
            var _baseName = _key.replace(/^(recommend_|recommended_|recommend|target)/, '');

            var _value = this.formatDisplayValue(_key, recommendConf[_key]);

            if (processedData.has(_baseName)) {
              var entry = processedData.get(_baseName);
              entry.after = _value;
            } else {// processedData.set(baseName, {
              //     name: this.formatDisplayName(baseName),
              //     current: '--',
              //     after: value
              // });
            }
          }

          return Array.from(processedData.values());
        } // --- 3. Main Open Method ---
        // openDetails(row: any) {
        //     this.selectedRowForSidebar = row;
        //     const strategy = (
        //         row.action ||
        //         ''
        //     ).toLowerCase();
        //     this.sidebarData.instanceScale = false;
        //     this.sidebarData.instanceDelete = false;
        //     this.sidebarData.volumeScale = false;
        //     this.sidebarData.volumeDelete = false;
        //     if (strategy.includes('deletevolume')) {
        //         this.sidebarData.volumeDelete = true;
        //     }
        //     else if (strategy.includes('migratevolume') || strategy.includes('volumerightsizing')) {
        //         this.sidebarData.volumeScale = true;
        //     }
        //     else if (
        //         strategy.includes('migrateinstance') ||
        //         strategy.includes('resizevm') ||
        //         strategy.includes('rightsizing')
        //     ) {
        //         this.sidebarData.instanceScale = true;
        //     }
        //     else if (strategy.includes('deleteinstance')) {
        //         this.sidebarData.instanceDelete = true;
        //     }
        //     // --- C. Set Helpers based on YOUR flags ---
        //     // We use the flags you just set to determine labels/formatting
        //     const isVolume = this.sidebarData.volumeDelete || this.sidebarData.volumeScale;
        //     const isDelete = this.sidebarData.volumeDelete || this.sidebarData.instanceDelete;
        //     // --- D. Extract Dynamic Specs ---
        //     const currentConf = row.details?.currentConfig || {};
        //     const optimalConf = row.details?.optimalConfig || {};
        //     // Look for volume keys if isVolume is true, otherwise instance keys
        //     const currentSpec = isVolume
        //         ? (
        //             currentConf.current_volume_type ||
        //             currentConf.volumeType ||
        //             '-'
        //         )
        //         : (
        //             currentConf.currentInstanceType ||
        //             currentConf.instanceType ||
        //             '-'
        //         );
        //     const optimalSpec = isVolume
        //         ? (
        //             optimalConf.recommend_volume_type ||
        //             optimalConf.targetVolumeType ||
        //             optimalConf.volumeType ||
        //             '-'
        //         )
        //         : (
        //             optimalConf.targetInstanceType ||
        //             optimalConf.instanceType ||
        //             '-'
        //         );
        //     // --- E. Populate Header ---
        //     this.sidebarData.header = {
        //         name: row.resource,
        //         from: currentSpec,
        //         to: isDelete ? 'Deleted' : optimalSpec,
        //         // Fix: Check for null, convert to number, fix to 2 decimals
        //         saving: (row.savings !== null && row.savings !== undefined) ? Number(row.savings).toFixed(2) : '--'
        //     };
        //     // --- F. Action Essentials (Matches JSON: name, value) ---
        //     this.sidebarData.actionEssentials = [
        //         { name: "Action Type", value: row.action || '--' },
        //         { name: "Cloud", value: row.cloud || '--' },
        //         { name: "Resource Name", value: row.resource || '--' },
        //         { name: "Status", value: row.uiStatus || '--' },
        //         { name: "State", value: row.actionMode || '--' }
        //     ];
        //     // --- G. Details Table (Matches JSON: name, value) ---
        //     // Dynamic Label: "Volume Type" or "Instance Type"
        //     const typeLabel = isVolume ? "Volume Type" : "Instance Type";
        //     this.sidebarData.details = [
        //         { name: "Name", value: row.resource || '--' },
        //         { name: "ID", value: row.resourceId || row.id || '--' },
        //         { name: "Region", value: row.region || "--" }, // Replace if you have row.region
        //         { name: "Current " + typeLabel, value: currentSpec },
        //         { name: "Recommended " + typeLabel, value: isDelete ? 'N/A' : optimalSpec }
        //     ];
        //     // --- H. Cost Impact (Matches JSON: name, current, after, saving) ---
        //     this.sidebarData.costImpact = [
        //         {
        //             name: "On demand rate ($/1 Hour)",
        //             current: row.cmcRatePerUnit != null ? Number(row.cmcRatePerUnit).toFixed(3) : "--",
        //             after: row.omcRatePerUnit != null ? Number(row.omcRatePerUnit).toFixed(3) : "--",
        //             saving: row.savings != null ? Number(row.savings).toFixed(2) : "--"
        //         },
        //         {
        //             name: "On demand cost ($)",
        //             current: row.cmc != null ? Number(row.cmc).toFixed(2) : "--",
        //             after: isDelete ? "0.00" : (row.omc != null ? Number(row.omc).toFixed(2) : "--"),
        //             saving: row.savings != null ? Number(row.savings).toFixed(2) : "--"
        //         }
        //     ];
        //     // --- I. Resource Impact (Matches JSON: name, current, after) ---
        //     this.sidebarData.resourceImpact = this.HandleConfigClick(row);
        //     this.chartOptions = null;
        //     // --- J. Show Sidebar ---
        //     this.showDetailsDialog = true;
        // }

      }, {
        key: "openDetails",
        value: function openDetails(row) {
          var _this5 = this;

          var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;

          this.selectedRowForSidebar = row; // 1. Force a clean state for the dialog

          this.showDetailsDialog = false;
          var isVpa = row.source === 'VPA';
          this.sidebarData.isVpa = isVpa; // 2. Reset VPA tables so old data doesn't flicker

          this.sidebarData.vpaRecommendations = [];
          this.sidebarData.vpaConfig = [];
          var strategy = (row.action || '').toLowerCase(); // Reset sidebar flags

          this.sidebarData.instanceScale = false;
          this.sidebarData.instanceDelete = false;
          this.sidebarData.volumeScale = false;
          this.sidebarData.volumeDelete = false;

          if (isVpa) {
            this.sidebarData.instanceScale = true; // Use instance layout
            // 1. Header for VPA

            this.sidebarData.header = {
              name: row.resource || row.workload,
              from: "".concat(((_a = row.vpaConfig) === null || _a === void 0 ? void 0 : _a.minCpu) || '--', " / ").concat(((_b = row.vpaConfig) === null || _b === void 0 ? void 0 : _b.minMemory) || '--'),
              to: "".concat(((_d = (_c = row.recommendation) === null || _c === void 0 ? void 0 : _c.cpu) === null || _d === void 0 ? void 0 : _d.target) || '--', " / ").concat(((_f = (_e = row.recommendation) === null || _e === void 0 ? void 0 : _e.memory) === null || _f === void 0 ? void 0 : _f.target) || '--'),
              saving: row.savings != null ? Number(row.savings).toFixed(3) : '--'
            }; // 2. Recommendation Table (name, cpu, memory)

            var rec = row.recommendation || {};
            this.sidebarData.vpaRecommendations = [{
              name: 'Target',
              cpu: ((_g = rec.cpu) === null || _g === void 0 ? void 0 : _g.target) || '--',
              memory: ((_h = rec.memory) === null || _h === void 0 ? void 0 : _h.target) || '--'
            }, {
              name: 'Uncapped Target',
              cpu: ((_j = rec.cpu) === null || _j === void 0 ? void 0 : _j.uncappedTarget) || '--',
              memory: ((_k = rec.memory) === null || _k === void 0 ? void 0 : _k.uncappedTarget) || '--'
            }, {
              name: 'Lower Bound',
              cpu: ((_l = rec.cpu) === null || _l === void 0 ? void 0 : _l.lower) || '--',
              memory: ((_m = rec.memory) === null || _m === void 0 ? void 0 : _m.lower) || '--'
            }, {
              name: 'Upper Bound',
              cpu: ((_o = rec.cpu) === null || _o === void 0 ? void 0 : _o.upper) || '--',
              memory: this.formatVpaValue((_p = rec.memory) === null || _p === void 0 ? void 0 : _p.upper, 'memory')
            }]; // 3. VPA Config Table (name, min, max)

            var vpaConf = row.vpaConfig || {};
            this.sidebarData.vpaConfig = [{
              name: 'CPU',
              min: vpaConf.minCpu || '--',
              max: vpaConf.maxCpu || '--'
            }, {
              name: 'Memory',
              min: vpaConf.minMemory || '--',
              max: this.formatVpaValue(vpaConf.maxCpu, 'cpu')
            }]; // 4. Essentials & Details

            this.sidebarData.actionEssentials = [{
              name: "Action Type",
              value: row.action || '--'
            }, {
              name: "Cloud",
              value: row.cloud || '--'
            }, {
              name: "Data Source Name",
              value: row.dataSourceName || '--'
            }, {
              name: "Cluster",
              value: row.cluster_name || '--'
            }, {
              name: "Namespace",
              value: row.namespace || '--'
            }];
            this.sidebarData.details = [{
              name: "Workload",
              value: row.workload || '--'
            }, {
              name: "Container",
              value: rec.containerName || '--'
            }, {
              name: "VPA Mode",
              value: vpaConf.mode || '--'
            }, {
              name: "Time",
              value: this.sessionService.convertTimestampIntoFormattedString(this.sessionService.convertFormattedStringIntoTimestamp(row.time, 'YYYY-MM-DD “T” hh:mm:ss.SSSZ')) || '--'
            }];
            this.sidebarData.resourceImpact = []; // Don't show standard table

            this.sidebarData.costImpact = [{
              name: "Estimated Savings",
              current: '--',
              after: '--',
              saving: row.savings != null ? Number(row.savings).toFixed(3) : "--"
            }];
          } else {
            // --- EXISTING CLOUD RESOURCE BRANCH ---
            if (strategy.includes('deletevolume')) {
              this.sidebarData.volumeDelete = true;
            } else if (strategy.includes('migratevolume') || strategy.includes('volumerightsizing')) {
              this.sidebarData.volumeScale = true;
            } else if (strategy.includes('migrateinstance') || strategy.includes('resizevm') || strategy.includes('rightsizing')) {
              this.sidebarData.instanceScale = true;
            } else if (strategy.includes('deleteinstance')) {
              this.sidebarData.instanceDelete = true;
            }

            var isVolume = this.sidebarData.volumeDelete || this.sidebarData.volumeScale;
            var isDelete = this.sidebarData.volumeDelete || this.sidebarData.instanceDelete;
            var currentConf = ((_q = row.details) === null || _q === void 0 ? void 0 : _q.currentConfig) || {};
            var optimalConf = ((_r = row.details) === null || _r === void 0 ? void 0 : _r.optimalConfig) || {};
            var currentSpec = isVolume ? currentConf.current_volume_type || currentConf.volumeType || '-' : currentConf.currentInstanceType || currentConf.instanceType || '-';
            var optimalSpec = isVolume ? optimalConf.recommend_volume_type || optimalConf.targetVolumeType || '-' : optimalConf.targetInstanceType || optimalConf.instanceType || '-';
            this.sidebarData.header = {
              name: row.resource,
              from: currentSpec,
              to: isDelete ? 'Deleted' : optimalSpec,
              saving: row.savings != null ? Number(row.savings).toFixed(3) : '--'
            };
            this.sidebarData.actionEssentials = [{
              name: "Action Type",
              value: row.action || '--'
            }, {
              name: "Cloud",
              value: row.cloud || '--'
            }, {
              name: "Resource Name",
              value: row.resource || '--'
            }, {
              name: "Status",
              value: row.uiStatus || '--'
            }];
            var typeLabel = isVolume ? "Volume Type" : "Instance Type";
            this.sidebarData.details = [{
              name: "Name",
              value: row.resource || '--'
            }, {
              name: "ID",
              value: row.resourceId || row.id || '--'
            }, {
              name: "Region",
              value: row.region || "--"
            }, {
              name: "Current " + typeLabel,
              value: currentSpec
            }, {
              name: "Recommended " + typeLabel,
              value: isDelete ? 'N/A' : optimalSpec
            }];
            this.sidebarData.costImpact = [{
              name: "On demand rate ($/1 Hour)",
              current: row.cmcRatePerUnit != null ? Number(row.cmcRatePerUnit).toFixed(3) : "--",
              after: row.omcRatePerUnit != null ? Number(row.omcRatePerUnit).toFixed(3) : "--",
              saving: row.cmcRatePerUnit > 0 || row.omcRatePerUnit > 0 ? Number(row.cmcRatePerUnit - row.omcRatePerUnit).toFixed(3) : "--"
            }, {
              name: "On demand cost ($/month)",
              current: row.cmc != null ? Number(row.cmc).toFixed(3) : "--",
              after: isDelete ? "0.00" : row.omc != null ? Number(row.omc).toFixed(3) : "--",
              saving: row.savings != null ? Number(row.savings).toFixed(3) : "--"
            }];
          } // Resource impact is now handled dynamically in HandleConfigClick for both types


          this.sidebarData.resourceImpact = this.HandleConfigClick(row);
          this.chartOptions = null; //this.showDetailsDialog = true;

          setTimeout(function () {
            _this5.showDetailsDialog = true;
          }, 0);
        }
      }, {
        key: "formatVpaValue",
        value: function formatVpaValue(value, type) {
          if (value === null || value === undefined || value === '--') return '--'; // If it's already a string with units (e.g., "100m", "250Mi"), return it as is

          if (isNaN(value) && typeof value === 'string') return value;
          var num = parseFloat(value);
          if (isNaN(num)) return value;

          if (type === 'memory') {
            // Assume input is in Bytes if it's a large number without units
            if (num >= 1024 * 1024 * 1024) return (num / (1024 * 1024 * 1024)).toFixed(3) + ' Gi';
            if (num >= 1024 * 1024) return (num / (1024 * 1024)).toFixed(3) + ' Mi';
            if (num >= 1024) return (num / 1024).toFixed(3) + ' Ki';
            return num + ' B';
          } else {
            // CPU: If it's a small decimal (e.g., 0.5), convert to millicores (500m)
            if (num < 5 && num > 0) return Math.round(num * 1000) + 'm';
            return num.toString();
          }
        } // 2. Handle Execute button inside Sidebar

      }, {
        key: "onSidebarExecute",
        value: function onSidebarExecute() {
          if (this.selectedRowForSidebar) {
            this.showDetailsDialog = false; // Close sidebar

            this.onExecuteAction(this.selectedRowForSidebar); // Reuse existing execute logic
          }
        }
      }, {
        key: "createRecommendation",
        value: function createRecommendation(optimalConfig) {
          var result = {};
          Object.keys(optimalConfig).forEach(function (key) {
            var newKey = key;

            if (key.startsWith('recommended_')) {
              newKey = key.replace('recommended_', '');
              result[newKey] = optimalConfig[key];
            } else if (key.startsWith('recommend_')) {
              newKey = key.replace('recommend_', '');
              result[newKey] = optimalConfig[key];
            } //  else {
            //     // include other fields as-is
            //     result[key] = optimalConfig[key];
            // }

          });
          return JSON.stringify(result);
        }
      }, {
        key: "onRefreshData",
        value: function onRefreshData() {
          // Call your existing method to fetch data from MongoDB again!
          this.fetchDataFromDB(true);
        }
      }]);
    }();

    CcActionsComponent.ctorParameters = function () {
      return [{
        type: _service_cc_actions_service__WEBPACK_IMPORTED_MODULE_6__["CcActionsService"]
      }, {
        type: src_app_shared_cav_toast_service_cav_message_service__WEBPACK_IMPORTED_MODULE_3__["CavMessageService"]
      }, {
        type: src_app_core_session_session_service__WEBPACK_IMPORTED_MODULE_7__["SessionService"]
      }];
    };

    CcActionsComponent = Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([Object(_angular_core__WEBPACK_IMPORTED_MODULE_1__["Component"])({
      selector: 'app-cc-actions',
      template: Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__importDefault"])(__webpack_require__(
      /*! raw-loader!./cc-actions.component.html */
      "./node_modules/raw-loader/dist/cjs.js!./src/app/pages/home/cloud-cost/cc-actions/cc-actions.component.html"))["default"],
      styles: [Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__importDefault"])(__webpack_require__(
      /*! ./cc-actions.component.scss */
      "./src/app/pages/home/cloud-cost/cc-actions/cc-actions.component.scss"))["default"]]
    })], CcActionsComponent);
    /***/
  },

  /***/
  "./src/app/pages/home/cloud-cost/cc-actions/cc-actions.module.ts":
  /*!***********************************************************************!*\
    !*** ./src/app/pages/home/cloud-cost/cc-actions/cc-actions.module.ts ***!
    \***********************************************************************/

  /*! exports provided: CcActionsModule */

  /***/
  function _src_app_pages_home_cloudCost_ccActions_ccActionsModuleTs(module, __webpack_exports__, __webpack_require__) {
    "use strict";

    __webpack_require__.r(__webpack_exports__);
    /* harmony export (binding) */


    __webpack_require__.d(__webpack_exports__, "CcActionsModule", function () {
      return CcActionsModule;
    });
    /* harmony import */


    var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(
    /*! tslib */
    "./node_modules/tslib/tslib.es6.js");
    /* harmony import */


    var _angular_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(
    /*! @angular/core */
    "./node_modules/@angular/core/__ivy_ngcc__/fesm2015/core.js");
    /* harmony import */


    var _angular_common__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(
    /*! @angular/common */
    "./node_modules/@angular/common/__ivy_ngcc__/fesm2015/common.js");
    /* harmony import */


    var _angular_forms__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(
    /*! @angular/forms */
    "./node_modules/@angular/forms/__ivy_ngcc__/fesm2015/forms.js");
    /* harmony import */


    var _common_component_cc_action_sidebar_cc_action_sidebar_module__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(
    /*! ../common-component/cc-action-sidebar/cc-action-sidebar.module */
    "./src/app/pages/home/cloud-cost/common-component/cc-action-sidebar/cc-action-sidebar.module.ts");
    /* harmony import */


    var _cc_actions_component__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(
    /*! ./cc-actions.component */
    "./src/app/pages/home/cloud-cost/cc-actions/cc-actions.component.ts");
    /* harmony import */


    var src_app_shared_cav_table_cav_table_module__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(
    /*! src/app/shared/cav-table/cav-table.module */
    "./src/app/shared/cav-table/cav-table.module.ts");
    /* harmony import */


    var primeng_dropdown__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(
    /*! primeng/dropdown */
    "./node_modules/primeng/__ivy_ngcc__/fesm2015/primeng-dropdown.js");
    /* harmony import */


    var primeng_button__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(
    /*! primeng/button */
    "./node_modules/primeng/__ivy_ngcc__/fesm2015/primeng-button.js");
    /* harmony import */


    var primeng_inputtext__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(
    /*! primeng/inputtext */
    "./node_modules/primeng/__ivy_ngcc__/fesm2015/primeng-inputtext.js");
    /* harmony import */


    var primeng_dialog__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(
    /*! primeng/dialog */
    "./node_modules/primeng/__ivy_ngcc__/fesm2015/primeng-dialog.js");
    /* harmony import */


    var _angular_router__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(
    /*! @angular/router */
    "./node_modules/@angular/router/__ivy_ngcc__/fesm2015/router.js");
    /* harmony import */


    var src_app_shared_cav_toolbar_cav_toolbar_module__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(
    /*! src/app/shared/cav-toolbar/cav-toolbar.module */
    "./src/app/shared/cav-toolbar/cav-toolbar.module.ts"); // 1. Import your New Component
    // 2. Import the Shared Tool (The file you just showed me)
    // 3. Import PrimeNG UI components needed for the Dropdowns/Dialogs


    var route = [{
      path: '',
      component: _cc_actions_component__WEBPACK_IMPORTED_MODULE_5__["CcActionsComponent"]
    }];

    var CcActionsModule = /*#__PURE__*/_createClass(function CcActionsModule() {
      _classCallCheck(this, CcActionsModule);
    });

    CcActionsModule = Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([Object(_angular_core__WEBPACK_IMPORTED_MODULE_1__["NgModule"])({
      declarations: [_cc_actions_component__WEBPACK_IMPORTED_MODULE_5__["CcActionsComponent"]],
      imports: [_angular_common__WEBPACK_IMPORTED_MODULE_2__["CommonModule"], _angular_forms__WEBPACK_IMPORTED_MODULE_3__["FormsModule"], src_app_shared_cav_table_cav_table_module__WEBPACK_IMPORTED_MODULE_6__["CavTableModule"], primeng_dropdown__WEBPACK_IMPORTED_MODULE_7__["DropdownModule"], primeng_button__WEBPACK_IMPORTED_MODULE_8__["ButtonModule"], primeng_inputtext__WEBPACK_IMPORTED_MODULE_9__["InputTextModule"], primeng_dialog__WEBPACK_IMPORTED_MODULE_10__["DialogModule"], _common_component_cc_action_sidebar_cc_action_sidebar_module__WEBPACK_IMPORTED_MODULE_4__["CcActionSidebarModule"], _angular_router__WEBPACK_IMPORTED_MODULE_11__["RouterModule"].forChild(route), src_app_shared_cav_toolbar_cav_toolbar_module__WEBPACK_IMPORTED_MODULE_12__["CavToolbarModule"]],
      exports: [_cc_actions_component__WEBPACK_IMPORTED_MODULE_5__["CcActionsComponent"], _angular_router__WEBPACK_IMPORTED_MODULE_11__["RouterModule"]]
    })], CcActionsModule);
    /***/
  },

  /***/
  "./src/app/pages/home/cloud-cost/cc-actions/service/cc-actions.service.ts":
  /*!********************************************************************************!*\
    !*** ./src/app/pages/home/cloud-cost/cc-actions/service/cc-actions.service.ts ***!
    \********************************************************************************/

  /*! exports provided: CcActionsService */

  /***/
  function _src_app_pages_home_cloudCost_ccActions_service_ccActionsServiceTs(module, __webpack_exports__, __webpack_require__) {
    "use strict";

    __webpack_require__.r(__webpack_exports__);
    /* harmony export (binding) */


    __webpack_require__.d(__webpack_exports__, "CcActionsService", function () {
      return CcActionsService;
    });
    /* harmony import */


    var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(
    /*! tslib */
    "./node_modules/tslib/tslib.es6.js");
    /* harmony import */


    var _angular_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(
    /*! @angular/core */
    "./node_modules/@angular/core/__ivy_ngcc__/fesm2015/core.js");
    /* harmony import */


    var rxjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(
    /*! rxjs */
    "./node_modules/rxjs/_esm2015/index.js");
    /* harmony import */


    var src_app_core_store_store__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(
    /*! src/app/core/store/store */
    "./src/app/core/store/store.ts");
    /* harmony import */


    var src_environments_environment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(
    /*! src/environments/environment */
    "./src/environments/environment.ts");
    /* harmony import */


    var src_app_core_session_session_service__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(
    /*! src/app/core/session/session.service */
    "./src/app/core/session/session.service.ts");
    /* harmony import */


    var _cc_actions_state__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(
    /*! ./cc-actions.state */
    "./src/app/pages/home/cloud-cost/cc-actions/service/cc-actions.state.ts");

    var CcActionsService = /*#__PURE__*/function (_src_app_core_store_s) {
      function CcActionsService(sessionService) {
        var _this6;

        _classCallCheck(this, CcActionsService);

        _this6 = _callSuper(this, CcActionsService);
        _this6.sessionService = sessionService;
        return _this6;
      }
      /**
      * Triggers the execution of an action by ID
      * Endpoint: POST /cc-actions/{id}/execute
      */


      _inherits(CcActionsService, _src_app_core_store_s);

      return _createClass(CcActionsService, [{
        key: "executeAction",
        value: function executeAction(actionId) {
          var output = new rxjs__WEBPACK_IMPORTED_MODULE_2__["Subject"](); // 1. Get Base Path from environment
          // Ensure this points to the controller (e.g., "/cc-actions")

          var basePathUrl = src_environments_environment__WEBPACK_IMPORTED_MODULE_4__["environment"].api.cloudCostActions.execute.endpoint; // 2. Construct the URL: /cc-actions/12345/execute

          var url = "".concat(basePathUrl, "/").concat(actionId, "/execute");
          console.log("executeAction url " + url); // 3. Emit Loading State

          output.next(new _cc_actions_state__WEBPACK_IMPORTED_MODULE_6__["CcActionsLoadingState"]()); // 4. Helper to get session base path (standard in your project)

          var sessionBasePath = this.sessionService.getBasePath(true, null, null); // 5. Make the POST Call
          // We pass an empty object {} as payload because the ID is in the URL

          this.controller.postWithoutBase(url, {}).subscribe(function (data) {
            // Success
            output.next(new _cc_actions_state__WEBPACK_IMPORTED_MODULE_6__["CcActionsLoadedState"](data));
            output.complete();
          }, function (error) {
            // Error
            console.error("CcActionsService: Error executing action", error);
            output.error(new _cc_actions_state__WEBPACK_IMPORTED_MODULE_6__["CcActionsErrorState"](error));
            output.complete();
          });
          return output;
        }
        /**
         * Fetches Action History from MongoDB
         * Maps nested 'rar' object to flat Table rows.
         */

      }, {
        key: "getActions",
        value: function getActions() {
          var output = new rxjs__WEBPACK_IMPORTED_MODULE_2__["Subject"](); // TODO: CHECK THIS ENDPOINT IN YOUR environment.ts
          // It should point to your collection where these actions are stored

          var path = src_environments_environment__WEBPACK_IMPORTED_MODULE_4__["environment"].api.cloudCostActions.read.endpoint; // MongoDB Aggregation Pipeline

          var payload = [{
            $project: {
              id: {
                $ifNull: [{
                  $toString: "$_id"
                }, "-"]
              },
              // 2. Flatten the Nested 'rar' object for the Table
              cloud: {
                $ifNull: ["$rar.actionParameters.provider", "-"]
              },
              resourceId: {
                $ifNull: ["$rar.cloudResourceId", "-"]
              },
              dataSourceName: {
                $ifNull: ["$rar.actionParameters.DataSourceName", "-"]
              },
              resource: {
                $ifNull: ["$rar.actionParameters.ResourceName", "-"]
              },
              action: {
                $ifNull: ["$rar.actionParameters.actionType", "-"]
              },
              savings: {
                $ifNull: ["$rar.actionParameters.Savings", 0]
              },
              region: {
                $ifNull: ["$rar.actionParameters.Region", "-"]
              },
              cmc: {
                $ifNull: ["$rar.actionParameters.cmc", 0]
              },
              omc: {
                $ifNull: ["$rar.actionParameters.omc", 0]
              },
              cmcRatePerUnit: {
                $ifNull: ["$rar.actionParameters.cmcRatePerUnit", 0]
              },
              omcRatePerUnit: {
                $ifNull: ["$rar.actionParameters.omcRatePerUnit", 0]
              },
              actionMode: {
                $ifNull: ["$actionStatus", "-"]
              },
              status: {
                $ifNull: ["$status", "-"]
              },
              scheduledTime: {
                $ifNull: ["$rar.actionParameters.scheduleTime", "-"]
              },
              // 4. Keep extra details for the 'View Details' Dialog
              details: {
                currentConfig: {
                  $ifNull: ["$rar.currentConfig", {}]
                },
                optimalConfig: {
                  $ifNull: ["$rar.optimalConfig", {}]
                },
                migrationType: {
                  $ifNull: ["$rar.actionParameters.migrationType", "-"]
                },
                ruleId: {
                  $ifNull: ["$rar.ruleId", "-"]
                }
              },
              // 5. Keep timestamp for sorting
              timestamp: {
                $ifNull: ["$lastUpdatedTimestamp", 0]
              }
            }
          }, {
            // Sort by newest first
            $sort: {
              timestamp: -1
            }
          }]; // Emit Loading State

          setTimeout(function () {
            output.next(new _cc_actions_state__WEBPACK_IMPORTED_MODULE_6__["CcActionsLoadingState"]());
          }, 0);
          var basePath = this.sessionService.getBasePath(true, null, null); // Make the API Call

          this.controller.post(path, payload, basePath).subscribe(function (data) {
            output.next(new _cc_actions_state__WEBPACK_IMPORTED_MODULE_6__["CcActionsLoadedState"](data));
            output.complete();
          }, function (error) {
            console.error("CcActionsService: Error fetching actions", error);
            output.error(new _cc_actions_state__WEBPACK_IMPORTED_MODULE_6__["CcActionsErrorState"](error));
            output.complete();
          });
          return output;
        }
      }, {
        key: "getKubOptActions",
        value: function getKubOptActions() {
          var output = new rxjs__WEBPACK_IMPORTED_MODULE_2__["Subject"](); // Ensure this endpoint points to the vpa_recommendations collection

          var path = src_environments_environment__WEBPACK_IMPORTED_MODULE_4__["environment"].api.kubOptAction.read.endpoint; // let payload = [
          //     {
          //         $project: {
          //             clusterId: { $ifNull: [{ $toString: "$clusterId" }, "-"] },
          //             cloud: { $ifNull: ["$provider", "Kubernetes"] },
          //             namespace: { $ifNull: ["$namespace", "-"] }, // Using namespace as ID context
          //             cluster_name: { $ifNull: ["$name", "-"] },
          //             recommendation: { $ifNull: ["$recommendation", "-"] },
          //             action: { $add: ["VPA ", "$workload_type"] }, // e.g., VPA Deployment
          //             uiStatus:{$ifNull:["$uiStatus","kubeOpt"]},
          //             // Mapping for Sidebar details
          //             details: {
          //                 currentConfig: {
          //                     cpu: "$current_cpu",
          //                     memory: "$current_mem"
          //                 },
          //                 optimalConfig: {
          //                     cpu: "$recommended_cpu",
          //                     memory: "$recommended_mem"
          //                 }
          //             }
          //         }
          //     }
          // ];

          var payload = [// 1️⃣ Sort by timestamp (latest first)
          {
            $sort: {
              timestamp: -1
            }
          }, // 2️⃣ Lookup datasource using dataSourceName
          {
            $lookup: {
              from: "dataSource",
              "let": {
                dsName: "$dataSourceName"
              },
              pipeline: [{
                $match: {
                  $expr: {
                    $eq: ["$dataSource.name", "$$dsName"]
                  }
                }
              }, {
                $unwind: "$coc.vpaConfig"
              }, {
                $project: {
                  _id: 0,
                  dataSourceName: "$dataSource.name",
                  cloud: "$dataSourceType",
                  vpaConfig: "$coc.vpaConfig"
                }
              }],
              as: "ds"
            }
          }, // 3️⃣ Flatten datasource
          {
            $unwind: {
              path: "$ds",
              preserveNullAndEmptyArrays: true
            }
          }, // 4️⃣ Final projection (UI + Sidebar ready)
          {
            $project: {
              _id: 0,

              /* ---------------- TABLE FIELDS ---------------- */
              resourceId: "$details.pod",
              resourceKey: {
                $concat: ["$details.pod", "|", "$actionType", "|", {
                  $toString: "$timestamp"
                }]
              },
              resource: {
                $arrayElemAt: ["$recommendation.containerRecommendations.containerName", 0]
              },
              cluster_name: "$clusterName",
              namespace: "$details.namespace",
              workload: "$details.workload",
              action: {
                $concat: ["VPA_", "$actionType"]
              },
              source: "$source",
              uiStatus: {
                $cond: {
                  "if": {
                    $and: [{
                      $ne: [{
                        $type: "$actionType"
                      }, "missing"]
                    }, {
                      $ne: ["$actionType", null]
                    }, {
                      $gte: [{
                        $indexOfCP: ["$actionType", "RECOMMENDATION"]
                      }, 0]
                    }]
                  },
                  then: "Pending",
                  "else": "Executed"
                }
              },
              dataSourceName: "$dataSourceName",
              cloud: {
                $ifNull: ["$ds.cloud", "-"]
              },
              time: {
                $ifNull: ["$timestamp", "-"]
              },
              timestamp: 1,

              /* ---------------- MESSAGE / REASON ---------------- */
              reason: "$details.reason",
              message: "$details.message",

              /* ---------------- VPA RECOMMENDATION ---------------- */
              recommendation: {
                containerName: {
                  $arrayElemAt: ["$recommendation.containerRecommendations.containerName", 0]
                },
                cpu: {
                  lower: {
                    $arrayElemAt: ["$recommendation.containerRecommendations.lowerBound.cpu", 0]
                  },
                  target: {
                    $arrayElemAt: ["$recommendation.containerRecommendations.target.cpu", 0]
                  },
                  upper: {
                    $arrayElemAt: ["$recommendation.containerRecommendations.upperBound.cpu", 0]
                  },
                  uncappedTarget: {
                    $arrayElemAt: ["$recommendation.containerRecommendations.uncappedTarget.cpu", 0]
                  }
                },
                memory: {
                  lower: {
                    $arrayElemAt: ["$recommendation.containerRecommendations.lowerBound.memory", 0]
                  },
                  target: {
                    $arrayElemAt: ["$recommendation.containerRecommendations.target.memory", 0]
                  },
                  upper: {
                    $arrayElemAt: ["$recommendation.containerRecommendations.upperBound.memory", 0]
                  },
                  uncappedTarget: {
                    $arrayElemAt: ["$recommendation.containerRecommendations.uncappedTarget.memory", 0]
                  }
                }
              },

              /* ---------------- VPA CONFIG (SIDEBAR) ---------------- */
              vpaConfig: {
                mode: "$ds.vpaConfig.mode",
                namespace: "$ds.vpaConfig.namespace",
                workload: "$ds.vpaConfig.workload",
                minCpu: {
                  $arrayElemAt: ["$ds.vpaConfig.containers.minimumCpu", 0]
                },
                maxCpu: {
                  $arrayElemAt: ["$ds.vpaConfig.containers.maximumCpu", 0]
                },
                minMemory: {
                  $arrayElemAt: ["$ds.vpaConfig.containers.minimumMemory", 0]
                },
                maxMemory: {
                  $arrayElemAt: ["$ds.vpaConfig.containers.maximumMemory", 0]
                }
              }
            }
          }];
          output.next(new _cc_actions_state__WEBPACK_IMPORTED_MODULE_6__["CcActionsLoadingState"]());
          var basePath = this.sessionService.getBasePath(true, null, null);
          this.controller.post(path, payload, basePath).subscribe(function (data) {
            output.next(new _cc_actions_state__WEBPACK_IMPORTED_MODULE_6__["CcActionsLoadedState"](data));
            output.complete();
          }, function (error) {
            output.error(new _cc_actions_state__WEBPACK_IMPORTED_MODULE_6__["CcActionsErrorState"](error));
          });
          return output;
        }
      }]);
    }(src_app_core_store_store__WEBPACK_IMPORTED_MODULE_3__["Store"].AbstractService);

    CcActionsService.ctorParameters = function () {
      return [{
        type: src_app_core_session_session_service__WEBPACK_IMPORTED_MODULE_5__["SessionService"]
      }];
    };

    CcActionsService = Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([Object(_angular_core__WEBPACK_IMPORTED_MODULE_1__["Injectable"])({
      providedIn: 'root'
    })], CcActionsService);
    /***/
  },

  /***/
  "./src/app/pages/home/cloud-cost/cc-actions/service/cc-actions.state.ts":
  /*!******************************************************************************!*\
    !*** ./src/app/pages/home/cloud-cost/cc-actions/service/cc-actions.state.ts ***!
    \******************************************************************************/

  /*! exports provided: CcActionsLoadingState, CcActionsLoadedState, CcActionsErrorState */

  /***/
  function _src_app_pages_home_cloudCost_ccActions_service_ccActionsStateTs(module, __webpack_exports__, __webpack_require__) {
    "use strict";

    __webpack_require__.r(__webpack_exports__);
    /* harmony export (binding) */


    __webpack_require__.d(__webpack_exports__, "CcActionsLoadingState", function () {
      return CcActionsLoadingState;
    });
    /* harmony export (binding) */


    __webpack_require__.d(__webpack_exports__, "CcActionsLoadedState", function () {
      return CcActionsLoadedState;
    });
    /* harmony export (binding) */


    __webpack_require__.d(__webpack_exports__, "CcActionsErrorState", function () {
      return CcActionsErrorState;
    });
    /* harmony import */


    var src_app_core_store_store__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(
    /*! src/app/core/store/store */
    "./src/app/core/store/store.ts"); // 1. Loading State - Added <any>


    var CcActionsLoadingState = /*#__PURE__*/function (_src_app_core_store_s2) {
      function CcActionsLoadingState() {
        _classCallCheck(this, CcActionsLoadingState);

        return _callSuper(this, CcActionsLoadingState);
      }

      _inherits(CcActionsLoadingState, _src_app_core_store_s2);

      return _createClass(CcActionsLoadingState);
    }(src_app_core_store_store__WEBPACK_IMPORTED_MODULE_0__["Store"].AbstractLoadingState); // 2. Loaded State (Success) - Added <any>


    var CcActionsLoadedState = /*#__PURE__*/function (_src_app_core_store_s3) {
      function CcActionsLoadedState(data) {
        var _this7;

        _classCallCheck(this, CcActionsLoadedState);

        _this7 = _callSuper(this, CcActionsLoadedState, [data]);
        _this7.data = data;
        return _this7;
      }

      _inherits(CcActionsLoadedState, _src_app_core_store_s3);

      return _createClass(CcActionsLoadedState);
    }(src_app_core_store_store__WEBPACK_IMPORTED_MODULE_0__["Store"].AbstractIdealState); // 3. Error State - Added <any>


    var CcActionsErrorState = /*#__PURE__*/function (_src_app_core_store_s4) {
      function CcActionsErrorState(error) {
        var _this8;

        _classCallCheck(this, CcActionsErrorState);

        _this8 = _callSuper(this, CcActionsErrorState, [error]);
        _this8.error = error;
        return _this8;
      }

      _inherits(CcActionsErrorState, _src_app_core_store_s4);

      return _createClass(CcActionsErrorState);
    }(src_app_core_store_store__WEBPACK_IMPORTED_MODULE_0__["Store"].AbstractErrorState);
    /***/

  },

  /***/
  "./src/app/pages/home/cloud-cost/common-component/cc-action-sidebar/cc-action-sidebar.component.scss":
  /*!***********************************************************************************************************!*\
    !*** ./src/app/pages/home/cloud-cost/common-component/cc-action-sidebar/cc-action-sidebar.component.scss ***!
    \***********************************************************************************************************/

  /*! exports provided: default */

  /***/
  function _src_app_pages_home_cloudCost_commonComponent_ccActionSidebar_ccActionSidebarComponentScss(module, __webpack_exports__, __webpack_require__) {
    "use strict";

    __webpack_require__.r(__webpack_exports__);
    /* harmony default export */


    __webpack_exports__["default"] = "";
    /***/
  },

  /***/
  "./src/app/pages/home/cloud-cost/common-component/cc-action-sidebar/cc-action-sidebar.component.ts":
  /*!*********************************************************************************************************!*\
    !*** ./src/app/pages/home/cloud-cost/common-component/cc-action-sidebar/cc-action-sidebar.component.ts ***!
    \*********************************************************************************************************/

  /*! exports provided: CcActionSidebarComponent */

  /***/
  function _src_app_pages_home_cloudCost_commonComponent_ccActionSidebar_ccActionSidebarComponentTs(module, __webpack_exports__, __webpack_require__) {
    "use strict";

    __webpack_require__.r(__webpack_exports__);
    /* harmony export (binding) */


    __webpack_require__.d(__webpack_exports__, "CcActionSidebarComponent", function () {
      return CcActionSidebarComponent;
    });
    /* harmony import */


    var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(
    /*! tslib */
    "./node_modules/tslib/tslib.es6.js");
    /* harmony import */


    var _angular_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(
    /*! @angular/core */
    "./node_modules/@angular/core/__ivy_ngcc__/fesm2015/core.js");
    /* harmony import */


    var highcharts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(
    /*! highcharts */
    "./node_modules/highcharts/highcharts.js");
    /* harmony import */


    var highcharts__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(highcharts__WEBPACK_IMPORTED_MODULE_2__);

    var CcActionSidebarComponent = /*#__PURE__*/function () {
      function CcActionSidebarComponent() {
        _classCallCheck(this, CcActionSidebarComponent);

        // --- Inputs ---
        this.visible = false;
        this.instanceActionHeader = {};
        this.volumeActionHeader = {};
        this.action = [];
        this.volumeDetails = [];
        this.instanceDetails = [];
        this.volumeResource = [];
        this.instanceResource = [];
        this.volumeCost = [];
        this.instanceCost = [];
        this.isVpa = false; // New

        this.vpaRecommendations = []; // New

        this.vpaConfig = []; // New
        // --- Outputs ---

        this.visibleChange = new _angular_core__WEBPACK_IMPORTED_MODULE_1__["EventEmitter"]();
        this.executeAction = new _angular_core__WEBPACK_IMPORTED_MODULE_1__["EventEmitter"]();
        this.Highcharts = highcharts__WEBPACK_IMPORTED_MODULE_2__;
      }
      /**
       * Emits an event to close the sidebar.
       */


      return _createClass(CcActionSidebarComponent, [{
        key: "onClose",
        value: function onClose() {
          this.visible = false;
          this.visibleChange.emit(this.visible);
        }
        /**
         * Emits an event to signal the parent component to execute the action.
         */

      }, {
        key: "onExecuteAction",
        value: function onExecuteAction() {
          this.executeAction.emit();
        }
      }, {
        key: "ngOnInit",
        value: function ngOnInit() {
          console.log("initializing action sidebar", this);
        }
      }, {
        key: "ngOnChanges",
        value: function ngOnChanges(changes) {
          console.log("SIDEBAR CHANGES DETECTED:", changes);

          if (changes.visible && changes.visible.currentValue === true) {
            console.log("SIDEBAR OPENING! Visible is now TRUE");
            console.log("Current Data - InstanceScale:", this.instanceScale);
            console.log("Current Data - Header:", this.instanceActionHeader);
          }
        }
      }]);
    }();

    Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([Object(_angular_core__WEBPACK_IMPORTED_MODULE_1__["Input"])()], CcActionSidebarComponent.prototype, "visible", void 0);
    Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([Object(_angular_core__WEBPACK_IMPORTED_MODULE_1__["Input"])()], CcActionSidebarComponent.prototype, "chartOptions", void 0);
    Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([Object(_angular_core__WEBPACK_IMPORTED_MODULE_1__["Input"])()], CcActionSidebarComponent.prototype, "instanceScale", void 0);
    Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([Object(_angular_core__WEBPACK_IMPORTED_MODULE_1__["Input"])()], CcActionSidebarComponent.prototype, "instanceDelete", void 0);
    Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([Object(_angular_core__WEBPACK_IMPORTED_MODULE_1__["Input"])()], CcActionSidebarComponent.prototype, "volumeScale", void 0);
    Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([Object(_angular_core__WEBPACK_IMPORTED_MODULE_1__["Input"])()], CcActionSidebarComponent.prototype, "volumeDelete", void 0);
    Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([Object(_angular_core__WEBPACK_IMPORTED_MODULE_1__["Input"])()], CcActionSidebarComponent.prototype, "instanceActionHeader", void 0);
    Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([Object(_angular_core__WEBPACK_IMPORTED_MODULE_1__["Input"])()], CcActionSidebarComponent.prototype, "volumeActionHeader", void 0);
    Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([Object(_angular_core__WEBPACK_IMPORTED_MODULE_1__["Input"])()], CcActionSidebarComponent.prototype, "action", void 0);
    Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([Object(_angular_core__WEBPACK_IMPORTED_MODULE_1__["Input"])()], CcActionSidebarComponent.prototype, "volumeDetails", void 0);
    Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([Object(_angular_core__WEBPACK_IMPORTED_MODULE_1__["Input"])()], CcActionSidebarComponent.prototype, "instanceDetails", void 0);
    Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([Object(_angular_core__WEBPACK_IMPORTED_MODULE_1__["Input"])()], CcActionSidebarComponent.prototype, "volumeResource", void 0);
    Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([Object(_angular_core__WEBPACK_IMPORTED_MODULE_1__["Input"])()], CcActionSidebarComponent.prototype, "instanceResource", void 0);
    Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([Object(_angular_core__WEBPACK_IMPORTED_MODULE_1__["Input"])()], CcActionSidebarComponent.prototype, "volumeCost", void 0);
    Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([Object(_angular_core__WEBPACK_IMPORTED_MODULE_1__["Input"])()], CcActionSidebarComponent.prototype, "instanceCost", void 0);
    Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([Object(_angular_core__WEBPACK_IMPORTED_MODULE_1__["Input"])()], CcActionSidebarComponent.prototype, "isVpa", void 0);
    Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([Object(_angular_core__WEBPACK_IMPORTED_MODULE_1__["Input"])()], CcActionSidebarComponent.prototype, "vpaRecommendations", void 0);
    Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([Object(_angular_core__WEBPACK_IMPORTED_MODULE_1__["Input"])()], CcActionSidebarComponent.prototype, "vpaConfig", void 0);
    Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([Object(_angular_core__WEBPACK_IMPORTED_MODULE_1__["Input"])()], CcActionSidebarComponent.prototype, "enableActionExecute", void 0);
    Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([Object(_angular_core__WEBPACK_IMPORTED_MODULE_1__["Output"])()], CcActionSidebarComponent.prototype, "visibleChange", void 0);
    Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([Object(_angular_core__WEBPACK_IMPORTED_MODULE_1__["Output"])()], CcActionSidebarComponent.prototype, "executeAction", void 0);
    CcActionSidebarComponent = Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([Object(_angular_core__WEBPACK_IMPORTED_MODULE_1__["Component"])({
      selector: 'app-cc-action-sidebar',
      template: Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__importDefault"])(__webpack_require__(
      /*! raw-loader!./cc-action-sidebar.component.html */
      "./node_modules/raw-loader/dist/cjs.js!./src/app/pages/home/cloud-cost/common-component/cc-action-sidebar/cc-action-sidebar.component.html"))["default"],
      encapsulation: _angular_core__WEBPACK_IMPORTED_MODULE_1__["ViewEncapsulation"].None // To ensure styles are applied correctly
      ,
      styles: [Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__importDefault"])(__webpack_require__(
      /*! ./cc-action-sidebar.component.scss */
      "./src/app/pages/home/cloud-cost/common-component/cc-action-sidebar/cc-action-sidebar.component.scss"))["default"]]
    })], CcActionSidebarComponent);
    /***/
  },

  /***/
  "./src/app/pages/home/cloud-cost/common-component/cc-action-sidebar/cc-action-sidebar.module.ts":
  /*!******************************************************************************************************!*\
    !*** ./src/app/pages/home/cloud-cost/common-component/cc-action-sidebar/cc-action-sidebar.module.ts ***!
    \******************************************************************************************************/

  /*! exports provided: CcActionSidebarModule */

  /***/
  function _src_app_pages_home_cloudCost_commonComponent_ccActionSidebar_ccActionSidebarModuleTs(module, __webpack_exports__, __webpack_require__) {
    "use strict";

    __webpack_require__.r(__webpack_exports__);
    /* harmony export (binding) */


    __webpack_require__.d(__webpack_exports__, "CcActionSidebarModule", function () {
      return CcActionSidebarModule;
    });
    /* harmony import */


    var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(
    /*! tslib */
    "./node_modules/tslib/tslib.es6.js");
    /* harmony import */


    var _angular_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(
    /*! @angular/core */
    "./node_modules/@angular/core/__ivy_ngcc__/fesm2015/core.js");
    /* harmony import */


    var _angular_common__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(
    /*! @angular/common */
    "./node_modules/@angular/common/__ivy_ngcc__/fesm2015/common.js");
    /* harmony import */


    var _angular_forms__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(
    /*! @angular/forms */
    "./node_modules/@angular/forms/__ivy_ngcc__/fesm2015/forms.js");
    /* harmony import */


    var primeng_sidebar__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(
    /*! primeng/sidebar */
    "./node_modules/primeng/__ivy_ngcc__/fesm2015/primeng-sidebar.js");
    /* harmony import */


    var primeng_button__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(
    /*! primeng/button */
    "./node_modules/primeng/__ivy_ngcc__/fesm2015/primeng-button.js");
    /* harmony import */


    var highcharts_angular__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(
    /*! highcharts-angular */
    "./node_modules/highcharts-angular/__ivy_ngcc__/fesm2015/highcharts-angular.js");
    /* harmony import */


    var _cc_action_sidebar_component__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(
    /*! ./cc-action-sidebar.component */
    "./src/app/pages/home/cloud-cost/common-component/cc-action-sidebar/cc-action-sidebar.component.ts");
    /* harmony import */


    var src_app_shared_cav_table_cav_table_module__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(
    /*! src/app/shared/cav-table/cav-table.module */
    "./src/app/shared/cav-table/cav-table.module.ts");

    var CcActionSidebarModule = /*#__PURE__*/_createClass(function CcActionSidebarModule() {
      _classCallCheck(this, CcActionSidebarModule);
    });

    CcActionSidebarModule = Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([Object(_angular_core__WEBPACK_IMPORTED_MODULE_1__["NgModule"])({
      declarations: [_cc_action_sidebar_component__WEBPACK_IMPORTED_MODULE_7__["CcActionSidebarComponent"]],
      imports: [_angular_common__WEBPACK_IMPORTED_MODULE_2__["CommonModule"], _angular_forms__WEBPACK_IMPORTED_MODULE_3__["FormsModule"], primeng_sidebar__WEBPACK_IMPORTED_MODULE_4__["SidebarModule"], primeng_button__WEBPACK_IMPORTED_MODULE_5__["ButtonModule"], highcharts_angular__WEBPACK_IMPORTED_MODULE_6__["HighchartsChartModule"], src_app_shared_cav_table_cav_table_module__WEBPACK_IMPORTED_MODULE_8__["CavTableModule"]],
      exports: [_cc_action_sidebar_component__WEBPACK_IMPORTED_MODULE_7__["CcActionSidebarComponent"]]
    })], CcActionSidebarModule);
    /***/
  }
}]);