/**
 * @module step-review.component
 * @description Step 4 wrapper — hosts EntityReviewPanelComponent.
 * Also renders server-side validation errors returned from ValidateSchema().
 */
import { Component, Input, ChangeDetectionStrategy } from '@angular/core';
import { generateERDFromTableSpec } from '../../../database-designer-erd.js';
import * as i0 from "@angular/core";
import * as i1 from "@memberjunction/ng-markdown";
import * as i2 from "../../shared/entity-review-panel.component";
function StepReviewComponent_Conditional_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 1);
    i0.ɵɵelement(1, "i", 7);
    i0.ɵɵtext(2, " Validating schema\u2026 ");
    i0.ɵɵelementEnd();
} }
function StepReviewComponent_Conditional_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 2);
    i0.ɵɵelement(1, "i", 8);
    i0.ɵɵtext(2, " Schema validated \u2014 review the definition below, then click ");
    i0.ɵɵelementStart(3, "strong");
    i0.ɵɵtext(4, "Create Entity");
    i0.ɵɵelementEnd();
    i0.ɵɵtext(5, " to build it. ");
    i0.ɵɵelementEnd();
} }
function StepReviewComponent_Conditional_3_For_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 9);
    i0.ɵɵelement(1, "i", 10);
    i0.ɵɵtext(2);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const err_r1 = ctx.$implicit;
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate1(" ", err_r1, " ");
} }
function StepReviewComponent_Conditional_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 3);
    i0.ɵɵrepeaterCreate(1, StepReviewComponent_Conditional_3_For_2_Template, 3, 1, "div", 9, i0.ɵɵrepeaterTrackByIndex);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext();
    i0.ɵɵadvance();
    i0.ɵɵrepeater(ctx_r1.ValidationErrors);
} }
function StepReviewComponent_Conditional_4_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "p", 4);
    i0.ɵɵtext(1);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext();
    i0.ɵɵadvance();
    i0.ɵɵtextInterpolate(ctx_r1.TableDefinition.Description);
} }
function StepReviewComponent_Conditional_6_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 6);
    i0.ɵɵelement(1, "mj-markdown", 11);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext();
    i0.ɵɵadvance();
    i0.ɵɵproperty("data", ctx_r1.ERDMermaidBlock);
} }
export class StepReviewComponent {
    TableDefinition = {};
    ValidationErrors = [];
    IsValidating = false;
    get AsEntityTableSpec() {
        const td = this.TableDefinition;
        if (!td.EntityName || !td.TableName || !td.SchemaName)
            return null;
        return td;
    }
    get ERDMermaidBlock() {
        const spec = this.AsEntityTableSpec;
        if (!spec)
            return null;
        const erd = generateERDFromTableSpec([spec]);
        if (!erd)
            return null;
        return `\`\`\`mermaid\n${erd}\n\`\`\``;
    }
    static ɵfac = function StepReviewComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || StepReviewComponent)(); };
    static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: StepReviewComponent, selectors: [["mj-entity-step-review"]], inputs: { TableDefinition: "TableDefinition", ValidationErrors: "ValidationErrors", IsValidating: "IsValidating" }, standalone: false, decls: 7, vars: 5, consts: [[1, "step-review"], [1, "step-banner", "step-banner-validating"], [1, "step-banner", "step-banner-success"], [1, "step-banner", "step-banner-error"], [1, "entity-description"], ["ModificationType", "create", 3, "TableDefinition"], [1, "erd-container"], [1, "fa-solid", "fa-spinner", "fa-spin"], [1, "fa-solid", "fa-circle-check"], [1, "banner-err-item"], [1, "fa-solid", "fa-triangle-exclamation"], [3, "data"]], template: function StepReviewComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelementStart(0, "div", 0);
            i0.ɵɵconditionalCreate(1, StepReviewComponent_Conditional_1_Template, 3, 0, "div", 1)(2, StepReviewComponent_Conditional_2_Template, 6, 0, "div", 2);
            i0.ɵɵconditionalCreate(3, StepReviewComponent_Conditional_3_Template, 3, 0, "div", 3);
            i0.ɵɵconditionalCreate(4, StepReviewComponent_Conditional_4_Template, 2, 1, "p", 4);
            i0.ɵɵelement(5, "mj-database-review-panel", 5);
            i0.ɵɵconditionalCreate(6, StepReviewComponent_Conditional_6_Template, 2, 1, "div", 6);
            i0.ɵɵelementEnd();
        } if (rf & 2) {
            i0.ɵɵadvance();
            i0.ɵɵconditional(ctx.IsValidating ? 1 : ctx.ValidationErrors.length === 0 && ctx.AsEntityTableSpec ? 2 : -1);
            i0.ɵɵadvance(2);
            i0.ɵɵconditional(ctx.ValidationErrors.length > 0 ? 3 : -1);
            i0.ɵɵadvance();
            i0.ɵɵconditional(ctx.TableDefinition.Description ? 4 : -1);
            i0.ɵɵadvance();
            i0.ɵɵproperty("TableDefinition", ctx.AsEntityTableSpec);
            i0.ɵɵadvance();
            i0.ɵɵconditional(ctx.ERDMermaidBlock ? 6 : -1);
        } }, dependencies: [i1.MarkdownComponent, i2.EntityReviewPanelComponent], styles: [".step-banner[_ngcontent-%COMP%] {\n            display: flex; flex-direction: column; gap: 6px;\n            padding: 12px 16px;\n            font-size: 0.875rem;\n            border-bottom: 1px solid var(--mj-border-subtle);\n        }\n        .step-banner-validating[_ngcontent-%COMP%] {\n            flex-direction: row; align-items: center; gap: 10px;\n            color: var(--mj-text-secondary);\n        }\n        .step-banner-success[_ngcontent-%COMP%] {\n            flex-direction: row; align-items: center; gap: 10px;\n            color: var(--mj-status-success-text);\n            background: var(--mj-status-success-bg);\n            border-color: var(--mj-status-success-border);\n        }\n        .step-banner-error[_ngcontent-%COMP%] {\n            background: var(--mj-status-error-bg);\n            border-color: var(--mj-status-error-border);\n        }\n        .banner-err-item[_ngcontent-%COMP%] {\n            display: flex; align-items: flex-start; gap: 8px;\n            color: var(--mj-status-error-text);\n        }\n        .entity-description[_ngcontent-%COMP%] {\n            margin: 12px 16px 0;\n            font-size: 0.875rem;\n            color: var(--mj-text-secondary);\n            line-height: 1.5;\n        }\n        .erd-container[_ngcontent-%COMP%] {\n            padding: 0 16px 12px;\n        }"], changeDetection: 0 });
}
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(StepReviewComponent, [{
        type: Component,
        args: [{ standalone: false, selector: 'mj-entity-step-review', changeDetection: ChangeDetectionStrategy.OnPush, template: "<div class=\"step-review\">\n\n  @if (IsValidating) {\n    <div class=\"step-banner step-banner-validating\">\n      <i class=\"fa-solid fa-spinner fa-spin\"></i>\n      Validating schema\u2026\n    </div>\n  } @else if (ValidationErrors.length === 0 && AsEntityTableSpec) {\n    <div class=\"step-banner step-banner-success\">\n      <i class=\"fa-solid fa-circle-check\"></i>\n      Schema validated \u2014 review the definition below, then click <strong>Create Entity</strong> to build it.\n    </div>\n  }\n\n  @if (ValidationErrors.length > 0) {\n    <div class=\"step-banner step-banner-error\">\n      @for (err of ValidationErrors; track $index) {\n        <div class=\"banner-err-item\">\n          <i class=\"fa-solid fa-triangle-exclamation\"></i>\n          {{ err }}\n        </div>\n      }\n    </div>\n  }\n\n  @if (TableDefinition.Description) {\n    <p class=\"entity-description\">{{ TableDefinition.Description }}</p>\n  }\n\n  <mj-database-review-panel\n    [TableDefinition]=\"AsEntityTableSpec\"\n    ModificationType=\"create\">\n  </mj-database-review-panel>\n\n  @if (ERDMermaidBlock) {\n    <div class=\"erd-container\">\n      <mj-markdown [data]=\"ERDMermaidBlock\"></mj-markdown>\n    </div>\n  }\n\n</div>\n", styles: ["\n        .step-banner {\n            display: flex; flex-direction: column; gap: 6px;\n            padding: 12px 16px;\n            font-size: 0.875rem;\n            border-bottom: 1px solid var(--mj-border-subtle);\n        }\n        .step-banner-validating {\n            flex-direction: row; align-items: center; gap: 10px;\n            color: var(--mj-text-secondary);\n        }\n        .step-banner-success {\n            flex-direction: row; align-items: center; gap: 10px;\n            color: var(--mj-status-success-text);\n            background: var(--mj-status-success-bg);\n            border-color: var(--mj-status-success-border);\n        }\n        .step-banner-error {\n            background: var(--mj-status-error-bg);\n            border-color: var(--mj-status-error-border);\n        }\n        .banner-err-item {\n            display: flex; align-items: flex-start; gap: 8px;\n            color: var(--mj-status-error-text);\n        }\n        .entity-description {\n            margin: 12px 16px 0;\n            font-size: 0.875rem;\n            color: var(--mj-text-secondary);\n            line-height: 1.5;\n        }\n        .erd-container {\n            padding: 0 16px 12px;\n        }\n    "] }]
    }], null, { TableDefinition: [{
            type: Input
        }], ValidationErrors: [{
            type: Input
        }], IsValidating: [{
            type: Input
        }] }); })();
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(StepReviewComponent, { className: "StepReviewComponent", filePath: "src/DatabaseDesigner/components/create-wizard/steps/step-review.component.ts", lineNumber: 52 }); })();
//# sourceMappingURL=step-review.component.js.map