import { Component, Input, Output, EventEmitter, ChangeDetectionStrategy } from '@angular/core';
import { Subject } from 'rxjs';
import { takeUntil, map } from 'rxjs/operators';
import { CompositeKey } from '@memberjunction/core';
import { SharedService } from '@memberjunction/ng-shared';
import { TestEngineBase } from '@memberjunction/testing-engine-base';
import * as i0 from "@angular/core";
import * as i1 from "../services/testing-instrumentation.service";
import * as i2 from "@memberjunction/ng-testing";
import * as i3 from "@memberjunction/ng-shared-generic";
import * as i4 from "../../AI/components/widgets/kpi-card.component";
import * as i5 from "@angular/common";
const _forTrack0 = ($index, $item) => $item.title;
const _forTrack1 = ($index, $item) => $item.id;
function TestingDashboardTabComponent_Conditional_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 0);
    i0.ɵɵelement(1, "mj-loading", 2);
    i0.ɵɵelementEnd();
} }
function TestingDashboardTabComponent_Conditional_1_For_10_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "app-kpi-card", 9);
} if (rf & 2) {
    const kpi_r3 = ctx.$implicit;
    i0.ɵɵproperty("data", kpi_r3);
} }
function TestingDashboardTabComponent_Conditional_1_Conditional_13_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "span", 28);
    i0.ɵɵelementStart(1, "h3");
    i0.ɵɵtext(2);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate2("", ctx_r1.RunningTests.length, " test", ctx_r1.RunningTests.length === 1 ? "" : "s", " running");
} }
function TestingDashboardTabComponent_Conditional_1_Conditional_14_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "i", 29);
    i0.ɵɵelementStart(1, "h3");
    i0.ɵɵtext(2, "No tests currently running");
    i0.ɵɵelementEnd();
} }
function TestingDashboardTabComponent_Conditional_1_Conditional_15_For_2_Template(rf, ctx) { if (rf & 1) {
    const _r4 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "div", 31);
    i0.ɵɵlistener("click", function TestingDashboardTabComponent_Conditional_1_Conditional_15_For_2_Template_div_click_0_listener() { const run_r5 = i0.ɵɵrestoreView(_r4).$implicit; const ctx_r1 = i0.ɵɵnextContext(3); return i0.ɵɵresetView(ctx_r1.OnViewRunningTest(run_r5)); });
    i0.ɵɵelementStart(1, "div", 32)(2, "div", 33);
    i0.ɵɵtext(3);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(4, "div", 34);
    i0.ɵɵtext(5);
    i0.ɵɵelementEnd()();
    i0.ɵɵelementStart(6, "div", 35)(7, "span", 36);
    i0.ɵɵtext(8);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(9, "span", 37);
    i0.ɵɵelement(10, "span", 38);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(11, "span", 39);
    i0.ɵɵtext(12);
    i0.ɵɵelementEnd()()();
} if (rf & 2) {
    const run_r5 = ctx.$implicit;
    const ctx_r1 = i0.ɵɵnextContext(3);
    i0.ɵɵadvance(3);
    i0.ɵɵtextInterpolate(run_r5.testName);
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate(ctx_r1.GetActiveRunStep(run_r5.testId));
    i0.ɵɵadvance(3);
    i0.ɵɵtextInterpolate(ctx_r1.FormatDuration(run_r5.duration));
    i0.ɵɵadvance(2);
    i0.ɵɵstyleProp("width", ctx_r1.GetActiveRunProgress(run_r5.testId), "%");
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate1("", ctx_r1.GetActiveRunProgress(run_r5.testId), "%");
} }
function TestingDashboardTabComponent_Conditional_1_Conditional_15_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 12);
    i0.ɵɵrepeaterCreate(1, TestingDashboardTabComponent_Conditional_1_Conditional_15_For_2_Template, 13, 6, "div", 30, _forTrack1);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance();
    i0.ɵɵrepeater(ctx_r1.RunningTests);
} }
function TestingDashboardTabComponent_Conditional_1_For_24_Template(rf, ctx) { if (rf & 1) {
    const _r6 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "div", 40);
    i0.ɵɵlistener("click", function TestingDashboardTabComponent_Conditional_1_For_24_Template_div_click_0_listener() { const run_r7 = i0.ɵɵrestoreView(_r6).$implicit; const ctx_r1 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r1.OnOpenRun(run_r7)); });
    i0.ɵɵelementStart(1, "div", 41)(2, "span", 42);
    i0.ɵɵtext(3);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(4, "span", 43);
    i0.ɵɵtext(5);
    i0.ɵɵelementEnd()();
    i0.ɵɵelementStart(6, "div", 44);
    i0.ɵɵelement(7, "app-test-status-badge", 45)(8, "app-score-indicator", 46);
    i0.ɵɵelementStart(9, "span", 47);
    i0.ɵɵtext(10);
    i0.ɵɵelementEnd();
    i0.ɵɵelement(11, "app-cost-display", 48);
    i0.ɵɵelementEnd()();
} if (rf & 2) {
    const run_r7 = ctx.$implicit;
    const ctx_r1 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(3);
    i0.ɵɵtextInterpolate(run_r7.testName);
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate(ctx_r1.FormatTimestamp(run_r7.runDateTime));
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("status", run_r7.status);
    i0.ɵɵadvance();
    i0.ɵɵproperty("score", run_r7.score)("showBar", true);
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate(ctx_r1.FormatDuration(run_r7.duration));
    i0.ɵɵadvance();
    i0.ɵɵproperty("cost", run_r7.cost);
} }
function TestingDashboardTabComponent_Conditional_1_ForEmpty_25_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 18);
    i0.ɵɵtext(1, "No completed test runs found");
    i0.ɵɵelementEnd();
} }
function TestingDashboardTabComponent_Conditional_1_For_34_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 23)(1, "div", 49)(2, "span", 50);
    i0.ɵɵtext(3);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(4, "span", 51);
    i0.ɵɵtext(5);
    i0.ɵɵelementEnd()();
    i0.ɵɵelementStart(6, "div", 52)(7, "div", 53);
    i0.ɵɵelement(8, "div", 54);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(9, "span", 55);
    i0.ɵɵtext(10);
    i0.ɵɵpipe(11, "number");
    i0.ɵɵelementEnd()()();
} if (rf & 2) {
    const suite_r8 = ctx.$implicit;
    const ctx_r1 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(3);
    i0.ɵɵtextInterpolate(suite_r8.name);
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate1("", suite_r8.testCount, " tests");
    i0.ɵɵadvance(3);
    i0.ɵɵstyleProp("width", suite_r8.passRate, "%")("background", ctx_r1.GetPassRateColor(suite_r8.passRate));
    i0.ɵɵadvance();
    i0.ɵɵstyleProp("color", ctx_r1.GetPassRateColor(suite_r8.passRate));
    i0.ɵɵadvance();
    i0.ɵɵtextInterpolate1(" ", i0.ɵɵpipeBind2(11, 9, suite_r8.passRate, "1.0-0"), "% ");
} }
function TestingDashboardTabComponent_Conditional_1_ForEmpty_35_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 18);
    i0.ɵɵtext(1, "No test suites found");
    i0.ɵɵelementEnd();
} }
function TestingDashboardTabComponent_Conditional_1_For_43_Conditional_6_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵtext(0, " Regression detected ");
} }
function TestingDashboardTabComponent_Conditional_1_For_43_Conditional_7_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵtext(0);
    i0.ɵɵpipe(1, "number");
} if (rf & 2) {
    const alert_r10 = i0.ɵɵnextContext().$implicit;
    i0.ɵɵtextInterpolate1(" Score below 0.5 (", i0.ɵɵpipeBind2(1, 1, alert_r10.score, "1.2-2"), ") ");
} }
function TestingDashboardTabComponent_Conditional_1_For_43_Template(rf, ctx) { if (rf & 1) {
    const _r9 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "div", 56);
    i0.ɵɵlistener("click", function TestingDashboardTabComponent_Conditional_1_For_43_Template_div_click_0_listener() { const alert_r10 = i0.ɵɵrestoreView(_r9).$implicit; const ctx_r1 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r1.OnOpenAlert(alert_r10)); });
    i0.ɵɵelement(1, "i", 57);
    i0.ɵɵelementStart(2, "div", 58)(3, "span", 59);
    i0.ɵɵtext(4);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(5, "span", 60);
    i0.ɵɵconditionalCreate(6, TestingDashboardTabComponent_Conditional_1_For_43_Conditional_6_Template, 1, 0)(7, TestingDashboardTabComponent_Conditional_1_For_43_Conditional_7_Template, 2, 4);
    i0.ɵɵelementEnd()();
    i0.ɵɵelement(8, "app-test-status-badge", 45);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const alert_r10 = ctx.$implicit;
    i0.ɵɵadvance();
    i0.ɵɵstyleProp("color", alert_r10.reason === "regression" ? "#ef4444" : "#f59e0b");
    i0.ɵɵclassProp("fa-arrow-trend-down", alert_r10.reason === "regression")("fa-circle-exclamation", alert_r10.reason === "low-score");
    i0.ɵɵadvance(3);
    i0.ɵɵtextInterpolate(alert_r10.testName);
    i0.ɵɵadvance(2);
    i0.ɵɵconditional(alert_r10.reason === "regression" ? 6 : 7);
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("status", alert_r10.status);
} }
function TestingDashboardTabComponent_Conditional_1_ForEmpty_44_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 18);
    i0.ɵɵelement(1, "i", 61);
    i0.ɵɵtext(2, " No alerts - all tests healthy ");
    i0.ɵɵelementEnd();
} }
function TestingDashboardTabComponent_Conditional_1_Template(rf, ctx) { if (rf & 1) {
    const _r1 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "div", 1)(1, "div", 3)(2, "h2", 4);
    i0.ɵɵelement(3, "i", 5);
    i0.ɵɵtext(4, " Testing Dashboard ");
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(5, "button", 6);
    i0.ɵɵlistener("click", function TestingDashboardTabComponent_Conditional_1_Template_button_click_5_listener() { i0.ɵɵrestoreView(_r1); const ctx_r1 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r1.OnRefresh()); });
    i0.ɵɵelement(6, "i", 7);
    i0.ɵɵtext(7, " Refresh ");
    i0.ɵɵelementEnd()();
    i0.ɵɵelementStart(8, "div", 8);
    i0.ɵɵrepeaterCreate(9, TestingDashboardTabComponent_Conditional_1_For_10_Template, 1, 1, "app-kpi-card", 9, _forTrack0);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(11, "div", 10)(12, "div", 11);
    i0.ɵɵconditionalCreate(13, TestingDashboardTabComponent_Conditional_1_Conditional_13_Template, 3, 2)(14, TestingDashboardTabComponent_Conditional_1_Conditional_14_Template, 3, 0);
    i0.ɵɵelementEnd();
    i0.ɵɵconditionalCreate(15, TestingDashboardTabComponent_Conditional_1_Conditional_15_Template, 3, 0, "div", 12);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(16, "div", 13)(17, "div", 14)(18, "div", 11)(19, "h3");
    i0.ɵɵelement(20, "i", 15);
    i0.ɵɵtext(21, " Recent Runs");
    i0.ɵɵelementEnd()();
    i0.ɵɵelementStart(22, "div", 16);
    i0.ɵɵrepeaterCreate(23, TestingDashboardTabComponent_Conditional_1_For_24_Template, 12, 7, "div", 17, _forTrack1, false, TestingDashboardTabComponent_Conditional_1_ForEmpty_25_Template, 2, 0, "div", 18);
    i0.ɵɵelementEnd()();
    i0.ɵɵelementStart(26, "div", 19)(27, "div", 20)(28, "div", 11)(29, "h3");
    i0.ɵɵelement(30, "i", 21);
    i0.ɵɵtext(31, " Suite Health");
    i0.ɵɵelementEnd()();
    i0.ɵɵelementStart(32, "div", 22);
    i0.ɵɵrepeaterCreate(33, TestingDashboardTabComponent_Conditional_1_For_34_Template, 12, 12, "div", 23, _forTrack1, false, TestingDashboardTabComponent_Conditional_1_ForEmpty_35_Template, 2, 0, "div", 18);
    i0.ɵɵelementEnd()();
    i0.ɵɵelementStart(36, "div", 24)(37, "div", 11)(38, "h3");
    i0.ɵɵelement(39, "i", 25);
    i0.ɵɵtext(40, " Alerts");
    i0.ɵɵelementEnd()();
    i0.ɵɵelementStart(41, "div", 26);
    i0.ɵɵrepeaterCreate(42, TestingDashboardTabComponent_Conditional_1_For_43_Template, 9, 9, "div", 27, _forTrack1, false, TestingDashboardTabComponent_Conditional_1_ForEmpty_44_Template, 3, 0, "div", 18);
    i0.ɵɵelementEnd()()()()();
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext();
    i0.ɵɵadvance(5);
    i0.ɵɵproperty("disabled", ctx_r1.IsLoading);
    i0.ɵɵadvance();
    i0.ɵɵclassProp("spinning", ctx_r1.IsLoading);
    i0.ɵɵadvance(3);
    i0.ɵɵrepeater(ctx_r1.KpiCards);
    i0.ɵɵadvance(4);
    i0.ɵɵconditional(ctx_r1.RunningTests.length > 0 ? 13 : 14);
    i0.ɵɵadvance(2);
    i0.ɵɵconditional(ctx_r1.RunningTests.length > 0 ? 15 : -1);
    i0.ɵɵadvance(8);
    i0.ɵɵrepeater(ctx_r1.RecentRuns);
    i0.ɵɵadvance(10);
    i0.ɵɵrepeater(ctx_r1.SortedSuites);
    i0.ɵɵadvance(9);
    i0.ɵɵrepeater(ctx_r1.Alerts);
} }
export class TestingDashboardTabComponent {
    instrumentationService;
    executionService;
    testingDialogService;
    cdr;
    initialState = null;
    stateChange = new EventEmitter();
    destroy$ = new Subject();
    /** Resolved data for the template */
    IsLoading = false;
    KpiCards = [];
    RunningTests = [];
    RecentRuns = [];
    SortedSuites = [];
    Alerts = [];
    activeRunsMap = new Map();
    constructor(instrumentationService, executionService, testingDialogService, cdr) {
        this.instrumentationService = instrumentationService;
        this.executionService = executionService;
        this.testingDialogService = testingDialogService;
        this.cdr = cdr;
    }
    // ---------------------------------------------------------------------------
    // Lifecycle
    // ---------------------------------------------------------------------------
    async ngOnInit() {
        await TestEngineBase.Instance.Config(false);
        this.subscribeToStreams();
        this.instrumentationService.refresh();
    }
    ngOnDestroy() {
        this.destroy$.next();
        this.destroy$.complete();
    }
    // ---------------------------------------------------------------------------
    // Public methods (PascalCase)
    // ---------------------------------------------------------------------------
    OnRefresh() {
        this.instrumentationService.refresh();
    }
    OnViewRunningTest(run) {
        this.testingDialogService.OpenTestMonitor(run.testId);
    }
    GetActiveRunProgress(testId) {
        return this.activeRunsMap.get(testId)?.Progress ?? 0;
    }
    GetActiveRunStep(testId) {
        const step = this.activeRunsMap.get(testId)?.CurrentStep ?? '';
        // Hide raw internal step identifiers (e.g. "driver_log", "loading_test")
        if (step.includes('_'))
            return '';
        return step;
    }
    OnOpenRun(run) {
        SharedService.Instance.OpenEntityRecord('MJ: Test Runs', CompositeKey.FromID(run.id));
    }
    OnOpenAlert(alert) {
        SharedService.Instance.OpenEntityRecord('MJ: Test Runs', CompositeKey.FromID(alert.id));
    }
    FormatDuration(ms) {
        if (ms < 1000)
            return `${ms}ms`;
        const totalSeconds = Math.floor(ms / 1000);
        const minutes = Math.floor(totalSeconds / 60);
        const seconds = totalSeconds % 60;
        if (minutes > 0)
            return `${minutes}m ${seconds}s`;
        return `${seconds}s`;
    }
    FormatTimestamp(date) {
        if (!date)
            return '';
        const d = date instanceof Date ? date : new Date(date);
        const now = new Date();
        const diffMs = now.getTime() - d.getTime();
        const diffMins = Math.floor(diffMs / 60000);
        if (diffMins < 1)
            return 'Just now';
        if (diffMins < 60)
            return `${diffMins}m ago`;
        const diffHours = Math.floor(diffMins / 60);
        if (diffHours < 24)
            return `${diffHours}h ago`;
        const diffDays = Math.floor(diffHours / 24);
        if (diffDays < 7)
            return `${diffDays}d ago`;
        return d.toLocaleDateString();
    }
    FormatCost(cost) {
        return `$${cost.toFixed(4)}`;
    }
    GetPassRateColor(rate) {
        if (rate >= 90)
            return '#22c55e';
        if (rate >= 70)
            return '#f59e0b';
        return '#ef4444';
    }
    // ---------------------------------------------------------------------------
    // Private helpers (camelCase)
    // ---------------------------------------------------------------------------
    subscribeToStreams() {
        this.subscribeLoading();
        this.subscribeKpis();
        this.subscribeTestRuns();
        this.subscribeSuites();
        this.subscribeActiveRuns();
    }
    subscribeActiveRuns() {
        this.executionService.ActiveRuns$.pipe(takeUntil(this.destroy$)).subscribe(runs => {
            this.activeRunsMap.clear();
            for (const run of runs) {
                this.activeRunsMap.set(run.TestId, run);
            }
            this.cdr.markForCheck();
        });
    }
    subscribeLoading() {
        this.instrumentationService.isLoading$.pipe(takeUntil(this.destroy$)).subscribe(loading => {
            this.IsLoading = loading;
            this.cdr.markForCheck();
        });
    }
    subscribeKpis() {
        this.instrumentationService.kpis$.pipe(takeUntil(this.destroy$), map(kpis => this.buildKpiCards(kpis))).subscribe(cards => {
            this.KpiCards = cards;
            this.cdr.markForCheck();
        });
    }
    subscribeTestRuns() {
        this.instrumentationService.testRuns$.pipe(takeUntil(this.destroy$)).subscribe(runs => {
            this.RunningTests = runs.filter(r => r.status === 'Running');
            this.RecentRuns = runs
                .filter(r => r.status !== 'Running')
                .slice(0, 15);
            this.Alerts = this.buildAlerts(runs);
            this.cdr.markForCheck();
        });
    }
    subscribeSuites() {
        this.instrumentationService.suiteHierarchy$.pipe(takeUntil(this.destroy$)).subscribe(suites => {
            this.SortedSuites = this.flattenAndSort(suites);
            this.cdr.markForCheck();
        });
    }
    buildKpiCards(kpis) {
        const trendDir = kpis.passRateTrend > 0
            ? 'up'
            : kpis.passRateTrend < 0
                ? 'down'
                : 'stable';
        return [
            {
                title: 'Active Tests',
                value: kpis.totalTestsActive,
                icon: 'fa-vial',
                color: 'primary',
                subtitle: `${kpis.totalTestRuns} runs this period`
            },
            {
                title: 'Pass Rate',
                value: `${kpis.passRateThisMonth.toFixed(1)}%`,
                icon: 'fa-check-circle',
                color: kpis.passRateThisMonth >= 90 ? 'success' : kpis.passRateThisMonth >= 75 ? 'warning' : 'danger',
                trend: kpis.passRateTrend !== 0 ? {
                    direction: trendDir,
                    percentage: Math.abs(Math.round(kpis.passRateTrend * 10) / 10),
                    period: 'vs previous period'
                } : undefined
            },
            {
                title: 'Total Cost',
                value: `$${kpis.totalCostThisMonth.toFixed(2)}`,
                icon: 'fa-dollar-sign',
                color: 'warning',
                subtitle: 'This period'
            },
            {
                title: 'Avg Duration',
                value: this.FormatDuration(kpis.averageDuration),
                icon: 'fa-clock',
                color: 'info',
                subtitle: 'Per test run'
            },
            {
                title: 'Pending Review',
                value: kpis.testsPendingReview,
                icon: 'fa-clipboard-check',
                color: kpis.testsPendingReview > 10 ? 'warning' : 'success',
                subtitle: 'Tests need feedback'
            }
        ];
    }
    buildAlerts(runs) {
        const alerts = [];
        // Group runs by test name to detect regressions
        const byTest = new Map();
        for (const run of runs) {
            const existing = byTest.get(run.testName);
            if (existing) {
                existing.push(run);
            }
            else {
                byTest.set(run.testName, [run]);
            }
        }
        this.detectRegressions(byTest, alerts);
        this.detectLowScores(runs, alerts);
        return alerts.slice(0, 20);
    }
    /** Find tests that previously passed but now fail */
    detectRegressions(byTest, alerts) {
        const seenIds = new Set();
        byTest.forEach((testRuns, testName) => {
            if (testRuns.length < 2)
                return;
            // Sort by date descending
            const sorted = [...testRuns].sort((a, b) => b.runDateTime.getTime() - a.runDateTime.getTime());
            const latest = sorted[0];
            const previous = sorted[1];
            if ((latest.status === 'Failed' || latest.status === 'Error') &&
                previous.status === 'Passed' &&
                !seenIds.has(latest.id)) {
                seenIds.add(latest.id);
                alerts.push({
                    id: latest.id,
                    testName,
                    reason: 'regression',
                    score: latest.score,
                    status: latest.status,
                    runDateTime: latest.runDateTime
                });
            }
        });
    }
    /** Flag tests with scores below 0.5 */
    detectLowScores(runs, alerts) {
        const alertIds = new Set(alerts.map(a => a.id));
        for (const run of runs) {
            if (run.score < 0.5 && run.status !== 'Running' && !alertIds.has(run.id)) {
                alerts.push({
                    id: run.id,
                    testName: run.testName,
                    reason: 'low-score',
                    score: run.score,
                    status: run.status,
                    runDateTime: run.runDateTime
                });
            }
        }
    }
    /** Flatten suite hierarchy and sort by worst health first */
    flattenAndSort(nodes) {
        const flat = [];
        this.collectNodes(nodes, flat);
        return flat.sort((a, b) => a.passRate - b.passRate);
    }
    collectNodes(nodes, out) {
        for (const node of nodes) {
            out.push(node);
            if (node.children.length > 0) {
                this.collectNodes(node.children, out);
            }
        }
    }
    static ɵfac = function TestingDashboardTabComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || TestingDashboardTabComponent)(i0.ɵɵdirectiveInject(i1.TestingInstrumentationService), i0.ɵɵdirectiveInject(i2.TestingExecutionService), i0.ɵɵdirectiveInject(i2.TestingDialogService), i0.ɵɵdirectiveInject(i0.ChangeDetectorRef)); };
    static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: TestingDashboardTabComponent, selectors: [["app-testing-dashboard-tab"]], inputs: { initialState: "initialState" }, outputs: { stateChange: "stateChange" }, standalone: false, decls: 2, vars: 1, consts: [[1, "full-page-loading"], [1, "dashboard-container"], ["text", "Loading Testing Dashboard..."], [1, "page-header"], [1, "page-title"], [1, "fa-solid", "fa-gauge-high"], [1, "refresh-btn", 3, "click", "disabled"], [1, "fa-solid", "fa-refresh"], [1, "kpi-row"], [3, "data"], [1, "live-activity-card"], [1, "section-header"], [1, "running-tests-list"], [1, "lower-grid"], [1, "card", "recent-runs-card"], [1, "fa-solid", "fa-history"], [1, "runs-list"], [1, "run-row"], [1, "empty-state"], [1, "right-column"], [1, "card", "suite-health-card"], [1, "fa-solid", "fa-heartbeat"], [1, "suite-health-list"], [1, "suite-health-row"], [1, "card", "alerts-card"], [1, "fa-solid", "fa-triangle-exclamation"], [1, "alerts-list"], [1, "alert-row"], [1, "live-dot"], [1, "fa-solid", "fa-circle-pause", "live-idle-icon"], [1, "running-test-item"], [1, "running-test-item", 3, "click"], [1, "running-test-info"], [1, "running-test-name"], [1, "running-test-step"], [1, "running-test-meta"], [1, "running-elapsed"], [1, "running-progress-bar"], [1, "running-progress-fill"], [1, "running-progress-pct"], [1, "run-row", 3, "click"], [1, "run-row-left"], [1, "run-row-name"], [1, "run-row-time"], [1, "run-row-right"], [3, "status"], [3, "score", "showBar"], [1, "run-row-duration"], [3, "cost"], [1, "suite-health-info"], [1, "suite-health-name"], [1, "suite-health-count"], [1, "suite-health-bar-wrapper"], [1, "suite-health-bar"], [1, "suite-health-bar-fill"], [1, "suite-health-pct"], [1, "alert-row", 3, "click"], [1, "fa-solid"], [1, "alert-info"], [1, "alert-name"], [1, "alert-reason"], [1, "fa-solid", "fa-check-circle", 2, "color", "var(--mj-status-success)", "margin-right", "6px"]], template: function TestingDashboardTabComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵconditionalCreate(0, TestingDashboardTabComponent_Conditional_0_Template, 2, 0, "div", 0)(1, TestingDashboardTabComponent_Conditional_1_Template, 45, 8, "div", 1);
        } if (rf & 2) {
            i0.ɵɵconditional(ctx.IsLoading ? 0 : 1);
        } }, dependencies: [i2.TestStatusBadgeComponent, i2.ScoreIndicatorComponent, i2.CostDisplayComponent, i3.LoadingComponent, i4.KPICardComponent, i5.DecimalPipe], styles: ["\n\n    .full-page-loading[_ngcontent-%COMP%] {\n      display: flex;\n      justify-content: center;\n      align-items: center;\n      height: 100%;\n      min-height: 400px;\n      background: var(--mj-bg-surface-card);\n    }\n\n    .dashboard-container[_ngcontent-%COMP%] {\n      padding: 24px;\n      height: 100%;\n      overflow-y: auto;\n      background: var(--mj-bg-surface-card);\n    }\n\n    \n\n    .page-header[_ngcontent-%COMP%] {\n      display: flex;\n      justify-content: space-between;\n      align-items: center;\n      margin-bottom: 24px;\n    }\n\n    .page-title[_ngcontent-%COMP%] {\n      margin: 0;\n      font-size: 22px;\n      font-weight: 700;\n      color: var(--mj-text-primary);\n      display: flex;\n      align-items: center;\n      gap: 10px;\n    }\n\n    .page-title[_ngcontent-%COMP%]   i[_ngcontent-%COMP%] { color: var(--mj-brand-primary); }\n\n    .refresh-btn[_ngcontent-%COMP%] {\n      background: var(--mj-brand-primary);\n      color: var(--mj-text-inverse);\n      border: none;\n      padding: 8px 18px;\n      border-radius: 8px;\n      cursor: pointer;\n      display: flex;\n      align-items: center;\n      gap: 6px;\n      font-size: 13px;\n      font-weight: 500;\n      transition: background 0.2s ease;\n    }\n\n    .refresh-btn[_ngcontent-%COMP%]:hover:not(:disabled) { background: var(--mj-brand-primary-hover); }\n    .refresh-btn[_ngcontent-%COMP%]:disabled { opacity: 0.6; cursor: not-allowed; }\n    .refresh-btn[_ngcontent-%COMP%]   i.spinning[_ngcontent-%COMP%] { animation: _ngcontent-%COMP%_spin 1s linear infinite; }\n\n    @keyframes _ngcontent-%COMP%_spin {\n      from { transform: rotate(0deg); }\n      to { transform: rotate(360deg); }\n    }\n\n    \n\n    .kpi-row[_ngcontent-%COMP%] {\n      display: grid;\n      grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));\n      gap: 16px;\n      margin-bottom: 24px;\n    }\n\n    \n\n    .card[_ngcontent-%COMP%] {\n      background: var(--mj-bg-surface);\n      border-radius: 12px;\n      box-shadow: var(--mj-shadow-sm);\n      overflow: hidden;\n    }\n\n    .section-header[_ngcontent-%COMP%] {\n      display: flex;\n      align-items: center;\n      gap: 8px;\n      padding: 16px 20px;\n      border-bottom: 1px solid var(--mj-border-default);\n    }\n\n    .section-header[_ngcontent-%COMP%]   h3[_ngcontent-%COMP%] {\n      margin: 0;\n      font-size: 14px;\n      font-weight: 600;\n      color: var(--mj-text-secondary);\n      display: flex;\n      align-items: center;\n      gap: 8px;\n    }\n\n    .section-header[_ngcontent-%COMP%]   h3[_ngcontent-%COMP%]   i[_ngcontent-%COMP%] { color: var(--mj-brand-primary); font-size: 13px; }\n\n    \n\n    .live-activity-card[_ngcontent-%COMP%] {\n      background: var(--mj-bg-surface);\n      border-radius: 12px;\n      box-shadow: var(--mj-shadow-sm);\n      margin-bottom: 24px;\n      overflow: hidden;\n    }\n\n    .live-dot[_ngcontent-%COMP%] {\n      width: 10px;\n      height: 10px;\n      background: var(--mj-status-success);\n      border-radius: 50%;\n      display: inline-block;\n      animation: _ngcontent-%COMP%_pulse-dot 1.5s ease-in-out infinite;\n    }\n\n    @keyframes _ngcontent-%COMP%_pulse-dot {\n      0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--mj-status-success) 50%, transparent); }\n      50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--mj-status-success) 0%, transparent); }\n    }\n\n    .live-idle-icon[_ngcontent-%COMP%] { color: var(--mj-text-disabled); font-size: 14px; }\n\n    .running-tests-list[_ngcontent-%COMP%] {\n      padding: 0 20px 16px;\n      display: flex;\n      flex-direction: column;\n      gap: 10px;\n    }\n\n    .running-test-item[_ngcontent-%COMP%] {\n      display: flex;\n      justify-content: space-between;\n      align-items: center;\n      padding: 10px 14px;\n      background: color-mix(in srgb, var(--mj-status-success) 10%, var(--mj-bg-surface));\n      border-radius: 8px;\n      border: 1px solid color-mix(in srgb, var(--mj-status-success) 25%, var(--mj-bg-surface));\n      cursor: pointer;\n      transition: background 0.2s;\n    }\n\n    .running-test-item[_ngcontent-%COMP%]:hover {\n      background: color-mix(in srgb, var(--mj-status-success) 16%, var(--mj-bg-surface));\n    }\n\n    .running-test-info[_ngcontent-%COMP%] {\n      display: flex;\n      flex-direction: column;\n      gap: 2px;\n    }\n\n    .running-test-name[_ngcontent-%COMP%] {\n      font-size: 13px;\n      font-weight: 500;\n      color: var(--mj-status-success);\n    }\n\n    .running-test-step[_ngcontent-%COMP%] {\n      font-size: 11px;\n      color: var(--mj-text-muted);\n    }\n\n    .running-test-meta[_ngcontent-%COMP%] {\n      display: flex;\n      align-items: center;\n      gap: 10px;\n    }\n\n    .running-elapsed[_ngcontent-%COMP%] {\n      font-size: 12px;\n      color: var(--mj-status-success);\n      font-weight: 500;\n    }\n\n    .running-progress-bar[_ngcontent-%COMP%] {\n      width: 80px;\n      height: 4px;\n      background: color-mix(in srgb, var(--mj-status-success) 15%, var(--mj-bg-surface));\n      border-radius: 2px;\n      overflow: hidden;\n    }\n\n    .running-progress-fill[_ngcontent-%COMP%] {\n      display: block;\n      height: 100%;\n      background: var(--mj-status-success);\n      border-radius: 2px;\n      transition: width 0.5s ease;\n    }\n\n    .running-progress-pct[_ngcontent-%COMP%] {\n      font-size: 11px;\n      font-weight: 600;\n      color: var(--mj-status-success);\n      min-width: 30px;\n      text-align: right;\n    }\n\n    \n\n    .lower-grid[_ngcontent-%COMP%] {\n      display: grid;\n      grid-template-columns: 1fr 1fr;\n      gap: 24px;\n    }\n\n    .right-column[_ngcontent-%COMP%] {\n      display: flex;\n      flex-direction: column;\n      gap: 24px;\n    }\n\n    \n\n    .runs-list[_ngcontent-%COMP%] {\n      max-height: 520px;\n      overflow-y: auto;\n    }\n\n    .run-row[_ngcontent-%COMP%] {\n      display: flex;\n      justify-content: space-between;\n      align-items: center;\n      padding: 10px 20px;\n      border-bottom: 1px solid var(--mj-bg-surface-card);\n      cursor: pointer;\n      transition: background 0.15s ease;\n    }\n\n    .run-row[_ngcontent-%COMP%]:hover { background: var(--mj-bg-surface-card); }\n\n    .run-row-left[_ngcontent-%COMP%] {\n      display: flex;\n      flex-direction: column;\n      gap: 2px;\n      flex: 1;\n      min-width: 0;\n    }\n\n    .run-row-name[_ngcontent-%COMP%] {\n      font-size: 13px;\n      font-weight: 500;\n      color: var(--mj-text-primary);\n      white-space: nowrap;\n      overflow: hidden;\n      text-overflow: ellipsis;\n    }\n\n    .run-row-time[_ngcontent-%COMP%] {\n      font-size: 11px;\n      color: var(--mj-text-disabled);\n    }\n\n    .run-row-right[_ngcontent-%COMP%] {\n      display: flex;\n      align-items: center;\n      gap: 12px;\n      flex-shrink: 0;\n    }\n\n    .run-row-duration[_ngcontent-%COMP%] {\n      font-size: 11px;\n      color: var(--mj-text-muted);\n      min-width: 44px;\n      text-align: right;\n    }\n\n    \n\n    .suite-health-list[_ngcontent-%COMP%] {\n      padding: 8px 0;\n      max-height: 260px;\n      overflow-y: auto;\n    }\n\n    .suite-health-row[_ngcontent-%COMP%] {\n      display: flex;\n      align-items: center;\n      justify-content: space-between;\n      padding: 8px 20px;\n    }\n\n    .suite-health-info[_ngcontent-%COMP%] {\n      display: flex;\n      flex-direction: column;\n      gap: 2px;\n      flex: 1;\n      min-width: 0;\n    }\n\n    .suite-health-name[_ngcontent-%COMP%] {\n      font-size: 13px;\n      font-weight: 500;\n      color: var(--mj-text-primary);\n      white-space: nowrap;\n      overflow: hidden;\n      text-overflow: ellipsis;\n    }\n\n    .suite-health-count[_ngcontent-%COMP%] {\n      font-size: 11px;\n      color: var(--mj-text-disabled);\n    }\n\n    .suite-health-bar-wrapper[_ngcontent-%COMP%] {\n      display: flex;\n      align-items: center;\n      gap: 8px;\n      flex-shrink: 0;\n    }\n\n    .suite-health-bar[_ngcontent-%COMP%] {\n      width: 80px;\n      height: 6px;\n      background: var(--mj-bg-surface-sunken);\n      border-radius: 3px;\n      overflow: hidden;\n    }\n\n    .suite-health-bar-fill[_ngcontent-%COMP%] {\n      height: 100%;\n      border-radius: 3px;\n      transition: width 0.3s ease;\n    }\n\n    .suite-health-pct[_ngcontent-%COMP%] {\n      font-size: 12px;\n      font-weight: 600;\n      min-width: 36px;\n      text-align: right;\n    }\n\n    \n\n    .alerts-list[_ngcontent-%COMP%] {\n      max-height: 220px;\n      overflow-y: auto;\n    }\n\n    .alert-row[_ngcontent-%COMP%] {\n      display: flex;\n      align-items: center;\n      gap: 10px;\n      padding: 10px 20px;\n      border-bottom: 1px solid var(--mj-bg-surface-card);\n      cursor: pointer;\n      transition: background 0.15s ease;\n    }\n\n    .alert-row[_ngcontent-%COMP%]:hover { background: color-mix(in srgb, var(--mj-status-error) 8%, var(--mj-bg-surface)); }\n\n    .alert-info[_ngcontent-%COMP%] {\n      display: flex;\n      flex-direction: column;\n      gap: 2px;\n      flex: 1;\n      min-width: 0;\n    }\n\n    .alert-name[_ngcontent-%COMP%] {\n      font-size: 13px;\n      font-weight: 500;\n      color: var(--mj-text-primary);\n      white-space: nowrap;\n      overflow: hidden;\n      text-overflow: ellipsis;\n    }\n\n    .alert-reason[_ngcontent-%COMP%] {\n      font-size: 11px;\n      color: var(--mj-text-disabled);\n    }\n\n    \n\n    .empty-state[_ngcontent-%COMP%] {\n      padding: 32px 20px;\n      text-align: center;\n      color: var(--mj-text-disabled);\n      font-size: 13px;\n      display: flex;\n      align-items: center;\n      justify-content: center;\n    }\n\n    \n\n    @media (max-width: 900px) {\n      .lower-grid[_ngcontent-%COMP%] {\n        grid-template-columns: 1fr;\n      }\n    }\n\n    @media (max-width: 640px) {\n      .dashboard-container[_ngcontent-%COMP%] { padding: 16px; }\n      .kpi-row[_ngcontent-%COMP%] { grid-template-columns: 1fr; }\n    }"], changeDetection: 0 });
}
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(TestingDashboardTabComponent, [{
        type: Component,
        args: [{ standalone: false, selector: 'app-testing-dashboard-tab', changeDetection: ChangeDetectionStrategy.OnPush, template: `
    <!-- Full-page loading state -->
    @if (IsLoading) {
      <div class="full-page-loading">
        <mj-loading text="Loading Testing Dashboard..."></mj-loading>
      </div>
    } @else {
      <div class="dashboard-container">

        <!-- Page Header -->
        <div class="page-header">
          <h2 class="page-title">
            <i class="fa-solid fa-gauge-high"></i>
            Testing Dashboard
          </h2>
          <button class="refresh-btn" (click)="OnRefresh()" [disabled]="IsLoading">
            <i class="fa-solid fa-refresh" [class.spinning]="IsLoading"></i>
            Refresh
          </button>
        </div>

        <!-- KPI Row -->
        <div class="kpi-row">
          @for (kpi of KpiCards; track kpi.title) {
            <app-kpi-card [data]="kpi"></app-kpi-card>
          }
        </div>

        <!-- Live Activity Section -->
        <div class="live-activity-card">
          <div class="section-header">
            @if (RunningTests.length > 0) {
              <span class="live-dot"></span>
              <h3>{{ RunningTests.length }} test{{ RunningTests.length === 1 ? '' : 's' }} running</h3>
            } @else {
              <i class="fa-solid fa-circle-pause live-idle-icon"></i>
              <h3>No tests currently running</h3>
            }
          </div>
          @if (RunningTests.length > 0) {
            <div class="running-tests-list">
              @for (run of RunningTests; track run.id) {
                <div class="running-test-item" (click)="OnViewRunningTest(run)">
                  <div class="running-test-info">
                    <div class="running-test-name">{{ run.testName }}</div>
                    <div class="running-test-step">{{ GetActiveRunStep(run.testId) }}</div>
                  </div>
                  <div class="running-test-meta">
                    <span class="running-elapsed">{{ FormatDuration(run.duration) }}</span>
                    <span class="running-progress-bar">
                      <span class="running-progress-fill" [style.width.%]="GetActiveRunProgress(run.testId)"></span>
                    </span>
                    <span class="running-progress-pct">{{ GetActiveRunProgress(run.testId) }}%</span>
                  </div>
                </div>
              }
            </div>
          }
        </div>

        <!-- Lower Content: 2-column layout -->
        <div class="lower-grid">

          <!-- Left Column: Recent Runs -->
          <div class="card recent-runs-card">
            <div class="section-header">
              <h3><i class="fa-solid fa-history"></i> Recent Runs</h3>
            </div>
            <div class="runs-list">
              @for (run of RecentRuns; track run.id) {
                <div class="run-row" (click)="OnOpenRun(run)">
                  <div class="run-row-left">
                    <span class="run-row-name">{{ run.testName }}</span>
                    <span class="run-row-time">{{ FormatTimestamp(run.runDateTime) }}</span>
                  </div>
                  <div class="run-row-right">
                    <app-test-status-badge [status]="run.status"></app-test-status-badge>
                    <app-score-indicator [score]="run.score" [showBar]="true"></app-score-indicator>
                    <span class="run-row-duration">{{ FormatDuration(run.duration) }}</span>
                    <app-cost-display [cost]="run.cost"></app-cost-display>
                  </div>
                </div>
              } @empty {
                <div class="empty-state">No completed test runs found</div>
              }
            </div>
          </div>

          <!-- Right Column: Suite Health + Alerts -->
          <div class="right-column">

            <!-- Suite Health -->
            <div class="card suite-health-card">
              <div class="section-header">
                <h3><i class="fa-solid fa-heartbeat"></i> Suite Health</h3>
              </div>
              <div class="suite-health-list">
                @for (suite of SortedSuites; track suite.id) {
                  <div class="suite-health-row">
                    <div class="suite-health-info">
                      <span class="suite-health-name">{{ suite.name }}</span>
                      <span class="suite-health-count">{{ suite.testCount }} tests</span>
                    </div>
                    <div class="suite-health-bar-wrapper">
                      <div class="suite-health-bar">
                        <div
                          class="suite-health-bar-fill"
                          [style.width.%]="suite.passRate"
                          [style.background]="GetPassRateColor(suite.passRate)">
                        </div>
                      </div>
                      <span class="suite-health-pct" [style.color]="GetPassRateColor(suite.passRate)">
                        {{ suite.passRate | number:'1.0-0' }}%
                      </span>
                    </div>
                  </div>
                } @empty {
                  <div class="empty-state">No test suites found</div>
                }
              </div>
            </div>

            <!-- Alerts -->
            <div class="card alerts-card">
              <div class="section-header">
                <h3><i class="fa-solid fa-triangle-exclamation"></i> Alerts</h3>
              </div>
              <div class="alerts-list">
                @for (alert of Alerts; track alert.id) {
                  <div class="alert-row" (click)="OnOpenAlert(alert)">
                    <i class="fa-solid"
                       [class.fa-arrow-trend-down]="alert.reason === 'regression'"
                       [class.fa-circle-exclamation]="alert.reason === 'low-score'"
                       [style.color]="alert.reason === 'regression' ? '#ef4444' : '#f59e0b'">
                    </i>
                    <div class="alert-info">
                      <span class="alert-name">{{ alert.testName }}</span>
                      <span class="alert-reason">
                        @if (alert.reason === 'regression') {
                          Regression detected
                        } @else {
                          Score below 0.5 ({{ alert.score | number:'1.2-2' }})
                        }
                      </span>
                    </div>
                    <app-test-status-badge [status]="alert.status"></app-test-status-badge>
                  </div>
                } @empty {
                  <div class="empty-state">
                    <i class="fa-solid fa-check-circle" style="color: var(--mj-status-success); margin-right: 6px;"></i>
                    No alerts - all tests healthy
                  </div>
                }
              </div>
            </div>

          </div>
        </div>
      </div>
    }
  `, styles: ["\n    /* ===== Layout ===== */\n    .full-page-loading {\n      display: flex;\n      justify-content: center;\n      align-items: center;\n      height: 100%;\n      min-height: 400px;\n      background: var(--mj-bg-surface-card);\n    }\n\n    .dashboard-container {\n      padding: 24px;\n      height: 100%;\n      overflow-y: auto;\n      background: var(--mj-bg-surface-card);\n    }\n\n    /* ===== Page Header ===== */\n    .page-header {\n      display: flex;\n      justify-content: space-between;\n      align-items: center;\n      margin-bottom: 24px;\n    }\n\n    .page-title {\n      margin: 0;\n      font-size: 22px;\n      font-weight: 700;\n      color: var(--mj-text-primary);\n      display: flex;\n      align-items: center;\n      gap: 10px;\n    }\n\n    .page-title i { color: var(--mj-brand-primary); }\n\n    .refresh-btn {\n      background: var(--mj-brand-primary);\n      color: var(--mj-text-inverse);\n      border: none;\n      padding: 8px 18px;\n      border-radius: 8px;\n      cursor: pointer;\n      display: flex;\n      align-items: center;\n      gap: 6px;\n      font-size: 13px;\n      font-weight: 500;\n      transition: background 0.2s ease;\n    }\n\n    .refresh-btn:hover:not(:disabled) { background: var(--mj-brand-primary-hover); }\n    .refresh-btn:disabled { opacity: 0.6; cursor: not-allowed; }\n    .refresh-btn i.spinning { animation: spin 1s linear infinite; }\n\n    @keyframes spin {\n      from { transform: rotate(0deg); }\n      to { transform: rotate(360deg); }\n    }\n\n    /* ===== KPI Row ===== */\n    .kpi-row {\n      display: grid;\n      grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));\n      gap: 16px;\n      margin-bottom: 24px;\n    }\n\n    /* ===== Card Base ===== */\n    .card {\n      background: var(--mj-bg-surface);\n      border-radius: 12px;\n      box-shadow: var(--mj-shadow-sm);\n      overflow: hidden;\n    }\n\n    .section-header {\n      display: flex;\n      align-items: center;\n      gap: 8px;\n      padding: 16px 20px;\n      border-bottom: 1px solid var(--mj-border-default);\n    }\n\n    .section-header h3 {\n      margin: 0;\n      font-size: 14px;\n      font-weight: 600;\n      color: var(--mj-text-secondary);\n      display: flex;\n      align-items: center;\n      gap: 8px;\n    }\n\n    .section-header h3 i { color: var(--mj-brand-primary); font-size: 13px; }\n\n    /* ===== Live Activity ===== */\n    .live-activity-card {\n      background: var(--mj-bg-surface);\n      border-radius: 12px;\n      box-shadow: var(--mj-shadow-sm);\n      margin-bottom: 24px;\n      overflow: hidden;\n    }\n\n    .live-dot {\n      width: 10px;\n      height: 10px;\n      background: var(--mj-status-success);\n      border-radius: 50%;\n      display: inline-block;\n      animation: pulse-dot 1.5s ease-in-out infinite;\n    }\n\n    @keyframes pulse-dot {\n      0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--mj-status-success) 50%, transparent); }\n      50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--mj-status-success) 0%, transparent); }\n    }\n\n    .live-idle-icon { color: var(--mj-text-disabled); font-size: 14px; }\n\n    .running-tests-list {\n      padding: 0 20px 16px;\n      display: flex;\n      flex-direction: column;\n      gap: 10px;\n    }\n\n    .running-test-item {\n      display: flex;\n      justify-content: space-between;\n      align-items: center;\n      padding: 10px 14px;\n      background: color-mix(in srgb, var(--mj-status-success) 10%, var(--mj-bg-surface));\n      border-radius: 8px;\n      border: 1px solid color-mix(in srgb, var(--mj-status-success) 25%, var(--mj-bg-surface));\n      cursor: pointer;\n      transition: background 0.2s;\n    }\n\n    .running-test-item:hover {\n      background: color-mix(in srgb, var(--mj-status-success) 16%, var(--mj-bg-surface));\n    }\n\n    .running-test-info {\n      display: flex;\n      flex-direction: column;\n      gap: 2px;\n    }\n\n    .running-test-name {\n      font-size: 13px;\n      font-weight: 500;\n      color: var(--mj-status-success);\n    }\n\n    .running-test-step {\n      font-size: 11px;\n      color: var(--mj-text-muted);\n    }\n\n    .running-test-meta {\n      display: flex;\n      align-items: center;\n      gap: 10px;\n    }\n\n    .running-elapsed {\n      font-size: 12px;\n      color: var(--mj-status-success);\n      font-weight: 500;\n    }\n\n    .running-progress-bar {\n      width: 80px;\n      height: 4px;\n      background: color-mix(in srgb, var(--mj-status-success) 15%, var(--mj-bg-surface));\n      border-radius: 2px;\n      overflow: hidden;\n    }\n\n    .running-progress-fill {\n      display: block;\n      height: 100%;\n      background: var(--mj-status-success);\n      border-radius: 2px;\n      transition: width 0.5s ease;\n    }\n\n    .running-progress-pct {\n      font-size: 11px;\n      font-weight: 600;\n      color: var(--mj-status-success);\n      min-width: 30px;\n      text-align: right;\n    }\n\n    /* ===== Lower Grid ===== */\n    .lower-grid {\n      display: grid;\n      grid-template-columns: 1fr 1fr;\n      gap: 24px;\n    }\n\n    .right-column {\n      display: flex;\n      flex-direction: column;\n      gap: 24px;\n    }\n\n    /* ===== Recent Runs ===== */\n    .runs-list {\n      max-height: 520px;\n      overflow-y: auto;\n    }\n\n    .run-row {\n      display: flex;\n      justify-content: space-between;\n      align-items: center;\n      padding: 10px 20px;\n      border-bottom: 1px solid var(--mj-bg-surface-card);\n      cursor: pointer;\n      transition: background 0.15s ease;\n    }\n\n    .run-row:hover { background: var(--mj-bg-surface-card); }\n\n    .run-row-left {\n      display: flex;\n      flex-direction: column;\n      gap: 2px;\n      flex: 1;\n      min-width: 0;\n    }\n\n    .run-row-name {\n      font-size: 13px;\n      font-weight: 500;\n      color: var(--mj-text-primary);\n      white-space: nowrap;\n      overflow: hidden;\n      text-overflow: ellipsis;\n    }\n\n    .run-row-time {\n      font-size: 11px;\n      color: var(--mj-text-disabled);\n    }\n\n    .run-row-right {\n      display: flex;\n      align-items: center;\n      gap: 12px;\n      flex-shrink: 0;\n    }\n\n    .run-row-duration {\n      font-size: 11px;\n      color: var(--mj-text-muted);\n      min-width: 44px;\n      text-align: right;\n    }\n\n    /* ===== Suite Health ===== */\n    .suite-health-list {\n      padding: 8px 0;\n      max-height: 260px;\n      overflow-y: auto;\n    }\n\n    .suite-health-row {\n      display: flex;\n      align-items: center;\n      justify-content: space-between;\n      padding: 8px 20px;\n    }\n\n    .suite-health-info {\n      display: flex;\n      flex-direction: column;\n      gap: 2px;\n      flex: 1;\n      min-width: 0;\n    }\n\n    .suite-health-name {\n      font-size: 13px;\n      font-weight: 500;\n      color: var(--mj-text-primary);\n      white-space: nowrap;\n      overflow: hidden;\n      text-overflow: ellipsis;\n    }\n\n    .suite-health-count {\n      font-size: 11px;\n      color: var(--mj-text-disabled);\n    }\n\n    .suite-health-bar-wrapper {\n      display: flex;\n      align-items: center;\n      gap: 8px;\n      flex-shrink: 0;\n    }\n\n    .suite-health-bar {\n      width: 80px;\n      height: 6px;\n      background: var(--mj-bg-surface-sunken);\n      border-radius: 3px;\n      overflow: hidden;\n    }\n\n    .suite-health-bar-fill {\n      height: 100%;\n      border-radius: 3px;\n      transition: width 0.3s ease;\n    }\n\n    .suite-health-pct {\n      font-size: 12px;\n      font-weight: 600;\n      min-width: 36px;\n      text-align: right;\n    }\n\n    /* ===== Alerts ===== */\n    .alerts-list {\n      max-height: 220px;\n      overflow-y: auto;\n    }\n\n    .alert-row {\n      display: flex;\n      align-items: center;\n      gap: 10px;\n      padding: 10px 20px;\n      border-bottom: 1px solid var(--mj-bg-surface-card);\n      cursor: pointer;\n      transition: background 0.15s ease;\n    }\n\n    .alert-row:hover { background: color-mix(in srgb, var(--mj-status-error) 8%, var(--mj-bg-surface)); }\n\n    .alert-info {\n      display: flex;\n      flex-direction: column;\n      gap: 2px;\n      flex: 1;\n      min-width: 0;\n    }\n\n    .alert-name {\n      font-size: 13px;\n      font-weight: 500;\n      color: var(--mj-text-primary);\n      white-space: nowrap;\n      overflow: hidden;\n      text-overflow: ellipsis;\n    }\n\n    .alert-reason {\n      font-size: 11px;\n      color: var(--mj-text-disabled);\n    }\n\n    /* ===== Empty State ===== */\n    .empty-state {\n      padding: 32px 20px;\n      text-align: center;\n      color: var(--mj-text-disabled);\n      font-size: 13px;\n      display: flex;\n      align-items: center;\n      justify-content: center;\n    }\n\n    /* ===== Responsive ===== */\n    @media (max-width: 900px) {\n      .lower-grid {\n        grid-template-columns: 1fr;\n      }\n    }\n\n    @media (max-width: 640px) {\n      .dashboard-container { padding: 16px; }\n      .kpi-row { grid-template-columns: 1fr; }\n    }\n  "] }]
    }], () => [{ type: i1.TestingInstrumentationService }, { type: i2.TestingExecutionService }, { type: i2.TestingDialogService }, { type: i0.ChangeDetectorRef }], { initialState: [{
            type: Input
        }], stateChange: [{
            type: Output
        }] }); })();
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(TestingDashboardTabComponent, { className: "TestingDashboardTabComponent", filePath: "src/Testing/components/testing-dashboard-tab.component.ts", lineNumber: 591 }); })();
//# sourceMappingURL=testing-dashboard-tab.component.js.map