/**
 * @module step-relationships.component
 * @description Step 3 — optional foreign key relationship definitions.
 *
 * Presents one card per FK row. Each card has cascading dropdowns:
 *   Source Column → Target Schema → Target Table → Target Column → FK Type
 *
 * All FK target data comes from `Metadata.Entities` (already in-memory at login),
 * so every dropdown is synchronous — no async loading needed.
 *
 * Phase C: FK source columns are no longer restricted to UUID type — any column
 * may be used as a FK source.  When the user selects a target column, the
 * component reads its SQL type and auto-selects the first source column whose
 * type matches, improving UX and preventing silent type mismatches.
 */
import { EventEmitter } from '@angular/core';
import { EntityInfo } from '@memberjunction/core';
import type { ColumnSpec, ForeignKeySpec } from '../../../database-designer.types.js';
import * as i0 from "@angular/core";
/** Target entity column with its SQL type — used for source-column auto-matching. */
export interface EntityColumnInfo {
    Name: string;
    /** SQL type string from EntityInfo.Fields (e.g. 'uniqueidentifier', 'int', 'nvarchar'). */
    SqlType: string;
}
/** Internal per-row state — carries the resolved entityId alongside the FK spec. */
interface FkRowState extends ForeignKeySpec {
    rowIndex: number;
    /** EntityInfo.ID of the selected target entity — used to look up columns. */
    selectedEntityId: string;
    /** SQL type of the selected target column — used for source-column auto-matching. */
    referencedColumnType?: string;
}
export declare class StepRelationshipsComponent {
    private readonly cdr;
    InitialForeignKeys: ForeignKeySpec[];
    AvailableColumns: ColumnSpec[];
    readonly ForeignKeysChanged: EventEmitter<ForeignKeySpec[]>;
    /** All Step 2 columns are valid FK source candidates (not just UUID). */
    get AllColumns(): ColumnSpec[];
    /**
     * Sorted schema names present in Metadata.Entities, excluding blocked schemas.
     * `MJ: Schema Info` only surfaces MJ-registered schemas, so __mj is the only
     * schema that needs filtering here.
     */
    get AvailableSchemas(): string[];
    /** Entities that belong to the given schema, sorted by BaseTable. */
    EntitiesForSchema(schemaName: string): EntityInfo[];
    /**
     * Physical columns for the entity identified by `entityId`, including SQL type info.
     * Returns `EntityColumnInfo[]` so the template can display `Name (SqlType)` and
     * the component can auto-match source columns by type.
     */
    ColumnsForEntity(entityId: string): EntityColumnInfo[];
    TablePlaceholder(row: FkRowState): string;
    ColumnPlaceholder(row: FkRowState): string;
    rows: FkRowState[];
    OnSchemaChange(rowIndex: number, schema: string): void;
    OnTableChange(rowIndex: number, entityId: string): void;
    /** "CustomerOrders" → "CustomerOrderID"; "People" → "PersonID". Best-effort singularizer. */
    private defaultFkColumnName;
    /**
     * Handle target-column selection.  Reads the column's SQL type, stores it in row
     * state, then auto-selects the first source column whose (normalised) type matches.
     */
    OnColumnChange(rowIndex: number, column: string, entityId: string): void;
    OnSourceColumnChange(rowIndex: number, column: string): void;
    OnFkTypeChange(rowIndex: number, isSoft: boolean): void;
    AddRelationship(): void;
    DeleteRow(index: number): void;
    InitFromForeignKeys(fks: ForeignKeySpec[]): void;
    private buildRowState;
    TrackByIndex(_: number, row: FkRowState): number;
    /**
     * Find the first Step 2 source column whose SQL type matches `targetSqlType`.
     * Type comparison is case-insensitive and ignores length/precision qualifiers
     * (e.g. `NVARCHAR(255)` normalises to `NVARCHAR`).
     *
     * Returns `undefined` when no match is found so the caller can decide whether
     * to leave the existing selection untouched.
     */
    private findMatchingSourceColumn;
    private emit;
    static ɵfac: i0.ɵɵFactoryDeclaration<StepRelationshipsComponent, never>;
    static ɵcmp: i0.ɵɵComponentDeclaration<StepRelationshipsComponent, "mj-entity-step-relationships", never, { "InitialForeignKeys": { "alias": "InitialForeignKeys"; "required": false; }; "AvailableColumns": { "alias": "AvailableColumns"; "required": false; }; }, { "ForeignKeysChanged": "ForeignKeysChanged"; }, never, never, false, never>;
}
export {};
//# sourceMappingURL=step-relationships.component.d.ts.map