var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var VersionHistoryGraphResourceComponent_1;
import { Component, ChangeDetectionStrategy } from '@angular/core';
import { Subject } from 'rxjs';
import { RegisterClass, UUIDsEqual } from '@memberjunction/global';
import { BaseResourceComponent } from '@memberjunction/ng-shared';
import { Metadata } from '@memberjunction/core';
import { UserInfoEngine } from '@memberjunction/core-entities';
import * as i0 from "@angular/core";
import * as i1 from "@angular/common";
import * as i2 from "@angular/forms";
import * as i3 from "@memberjunction/ng-shared-generic";
function VersionHistoryGraphResourceComponent_Conditional_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "mj-loading", 1);
} }
function VersionHistoryGraphResourceComponent_Conditional_2_Conditional_30_For_2_Template(rf, ctx) { if (rf & 1) {
    const _r3 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "button", 28);
    i0.ɵɵlistener("click", function VersionHistoryGraphResourceComponent_Conditional_2_Conditional_30_For_2_Template_button_click_0_listener() { const schema_r4 = i0.ɵɵrestoreView(_r3).$implicit; const ctx_r1 = i0.ɵɵnextContext(3); return i0.ɵɵresetView(ctx_r1.OnSchemaFilterChange(schema_r4)); });
    i0.ɵɵtext(1);
    i0.ɵɵelementStart(2, "span", 29);
    i0.ɵɵtext(3);
    i0.ɵɵelementEnd()();
} if (rf & 2) {
    const schema_r4 = ctx.$implicit;
    const ctx_r1 = i0.ɵɵnextContext(3);
    i0.ɵɵclassProp("active", ctx_r1.SchemaFilter === schema_r4);
    i0.ɵɵadvance();
    i0.ɵɵtextInterpolate1(" ", schema_r4, " ");
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate(ctx_r1.GetSchemaEntityCount(schema_r4));
} }
function VersionHistoryGraphResourceComponent_Conditional_2_Conditional_30_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 21);
    i0.ɵɵrepeaterCreate(1, VersionHistoryGraphResourceComponent_Conditional_2_Conditional_30_For_2_Template, 4, 4, "button", 27, i0.ɵɵrepeaterTrackByIdentity);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance();
    i0.ɵɵrepeater(ctx_r1.AvailableSchemas);
} }
function VersionHistoryGraphResourceComponent_Conditional_2_For_33_Conditional_4_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "span", 33);
    i0.ɵɵtext(1);
    i0.ɵɵelement(2, "i", 35);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const entity_r6 = i0.ɵɵnextContext().$implicit;
    const ctx_r1 = i0.ɵɵnextContext(2);
    i0.ɵɵproperty("ngClass", ctx_r1.GetDependencyLevel(entity_r6.ReferencedByCount));
    i0.ɵɵadvance();
    i0.ɵɵtextInterpolate1(" ", entity_r6.ReferencedByCount, " ");
} }
function VersionHistoryGraphResourceComponent_Conditional_2_For_33_Conditional_5_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "span", 34);
    i0.ɵɵtext(1);
    i0.ɵɵelement(2, "i", 36);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const entity_r6 = i0.ɵɵnextContext().$implicit;
    i0.ɵɵadvance();
    i0.ɵɵtextInterpolate1(" ", entity_r6.DependsOnCount, " ");
} }
function VersionHistoryGraphResourceComponent_Conditional_2_For_33_Template(rf, ctx) { if (rf & 1) {
    const _r5 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "div", 30);
    i0.ɵɵlistener("click", function VersionHistoryGraphResourceComponent_Conditional_2_For_33_Template_div_click_0_listener() { const entity_r6 = i0.ɵɵrestoreView(_r5).$implicit; const ctx_r1 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r1.SelectEntity(entity_r6)); });
    i0.ɵɵelementStart(1, "div", 31);
    i0.ɵɵtext(2);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(3, "div", 32);
    i0.ɵɵconditionalCreate(4, VersionHistoryGraphResourceComponent_Conditional_2_For_33_Conditional_4_Template, 3, 2, "span", 33);
    i0.ɵɵconditionalCreate(5, VersionHistoryGraphResourceComponent_Conditional_2_For_33_Conditional_5_Template, 3, 1, "span", 34);
    i0.ɵɵelementEnd()();
} if (rf & 2) {
    const entity_r6 = ctx.$implicit;
    i0.ɵɵclassProp("selected", entity_r6.IsSelected);
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate(entity_r6.Name);
    i0.ɵɵadvance(2);
    i0.ɵɵconditional(entity_r6.ReferencedByCount > 0 ? 4 : -1);
    i0.ɵɵadvance();
    i0.ɵɵconditional(entity_r6.DependsOnCount > 0 ? 5 : -1);
} }
function VersionHistoryGraphResourceComponent_Conditional_2_Conditional_34_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 24)(1, "p");
    i0.ɵɵtext(2, "No entities match your search.");
    i0.ɵɵelementEnd()();
} }
function VersionHistoryGraphResourceComponent_Conditional_2_Conditional_36_Conditional_18_For_2_Template(rf, ctx) { if (rf & 1) {
    const _r7 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "div", 50)(1, "div", 51);
    i0.ɵɵlistener("click", function VersionHistoryGraphResourceComponent_Conditional_2_Conditional_36_Conditional_18_For_2_Template_div_click_1_listener() { const rel_r8 = i0.ɵɵrestoreView(_r7).$implicit; const ctx_r1 = i0.ɵɵnextContext(4); return i0.ɵɵresetView(ctx_r1.NavigateToEntity(rel_r8.ToEntity)); });
    i0.ɵɵelement(2, "i", 52);
    i0.ɵɵelementStart(3, "span", 53);
    i0.ɵɵtext(4);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(5, "span", 54);
    i0.ɵɵelement(6, "i", 55);
    i0.ɵɵtext(7);
    i0.ɵɵelementEnd()()();
} if (rf & 2) {
    const rel_r8 = ctx.$implicit;
    i0.ɵɵadvance(4);
    i0.ɵɵtextInterpolate(rel_r8.ToEntity);
    i0.ɵɵadvance(3);
    i0.ɵɵtextInterpolate1(" ", rel_r8.RelatedEntityJoinField, " ");
} }
function VersionHistoryGraphResourceComponent_Conditional_2_Conditional_36_Conditional_18_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 47);
    i0.ɵɵrepeaterCreate(1, VersionHistoryGraphResourceComponent_Conditional_2_Conditional_36_Conditional_18_For_2_Template, 8, 2, "div", 50, i0.ɵɵrepeaterTrackByIdentity);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext(3);
    i0.ɵɵadvance();
    i0.ɵɵrepeater(ctx_r1.ReferencedByEntities);
} }
function VersionHistoryGraphResourceComponent_Conditional_2_Conditional_36_Conditional_19_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 48)(1, "p");
    i0.ɵɵtext(2, "No entities reference this entity.");
    i0.ɵɵelementEnd()();
} }
function VersionHistoryGraphResourceComponent_Conditional_2_Conditional_36_Conditional_31_For_2_Template(rf, ctx) { if (rf & 1) {
    const _r9 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "div", 50)(1, "div", 51);
    i0.ɵɵlistener("click", function VersionHistoryGraphResourceComponent_Conditional_2_Conditional_36_Conditional_31_For_2_Template_div_click_1_listener() { const rel_r10 = i0.ɵɵrestoreView(_r9).$implicit; const ctx_r1 = i0.ɵɵnextContext(4); return i0.ɵɵresetView(ctx_r1.NavigateToEntity(rel_r10.FromEntity)); });
    i0.ɵɵelement(2, "i", 52);
    i0.ɵɵelementStart(3, "span", 53);
    i0.ɵɵtext(4);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(5, "span", 54);
    i0.ɵɵelement(6, "i", 55);
    i0.ɵɵtext(7);
    i0.ɵɵelementEnd()()();
} if (rf & 2) {
    const rel_r10 = ctx.$implicit;
    i0.ɵɵadvance(4);
    i0.ɵɵtextInterpolate(rel_r10.FromEntity);
    i0.ɵɵadvance(3);
    i0.ɵɵtextInterpolate1(" ", rel_r10.RelatedEntityJoinField, " ");
} }
function VersionHistoryGraphResourceComponent_Conditional_2_Conditional_36_Conditional_31_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 47);
    i0.ɵɵrepeaterCreate(1, VersionHistoryGraphResourceComponent_Conditional_2_Conditional_36_Conditional_31_For_2_Template, 8, 2, "div", 50, i0.ɵɵrepeaterTrackByIdentity);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext(3);
    i0.ɵɵadvance();
    i0.ɵɵrepeater(ctx_r1.DependsOnEntities);
} }
function VersionHistoryGraphResourceComponent_Conditional_2_Conditional_36_Conditional_32_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 48)(1, "p");
    i0.ɵɵtext(2, "This entity has no foreign key dependencies.");
    i0.ɵɵelementEnd()();
} }
function VersionHistoryGraphResourceComponent_Conditional_2_Conditional_36_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 37);
    i0.ɵɵelement(1, "i", 38);
    i0.ɵɵelementStart(2, "div", 39)(3, "h3", 40);
    i0.ɵɵtext(4);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(5, "span", 41);
    i0.ɵɵtext(6);
    i0.ɵɵelementEnd()()();
    i0.ɵɵelementStart(7, "div", 42)(8, "div", 43);
    i0.ɵɵelement(9, "i", 44);
    i0.ɵɵelementStart(10, "h4");
    i0.ɵɵtext(11, "Referenced By");
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(12, "span", 45);
    i0.ɵɵtext(13);
    i0.ɵɵelementEnd()();
    i0.ɵɵelementStart(14, "p", 46);
    i0.ɵɵtext(15, "Entities that have foreign keys pointing to ");
    i0.ɵɵelementStart(16, "strong");
    i0.ɵɵtext(17);
    i0.ɵɵelementEnd()();
    i0.ɵɵconditionalCreate(18, VersionHistoryGraphResourceComponent_Conditional_2_Conditional_36_Conditional_18_Template, 3, 0, "div", 47);
    i0.ɵɵconditionalCreate(19, VersionHistoryGraphResourceComponent_Conditional_2_Conditional_36_Conditional_19_Template, 3, 0, "div", 48);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(20, "div", 42)(21, "div", 43);
    i0.ɵɵelement(22, "i", 49);
    i0.ɵɵelementStart(23, "h4");
    i0.ɵɵtext(24, "Depends On");
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(25, "span", 45);
    i0.ɵɵtext(26);
    i0.ɵɵelementEnd()();
    i0.ɵɵelementStart(27, "p", 46)(28, "strong");
    i0.ɵɵtext(29);
    i0.ɵɵelementEnd();
    i0.ɵɵtext(30, " has foreign keys pointing to these entities");
    i0.ɵɵelementEnd();
    i0.ɵɵconditionalCreate(31, VersionHistoryGraphResourceComponent_Conditional_2_Conditional_36_Conditional_31_Template, 3, 0, "div", 47);
    i0.ɵɵconditionalCreate(32, VersionHistoryGraphResourceComponent_Conditional_2_Conditional_36_Conditional_32_Template, 3, 0, "div", 48);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(4);
    i0.ɵɵtextInterpolate(ctx_r1.SelectedEntity.Name);
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate(ctx_r1.SelectedEntity.SchemaName);
    i0.ɵɵadvance(7);
    i0.ɵɵtextInterpolate(ctx_r1.ReferencedByEntities.length);
    i0.ɵɵadvance(4);
    i0.ɵɵtextInterpolate(ctx_r1.SelectedEntity.Name);
    i0.ɵɵadvance();
    i0.ɵɵconditional(ctx_r1.ReferencedByEntities.length > 0 ? 18 : -1);
    i0.ɵɵadvance();
    i0.ɵɵconditional(ctx_r1.ReferencedByEntities.length === 0 ? 19 : -1);
    i0.ɵɵadvance(7);
    i0.ɵɵtextInterpolate(ctx_r1.DependsOnEntities.length);
    i0.ɵɵadvance(3);
    i0.ɵɵtextInterpolate(ctx_r1.SelectedEntity.Name);
    i0.ɵɵadvance(2);
    i0.ɵɵconditional(ctx_r1.DependsOnEntities.length > 0 ? 31 : -1);
    i0.ɵɵadvance();
    i0.ɵɵconditional(ctx_r1.DependsOnEntities.length === 0 ? 32 : -1);
} }
function VersionHistoryGraphResourceComponent_Conditional_2_Conditional_37_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 26);
    i0.ɵɵelement(1, "i", 56);
    i0.ɵɵelementStart(2, "h3");
    i0.ɵɵtext(3, "Select an Entity");
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(4, "p");
    i0.ɵɵtext(5, "Choose an entity from the list to explore its dependency relationships.");
    i0.ɵɵelementEnd()();
} }
function VersionHistoryGraphResourceComponent_Conditional_2_Template(rf, ctx) { if (rf & 1) {
    const _r1 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "div", 2)(1, "div", 3)(2, "h2", 4);
    i0.ɵɵtext(3, "Entity Dependency Graph");
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(4, "p", 5);
    i0.ɵɵtext(5, "Explore entity relationships used by the version history system");
    i0.ɵɵelementEnd()();
    i0.ɵɵelementStart(6, "div", 6)(7, "button", 7);
    i0.ɵɵlistener("click", function VersionHistoryGraphResourceComponent_Conditional_2_Template_button_click_7_listener() { i0.ɵɵrestoreView(_r1); const ctx_r1 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r1.Refresh()); });
    i0.ɵɵelement(8, "i", 8);
    i0.ɵɵelementEnd()()();
    i0.ɵɵelementStart(9, "div", 9)(10, "div", 10);
    i0.ɵɵelement(11, "i", 11);
    i0.ɵɵelementStart(12, "span");
    i0.ɵɵtext(13);
    i0.ɵɵelementEnd()();
    i0.ɵɵelementStart(14, "div", 10);
    i0.ɵɵelement(15, "i", 12);
    i0.ɵɵelementStart(16, "span");
    i0.ɵɵtext(17);
    i0.ɵɵelementEnd()();
    i0.ɵɵelementStart(18, "div", 10);
    i0.ɵɵelement(19, "i", 13);
    i0.ɵɵelementStart(20, "span");
    i0.ɵɵtext(21);
    i0.ɵɵelementEnd()()();
    i0.ɵɵelementStart(22, "div", 14)(23, "div", 15)(24, "div", 16)(25, "h3", 17);
    i0.ɵɵtext(26, "Entities");
    i0.ɵɵelementEnd()();
    i0.ɵɵelementStart(27, "div", 18);
    i0.ɵɵelement(28, "i", 19);
    i0.ɵɵelementStart(29, "input", 20);
    i0.ɵɵlistener("ngModelChange", function VersionHistoryGraphResourceComponent_Conditional_2_Template_input_ngModelChange_29_listener($event) { i0.ɵɵrestoreView(_r1); const ctx_r1 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r1.OnSearchChange($event)); });
    i0.ɵɵelementEnd()();
    i0.ɵɵconditionalCreate(30, VersionHistoryGraphResourceComponent_Conditional_2_Conditional_30_Template, 3, 0, "div", 21);
    i0.ɵɵelementStart(31, "div", 22);
    i0.ɵɵrepeaterCreate(32, VersionHistoryGraphResourceComponent_Conditional_2_For_33_Template, 6, 5, "div", 23, i0.ɵɵrepeaterTrackByIdentity);
    i0.ɵɵconditionalCreate(34, VersionHistoryGraphResourceComponent_Conditional_2_Conditional_34_Template, 3, 0, "div", 24);
    i0.ɵɵelementEnd()();
    i0.ɵɵelementStart(35, "div", 25);
    i0.ɵɵconditionalCreate(36, VersionHistoryGraphResourceComponent_Conditional_2_Conditional_36_Template, 33, 10)(37, VersionHistoryGraphResourceComponent_Conditional_2_Conditional_37_Template, 6, 0, "div", 26);
    i0.ɵɵelementEnd()();
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext();
    i0.ɵɵadvance(13);
    i0.ɵɵtextInterpolate1("", ctx_r1.TotalEntities, " Entities");
    i0.ɵɵadvance(4);
    i0.ɵɵtextInterpolate1("", ctx_r1.EntitiesWithDependents, " with Dependents");
    i0.ɵɵadvance(4);
    i0.ɵɵtextInterpolate1("", ctx_r1.TotalRelationships, " Relationships");
    i0.ɵɵadvance(8);
    i0.ɵɵproperty("ngModel", ctx_r1.SearchText);
    i0.ɵɵadvance();
    i0.ɵɵconditional(ctx_r1.AvailableSchemas.length > 1 ? 30 : -1);
    i0.ɵɵadvance(2);
    i0.ɵɵrepeater(ctx_r1.FilteredEntities);
    i0.ɵɵadvance(2);
    i0.ɵɵconditional(ctx_r1.FilteredEntities.length === 0 ? 34 : -1);
    i0.ɵɵadvance(2);
    i0.ɵɵconditional(ctx_r1.SelectedEntity ? 36 : 37);
} }
let VersionHistoryGraphResourceComponent = class VersionHistoryGraphResourceComponent extends BaseResourceComponent {
    static { VersionHistoryGraphResourceComponent_1 = this; }
    cdr;
    IsLoading = true;
    // Entity browser
    AllEntities = [];
    FilteredEntities = [];
    SearchText = '';
    SchemaFilter = '';
    AvailableSchemas = [];
    // Selected entity detail
    SelectedEntity = null;
    SelectedEntityInfo = null;
    ReferencedByEntities = [];
    DependsOnEntities = [];
    // Stats
    TotalEntities = 0;
    EntitiesWithDependents = 0;
    TotalRelationships = 0;
    static PREFS_KEY = 'VersionHistory.Graph.UserPreferences';
    preferencesLoaded = false;
    metadata = new Metadata();
    destroy$ = new Subject();
    constructor(cdr) {
        super();
        this.cdr = cdr;
    }
    ngOnInit() {
        this.loadUserPreferences();
        this.LoadData();
    }
    ngOnDestroy() {
        this.destroy$.next();
        this.destroy$.complete();
    }
    async GetResourceDisplayName(data) {
        return 'Dependency Graph';
    }
    async GetResourceIconClass(data) {
        return 'fa-solid fa-diagram-project';
    }
    LoadData() {
        try {
            this.IsLoading = true;
            this.cdr.markForCheck();
            const entities = this.metadata.Entities;
            this.AllEntities = entities.map(e => ({
                Name: e.Name,
                ID: e.ID,
                SchemaName: e.SchemaName,
                ReferencedByCount: this.countReferencedBy(e),
                DependsOnCount: this.countDependsOn(e),
                IsSelected: false
            })).sort((a, b) => a.Name.localeCompare(b.Name));
            // Extract unique schemas, sorted
            const schemaSet = new Set(this.AllEntities.map(e => e.SchemaName));
            this.AvailableSchemas = Array.from(schemaSet).sort();
            this.TotalEntities = this.AllEntities.length;
            this.EntitiesWithDependents = this.AllEntities.filter(e => e.ReferencedByCount > 0).length;
            this.TotalRelationships = this.AllEntities.reduce((sum, e) => sum + e.ReferencedByCount, 0);
            this.applyFilter();
        }
        catch (error) {
            console.error('Error loading dependency graph data:', error);
        }
        finally {
            this.IsLoading = false;
            this.NotifyLoadComplete();
            this.cdr.markForCheck();
        }
    }
    /** Count entities that reference this entity (have FKs pointing to it), excluding self-references */
    countReferencedBy(entity) {
        return entity.RelatedEntities.filter(r => r.Type.trim().toUpperCase() === 'ONE TO MANY' &&
            r.RelatedEntity !== entity.Name).length;
    }
    /** Count entities this entity depends on (has FKs pointing to), excluding self-references */
    countDependsOn(entity) {
        return this.metadata.Entities.filter(e => e.Name !== entity.Name &&
            e.RelatedEntities.some(r => r.Type.trim().toUpperCase() === 'ONE TO MANY' &&
                r.RelatedEntity === entity.Name)).length;
    }
    OnSearchChange(text) {
        this.SearchText = text;
        this.applyFilter();
    }
    OnSchemaFilterChange(schema) {
        this.SchemaFilter = this.SchemaFilter === schema ? '' : schema;
        this.applyFilter();
        this.persistPreferences();
    }
    loadUserPreferences() {
        try {
            const raw = UserInfoEngine.Instance.GetSetting(VersionHistoryGraphResourceComponent_1.PREFS_KEY);
            if (raw) {
                const prefs = JSON.parse(raw);
                if (prefs.SchemaFilter != null) {
                    this.SchemaFilter = prefs.SchemaFilter;
                }
            }
        }
        catch (error) {
            console.error('Error loading graph preferences:', error);
            this.SchemaFilter = '';
        }
        this.preferencesLoaded = true;
    }
    persistPreferences() {
        if (!this.preferencesLoaded)
            return;
        const prefs = {
            SchemaFilter: this.SchemaFilter
        };
        UserInfoEngine.Instance.SetSettingDebounced(VersionHistoryGraphResourceComponent_1.PREFS_KEY, JSON.stringify(prefs));
    }
    applyFilter() {
        let result = this.AllEntities;
        if (this.SchemaFilter) {
            result = result.filter(e => e.SchemaName === this.SchemaFilter);
        }
        if (this.SearchText) {
            const search = this.SearchText.toLowerCase();
            result = result.filter(e => e.Name.toLowerCase().includes(search));
        }
        this.FilteredEntities = result;
        this.cdr.markForCheck();
    }
    SelectEntity(entityNode) {
        if (this.SelectedEntity) {
            this.SelectedEntity.IsSelected = false;
        }
        entityNode.IsSelected = true;
        this.SelectedEntity = entityNode;
        const entityInfo = this.metadata.Entities.find(e => UUIDsEqual(e.ID, entityNode.ID));
        this.SelectedEntityInfo = entityInfo ?? null;
        if (entityInfo) {
            this.ReferencedByEntities = this.buildReferencedByList(entityInfo);
            this.DependsOnEntities = this.buildDependsOnList(entityInfo);
        }
        else {
            this.ReferencedByEntities = [];
            this.DependsOnEntities = [];
        }
        this.cdr.markForCheck();
    }
    /** Entities that have FKs pointing TO the selected entity (it is the "one" side) */
    buildReferencedByList(entityInfo) {
        return entityInfo.RelatedEntities
            .filter(r => r.Type.trim().toUpperCase() === 'ONE TO MANY' &&
            r.RelatedEntity !== entityInfo.Name)
            .map(r => ({
            FromEntity: entityInfo.Name,
            ToEntity: r.RelatedEntity,
            RelatedEntityJoinField: r.RelatedEntityJoinField,
            Type: r.Type
        }))
            .sort((a, b) => a.ToEntity.localeCompare(b.ToEntity));
    }
    /** Entities the selected entity has FKs pointing to (it is the "many" side) */
    buildDependsOnList(entityInfo) {
        return this.metadata.Entities
            .filter(e => e.Name !== entityInfo.Name &&
            e.RelatedEntities.some(r => r.Type.trim().toUpperCase() === 'ONE TO MANY' &&
                r.RelatedEntity === entityInfo.Name))
            .map(e => {
            const rel = e.RelatedEntities.find(r => r.Type.trim().toUpperCase() === 'ONE TO MANY' &&
                r.RelatedEntity === entityInfo.Name);
            return {
                FromEntity: e.Name,
                ToEntity: entityInfo.Name,
                RelatedEntityJoinField: rel.RelatedEntityJoinField,
                Type: rel.Type
            };
        })
            .sort((a, b) => a.FromEntity.localeCompare(b.FromEntity));
    }
    NavigateToEntity(entityName) {
        const node = this.AllEntities.find(e => e.Name === entityName);
        if (node) {
            // Clear schema filter so the entity is visible
            if (this.SchemaFilter && node.SchemaName !== this.SchemaFilter) {
                this.SchemaFilter = '';
                this.applyFilter();
            }
            this.SelectEntity(node);
        }
    }
    GetDependencyLevel(count) {
        if (count === 0)
            return 'level-none';
        if (count <= 3)
            return 'level-low';
        if (count <= 10)
            return 'level-medium';
        return 'level-high';
    }
    GetSchemaEntityCount(schema) {
        return this.AllEntities.filter(e => e.SchemaName === schema).length;
    }
    Refresh() {
        this.LoadData();
    }
    static ɵfac = function VersionHistoryGraphResourceComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || VersionHistoryGraphResourceComponent)(i0.ɵɵdirectiveInject(i0.ChangeDetectorRef)); };
    static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: VersionHistoryGraphResourceComponent, selectors: [["mj-version-history-graph-resource"]], standalone: false, features: [i0.ɵɵInheritDefinitionFeature], decls: 3, vars: 2, consts: [[1, "graph-container"], ["text", "Loading dependency graph..."], [1, "page-header"], [1, "header-left"], [1, "page-title"], [1, "page-subtitle"], [1, "header-actions"], ["title", "Refresh", 1, "btn-icon", 3, "click"], [1, "fa-solid", "fa-refresh"], [1, "stats-row"], [1, "stat-badge"], [1, "fa-solid", "fa-table"], [1, "fa-solid", "fa-diagram-project"], [1, "fa-solid", "fa-arrow-right-arrow-left"], [1, "graph-layout"], [1, "entity-list-panel"], [1, "panel-header"], [1, "panel-title"], [1, "search-bar"], [1, "fa-solid", "fa-search", "search-icon"], ["type", "text", "placeholder", "Filter entities...", 1, "search-input", 3, "ngModelChange", "ngModel"], [1, "schema-chips"], [1, "entity-scroll-list"], [1, "entity-list-item", 3, "selected"], [1, "empty-list"], [1, "entity-detail-panel"], [1, "no-selection"], [1, "schema-chip", 3, "active"], [1, "schema-chip", 3, "click"], [1, "schema-chip-count"], [1, "entity-list-item", 3, "click"], [1, "entity-list-name"], [1, "entity-list-badges"], ["title", "Referenced by (entities with FKs to this)", 1, "dep-badge", 3, "ngClass"], ["title", "Depends on (entities this has FKs to)", 1, "dep-badge", "level-depends-on"], [1, "fa-solid", "fa-arrow-down"], [1, "fa-solid", "fa-arrow-up"], [1, "detail-header"], [1, "fa-solid", "fa-table", "detail-icon"], [1, "detail-header-text"], [1, "detail-title"], [1, "detail-schema"], [1, "relationship-section"], [1, "section-header"], [1, "fa-solid", "fa-arrow-down", "section-icon", "referenced-by-icon"], [1, "section-count"], [1, "section-hint"], [1, "relationship-list"], [1, "empty-relationships"], [1, "fa-solid", "fa-arrow-up", "section-icon", "depends-on-icon"], [1, "relationship-item"], [1, "rel-main", 3, "click"], [1, "fa-solid", "fa-table", "rel-icon"], [1, "rel-entity-name"], [1, "rel-join-field"], [1, "fa-solid", "fa-link"], [1, "fa-solid", "fa-diagram-project", "no-selection-icon"]], template: function VersionHistoryGraphResourceComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelementStart(0, "div", 0);
            i0.ɵɵconditionalCreate(1, VersionHistoryGraphResourceComponent_Conditional_1_Template, 1, 0, "mj-loading", 1);
            i0.ɵɵconditionalCreate(2, VersionHistoryGraphResourceComponent_Conditional_2_Template, 38, 7);
            i0.ɵɵelementEnd();
        } if (rf & 2) {
            i0.ɵɵadvance();
            i0.ɵɵconditional(ctx.IsLoading ? 1 : -1);
            i0.ɵɵadvance();
            i0.ɵɵconditional(!ctx.IsLoading ? 2 : -1);
        } }, dependencies: [i1.NgClass, i2.DefaultValueAccessor, i2.NgControlStatus, i2.NgModel, i3.LoadingComponent], styles: [".graph-container[_ngcontent-%COMP%] {\n    padding: 24px;\n    height: 100%;\n    overflow-y: auto;\n    display: flex;\n    flex-direction: column;\n}\n\n\n\n.page-header[_ngcontent-%COMP%] {\n    display: flex;\n    justify-content: space-between;\n    align-items: flex-start;\n    margin-bottom: 20px;\n}\n\n.header-left[_ngcontent-%COMP%] { flex: 1; }\n\n.page-title[_ngcontent-%COMP%] {\n    font-size: 24px;\n    font-weight: 700;\n    color: var(--mj-text-primary);\n    margin: 0 0 4px 0;\n}\n\n.page-subtitle[_ngcontent-%COMP%] {\n    font-size: 14px;\n    color: var(--mj-text-secondary);\n    margin: 0;\n}\n\n.header-actions[_ngcontent-%COMP%] { display: flex; gap: 12px; }\n\n.btn-icon[_ngcontent-%COMP%] {\n    display: flex;\n    align-items: center;\n    justify-content: center;\n    width: 40px;\n    height: 40px;\n    background: var(--mj-bg-surface-card);\n    border: 1px solid var(--mj-border-default);\n    border-radius: 8px;\n    cursor: pointer;\n    transition: all 0.2s ease;\n    color: var(--mj-text-secondary);\n}\n\n.btn-icon[_ngcontent-%COMP%]:hover {\n    background: var(--mj-bg-surface-sunken);\n    color: var(--mj-text-primary);\n}\n\n\n\n.stats-row[_ngcontent-%COMP%] {\n    display: flex;\n    gap: 12px;\n    margin-bottom: 20px;\n}\n\n.stat-badge[_ngcontent-%COMP%] {\n    display: inline-flex;\n    align-items: center;\n    gap: 8px;\n    padding: 8px 16px;\n    background: var(--mj-bg-surface-card);\n    border: 1px solid var(--mj-border-default);\n    border-radius: 20px;\n    font-size: 13px;\n    color: var(--mj-text-secondary);\n}\n\n.stat-badge[_ngcontent-%COMP%]   i[_ngcontent-%COMP%] {\n    color: var(--mj-brand-primary);\n}\n\n\n\n.graph-layout[_ngcontent-%COMP%] {\n    display: grid;\n    grid-template-columns: 340px 1fr;\n    gap: 20px;\n    flex: 1;\n    min-height: 0;\n}\n\n\n\n.entity-list-panel[_ngcontent-%COMP%] {\n    background: var(--mj-bg-surface-card);\n    border: 1px solid var(--mj-border-default);\n    border-radius: 12px;\n    display: flex;\n    flex-direction: column;\n    max-height: calc(100vh - 280px);\n}\n\n.panel-header[_ngcontent-%COMP%] {\n    padding: 16px 20px 0;\n}\n\n.panel-title[_ngcontent-%COMP%] {\n    font-size: 16px;\n    font-weight: 600;\n    color: var(--mj-text-primary);\n    margin: 0;\n}\n\n.search-bar[_ngcontent-%COMP%] {\n    position: relative;\n    padding: 12px 16px 8px;\n}\n\n.search-icon[_ngcontent-%COMP%] {\n    position: absolute;\n    left: 28px;\n    top: 50%;\n    transform: translateY(-50%);\n    color: var(--mj-text-secondary);\n    font-size: 13px;\n}\n\n.search-input[_ngcontent-%COMP%] {\n    width: 100%;\n    padding: 8px 12px 8px 34px;\n    background: var(--mj-bg-surface);\n    border: 1px solid var(--mj-border-strong);\n    border-radius: 8px;\n    font-size: 13px;\n    color: var(--mj-text-primary);\n    outline: none;\n    box-sizing: border-box;\n}\n\n.search-input[_ngcontent-%COMP%]:focus {\n    background: var(--mj-bg-surface-card);\n    border-color: var(--mj-brand-primary);\n}\n\n\n\n.schema-chips[_ngcontent-%COMP%] {\n    display: flex;\n    flex-wrap: wrap;\n    gap: 6px;\n    padding: 0 16px 10px;\n}\n\n.schema-chip[_ngcontent-%COMP%] {\n    display: inline-flex;\n    align-items: center;\n    gap: 5px;\n    padding: 4px 10px;\n    background: var(--mj-bg-surface-sunken);\n    border: 1px solid var(--mj-border-default);\n    border-radius: 14px;\n    font-size: 11px;\n    font-weight: 500;\n    color: var(--mj-text-secondary);\n    cursor: pointer;\n    transition: all 0.15s ease;\n}\n\n.schema-chip[_ngcontent-%COMP%]:hover {\n    background: color-mix(in srgb, var(--mj-brand-primary) 6%, transparent);\n    border-color: color-mix(in srgb, var(--mj-brand-primary) 30%, transparent);\n}\n\n.schema-chip.active[_ngcontent-%COMP%] {\n    background: color-mix(in srgb, var(--mj-brand-primary) 10%, transparent);\n    border-color: var(--mj-brand-primary);\n    color: var(--mj-brand-primary);\n}\n\n.schema-chip-count[_ngcontent-%COMP%] {\n    display: inline-flex;\n    align-items: center;\n    justify-content: center;\n    min-width: 18px;\n    height: 18px;\n    padding: 0 4px;\n    background: color-mix(in srgb, var(--mj-text-primary) 6%, transparent);\n    border-radius: 9px;\n    font-size: 10px;\n    font-weight: 600;\n}\n\n.schema-chip.active[_ngcontent-%COMP%]   .schema-chip-count[_ngcontent-%COMP%] {\n    background: color-mix(in srgb, var(--mj-brand-primary) 15%, transparent);\n}\n\n.entity-scroll-list[_ngcontent-%COMP%] {\n    flex: 1;\n    overflow-y: auto;\n    padding: 0 8px 8px;\n}\n\n.entity-list-item[_ngcontent-%COMP%] {\n    display: flex;\n    align-items: center;\n    justify-content: space-between;\n    padding: 10px 12px;\n    border-radius: 8px;\n    cursor: pointer;\n    transition: all 0.15s ease;\n}\n\n.entity-list-item[_ngcontent-%COMP%]:hover {\n    background: var(--mj-bg-surface-sunken);\n}\n\n.entity-list-item.selected[_ngcontent-%COMP%] {\n    background: color-mix(in srgb, var(--mj-brand-primary) 8%, transparent);\n    border-left: 3px solid var(--mj-brand-primary);\n}\n\n.entity-list-name[_ngcontent-%COMP%] {\n    font-size: 13px;\n    color: var(--mj-text-primary);\n    white-space: nowrap;\n    overflow: hidden;\n    text-overflow: ellipsis;\n    flex: 1;\n}\n\n.entity-list-badges[_ngcontent-%COMP%] {\n    display: flex;\n    gap: 4px;\n    flex-shrink: 0;\n}\n\n.dep-badge[_ngcontent-%COMP%] {\n    display: inline-flex;\n    align-items: center;\n    gap: 3px;\n    padding: 2px 8px;\n    border-radius: 10px;\n    font-size: 11px;\n    font-weight: 600;\n}\n\n.dep-badge[_ngcontent-%COMP%]   i[_ngcontent-%COMP%] { font-size: 9px; }\n\n.level-none[_ngcontent-%COMP%] { display: none; }\n\n.level-low[_ngcontent-%COMP%] {\n    background: color-mix(in srgb, var(--mj-status-success) 10%, transparent);\n    color: var(--mj-status-success);\n}\n\n.level-medium[_ngcontent-%COMP%] {\n    background: color-mix(in srgb, var(--mj-status-warning) 10%, transparent);\n    color: var(--mj-status-warning);\n}\n\n.level-high[_ngcontent-%COMP%] {\n    background: color-mix(in srgb, var(--mj-status-error) 10%, transparent);\n    color: var(--mj-status-error);\n}\n\n.level-depends-on[_ngcontent-%COMP%] {\n    background: color-mix(in srgb, var(--mj-brand-primary) 10%, transparent);\n    color: var(--mj-brand-primary);\n}\n\n.empty-list[_ngcontent-%COMP%] {\n    padding: 20px;\n    text-align: center;\n    font-size: 13px;\n    color: var(--mj-text-secondary);\n}\n\n\n\n.entity-detail-panel[_ngcontent-%COMP%] {\n    background: var(--mj-bg-surface-card);\n    border: 1px solid var(--mj-border-default);\n    border-radius: 12px;\n    padding: 24px;\n    overflow-y: auto;\n    max-height: calc(100vh - 280px);\n}\n\n.detail-header[_ngcontent-%COMP%] {\n    display: flex;\n    align-items: center;\n    gap: 12px;\n    margin-bottom: 28px;\n    padding-bottom: 16px;\n    border-bottom: 1px solid var(--mj-border-default);\n}\n\n.detail-header-text[_ngcontent-%COMP%] {\n    display: flex;\n    flex-direction: column;\n    gap: 2px;\n}\n\n.detail-icon[_ngcontent-%COMP%] {\n    font-size: 20px;\n    color: var(--mj-brand-primary);\n}\n\n.detail-title[_ngcontent-%COMP%] {\n    font-size: 20px;\n    font-weight: 700;\n    color: var(--mj-text-primary);\n    margin: 0;\n}\n\n.detail-schema[_ngcontent-%COMP%] {\n    font-size: 12px;\n    color: var(--mj-text-secondary);\n}\n\n\n\n.relationship-section[_ngcontent-%COMP%] {\n    margin-bottom: 28px;\n}\n\n.section-header[_ngcontent-%COMP%] {\n    display: flex;\n    align-items: center;\n    gap: 10px;\n    margin-bottom: 4px;\n}\n\n.section-header[_ngcontent-%COMP%]   h4[_ngcontent-%COMP%] {\n    font-size: 14px;\n    font-weight: 600;\n    color: var(--mj-text-primary);\n    margin: 0;\n    flex: 1;\n}\n\n.section-hint[_ngcontent-%COMP%] {\n    font-size: 12px;\n    color: var(--mj-text-muted);\n    margin: 0 0 12px 0;\n}\n\n.section-hint[_ngcontent-%COMP%]   strong[_ngcontent-%COMP%] {\n    color: var(--mj-text-secondary);\n}\n\n.section-icon[_ngcontent-%COMP%] {\n    font-size: 14px;\n}\n\n.referenced-by-icon[_ngcontent-%COMP%] { color: var(--mj-status-success); }\n.depends-on-icon[_ngcontent-%COMP%] { color: var(--mj-brand-primary); }\n\n.section-count[_ngcontent-%COMP%] {\n    display: inline-flex;\n    align-items: center;\n    justify-content: center;\n    min-width: 24px;\n    height: 24px;\n    padding: 0 8px;\n    background: var(--mj-bg-surface-sunken);\n    border-radius: 12px;\n    font-size: 12px;\n    font-weight: 600;\n    color: var(--mj-text-secondary);\n}\n\n.relationship-list[_ngcontent-%COMP%] {\n    display: flex;\n    flex-direction: column;\n    gap: 4px;\n}\n\n.relationship-item[_ngcontent-%COMP%] {\n    border-radius: 8px;\n    transition: background 0.15s ease;\n}\n\n.relationship-item[_ngcontent-%COMP%]:hover {\n    background: var(--mj-bg-surface-sunken);\n}\n\n.rel-main[_ngcontent-%COMP%] {\n    display: flex;\n    align-items: center;\n    gap: 8px;\n    padding: 8px 12px;\n    cursor: pointer;\n}\n\n.rel-icon[_ngcontent-%COMP%] {\n    font-size: 12px;\n    color: var(--mj-brand-primary);\n    opacity: 0.7;\n    flex-shrink: 0;\n}\n\n.rel-entity-name[_ngcontent-%COMP%] {\n    font-size: 14px;\n    color: var(--mj-brand-primary);\n    font-weight: 500;\n}\n\n.rel-entity-name[_ngcontent-%COMP%]:hover {\n    text-decoration: underline;\n}\n\n.rel-join-field[_ngcontent-%COMP%] {\n    display: inline-flex;\n    align-items: center;\n    gap: 4px;\n    font-size: 11px;\n    color: var(--mj-text-muted);\n    font-family: 'SF Mono', 'Fira Code', monospace;\n    margin-left: 4px;\n    padding: 2px 8px;\n    background: var(--mj-bg-surface-sunken);\n    border-radius: 4px;\n}\n\n.rel-join-field[_ngcontent-%COMP%]   i[_ngcontent-%COMP%] {\n    font-size: 9px;\n    opacity: 0.5;\n}\n\n.empty-relationships[_ngcontent-%COMP%] {\n    padding: 12px;\n    text-align: center;\n    font-size: 13px;\n    color: var(--mj-text-muted);\n}\n\n\n\n.no-selection[_ngcontent-%COMP%] {\n    display: flex;\n    flex-direction: column;\n    align-items: center;\n    justify-content: center;\n    padding: 60px 20px;\n    text-align: center;\n    height: 100%;\n}\n\n.no-selection-icon[_ngcontent-%COMP%] {\n    font-size: 48px;\n    color: var(--mj-text-muted);\n    margin-bottom: 16px;\n}\n\n.no-selection[_ngcontent-%COMP%]   h3[_ngcontent-%COMP%] {\n    font-size: 18px;\n    font-weight: 600;\n    color: var(--mj-text-primary);\n    margin: 0 0 8px 0;\n}\n\n.no-selection[_ngcontent-%COMP%]   p[_ngcontent-%COMP%] {\n    font-size: 14px;\n    color: var(--mj-text-secondary);\n    margin: 0;\n    max-width: 300px;\n}"], changeDetection: 0 });
};
VersionHistoryGraphResourceComponent = VersionHistoryGraphResourceComponent_1 = __decorate([
    RegisterClass(BaseResourceComponent, 'VersionHistoryGraphResource')
], VersionHistoryGraphResourceComponent);
export { VersionHistoryGraphResourceComponent };
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(VersionHistoryGraphResourceComponent, [{
        type: Component,
        args: [{ standalone: false, selector: 'mj-version-history-graph-resource', changeDetection: ChangeDetectionStrategy.OnPush, template: "<div class=\"graph-container\">\n  @if (IsLoading) {\n    <mj-loading text=\"Loading dependency graph...\"></mj-loading>\n  }\n\n  @if (!IsLoading) {\n    <!-- Header -->\n    <div class=\"page-header\">\n      <div class=\"header-left\">\n        <h2 class=\"page-title\">Entity Dependency Graph</h2>\n        <p class=\"page-subtitle\">Explore entity relationships used by the version history system</p>\n      </div>\n      <div class=\"header-actions\">\n        <button class=\"btn-icon\" (click)=\"Refresh()\" title=\"Refresh\">\n          <i class=\"fa-solid fa-refresh\"></i>\n        </button>\n      </div>\n    </div>\n    <!-- Stats Row -->\n    <div class=\"stats-row\">\n      <div class=\"stat-badge\">\n        <i class=\"fa-solid fa-table\"></i>\n        <span>{{TotalEntities}} Entities</span>\n      </div>\n      <div class=\"stat-badge\">\n        <i class=\"fa-solid fa-diagram-project\"></i>\n        <span>{{EntitiesWithDependents}} with Dependents</span>\n      </div>\n      <div class=\"stat-badge\">\n        <i class=\"fa-solid fa-arrow-right-arrow-left\"></i>\n        <span>{{TotalRelationships}} Relationships</span>\n      </div>\n    </div>\n    <!-- Main Layout: Entity List + Detail -->\n    <div class=\"graph-layout\">\n      <!-- Entity List -->\n      <div class=\"entity-list-panel\">\n        <div class=\"panel-header\">\n          <h3 class=\"panel-title\">Entities</h3>\n        </div>\n        <div class=\"search-bar\">\n          <i class=\"fa-solid fa-search search-icon\"></i>\n          <input type=\"text\"\n            class=\"search-input\"\n            placeholder=\"Filter entities...\"\n            [ngModel]=\"SearchText\"\n            (ngModelChange)=\"OnSearchChange($event)\" />\n        </div>\n        <!-- Schema Filter Chips -->\n        @if (AvailableSchemas.length > 1) {\n          <div class=\"schema-chips\">\n            @for (schema of AvailableSchemas; track schema) {\n              <button class=\"schema-chip\"\n                [class.active]=\"SchemaFilter === schema\"\n                (click)=\"OnSchemaFilterChange(schema)\">\n                {{schema}}\n                <span class=\"schema-chip-count\">{{GetSchemaEntityCount(schema)}}</span>\n              </button>\n            }\n          </div>\n        }\n        <div class=\"entity-scroll-list\">\n          @for (entity of FilteredEntities; track entity) {\n            <div class=\"entity-list-item\"\n              [class.selected]=\"entity.IsSelected\"\n              (click)=\"SelectEntity(entity)\">\n              <div class=\"entity-list-name\">{{entity.Name}}</div>\n              <div class=\"entity-list-badges\">\n                @if (entity.ReferencedByCount > 0) {\n                  <span class=\"dep-badge\"\n                    [ngClass]=\"GetDependencyLevel(entity.ReferencedByCount)\"\n                    title=\"Referenced by (entities with FKs to this)\">\n                    {{entity.ReferencedByCount}} <i class=\"fa-solid fa-arrow-down\"></i>\n                  </span>\n                }\n                @if (entity.DependsOnCount > 0) {\n                  <span class=\"dep-badge level-depends-on\"\n                    title=\"Depends on (entities this has FKs to)\">\n                    {{entity.DependsOnCount}} <i class=\"fa-solid fa-arrow-up\"></i>\n                  </span>\n                }\n              </div>\n            </div>\n          }\n          @if (FilteredEntities.length === 0) {\n            <div class=\"empty-list\">\n              <p>No entities match your search.</p>\n            </div>\n          }\n        </div>\n      </div>\n      <!-- Detail Panel -->\n      <div class=\"entity-detail-panel\">\n        @if (SelectedEntity) {\n          <div class=\"detail-header\">\n            <i class=\"fa-solid fa-table detail-icon\"></i>\n            <div class=\"detail-header-text\">\n              <h3 class=\"detail-title\">{{SelectedEntity.Name}}</h3>\n              <span class=\"detail-schema\">{{SelectedEntity.SchemaName}}</span>\n            </div>\n          </div>\n          <!-- Referenced By (entities that have FKs pointing to this entity) -->\n          <div class=\"relationship-section\">\n            <div class=\"section-header\">\n              <i class=\"fa-solid fa-arrow-down section-icon referenced-by-icon\"></i>\n              <h4>Referenced By</h4>\n              <span class=\"section-count\">{{ReferencedByEntities.length}}</span>\n            </div>\n            <p class=\"section-hint\">Entities that have foreign keys pointing to <strong>{{SelectedEntity.Name}}</strong></p>\n            @if (ReferencedByEntities.length > 0) {\n              <div class=\"relationship-list\">\n                @for (rel of ReferencedByEntities; track rel) {\n                  <div class=\"relationship-item\">\n                    <div class=\"rel-main\"\n                      (click)=\"NavigateToEntity(rel.ToEntity)\">\n                      <i class=\"fa-solid fa-table rel-icon\"></i>\n                      <span class=\"rel-entity-name\">{{rel.ToEntity}}</span>\n                      <span class=\"rel-join-field\">\n                        <i class=\"fa-solid fa-link\"></i>\n                        {{rel.RelatedEntityJoinField}}\n                      </span>\n                    </div>\n                  </div>\n                }\n              </div>\n            }\n            @if (ReferencedByEntities.length === 0) {\n              <div class=\"empty-relationships\">\n                <p>No entities reference this entity.</p>\n              </div>\n            }\n          </div>\n          <!-- Depends On (entities this entity has FKs to) -->\n          <div class=\"relationship-section\">\n            <div class=\"section-header\">\n              <i class=\"fa-solid fa-arrow-up section-icon depends-on-icon\"></i>\n              <h4>Depends On</h4>\n              <span class=\"section-count\">{{DependsOnEntities.length}}</span>\n            </div>\n            <p class=\"section-hint\"><strong>{{SelectedEntity.Name}}</strong> has foreign keys pointing to these entities</p>\n            @if (DependsOnEntities.length > 0) {\n              <div class=\"relationship-list\">\n                @for (rel of DependsOnEntities; track rel) {\n                  <div class=\"relationship-item\">\n                    <div class=\"rel-main\"\n                      (click)=\"NavigateToEntity(rel.FromEntity)\">\n                      <i class=\"fa-solid fa-table rel-icon\"></i>\n                      <span class=\"rel-entity-name\">{{rel.FromEntity}}</span>\n                      <span class=\"rel-join-field\">\n                        <i class=\"fa-solid fa-link\"></i>\n                        {{rel.RelatedEntityJoinField}}\n                      </span>\n                    </div>\n                  </div>\n                }\n              </div>\n            }\n            @if (DependsOnEntities.length === 0) {\n              <div class=\"empty-relationships\">\n                <p>This entity has no foreign key dependencies.</p>\n              </div>\n            }\n          </div>\n        } @else {\n          <div class=\"no-selection\">\n            <i class=\"fa-solid fa-diagram-project no-selection-icon\"></i>\n            <h3>Select an Entity</h3>\n            <p>Choose an entity from the list to explore its dependency relationships.</p>\n          </div>\n        }\n      </div>\n    </div>\n  }\n</div>\n", styles: [".graph-container {\n    padding: 24px;\n    height: 100%;\n    overflow-y: auto;\n    display: flex;\n    flex-direction: column;\n}\n\n/* Header */\n.page-header {\n    display: flex;\n    justify-content: space-between;\n    align-items: flex-start;\n    margin-bottom: 20px;\n}\n\n.header-left { flex: 1; }\n\n.page-title {\n    font-size: 24px;\n    font-weight: 700;\n    color: var(--mj-text-primary);\n    margin: 0 0 4px 0;\n}\n\n.page-subtitle {\n    font-size: 14px;\n    color: var(--mj-text-secondary);\n    margin: 0;\n}\n\n.header-actions { display: flex; gap: 12px; }\n\n.btn-icon {\n    display: flex;\n    align-items: center;\n    justify-content: center;\n    width: 40px;\n    height: 40px;\n    background: var(--mj-bg-surface-card);\n    border: 1px solid var(--mj-border-default);\n    border-radius: 8px;\n    cursor: pointer;\n    transition: all 0.2s ease;\n    color: var(--mj-text-secondary);\n}\n\n.btn-icon:hover {\n    background: var(--mj-bg-surface-sunken);\n    color: var(--mj-text-primary);\n}\n\n/* Stats Row */\n.stats-row {\n    display: flex;\n    gap: 12px;\n    margin-bottom: 20px;\n}\n\n.stat-badge {\n    display: inline-flex;\n    align-items: center;\n    gap: 8px;\n    padding: 8px 16px;\n    background: var(--mj-bg-surface-card);\n    border: 1px solid var(--mj-border-default);\n    border-radius: 20px;\n    font-size: 13px;\n    color: var(--mj-text-secondary);\n}\n\n.stat-badge i {\n    color: var(--mj-brand-primary);\n}\n\n/* Main Layout */\n.graph-layout {\n    display: grid;\n    grid-template-columns: 340px 1fr;\n    gap: 20px;\n    flex: 1;\n    min-height: 0;\n}\n\n/* Entity List Panel */\n.entity-list-panel {\n    background: var(--mj-bg-surface-card);\n    border: 1px solid var(--mj-border-default);\n    border-radius: 12px;\n    display: flex;\n    flex-direction: column;\n    max-height: calc(100vh - 280px);\n}\n\n.panel-header {\n    padding: 16px 20px 0;\n}\n\n.panel-title {\n    font-size: 16px;\n    font-weight: 600;\n    color: var(--mj-text-primary);\n    margin: 0;\n}\n\n.search-bar {\n    position: relative;\n    padding: 12px 16px 8px;\n}\n\n.search-icon {\n    position: absolute;\n    left: 28px;\n    top: 50%;\n    transform: translateY(-50%);\n    color: var(--mj-text-secondary);\n    font-size: 13px;\n}\n\n.search-input {\n    width: 100%;\n    padding: 8px 12px 8px 34px;\n    background: var(--mj-bg-surface);\n    border: 1px solid var(--mj-border-strong);\n    border-radius: 8px;\n    font-size: 13px;\n    color: var(--mj-text-primary);\n    outline: none;\n    box-sizing: border-box;\n}\n\n.search-input:focus {\n    background: var(--mj-bg-surface-card);\n    border-color: var(--mj-brand-primary);\n}\n\n/* Schema Filter Chips */\n.schema-chips {\n    display: flex;\n    flex-wrap: wrap;\n    gap: 6px;\n    padding: 0 16px 10px;\n}\n\n.schema-chip {\n    display: inline-flex;\n    align-items: center;\n    gap: 5px;\n    padding: 4px 10px;\n    background: var(--mj-bg-surface-sunken);\n    border: 1px solid var(--mj-border-default);\n    border-radius: 14px;\n    font-size: 11px;\n    font-weight: 500;\n    color: var(--mj-text-secondary);\n    cursor: pointer;\n    transition: all 0.15s ease;\n}\n\n.schema-chip:hover {\n    background: color-mix(in srgb, var(--mj-brand-primary) 6%, transparent);\n    border-color: color-mix(in srgb, var(--mj-brand-primary) 30%, transparent);\n}\n\n.schema-chip.active {\n    background: color-mix(in srgb, var(--mj-brand-primary) 10%, transparent);\n    border-color: var(--mj-brand-primary);\n    color: var(--mj-brand-primary);\n}\n\n.schema-chip-count {\n    display: inline-flex;\n    align-items: center;\n    justify-content: center;\n    min-width: 18px;\n    height: 18px;\n    padding: 0 4px;\n    background: color-mix(in srgb, var(--mj-text-primary) 6%, transparent);\n    border-radius: 9px;\n    font-size: 10px;\n    font-weight: 600;\n}\n\n.schema-chip.active .schema-chip-count {\n    background: color-mix(in srgb, var(--mj-brand-primary) 15%, transparent);\n}\n\n.entity-scroll-list {\n    flex: 1;\n    overflow-y: auto;\n    padding: 0 8px 8px;\n}\n\n.entity-list-item {\n    display: flex;\n    align-items: center;\n    justify-content: space-between;\n    padding: 10px 12px;\n    border-radius: 8px;\n    cursor: pointer;\n    transition: all 0.15s ease;\n}\n\n.entity-list-item:hover {\n    background: var(--mj-bg-surface-sunken);\n}\n\n.entity-list-item.selected {\n    background: color-mix(in srgb, var(--mj-brand-primary) 8%, transparent);\n    border-left: 3px solid var(--mj-brand-primary);\n}\n\n.entity-list-name {\n    font-size: 13px;\n    color: var(--mj-text-primary);\n    white-space: nowrap;\n    overflow: hidden;\n    text-overflow: ellipsis;\n    flex: 1;\n}\n\n.entity-list-badges {\n    display: flex;\n    gap: 4px;\n    flex-shrink: 0;\n}\n\n.dep-badge {\n    display: inline-flex;\n    align-items: center;\n    gap: 3px;\n    padding: 2px 8px;\n    border-radius: 10px;\n    font-size: 11px;\n    font-weight: 600;\n}\n\n.dep-badge i { font-size: 9px; }\n\n.level-none { display: none; }\n\n.level-low {\n    background: color-mix(in srgb, var(--mj-status-success) 10%, transparent);\n    color: var(--mj-status-success);\n}\n\n.level-medium {\n    background: color-mix(in srgb, var(--mj-status-warning) 10%, transparent);\n    color: var(--mj-status-warning);\n}\n\n.level-high {\n    background: color-mix(in srgb, var(--mj-status-error) 10%, transparent);\n    color: var(--mj-status-error);\n}\n\n.level-depends-on {\n    background: color-mix(in srgb, var(--mj-brand-primary) 10%, transparent);\n    color: var(--mj-brand-primary);\n}\n\n.empty-list {\n    padding: 20px;\n    text-align: center;\n    font-size: 13px;\n    color: var(--mj-text-secondary);\n}\n\n/* Detail Panel */\n.entity-detail-panel {\n    background: var(--mj-bg-surface-card);\n    border: 1px solid var(--mj-border-default);\n    border-radius: 12px;\n    padding: 24px;\n    overflow-y: auto;\n    max-height: calc(100vh - 280px);\n}\n\n.detail-header {\n    display: flex;\n    align-items: center;\n    gap: 12px;\n    margin-bottom: 28px;\n    padding-bottom: 16px;\n    border-bottom: 1px solid var(--mj-border-default);\n}\n\n.detail-header-text {\n    display: flex;\n    flex-direction: column;\n    gap: 2px;\n}\n\n.detail-icon {\n    font-size: 20px;\n    color: var(--mj-brand-primary);\n}\n\n.detail-title {\n    font-size: 20px;\n    font-weight: 700;\n    color: var(--mj-text-primary);\n    margin: 0;\n}\n\n.detail-schema {\n    font-size: 12px;\n    color: var(--mj-text-secondary);\n}\n\n/* Relationship Sections */\n.relationship-section {\n    margin-bottom: 28px;\n}\n\n.section-header {\n    display: flex;\n    align-items: center;\n    gap: 10px;\n    margin-bottom: 4px;\n}\n\n.section-header h4 {\n    font-size: 14px;\n    font-weight: 600;\n    color: var(--mj-text-primary);\n    margin: 0;\n    flex: 1;\n}\n\n.section-hint {\n    font-size: 12px;\n    color: var(--mj-text-muted);\n    margin: 0 0 12px 0;\n}\n\n.section-hint strong {\n    color: var(--mj-text-secondary);\n}\n\n.section-icon {\n    font-size: 14px;\n}\n\n.referenced-by-icon { color: var(--mj-status-success); }\n.depends-on-icon { color: var(--mj-brand-primary); }\n\n.section-count {\n    display: inline-flex;\n    align-items: center;\n    justify-content: center;\n    min-width: 24px;\n    height: 24px;\n    padding: 0 8px;\n    background: var(--mj-bg-surface-sunken);\n    border-radius: 12px;\n    font-size: 12px;\n    font-weight: 600;\n    color: var(--mj-text-secondary);\n}\n\n.relationship-list {\n    display: flex;\n    flex-direction: column;\n    gap: 4px;\n}\n\n.relationship-item {\n    border-radius: 8px;\n    transition: background 0.15s ease;\n}\n\n.relationship-item:hover {\n    background: var(--mj-bg-surface-sunken);\n}\n\n.rel-main {\n    display: flex;\n    align-items: center;\n    gap: 8px;\n    padding: 8px 12px;\n    cursor: pointer;\n}\n\n.rel-icon {\n    font-size: 12px;\n    color: var(--mj-brand-primary);\n    opacity: 0.7;\n    flex-shrink: 0;\n}\n\n.rel-entity-name {\n    font-size: 14px;\n    color: var(--mj-brand-primary);\n    font-weight: 500;\n}\n\n.rel-entity-name:hover {\n    text-decoration: underline;\n}\n\n.rel-join-field {\n    display: inline-flex;\n    align-items: center;\n    gap: 4px;\n    font-size: 11px;\n    color: var(--mj-text-muted);\n    font-family: 'SF Mono', 'Fira Code', monospace;\n    margin-left: 4px;\n    padding: 2px 8px;\n    background: var(--mj-bg-surface-sunken);\n    border-radius: 4px;\n}\n\n.rel-join-field i {\n    font-size: 9px;\n    opacity: 0.5;\n}\n\n.empty-relationships {\n    padding: 12px;\n    text-align: center;\n    font-size: 13px;\n    color: var(--mj-text-muted);\n}\n\n/* No Selection */\n.no-selection {\n    display: flex;\n    flex-direction: column;\n    align-items: center;\n    justify-content: center;\n    padding: 60px 20px;\n    text-align: center;\n    height: 100%;\n}\n\n.no-selection-icon {\n    font-size: 48px;\n    color: var(--mj-text-muted);\n    margin-bottom: 16px;\n}\n\n.no-selection h3 {\n    font-size: 18px;\n    font-weight: 600;\n    color: var(--mj-text-primary);\n    margin: 0 0 8px 0;\n}\n\n.no-selection p {\n    font-size: 14px;\n    color: var(--mj-text-secondary);\n    margin: 0;\n    max-width: 300px;\n}\n"] }]
    }], () => [{ type: i0.ChangeDetectorRef }], null); })();
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(VersionHistoryGraphResourceComponent, { className: "VersionHistoryGraphResourceComponent", filePath: "src/VersionHistory/components/graph-resource.component.ts", lineNumber: 35 }); })();
//# sourceMappingURL=graph-resource.component.js.map