/**
 * @module entity-list.component
 * @description Displays the list of entities accessible to the current user.
 *
 * Loaded from `DatabaseDesignerEngine.Instance.loadAccessibleEntities()` —
 * data access goes through the engine singleton, not this component directly,
 * so the cache is shared across wizard openings.
 */
import { Component, Output, EventEmitter, ChangeDetectionStrategy, ChangeDetectorRef, inject, } from '@angular/core';
import { Subject, BehaviorSubject, combineLatest } from 'rxjs';
import { debounceTime, takeUntil, map } from 'rxjs/operators';
import { DatabaseDesignerEngine } from '../services/database-designer.engine.js';
import * as i0 from "@angular/core";
import * as i1 from "@angular/forms";
import * as i2 from "@memberjunction/ng-ui-components";
const _c0 = () => [1, 2, 3, 4];
function EntityListComponent_Conditional_11_For_4_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "option", 16);
    i0.ɵɵtext(1);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const schema_r3 = ctx.$implicit;
    i0.ɵɵproperty("value", schema_r3);
    i0.ɵɵadvance();
    i0.ɵɵtextInterpolate(schema_r3);
} }
function EntityListComponent_Conditional_11_Template(rf, ctx) { if (rf & 1) {
    const _r1 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "select", 14);
    i0.ɵɵlistener("change", function EntityListComponent_Conditional_11_Template_select_change_0_listener($event) { i0.ɵɵrestoreView(_r1); const ctx_r1 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r1.SelectedSchema = $event.target.value); });
    i0.ɵɵelementStart(1, "option", 15);
    i0.ɵɵtext(2, "All Schemas");
    i0.ɵɵelementEnd();
    i0.ɵɵrepeaterCreate(3, EntityListComponent_Conditional_11_For_4_Template, 2, 2, "option", 16, i0.ɵɵrepeaterTrackByIdentity);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext();
    i0.ɵɵproperty("value", ctx_r1.SelectedSchema);
    i0.ɵɵadvance(3);
    i0.ɵɵrepeater(ctx_r1.AvailableFilterSchemas);
} }
function EntityListComponent_Conditional_13_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 12);
    i0.ɵɵelement(1, "i", 17);
    i0.ɵɵtext(2);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext();
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate1(" ", ctx_r1.ErrorMessage, " ");
} }
function EntityListComponent_Conditional_14_For_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 18);
    i0.ɵɵelement(1, "div", 19)(2, "div", 20)(3, "div", 21)(4, "div", 21)(5, "div", 20)(6, "div", 21);
    i0.ɵɵelementEnd();
} }
function EntityListComponent_Conditional_14_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 13);
    i0.ɵɵrepeaterCreate(1, EntityListComponent_Conditional_14_For_2_Template, 7, 0, "div", 18, i0.ɵɵrepeaterTrackByIndex);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    i0.ɵɵadvance();
    i0.ɵɵrepeater(i0.ɵɵpureFunction0(0, _c0));
} }
function EntityListComponent_Conditional_15_Conditional_0_Conditional_7_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "i", 36);
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext(3);
    i0.ɵɵclassProp("fa-chevron-up", ctx_r1.SortDirection === "asc")("fa-chevron-down", ctx_r1.SortDirection === "desc");
} }
function EntityListComponent_Conditional_15_Conditional_0_Conditional_8_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "i", 28);
} }
function EntityListComponent_Conditional_15_Conditional_0_Conditional_12_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "i", 36);
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext(3);
    i0.ɵɵclassProp("fa-chevron-up", ctx_r1.SortDirection === "asc")("fa-chevron-down", ctx_r1.SortDirection === "desc");
} }
function EntityListComponent_Conditional_15_Conditional_0_Conditional_13_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "i", 28);
} }
function EntityListComponent_Conditional_15_Conditional_0_Conditional_17_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "i", 36);
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext(3);
    i0.ɵɵclassProp("fa-chevron-up", ctx_r1.SortDirection === "asc")("fa-chevron-down", ctx_r1.SortDirection === "desc");
} }
function EntityListComponent_Conditional_15_Conditional_0_Conditional_18_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "i", 28);
} }
function EntityListComponent_Conditional_15_Conditional_0_Conditional_22_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "i", 36);
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext(3);
    i0.ɵɵclassProp("fa-chevron-up", ctx_r1.SortDirection === "asc")("fa-chevron-down", ctx_r1.SortDirection === "desc");
} }
function EntityListComponent_Conditional_15_Conditional_0_Conditional_23_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "i", 28);
} }
function EntityListComponent_Conditional_15_Conditional_0_Conditional_27_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "i", 36);
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext(3);
    i0.ɵɵclassProp("fa-chevron-up", ctx_r1.SortDirection === "asc")("fa-chevron-down", ctx_r1.SortDirection === "desc");
} }
function EntityListComponent_Conditional_15_Conditional_0_Conditional_28_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "i", 28);
} }
function EntityListComponent_Conditional_15_Conditional_0_For_33_Conditional_5_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "span", 40);
    i0.ɵɵtext(1, "You");
    i0.ɵɵelementEnd();
} }
function EntityListComponent_Conditional_15_Conditional_0_For_33_Conditional_13_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "span", 46);
    i0.ɵɵelement(1, "i", 54);
    i0.ɵɵtext(2, " You ");
    i0.ɵɵelementEnd();
} }
function EntityListComponent_Conditional_15_Conditional_0_For_33_Conditional_14_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "span", 47);
    i0.ɵɵtext(1);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const entity_r6 = i0.ɵɵnextContext().$implicit;
    i0.ɵɵadvance();
    i0.ɵɵtextInterpolate(entity_r6.ownerDisplayName);
} }
function EntityListComponent_Conditional_15_Conditional_0_For_33_Conditional_15_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "span", 48);
    i0.ɵɵtext(1, "\u2014");
    i0.ɵɵelementEnd();
} }
function EntityListComponent_Conditional_15_Conditional_0_For_33_Template(rf, ctx) { if (rf & 1) {
    const _r5 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "tr", 34)(1, "td", 37)(2, "div", 38)(3, "span", 39);
    i0.ɵɵtext(4);
    i0.ɵɵelementEnd();
    i0.ɵɵconditionalCreate(5, EntityListComponent_Conditional_15_Conditional_0_For_33_Conditional_5_Template, 2, 0, "span", 40);
    i0.ɵɵelementEnd()();
    i0.ɵɵelementStart(6, "td", 41)(7, "span", 42);
    i0.ɵɵtext(8);
    i0.ɵɵelementEnd()();
    i0.ɵɵelementStart(9, "td", 43)(10, "code", 44);
    i0.ɵɵtext(11);
    i0.ɵɵelementEnd()();
    i0.ɵɵelementStart(12, "td", 45);
    i0.ɵɵconditionalCreate(13, EntityListComponent_Conditional_15_Conditional_0_For_33_Conditional_13_Template, 3, 0, "span", 46)(14, EntityListComponent_Conditional_15_Conditional_0_For_33_Conditional_14_Template, 2, 1, "span", 47)(15, EntityListComponent_Conditional_15_Conditional_0_For_33_Conditional_15_Template, 2, 0, "span", 48);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(16, "td", 49);
    i0.ɵɵtext(17);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(18, "td", 50)(19, "div", 51)(20, "button", 52);
    i0.ɵɵlistener("click", function EntityListComponent_Conditional_15_Conditional_0_For_33_Template_button_click_20_listener() { const entity_r6 = i0.ɵɵrestoreView(_r5).$implicit; const ctx_r1 = i0.ɵɵnextContext(3); return i0.ɵɵresetView(ctx_r1.OnEditEntity(entity_r6)); });
    i0.ɵɵelement(21, "i", 53);
    i0.ɵɵtext(22, " Edit ");
    i0.ɵɵelementEnd()()()();
} if (rf & 2) {
    const entity_r6 = ctx.$implicit;
    const ctx_r1 = i0.ɵɵnextContext(3);
    i0.ɵɵadvance(4);
    i0.ɵɵtextInterpolate(entity_r6.entityName);
    i0.ɵɵadvance();
    i0.ɵɵconditional(entity_r6.isOwner ? 5 : -1);
    i0.ɵɵadvance(3);
    i0.ɵɵtextInterpolate(entity_r6.schemaName);
    i0.ɵɵadvance(3);
    i0.ɵɵtextInterpolate(entity_r6.tableName);
    i0.ɵɵadvance(2);
    i0.ɵɵconditional(entity_r6.isOwner ? 13 : entity_r6.ownerDisplayName ? 14 : 15);
    i0.ɵɵadvance(4);
    i0.ɵɵtextInterpolate(ctx_r1.FormatDate(entity_r6.createdAt));
} }
function EntityListComponent_Conditional_15_Conditional_0_Conditional_36_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵtext(0);
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext(3);
    i0.ɵɵtextInterpolate1(" matching \"", ctx_r1.SearchTerm, "\" ");
} }
function EntityListComponent_Conditional_15_Conditional_0_Template(rf, ctx) { if (rf & 1) {
    const _r4 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "div", 23)(1, "table", 24)(2, "thead")(3, "tr")(4, "th", 25);
    i0.ɵɵlistener("click", function EntityListComponent_Conditional_15_Conditional_0_Template_th_click_4_listener() { i0.ɵɵrestoreView(_r4); const ctx_r1 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r1.OnSortChange("entityName")); });
    i0.ɵɵtext(5, " Entity Name ");
    i0.ɵɵelementStart(6, "span", 26);
    i0.ɵɵconditionalCreate(7, EntityListComponent_Conditional_15_Conditional_0_Conditional_7_Template, 1, 4, "i", 27)(8, EntityListComponent_Conditional_15_Conditional_0_Conditional_8_Template, 1, 0, "i", 28);
    i0.ɵɵelementEnd()();
    i0.ɵɵelementStart(9, "th", 29);
    i0.ɵɵlistener("click", function EntityListComponent_Conditional_15_Conditional_0_Template_th_click_9_listener() { i0.ɵɵrestoreView(_r4); const ctx_r1 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r1.OnSortChange("schemaName")); });
    i0.ɵɵtext(10, " Schema ");
    i0.ɵɵelementStart(11, "span", 26);
    i0.ɵɵconditionalCreate(12, EntityListComponent_Conditional_15_Conditional_0_Conditional_12_Template, 1, 4, "i", 27)(13, EntityListComponent_Conditional_15_Conditional_0_Conditional_13_Template, 1, 0, "i", 28);
    i0.ɵɵelementEnd()();
    i0.ɵɵelementStart(14, "th", 30);
    i0.ɵɵlistener("click", function EntityListComponent_Conditional_15_Conditional_0_Template_th_click_14_listener() { i0.ɵɵrestoreView(_r4); const ctx_r1 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r1.OnSortChange("tableName")); });
    i0.ɵɵtext(15, " Table ");
    i0.ɵɵelementStart(16, "span", 26);
    i0.ɵɵconditionalCreate(17, EntityListComponent_Conditional_15_Conditional_0_Conditional_17_Template, 1, 4, "i", 27)(18, EntityListComponent_Conditional_15_Conditional_0_Conditional_18_Template, 1, 0, "i", 28);
    i0.ɵɵelementEnd()();
    i0.ɵɵelementStart(19, "th", 31);
    i0.ɵɵlistener("click", function EntityListComponent_Conditional_15_Conditional_0_Template_th_click_19_listener() { i0.ɵɵrestoreView(_r4); const ctx_r1 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r1.OnSortChange("owner")); });
    i0.ɵɵtext(20, " Owner ");
    i0.ɵɵelementStart(21, "span", 26);
    i0.ɵɵconditionalCreate(22, EntityListComponent_Conditional_15_Conditional_0_Conditional_22_Template, 1, 4, "i", 27)(23, EntityListComponent_Conditional_15_Conditional_0_Conditional_23_Template, 1, 0, "i", 28);
    i0.ɵɵelementEnd()();
    i0.ɵɵelementStart(24, "th", 32);
    i0.ɵɵlistener("click", function EntityListComponent_Conditional_15_Conditional_0_Template_th_click_24_listener() { i0.ɵɵrestoreView(_r4); const ctx_r1 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r1.OnSortChange("createdAt")); });
    i0.ɵɵtext(25, " Created ");
    i0.ɵɵelementStart(26, "span", 26);
    i0.ɵɵconditionalCreate(27, EntityListComponent_Conditional_15_Conditional_0_Conditional_27_Template, 1, 4, "i", 27)(28, EntityListComponent_Conditional_15_Conditional_0_Conditional_28_Template, 1, 0, "i", 28);
    i0.ɵɵelementEnd()();
    i0.ɵɵelementStart(29, "th", 33);
    i0.ɵɵtext(30, "Actions");
    i0.ɵɵelementEnd()()();
    i0.ɵɵelementStart(31, "tbody");
    i0.ɵɵrepeaterCreate(32, EntityListComponent_Conditional_15_Conditional_0_For_33_Template, 23, 6, "tr", 34, i0.ɵɵcomponentInstance().TrackByEntityId, true);
    i0.ɵɵelementEnd()()();
    i0.ɵɵelementStart(34, "div", 35);
    i0.ɵɵtext(35);
    i0.ɵɵconditionalCreate(36, EntityListComponent_Conditional_15_Conditional_0_Conditional_36_Template, 1, 1);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(7);
    i0.ɵɵconditional(ctx_r1.SortField === "entityName" ? 7 : 8);
    i0.ɵɵadvance(5);
    i0.ɵɵconditional(ctx_r1.SortField === "schemaName" ? 12 : 13);
    i0.ɵɵadvance(5);
    i0.ɵɵconditional(ctx_r1.SortField === "tableName" ? 17 : 18);
    i0.ɵɵadvance(5);
    i0.ɵɵconditional(ctx_r1.SortField === "owner" ? 22 : 23);
    i0.ɵɵadvance(5);
    i0.ɵɵconditional(ctx_r1.SortField === "createdAt" ? 27 : 28);
    i0.ɵɵadvance(5);
    i0.ɵɵrepeater(ctx_r1.FilteredEntities);
    i0.ɵɵadvance(3);
    i0.ɵɵtextInterpolate2(" ", ctx_r1.FilteredEntities.length, " ", ctx_r1.FilteredEntities.length === 1 ? "entity" : "entities", " ");
    i0.ɵɵadvance();
    i0.ɵɵconditional(ctx_r1.SearchTerm ? 36 : -1);
} }
function EntityListComponent_Conditional_15_Conditional_1_Conditional_3_Template(rf, ctx) { if (rf & 1) {
    const _r7 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "h3", 57);
    i0.ɵɵtext(1);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(2, "p", 58);
    i0.ɵɵtext(3, "Try a different search term or clear the filter.");
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(4, "button", 59);
    i0.ɵɵlistener("click", function EntityListComponent_Conditional_15_Conditional_1_Conditional_3_Template_button_click_4_listener() { i0.ɵɵrestoreView(_r7); const ctx_r1 = i0.ɵɵnextContext(3); return i0.ɵɵresetView(ctx_r1.SearchTerm = ""); });
    i0.ɵɵtext(5, " Clear search ");
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext(3);
    i0.ɵɵadvance();
    i0.ɵɵtextInterpolate1("No entities match \"", ctx_r1.SearchTerm, "\"");
} }
function EntityListComponent_Conditional_15_Conditional_1_Conditional_4_Template(rf, ctx) { if (rf & 1) {
    const _r8 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "h3", 57);
    i0.ɵɵtext(1, "No entities yet");
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(2, "p", 58);
    i0.ɵɵtext(3, " Create your first user-defined entity. You can also use the Database Designer agent in a conversation for guided design. ");
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(4, "button", 60);
    i0.ɵɵlistener("click", function EntityListComponent_Conditional_15_Conditional_1_Conditional_4_Template_button_click_4_listener() { i0.ɵɵrestoreView(_r8); const ctx_r1 = i0.ɵɵnextContext(3); return i0.ɵɵresetView(ctx_r1.OnNewEntity()); });
    i0.ɵɵelement(5, "i", 61);
    i0.ɵɵtext(6, " Create Entity ");
    i0.ɵɵelementEnd();
} }
function EntityListComponent_Conditional_15_Conditional_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 22)(1, "div", 55);
    i0.ɵɵelement(2, "i", 56);
    i0.ɵɵelementEnd();
    i0.ɵɵconditionalCreate(3, EntityListComponent_Conditional_15_Conditional_1_Conditional_3_Template, 6, 1)(4, EntityListComponent_Conditional_15_Conditional_1_Conditional_4_Template, 7, 0);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(3);
    i0.ɵɵconditional(ctx_r1.SearchTerm ? 3 : 4);
} }
function EntityListComponent_Conditional_15_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵconditionalCreate(0, EntityListComponent_Conditional_15_Conditional_0_Template, 37, 8)(1, EntityListComponent_Conditional_15_Conditional_1_Template, 5, 1, "div", 22);
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext();
    i0.ɵɵconditional(ctx_r1.FilteredEntities.length > 0 ? 0 : !ctx_r1.IsLoading ? 1 : -1);
} }
export class EntityListComponent {
    /** Emitted when the user clicks "Edit" on an entity row. */
    EditEntity = new EventEmitter();
    /** Emitted when the user clicks "View Details" on an entity row. */
    ViewEntity = new EventEmitter();
    /** Emitted when the user clicks "New Entity". */
    NewEntity = new EventEmitter();
    IsLoading = false;
    ErrorMessage = null;
    /** Full unfiltered list from the engine. */
    _allEntities = [];
    /** Public accessor for the chrome's X-of-Y badge. */
    get TotalEntityCount() {
        return this._allEntities.length;
    }
    /** Cached sorted unique schema names — recomputed only when _allEntities changes. */
    _availableFilterSchemas = [];
    /** Currently displayed (filtered + sorted) rows. */
    FilteredEntities = [];
    _search$ = new BehaviorSubject('');
    _schema$ = new BehaviorSubject('');
    _sortField$ = new BehaviorSubject('entityName');
    _sortDir$ = new BehaviorSubject('asc');
    _destroy$ = new Subject();
    cdr = inject(ChangeDetectorRef);
    // ─── Lifecycle ─────────────────────────────────────────────────────────
    ngOnInit() {
        this.setupFilter();
        this.loadEntities();
    }
    ngOnDestroy() {
        this._destroy$.next();
        this._destroy$.complete();
    }
    // ─── Template bindings ─────────────────────────────────────────────────
    get SearchTerm() { return this._search$.value; }
    set SearchTerm(v) { this._search$.next(v); }
    get SelectedSchema() { return this._schema$.value; }
    set SelectedSchema(v) { this._schema$.next(v); }
    /** Unique schema names present in the loaded entity list, sorted alphabetically. */
    get AvailableFilterSchemas() { return this._availableFilterSchemas; }
    get SortField() { return this._sortField$.value; }
    get SortDirection() { return this._sortDir$.value; }
    /** Toggle sort: same field flips direction; new field defaults to asc. */
    OnSortChange(field) {
        if (this._sortField$.value === field) {
            this._sortDir$.next(this._sortDir$.value === 'asc' ? 'desc' : 'asc');
        }
        else {
            this._sortField$.next(field);
            this._sortDir$.next('asc');
        }
    }
    OnEditEntity(entity) {
        this.EditEntity.emit(entity);
    }
    OnViewEntity(entity) {
        this.ViewEntity.emit(entity);
    }
    OnNewEntity() {
        this.NewEntity.emit();
    }
    OnRefresh() {
        DatabaseDesignerEngine.Instance.invalidateCache();
        this.loadEntities();
    }
    TrackByEntityId(_, entity) {
        return entity.entityId;
    }
    FormatDate(date) {
        return date.toLocaleDateString(undefined, { year: 'numeric', month: 'short', day: 'numeric' });
    }
    // ─── Private helpers ───────────────────────────────────────────────────
    setupFilter() {
        combineLatest([this._search$, this._schema$, this._sortField$, this._sortDir$])
            .pipe(debounceTime(150), map(([search, schema, field, dir]) => this.applyFilterAndSort(search, schema, field, dir)), takeUntil(this._destroy$))
            .subscribe(result => {
            this.FilteredEntities = result;
            this.cdr.markForCheck();
        });
    }
    async loadEntities() {
        this.IsLoading = true;
        this.ErrorMessage = null;
        this.cdr.markForCheck();
        try {
            this._allEntities = await DatabaseDesignerEngine.Instance.loadAccessibleEntities();
            this._availableFilterSchemas = [...new Set(this._allEntities.map(e => e.schemaName))].sort();
            // Trigger the combineLatest pipe to recalculate; reset schema filter if
            // the previously selected schema is no longer present in the new entity list.
            const schemas = this._availableFilterSchemas;
            if (this._schema$.value && !schemas.includes(this._schema$.value)) {
                this._schema$.next('');
            }
            else {
                this._search$.next(this._search$.value);
            }
        }
        catch (err) {
            this.ErrorMessage = err instanceof Error ? err.message : String(err);
        }
        finally {
            this.IsLoading = false;
            this.cdr.markForCheck();
        }
    }
    applyFilterAndSort(search, schema, field, dir) {
        const term = search.trim().toLowerCase();
        let results = [...this._allEntities];
        if (schema) {
            results = results.filter(e => e.schemaName === schema);
        }
        if (term) {
            results = results.filter(e => e.entityName.toLowerCase().includes(term) ||
                e.tableName.toLowerCase().includes(term) ||
                e.schemaName.toLowerCase().includes(term));
        }
        results.sort((a, b) => {
            const aVal = this.sortValue(a, field);
            const bVal = this.sortValue(b, field);
            const cmp = aVal < bVal ? -1 : aVal > bVal ? 1 : 0;
            return dir === 'asc' ? cmp : -cmp;
        });
        return results;
    }
    sortValue(entity, field) {
        switch (field) {
            case 'entityName': return entity.entityName.toLowerCase();
            case 'tableName': return entity.tableName.toLowerCase();
            case 'schemaName': return entity.schemaName.toLowerCase();
            case 'createdAt': return entity.createdAt.getTime();
            case 'owner': return entity.isOwner ? 0 : 1;
            default: return entity.entityName.toLowerCase();
        }
    }
    static ɵfac = function EntityListComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || EntityListComponent)(); };
    static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: EntityListComponent, selectors: [["mj-database-entity-list"]], outputs: { EditEntity: "EditEntity", ViewEntity: "ViewEntity", NewEntity: "NewEntity" }, standalone: false, decls: 16, vars: 9, consts: [["AriaLabel", "Database Designer", "Title", "Database Designer", "Subtitle", "Browse and create user-defined entities"], ["meta", ""], ["Label", "entities", 3, "Count", "Total"], ["actions", ""], [3, "Clicked", "Loading"], ["mjButton", "", "variant", "primary", "size", "sm", 3, "click"], ["aria-hidden", "true", 1, "fa-solid", "fa-plus"], [1, "mj-action-label"], ["toolbar", ""], ["Placeholder", "Search by name, table, or schema...", 3, "ValueChange", "Value"], ["aria-label", "Filter by schema", 1, "mj-input", "schema-filter", 3, "value"], [3, "Padding"], ["role", "alert", 1, "entity-list-error"], ["aria-busy", "true", "aria-label", "Loading entities\u2026", 1, "skeleton-table"], ["aria-label", "Filter by schema", 1, "mj-input", "schema-filter", 3, "change", "value"], ["value", ""], [3, "value"], [1, "fa-solid", "fa-circle-exclamation"], [1, "skeleton-row"], [1, "skeleton-cell", "wide"], [1, "skeleton-cell", "medium"], [1, "skeleton-cell", "narrow"], [1, "zero-state"], [1, "table-wrap"], ["role", "grid", "aria-label", "User-defined entities", 1, "entity-table"], ["scope", "col", 1, "col-name", "sortable", 3, "click"], [1, "sort-icon"], [1, "fa-solid", 3, "fa-chevron-up", "fa-chevron-down"], [1, "fa-solid", "fa-chevron-up", "muted"], ["scope", "col", 1, "col-schema", "sortable", 3, "click"], ["scope", "col", 1, "col-table", "sortable", 3, "click"], ["scope", "col", 1, "col-owner", "sortable", 3, "click"], ["scope", "col", 1, "col-created", "sortable", 3, "click"], ["scope", "col", 1, "col-actions"], [1, "entity-row"], [1, "entity-count"], [1, "fa-solid"], [1, "col-name"], [1, "entity-name-cell"], [1, "entity-name"], ["title", "You own this entity", 1, "owner-badge", "owner-you"], [1, "col-schema"], [1, "schema-badge"], [1, "col-table"], [1, "table-name"], [1, "col-owner"], [1, "owner-self"], [1, "owner-other"], [1, "owner-other", "muted"], [1, "col-created"], [1, "col-actions"], [1, "row-actions"], ["mjButton", "", "buttonStyle", "secondary", "title", "Edit this entity", 1, "action-btn", 3, "click"], [1, "fa-solid", "fa-pen-to-square"], [1, "fa-solid", "fa-user-check"], [1, "zero-state-icon"], [1, "fa-regular", "fa-rectangle-list"], [1, "zero-state-title"], [1, "zero-state-body"], ["mjButton", "", "buttonStyle", "secondary", 3, "click"], ["mjButton", "", "buttonStyle", "primary", 3, "click"], [1, "fa-solid", "fa-plus"]], template: function EntityListComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelementStart(0, "mj-page-header-interior", 0)(1, "div", 1);
            i0.ɵɵelement(2, "mj-stat-badge", 2);
            i0.ɵɵelementEnd();
            i0.ɵɵelementStart(3, "div", 3)(4, "mj-refresh-button", 4);
            i0.ɵɵlistener("Clicked", function EntityListComponent_Template_mj_refresh_button_Clicked_4_listener() { return ctx.OnRefresh(); });
            i0.ɵɵelementEnd();
            i0.ɵɵelementStart(5, "button", 5);
            i0.ɵɵlistener("click", function EntityListComponent_Template_button_click_5_listener() { return ctx.OnNewEntity(); });
            i0.ɵɵelement(6, "i", 6);
            i0.ɵɵelementStart(7, "span", 7);
            i0.ɵɵtext(8, "New Entity");
            i0.ɵɵelementEnd()()();
            i0.ɵɵelementStart(9, "div", 8)(10, "mj-page-search", 9);
            i0.ɵɵlistener("ValueChange", function EntityListComponent_Template_mj_page_search_ValueChange_10_listener($event) { return ctx.SearchTerm = $event; });
            i0.ɵɵelementEnd();
            i0.ɵɵconditionalCreate(11, EntityListComponent_Conditional_11_Template, 5, 1, "select", 10);
            i0.ɵɵelementEnd()();
            i0.ɵɵelementStart(12, "mj-page-body-interior", 11);
            i0.ɵɵconditionalCreate(13, EntityListComponent_Conditional_13_Template, 3, 1, "div", 12);
            i0.ɵɵconditionalCreate(14, EntityListComponent_Conditional_14_Template, 3, 1, "div", 13);
            i0.ɵɵconditionalCreate(15, EntityListComponent_Conditional_15_Template, 2, 1);
            i0.ɵɵelementEnd();
        } if (rf & 2) {
            i0.ɵɵadvance(2);
            i0.ɵɵproperty("Count", ctx.FilteredEntities.length)("Total", ctx.TotalEntityCount);
            i0.ɵɵadvance(2);
            i0.ɵɵproperty("Loading", ctx.IsLoading);
            i0.ɵɵadvance(6);
            i0.ɵɵproperty("Value", ctx.SearchTerm);
            i0.ɵɵadvance();
            i0.ɵɵconditional(ctx.AvailableFilterSchemas.length > 1 ? 11 : -1);
            i0.ɵɵadvance();
            i0.ɵɵproperty("Padding", false);
            i0.ɵɵadvance();
            i0.ɵɵconditional(ctx.ErrorMessage ? 13 : -1);
            i0.ɵɵadvance();
            i0.ɵɵconditional(ctx.IsLoading && ctx.FilteredEntities.length === 0 ? 14 : -1);
            i0.ɵɵadvance();
            i0.ɵɵconditional(!ctx.IsLoading || ctx.FilteredEntities.length > 0 ? 15 : -1);
        } }, dependencies: [i1.NgSelectOption, i1.ɵNgSelectMultipleOption, i2.MJButtonDirective, i2.MJPageHeaderInteriorComponent, i2.MJPageBodyInteriorComponent, i2.MJPageSearchComponent, i2.MJRefreshButtonComponent, i2.MJStatBadgeComponent], styles: ["\n\n\n\n\n\n\n\n[_nghost-%COMP%] {\n  display: flex;\n  flex-direction: column;\n  height: 100%;\n  overflow: hidden;\n  background: var(--mj-bg-page);\n}\n\n\n\n.schema-filter[_ngcontent-%COMP%] {\n  width: auto;\n  min-width: 160px;\n  max-width: 220px;\n  flex-shrink: 0;\n}\n\n\n\n\n.entity-list-error[_ngcontent-%COMP%] {\n  margin: 12px 24px;\n  padding: 10px 14px;\n  background: var(--mj-status-error-bg);\n  color: var(--mj-status-error-text);\n  border: 1px solid var(--mj-status-error-border);\n  border-radius: 6px;\n  display: flex;\n  align-items: center;\n  gap: 8px;\n  font-size: 0.875rem;\n}\n\n\n\n\n.skeleton-table[_ngcontent-%COMP%] {\n  padding: 0 24px;\n  margin-top: 8px;\n}\n\n.skeleton-row[_ngcontent-%COMP%] {\n  display: flex;\n  gap: 16px;\n  padding: 12px 0;\n  border-bottom: 1px solid var(--mj-border-subtle);\n}\n\n.skeleton-cell[_ngcontent-%COMP%] {\n  height: 18px;\n  border-radius: 4px;\n  background: var(--mj-bg-surface-sunken);\n  animation: _ngcontent-%COMP%_skeleton-pulse 1.4s ease-in-out infinite;\n}\n\n.skeleton-cell.wide[_ngcontent-%COMP%]   { flex: 3; }\n.skeleton-cell.medium[_ngcontent-%COMP%] { flex: 2; }\n.skeleton-cell.narrow[_ngcontent-%COMP%] { flex: 1; }\n\n@keyframes _ngcontent-%COMP%_skeleton-pulse {\n  0%, 100% { opacity: 1; }\n  50%       { opacity: 0.45; }\n}\n\n\n\n\n.table-wrap[_ngcontent-%COMP%] {\n  flex: 1;\n  overflow: auto;\n  padding: 0 24px;\n}\n\n\n\n\n.entity-table[_ngcontent-%COMP%] {\n  width: 100%;\n  border-collapse: collapse;\n  font-size: 0.9rem;\n}\n\n.entity-table[_ngcontent-%COMP%]   thead[_ngcontent-%COMP%]   tr[_ngcontent-%COMP%] {\n  border-bottom: 2px solid var(--mj-border-default);\n}\n\n.entity-table[_ngcontent-%COMP%]   th[_ngcontent-%COMP%] {\n  padding: 10px 12px;\n  text-align: left;\n  font-weight: 600;\n  color: var(--mj-text-secondary);\n  font-size: 0.8125rem;\n  text-transform: uppercase;\n  letter-spacing: 0.03em;\n  white-space: nowrap;\n  user-select: none;\n}\n\n.entity-table[_ngcontent-%COMP%]   th.sortable[_ngcontent-%COMP%] {\n  cursor: pointer;\n}\n\n.entity-table[_ngcontent-%COMP%]   th.sortable[_ngcontent-%COMP%]:hover {\n  color: var(--mj-text-primary);\n}\n\n.sort-icon[_ngcontent-%COMP%] {\n  display: inline-block;\n  margin-left: 5px;\n  font-size: 0.75rem;\n  vertical-align: middle;\n  min-width: 14px;\n}\n\n.sort-icon[_ngcontent-%COMP%]   .muted[_ngcontent-%COMP%] {\n  opacity: 0.3;\n}\n\n.entity-row[_ngcontent-%COMP%] {\n  border-bottom: 1px solid var(--mj-border-subtle);\n  transition: background 0.1s;\n}\n\n.entity-row[_ngcontent-%COMP%]:hover {\n  background: var(--mj-bg-surface-hover);\n}\n\n.entity-table[_ngcontent-%COMP%]   td[_ngcontent-%COMP%] {\n  padding: 12px 12px;\n  color: var(--mj-text-primary);\n  vertical-align: middle;\n}\n\n\n\n\n\n\n.entity-table[_ngcontent-%COMP%] {\n  table-layout: fixed;\n}\n\n.col-name[_ngcontent-%COMP%]    { width: 28%; }\n.col-schema[_ngcontent-%COMP%]  { width: 14%; }\n.col-table[_ngcontent-%COMP%]   { width: 18%; }\n.col-owner[_ngcontent-%COMP%]   { width: 15%; }\n.col-created[_ngcontent-%COMP%] { width: 13%; white-space: nowrap; }\n.col-actions[_ngcontent-%COMP%] { width: 12%; }\n\n\n\n\n.entity-name-cell[_ngcontent-%COMP%] {\n  display: flex;\n  align-items: center;\n  gap: 8px;\n}\n\n.entity-name[_ngcontent-%COMP%] {\n  font-weight: 500;\n  color: var(--mj-text-primary);\n}\n\n.owner-badge[_ngcontent-%COMP%] {\n  display: inline-flex;\n  align-items: center;\n  font-size: 0.7rem;\n  font-weight: 600;\n  padding: 2px 6px;\n  border-radius: 10px;\n  text-transform: uppercase;\n  letter-spacing: 0.04em;\n}\n\n.owner-badge.owner-you[_ngcontent-%COMP%] {\n  background: color-mix(in srgb, var(--mj-brand-primary) 12%, var(--mj-bg-surface));\n  color: var(--mj-brand-primary);\n}\n\n.schema-badge[_ngcontent-%COMP%] {\n  display: inline-block;\n  font-size: 0.8rem;\n  font-family: monospace;\n  padding: 2px 8px;\n  border-radius: 4px;\n  background: var(--mj-bg-surface-sunken);\n  color: var(--mj-text-secondary);\n  border: 1px solid var(--mj-border-subtle);\n}\n\ncode.table-name[_ngcontent-%COMP%] {\n  font-size: 0.8rem;\n  font-family: monospace;\n  color: var(--mj-text-secondary);\n}\n\n.owner-self[_ngcontent-%COMP%] {\n  display: inline-flex;\n  align-items: center;\n  gap: 5px;\n  color: var(--mj-brand-primary);\n  font-size: 0.875rem;\n}\n\n.owner-self[_ngcontent-%COMP%]   i[_ngcontent-%COMP%] {\n  font-size: 0.8rem;\n}\n\n.owner-other[_ngcontent-%COMP%] {\n  color: var(--mj-text-secondary);\n  font-size: 0.875rem;\n}\n\n.owner-other.muted[_ngcontent-%COMP%] {\n  color: var(--mj-text-muted);\n}\n\n\n\n\n.row-actions[_ngcontent-%COMP%] {\n  display: flex;\n  align-items: center;\n  gap: 6px;\n}\n\n.action-btn[_ngcontent-%COMP%] {\n  font-size: 0.8125rem;\n  padding: 6px 12px;\n}\n\n\n\n\n.entity-count[_ngcontent-%COMP%] {\n  padding: 10px 24px;\n  font-size: 0.8rem;\n  color: var(--mj-text-muted);\n  border-top: 1px solid var(--mj-border-subtle);\n  flex-shrink: 0;\n}\n\n\n\n\n.zero-state[_ngcontent-%COMP%] {\n  flex: 1;\n  display: flex;\n  flex-direction: column;\n  align-items: center;\n  justify-content: center;\n  padding: 60px 24px;\n  text-align: center;\n  gap: 16px;\n}\n\n.zero-state-icon[_ngcontent-%COMP%] {\n  width: 72px;\n  height: 72px;\n  border-radius: 50%;\n  background: var(--mj-bg-surface-sunken);\n  display: flex;\n  align-items: center;\n  justify-content: center;\n}\n\n.zero-state-icon[_ngcontent-%COMP%]   i[_ngcontent-%COMP%] {\n  font-size: 2rem;\n  color: var(--mj-text-muted);\n}\n\n.zero-state-title[_ngcontent-%COMP%] {\n  margin: 0;\n  font-size: 1.1rem;\n  font-weight: 600;\n  color: var(--mj-text-primary);\n}\n\n.zero-state-body[_ngcontent-%COMP%] {\n  margin: 0;\n  font-size: 0.9rem;\n  color: var(--mj-text-secondary);\n  max-width: 420px;\n  line-height: 1.6;\n  word-break: break-word;\n  overflow-wrap: break-word;\n}"], changeDetection: 0 });
}
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(EntityListComponent, [{
        type: Component,
        args: [{ standalone: false, selector: 'mj-database-entity-list', changeDetection: ChangeDetectionStrategy.OnPush, template: "<!--\n  Database Designer is a sub-page of Admin \u2192 Data & Schema's left-nav shell, so\n  per Section 9b/10 of plans/explorer-chrome-conventions.md we use the interior\n  chrome pattern instead of <mj-page-layout> + <mj-page-header> (which would\n  produce a doubled-header inside the Admin shell).\n-->\n<mj-page-header-interior\n  AriaLabel=\"Database Designer\"\n  Title=\"Database Designer\"\n  Subtitle=\"Browse and create user-defined entities\">\n  <!-- X-of-Y filtered count earns its meta spot per chrome conventions \u00A72.\n       Material on this page (~300 entities per deployment) makes the\n       narrowing signal valuable. -->\n  <div meta>\n    <mj-stat-badge\n      [Count]=\"FilteredEntities.length\"\n      [Total]=\"TotalEntityCount\"\n      Label=\"entities\">\n    </mj-stat-badge>\n  </div>\n  <div actions>\n    <mj-refresh-button [Loading]=\"IsLoading\" (Clicked)=\"OnRefresh()\"></mj-refresh-button>\n    <button mjButton variant=\"primary\" size=\"sm\" (click)=\"OnNewEntity()\">\n      <i class=\"fa-solid fa-plus\" aria-hidden=\"true\"></i> <span class=\"mj-action-label\">New Entity</span>\n    </button>\n  </div>\n  <div toolbar>\n    <mj-page-search\n      Placeholder=\"Search by name, table, or schema...\"\n      [Value]=\"SearchTerm\"\n      (ValueChange)=\"SearchTerm = $event\">\n    </mj-page-search>\n    @if (AvailableFilterSchemas.length > 1) {\n      <select\n        class=\"mj-input schema-filter\"\n        [value]=\"SelectedSchema\"\n        (change)=\"SelectedSchema = $any($event.target).value\"\n        aria-label=\"Filter by schema\">\n        <option value=\"\">All Schemas</option>\n        @for (schema of AvailableFilterSchemas; track schema) {\n          <option [value]=\"schema\">{{ schema }}</option>\n        }\n      </select>\n    }\n  </div>\n</mj-page-header-interior>\n\n<mj-page-body-interior [Padding]=\"false\">\n  <!-- \u2500\u2500 Error \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 -->\n  @if (ErrorMessage) {\n    <div class=\"entity-list-error\" role=\"alert\">\n      <i class=\"fa-solid fa-circle-exclamation\"></i>\n      {{ ErrorMessage }}\n    </div>\n  }\n\n  <!-- \u2500\u2500 Loading skeleton \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 -->\n  @if (IsLoading && FilteredEntities.length === 0) {\n    <div class=\"skeleton-table\" aria-busy=\"true\" aria-label=\"Loading entities\u2026\">\n      @for (_ of [1, 2, 3, 4]; track $index) {\n        <div class=\"skeleton-row\">\n          <div class=\"skeleton-cell wide\"></div>\n          <div class=\"skeleton-cell medium\"></div>\n          <div class=\"skeleton-cell narrow\"></div>\n          <div class=\"skeleton-cell narrow\"></div>\n          <div class=\"skeleton-cell medium\"></div>\n          <div class=\"skeleton-cell narrow\"></div>\n        </div>\n      }\n    </div>\n  }\n\n  <!-- \u2500\u2500 Entity table \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 -->\n  @if (!IsLoading || FilteredEntities.length > 0) {\n    @if (FilteredEntities.length > 0) {\n      <div class=\"table-wrap\">\n        <table class=\"entity-table\" role=\"grid\" aria-label=\"User-defined entities\">\n          <thead>\n            <tr>\n              <th class=\"col-name sortable\" (click)=\"OnSortChange('entityName')\" scope=\"col\">\n                Entity Name\n                <span class=\"sort-icon\">\n                  @if (SortField === 'entityName') {\n                    <i class=\"fa-solid\" [class.fa-chevron-up]=\"SortDirection === 'asc'\" [class.fa-chevron-down]=\"SortDirection === 'desc'\"></i>\n                  } @else {\n                    <i class=\"fa-solid fa-chevron-up muted\"></i>\n                  }\n                </span>\n              </th>\n              <th class=\"col-schema sortable\" (click)=\"OnSortChange('schemaName')\" scope=\"col\">\n                Schema\n                <span class=\"sort-icon\">\n                  @if (SortField === 'schemaName') {\n                    <i class=\"fa-solid\" [class.fa-chevron-up]=\"SortDirection === 'asc'\" [class.fa-chevron-down]=\"SortDirection === 'desc'\"></i>\n                  } @else {\n                    <i class=\"fa-solid fa-chevron-up muted\"></i>\n                  }\n                </span>\n              </th>\n              <th class=\"col-table sortable\" (click)=\"OnSortChange('tableName')\" scope=\"col\">\n                Table\n                <span class=\"sort-icon\">\n                  @if (SortField === 'tableName') {\n                    <i class=\"fa-solid\" [class.fa-chevron-up]=\"SortDirection === 'asc'\" [class.fa-chevron-down]=\"SortDirection === 'desc'\"></i>\n                  } @else {\n                    <i class=\"fa-solid fa-chevron-up muted\"></i>\n                  }\n                </span>\n              </th>\n              <th class=\"col-owner sortable\" (click)=\"OnSortChange('owner')\" scope=\"col\">\n                Owner\n                <span class=\"sort-icon\">\n                  @if (SortField === 'owner') {\n                    <i class=\"fa-solid\" [class.fa-chevron-up]=\"SortDirection === 'asc'\" [class.fa-chevron-down]=\"SortDirection === 'desc'\"></i>\n                  } @else {\n                    <i class=\"fa-solid fa-chevron-up muted\"></i>\n                  }\n                </span>\n              </th>\n              <th class=\"col-created sortable\" (click)=\"OnSortChange('createdAt')\" scope=\"col\">\n                Created\n                <span class=\"sort-icon\">\n                  @if (SortField === 'createdAt') {\n                    <i class=\"fa-solid\" [class.fa-chevron-up]=\"SortDirection === 'asc'\" [class.fa-chevron-down]=\"SortDirection === 'desc'\"></i>\n                  } @else {\n                    <i class=\"fa-solid fa-chevron-up muted\"></i>\n                  }\n                </span>\n              </th>\n              <th class=\"col-actions\" scope=\"col\">Actions</th>\n            </tr>\n          </thead>\n          <tbody>\n            @for (entity of FilteredEntities; track TrackByEntityId($index, entity)) {\n              <tr class=\"entity-row\">\n                <td class=\"col-name\">\n                  <div class=\"entity-name-cell\">\n                    <span class=\"entity-name\">{{ entity.entityName }}</span>\n                    @if (entity.isOwner) {\n                      <span class=\"owner-badge owner-you\" title=\"You own this entity\">You</span>\n                    }\n                  </div>\n                </td>\n                <td class=\"col-schema\">\n                  <span class=\"schema-badge\">{{ entity.schemaName }}</span>\n                </td>\n                <td class=\"col-table\">\n                  <code class=\"table-name\">{{ entity.tableName }}</code>\n                </td>\n                <td class=\"col-owner\">\n                  @if (entity.isOwner) {\n                    <span class=\"owner-self\">\n                      <i class=\"fa-solid fa-user-check\"></i>\n                      You\n                    </span>\n                  } @else if (entity.ownerDisplayName) {\n                    <span class=\"owner-other\">{{ entity.ownerDisplayName }}</span>\n                  } @else {\n                    <span class=\"owner-other muted\">\u2014</span>\n                  }\n                </td>\n                <td class=\"col-created\">{{ FormatDate(entity.createdAt) }}</td>\n                <td class=\"col-actions\">\n                  <div class=\"row-actions\">\n                    <button\n                      mjButton\n                      buttonStyle=\"secondary\"\n                      class=\"action-btn\"\n                      title=\"Edit this entity\"\n                      (click)=\"OnEditEntity(entity)\">\n                      <i class=\"fa-solid fa-pen-to-square\"></i>\n                      Edit\n                    </button>\n                  </div>\n                </td>\n              </tr>\n            }\n          </tbody>\n        </table>\n      </div>\n\n      <div class=\"entity-count\">\n        {{ FilteredEntities.length }} {{ FilteredEntities.length === 1 ? 'entity' : 'entities' }}\n        @if (SearchTerm) { matching \"{{ SearchTerm }}\" }\n      </div>\n    } @else if (!IsLoading) {\n      <!-- \u2500\u2500 Zero state \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 -->\n      <div class=\"zero-state\">\n        <div class=\"zero-state-icon\">\n          <i class=\"fa-regular fa-rectangle-list\"></i>\n        </div>\n        @if (SearchTerm) {\n          <h3 class=\"zero-state-title\">No entities match \"{{ SearchTerm }}\"</h3>\n          <p class=\"zero-state-body\">Try a different search term or clear the filter.</p>\n          <button mjButton buttonStyle=\"secondary\" (click)=\"SearchTerm = ''\">\n            Clear search\n          </button>\n        } @else {\n          <h3 class=\"zero-state-title\">No entities yet</h3>\n          <p class=\"zero-state-body\">\n            Create your first user-defined entity. You can also use the\n            Database Designer agent in a conversation for guided design.\n          </p>\n          <button mjButton buttonStyle=\"primary\" (click)=\"OnNewEntity()\">\n            <i class=\"fa-solid fa-plus\"></i>\n            Create Entity\n          </button>\n        }\n      </div>\n    }\n  }\n</mj-page-body-interior>\n", styles: ["/*\n  Database Designer entity-list \u2014 sub-page of Admin \u2192 Data & Schema. Host is a\n  flex column so <mj-page-header-interior> pins at the top and <mj-page-body-interior>\n  fills the rest. The body primitive owns its own flex/scroll/padding \u2014 this\n  component just needs the host-level layout. See Section 10 of\n  plans/explorer-chrome-conventions.md.\n*/\n:host {\n  display: flex;\n  flex-direction: column;\n  height: 100%;\n  overflow: hidden;\n  background: var(--mj-bg-page);\n}\n\n/* Schema filter used in the [toolbar] slot. */\n.schema-filter {\n  width: auto;\n  min-width: 160px;\n  max-width: 220px;\n  flex-shrink: 0;\n}\n\n/* \u2500\u2500 Error banner \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n\n.entity-list-error {\n  margin: 12px 24px;\n  padding: 10px 14px;\n  background: var(--mj-status-error-bg);\n  color: var(--mj-status-error-text);\n  border: 1px solid var(--mj-status-error-border);\n  border-radius: 6px;\n  display: flex;\n  align-items: center;\n  gap: 8px;\n  font-size: 0.875rem;\n}\n\n/* \u2500\u2500 Skeleton loader \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n\n.skeleton-table {\n  padding: 0 24px;\n  margin-top: 8px;\n}\n\n.skeleton-row {\n  display: flex;\n  gap: 16px;\n  padding: 12px 0;\n  border-bottom: 1px solid var(--mj-border-subtle);\n}\n\n.skeleton-cell {\n  height: 18px;\n  border-radius: 4px;\n  background: var(--mj-bg-surface-sunken);\n  animation: skeleton-pulse 1.4s ease-in-out infinite;\n}\n\n.skeleton-cell.wide   { flex: 3; }\n.skeleton-cell.medium { flex: 2; }\n.skeleton-cell.narrow { flex: 1; }\n\n@keyframes skeleton-pulse {\n  0%, 100% { opacity: 1; }\n  50%       { opacity: 0.45; }\n}\n\n/* \u2500\u2500 Table wrap \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n\n.table-wrap {\n  flex: 1;\n  overflow: auto;\n  padding: 0 24px;\n}\n\n/* \u2500\u2500 Entity table \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n\n.entity-table {\n  width: 100%;\n  border-collapse: collapse;\n  font-size: 0.9rem;\n}\n\n.entity-table thead tr {\n  border-bottom: 2px solid var(--mj-border-default);\n}\n\n.entity-table th {\n  padding: 10px 12px;\n  text-align: left;\n  font-weight: 600;\n  color: var(--mj-text-secondary);\n  font-size: 0.8125rem;\n  text-transform: uppercase;\n  letter-spacing: 0.03em;\n  white-space: nowrap;\n  user-select: none;\n}\n\n.entity-table th.sortable {\n  cursor: pointer;\n}\n\n.entity-table th.sortable:hover {\n  color: var(--mj-text-primary);\n}\n\n.sort-icon {\n  display: inline-block;\n  margin-left: 5px;\n  font-size: 0.75rem;\n  vertical-align: middle;\n  min-width: 14px;\n}\n\n.sort-icon .muted {\n  opacity: 0.3;\n}\n\n.entity-row {\n  border-bottom: 1px solid var(--mj-border-subtle);\n  transition: background 0.1s;\n}\n\n.entity-row:hover {\n  background: var(--mj-bg-surface-hover);\n}\n\n.entity-table td {\n  padding: 12px 12px;\n  color: var(--mj-text-primary);\n  vertical-align: middle;\n}\n\n/* \u2500\u2500 Column sizing \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n/* Fixed layout \u2014 percentages for content columns, px only for utility columns */\n\n.entity-table {\n  table-layout: fixed;\n}\n\n.col-name    { width: 28%; }\n.col-schema  { width: 14%; }\n.col-table   { width: 18%; }\n.col-owner   { width: 15%; }\n.col-created { width: 13%; white-space: nowrap; }\n.col-actions { width: 12%; }\n\n/* \u2500\u2500 Cell content \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n\n.entity-name-cell {\n  display: flex;\n  align-items: center;\n  gap: 8px;\n}\n\n.entity-name {\n  font-weight: 500;\n  color: var(--mj-text-primary);\n}\n\n.owner-badge {\n  display: inline-flex;\n  align-items: center;\n  font-size: 0.7rem;\n  font-weight: 600;\n  padding: 2px 6px;\n  border-radius: 10px;\n  text-transform: uppercase;\n  letter-spacing: 0.04em;\n}\n\n.owner-badge.owner-you {\n  background: color-mix(in srgb, var(--mj-brand-primary) 12%, var(--mj-bg-surface));\n  color: var(--mj-brand-primary);\n}\n\n.schema-badge {\n  display: inline-block;\n  font-size: 0.8rem;\n  font-family: monospace;\n  padding: 2px 8px;\n  border-radius: 4px;\n  background: var(--mj-bg-surface-sunken);\n  color: var(--mj-text-secondary);\n  border: 1px solid var(--mj-border-subtle);\n}\n\ncode.table-name {\n  font-size: 0.8rem;\n  font-family: monospace;\n  color: var(--mj-text-secondary);\n}\n\n.owner-self {\n  display: inline-flex;\n  align-items: center;\n  gap: 5px;\n  color: var(--mj-brand-primary);\n  font-size: 0.875rem;\n}\n\n.owner-self i {\n  font-size: 0.8rem;\n}\n\n.owner-other {\n  color: var(--mj-text-secondary);\n  font-size: 0.875rem;\n}\n\n.owner-other.muted {\n  color: var(--mj-text-muted);\n}\n\n/* \u2500\u2500 Row actions \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n\n.row-actions {\n  display: flex;\n  align-items: center;\n  gap: 6px;\n}\n\n.action-btn {\n  font-size: 0.8125rem;\n  padding: 6px 12px;\n}\n\n/* \u2500\u2500 Row count footer \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n\n.entity-count {\n  padding: 10px 24px;\n  font-size: 0.8rem;\n  color: var(--mj-text-muted);\n  border-top: 1px solid var(--mj-border-subtle);\n  flex-shrink: 0;\n}\n\n/* \u2500\u2500 Zero state \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n\n.zero-state {\n  flex: 1;\n  display: flex;\n  flex-direction: column;\n  align-items: center;\n  justify-content: center;\n  padding: 60px 24px;\n  text-align: center;\n  gap: 16px;\n}\n\n.zero-state-icon {\n  width: 72px;\n  height: 72px;\n  border-radius: 50%;\n  background: var(--mj-bg-surface-sunken);\n  display: flex;\n  align-items: center;\n  justify-content: center;\n}\n\n.zero-state-icon i {\n  font-size: 2rem;\n  color: var(--mj-text-muted);\n}\n\n.zero-state-title {\n  margin: 0;\n  font-size: 1.1rem;\n  font-weight: 600;\n  color: var(--mj-text-primary);\n}\n\n.zero-state-body {\n  margin: 0;\n  font-size: 0.9rem;\n  color: var(--mj-text-secondary);\n  max-width: 420px;\n  line-height: 1.6;\n  word-break: break-word;\n  overflow-wrap: break-word;\n}\n"] }]
    }], null, { EditEntity: [{
            type: Output
        }], ViewEntity: [{
            type: Output
        }], NewEntity: [{
            type: Output
        }] }); })();
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(EntityListComponent, { className: "EntityListComponent", filePath: "src/DatabaseDesigner/components/entity-list.component.ts", lineNumber: 32 }); })();
//# sourceMappingURL=entity-list.component.js.map