import { Component, Input, Output, EventEmitter, ChangeDetectionStrategy, ChangeDetectorRef, inject, } from '@angular/core';
import { CommonModule } from '@angular/common';
import { BaseAngularComponent } from '@memberjunction/ng-base-types';
import * as i0 from "@angular/core";
const _forTrack0 = ($index, $item) => $item.ID;
function FormOverrideDialogComponent_Conditional_0_Conditional_9_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵtext(0, " Update the override's name, description, scope, priority, or status. Component code is edited from the cockpit's main editor \u2014 this dialog covers the override-row metadata only. ");
} }
function FormOverrideDialogComponent_Conditional_0_Conditional_10_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵtext(0, " Create an Entity Form Override so MemberJunction renders this Component instead of the default form for matching users. Skip to keep the Component saved but inactive. ");
} }
function FormOverrideDialogComponent_Conditional_0_Conditional_39_For_4_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵdomElementStart(0, "option", 28);
    i0.ɵɵtext(1);
    i0.ɵɵdomElementEnd();
} if (rf & 2) {
    const r_r4 = ctx.$implicit;
    i0.ɵɵdomProperty("value", r_r4.ID);
    i0.ɵɵadvance();
    i0.ɵɵtextInterpolate(r_r4.Name);
} }
function FormOverrideDialogComponent_Conditional_0_Conditional_39_Template(rf, ctx) { if (rf & 1) {
    const _r3 = i0.ɵɵgetCurrentView();
    i0.ɵɵdomElementStart(0, "select", 26);
    i0.ɵɵdomListener("change", function FormOverrideDialogComponent_Conditional_0_Conditional_39_Template_select_change_0_listener($event) { i0.ɵɵrestoreView(_r3); const ctx_r1 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r1.OnRoleChanged($event)); });
    i0.ɵɵdomElementStart(1, "option", 27);
    i0.ɵɵtext(2, "\u2014 pick a role \u2014");
    i0.ɵɵdomElementEnd();
    i0.ɵɵrepeaterCreate(3, FormOverrideDialogComponent_Conditional_0_Conditional_39_For_4_Template, 2, 2, "option", 28, _forTrack0);
    i0.ɵɵdomElementEnd();
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext(2);
    i0.ɵɵdomProperty("value", ctx_r1.RoleID ?? "");
    i0.ɵɵadvance(3);
    i0.ɵɵrepeater(ctx_r1.availableRoles);
} }
function FormOverrideDialogComponent_Conditional_0_Conditional_65_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵdomElementStart(0, "div", 22);
    i0.ɵɵtext(1);
    i0.ɵɵdomElementEnd();
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance();
    i0.ɵɵtextInterpolate(ctx_r1.validationError);
} }
function FormOverrideDialogComponent_Conditional_0_Template(rf, ctx) { if (rf & 1) {
    const _r1 = i0.ɵɵgetCurrentView();
    i0.ɵɵdomElementStart(0, "div", 1);
    i0.ɵɵdomListener("click", function FormOverrideDialogComponent_Conditional_0_Template_div_click_0_listener() { i0.ɵɵrestoreView(_r1); const ctx_r1 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r1.OnCancelClick()); });
    i0.ɵɵdomElementStart(1, "div", 2);
    i0.ɵɵdomListener("click", function FormOverrideDialogComponent_Conditional_0_Template_div_click_1_listener($event) { i0.ɵɵrestoreView(_r1); return i0.ɵɵresetView($event.stopPropagation()); });
    i0.ɵɵdomElementStart(2, "header", 3)(3, "h3");
    i0.ɵɵtext(4);
    i0.ɵɵdomElementEnd();
    i0.ɵɵdomElementStart(5, "button", 4);
    i0.ɵɵdomListener("click", function FormOverrideDialogComponent_Conditional_0_Template_button_click_5_listener() { i0.ɵɵrestoreView(_r1); const ctx_r1 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r1.OnCancelClick()); });
    i0.ɵɵdomElement(6, "i", 5);
    i0.ɵɵdomElementEnd()();
    i0.ɵɵdomElementStart(7, "div", 6)(8, "p", 7);
    i0.ɵɵconditionalCreate(9, FormOverrideDialogComponent_Conditional_0_Conditional_9_Template, 1, 0)(10, FormOverrideDialogComponent_Conditional_0_Conditional_10_Template, 1, 0);
    i0.ɵɵdomElementEnd();
    i0.ɵɵdomElementStart(11, "div", 8)(12, "label");
    i0.ɵɵtext(13, "Override Name");
    i0.ɵɵdomElementEnd();
    i0.ɵɵdomElementStart(14, "input", 9);
    i0.ɵɵdomListener("input", function FormOverrideDialogComponent_Conditional_0_Template_input_input_14_listener($event) { i0.ɵɵrestoreView(_r1); const ctx_r1 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r1.OnNameInput($event)); });
    i0.ɵɵdomElementEnd()();
    i0.ɵɵdomElementStart(15, "div", 8)(16, "label");
    i0.ɵɵtext(17, "Description");
    i0.ɵɵdomElementEnd();
    i0.ɵɵdomElementStart(18, "textarea", 10);
    i0.ɵɵdomListener("input", function FormOverrideDialogComponent_Conditional_0_Template_textarea_input_18_listener($event) { i0.ɵɵrestoreView(_r1); const ctx_r1 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r1.OnDescriptionInput($event)); });
    i0.ɵɵdomElementEnd()();
    i0.ɵɵdomElementStart(19, "div", 8)(20, "label");
    i0.ɵɵtext(21, "Notes");
    i0.ɵɵdomElementEnd();
    i0.ɵɵdomElementStart(22, "textarea", 11);
    i0.ɵɵdomListener("input", function FormOverrideDialogComponent_Conditional_0_Template_textarea_input_22_listener($event) { i0.ɵɵrestoreView(_r1); const ctx_r1 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r1.OnNotesInput($event)); });
    i0.ɵɵdomElementEnd()();
    i0.ɵɵdomElementStart(23, "div", 8)(24, "label");
    i0.ɵɵtext(25, "Entity");
    i0.ɵɵdomElementEnd();
    i0.ɵɵdomElement(26, "input", 12);
    i0.ɵɵdomElementStart(27, "small", 13);
    i0.ɵɵtext(28, "Set in the Field Binding inspector.");
    i0.ɵɵdomElementEnd()();
    i0.ɵɵdomElementStart(29, "div", 8)(30, "label");
    i0.ɵɵtext(31, "Scope");
    i0.ɵɵdomElementEnd();
    i0.ɵɵdomElementStart(32, "div", 14)(33, "label", 15)(34, "input", 16);
    i0.ɵɵdomListener("change", function FormOverrideDialogComponent_Conditional_0_Template_input_change_34_listener() { i0.ɵɵrestoreView(_r1); const ctx_r1 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r1.OnScopeChange("User")); });
    i0.ɵɵdomElementEnd();
    i0.ɵɵtext(35, " Me only (User) ");
    i0.ɵɵdomElementEnd();
    i0.ɵɵdomElementStart(36, "label", 15)(37, "input", 16);
    i0.ɵɵdomListener("change", function FormOverrideDialogComponent_Conditional_0_Template_input_change_37_listener() { i0.ɵɵrestoreView(_r1); const ctx_r1 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r1.OnScopeChange("Role")); });
    i0.ɵɵdomElementEnd();
    i0.ɵɵtext(38, " A role ");
    i0.ɵɵdomElementEnd();
    i0.ɵɵconditionalCreate(39, FormOverrideDialogComponent_Conditional_0_Conditional_39_Template, 5, 1, "select", 17);
    i0.ɵɵdomElementStart(40, "label", 15)(41, "input", 16);
    i0.ɵɵdomListener("change", function FormOverrideDialogComponent_Conditional_0_Template_input_change_41_listener() { i0.ɵɵrestoreView(_r1); const ctx_r1 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r1.OnScopeChange("Global")); });
    i0.ɵɵdomElementEnd();
    i0.ɵɵtext(42, " Everyone (Global) ");
    i0.ɵɵdomElementEnd()()();
    i0.ɵɵdomElementStart(43, "div", 18)(44, "div", 8)(45, "label");
    i0.ɵɵtext(46, "Priority");
    i0.ɵɵdomElementEnd();
    i0.ɵɵdomElementStart(47, "input", 19);
    i0.ɵɵdomListener("input", function FormOverrideDialogComponent_Conditional_0_Template_input_input_47_listener($event) { i0.ɵɵrestoreView(_r1); const ctx_r1 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r1.OnPriorityInput($event)); });
    i0.ɵɵdomElementEnd()();
    i0.ɵɵdomElementStart(48, "div", 8)(49, "label");
    i0.ɵɵtext(50, "Status");
    i0.ɵɵdomElementEnd();
    i0.ɵɵdomElementStart(51, "div", 20)(52, "label", 15)(53, "input", 21);
    i0.ɵɵdomListener("change", function FormOverrideDialogComponent_Conditional_0_Template_input_change_53_listener() { i0.ɵɵrestoreView(_r1); const ctx_r1 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r1.Status = "Pending"); });
    i0.ɵɵdomElementEnd();
    i0.ɵɵtext(54, " Pending ");
    i0.ɵɵdomElementStart(55, "span", 13);
    i0.ɵɵtext(56, "(draft)");
    i0.ɵɵdomElementEnd()();
    i0.ɵɵdomElementStart(57, "label", 15)(58, "input", 21);
    i0.ɵɵdomListener("change", function FormOverrideDialogComponent_Conditional_0_Template_input_change_58_listener() { i0.ɵɵrestoreView(_r1); const ctx_r1 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r1.Status = "Active"); });
    i0.ɵɵdomElementEnd();
    i0.ɵɵtext(59, " Active ");
    i0.ɵɵdomElementStart(60, "span", 13);
    i0.ɵɵtext(61, "(live)");
    i0.ɵɵdomElementEnd()();
    i0.ɵɵdomElementStart(62, "label", 15)(63, "input", 21);
    i0.ɵɵdomListener("change", function FormOverrideDialogComponent_Conditional_0_Template_input_change_63_listener() { i0.ɵɵrestoreView(_r1); const ctx_r1 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r1.Status = "Inactive"); });
    i0.ɵɵdomElementEnd();
    i0.ɵɵtext(64, " Inactive ");
    i0.ɵɵdomElementEnd()()()();
    i0.ɵɵconditionalCreate(65, FormOverrideDialogComponent_Conditional_0_Conditional_65_Template, 2, 1, "div", 22);
    i0.ɵɵdomElementEnd();
    i0.ɵɵdomElementStart(66, "footer", 23)(67, "button", 24);
    i0.ɵɵdomListener("click", function FormOverrideDialogComponent_Conditional_0_Template_button_click_67_listener() { i0.ɵɵrestoreView(_r1); const ctx_r1 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r1.OnConfirmClick()); });
    i0.ɵɵtext(68);
    i0.ɵɵdomElementEnd();
    i0.ɵɵdomElementStart(69, "button", 25);
    i0.ɵɵdomListener("click", function FormOverrideDialogComponent_Conditional_0_Template_button_click_69_listener() { i0.ɵɵrestoreView(_r1); const ctx_r1 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r1.OnCancelClick()); });
    i0.ɵɵtext(70);
    i0.ɵɵdomElementEnd()()()();
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext();
    i0.ɵɵadvance(4);
    i0.ɵɵtextInterpolate(ctx_r1.EditMode ? "Edit form details" : "Activate this form");
    i0.ɵɵadvance(5);
    i0.ɵɵconditional(ctx_r1.EditMode ? 9 : 10);
    i0.ɵɵadvance(5);
    i0.ɵɵdomProperty("value", ctx_r1.Name);
    i0.ɵɵadvance(4);
    i0.ɵɵdomProperty("value", ctx_r1.Description ?? "");
    i0.ɵɵadvance(4);
    i0.ɵɵdomProperty("value", ctx_r1.Notes ?? "");
    i0.ɵɵadvance(4);
    i0.ɵɵdomProperty("value", ctx_r1.EntityName);
    i0.ɵɵadvance(8);
    i0.ɵɵdomProperty("checked", ctx_r1.Scope === "User");
    i0.ɵɵadvance(3);
    i0.ɵɵdomProperty("checked", ctx_r1.Scope === "Role");
    i0.ɵɵadvance(2);
    i0.ɵɵconditional(ctx_r1.Scope === "Role" ? 39 : -1);
    i0.ɵɵadvance(2);
    i0.ɵɵdomProperty("checked", ctx_r1.Scope === "Global");
    i0.ɵɵadvance(6);
    i0.ɵɵdomProperty("value", ctx_r1.Priority);
    i0.ɵɵadvance(6);
    i0.ɵɵdomProperty("checked", ctx_r1.Status === "Pending");
    i0.ɵɵadvance(5);
    i0.ɵɵdomProperty("checked", ctx_r1.Status === "Active");
    i0.ɵɵadvance(5);
    i0.ɵɵdomProperty("checked", ctx_r1.Status === "Inactive");
    i0.ɵɵadvance(2);
    i0.ɵɵconditional(ctx_r1.validationError ? 65 : -1);
    i0.ɵɵadvance(3);
    i0.ɵɵtextInterpolate(ctx_r1.EditMode ? "Save changes" : "Create Override");
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate(ctx_r1.EditMode ? "Cancel" : "Skip");
} }
/**
 * Modal shown after a form-role Component is saved. Lets the author create
 * an `EntityFormOverride` row pointing the just-saved Component at an
 * entity for User / Role / Global scope. Skip exits without persisting —
 * useful when authoring a Component that isn't ready to be activated.
 *
 * The dialog only collects intent. The dashboard wires the confirm event
 * to the write call (currently blocked on the EntityFormOverrideEntity
 * generated class; see Tasks 3 + 15).
 */
export class FormOverrideDialogComponent extends BaseAngularComponent {
    /**
     * Plain `@Input()`. Per-open re-sync of editable state happens in
     * `ngOnChanges` — that's the only Angular hook that fires AFTER all
     * inputs in a single change-detection cycle are bound. The earlier
     * setter-based approach fired BEFORE peer inputs (`InitialName`,
     * `InitialDescription`, etc.) were set, so the dialog rendered with
     * stale or empty pre-fill values.
     */
    Visible = false;
    ComponentName = '';
    EntityName = '';
    /** Pre-fill for the Description textarea (cockpit's input value). */
    InitialDescription = null;
    /** Pre-fill for the Name input (defaults to ComponentName). */
    InitialName = null;
    /** Pre-fill for the Notes textarea (when present in the cockpit). */
    InitialNotes = null;
    /** Pre-fill for the Status radio group. Default: 'Pending'. */
    InitialStatus = null;
    /** Pre-fill for the Scope radio group. Default: 'User'. */
    InitialScope = null;
    /** Pre-fill for the Role select (when Scope='Role'). */
    InitialRoleID = undefined;
    /** Pre-fill for the Priority numeric input. Default: 0. */
    InitialPriority = undefined;
    /**
     * When true, render the dialog as "Edit form details" instead of
     * "Activate this form" — same fields, different framing. The
     * confirm button reads "Save changes" and the explanatory hint adapts.
     */
    EditMode = false;
    confirmed = new EventEmitter();
    dismissed = new EventEmitter();
    Name = '';
    Description = null;
    Notes = null;
    Scope = 'User';
    RoleID = null;
    Priority = 0;
    Status = 'Pending';
    validationError = null;
    availableRoles = [];
    cd = inject(ChangeDetectorRef);
    ngOnInit() {
        // Load roles eagerly — small list, used only when Scope='Role'.
        const provider = this.ProviderToUse;
        this.availableRoles = provider?.Roles ?? [];
    }
    /**
     * Re-sync editable state every time `Visible` flips false→true, AFTER
     * Angular has bound all the peer `@Input()`s for the same change-
     * detection cycle. The previous setter-based approach fired BEFORE
     * sibling inputs (`InitialName`, etc.) had landed, leaving the dialog
     * pre-fill empty.
     */
    ngOnChanges(changes) {
        const visChange = changes['Visible'];
        if (!visChange)
            return;
        const becameVisible = !visChange.previousValue && visChange.currentValue;
        if (becameVisible) {
            this.resetFromInputs();
        }
    }
    /**
     * Sync editable state from `@Input()`s. Called on first open AND on
     * every subsequent Visible: false → true transition so the dialog
     * doesn't show stale data from a previous invocation.
     */
    resetFromInputs() {
        this.Name = (this.InitialName?.trim() || this.ComponentName || '').trim();
        this.Description = this.InitialDescription?.trim() || null;
        this.Notes = this.InitialNotes?.trim() || null;
        this.validationError = null;
        // Default Status to Pending — matches the new "create as draft,
        // activate later" workflow. Edit-mode callers will override via
        // InitialStatus.
        if (this.InitialStatus)
            this.Status = this.InitialStatus;
        if (this.InitialScope)
            this.Scope = this.InitialScope;
        if (this.InitialRoleID !== undefined)
            this.RoleID = this.InitialRoleID;
        if (this.InitialPriority !== undefined)
            this.Priority = this.InitialPriority;
        this.cd.markForCheck();
    }
    OnNameInput(e) {
        this.Name = e.target.value;
    }
    OnDescriptionInput(e) {
        const v = e.target.value;
        this.Description = v.trim().length > 0 ? v : null;
    }
    OnNotesInput(e) {
        const v = e.target.value;
        this.Notes = v.trim().length > 0 ? v : null;
    }
    OnScopeChange(scope) {
        this.Scope = scope;
        if (scope !== 'Role') {
            this.RoleID = null;
        }
    }
    OnRoleChanged(e) {
        const v = e.target.value;
        this.RoleID = v.length > 0 ? v : null;
    }
    OnPriorityInput(e) {
        const parsed = parseInt(e.target.value, 10);
        this.Priority = isNaN(parsed) ? 0 : parsed;
    }
    OnConfirmClick() {
        if (!this.Name?.trim()) {
            this.validationError = 'Name is required.';
            return;
        }
        if (!this.EntityName) {
            this.validationError = 'No entity selected. Pick one in the Field Binding inspector before activating.';
            return;
        }
        if (this.Scope === 'Role' && !this.RoleID) {
            this.validationError = 'Pick a role when Scope = Role.';
            return;
        }
        this.validationError = null;
        this.confirmed.emit({
            Name: this.Name.trim(),
            Description: this.Description,
            Notes: this.Notes,
            EntityName: this.EntityName,
            Scope: this.Scope,
            RoleID: this.RoleID,
            Priority: this.Priority,
            Status: this.Status,
        });
    }
    OnCancelClick() {
        this.dismissed.emit();
    }
    static ɵfac = /*@__PURE__*/ (() => { let ɵFormOverrideDialogComponent_BaseFactory; return function FormOverrideDialogComponent_Factory(__ngFactoryType__) { return (ɵFormOverrideDialogComponent_BaseFactory || (ɵFormOverrideDialogComponent_BaseFactory = i0.ɵɵgetInheritedFactory(FormOverrideDialogComponent)))(__ngFactoryType__ || FormOverrideDialogComponent); }; })();
    static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: FormOverrideDialogComponent, selectors: [["mj-form-override-dialog"]], inputs: { Visible: "Visible", ComponentName: "ComponentName", EntityName: "EntityName", InitialDescription: "InitialDescription", InitialName: "InitialName", InitialNotes: "InitialNotes", InitialStatus: "InitialStatus", InitialScope: "InitialScope", InitialRoleID: "InitialRoleID", InitialPriority: "InitialPriority", EditMode: "EditMode" }, outputs: { confirmed: "confirmed", dismissed: "dismissed" }, features: [i0.ɵɵInheritDefinitionFeature, i0.ɵɵNgOnChangesFeature], decls: 1, vars: 1, consts: [[1, "modal-backdrop"], [1, "modal-backdrop", 3, "click"], [1, "modal", 3, "click"], [1, "modal-header"], ["aria-label", "Close", 1, "close-btn", 3, "click"], [1, "fa-solid", "fa-times"], [1, "modal-body"], [1, "hint"], [1, "field"], ["type", "text", "placeholder", "e.g. Compact Application Form", 3, "input", "value"], ["rows", "2", "placeholder", "Optional \u2014 what's special about this variant?", 3, "input", "value"], ["rows", "2", "placeholder", "Optional \u2014 private notes about this version, e.g. why you forked, what changed.", 3, "input", "value"], ["type", "text", "disabled", "", 3, "value"], [1, "muted"], [1, "scope-options"], [1, "radio"], ["type", "radio", "name", "scope", 3, "change", "checked"], [1, "role-picker", 3, "value"], [1, "field-row"], ["type", "number", "min", "0", "step", "1", 3, "input", "value"], [1, "status-options"], ["type", "radio", "name", "status", 3, "change", "checked"], [1, "error"], [1, "modal-footer"], [1, "btn", "btn-primary", 3, "click"], [1, "btn", 3, "click"], [1, "role-picker", 3, "change", "value"], ["value", ""], [3, "value"]], template: function FormOverrideDialogComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵconditionalCreate(0, FormOverrideDialogComponent_Conditional_0_Template, 71, 17, "div", 0);
        } if (rf & 2) {
            i0.ɵɵconditional(ctx.Visible ? 0 : -1);
        } }, dependencies: [CommonModule], styles: [".modal-backdrop[_ngcontent-%COMP%] { position: fixed; inset: 0; background: var(--mj-bg-overlay, rgba(0,0,0,0.5)); display: flex; align-items: center; justify-content: center; z-index: 1000; }\n        .modal[_ngcontent-%COMP%] { background: var(--mj-bg-surface, #fff); border-radius: 8px; width: 520px; max-width: 90vw; max-height: 90vh; display: flex; flex-direction: column; box-shadow: 0 8px 32px rgba(0,0,0,0.12); }\n        .modal-header[_ngcontent-%COMP%] { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--mj-border-default, #e0e0e0); }\n        .modal-header[_ngcontent-%COMP%]   h3[_ngcontent-%COMP%] { margin: 0; font-size: 16px; font-weight: 600; }\n        .close-btn[_ngcontent-%COMP%] { background: transparent; border: 0; cursor: pointer; font-size: 16px; color: var(--mj-text-muted, #64748b); padding: 4px; }\n        .modal-body[_ngcontent-%COMP%] { padding: 16px 20px; overflow-y: auto; }\n        .modal-footer[_ngcontent-%COMP%] { display: flex; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--mj-border-default, #e0e0e0); }\n        .hint[_ngcontent-%COMP%] { margin: 0 0 16px; color: var(--mj-text-muted, #64748b); font-size: 13px; line-height: 1.5; }\n        .field[_ngcontent-%COMP%] { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }\n        .field[_ngcontent-%COMP%]   label[_ngcontent-%COMP%] { font-size: 11px; color: var(--mj-text-muted, #64748b); text-transform: uppercase; letter-spacing: 0.5px; }\n        .field[_ngcontent-%COMP%]   input[type=\"text\"][_ngcontent-%COMP%], .field[_ngcontent-%COMP%]   input[type=\"number\"][_ngcontent-%COMP%], .field[_ngcontent-%COMP%]   textarea[_ngcontent-%COMP%], .field[_ngcontent-%COMP%]   select[_ngcontent-%COMP%] { padding: 8px 10px; border: 1px solid var(--mj-border-default, #e0e0e0); border-radius: 4px; font-size: 14px; background: var(--mj-bg-surface, #fff); color: var(--mj-text-primary, #111); font-family: inherit; }\n        .field[_ngcontent-%COMP%]   input[_ngcontent-%COMP%]:disabled { background: var(--mj-bg-surface-sunken, #f1f5f9); color: var(--mj-text-muted, #64748b); }\n        .field-row[_ngcontent-%COMP%] { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }\n        .muted[_ngcontent-%COMP%] { font-size: 11px; color: var(--mj-text-muted, #64748b); }\n        .scope-options[_ngcontent-%COMP%] { display: flex; flex-direction: column; gap: 8px; }\n        .status-options[_ngcontent-%COMP%] { display: flex; gap: 16px; padding-top: 6px; }\n        .radio[_ngcontent-%COMP%] { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }\n        .role-picker[_ngcontent-%COMP%] { margin-left: 24px; }\n        .error[_ngcontent-%COMP%] { color: var(--mj-status-error-text, #b91c1c); background: var(--mj-status-error-bg, #fee2e2); padding: 8px 12px; border-radius: 4px; font-size: 13px; margin-top: 8px; }\n        .btn[_ngcontent-%COMP%] { padding: 8px 16px; border: 1px solid var(--mj-border-default, #e0e0e0); border-radius: 4px; background: var(--mj-bg-surface, #fff); color: var(--mj-text-primary, #111); font-size: 14px; cursor: pointer; }\n        .btn-primary[_ngcontent-%COMP%] { background: var(--mj-brand-primary, #5B4FE9); color: #fff; border-color: var(--mj-brand-primary, #5B4FE9); font-weight: 500; }"], changeDetection: 0 });
}
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(FormOverrideDialogComponent, [{
        type: Component,
        args: [{ standalone: true, imports: [CommonModule], selector: 'mj-form-override-dialog', changeDetection: ChangeDetectionStrategy.OnPush, template: `
@if (Visible) {
<div class="modal-backdrop" (click)="OnCancelClick()">
    <div class="modal" (click)="$event.stopPropagation()">
        <header class="modal-header">
            <h3>{{ EditMode ? 'Edit form details' : 'Activate this form' }}</h3>
            <button class="close-btn" (click)="OnCancelClick()" aria-label="Close">
                <i class="fa-solid fa-times"></i>
            </button>
        </header>
        <div class="modal-body">
            <p class="hint">
                @if (EditMode) {
                    Update the override's name, description, scope, priority, or status.
                    Component code is edited from the cockpit's main editor — this dialog
                    covers the override-row metadata only.
                } @else {
                    Create an Entity Form Override so MemberJunction renders this
                    Component instead of the default form for matching users.
                    Skip to keep the Component saved but inactive.
                }
            </p>

            <div class="field">
                <label>Override Name</label>
                <input type="text" [value]="Name" (input)="OnNameInput($event)" placeholder="e.g. Compact Application Form" />
            </div>

            <div class="field">
                <label>Description</label>
                <textarea [value]="Description ?? ''" (input)="OnDescriptionInput($event)" rows="2"
                          placeholder="Optional — what's special about this variant?"></textarea>
            </div>

            <div class="field">
                <label>Notes</label>
                <textarea [value]="Notes ?? ''" (input)="OnNotesInput($event)" rows="2"
                          placeholder="Optional — private notes about this version, e.g. why you forked, what changed."></textarea>
            </div>

            <div class="field">
                <label>Entity</label>
                <input type="text" [value]="EntityName" disabled />
                <small class="muted">Set in the Field Binding inspector.</small>
            </div>

            <div class="field">
                <label>Scope</label>
                <div class="scope-options">
                    <label class="radio">
                        <input type="radio" name="scope" [checked]="Scope === 'User'" (change)="OnScopeChange('User')" />
                        Me only (User)
                    </label>
                    <label class="radio">
                        <input type="radio" name="scope" [checked]="Scope === 'Role'" (change)="OnScopeChange('Role')" />
                        A role
                    </label>
                    @if (Scope === 'Role') {
                        <select [value]="RoleID ?? ''" (change)="OnRoleChanged($event)" class="role-picker">
                            <option value="">— pick a role —</option>
                            @for (r of availableRoles; track r.ID) {
                                <option [value]="r.ID">{{ r.Name }}</option>
                            }
                        </select>
                    }
                    <label class="radio">
                        <input type="radio" name="scope" [checked]="Scope === 'Global'" (change)="OnScopeChange('Global')" />
                        Everyone (Global)
                    </label>
                </div>
            </div>

            <div class="field-row">
                <div class="field">
                    <label>Priority</label>
                    <input type="number" [value]="Priority" (input)="OnPriorityInput($event)" min="0" step="1" />
                </div>

                <div class="field">
                    <label>Status</label>
                    <div class="status-options">
                        <label class="radio">
                            <input type="radio" name="status" [checked]="Status === 'Pending'" (change)="Status = 'Pending'" />
                            Pending <span class="muted">(draft)</span>
                        </label>
                        <label class="radio">
                            <input type="radio" name="status" [checked]="Status === 'Active'" (change)="Status = 'Active'" />
                            Active <span class="muted">(live)</span>
                        </label>
                        <label class="radio">
                            <input type="radio" name="status" [checked]="Status === 'Inactive'" (change)="Status = 'Inactive'" />
                            Inactive
                        </label>
                    </div>
                </div>
            </div>

            @if (validationError) {
                <div class="error">{{ validationError }}</div>
            }
        </div>
        <footer class="modal-footer">
            <button class="btn btn-primary" (click)="OnConfirmClick()">{{ EditMode ? 'Save changes' : 'Create Override' }}</button>
            <button class="btn" (click)="OnCancelClick()">{{ EditMode ? 'Cancel' : 'Skip' }}</button>
        </footer>
    </div>
</div>
}
`, styles: ["\n        .modal-backdrop { position: fixed; inset: 0; background: var(--mj-bg-overlay, rgba(0,0,0,0.5)); display: flex; align-items: center; justify-content: center; z-index: 1000; }\n        .modal { background: var(--mj-bg-surface, #fff); border-radius: 8px; width: 520px; max-width: 90vw; max-height: 90vh; display: flex; flex-direction: column; box-shadow: 0 8px 32px rgba(0,0,0,0.12); }\n        .modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--mj-border-default, #e0e0e0); }\n        .modal-header h3 { margin: 0; font-size: 16px; font-weight: 600; }\n        .close-btn { background: transparent; border: 0; cursor: pointer; font-size: 16px; color: var(--mj-text-muted, #64748b); padding: 4px; }\n        .modal-body { padding: 16px 20px; overflow-y: auto; }\n        .modal-footer { display: flex; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--mj-border-default, #e0e0e0); }\n        .hint { margin: 0 0 16px; color: var(--mj-text-muted, #64748b); font-size: 13px; line-height: 1.5; }\n        .field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }\n        .field label { font-size: 11px; color: var(--mj-text-muted, #64748b); text-transform: uppercase; letter-spacing: 0.5px; }\n        .field input[type=\"text\"], .field input[type=\"number\"], .field textarea, .field select { padding: 8px 10px; border: 1px solid var(--mj-border-default, #e0e0e0); border-radius: 4px; font-size: 14px; background: var(--mj-bg-surface, #fff); color: var(--mj-text-primary, #111); font-family: inherit; }\n        .field input:disabled { background: var(--mj-bg-surface-sunken, #f1f5f9); color: var(--mj-text-muted, #64748b); }\n        .field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }\n        .muted { font-size: 11px; color: var(--mj-text-muted, #64748b); }\n        .scope-options { display: flex; flex-direction: column; gap: 8px; }\n        .status-options { display: flex; gap: 16px; padding-top: 6px; }\n        .radio { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }\n        .role-picker { margin-left: 24px; }\n        .error { color: var(--mj-status-error-text, #b91c1c); background: var(--mj-status-error-bg, #fee2e2); padding: 8px 12px; border-radius: 4px; font-size: 13px; margin-top: 8px; }\n        .btn { padding: 8px 16px; border: 1px solid var(--mj-border-default, #e0e0e0); border-radius: 4px; background: var(--mj-bg-surface, #fff); color: var(--mj-text-primary, #111); font-size: 14px; cursor: pointer; }\n        .btn-primary { background: var(--mj-brand-primary, #5B4FE9); color: #fff; border-color: var(--mj-brand-primary, #5B4FE9); font-weight: 500; }\n    "] }]
    }], null, { Visible: [{
            type: Input
        }], ComponentName: [{
            type: Input
        }], EntityName: [{
            type: Input
        }], InitialDescription: [{
            type: Input
        }], InitialName: [{
            type: Input
        }], InitialNotes: [{
            type: Input
        }], InitialStatus: [{
            type: Input
        }], InitialScope: [{
            type: Input
        }], InitialRoleID: [{
            type: Input
        }], InitialPriority: [{
            type: Input
        }], EditMode: [{
            type: Input
        }], confirmed: [{
            type: Output
        }], dismissed: [{
            type: Output
        }] }); })();
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(FormOverrideDialogComponent, { className: "FormOverrideDialogComponent", filePath: "src/ComponentStudio/components/form-override-dialog.component.ts", lineNumber: 189 }); })();
//# sourceMappingURL=form-override-dialog.component.js.map