function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }

function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure 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 _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 _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }

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

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-policies-cc-policies-configuration-cc-polocies-configuration-module"], {
  /***/
  "./node_modules/raw-loader/dist/cjs.js!./src/app/pages/home/cloud-cost/cc-policies/cc-policies-configuration/cc-policies.component.html":
  /*!**********************************************************************************************************************************************!*\
    !*** ./node_modules/raw-loader/dist/cjs.js!./src/app/pages/home/cloud-cost/cc-policies/cc-policies-configuration/cc-policies.component.html ***!
    \**********************************************************************************************************************************************/

  /*! exports provided: default */

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

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


    __webpack_exports__["default"] = "<div class=\"scroll-container\">\n<p-panel styleClass=\"net-panel mt-10 mb-12\" [toggleable]=\"true\" header=\"Set Policies Type\">\n  <div class=\"p-grid p-col-12 ml-6 p-align-start threshold\">\n    <div class=\"p-grid p-align-center p-col-10-change\">\n\n      <div class=\"p-6\">Policy Name</div>\n        <div class=\"m-6\">\n          <input type=\"text\" pInputText \n                 [(ngModel)]=\"ccmPolicy.policyName\" \n                 placeholder=\"Enter Policy Name\"\n                 class=\"width-180\"\n                 [disabled]=\"isEditMode\" > </div>\n\n      <!-- Select Policy Type -->\n      <div class=\"p-6\">Trigger</div>\n      <div class=\"m-6\">\n        <p-dropdown \n          [options]=\"policyTypeList\" \n          [(ngModel)]=\"ccmPolicy.policyCategory\" \n          (onChange)=\"updateResourceTypes()\"\n          [disabled]=\"isPolicyCategoryLocked\"\n          [style]=\"{'min-width':'150px'}\">\n        </p-dropdown>\n      </div>\n\n      <!-- Select Resource Type -->\n      <div class=\"p-6\">{{ccmPolicy.policyCategory==='Power Scheduler' ? 'For state' : 'Policy on'}}</div>\n      <div class=\"m-6\">\n        <p-dropdown \n          [options]=\"filteredResourceTypeList\" \n          [(ngModel)]=\"ccmPolicy.policyType\"\n          (onChange)=\"filteredResourceType($event)\" \n          [style]=\"{'min-width':'150px'}\">\n        </p-dropdown>\n      </div>\n\n      <!-- Pool Dropdown: ONLY Visible for \"Resource Lifecycle\" -->\n    </div>\n  </div>\n</p-panel>\n<p-panel styleClass=\"net-panel mb-12\" [toggleable]=\"true\" [header]= \"ccmPolicy.policyCategory==='Power Scheduler' ? 'Schedule Time' : 'Policies Condition'\">\n\n  <div class=\"p-grid p-align-center\" *ngIf=\"ccmPolicy.policyCategory === 'Anomaly Detection'\">\n    <div class=\"p-col-fixed\">If Daily</div> {{ ccmPolicy.policyType.toLowerCase() }} deviates from baseline of\n    <!-- Select Policy Type -->\n    <!-- <div class=\"p-col-fixed\">\n      <p-dropdown [options]=\"timePeriodList\" [(ngModel)]=\"ccmPolicy.anomalyPolicy.timePeriod\" (onChange)=\"updateBaselineDays()\" placeholder=\"Select Time Period\"\n        [style]=\"{'min-width':'100px'}\">\n      </p-dropdown>\n    </div>\n    <div class=\"p-col-fixed\"> {{ ccmPolicy.policyType.toLowerCase() }} deviates from baseline of\n    </div> -->\n    <div class=\"p-col-fixed\">\n      <input type=\"number\" pInputText [(ngModel)]=\"ccmPolicy.anomalyPolicy.evaluationPeriod\" class=\"width-150\">\n    </div>\n    <div class=\"p-col-fixed\">days by more than</div>\n    <div class=\"p-col-fixed\">\n      <input type=\"number\" pInputText [(ngModel)]=\"ccmPolicy.anomalyPolicy.threshold\" class=\"width-100\">\n    </div>\n    <div class=\"p-col-fixed\">% threshold.</div>\n  </div>\n\n  <!-- Anomaly Detection Specific Condition -->\n  <!-- Quotas and Budgets Conditions -->\n\n\n\n  <div class=\"p-grid p-align-center\"\n    *ngIf=\"ccmPolicy?.policyType === 'Resource quota' && ccmPolicy.policyCategory === 'Quotas and Budgets'\">\n    <div class=\"p-col-fixed\">If resource count exceeds </div>\n    <div class=\"p-col-fixed width-80\">\n      <input type=\"number\" pInputText [(ngModel)]=\"ccmPolicy.quotaBudgetPolicy.resourceCount\" class=\"w-100-p\">\n    </div>\n    <!-- <div class=\"p-col-fixed\">Days.</div> -->\n  </div>\n\n\n  <div class=\"p-grid p-align-center\" *ngIf=\"ccmPolicy.policyType === 'Recurring Budget'\">\n    <div class=\"p-col-fixed\">If recurring budget exceeds $</div>\n    <div class=\"p-col-fixed\">\n      <input type=\"number\" pInputText [(ngModel)]=\"ccmPolicy.quotaBudgetPolicy.monthlyBudget\" class=\"width-50\">\n    </div>\n    <div class=\"p-col-fixed\">for current</div>\n    <!-- Time Period Dropdown -->\n    <div class=\"p-col-fixed\">\n      <p-dropdown [options]=\"timePeriodList\" placeholder=\"Select Time Period\" [(ngModel)]=\"ccmPolicy.quotaBudgetPolicy.timePeriod\" [style]=\"{'min-width':'100px'}\"\n        appendTo=\"body\">\n      </p-dropdown>\n    </div>\n  </div>\n\n\n  <!-- Condition: Expiring Budget Exceeds for a Date Range -->\n  <div class=\"p-grid p-align-center\" *ngIf=\"ccmPolicy.policyType === 'Expiring Budget'\">\n    <div class=\"p-col-fixed\">If expiring budget exceeds </div>\n    <div class=\"p-col-fixed\">\n      <input type=\"number\" pInputText [(ngModel)]=\"ccmPolicy.quotaBudgetPolicy.totalBudget\" class=\"width-100\">\n    </div>\n    <div class=\"p-col-fixed\">from</div>\n    <div class=\"p-col-fixed\">\n      <p-calendar [(ngModel)]=\"ccmPolicy.quotaBudgetPolicy.startDate\" [showTime]=\"true\" [showIcon]=\"true\" (onSelect)=\"ccmPolicy.quotaBudgetPolicy.startTimestamp = convertToLong(ccmPolicy.taggingPolicy.startDate)\"></p-calendar>\n    </div>\n\n    <!-- <div class=\"p-col-fixed\">to</div>\n    <div class=\"p-col-fixed\">\n      <p-calendar [(ngModel)]=\"ccmPolicy.quotaBudgetPolicy.endDate\" [showTime]=\"true\" [showIcon]=\"true\"></p-calendar>\n    </div> -->\n  </div>\n\n\n\n  <!-- Condition: Expiring Budget Exceeds for a Date Range -->\n  <div class=\"p-grid p-align-center\"\n    *ngIf=\"ccmPolicy.policyType === 'Required tag' && ccmPolicy.policyCategory === 'Tagging'\">\n    <div class=\"p-col-fixed\">For resources not having </div>\n    <div class=\"p-col-fixed\">\n      <input type=\"text\" pInputText [(ngModel)]=\"ccmPolicy.taggingPolicy.requiredTag\" class=\"width-100\">\n    </div>\n    <div class=\"p-col-fixed\">required tag after</div>\n    <div class=\"p-col-fixed\">\n      <p-calendar [(ngModel)]=\"ccmPolicy.taggingPolicy.startDate\" [showTime]=\"true\" [showIcon]=\"true\" (onSelect)=\"ccmPolicy.taggingPolicy.startTimestamp = convertToLong(ccmPolicy.taggingPolicy.startDate)\"></p-calendar>\n    </div>\n  </div>\n\n\n\n  <!-- Condition: Expiring Budget Exceeds for a Date Range -->\n  <div class=\"p-grid p-align-center\"\n    *ngIf=\"ccmPolicy.policyType === 'Prohibited tag' && ccmPolicy.policyCategory === 'Tagging'\">\n    <div class=\"p-col-fixed\">For resources having </div>\n    <div class=\"p-col-fixed\">\n      <input type=\"text\" pInputText [(ngModel)]=\"ccmPolicy.taggingPolicy.prohibitedTag\" class=\"width-100\">\n    </div>\n    <div class=\"p-col-fixed\">prohibited tag after</div>\n    <div class=\"p-col-fixed\">\n      <p-calendar [(ngModel)]=\"ccmPolicy.taggingPolicy.startDate\" [showTime]=\"true\" [showIcon]=\"true\" (onSelect)=\"ccmPolicy.taggingPolicy.startTimestamp = convertToLong(ccmPolicy.taggingPolicy.startDate)\"></p-calendar>\n    </div>\n  </div>\n\n\n\n  <!-- Condition: Expiring Budget Exceeds for a Date Range -->\n  <div class=\"p-grid p-align-center\"\n    *ngIf=\"ccmPolicy.policyType === 'Tags correlation' && ccmPolicy.policyCategory === 'Tagging'\">\n    <div class=\"p-col-fixed\">For resources having primary tag</div>\n    <div class=\"p-col-fixed\">\n      <input type=\"text\" pInputText [(ngModel)]=\"ccmPolicy.taggingPolicy.primaryTag\" class=\"width-80\">\n    </div>\n    <div class=\"p-col-fixed\">and not having correlated tag</div>\n    <div class=\"p-col-fixed\">\n      <input type=\"text\" pInputText [(ngModel)]=\"ccmPolicy.taggingPolicy.correlatedTag\" class=\"width-80\">\n    </div>\n    <div class=\"p-col-fixed\">and start time</div>\n    <div class=\"p-col-fixed\">\n      <p-calendar [(ngModel)]=\"ccmPolicy.taggingPolicy.startDate\" [showTime]=\"true\" [showIcon]=\"true\" (onSelect)=\"ccmPolicy.taggingPolicy.startTimestamp = convertToLong(ccmPolicy.taggingPolicy.startDate)\"></p-calendar>\n    </div>\n  </div>\n\n  <div class=\"p-grid p-align-center\" *ngIf=\"ccmPolicy.policyCategory === 'Resource Lifecycle'\">\n    <div class=\"p-col-fixed\">Pool</div>\n    <div class=\"p-col-fixed\">\n      <p-dropdown \n        [options]=\"pools\" \n        [(ngModel)]=\"ccmPolicy.resourceLifeCyclePolicy.poolName\"\n        [style]=\"{'min-width':'150px'}\">\n      </p-dropdown>\n    </div>\n\n    <!-- TTL Input Box -->\n    <div class=\"p-grid p-align-center\" *ngIf=\"ccmPolicy.policyType === 'TTL'\">\n      <div class=\"p-col-fixed\">TTL</div>\n      <div class=\"p-col-fixed\">\n        <input type=\"number\" pInputText [(ngModel)]=\"ccmPolicy.resourceLifeCyclePolicy.ttl\" class=\"width-70\">\n      </div>\n      <div class=\"p-col-fixed\">Hours</div>\n    </div>\n\n    <!-- Daily Expense Limit Input Box -->\n    <div class=\"p-grid p-align-center\" *ngIf=\"ccmPolicy.policyType === 'Daily expense limit'\">\n      <div class=\"p-col-fixed\">Expense Limit $</div>\n      <div class=\"p-col-fixed\">\n        <input type=\"number\" pInputText [(ngModel)]=\"ccmPolicy.resourceLifeCyclePolicy.expenseLimit\" class=\"width-80\">\n      </div>\n    </div>\n\n  </div>\n\n  <!-- Box for Power Scheduler -->\n  <div class=\"p-grid p-align-center\" *ngIf=\"ccmPolicy.policyCategory==='Power Scheduler'\">\n  <ng-container *ngIf=\"inputForCavScheduler\">\n      <app-cav-scheduler \n          [cavScheduleInput]=\"inputForCavScheduler\" \n          (responseEvent)=\"cavScheduleEventHandler($event)\" \n          (scheduleNow)=\"handleScheduleNow($event)\">\n      </app-cav-scheduler>\n  </ng-container>\n</div>\n\n      \n</p-panel>\n\n<p-panel *ngIf=\"ccmPolicy.policyCategory !== 'Resource Lifecycle'\" styleClass=\"net-panel mb-10\" [toggleable]=\"true\" header=\"Policies Filters\">\n  <!-- Dropdown Filters -->\n  <div class=\"p-grid w-100-p\">\n    <!-- <div class=\"p-col-2 p-grid p-nogutter1\">\n      <label class=\"p-col-12\">Suggested filters</label>\n      <div class=\"p-col-12\">\n        <p-dropdown [options]=\"suggestedFilters\" [(ngModel)]=\"ccmPolicy.filters.suggested\" placeholder=\"Select Filter\">\n        </p-dropdown>\n      </div>\n    </div> -->\n\n    <div class=\"p-col-2 p-grid p-nogutter1\">\n      <label class=\"p-col-12\">Data source</label>\n      <div class=\"p-col-12\">\n      <!-- <p-dropdown [options]=\"dataSources\" [(ngModel)]=\"ccmPolicy.filters.dataSource\" placeholder=\"Select Data Source\">\n      </p-dropdown> -->\n       <p-multiSelect [options]=\"dataSources\" [(ngModel)]=\"ccmPolicy.filters.dataSource\"\n            defaultLabel=\"Select Data Sources\" display=\"chip\" [style]=\"{'width':'100%'}\">\n          </p-multiSelect>\n      </div>\n    </div>\n\n    <div class=\"p-col-2 p-grid p-nogutter1\">\n      <label class=\"p-col-12\">Pool</label>\n      <div class=\"p-col-12\">\n      <!-- <p-dropdown [options]=\"pools\" [(ngModel)]=\"ccmPolicy.filters.pool\" placeholder=\"Select Pool\">\n      </p-dropdown> -->\n       <p-multiSelect [options]=\"pools\" [(ngModel)]=\"ccmPolicy.filters.pool\" defaultLabel=\"Select Pools\"\n            display=\"chip\" [style]=\"{'width':'100%'}\">\n          </p-multiSelect>\n    </div>\n    </div>\n\n    <div class=\"p-col-2 p-grid p-nogutter1\">\n      <label class=\"p-col-12\">Owner</label>\n        <div class=\"p-col-12\">\n          <!-- <p-dropdown [options]=\"owners\" [(ngModel)]=\"ccmPolicy.filters.owner\" placeholder=\"Select Owner\">\n      </p-dropdown> -->\n       <p-multiSelect [options]=\"owners\" [(ngModel)]=\"ccmPolicy.filters.owner\" defaultLabel=\"Select Owners\"\n            display=\"chip\" [style]=\"{'width':'100%'}\">\n          </p-multiSelect>\n      </div>\n    </div>\n\n    <div class=\"p-col-2 p-grid p-nogutter1\">\n      <label class=\"p-col-12\">Region</label>\n      <div class=\"p-col-12\">\n      <!-- <p-dropdown [options]=\"regions\" [(ngModel)]=\"ccmPolicy.filters.region\" placeholder=\"Select Region\">\n      </p-dropdown> -->\n       <p-multiSelect [options]=\"regions\" [(ngModel)]=\"ccmPolicy.filters.region\" defaultLabel=\"Select Regions\"\n            display=\"chip\" [style]=\"{'width':'100%'}\">\n          </p-multiSelect>\n      </div>\n    </div>\n\n    <div class=\"p-col-2 p-grid p-nogutter1\">\n      <label class=\"p-col-12\">Service</label>\n      <div class=\"p-col-12\">\n        <!-- <p-dropdown [options]=\"services\" [(ngModel)]=\"ccmPolicy.filters.service\" placeholder=\"Select Service\">\n      </p-dropdown> -->\n       <p-multiSelect [options]=\"services\" [(ngModel)]=\"ccmPolicy.filters.service\" defaultLabel=\"Select Services\"\n            display=\"chip\" [style]=\"{'width':'100%'}\">\n          </p-multiSelect>\n      </div>\n    </div>\n\n    <div class=\"p-col-2 p-grid p-nogutter1\">\n      <label class=\"p-col-12\">Resource type</label>\n      <div class=\"p-col-12\">\n        <!-- <p-dropdown [options]=\"resourceTypes\" [(ngModel)]=\"ccmPolicy.filters.resourceType\"\n        placeholder=\"Select Resource Type\">\n      </p-dropdown> -->\n       <p-multiSelect [options]=\"resourceTypes\" [(ngModel)]=\"ccmPolicy.filters.resourceType\"\n            defaultLabel=\"Select Types\" display=\"chip\" [style]=\"{'width':'100%'}\">\n          </p-multiSelect>\n      </div>\n    </div>\n  </div>\n</p-panel>\n\n<p-panel  styleClass=\"net-panel mb-10\" [toggleable]=\"true\"\n  header=\"Policies Alert\">\n  <div class=\"p-grid p-align-center w-100-p p-nogutter\">\n    <div class=\"p-col-12\">\n        <app-cav-notification-settings #notificationComponent\n          [notificationData]=\"notificationData\"></app-cav-notification-settings>\n    </div>\n  </div>  \n</p-panel>\n<div class=\"p-grid p-justify-end p-mt-3\">\n  <button pButton type=\"button\" \n          [label]=\"isEditMode ? 'Update' : 'Save'\" \n          icon=\"pi pi-check\" \n          class=\"p-button-primary\"\n          [disabled]=\"!ccmPolicy.policyName || ccmPolicy.policyName.trim() === ''\" \n          (click)=\"isEditMode ? updatePolicy() : savePolicy()\"> </button>\n</div>\n<!-- <p-dialog header=\"Save {{ccmPolicy.policyCategory}} Policy\" [(visible)]=\"saveContent\" [style]=\"{height: '200px', width:'450px'}\">\n  <div>\n    <label for=\"policyname\" class=\"font-semibold w-24 mr-5\">Policy Name</label>\n    <input type=\"text\" pInputText [(ngModel)]=\"ccmPolicy.policyName\" class=\"width-180\">\n  </div>\n  <div class=\"flex justify-end gap-2 right mt-40\">\n    <button pButton type=\"button\" label=\"Cancel\" severity=\"info\" class=\"p-button-primary mr-4\" (click)=\"cancelSave()\"></button>\n    <button pButton type=\"button\" label=\"Save\" class=\"p-button-primary mr-4\" [disabled]=\"(!ccmPolicy.policyName ||ccmPolicy.policyName.trim() == '' )\" (click)=\"savePolicy()\"></button>\n  </div>\n</p-dialog> -->\n</div>";
    /***/
  },

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

  /*! exports provided: default */

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

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


    __webpack_exports__["default"] = ".scroll-container {\n  max-height: 90vh;\n  /* take up 90% of viewport height */\n  overflow-y: auto;\n  /* enable vertical scroll */\n  padding-right: 8px;\n  /* prevents scrollbar overlap */\n}\n\n:host {\n  display: block;\n  height: 100vh;\n  /* full screen height */\n  overflow-y: auto;\n  /* enable vertical scroll */\n}";
    /***/
  },

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

  /*! exports provided: CcPoliciesComponent */

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

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


    __webpack_require__.d(__webpack_exports__, "CcPoliciesComponent", function () {
      return CcPoliciesComponent;
    });
    /* 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 _service_cc_policies_service__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(
    /*! ../service/cc-policies.service */
    "./src/app/pages/home/cloud-cost/cc-policies/service/cc-policies.service.ts");
    /* harmony import */


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


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


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


    var src_app_shared_cav_notification_settings_cav_notification_settings_component__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(
    /*! src/app/shared/cav-notification-settings/cav-notification-settings.component */
    "./src/app/shared/cav-notification-settings/cav-notification-settings.component.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");
    /* harmony import */


    var _cloud_data_source_service_cloud_data_source_service__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(
    /*! ../../../cloud-data-source/service/cloud-data-source.service */
    "./src/app/pages/home/cloud-data-source/service/cloud-data-source.service.ts");
    /* harmony import */


    var _cloud_data_source_service_cloud_data_source_state__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(
    /*! ../../../cloud-data-source/service/cloud-data-source.state */
    "./src/app/pages/home/cloud-data-source/service/cloud-data-source.state.ts");
    /* harmony import */


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


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


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


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


    var rxjs_operators__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(
    /*! rxjs/operators */
    "./node_modules/rxjs/_esm2015/operators/index.js");

    var CcPoliciesComponent = /*#__PURE__*/function () {
      function CcPoliciesComponent(ccmPoliciesService, messageService, router, sessionService, cloudDataSourceService, ccPoolsService) {
        _classCallCheck(this, CcPoliciesComponent);

        this.ccmPoliciesService = ccmPoliciesService;
        this.messageService = messageService;
        this.router = router;
        this.sessionService = sessionService;
        this.cloudDataSourceService = cloudDataSourceService;
        this.ccPoolsService = ccPoolsService;
        this.callFromActiveAlert = false;
        this.isOnlyReadable = false;
        this.dataSources = [];
        this.regions = [];
        this.pools = [];
        this.services = [];
        this.resourceTypes = [];
        this.owners = [];
        this.isPolicyCategoryLocked = false;
        this.isEditMode = false;
        this.currentTaskId = null;
        this.ccmPolicy = {
          policyCategory: 'Anomaly Detection',
          policyName: "",
          policyType: "",
          anomalyPolicy: {},
          quotaBudgetPolicy: {},
          taggingPolicy: {},
          resourceLifeCyclePolicy: {},
          description: "",
          filters: {}
        };
        this.panel = {
          collapsed: true
        };
        this.policyDescription = {
          'Resource Count': 'Daily ${ccmPolicy.policyType} must not exceed the average amount for the last ${ccmPolicy.anomalyPolicy.evaluationPeriod} days by ${ccmPolicy.anomalyPolicy.threshold}%.',
          'Expenses': 'Daily ${ccmPolicy.policyType} must not exceed the average amount for the last ${ccmPolicy.anomalyPolicy.evaluationPeriod} days by ${ccmPolicy.anomalyPolicy.threshold}%.',
          'Resource quota': 'Resource count must not exceed ${ccmPolicy.quotaBudgetPolicy.resourceCount}.',
          'Recurring Budget': 'Current month expenses must not exceed ${ccmPolicy.quotaBudgetPolicy.monthlyBudget}.',
          'Expiring Budget': 'Total expenses from ${ccmPolicy.quotaBudgetPolicy.startDate} must not exceed ${ccmPolicy.quotaBudgetPolicy.totalBudget}.',
          'Required tag': 'The ${ccmPolicy.taggingPolicy.requiredTag} tag is required starting from ${ccmPolicy.taggingPolicy.startDate}.',
          'Prohibited tag': 'Tag ${ccmPolicy.taggingPolicy.prohibitedTag} is prohibited starting from ${ccmPolicy.taggingPolicy.startDate}.',
          'Tags correlation': 'Resources tagged with ${ccmPolicy.taggingPolicy.primaryTag} must be tagged with ${ccmPolicy.taggingPolicy.correlatedTag} starting from ${ccmPolicy.taggingPolicy.startDate}.',
          'TTL': 'Alert if any resource in ${ccmPolicy.resourceLifeCyclePolicy.poolName} pool runs longer than ${ccmPolicy.resourceLifeCyclePolicy.ttl} hours.',
          'Daily expense limit': 'Alert if daily expenses for resources in ${ccmPolicy.resourceLifeCyclePolicy.poolName} pool exceed $${ccmPolicy.resourceLifeCyclePolicy.expenseLimit}.',
          'ON': 'Set time to start the Scheduler',
          'OFF': 'Set Time to stop the Scheduler '
        };
        this.policyTypeList = [{
          label: 'Anomaly Detection',
          value: 'Anomaly Detection'
        }, {
          label: 'Quotas and Budgets',
          value: 'Quotas and Budgets'
        }, {
          label: 'Tagging',
          value: 'Tagging'
        }, {
          label: 'Resource Lifecycle',
          value: 'Resource Lifecycle'
        }, {
          label: 'Power Scheduler',
          value: 'Power Scheduler'
        }];
        this.allResourceTypeList = {
          'Anomaly Detection': [{
            label: 'Resource Count',
            value: 'Resource Count'
          }, {
            label: 'Expenses',
            value: 'Expenses'
          }],
          'Quotas and Budgets': [{
            label: 'Resource quota',
            value: 'Resource quota'
          }, {
            label: 'Recurring Budget',
            value: 'Recurring Budget'
          }, {
            label: 'Expiring Budget',
            value: 'Expiring Budget'
          }],
          'Tagging': [{
            label: 'Required tag',
            value: 'Required tag'
          }, {
            label: 'Prohibited tag',
            value: 'Prohibited tag'
          }, {
            label: 'Tags correlation',
            value: 'Tags correlation'
          }],
          'Resource Lifecycle': [{
            label: 'TTL',
            value: 'TTL'
          }, {
            label: 'Daily expense limit',
            value: 'Daily expense limit'
          }],
          'Power Scheduler': [{
            label: 'ON',
            value: 'ON'
          }, {
            label: 'OFF',
            value: 'OFF'
          }]
        };
        this.suggestedFilters = [{
          label: 'Assigned to me',
          value: 'Assigned to me'
        }, {
          label: 'Instance',
          value: 'Instance'
        }, {
          label: 'Volume',
          value: 'Volume'
        }, {
          label: 'Active',
          value: 'Active'
        }, {
          label: 'With violated constraints',
          value: 'With violated constraints'
        }];
        this.selectedFilter = {};
        this.filteredResourceTypeList = [];
        this.selectedPolicy = {
          type: '',
          resourceType: '',
          threshold: null,
          budgetLimit: null,
          poolType: '',
          ttlValue: null,
          expenseLimit: null,
          missingTagLimit: null,
          timePeriod: '',
          baselineDays: 30,
          expiringBudgetLimit: null,
          startDate: '',
          endDate: ''
        };
        this.timePeriodList = [{
          label: 'Monthly',
          value: 'Monthly'
        }, {
          label: 'Quarterly',
          value: 'Quarterly'
        }, {
          label: 'Yearly',
          value: 'Yearly'
        }];
        this.saveContent = false;
        this.policiesRuleTemplate = [{
          "rule_set": {
            "rsName": "$Policy_name",
            "rules": [{
              "ruleName": "$policyName",
              "ruleOption": "Anomaly Detection",
              "template_type": "Resource Count",
              "ruleType": "POLICY",
              "description": {
                "policy_description": "$description"
              },
              "priority": 1,
              "factAggregationRequests": [{
                "metaData": {
                  "aggregateName": "ResourceCountAggregate",
                  "ruleName": "$policyName"
                },
                "sourceCollections": ["cloud_resources"],
                "destinationCollection": "cloud_resource_history",
                "periodicity": 300000,
                "groupby": [],
                "aggregates": [{
                  "aggregateName": "currentResourceCount",
                  "sourceAttribute": "currentResourceCount",
                  "aggregateFunction": "count",
                  "schedule": "true",
                  "interval": "now"
                }, {
                  "aggregateName": "avgResourceCount",
                  "sourceAttribute": "currentResourceCount",
                  "aggregateFunction": "avg",
                  "schedule": "false",
                  "interval": "last_$evaluationPeriod$_days"
                }],
                "filter": []
              }],
              "ruleConditions": [{
                "condType": "ALL",
                "ruleConditionsList": [{
                  "condName": "trigger_policy",
                  "fieldType": "Boolean",
                  // Note: the 1.3 is dynamic based on threshold. Logic below handles this.
                  "expression": "currentResourceCount > (avgResourceCount * $thresholdFactor$)",
                  "lhsOperand": {
                    "operationType": "FACT",
                    "factName": "VMInstance",
                    "field": "isAnomaly",
                    "dependsOn": [{
                      "field": "currentResourceCount",
                      "operationType": "FACT",
                      "factName": "VMInstance"
                    }, {
                      "field": "avgResourceCount",
                      "operationType": "FACT",
                      "factName": "VMInstance"
                    }]
                  },
                  "operator": "==",
                  "rhsOperand": {
                    "operationType": "VALUE",
                    "value": true
                  }
                }]
              }],
              "ruleSchedule": {
                "periodicity": "4",
                "units": "hours",
                "alignTime": "01:00"
              },
              "declarations": [{
                "factVar": "$resource",
                "factType": "LOGICAL",
                "factParam": "VMInstance"
              }],
              "actions": [{
                "atype": "NOTIFICATION",
                "kvlist": [{
                  "key": "notification_platform",
                  "value": "value1"
                }]
              }, {
                "atype": "EXECUTESCRIPT",
                "kvlist": [{
                  "key": "key1",
                  "value": "value1"
                }]
              }],
              "resourceType": "ALL"
            }]
          }
        }, {
          "rule_set": {
            "rsName": "$Policy_name",
            "rules": [{
              "ruleName": "$policyName",
              "ruleOption": "Anomaly Detection",
              "template_type": "Expenses",
              "ruleType": "POLICY",
              "description": {
                "policy_description": "$description"
              },
              "priority": 1,
              "factAggregationRequests": [{
                "metaData": {
                  "aggregateName": "ExpenseAggregate",
                  "ruleName": "$policyName"
                },
                "sourceCollections": ["cloud_resources", "cloud_cost_visibility"],
                "destinationCollection": "cloud_cost_history",
                "periodicity": 300000,
                "groupby": [],
                "aggregates": [{
                  "aggregateName": "currentExpenses",
                  "sourceAttribute": "currentExpenses",
                  "aggregateFunction": "sum",
                  "schedule": "true",
                  "interval": "now"
                }, {
                  "aggregateName": "avgExpenses",
                  "sourceAttribute": "currentExpenses",
                  "aggregateFunction": "avg",
                  "schedule": "false",
                  "interval": "last_$evaluationPeriod$_days"
                }],
                "filter": []
              }],
              "ruleConditions": [{
                "condType": "ALL",
                "ruleConditionsList": [{
                  "condName": "trigger_policy",
                  "fieldType": "Boolean",
                  "expression": "currentExpenses > (avgExpenses * $thresholdFactor$)",
                  "lhsOperand": {
                    "operationType": "FACT",
                    "factName": "VMInstance",
                    "field": "isAnomaly",
                    "dependsOn": [{
                      "field": "currentExpenses",
                      "operationType": "FACT",
                      "factName": "VMInstance"
                    }, {
                      "field": "avgExpenses",
                      "operationType": "FACT",
                      "factName": "VMInstance"
                    }]
                  },
                  "operator": "==",
                  "rhsOperand": {
                    "operationType": "VALUE",
                    "value": true
                  }
                }]
              }],
              "ruleSchedule": {
                "periodicity": "4",
                "units": "hours",
                "alignTime": "01:00"
              },
              "declarations": [{
                "factVar": "$resource",
                "factType": "LOGICAL",
                "factParam": "VMInstance"
              }],
              "actions": [{
                "atype": "NOTIFICATION",
                "kvlist": [{
                  "key": "notification_platform",
                  "value": "value1"
                }]
              }, {
                "atype": "EXECUTESCRIPT",
                "kvlist": [{
                  "key": "key1",
                  "value": "value1"
                }]
              }],
              "resourceType": "ALL"
            }]
          }
        }, {
          "rule_set": {
            "rsName": "$Policy_name",
            "rules": [{
              "ruleName": "$policyName",
              "ruleOption": "Quotas and Budgets",
              "template_type": "Resource quota",
              "ruleType": "POLICY",
              "description": {
                "policy_description": "$description"
              },
              "priority": 1,
              "ruleSchedule": {
                "periodicity": "4",
                "units": "hours",
                "alignTime": "01:00"
              },
              "factAggregationRequests": [{
                "metaData": {
                  "aggregateName": "ResourceCountAggregate",
                  "ruleName": ""
                },
                "sourceCollections": ["cloud_resources", "resource_metrics", "cloud_cost_visibility"],
                "destinationCollection": "",
                "periodicity": 0,
                "groupby": [],
                "aggregates": [{
                  "aggregateName": "resourceCount",
                  "sourceAttribute": "resource",
                  "aggregateFunction": "count",
                  "interval": "now",
                  "metricName": ""
                }],
                "life": 0,
                "filter": [] // Add this to hold the dynamic AzureTest/Region filters

              }],
              "declarations": [{
                "factVar": "$resource",
                "factType": "LOGICAL",
                "factParam": "VMInstance"
              }],
              "ruleConditions": [{
                "condType": "ALL",
                "ruleConditionsList": [{
                  "condName": "trigger_policy",
                  "expression": "resourceCount > $resourceCount$",
                  "fieldType": "Boolean",
                  "lhsOperand": {
                    "operationType": "FACT",
                    "factName": "VMInstance",
                    "field": "isQuotaViolated",
                    "dependsOn": [{
                      "field": "resourceCount",
                      "operationType": "FACT",
                      "factName": "VMInstance"
                    }]
                  },
                  "operator": "==",
                  "rhsOperand": {
                    "operationType": "VALUE",
                    "value": true
                  }
                }]
              }],
              "actions": [{
                "atype": "NOTIFICATION",
                "kvlist": [{
                  "key": "notification_platform",
                  "value": "value1"
                }]
              }, {
                "atype": "EXECUTESCRIPT",
                "kvlist": [{
                  "key": "key1",
                  "value": "value1"
                }]
              }],
              "resourceType": "ALL"
            }]
          }
        }, {
          "rule_set": {
            "rsName": "$Policy_name",
            "rules": [{
              "ruleName": "$policyName",
              "ruleOption": "Quotas and Budgets",
              "template_type": "Recurring Budget",
              "ruleType": "POLICY",
              "description": {
                "policy_description": "$description"
              },
              "priority": 1,
              "ruleSchedule": {
                "periodicity": "4",
                "units": "hours",
                "alignTime": "01:00"
              },
              "factAggregationRequests": [{
                "metaData": {
                  "aggregateName": "RecurringBudgetAggregate",
                  "ruleName": ""
                },
                "sourceCollections": ["cloud_resources", "resource_metrics", "cloud_cost_visibility"],
                "destinationCollection": "",
                "periodicity": 0,
                "groupby": [],
                "aggregates": [{
                  "aggregateName": "currentMonthCost",
                  "sourceAttribute": "cost",
                  "aggregateFunction": "sum",
                  "interval": "$interval$",
                  "metricName": ""
                }],
                "life": 0,
                "filter": []
              }],
              "declarations": [{
                "factVar": "$resource",
                "factType": "LOGICAL",
                "factParam": "VMInstance"
              }],
              "ruleConditions": [{
                "condType": "ALL",
                "ruleConditionsList": [{
                  "condName": "trigger_policy",
                  "expression": "currentMonthCost > $monthlyBudget$",
                  "fieldType": "Boolean",
                  "lhsOperand": {
                    "operationType": "FACT",
                    "factName": "VMInstance",
                    "field": "isBudgetViolated",
                    "dependsOn": [{
                      "field": "currentMonthCost",
                      "operationType": "FACT",
                      "factName": "VMInstance"
                    }]
                  },
                  "operator": "==",
                  "rhsOperand": {
                    "operationType": "VALUE",
                    "value": true
                  }
                }]
              }],
              "actions": [{
                "atype": "NOTIFICATION",
                "kvlist": [{
                  "key": "notification_platform",
                  "value": "value1"
                }]
              }, {
                "atype": "EXECUTESCRIPT",
                "kvlist": [{
                  "key": "key1",
                  "value": "value1"
                }]
              }],
              "resourceType": "ALL"
            }]
          }
        }, {
          "rule_set": {
            "rsName": "$Policy_name",
            "rules": [{
              "ruleName": "$policyName",
              "ruleOption": "Quotas and Budgets",
              "template_type": "Expiring Budget",
              "ruleType": "POLICY",
              "description": {
                "policy_description": "$description"
              },
              "priority": 1,
              "ruleSchedule": {
                "periodicity": "4",
                "units": "hours",
                "alignTime": "01:00"
              },
              "factAggregationRequests": [{
                "metaData": {
                  "aggregateName": "ExpiringBudgetAggregate",
                  "ruleName": ""
                },
                "sourceCollections": ["cloud_resources", "resource_metrics", "cloud_cost_visibility"],
                "destinationCollection": "",
                "periodicity": 0,
                "groupby": [],
                "aggregates": [{
                  "aggregateName": "totalCumulativeSpend",
                  "sourceAttribute": "cost",
                  "aggregateFunction": "sum",
                  "interval": "$startDate$",
                  "metricName": ""
                }],
                "life": 0,
                "filter": []
              }],
              "declarations": [{
                "factVar": "$resource",
                "factType": "LOGICAL",
                "factParam": "VMInstance"
              }],
              "ruleConditions": [{
                "condType": "ALL",
                "ruleConditionsList": [{
                  "condName": "trigger_policy",
                  "expression": "totalCumulativeSpend > $totalBudget$",
                  "fieldType": "Boolean",
                  "lhsOperand": {
                    "operationType": "FACT",
                    "factName": "VMInstance",
                    "field": "isBudgetViolated",
                    "dependsOn": [{
                      "field": "totalCumulativeSpend",
                      "operationType": "FACT",
                      "factName": "VMInstance"
                    }]
                  },
                  "operator": "==",
                  "rhsOperand": {
                    "operationType": "VALUE",
                    "value": true
                  }
                }]
              }],
              "actions": [{
                "atype": "NOTIFICATION",
                "kvlist": [{
                  "key": "notification_platform",
                  "value": "value1"
                }]
              }, {
                "atype": "EXECUTESCRIPT",
                "kvlist": [{
                  "key": "key1",
                  "value": "value1"
                }]
              }],
              "resourceType": "ALL"
            }]
          }
        }, {
          "rule_set": {
            "rsName": "$Policy_name",
            "rules": [{
              "ruleName": "$policyName",
              "ruleOption": "Tagging",
              "template_type": "Required tag",
              "ruleType": "POLICY",
              "description": {
                "policy_description": "$description"
              },
              "priority": 1,
              "ruleSchedule": {
                "periodicity": "4",
                "units": "hours",
                "alignTime": "01:00"
              },
              "declarations": [{
                "factVar": "$resource",
                "factType": "LOGICAL",
                "factParam": "VMInstance"
              }],
              "ruleConditions": [{
                "condType": "ALL",
                "ruleConditionsList": [{
                  "rhsOperand": {
                    "operationType": "VALUE",
                    "value": "false"
                  },
                  "fieldType": "Boolean",
                  "lhsOperand": {
                    "field": "hasTag",
                    "operationType": "FACT",
                    "factName": "VMInstance",
                    "dependsOn": [{
                      "field": "TagMap",
                      "operationType": "FACT",
                      "factName": "VMInstance",
                      "fieldValueType": "ATTRIBUTE"
                    }]
                  },
                  "expression": "TagMap != null && TagMap.containsKey('$requiredTag$')",
                  "condName": "policies_condition",
                  "operator": "=="
                }, {
                  "condName": "policies_filters",
                  "expression": "$dataSource$.contains(DataSourceName)",
                  "fieldType": "Boolean",
                  "lhsOperand": {
                    "field": "isMatchingDataSource",
                    "operationType": "FACT",
                    "factName": "VMInstance",
                    "dependsOn": [{
                      "field": "DataSourceName",
                      "operationType": "FACT",
                      "factName": "VMInstance"
                    }]
                  },
                  "operator": "==",
                  "rhsOperand": {
                    "operationType": "VALUE",
                    "value": "true"
                  }
                }, {
                  "condName": "policies_filters",
                  "expression": "$pool$.contains(PoolName)",
                  "fieldType": "Boolean",
                  "lhsOperand": {
                    "field": "isMatchingPool",
                    "operationType": "FACT",
                    "factName": "VMInstance",
                    "dependsOn": [{
                      "field": "PoolName",
                      "operationType": "FACT",
                      "factName": "VMInstance"
                    }]
                  },
                  "operator": "==",
                  "rhsOperand": {
                    "operationType": "VALUE",
                    "value": "true"
                  }
                }, {
                  "condName": "policies_filters",
                  "expression": "$owner$.contains(owner)",
                  "fieldType": "Boolean",
                  "lhsOperand": {
                    "field": "isMatchingOwner",
                    "operationType": "FACT",
                    "factName": "VMInstance",
                    "dependsOn": [{
                      "field": "owner",
                      "operationType": "FACT",
                      "factName": "VMInstance"
                    }]
                  },
                  "operator": "==",
                  "rhsOperand": {
                    "operationType": "VALUE",
                    "value": "true"
                  }
                }, {
                  "condName": "policies_filters",
                  "expression": "$region$.contains(Region)",
                  "fieldType": "Boolean",
                  "lhsOperand": {
                    "field": "isMatchingRegion",
                    "operationType": "FACT",
                    "factName": "VMInstance",
                    "dependsOn": [{
                      "field": "Region",
                      "operationType": "FACT",
                      "factName": "VMInstance"
                    }]
                  },
                  "operator": "==",
                  "rhsOperand": {
                    "operationType": "VALUE",
                    "value": "true"
                  }
                }, {
                  "condName": "policies_filters",
                  "expression": "$service$.contains(service)",
                  "fieldType": "Boolean",
                  "lhsOperand": {
                    "field": "isMatchingService",
                    "operationType": "FACT",
                    "factName": "VMInstance",
                    "dependsOn": [{
                      "field": "service",
                      "operationType": "FACT",
                      "factName": "VMInstance"
                    }]
                  },
                  "operator": "==",
                  "rhsOperand": {
                    "operationType": "VALUE",
                    "value": "true"
                  }
                }, {
                  "condName": "policies_filters",
                  "expression": "$resourceType$.contains(resourceType)",
                  "fieldType": "Boolean",
                  "lhsOperand": {
                    "field": "isMatchingResourceType",
                    "operationType": "FACT",
                    "factName": "VMInstance",
                    "dependsOn": [{
                      "field": "resourceType",
                      "operationType": "FACT",
                      "factName": "VMInstance"
                    }]
                  },
                  "operator": "==",
                  "rhsOperand": {
                    "operationType": "VALUE",
                    "value": "true"
                  }
                }]
              }],
              "actions": [{
                "atype": "NOTIFICATION",
                "kvlist": [{
                  "key": "notification_platform",
                  "value": "value1"
                }]
              }, {
                "atype": "EXECUTESCRIPT",
                "kvlist": [{
                  "key": "key1",
                  "value": "value1"
                }]
              }],
              "resourceType": "ALL"
            }]
          }
        }, {
          "rule_set": {
            "rsName": "$Policy_name",
            "rules": [{
              "ruleName": "$policyName",
              "ruleOption": "Tagging",
              "template_type": "Prohibited tag",
              "ruleType": "POLICY",
              "description": {
                "policy_description": "$description"
              },
              "priority": 1,
              "ruleSchedule": {
                "periodicity": "4",
                "units": "hours",
                "alignTime": "01:00"
              },
              "declarations": [{
                "factVar": "$resource",
                "factType": "LOGICAL",
                "factParam": "VMInstance"
              }],
              "ruleConditions": [{
                "condType": "ALL",
                "ruleConditionsList": [{
                  "rhsOperand": {
                    "operationType": "VALUE",
                    "value": "true"
                  },
                  "fieldType": "Boolean",
                  "lhsOperand": {
                    "field": "hasTag",
                    "operationType": "FACT",
                    "factName": "VMInstance",
                    "dependsOn": [{
                      "field": "TagMap",
                      "operationType": "FACT",
                      "factName": "VMInstance",
                      "fieldValueType": "ATTRIBUTE"
                    }]
                  },
                  "expression": "TagMap != null && TagMap.containsKey('$prohibitedTag$')",
                  "condName": "trigger_policy",
                  "operator": "=="
                }, {
                  "condName": "policies_filters",
                  "expression": "$dataSource$.contains(DataSourceName)",
                  "fieldType": "Boolean",
                  "lhsOperand": {
                    "field": "isMatchingDataSource",
                    "operationType": "FACT",
                    "factName": "VMInstance",
                    "dependsOn": [{
                      "field": "DataSourceName",
                      "operationType": "FACT",
                      "factName": "VMInstance"
                    }]
                  },
                  "operator": "==",
                  "rhsOperand": {
                    "operationType": "VALUE",
                    "value": "true"
                  }
                }, {
                  "condName": "policies_filters",
                  "expression": "$pool$.contains(PoolName)",
                  "fieldType": "Boolean",
                  "lhsOperand": {
                    "field": "isMatchingPool",
                    "operationType": "FACT",
                    "factName": "VMInstance",
                    "dependsOn": [{
                      "field": "PoolName",
                      "operationType": "FACT",
                      "factName": "VMInstance"
                    }]
                  },
                  "operator": "==",
                  "rhsOperand": {
                    "operationType": "VALUE",
                    "value": "true"
                  }
                }, {
                  "condName": "policies_filters",
                  "expression": "$owner$.contains(owner)",
                  "fieldType": "Boolean",
                  "lhsOperand": {
                    "field": "isMatchingOwner",
                    "operationType": "FACT",
                    "factName": "VMInstance",
                    "dependsOn": [{
                      "field": "owner",
                      "operationType": "FACT",
                      "factName": "VMInstance"
                    }]
                  },
                  "operator": "==",
                  "rhsOperand": {
                    "operationType": "VALUE",
                    "value": "true"
                  }
                }, {
                  "condName": "policies_filters",
                  "expression": "$region$.contains(Region)",
                  "fieldType": "Boolean",
                  "lhsOperand": {
                    "field": "isMatchingRegion",
                    "operationType": "FACT",
                    "factName": "VMInstance",
                    "dependsOn": [{
                      "field": "Region",
                      "operationType": "FACT",
                      "factName": "VMInstance"
                    }]
                  },
                  "operator": "==",
                  "rhsOperand": {
                    "operationType": "VALUE",
                    "value": "true"
                  }
                }, {
                  "condName": "policies_filters",
                  "expression": "$service$.contains(service)",
                  "fieldType": "Boolean",
                  "lhsOperand": {
                    "field": "isMatchingService",
                    "operationType": "FACT",
                    "factName": "VMInstance",
                    "dependsOn": [{
                      "field": "service",
                      "operationType": "FACT",
                      "factName": "VMInstance"
                    }]
                  },
                  "operator": "==",
                  "rhsOperand": {
                    "operationType": "VALUE",
                    "value": "true"
                  }
                }, {
                  "condName": "policies_filters",
                  "expression": "$resourceType$.contains(resourceType)",
                  "fieldType": "Boolean",
                  "lhsOperand": {
                    "field": "isMatchingResourceType",
                    "operationType": "FACT",
                    "factName": "VMInstance",
                    "dependsOn": [{
                      "field": "resourceType",
                      "operationType": "FACT",
                      "factName": "VMInstance"
                    }]
                  },
                  "operator": "==",
                  "rhsOperand": {
                    "operationType": "VALUE",
                    "value": "true"
                  }
                }]
              }],
              "actions": [{
                "atype": "NOTIFICATION",
                "kvlist": [{
                  "key": "notification_platform",
                  "value": "value1"
                }]
              }, {
                "atype": "EXECUTESCRIPT",
                "kvlist": [{
                  "key": "key1",
                  "value": "value1"
                }]
              }],
              "resourceType": "ALL"
            }]
          }
        }, {
          "rule_set": {
            "rsName": "$Policy_name",
            "rules": [{
              "ruleName": "$policyName",
              "ruleOption": "Tagging",
              "template_type": "Tags correlation",
              "ruleType": "POLICY",
              "description": {
                "policy_description": "$description"
              },
              "priority": 1,
              "ruleSchedule": {
                "periodicity": "4",
                "units": "hours",
                "alignTime": "01:00"
              },
              "declarations": [{
                "factVar": "$resource",
                "factType": "LOGICAL",
                "factParam": "VMInstance"
              }],
              "ruleConditions": [{
                "condType": "ALL",
                "ruleConditionsList": [{
                  "condName": "policies_condition",
                  "fieldType": "Long",
                  "lhsOperand": {
                    "operationType": "FACT",
                    "factName": "VMInstance",
                    "field": "CreatedAt"
                  },
                  "operator": ">",
                  "rhsOperand": {
                    "operationType": "VALUE",
                    "value": "$startTimestamp"
                  }
                }, {
                  "rhsOperand": {
                    "operationType": "VALUE",
                    "value": "true"
                  },
                  "fieldType": "Boolean",
                  "lhsOperand": {
                    "field": "hasPrimaryTag",
                    "operationType": "FACT",
                    "factName": "VMInstance",
                    "dependsOn": [{
                      "field": "TagMap",
                      "operationType": "FACT",
                      "factName": "VMInstance",
                      "fieldValueType": "ATTRIBUTE"
                    }]
                  },
                  "expression": "TagMap != null && TagMap.containsKey('$primaryTag$')",
                  "condName": "policies_condition",
                  "operator": "=="
                }, {
                  "rhsOperand": {
                    "operationType": "VALUE",
                    "value": "false"
                  },
                  "fieldType": "Boolean",
                  "lhsOperand": {
                    "field": "hasCorrelatedTag",
                    "operationType": "FACT",
                    "factName": "VMInstance",
                    "dependsOn": [{
                      "field": "TagMap",
                      "operationType": "FACT",
                      "factName": "VMInstance",
                      "fieldValueType": "ATTRIBUTE"
                    }]
                  },
                  "expression": "TagMap != null && TagMap.containsKey('$correlatedTag$')",
                  "condName": "policies_condition",
                  "operator": "=="
                }, {
                  "condName": "policies_filters",
                  "expression": "$dataSource$.contains(DataSourceName)",
                  "fieldType": "Boolean",
                  "lhsOperand": {
                    "field": "isMatchingDataSource",
                    "operationType": "FACT",
                    "factName": "VMInstance",
                    "dependsOn": [{
                      "field": "DataSourceName",
                      "operationType": "FACT",
                      "factName": "VMInstance"
                    }]
                  },
                  "operator": "==",
                  "rhsOperand": {
                    "operationType": "VALUE",
                    "value": "true"
                  }
                }, {
                  "condName": "policies_filters",
                  "expression": "$pool$.contains(PoolName)",
                  "fieldType": "Boolean",
                  "lhsOperand": {
                    "field": "isMatchingPool",
                    "operationType": "FACT",
                    "factName": "VMInstance",
                    "dependsOn": [{
                      "field": "PoolName",
                      "operationType": "FACT",
                      "factName": "VMInstance"
                    }]
                  },
                  "operator": "==",
                  "rhsOperand": {
                    "operationType": "VALUE",
                    "value": "true"
                  }
                }, {
                  "condName": "policies_filters",
                  "expression": "$owner$.contains(owner)",
                  "fieldType": "Boolean",
                  "lhsOperand": {
                    "field": "isMatchingOwner",
                    "operationType": "FACT",
                    "factName": "VMInstance",
                    "dependsOn": [{
                      "field": "owner",
                      "operationType": "FACT",
                      "factName": "VMInstance"
                    }]
                  },
                  "operator": "==",
                  "rhsOperand": {
                    "operationType": "VALUE",
                    "value": "true"
                  }
                }, {
                  "condName": "policies_filters",
                  "expression": "$region$.contains(Region)",
                  "fieldType": "Boolean",
                  "lhsOperand": {
                    "field": "isMatchingRegion",
                    "operationType": "FACT",
                    "factName": "VMInstance",
                    "dependsOn": [{
                      "field": "Region",
                      "operationType": "FACT",
                      "factName": "VMInstance"
                    }]
                  },
                  "operator": "==",
                  "rhsOperand": {
                    "operationType": "VALUE",
                    "value": "true"
                  }
                }, {
                  "condName": "policies_filters",
                  "expression": "$service$.contains(service)",
                  "fieldType": "Boolean",
                  "lhsOperand": {
                    "field": "isMatchingService",
                    "operationType": "FACT",
                    "factName": "VMInstance",
                    "dependsOn": [{
                      "field": "service",
                      "operationType": "FACT",
                      "factName": "VMInstance"
                    }]
                  },
                  "operator": "==",
                  "rhsOperand": {
                    "operationType": "VALUE",
                    "value": "true"
                  }
                }, {
                  "condName": "policies_filters",
                  "expression": "$resourceType$.contains(resourceType)",
                  "fieldType": "Boolean",
                  "lhsOperand": {
                    "field": "isMatchingResourceType",
                    "operationType": "FACT",
                    "factName": "VMInstance",
                    "dependsOn": [{
                      "field": "resourceType",
                      "operationType": "FACT",
                      "factName": "VMInstance"
                    }]
                  },
                  "operator": "==",
                  "rhsOperand": {
                    "operationType": "VALUE",
                    "value": "true"
                  }
                }]
              }],
              "actions": [{
                "atype": "NOTIFICATION",
                "kvlist": [{
                  "key": "notification_platform",
                  "value": "value1"
                }]
              }, {
                "atype": "EXECUTESCRIPT",
                "kvlist": [{
                  "key": "key1",
                  "value": "value1"
                }]
              }],
              "resourceType": "ALL"
            }]
          }
        }, {
          "rule_set": {
            "rsName": "$Policy_name",
            "rules": [{
              "ruleName": "$policyName",
              "ruleOption": "Resource Lifecycle",
              "template_type": "Daily expense limit",
              "ruleType": "POLICY",
              "description": {
                "policy_description": "$description"
              },
              "priority": 1,
              "factAggregationRequests": [{
                "metaData": {
                  "aggregateName": "DailyCostCalc",
                  "ruleName": "$policyName"
                },
                "sourceCollections": ["cloud_resources", "cloud_cost_visibility"],
                "destinationCollection": "",
                "periodicity": 0,
                "groupby": ["resourceId", "PoolName"],
                "aggregates": [{
                  "aggregateName": "dailyCost",
                  "sourceAttribute": "cost",
                  "aggregateFunction": "sum",
                  "schedule": "false",
                  "interval": "last_day"
                }],
                "filter": []
              }],
              "ruleConditions": [{
                "condType": "ALL",
                "ruleConditionsList": [{
                  "condName": "check_cost_limit",
                  "fieldType": "Boolean",
                  "expression": "dailyCost > $expenseLimit$",
                  "lhsOperand": {
                    "operationType": "FACT",
                    "factName": "VMInstance",
                    "field": "isViolation",
                    "dependsOn": [{
                      "field": "dailyCost",
                      "operationType": "FACT",
                      "factName": "VMInstance"
                    }]
                  },
                  "operator": "==",
                  "rhsOperand": {
                    "operationType": "VALUE",
                    "value": true
                  }
                }, {
                  "condName": "check_pool_name",
                  "fieldType": "String",
                  "lhsOperand": {
                    "operationType": "FACT",
                    "factName": "VMInstance",
                    "field": "PoolName"
                  },
                  "operator": "==",
                  "rhsOperand": {
                    "operationType": "VALUE",
                    "value": "$pool"
                  }
                }]
              }],
              "ruleSchedule": {
                "periodicity": "4",
                "units": "hours",
                "alignTime": "01:00"
              },
              "declarations": [{
                "factVar": "$resource",
                "factType": "LOGICAL",
                "factParam": "VMInstance"
              }],
              "actions": [{
                "atype": "NOTIFICATION",
                "kvlist": [{
                  "key": "notification_platform",
                  "value": "value1"
                }]
              }, {
                "atype": "EXECUTESCRIPT",
                "kvlist": [{
                  "key": "key1",
                  "value": "value1"
                }]
              }],
              "resourceType": "ALL"
            }]
          }
        }, {
          "rule_set": {
            "rsName": "$Policy_name",
            "rules": [{
              "ruleName": "$policyName",
              "ruleOption": "Resource Lifecycle",
              "template_type": "TTL",
              "ruleType": "POLICY",
              "description": {
                "policy_description": "$description"
              },
              "priority": 1,
              "ruleConditions": [{
                "condType": "ALL",
                "ruleConditionsList": [{
                  "condName": "check_ttl_limit",
                  "fieldType": "Boolean",
                  "expression": "AgeHours > $ttl$",
                  "lhsOperand": {
                    "operationType": "FACT",
                    "factName": "VMInstance",
                    "field": "isViolation",
                    "dependsOn": [{
                      "field": "AgeHours",
                      "operationType": "FACT",
                      "factName": "VMInstance"
                    }]
                  },
                  "operator": "==",
                  "rhsOperand": {
                    "operationType": "VALUE",
                    "value": true
                  }
                }, {
                  "condName": "check_pool_name",
                  "fieldType": "String",
                  "lhsOperand": {
                    "operationType": "FACT",
                    "factName": "VMInstance",
                    "field": "PoolName"
                  },
                  "operator": "==",
                  "rhsOperand": {
                    "operationType": "VALUE",
                    "value": "$poolName"
                  }
                }]
              }],
              "ruleSchedule": {
                "periodicity": "4",
                "units": "hours",
                "alignTime": "01:00"
              },
              "declarations": [{
                "factVar": "$resource",
                "factType": "LOGICAL",
                "factParam": "VMInstance"
              }],
              "actions": [{
                "atype": "NOTIFICATION",
                "kvlist": [{
                  "key": "notification_platform",
                  "value": "value1"
                }]
              }, {
                "atype": "EXECUTESCRIPT",
                "kvlist": [{
                  "key": "key1",
                  "value": "value1"
                }]
              }],
              "resourceType": "INSTANCE"
            }]
          }
        }, {
          "rule_set": {
            "rsName": "$Policy_name",
            "rules": [{
              "ruleName": "$policyName",
              "ruleOption": "Power Scheduler",
              "template_type": "ON",
              "ruleType": "POLICY",
              "description": {
                "policy_description": "$description"
              },
              "priority": 1,
              "ruleSchedule": {
                "periodicity": "4",
                "units": "hours",
                "alignTime": "01:00"
              },
              "declarations": [{
                "factVar": "$resource",
                "factType": "LOGICAL",
                "factParam": "VMInstance"
              }],
              "ruleConditions": [{
                "condType": "ALL",
                "ruleConditionsList": [// {
                //   "condName": "policies_filters",
                //   "fieldType": "String",
                //   "lhsOperand": {
                //     "operationType": "FACT",
                //     "factName": "VMInstance",
                //     "field": "filter_sugg",
                //   },
                //   "operator": "==",
                //   "rhsOperand": {
                //     "operationType": "VALUE",
                //     "value": "$suggested"
                //   }
                // },
                {
                  "condName": "policies_filters",
                  "expression": "$dataSource$.contains(DataSourceName)",
                  "fieldType": "Boolean",
                  "lhsOperand": {
                    "field": "isMatchingDataSource",
                    "operationType": "FACT",
                    "factName": "VMInstance",
                    "dependsOn": [{
                      "field": "DataSourceName",
                      "operationType": "FACT",
                      "factName": "VMInstance"
                    }]
                  },
                  "operator": "==",
                  "rhsOperand": {
                    "operationType": "VALUE",
                    "value": "true"
                  }
                }, {
                  "condName": "policies_filters",
                  "expression": "$pool$.contains(PoolName)",
                  "fieldType": "Boolean",
                  "lhsOperand": {
                    "field": "isMatchingPool",
                    "operationType": "FACT",
                    "factName": "VMInstance",
                    "dependsOn": [{
                      "field": "PoolName",
                      "operationType": "FACT",
                      "factName": "VMInstance"
                    }]
                  },
                  "operator": "==",
                  "rhsOperand": {
                    "operationType": "VALUE",
                    "value": "true"
                  }
                }, {
                  "condName": "policies_filters",
                  "expression": "$owner$.contains(owner)",
                  "fieldType": "Boolean",
                  "lhsOperand": {
                    "field": "isMatchingOwner",
                    "operationType": "FACT",
                    "factName": "VMInstance",
                    "dependsOn": [{
                      "field": "owner",
                      "operationType": "FACT",
                      "factName": "VMInstance"
                    }]
                  },
                  "operator": "==",
                  "rhsOperand": {
                    "operationType": "VALUE",
                    "value": "true"
                  }
                }, {
                  "condName": "policies_filters",
                  "expression": "$region$.contains(Region)",
                  "fieldType": "Boolean",
                  "lhsOperand": {
                    "field": "isMatchingRegion",
                    "operationType": "FACT",
                    "factName": "VMInstance",
                    "dependsOn": [{
                      "field": "Region",
                      "operationType": "FACT",
                      "factName": "VMInstance"
                    }]
                  },
                  "operator": "==",
                  "rhsOperand": {
                    "operationType": "VALUE",
                    "value": "true"
                  }
                }, {
                  "condName": "policies_filters",
                  "expression": "$service$.contains(service)",
                  "fieldType": "Boolean",
                  "lhsOperand": {
                    "field": "isMatchingService",
                    "operationType": "FACT",
                    "factName": "VMInstance",
                    "dependsOn": [{
                      "field": "service",
                      "operationType": "FACT",
                      "factName": "VMInstance"
                    }]
                  },
                  "operator": "==",
                  "rhsOperand": {
                    "operationType": "VALUE",
                    "value": "true"
                  }
                }, {
                  "condName": "policies_filters",
                  "expression": "$resourceType$.contains(resourceType)",
                  "fieldType": "Boolean",
                  "lhsOperand": {
                    "field": "isMatchingResourceType",
                    "operationType": "FACT",
                    "factName": "VMInstance",
                    "dependsOn": [{
                      "field": "resourceType",
                      "operationType": "FACT",
                      "factName": "VMInstance"
                    }]
                  },
                  "operator": "==",
                  "rhsOperand": {
                    "operationType": "VALUE",
                    "value": "true"
                  }
                }]
              }],
              "actions": [{
                "atype": "NOTIFICATION",
                "kvlist": [{
                  "key": "notification_platform",
                  "value": "value1"
                }]
              }, {
                "atype": "EXECUTESCRIPT",
                "kvlist": [{
                  "key": "key1",
                  "value": "value1"
                }]
              }],
              "resourceType": "ALL"
            }]
          }
        }, {
          "rule_set": {
            "rsName": "$Policy_name",
            "rules": [{
              "ruleName": "$policyName",
              "ruleOption": "Power Scheduler",
              "template_type": "OFF",
              "ruleType": "POLICY",
              "description": {
                "policy_description": "$description"
              },
              "priority": 1,
              "ruleSchedule": {
                "periodicity": "4",
                "units": "hours",
                "alignTime": "01:00"
              },
              "declarations": [{
                "factVar": "$resource",
                "factType": "LOGICAL",
                "factParam": "VMInstance"
              }],
              "ruleConditions": [{
                "condType": "ALL",
                "ruleConditionsList": [// {
                //   "condName": "policies_filters",
                //   "fieldType": "String",
                //   "lhsOperand": {
                //     "operationType": "FACT",
                //     "factName": "VMInstance",
                //     "field": "filter_sugg",
                //   },
                //   "operator": "==",
                //   "rhsOperand": {
                //     "operationType": "VALUE",
                //     "value": "$suggested"
                //   }
                // },
                {
                  "condName": "policies_filters",
                  "expression": "$dataSource$.contains(DataSourceName)",
                  "fieldType": "Boolean",
                  "lhsOperand": {
                    "field": "isMatchingDataSource",
                    "operationType": "FACT",
                    "factName": "VMInstance",
                    "dependsOn": [{
                      "field": "DataSourceName",
                      "operationType": "FACT",
                      "factName": "VMInstance"
                    }]
                  },
                  "operator": "==",
                  "rhsOperand": {
                    "operationType": "VALUE",
                    "value": "true"
                  }
                }, {
                  "condName": "policies_filters",
                  "expression": "$pool$.contains(PoolName)",
                  "fieldType": "Boolean",
                  "lhsOperand": {
                    "field": "isMatchingPool",
                    "operationType": "FACT",
                    "factName": "VMInstance",
                    "dependsOn": [{
                      "field": "PoolName",
                      "operationType": "FACT",
                      "factName": "VMInstance"
                    }]
                  },
                  "operator": "==",
                  "rhsOperand": {
                    "operationType": "VALUE",
                    "value": "true"
                  }
                }, {
                  "condName": "policies_filters",
                  "expression": "$owner$.contains(owner)",
                  "fieldType": "Boolean",
                  "lhsOperand": {
                    "field": "isMatchingOwner",
                    "operationType": "FACT",
                    "factName": "VMInstance",
                    "dependsOn": [{
                      "field": "owner",
                      "operationType": "FACT",
                      "factName": "VMInstance"
                    }]
                  },
                  "operator": "==",
                  "rhsOperand": {
                    "operationType": "VALUE",
                    "value": "true"
                  }
                }, {
                  "condName": "policies_filters",
                  "expression": "$region$.contains(Region)",
                  "fieldType": "Boolean",
                  "lhsOperand": {
                    "field": "isMatchingRegion",
                    "operationType": "FACT",
                    "factName": "VMInstance",
                    "dependsOn": [{
                      "field": "Region",
                      "operationType": "FACT",
                      "factName": "VMInstance"
                    }]
                  },
                  "operator": "==",
                  "rhsOperand": {
                    "operationType": "VALUE",
                    "value": "true"
                  }
                }, {
                  "condName": "policies_filters",
                  "expression": "$service$.contains(service)",
                  "fieldType": "Boolean",
                  "lhsOperand": {
                    "field": "isMatchingService",
                    "operationType": "FACT",
                    "factName": "VMInstance",
                    "dependsOn": [{
                      "field": "service",
                      "operationType": "FACT",
                      "factName": "VMInstance"
                    }]
                  },
                  "operator": "==",
                  "rhsOperand": {
                    "operationType": "VALUE",
                    "value": "true"
                  }
                }, {
                  "condName": "policies_filters",
                  "expression": "$resourceType$.contains(resourceType)",
                  "fieldType": "Boolean",
                  "lhsOperand": {
                    "field": "isMatchingResourceType",
                    "operationType": "FACT",
                    "factName": "VMInstance",
                    "dependsOn": [{
                      "field": "resourceType",
                      "operationType": "FACT",
                      "factName": "VMInstance"
                    }]
                  },
                  "operator": "==",
                  "rhsOperand": {
                    "operationType": "VALUE",
                    "value": "true"
                  }
                }]
              }],
              "actions": [{
                "atype": "NOTIFICATION",
                "kvlist": [{
                  "key": "notification_platform",
                  "value": "value1"
                }]
              }, {
                "atype": "EXECUTESCRIPT",
                "kvlist": [{
                  "key": "key1",
                  "value": "value1"
                }]
              }],
              "resourceType": "ALL"
            }]
          }
        }];
        this.notificationData = [];
        console.log('coming in cc policy configuration component');
        this.updateResourceTypes();
      }

      return _createClass(CcPoliciesComponent, [{
        key: "convertToLong",
        value: function convertToLong(time) {
          console.log("going to convert time to long");
          return this.sessionService.convertFormattedStringIntoTimestamp(time, 'EEE MMM dd yyyy HH:mm:ss "GMT"Z') / 1000;
        }
      }, {
        key: "updateResourceTypes",
        value: function updateResourceTypes() {
          var _a, _b;

          if (this.ccmPolicy.policyCategory) {
            this.filteredResourceTypeList = this.allResourceTypeList[this.ccmPolicy.policyCategory];
            this.ccmPolicy.policyType = ((_a = this.filteredResourceTypeList[0]) === null || _a === void 0 ? void 0 : _a.value) || ''; // Reset all policies to null

            this.ccmPolicy.anomalyPolicy = {};
            this.ccmPolicy.quotaBudgetPolicy = {};
            this.ccmPolicy.resourceLifeCyclePolicy = {};
            this.ccmPolicy.taggingPolicy = {};
            this.ccmPolicy.filters.pool = [];

            if (((_b = this.pools) === null || _b === void 0 ? void 0 : _b.length) > 0) {
              this.ccmPolicy.resourceLifeCyclePolicy.poolName = this.pools[0].value; // this.ccmPolicy.filters.pool = this.pools[0].value;
            }
          }
        }
      }, {
        key: "updateAdditionalFields",
        value: function updateAdditionalFields() {
          this.ccmPolicy.resourceLifeCyclePolicy.ttl = null;
          this.ccmPolicy.resourceLifeCyclePolicy.expenseLimit = null;
        }
      }, {
        key: "filteredResourceType",
        value: function filteredResourceType(e) {
          console.log(e); // this.selectedPolicy.resourceType = 
        }
      }, {
        key: "applyFilters",
        value: function applyFilters() {
          this.saveContent = true; // Implement logic to filter policies based on selections
        }
      }, {
        key: "savePolicy",
        value: function savePolicy() {
          var _this = this;

          var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;

          var obj = {
            "taskType": "CloudCostTask",
            "taskReq": {
              "ruleName": this.ccmPolicy.policyName,
              "enable": false,
              "action": "Create",
              "collectionName": "cloud_cost_policy",
              "policyType": this.ccmPolicy.policyCategory // "Description" : this.createPolicyDescription(this.policyDescription[this.ccmPolicy.policyType], this.ccmPolicy)

            }
          };
          var cavScheduleObj = {
            task: [obj],
            inputType: "ADD",
            enableFor: true
          };
          console.log("this is scheduler obj", cavScheduleObj);
          this.inputForCavScheduler = cavScheduleObj;
          this.notificationData = this.notificationComponent.sendDataToParent();
          console.log("notificationData:::", this.notificationData);
          var payload = {
            "policyName": this.ccmPolicy.policyName
          };
          var filteredJsrPolicy;
          var unAssignedFilter = [];
          this.ccmPolicy.description = this.createPolicyDescription(this.policyDescription[this.ccmPolicy.policyType], this.ccmPolicy);
          this.policiesRuleTemplate.forEach(function (policy) {
            var _a, _b;

            (_b = (_a = policy === null || policy === void 0 ? void 0 : policy.rule_set) === null || _a === void 0 ? void 0 : _a.rules) === null || _b === void 0 ? void 0 : _b.forEach(function (element) {
              if (element.ruleOption === _this.ccmPolicy.policyCategory && element.template_type === _this.ccmPolicy.policyType) {
                filteredJsrPolicy = policy === null || policy === void 0 ? void 0 : policy.rule_set;
              }
            });
          });
          console.log("filteredPolicy:::", filteredJsrPolicy);
          filteredJsrPolicy.rsName = this.ccmPolicy.policyName;
          filteredJsrPolicy.rules[0].ruleName = this.ccmPolicy.policyName;
          filteredJsrPolicy.rules[0].description.policy_description = this.ccmPolicy.description; // let transformedPolicyJsr = this.transformJsrPolicyWithSavedValues(filterPolicyByCategory);

          if (this.ccmPolicy.taggingPolicy.startDate) {
            // Ensure the model has a numeric timestamp for the template to grab
            this.ccmPolicy.taggingPolicy['startTimestamp'] = this.convertToLong(this.ccmPolicy.taggingPolicy.startDate);
          } // Check for Anomaly Detection (Both Resource Count and Expenses)


          if (this.ccmPolicy.policyCategory === 'Anomaly Detection') {
            // 1. Calculate the Threshold Factor (e.g., 30% -> 1.3)
            // Using Number() to prevent TS(2362) arithmetic type errors
            var thresholdPercent = Number(this.ccmPolicy.anomalyPolicy['threshold']) || 0;
            var factor = 1 + thresholdPercent / 100;
            this.ccmPolicy.anomalyPolicy['thresholdFactor'] = factor; // 2. Handle Dynamic Evaluation Period for Aggregation

            var evalPeriod = Number(this.ccmPolicy.anomalyPolicy['evaluationPeriod']) || 7;
            var aggReq = (_a = filteredJsrPolicy.rules[0].factAggregationRequests) === null || _a === void 0 ? void 0 : _a[0];

            if (aggReq && aggReq.aggregates[1]) {
              // Sets interval to "last_7_days", "last_30_days", etc.
              aggReq.aggregates[1].interval = "last_".concat(evalPeriod, "_days");
            } // 3. Set the RuleName inside Metadata explicitly


            if (aggReq) {
              aggReq.metaData.ruleName = this.ccmPolicy.policyName;
            } // 4. Populate dynamic filters and groupby (Region, DataSource, etc.)


            this.handleDynamicAggregationFilters(filteredJsrPolicy);
          } // Inside savePolicy()


          if (this.ccmPolicy.policyType === 'Resource quota' || this.ccmPolicy.policyType === 'Recurring Budget') {
            // 1. Define the Mapping
            var intervalMapping = {
              'Monthly': 'last_30days',
              'Quarterly': 'last_90days',
              'Yearly': 'last_365days'
            }; // 2. Get the value from the UI model (ccmPolicy.quotaBudgetPolicy.timePeriod)
            // Fallback to 'last_30days' if nothing is selected

            var selectedTimePeriod = this.ccmPolicy.quotaBudgetPolicy['timePeriod'] || 'Daily';
            var intervalValue = intervalMapping[selectedTimePeriod] || 'now'; // 3. Inject it into the Aggregation Request

            var _aggReq = filteredJsrPolicy.rules[0].factAggregationRequests[0];

            if (_aggReq && _aggReq.aggregates[0]) {
              _aggReq.aggregates[0].interval = intervalValue;
            } // Also handle filters/groupby for Budget as we did for Quotas


            this.handleDynamicAggregationFilters(filteredJsrPolicy);
          } // Inside savePolicy()


          if (this.ccmPolicy.policyType === 'Expiring Budget') {
            // 1. Get the start date from the UI (format it as ISO if your backend expects it)
            var rawDate = this.ccmPolicy.quotaBudgetPolicy['startDate']; // Example format: 2025-01-01T10:49:13

            var formattedDate = new Date(rawDate).toISOString().split('.')[0]; // 2. Inject the date into the Aggregation Request interval

            var _aggReq2 = filteredJsrPolicy.rules[0].factAggregationRequests[0];

            if (_aggReq2 && _aggReq2.aggregates[0]) {
              _aggReq2.aggregates[0].interval = formattedDate;
            } // 3. Populate dynamic groupby and filter array (the AzureTest/Region logic)


            this.handleDynamicAggregationFilters(filteredJsrPolicy);
          }

          (_e = (_d = (_c = (_b = filteredJsrPolicy === null || filteredJsrPolicy === void 0 ? void 0 : filteredJsrPolicy.rules) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.ruleConditions[0]) === null || _d === void 0 ? void 0 : _d.ruleConditionsList) === null || _e === void 0 ? void 0 : _e.forEach(function (ruleList, index) {
            var isDaysFieldPresent = "false";

            for (var key in ruleList) {
              if (key === "expression" && ruleList[key].includes('$')) {
                var expressionVal = ruleList[key];
                var fieldList = expressionVal.match(/\$(.*?)\$/g);
                var field = fieldList[0];
                var prefixField = expressionVal.substring(0, expressionVal.indexOf(field));
                var postfixField = expressionVal.substring(expressionVal.indexOf(field) + field.length, expressionVal.length); // ruleList[key] = prefixField + this.transformJsrPolicyWithSavedValues(field,isDaysFieldPresent,unAssignedFilter,null) + postfixField

                var val = _this.transformJsrPolicyWithSavedValues(field, isDaysFieldPresent, unAssignedFilter, index);

                if (val !== undefined) {
                  // 2. Format array into MVEL list syntax (e.g. ['eastus', 'westus'])
                  // If it's a normal string, it leaves it alone.
                  var valStr = Array.isArray(val) ? "[" + val.map(function (v) {
                    return "'".concat(v, "'");
                  }).join(', ') + "]" : val;
                  ruleList[key] = prefixField + valStr + postfixField;
                }
              }

              if (typeof ruleList[key] === 'string' && ruleList[key].startsWith('$')) {
                // ruleList[key] = this.transformJsrPolicyWithSavedValues(ruleList[key],isDaysFieldPresent,unAssignedFilter,index)
                var fieldKey = ruleList[key];

                var _val = _this.transformJsrPolicyWithSavedValues(fieldKey, isDaysFieldPresent, unAssignedFilter, index); // NEW LOGIC: Check if the value is an array from the Multi-Select


                if (Array.isArray(_val)) {
                  ruleList['operator'] = "in"; // Backend will now use Filters.in()
                }

                ruleList[key] = _val; // Assign the value (string or string[])
              } else if (typeof ruleList[key] === 'object' && ruleList[key] !== null) {
                for (var nestedKey in ruleList[key]) {
                  if (ruleList[key][nestedKey] === 'LastSeen') {
                    isDaysFieldPresent = "true";
                  }

                  if (typeof ruleList[key][nestedKey] === 'string' && ruleList[key][nestedKey].startsWith('$')) {
                    ruleList[key][nestedKey] = _this.transformJsrPolicyWithSavedValues(ruleList[key][nestedKey], isDaysFieldPresent, unAssignedFilter, index);
                  }
                }
              }
            }
          });
          var filteredRulecondtion = [];
          (_j = (_h = (_g = (_f = filteredJsrPolicy === null || filteredJsrPolicy === void 0 ? void 0 : filteredJsrPolicy.rules) === null || _f === void 0 ? void 0 : _f[0]) === null || _g === void 0 ? void 0 : _g.ruleConditions[0]) === null || _h === void 0 ? void 0 : _h.ruleConditionsList) === null || _j === void 0 ? void 0 : _j.forEach(function (ruleCondition, index) {
            if (unAssignedFilter.indexOf(index) == -1) {
              filteredRulecondtion.push(ruleCondition);
            }
          });
          filteredJsrPolicy.rules[0].ruleConditions[0].ruleConditionsList = filteredRulecondtion;
          (_m = (_l = (_k = filteredJsrPolicy === null || filteredJsrPolicy === void 0 ? void 0 : filteredJsrPolicy.rules) === null || _k === void 0 ? void 0 : _k[0]) === null || _l === void 0 ? void 0 : _l.actions) === null || _m === void 0 ? void 0 : _m.forEach(function (element) {
            if (element.atype == "NOTIFICATION") element.kvlist[0].value = JSON.stringify(_this.notificationData);
          });
          console.log("UpdatedJsrPolicy::", filteredJsrPolicy);
          this.ccmPoliciesService.savePolicyJsrRule(filteredJsrPolicy).subscribe(function (state) {
            if (state instanceof _service_cc_policies_state__WEBPACK_IMPORTED_MODULE_3__["CCPoliciesLoadingState"]) {
              return;
            }

            if (state instanceof _service_cc_policies_state__WEBPACK_IMPORTED_MODULE_3__["CCPoliciessLoadedState"]) {
              console.log("savePolicyJsrRule:::::", state.data);
            }
          });
          this.ccmPoliciesService.getCCMPolicies(payload).subscribe(function (state) {
            if (state instanceof _service_cc_policies_state__WEBPACK_IMPORTED_MODULE_3__["CCPoliciessLoadedState"]) {
              console.log("Policy Exists :: ", state.data);

              if (state.data.length > 0) {
                _this.messageService.add({
                  severity: 'error',
                  summary: "error",
                  detail: "Policy with \"".concat(_this.ccmPolicy.policyName, "\" name is already exists!!"),
                  sticky: false,
                  life: 2000
                });

                return;
              } else {
                _this.storePolicy(_this.ccmPolicy);
              }
            }
          });
        }
      }, {
        key: "handleDynamicAggregationFilters",
        value: function handleDynamicAggregationFilters(filteredJsrPolicy) {
          var _this2 = this;

          var filterMapping = [{
            key: '$dataSource',
            attr: 'DataSourceName'
          }, {
            key: '$region',
            attr: 'Region'
          }, {
            key: '$pool',
            attr: 'PoolName'
          }, {
            key: '$service',
            attr: 'Service'
          }, {
            key: '$owner',
            attr: 'Owner'
          }, {
            key: '$resourceType',
            attr: 'ResourceType'
          }];
          var dynamicGroupBy = [];
          var dynamicFilters = [];
          filterMapping.forEach(function (item) {
            var val = _this2.transformJsrPolicyWithSavedValues(item.key, 'false', [], null);

            if (val !== undefined && val !== null && val !== '') {
              dynamicGroupBy.push(item.attr); // If val is an array, use "in", otherwise use "=="

              var condition = Array.isArray(val) ? "in" : "==";
              dynamicFilters.push({
                attribute: item.attr,
                condition: condition,
                value: val
              });
            }
          });
          var aggReq = filteredJsrPolicy.rules[0].factAggregationRequests[0];

          if (aggReq) {
            aggReq.groupby = dynamicGroupBy;
            aggReq.filter = dynamicFilters;
          }
        }
      }, {
        key: "updatePolicy",
        value: function updatePolicy() {
          var _this3 = this;

          var _a; // 1. Validation


          if (!this.ccmPolicy.policyName || this.ccmPolicy.policyName.trim() === '') {
            this.messageService.add({
              severity: 'error',
              summary: 'Error',
              detail: 'Policy Name is required.'
            });
            return;
          } // DATA STORE 1: UPDATE SCHEDULER (CavScheduler)


          var schedulerObj = {
            "taskType": "CloudCostTask",
            "taskReq": {
              "ruleName": this.ccmPolicy.policyName,
              "enable": true,
              "action": "Update",
              "collectionName": "cloud_cost_policy",
              "policyType": this.ccmPolicy.policyCategory
            },
            "id": this.currentTaskId
          }; // Attach ID so backend knows which task to update

          if (!this.currentTaskId) {
            console.error("CRITICAL ERROR: Cannot update. Task ID is missing!");
          } // Trigger the Child Component to save the schedule


          var cavScheduleObj = {
            task: [schedulerObj],
            inputType: "UPDATE",
            enableFor: true
          };
          this.inputForCavScheduler = cavScheduleObj; // DATA STORE 2: UPDATE JSR RULE (Logic)

          var filteredJsrPolicy;
          var unAssignedFilter = []; // Regenerate Description & Find Template

          this.ccmPolicy.description = this.createPolicyDescription(this.policyDescription[this.ccmPolicy.policyType], this.ccmPolicy);
          this.policiesRuleTemplate.forEach(function (policy) {
            var _a, _b;

            (_b = (_a = policy === null || policy === void 0 ? void 0 : policy.rule_set) === null || _a === void 0 ? void 0 : _a.rules) === null || _b === void 0 ? void 0 : _b.forEach(function (element) {
              if (element.ruleOption === _this3.ccmPolicy.policyCategory && element.template_type === _this3.ccmPolicy.policyType) {
                filteredJsrPolicy = JSON.parse(JSON.stringify(policy.rule_set)); // Deep copy
              }
            });
          });

          if (filteredJsrPolicy) {
            // Update Template Values
            filteredJsrPolicy.rsName = this.ccmPolicy.policyName;
            filteredJsrPolicy.rules[0].ruleName = this.ccmPolicy.policyName;
            filteredJsrPolicy.rules[0].description.policy_description = this.ccmPolicy.description; // FULL JSR TRANSFORMATION LOGIC (Restored from your savePolicy)

            filteredJsrPolicy.rules[0].ruleConditions[0].ruleConditionsList.forEach(function (ruleList, index) {
              var isDaysFieldPresent = "false";

              for (var key in ruleList) {
                // Case 1: Regex replacement for expressions (e.g. "$field$")
                if (key === "expression" && ruleList[key].includes('$')) {
                  var expressionVal = ruleList[key];
                  var fieldList = expressionVal.match(/\$(.*?)\$/g);

                  if (fieldList) {
                    var field = fieldList[0];
                    var prefixField = expressionVal.substring(0, expressionVal.indexOf(field));
                    var postfixField = expressionVal.substring(expressionVal.indexOf(field) + field.length, expressionVal.length);
                    ruleList[key] = prefixField + _this3.transformJsrPolicyWithSavedValues(field, isDaysFieldPresent, unAssignedFilter, null) + postfixField;
                  }
                } // Case 2: Direct string replacement


                if (typeof ruleList[key] === 'string' && ruleList[key].startsWith('$')) {
                  ruleList[key] = _this3.transformJsrPolicyWithSavedValues(ruleList[key], isDaysFieldPresent, unAssignedFilter, index);
                } // Case 3: Nested Object replacement
                else if (typeof ruleList[key] === 'object' && ruleList[key] !== null) {
                  for (var nestedKey in ruleList[key]) {
                    if (ruleList[key][nestedKey] === 'LastSeen') {
                      isDaysFieldPresent = "true";
                    }

                    if (typeof ruleList[key][nestedKey] === 'string' && ruleList[key][nestedKey].startsWith('$')) {
                      ruleList[key][nestedKey] = _this3.transformJsrPolicyWithSavedValues(ruleList[key][nestedKey], isDaysFieldPresent, unAssignedFilter, index);
                    }
                  }
                }
              }
            }); // Filter Unassigned Conditions

            var filteredRulecondtion = [];
            filteredJsrPolicy.rules[0].ruleConditions[0].ruleConditionsList.forEach(function (ruleCondition, index) {
              if (unAssignedFilter.indexOf(index) == -1) {
                filteredRulecondtion.push(ruleCondition);
              }
            });
            filteredJsrPolicy.rules[0].ruleConditions[0].ruleConditionsList = filteredRulecondtion; // Update Notification Action

            this.notificationData = this.notificationComponent.sendDataToParent();
            (_a = filteredJsrPolicy.rules[0].actions) === null || _a === void 0 ? void 0 : _a.forEach(function (element) {
              if (element.atype == "NOTIFICATION") element.kvlist[0].value = JSON.stringify(_this3.notificationData);
            });
            console.log("Updating JSR Policy:", filteredJsrPolicy); // Call Service to Update JSR 

            this.ccmPoliciesService.updatePolicyJsrRule(filteredJsrPolicy).subscribe(function (state) {
              if (state instanceof _service_cc_policies_state__WEBPACK_IMPORTED_MODULE_3__["CCPoliciessLoadedState"]) {
                console.log("JSR Rule Updated successfully");
              }
            });
          } // ============================================================
          // DATA STORE 3: UPDATE METADATA (CCM Policy)
          // ============================================================
          // Call the NEW update method for metadata (Filters, Description, etc.)


          this.ccmPoliciesService.updateCCMPolicies(this.ccmPolicy).subscribe(function (state) {
            if (state instanceof _service_cc_policies_state__WEBPACK_IMPORTED_MODULE_3__["CCPoliciessLoadedState"]) {
              _this3.messageService.add({
                severity: 'success',
                summary: "Success",
                detail: "Policy \"".concat(_this3.ccmPolicy.policyName, "\" updated successfully"),
                life: 2000
              });

              _this3.router.navigate(['/home/cloud-cost/policies']);
            }
          });
        }
      }, {
        key: "transformJsrPolicyWithSavedValues",
        value: function transformJsrPolicyWithSavedValues(value, isDaysFieldPresent, unAssignedFilter, filterIndex) {
          value = value.endsWith('$') ? value.substring(1, value.length - 1) : value.substring(1);

          var getValue = function getValue(obj, key) {
            if (key in obj) {
              return obj[key];
            }

            for (var k in obj) {
              if (typeof obj[k] === 'object' && obj[k] !== null && key in obj[k]) {
                return obj[k][key];
              }
            }

            return null; // Return null if value is not found
          };

          var result = getValue(this.ccmPolicy, value);

          if (result !== null) {
            // return isDaysFieldPresent === 'true' ? result * 24 * 60 * 60 : result;
            // Check for empty arrays from Multi-Select
            if (Array.isArray(result) && result.length === 0) {
              if (filterIndex != null) unAssignedFilter.push(filterIndex);
              return undefined;
            } // Perform math only on single numeric values (evaluationPeriod, etc.)


            if (isDaysFieldPresent === 'true' && !Array.isArray(result)) {
              return Number(result) * 24 * 60 * 60;
            }

            return result; // Returns string or string[]
          }

          if (filterIndex != null) unAssignedFilter.push(filterIndex);
          return undefined; // Return undefined if value is not found
        } // transformJsrPolicyWithSavedValues(value,isDaysFieldPresent,unAssignedFilter,filterIndex){
        //   value = value.substring(1);
        //   if(Object.keys(this.ccmPolicy).includes(value)){
        //     return isDaysFieldPresent == 'true' ? this.ccmPolicy[value] * 24 * 60 * 60 : this.ccmPolicy[value];
        //   }
        //   else{
        //     for(let key in this.ccmPolicy){
        //       if(typeof this.ccmPolicy[key] === 'object' && this.ccmPolicy[key] !== null){
        //         for(let nestedKey in this.ccmPolicy[key]){
        //           if(Object.keys(this.ccmPolicy[key]).includes(value)){
        //             return isDaysFieldPresent == 'true' ? (this.ccmPolicy[key][value] * 24 * 60 * 60) : (this.ccmPolicy[key][value]);
        //           }
        //         }
        //       }
        //     }
        //   }
        // }

      }, {
        key: "storePolicy",
        value: function storePolicy(ccmPolicy) {
          var _this4 = this;

          this.ccmPoliciesService.storeCCMPolicies(ccmPolicy).subscribe(function (state) {
            if (state instanceof _service_cc_policies_state__WEBPACK_IMPORTED_MODULE_3__["CCPoliciessLoadedState"]) {
              _this4.saveContent = false;

              _this4.messageService.add({
                severity: 'success',
                summary: "Success",
                detail: "Policy \"".concat(ccmPolicy.policyName, "\" saved successfully"),
                sticky: false,
                life: 2000
              });

              _this4.router.navigate(['/home/cloud-cost/policies']);
            }
          });
        }
      }, {
        key: "createPolicyDescription",
        value: function createPolicyDescription(template, ccmPolicy) {
          return new Function("ccmPolicy", "return `".concat(template, "`;"))(ccmPolicy); // Fallback if key doesn't exist
        }
      }, {
        key: "cancelSave",
        value: function cancelSave() {
          this.saveContent = false;
        }
      }, {
        key: "updateBaselineDays",
        value: function updateBaselineDays() {
          switch (this.ccmPolicy.anomalyPolicy.timePeriod) {
            case 'Month':
              this.selectedPolicy.baselineDays = 30;
              break;

            case 'Quarter':
              this.selectedPolicy.baselineDays = 90;
              break;

            case 'Year':
              this.selectedPolicy.baselineDays = 365;
              break;

            default:
              this.selectedPolicy.baselineDays = 30;
            // Default fallback
          }
        }
      }, {
        key: "getCloudDataSources",
        value: function getCloudDataSources() {
          var _this5 = this;

          var me = this;
          me.cloudDataSourceService.readCloudConfiguration().subscribe(function (state) {
            if (state instanceof _cloud_data_source_service_cloud_data_source_state__WEBPACK_IMPORTED_MODULE_9__["ReadCloudConfigurationLoadingState"]) {
              return;
            }

            if (state instanceof _cloud_data_source_service_cloud_data_source_state__WEBPACK_IMPORTED_MODULE_9__["ReadCloudConfigurationLoadedState"]) {
              _this5.setDataSourceValue(state);

              return;
            }
          }, function (state) {});
        }
      }, {
        key: "setDataSourceValue",
        value: function setDataSourceValue(state) {
          var _this6 = this;

          var data = state.data;
          data.forEach(function (ds) {
            var _a;

            var dsName = (_a = ds === null || ds === void 0 ? void 0 : ds.dataSource) === null || _a === void 0 ? void 0 : _a.name;

            _this6.dataSources.push({
              label: dsName,
              value: dsName
            });
          });
        }
      }, {
        key: "getRegionLists",
        value: function getRegionLists() {
          var _this7 = this;

          this.ccmPoliciesService.getCloudRegionList().subscribe(function (state) {
            if (state instanceof _service_cc_policies_state__WEBPACK_IMPORTED_MODULE_3__["CCPoliciessLoadedState"]) {
              _this7.setRegionList(state);

              return;
            }
          }, function (state) {});
        }
      }, {
        key: "setRegionList",
        value: function setRegionList(state) {
          var _this8 = this;

          var regionData = state.data;
          regionData.forEach(function (region) {
            _this8.regions.push({
              label: region.regionCode,
              value: region.regionCode
            });
          });
        }
      }, {
        key: "getPoolList",
        value: function getPoolList() {
          var _this9 = this;

          this.ccPoolsService.readPoolsConfiguration().subscribe(function (state) {
            var _a;

            if (state instanceof _cc_pools_service_cc_pools_state__WEBPACK_IMPORTED_MODULE_10__["CCPoolssLoadedState"]) {
              console.log("state read:::::", state);
              (_a = state === null || state === void 0 ? void 0 : state.data) === null || _a === void 0 ? void 0 : _a.forEach(function (item) {
                _this9.pools.push({
                  label: item.Poolname,
                  value: item.Poolname
                });
              });
            }
          });
        }
      }, {
        key: "getCloudFiltersLists",
        value: function getCloudFiltersLists() {
          var _this0 = this;

          var path = src_environments_environment__WEBPACK_IMPORTED_MODULE_12__["environment"].api.dashboard.dbQuery.endpoint;
          var et = new Date().getTime();
          var st = et - 24 * 60 * 60 * 1000;
          var payload = {
            dbSourceCtx: {
              connectionUrl: "127.0.0.1:5432/alert_work?username=cavisson&password=''",
              databaseQuery: "SELECT DISTINCT data_source_name, service_name, region, type FROM expenses;",
              databaseType: "postgres",
              isDefaultDatabase: false,
              selectedDatabase: "alert_work"
            }
          };
          this.ccmPoliciesService.getFilters(path, payload).subscribe(function (state) {
            if (state instanceof _service_cc_policies_state__WEBPACK_IMPORTED_MODULE_3__["CCPoliciessLoadedState"]) {
              _this0.processFilters(state);

              return;
            }
          });
        }
      }, {
        key: "processFilters",
        value: function processFilters(state) {
          var _a, _b;

          var me = this;

          if ((_b = (_a = state === null || state === void 0 ? void 0 : state.data) === null || _a === void 0 ? void 0 : _a.dbData) === null || _b === void 0 ? void 0 : _b.dbData) {
            var uniqueValues = {};
            state.data.dbData.dbData.forEach(function (row) {
              Object.entries(row).forEach(function (_ref) {
                var _ref2 = _slicedToArray(_ref, 2),
                    key = _ref2[0],
                    value = _ref2[1];

                if (!uniqueValues[key]) {
                  uniqueValues[key] = new Set();
                }

                uniqueValues[key].add(value);
              });
            });
            Object.keys(uniqueValues).forEach(function (key) {
              if (key == "service_name") me.services = me.getOptionsList(uniqueValues, key, false);else if (key == "type") me.resourceTypes = me.getOptionsList(uniqueValues, key, true);
            });
          } else {
            console.log('Data not Available.');
          }
        }
      }, {
        key: "getOptionsList",
        value: function getOptionsList(uniqueValues, key) {
          var isUpperCase = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
          var me = this;
          return Array.from(uniqueValues[key]).map(function (item) {
            return me.getSelectedItem(item, isUpperCase);
          });
        }
      }, {
        key: "getSelectedItem",
        value: function getSelectedItem(item, isUpperCase) {
          return {
            label: item,
            value: item
          };
        }
      }, {
        key: "getOwnerListFromResources",
        value: function getOwnerListFromResources() {
          var _this1 = this;

          this.ccmPoliciesService.getResourceOwnerLists().subscribe(function (state) {
            if (state instanceof _service_cc_policies_state__WEBPACK_IMPORTED_MODULE_3__["CCPoliciessLoadedState"]) {
              Array.from(state.data).map(function (item) {
                return _this1.owners.push(_this1.getSelectedItem(item['CreatedBy'], false));
              });
              return;
            }
          }, function (state) {});
        }
      }, {
        key: "ngOnInit",
        value: function ngOnInit() {
          var _this10 = this;

          this.inputForCavScheduler = {
            enableFor: true,
            enableNow: false
          };
          this.updateResourceTypes();
          this.getOwnerListFromResources();
          this.getRegionLists();
          this.getCloudFiltersLists();
          var pools$ = this.ccPoolsService.readPoolsConfiguration().pipe(Object(rxjs_operators__WEBPACK_IMPORTED_MODULE_14__["catchError"])(function () {
            return Object(rxjs__WEBPACK_IMPORTED_MODULE_13__["of"])(null);
          }));
          var dataSources$ = this.cloudDataSourceService.readCloudConfiguration().pipe(Object(rxjs_operators__WEBPACK_IMPORTED_MODULE_14__["catchError"])(function () {
            return Object(rxjs__WEBPACK_IMPORTED_MODULE_13__["of"])(null);
          })); // 2. Wait for ALL to finish

          Object(rxjs__WEBPACK_IMPORTED_MODULE_13__["forkJoin"])([pools$, dataSources$]).subscribe(function (results) {
            var _a;

            var _results = _slicedToArray(results, 2),
                poolState = _results[0],
                dsState = _results[1]; // 1. Manually populate Pools (Logic copied from getPoolList)


            if (poolState instanceof _cc_pools_service_cc_pools_state__WEBPACK_IMPORTED_MODULE_10__["CCPoolssLoadedState"]) {
              (_a = poolState === null || poolState === void 0 ? void 0 : poolState.data) === null || _a === void 0 ? void 0 : _a.forEach(function (item) {
                _this10.pools.push({
                  label: item.Poolname,
                  value: item.Poolname
                });
              });
            } // 2. Manually populate DataSources (Logic copied from getCloudDataSources)


            if (dsState instanceof _cloud_data_source_service_cloud_data_source_state__WEBPACK_IMPORTED_MODULE_9__["ReadCloudConfigurationLoadedState"]) {
              dsState.data.forEach(function (ds) {
                var _a;

                var dsName = (_a = ds === null || ds === void 0 ? void 0 : ds.dataSource) === null || _a === void 0 ? void 0 : _a.name;

                _this10.dataSources.push({
                  label: dsName,
                  value: dsName
                });
              });
            } // 3. NOW it is safe to run the Edit Logic


            _this10.handleNavigationState();
          });
        }
      }, {
        key: "handleNavigationState",
        value: function handleNavigationState() {
          var _this11 = this;

          var _a, _b, _c; // --- 1. Power Scheduler Mode ---


          if (((_a = history.state) === null || _a === void 0 ? void 0 : _a.from) === "PowerScheduler") {
            this.ccmPolicy.policyCategory = "Power Scheduler";
            this.isPolicyCategoryLocked = true;
            this.policyTypeList = [{
              label: 'Power Scheduler',
              value: 'Power Scheduler'
            }];
            this.updateResourceTypes();
          } // --- 2. Edit Mode ---


          if ((_b = history.state) === null || _b === void 0 ? void 0 : _b.editData) {
            var editEvent = history.state.editData;
            this.isEditMode = true;

            if (editEvent.task && editEvent.task.length > 0) {
              // A. Restore Policy Name
              this.ccmPolicy.policyName = ((_c = editEvent.task[0].taskReq) === null || _c === void 0 ? void 0 : _c.ruleName) || ""; // B. Lock UI for Power Scheduler if needed

              this.ccmPolicy.policyCategory = "Power Scheduler";
              this.isPolicyCategoryLocked = true;
              this.policyTypeList = [{
                label: 'Power Scheduler',
                value: 'Power Scheduler'
              }]; // C. Capture Task ID (For Update)

              this.currentTaskId = editEvent.task[0].id || editEvent.task[0]._id; // D. Restore Metadata (Filters, etc.)

              if (this.ccmPolicy.policyName) {
                var payload = {
                  "policyName": this.ccmPolicy.policyName
                }; // Since we are inside forkJoin, we know pools/sources are ready!

                this.ccmPoliciesService.getCCMPolicies(payload).subscribe(function (state) {
                  if (state instanceof _service_cc_policies_state__WEBPACK_IMPORTED_MODULE_3__["CCPoliciessLoadedState"] && state.data && state.data.length > 0) {
                    var fullPolicyData = state.data[0];

                    if (fullPolicyData.filters) {
                      // This assignment will now correctly show values in dropdowns
                      _this11.ccmPolicy.filters = Object.assign({}, fullPolicyData.filters);
                    }
                  }
                });
              } // E. Restore Scheduler (With ID fix)


              var rawSchedule = editEvent.schedule || [];
              var cleanSchedule = rawSchedule.map(function (item) {
                return {
                  scheduleType: item.scheduleType,
                  schedule: item.schedule,
                  zone: item.zone,
                  id: item.id || item._id,
                  _id: item._id || item.id
                };
              });
              this.inputForCavScheduler = {
                schedule: cleanSchedule,
                enableFor: true,
                preview: true
              };
            }
          }
        }
      }, {
        key: "cavScheduleEventHandler",
        value: function cavScheduleEventHandler(event) {}
      }, {
        key: "handleScheduleNow",
        value: function handleScheduleNow(event) {}
      }]);
    }();

    CcPoliciesComponent.ctorParameters = function () {
      return [{
        type: _service_cc_policies_service__WEBPACK_IMPORTED_MODULE_2__["CcPoliciesService"]
      }, {
        type: src_app_shared_cav_toast_service_cav_message_service__WEBPACK_IMPORTED_MODULE_4__["CavMessageService"]
      }, {
        type: _angular_router__WEBPACK_IMPORTED_MODULE_5__["Router"]
      }, {
        type: src_app_core_session_session_service__WEBPACK_IMPORTED_MODULE_7__["SessionService"]
      }, {
        type: _cloud_data_source_service_cloud_data_source_service__WEBPACK_IMPORTED_MODULE_8__["CloudDataSourceService"]
      }, {
        type: _cc_pools_service_cc_pools_service__WEBPACK_IMPORTED_MODULE_11__["CcPoolsService"]
      }];
    };

    Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([Object(_angular_core__WEBPACK_IMPORTED_MODULE_1__["ViewChild"])(src_app_shared_cav_notification_settings_cav_notification_settings_component__WEBPACK_IMPORTED_MODULE_6__["CavNotificationSettingsComponent"])], CcPoliciesComponent.prototype, "notificationComponent", void 0);
    CcPoliciesComponent = Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([Object(_angular_core__WEBPACK_IMPORTED_MODULE_1__["Component"])({
      selector: 'app-cc-policies',
      template: Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__importDefault"])(__webpack_require__(
      /*! raw-loader!./cc-policies.component.html */
      "./node_modules/raw-loader/dist/cjs.js!./src/app/pages/home/cloud-cost/cc-policies/cc-policies-configuration/cc-policies.component.html"))["default"],
      styles: [Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__importDefault"])(__webpack_require__(
      /*! ./cc-policies.component.scss */
      "./src/app/pages/home/cloud-cost/cc-policies/cc-policies-configuration/cc-policies.component.scss"))["default"]]
    })], CcPoliciesComponent);
    /***/
  },

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

  /*! exports provided: CcPoliciesConfigurationModule */

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

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


    __webpack_require__.d(__webpack_exports__, "CcPoliciesConfigurationModule", function () {
      return CcPoliciesConfigurationModule;
    });
    /* 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 _cc_policies_component__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(
    /*! ./cc-policies.component */
    "./src/app/pages/home/cloud-cost/cc-policies/cc-policies-configuration/cc-policies.component.ts");
    /* harmony import */


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


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


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


    var src_app_shared_cav_table_cav_table_module__WEBPACK_IMPORTED_MODULE_7__ = __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_8__ = __webpack_require__(
    /*! primeng/dropdown */
    "./node_modules/primeng/__ivy_ngcc__/fesm2015/primeng-dropdown.js");
    /* harmony import */


    var primeng_multiselect__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(
    /*! primeng/multiselect */
    "./node_modules/primeng/__ivy_ngcc__/fesm2015/primeng-multiselect.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 primeng_button__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(
    /*! primeng/button */
    "./node_modules/primeng/__ivy_ngcc__/fesm2015/primeng-button.js");
    /* harmony import */


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


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


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

    var route = [{
      path: '',
      component: _cc_policies_component__WEBPACK_IMPORTED_MODULE_3__["CcPoliciesComponent"]
    }];

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

    CcPoliciesConfigurationModule = Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([Object(_angular_core__WEBPACK_IMPORTED_MODULE_1__["NgModule"])({
      declarations: [_cc_policies_component__WEBPACK_IMPORTED_MODULE_3__["CcPoliciesComponent"]],
      imports: [_angular_common__WEBPACK_IMPORTED_MODULE_2__["CommonModule"], primeng__WEBPACK_IMPORTED_MODULE_6__["TabMenuModule"], _angular_forms__WEBPACK_IMPORTED_MODULE_4__["FormsModule"], primeng__WEBPACK_IMPORTED_MODULE_6__["TooltipModule"], _angular_common__WEBPACK_IMPORTED_MODULE_2__["CommonModule"], src_app_shared_cav_table_cav_table_module__WEBPACK_IMPORTED_MODULE_7__["CavTableModule"], primeng_dropdown__WEBPACK_IMPORTED_MODULE_8__["DropdownModule"], primeng_multiselect__WEBPACK_IMPORTED_MODULE_9__["MultiSelectModule"], primeng_dialog__WEBPACK_IMPORTED_MODULE_10__["DialogModule"], primeng_button__WEBPACK_IMPORTED_MODULE_11__["ButtonModule"], _angular_forms__WEBPACK_IMPORTED_MODULE_4__["FormsModule"], _angular_forms__WEBPACK_IMPORTED_MODULE_4__["ReactiveFormsModule"], primeng__WEBPACK_IMPORTED_MODULE_6__["PanelModule"], primeng__WEBPACK_IMPORTED_MODULE_6__["InputTextModule"], primeng__WEBPACK_IMPORTED_MODULE_6__["CalendarModule"], src_app_shared_cav_notification_settings_cav_notification_settings_module__WEBPACK_IMPORTED_MODULE_12__["CavNotificationSettingsModule"], src_app_shared_cav_scheduler_cav_scheduler_module__WEBPACK_IMPORTED_MODULE_13__["CavSchedulerModule"], src_app_shared_cav_scheduler_table_cav_scheduler_table_module__WEBPACK_IMPORTED_MODULE_14__["cavSchedulerTableModule"], _angular_router__WEBPACK_IMPORTED_MODULE_5__["RouterModule"].forChild(route)],
      providers: [],
      exports: [_angular_router__WEBPACK_IMPORTED_MODULE_5__["RouterModule"]]
    })], CcPoliciesConfigurationModule);
    /***/
  }
}]);