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

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

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

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

function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }

function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }

function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }

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 _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([["view-report-view-report-module"], {
  /***/
  "./node_modules/raw-loader/dist/cjs.js!./src/app/pages/home/functional/view-report/view-report.component.html":
  /*!********************************************************************************************************************!*\
    !*** ./node_modules/raw-loader/dist/cjs.js!./src/app/pages/home/functional/view-report/view-report.component.html ***!
    \********************************************************************************************************************/

  /*! exports provided: default */

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

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


    __webpack_exports__["default"] = "<div #pdfContent id=\"pdfContent\" class=\"overflow h-100vh-85\">\n\n    <div class=\"p-grid\">\n        <div class=\"p-col-12\">\n            <div\n                class=\"p-grid p-align-center p-justify-between border-all border-7 bg-secondary-100 d-bg-secondary-1200\">\n                <div class=\"inline-flex p-col-fixed\">\n                    <button type=\"button\" pButton icon=\"icons8 icons8-left font-18\" class=\"btn-icon\" matTooltip=\"Back\"\n                        (click)=\"goToBack()\"></button>\n                </div>\n                <div class=\"inline-flex font-18 font-weight-600 p-col-fixed\" style=\"margin-left: -120px\">\n                    Test Suite Report\n                </div>\n                <div class=\"inline-flex p-col-fixed\">\n                    <p-button type=\"button\" [icon]=\"isDownloading ? 'pi pi-spin pi-spinner' : 'icons8 icons8-installing-updates font-18'\"\n                        styleClass=\"btn-icon\" matTooltip=\"Download as PDF\" (click)=\"downloadReport()\"\n                        [disabled]=\"isDownloading\"></p-button>\n                </div>\n            </div>\n        </div>\n        <div class=\"p-col-12 thead-none\">\n            <cav-table [value]=\"summaryData\" [headers]=\"summaryHeader\" [scrollable]=\"scrollable\"\n                (clickButtonEvent)=\"onClickRecentTestEvent()\" [tableConfig]=\"summaryConfig\"></cav-table>\n        </div>\n\n        <div class=\"p-col-12\">\n            <cav-table [value]=\"reportDetailsData\" [headers]=\"detailsTableHeader\" [first]=\"first\" [rows]=\"rows\"\n                [paginator]=\"paginator\" [responsive]=\"true\" [rowsPerPageOptions]=\"[10,20,50,100,500]\" [showCurrentPageReport]=\"true\"\n                [scrollable]=\"scrollable\"\n                (clickButtonEvent)=\"onClickRecentTestEvent()\" [tableConfig]=\"detailsTableConfig\"></cav-table>\n        </div>\n    </div>\n</div>\n";
    /***/
  },

  /***/
  "./src/app/pages/home/functional/view-report/view-report.component.scss":
  /*!******************************************************************************!*\
    !*** ./src/app/pages/home/functional/view-report/view-report.component.scss ***!
    \******************************************************************************/

  /*! exports provided: default */

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

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


    __webpack_exports__["default"] = "app-view-report .thead-none cav-table .ui-table-thead {\n  display: none;\n}";
    /***/
  },

  /***/
  "./src/app/pages/home/functional/view-report/view-report.component.ts":
  /*!****************************************************************************!*\
    !*** ./src/app/pages/home/functional/view-report/view-report.component.ts ***!
    \****************************************************************************/

  /*! exports provided: ViewReportComponent */

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

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


    __webpack_require__.d(__webpack_exports__, "ViewReportComponent", function () {
      return ViewReportComponent;
    });
    /* 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_router__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(
    /*! @angular/router */
    "./node_modules/@angular/router/__ivy_ngcc__/fesm2015/router.js");
    /* harmony import */


    var _service_functional_service__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(
    /*! ../service/functional.service */
    "./src/app/pages/home/functional/service/functional.service.ts");
    /* harmony import */


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


    var jspdf__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(
    /*! jspdf */
    "./node_modules/jspdf/dist/jspdf.es.min.js");
    /* harmony import */


    var html2canvas__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(
    /*! html2canvas */
    "./node_modules/html2canvas/dist/html2canvas.js");
    /* harmony import */


    var html2canvas__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(html2canvas__WEBPACK_IMPORTED_MODULE_6__);
    /* harmony import */


    var _service_functional_enum__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(
    /*! ../service/functional-enum */
    "./src/app/pages/home/functional/service/functional-enum.ts");

    var ViewReportComponent = /*#__PURE__*/function () {
      function ViewReportComponent(router, _functionalService, _sessionService, cd) {
        _classCallCheck(this, ViewReportComponent);

        this.router = router;
        this._functionalService = _functionalService;
        this._sessionService = _sessionService;
        this.cd = cd;
        this.summaryData = [];
        this.summaryHeader = [];
        this.detailsTableHeader = [];
        this.isCompare = false;
        this.reportMap = new Map();
        this.isDownloading = false;
        this.first = {
          first: 0
        };
        this.rows = {
          rows: 10
        };
        this.activeComponent = 'title'; // Controls used to alter table behavior during PDF capture

        this.paginator = true;
        this.scrollable = true;
      }
      /**
       * Initialize component: configure tables and populate data.
       * Converts timestamps/durations and prepares table headers/data.
       */


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

          this.summaryConfig = {
            config: {
              "download": true,
              "tableName": "Summary"
            }
          };
          this.detailsTableConfig = {
            config: {
              "download": true,
              "paginator": true,
              "globalFilter": true,
              "toggleFilter": true,
              "tableName": "Detail(s)"
            }
          };

          if (!this._functionalService || !Array.isArray(this._functionalService.testRunData)) {
            console.error('FunctionalService.testRunData not available in ngOnInit');
            return;
          }

          if (this._functionalService.testRunData.length > 0) {
            this.isCompare = this._functionalService.testRunData.length > 1;

            try {
              var _iterator = _createForOfIteratorHelper(this._functionalService.testRunData),
                  _step;

              try {
                for (_iterator.s(); !(_step = _iterator.n()).done;) {
                  var item = _step.value;
                  var startTimeInMS = item.startTimeInMS,
                      durationInMS = item.durationInMS;

                  try {
                    item.startTimeInMS = this._sessionService.convertTimeToSelectedTimeZone(startTimeInMS);
                  } catch (e) {
                    console.error('Failed to convert time for item', item, e);
                    item.startTimeInMS = String(startTimeInMS !== null && startTimeInMS !== void 0 ? startTimeInMS : '-');
                  } //In case of running test case duration will be '-'.


                  item.durationInMS = durationInMS === '-' ? '-' : this._sessionService.convertMSIntoDuration(durationInMS);
                }
              } catch (err) {
                _iterator.e(err);
              } finally {
                _iterator.f();
              }
            } catch (e) {
              console.error('Error normalizing testRunData in ngOnInit', e);
            } //Below method is use for making dynamic header and data for summary cav-table.


            this.convertDataAccCavTable().then(function (data) {
              _this.summaryData = data;
              _this.summaryHeader = _this.getFormatedHeaderForCavTable(_this.summaryData);
            })["catch"](function (e) {
              return console.error('convertDataAccCavTable failed', e);
            }); // This method is used to get laod per-test-run details and populate `reportMap` and table headers/data.

            this.getReportDetails();
          }
        }
      }, {
        key: "convertDataAccCavTable",
        value: function convertDataAccCavTable() {
          var _this2 = this;

          /**
           * Convert `this._functionalService.testRunData` into a keyed array consumable by the cav-table.
           * Numeric columns are formatted with comma separators.
           */
          return new Promise(function (resolve) {
            var headerValue = ["Test Name", "Test Run", "Start Time", "Duration", "Total Test Cases", "Pass", "Fail", "Error", "Aborted"];
            var keyMap = {
              "Test Name": "scenarioName",
              "Test Run": "testRun",
              "Start Time": "startTimeInMS",
              "Duration": "durationInMS",
              "Total Test Cases": "totalCase",
              "Pass": "pass",
              "Fail": "fail",
              "Error": "error",
              "Aborted": "aborted"
            };
            var numericHeaders = new Set(["Total Test Cases", "Pass", "Fail", "Error", "Aborted"]);

            var formatNumberWithCommas = function formatNumberWithCommas(val) {
              if (val === null || val === undefined || val === '') return '-';
              var n = Number(val);
              if (!isFinite(n)) return String(val);
              return n.toLocaleString('en-US');
            };

            var result = headerValue.map(function (header) {
              var obj = {
                name: header
              };

              try {
                (_this2._functionalService.testRunData || []).forEach(function (item, index) {
                  var raw = item ? item[keyMap[header]] : undefined;
                  obj["val".concat(index + 1)] = numericHeaders.has(header) ? formatNumberWithCommas(raw) : raw != null ? String(raw) : '-';
                });
              } catch (e) {
                console.error('Error building row for header', header, e);
              }

              return obj;
            });
            resolve(result);
          });
        }
        /**
         * Convert a single row object into cav-table header column definitions.
         * Returns empty array when `res` is invalid or empty.
         */

      }, {
        key: "getFormatedHeaderForCavTable",
        value: function getFormatedHeaderForCavTable(res) {
          if (!res || !Array.isArray(res) || res.length === 0) return [];
          var columnData = Object.keys(res[0]).map(function (key, index) {
            return {
              label: '',
              key: index === 0 ? 'name' : "val".concat(index),
              type: 0,
              classes: index === 0 ? 'btn-icon font-weight-600' : ''
            };
          });
          return [{
            cols: columnData
          }];
        }
      }, {
        key: "onClickRecentTestEvent",
        value: function onClickRecentTestEvent() {}
        /**
         * Load per-test-run details and populate `reportMap` and table headers/data.
         */

      }, {
        key: "getReportDetails",
        value: function getReportDetails() {
          return Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__awaiter"])(this, void 0, void 0, /*#__PURE__*/_regenerator().m(function _callee2() {
            var _this3 = this;

            var testRuns, compare, _t;

            return _regenerator().w(function (_context2) {
              while (1) switch (_context2.p = _context2.n) {
                case 0:
                  testRuns = this._functionalService && Array.isArray(this._functionalService.testRunData) ? this._functionalService.testRunData.map(function (tr) {
                    return tr === null || tr === void 0 ? void 0 : tr.testRun;
                  }).filter(Boolean) : [];
                  _context2.p = 1;
                  _context2.n = 2;
                  return Promise.all(testRuns.map(function (tr) {
                    return Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__awaiter"])(_this3, void 0, void 0, /*#__PURE__*/_regenerator().m(function _callee() {
                      var report;
                      return _regenerator().w(function (_context) {
                        while (1) switch (_context.n) {
                          case 0:
                            _context.n = 1;
                            return this.getTestRunReport(tr);

                          case 1:
                            report = _context.v;
                            this.reportMap.set(tr, report !== null && report !== void 0 ? report : []);
                            return _context.a(2, report);
                        }
                      }, _callee, this);
                    }));
                  }));

                case 2:
                  if (this.isCompare) {
                    compare = this.buildCompareDetailsTable();
                    this.detailsTableHeader = compare.header;
                    this.reportDetailsData = compare.data ? _toConsumableArray(compare.data) : [];
                  } else {
                    this.detailsTableHeader = this.getNonCompareHeader();
                  }

                  _context2.n = 4;
                  break;

                case 3:
                  _context2.p = 3;
                  _t = _context2.v;
                  console.error('getReportDetails failed', _t);
                  this.detailsTableHeader = this.getNonCompareHeader();
                  this.reportDetailsData = [];

                case 4:
                  return _context2.a(2);
              }
            }, _callee2, this, [[1, 3]]);
          }));
        }
        /**
         * Build dynamic header and rows for compare (multi test run) details table
         */

      }, {
        key: "buildCompareDetailsTable",
        value: function buildCompareDetailsTable() {
          var _a, _b;

          var testRuns = ((_b = (_a = this._functionalService) === null || _a === void 0 ? void 0 : _a.testRunData) === null || _b === void 0 ? void 0 : _b.map(function (tr) {
            return (tr === null || tr === void 0 ? void 0 : tr.testRun) + "";
          })) || [];
          var header = this.getCompareHeader(testRuns); // Build a quick lookup by normalized test name (to avoid duplicate rows for same base test)
          // Example: 
          //  .SubhamSCENARIO_Test1_ca30b4 and .SubhamSCENARIO_Test1_faaab3
          //  -> normalized key: .SubhamSCENARIO_Test1

          var perRunKeyMap = new Map();
          var uniqueKeys = new Set();
          var displayNameForKey = new Map();

          var _iterator2 = _createForOfIteratorHelper(testRuns),
              _step2;

          try {
            for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
              var tr = _step2.value;
              var list = this.reportMap.get(tr) || [];
              var keyMap = new Map();

              var _iterator4 = _createForOfIteratorHelper(list),
                  _step4;

              try {
                for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
                  var item = _step4.value;
                  var key = this.normalizeTestCaseName(item === null || item === void 0 ? void 0 : item.name);
                  uniqueKeys.add(key);
                  keyMap.set(key, item); // Use the first encountered name as display label (preserves suffix from first available run)

                  if (!displayNameForKey.has(key)) {
                    displayNameForKey.set(key, (item === null || item === void 0 ? void 0 : item.name) || key);
                  }
                }
              } catch (err) {
                _iterator4.e(err);
              } finally {
                _iterator4.f();
              }

              perRunKeyMap.set(tr, keyMap);
            } // Produce rows aligned by normalized name

          } catch (err) {
            _iterator2.e(err);
          } finally {
            _iterator2.f();
          }

          var data = Array.from(uniqueKeys).sort(function (a, b) {
            return (displayNameForKey.get(a) || a).localeCompare(displayNameForKey.get(b) || b);
          }).map(function (key) {
            var _a, _b;

            var row = {
              name: displayNameForKey.get(key) || key
            };

            var _iterator3 = _createForOfIteratorHelper(testRuns),
                _step3;

            try {
              for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
                var tr = _step3.value;
                var item = (_a = perRunKeyMap.get(tr)) === null || _a === void 0 ? void 0 : _a.get(key);
                row["tr_".concat(tr, "_status")] = (_b = item === null || item === void 0 ? void 0 : item.status) !== null && _b !== void 0 ? _b : '-'; // row[`tr_${tr}_duration`] = item?.duration ?? '-';
              }
            } catch (err) {
              _iterator3.e(err);
            } finally {
              _iterator3.f();
            }

            return row;
          });
          return {
            header: header,
            data: data
          };
        }
        /**
         * Normalize test case names by removing trailing random suffixes like _<6-hex>.
         * Examples:
         *  .SubhamSCENARIO_Test1_ca30b4 -> .SubhamSCENARIO_Test1
         *  .SubhamSCENARIO_Test2_e1fa94 -> .SubhamSCENARIO_Test2
         */

      }, {
        key: "normalizeTestCaseName",
        value: function normalizeTestCaseName(name) {
          if (!name) return name;
          var match = name.match(/^(.*)_[a-fA-F0-9]{6}$/);
          return match ? match[1] : name;
        }
        /**
         * Dynamic multi-header for compare view.
         * Example: [ Name | Test Run 1091 -> (Status, Duration) | Test Run 1088 -> (Status, Duration) ]
         */

      }, {
        key: "getCompareHeader",
        value: function getCompareHeader(testRuns) {
          var PX180 = '180px';
          var statusDefinition = [{
            value: '1',
            label: 'Success',
            borClrCls: 'cav-status rounded-3 completed'
          }, {
            value: '2',
            label: 'Failed',
            borClrCls: 'cav-status rounded-3 failed'
          }, {
            value: '3',
            label: 'Not Started',
            borClrCls: 'cav-status rounded-3 configured'
          }, {
            value: '4',
            label: 'Aborted',
            borClrCls: 'cav-status rounded-3 stopped'
          }, {
            value: '5',
            label: 'Error',
            borClrCls: 'cav-status rounded-3 failed'
          }, {
            value: '6',
            label: 'Running',
            borClrCls: 'cav-status rounded-3 running',
            iconClass: 'pi pi-spinner spin',
            toolTip: 'In progress'
          }];
          var cols = [{
            label: 'TC Name',
            key: 'name',
            type: 0
          }];

          var _iterator5 = _createForOfIteratorHelper(testRuns),
              _step5;

          try {
            for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
              var tr = _step5.value;
              cols.push({
                label: "Test Run ".concat(tr),
                key: "tr_".concat(tr, "_status"),
                type: 8,
                definition: statusDefinition,
                classes: 'text-center' // child: [
                //   { label: 'Status', key: `tr_${tr}_status`, type: 8, width: PX180, classes: 'text-center', definition: statusDefinition },
                //   { label: 'Duration', key: `tr_${tr}_duration`, type: 0, width: PX180, classes: 'text-right' }
                // ]

              });
            }
          } catch (err) {
            _iterator5.e(err);
          } finally {
            _iterator5.f();
          }

          return [{
            cols: cols
          }];
        }
      }, {
        key: "getTestRunReport",
        value: function getTestRunReport(testRun) {
          return Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__awaiter"])(this, void 0, void 0, /*#__PURE__*/_regenerator().m(function _callee3() {
            var _this4 = this;

            var me, filePath, data, lines, testCaseLines, normalizeStatus, tableData, _t2;

            return _regenerator().w(function (_context3) {
              while (1) switch (_context3.p = _context3.n) {
                case 0:
                  _context3.p = 0;
                  me = this;
                  filePath = this._functionalService.getLogBasePath() + testRun + "/tc_summary.top";
                  _context3.n = 1;
                  return me._functionalService.readFileData(filePath);

                case 1:
                  data = _context3.v;

                  if (data) {
                    _context3.n = 2;
                    break;
                  }

                  this.reportDetailsData = [];
                  return _context3.a(2, []);

                case 2:
                  lines = data.split('\n'); // Robustly filter: drop headers, blanks, and malformed rows without '|'

                  testCaseLines = lines.map(function (l) {
                    return (l || '').trim();
                  }).filter(function (line) {
                    return line && !line.startsWith('#') && line.includes('|');
                  });

                  normalizeStatus = function normalizeStatus(raw) {
                    if (!raw) return '';
                    var s = raw.toString().trim().toLowerCase().replace(/[-\s]+/g, '_');
                    if (s === 'success' || s === 'succeeded' || s === 'pass') s = 'passed';
                    if (s === 'notstarted') s = 'not_started';
                    if (s === 'abort') s = 'stopped';
                    return s;
                  };

                  tableData = testCaseLines.map(function (line) {
                    var parts = line.split('|');
                    if (!parts || parts.length < 5) return null;
                    var tr = (parts[0] || '').trim();
                    var path = (parts[1] || '').trim();
                    var errorMsg = (parts[5] || '').trim();
                    var nameParts = path.split('/');
                    var name = nameParts[nameParts.length - 1] || path;
                    var startSec = Number((parts[2] || '0').trim());
                    var durationSec = Number((parts[3] || '0').trim());
                    var statusKey = normalizeStatus((parts[4] || '').trim());

                    var status = _this4._functionalService.getStatus(statusKey);

                    if (status == null) {
                      // Default unknown statuses to 'error'
                      status = _this4._functionalService.getStatus('error');
                    }

                    return {
                      name: name,
                      description: 'Sample Test',
                      startTime: startSec > 0 ? _this4._sessionService.convertTimeToSelectedTimeZone(startSec * 1000) : '-',
                      duration: status === _service_functional_enum__WEBPACK_IMPORTED_MODULE_7__["Status"].RUNNING ? '-' : _this4._sessionService.convertMSIntoDuration(durationSec * 1000),
                      status: status,
                      error: errorMsg,
                      testRun: tr
                    };
                  }).filter(Boolean);
                  this.reportDetailsData = _toConsumableArray(tableData);
                  return _context3.a(2, tableData);

                case 3:
                  _context3.p = 3;
                  _t2 = _context3.v;
                  console.error("getSummaryData: ", _t2);
                  return _context3.a(2, []);
              }
            }, _callee3, this, [[0, 3]]);
          }));
        }
        /**
         * Generates a multi-page PDF from the entire scrollable content of the report.
         */

      }, {
        key: "downloadReport",
        value: function downloadReport() {
          var _a;

          return Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__awaiter"])(this, void 0, void 0, /*#__PURE__*/_regenerator().m(function _callee4() {
            var content, originalRows, originalFirst, originalPaginator, originalScrollable, prevStyle, canvas, imgData, pdf, pageWidth, pageHeight, canvasAspectRatio, imgHeight, heightLeft, position, _t3;

            return _regenerator().w(function (_context4) {
              while (1) switch (_context4.p = _context4.n) {
                case 0:
                  if (!this.isDownloading) {
                    _context4.n = 1;
                    break;
                  }

                  return _context4.a(2);

                case 1:
                  this.isDownloading = true;
                  content = this.pdfContent.nativeElement; // We'll use these in finally to restore UI state

                  originalRows = Object.assign({}, this.rows);
                  originalFirst = Object.assign({}, this.first);
                  originalPaginator = this.paginator;
                  originalScrollable = this.scrollable;
                  prevStyle = null;
                  _context4.p = 2;
                  // 1) Expand table to render all rows and disable internal scroll/pagination
                  this.paginator = false;
                  this.scrollable = false;
                  this.first = {
                    first: 0
                  };
                  this.rows = {
                    rows: ((_a = this.reportDetailsData) === null || _a === void 0 ? void 0 : _a.length) || 100000
                  };
                  this.cd.detectChanges();
                  _context4.n = 3;
                  return new Promise(requestAnimationFrame);

                case 3:
                  // 2) Temporarily remove clipping on the capture root to include scrolled content
                  prevStyle = {
                    height: content.style.height,
                    overflow: content.style.overflow,
                    maxHeight: content.style.maxHeight
                  };
                  content.style.height = content.scrollHeight + 'px';
                  content.style.maxHeight = 'none';
                  content.style.overflow = 'visible'; // Use html2canvas to capture the content.

                  _context4.n = 4;
                  return html2canvas__WEBPACK_IMPORTED_MODULE_6___default()(content, {
                    height: content.scrollHeight,
                    width: content.scrollWidth,
                    windowHeight: content.scrollHeight,
                    windowWidth: content.scrollWidth,
                    backgroundColor: '#ffffff',
                    scale: 2,
                    useCORS: true,
                    logging: false
                  });

                case 4:
                  canvas = _context4.v;
                  imgData = canvas.toDataURL('image/png'); // A4 paper dimensions in mm

                  pdf = new jspdf__WEBPACK_IMPORTED_MODULE_5__["default"]({
                    orientation: 'p',
                    unit: 'mm',
                    format: 'a4'
                  });
                  pageWidth = pdf.internal.pageSize.getWidth();
                  pageHeight = pdf.internal.pageSize.getHeight();
                  canvasAspectRatio = canvas.width / canvas.height; // Calculate the image height in the PDF to maintain aspect ratio

                  imgHeight = pageWidth / canvasAspectRatio;
                  heightLeft = imgHeight; // Add the first page

                  pdf.addImage(imgData, 'PNG', 0, 0, pageWidth, imgHeight);
                  heightLeft -= pageHeight; // Add subsequent pages if the content is longer than one page

                  position = -pageHeight;

                  while (heightLeft > 0) {
                    pdf.addPage();
                    pdf.addImage(imgData, 'PNG', 0, position, pageWidth, imgHeight);
                    heightLeft -= pageHeight;
                    position -= pageHeight;
                  }

                  pdf.save('Test_Suite_Report.pdf'); // Success path continues to finally for uniform cleanup

                  _context4.n = 6;
                  break;

                case 5:
                  _context4.p = 5;
                  _t3 = _context4.v;
                  console.error('Error generating PDF:', _t3); // Optionally, show an error notification to the user

                case 6:
                  _context4.p = 6;
                  // Restore UI state
                  this.first = originalFirst || {
                    first: 0
                  };
                  this.rows = originalRows || {
                    rows: 10
                  };
                  this.paginator = originalPaginator;
                  this.scrollable = originalScrollable;

                  try {
                    content.style.height = (prevStyle === null || prevStyle === void 0 ? void 0 : prevStyle.height) || '';
                    content.style.maxHeight = (prevStyle === null || prevStyle === void 0 ? void 0 : prevStyle.maxHeight) || '';
                    content.style.overflow = (prevStyle === null || prevStyle === void 0 ? void 0 : prevStyle.overflow) || '';
                  } catch (_b) {}

                  this.cd.detectChanges();
                  this.isDownloading = false;
                  return _context4.f(6);

                case 7:
                  return _context4.a(2);
              }
            }, _callee4, this, [[2, 5, 6, 7]]);
          }));
        }
      }, {
        key: "goToBack",
        value: function goToBack() {
          this.router.navigate(['/home/functional']);
        }
      }, {
        key: "getNonCompareHeader",
        value: function getNonCompareHeader() {
          var header = [{
            "cols": [{
              "label": "Test Case Name",
              "key": "name",
              "type": 0
            }, {
              "label": "Start Time",
              "key": "startTime",
              "width": "180px",
              "type": 0
            }, {
              "label": "Duration",
              "key": "duration",
              "type": 0,
              "width": "180px",
              "classes": "text-right"
            }, {
              "label": "Status",
              "key": "status",
              "type": 8,
              "width": "180px",
              "classes": "text-center",
              "definition": [{
                "value": "1",
                "label": "Success",
                "borClrCls": "cav-status rounded-3 completed"
              }, {
                "value": "2",
                "label": "Failed",
                "borClrCls": "cav-status rounded-3 failed"
              }, {
                "value": "3",
                "label": "Not Started",
                "borClrCls": "cav-status rounded-3 configured"
              }, {
                "value": "4",
                "label": "Aborted",
                "borClrCls": "cav-status rounded-3 stopped"
              }, {
                "value": "5",
                "label": "Error",
                "borClrCls": "cav-status rounded-3 failed"
              }, {
                "value": "6",
                "label": "Running",
                "borClrCls": "cav-status rounded-3 running",
                "iconClass": "pi pi-spinner spin",
                "toolTip": "In progress"
              }]
            }, {
              "label": "Error",
              "key": "error",
              "width": "250px",
              "type": 0
            }]
          }];
          return header;
        }
      }]);
    }();

    ViewReportComponent.ctorParameters = function () {
      return [{
        type: _angular_router__WEBPACK_IMPORTED_MODULE_2__["Router"]
      }, {
        type: _service_functional_service__WEBPACK_IMPORTED_MODULE_3__["FunctionalService"]
      }, {
        type: src_app_core_session_session_service__WEBPACK_IMPORTED_MODULE_4__["SessionService"]
      }, {
        type: _angular_core__WEBPACK_IMPORTED_MODULE_1__["ChangeDetectorRef"]
      }];
    };

    Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([Object(_angular_core__WEBPACK_IMPORTED_MODULE_1__["ViewChild"])('pdfContent', {
      "static": false
    })], ViewReportComponent.prototype, "pdfContent", void 0);
    ViewReportComponent = Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([Object(_angular_core__WEBPACK_IMPORTED_MODULE_1__["Component"])({
      selector: 'app-view-report',
      template: Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__importDefault"])(__webpack_require__(
      /*! raw-loader!./view-report.component.html */
      "./node_modules/raw-loader/dist/cjs.js!./src/app/pages/home/functional/view-report/view-report.component.html"))["default"],
      encapsulation: _angular_core__WEBPACK_IMPORTED_MODULE_1__["ViewEncapsulation"].None,
      styles: [Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__importDefault"])(__webpack_require__(
      /*! ./view-report.component.scss */
      "./src/app/pages/home/functional/view-report/view-report.component.scss"))["default"]]
    })], ViewReportComponent);
    /***/
  },

  /***/
  "./src/app/pages/home/functional/view-report/view-report.module.ts":
  /*!*************************************************************************!*\
    !*** ./src/app/pages/home/functional/view-report/view-report.module.ts ***!
    \*************************************************************************/

  /*! exports provided: ViewReportModule */

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

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


    __webpack_require__.d(__webpack_exports__, "ViewReportModule", function () {
      return ViewReportModule;
    });
    /* 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 _view_report_component__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(
    /*! ./view-report.component */
    "./src/app/pages/home/functional/view-report/view-report.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_material_tooltip__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(
    /*! @angular/material/tooltip */
    "./node_modules/@angular/material/__ivy_ngcc__/fesm2015/tooltip.js");
    /* harmony import */


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


    var primeng__WEBPACK_IMPORTED_MODULE_7__ = __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_8__ = __webpack_require__(
    /*! src/app/shared/cav-table/cav-table.module */
    "./src/app/shared/cav-table/cav-table.module.ts");

    var imports = [_angular_common__WEBPACK_IMPORTED_MODULE_2__["CommonModule"], primeng__WEBPACK_IMPORTED_MODULE_7__["TableModule"], primeng__WEBPACK_IMPORTED_MODULE_7__["CardModule"], primeng__WEBPACK_IMPORTED_MODULE_7__["ButtonModule"], _angular_forms__WEBPACK_IMPORTED_MODULE_4__["FormsModule"], primeng__WEBPACK_IMPORTED_MODULE_7__["TabViewModule"], src_app_shared_cav_table_cav_table_module__WEBPACK_IMPORTED_MODULE_8__["CavTableModule"], _angular_material_tooltip__WEBPACK_IMPORTED_MODULE_5__["MatTooltipModule"], primeng__WEBPACK_IMPORTED_MODULE_7__["ToolbarModule"]];
    var components = [_view_report_component__WEBPACK_IMPORTED_MODULE_3__["ViewReportComponent"]];
    var routes = [{
      path: '',
      component: _view_report_component__WEBPACK_IMPORTED_MODULE_3__["ViewReportComponent"]
    }];

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

    ViewReportModule = Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([Object(_angular_core__WEBPACK_IMPORTED_MODULE_1__["NgModule"])({
      declarations: [components],
      imports: [imports, _angular_router__WEBPACK_IMPORTED_MODULE_6__["RouterModule"].forChild(routes)],
      exports: [_angular_router__WEBPACK_IMPORTED_MODULE_6__["RouterModule"]]
    })], ViewReportModule);
    /***/
  }
}]);