import { Component, Output, EventEmitter } from '@angular/core';
import { Validators } from '@angular/forms';
import { Subject, BehaviorSubject, takeUntil } from 'rxjs';
import { RunView } from '@memberjunction/core';
import { MJNotificationService } from '@memberjunction/ng-notifications';
import { UUIDsEqual } from '@memberjunction/global';
import * as i0 from "@angular/core";
import * as i1 from "@angular/forms";
import * as i2 from "@memberjunction/ng-ui-components";
import * as i3 from "@angular/common";
const _c0 = () => ({ Name: "Default Type", ID: null });
function SubAgentAdvancedSettingsDialogComponent_Conditional_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 1)(1, "div", 6);
    i0.ɵɵelement(2, "i", 7);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(3, "p");
    i0.ɵɵtext(4, "Loading sub-agent settings...");
    i0.ɵɵelementEnd()();
} }
function SubAgentAdvancedSettingsDialogComponent_Conditional_3_Conditional_10_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 15);
    i0.ɵɵtext(1);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance();
    i0.ɵɵtextInterpolate(ctx_r0.getFieldError("executionOrder"));
} }
function SubAgentAdvancedSettingsDialogComponent_Conditional_3_Conditional_11_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 15);
    i0.ɵɵtext(1);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance();
    i0.ɵɵtextInterpolate(ctx_r0.executionOrderError);
} }
function SubAgentAdvancedSettingsDialogComponent_Conditional_3_Conditional_18_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 15);
    i0.ɵɵtext(1);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance();
    i0.ɵɵtextInterpolate(ctx_r0.getFieldError("executionMode"));
} }
function SubAgentAdvancedSettingsDialogComponent_Conditional_3_Conditional_37_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 15);
    i0.ɵɵtext(1);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance();
    i0.ɵɵtextInterpolate(ctx_r0.getFieldError("status"));
} }
function SubAgentAdvancedSettingsDialogComponent_Conditional_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "form", 2)(1, "div", 8)(2, "h3", 9);
    i0.ɵɵelement(3, "i", 10);
    i0.ɵɵtext(4, " Execution Configuration ");
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(5, "div", 11)(6, "div", 12)(7, "label", 13);
    i0.ɵɵtext(8, "Execution Order *");
    i0.ɵɵelementEnd();
    i0.ɵɵelement(9, "mj-numeric-input", 14);
    i0.ɵɵconditionalCreate(10, SubAgentAdvancedSettingsDialogComponent_Conditional_3_Conditional_10_Template, 2, 1, "div", 15);
    i0.ɵɵconditionalCreate(11, SubAgentAdvancedSettingsDialogComponent_Conditional_3_Conditional_11_Template, 2, 1, "div", 15);
    i0.ɵɵelementStart(12, "small", 16);
    i0.ɵɵtext(13, "Order in which this sub-agent executes among siblings (0 = first). Must be unique among sibling agents.");
    i0.ɵɵelementEnd()();
    i0.ɵɵelementStart(14, "div", 12)(15, "label", 17);
    i0.ɵɵtext(16, "Execution Mode *");
    i0.ɵɵelementEnd();
    i0.ɵɵelement(17, "mj-dropdown", 18);
    i0.ɵɵconditionalCreate(18, SubAgentAdvancedSettingsDialogComponent_Conditional_3_Conditional_18_Template, 2, 1, "div", 15);
    i0.ɵɵelementStart(19, "small", 16);
    i0.ɵɵtext(20);
    i0.ɵɵelementEnd()()()();
    i0.ɵɵelementStart(21, "div", 8)(22, "h3", 9);
    i0.ɵɵelement(23, "i", 19);
    i0.ɵɵtext(24, " Agent Configuration ");
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(25, "div", 11)(26, "div", 12)(27, "label", 20);
    i0.ɵɵtext(28, "Agent Type");
    i0.ɵɵelementEnd();
    i0.ɵɵelement(29, "mj-dropdown", 21);
    i0.ɵɵpipe(30, "async");
    i0.ɵɵelementStart(31, "small", 16);
    i0.ɵɵtext(32, "Specialized agent type that defines behavior and capabilities");
    i0.ɵɵelementEnd()();
    i0.ɵɵelementStart(33, "div", 12)(34, "label", 22);
    i0.ɵɵtext(35, "Status *");
    i0.ɵɵelementEnd();
    i0.ɵɵelement(36, "mj-dropdown", 23);
    i0.ɵɵconditionalCreate(37, SubAgentAdvancedSettingsDialogComponent_Conditional_3_Conditional_37_Template, 2, 1, "div", 15);
    i0.ɵɵelementStart(38, "small", 16);
    i0.ɵɵtext(39, "Current operational status of this sub-agent");
    i0.ɵɵelementEnd()()()();
    i0.ɵɵelementStart(40, "div", 8)(41, "h3", 9);
    i0.ɵɵelement(42, "i", 24);
    i0.ɵɵtext(43, " Capability Restrictions ");
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(44, "div", 11)(45, "div", 25)(46, "label", 26);
    i0.ɵɵelement(47, "input", 27);
    i0.ɵɵtext(48, " Expose As Action ");
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(49, "small", 28);
    i0.ɵɵelement(50, "i", 29);
    i0.ɵɵtext(51, " Sub-agents cannot be exposed as actions. Only root agents (without parents) can be exposed as actions for use by other agents. ");
    i0.ɵɵelementEnd()()()()();
} if (rf & 2) {
    let tmp_9_0;
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵproperty("formGroup", ctx_r0.advancedForm);
    i0.ɵɵadvance(9);
    i0.ɵɵclassProp("error-border", ctx_r0.hasExecutionOrderError());
    i0.ɵɵproperty("Min", 0);
    i0.ɵɵadvance();
    i0.ɵɵconditional(ctx_r0.isFieldInvalid("executionOrder") ? 10 : -1);
    i0.ɵɵadvance();
    i0.ɵɵconditional(ctx_r0.hasExecutionOrderError() ? 11 : -1);
    i0.ɵɵadvance(6);
    i0.ɵɵproperty("Data", ctx_r0.executionModeOptions)("ValuePrimitive", true);
    i0.ɵɵadvance();
    i0.ɵɵconditional(ctx_r0.isFieldInvalid("executionMode") ? 18 : -1);
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate(ctx_r0.getExecutionModeDescription((tmp_9_0 = ctx_r0.advancedForm.get("executionMode")) == null ? null : tmp_9_0.value));
    i0.ɵɵadvance(9);
    i0.ɵɵproperty("Data", i0.ɵɵpipeBind1(30, 17, ctx_r0.agentTypes$))("ValuePrimitive", true)("DefaultItem", i0.ɵɵpureFunction0(19, _c0));
    i0.ɵɵadvance(7);
    i0.ɵɵproperty("Data", ctx_r0.statusOptions)("ValuePrimitive", true);
    i0.ɵɵadvance();
    i0.ɵɵconditional(ctx_r0.isFieldInvalid("status") ? 37 : -1);
    i0.ɵɵadvance(10);
    i0.ɵɵproperty("disabled", true);
} }
function SubAgentAdvancedSettingsDialogComponent_Conditional_11_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "i", 30);
    i0.ɵɵtext(1, " Saving... ");
} }
function SubAgentAdvancedSettingsDialogComponent_Conditional_13_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "i", 31);
    i0.ɵɵtext(1, " Save Settings ");
} }
/**
 * Advanced Settings dialog for Sub-Agents.
 * Manages execution order, execution mode, and other advanced sub-agent configurations.
 */
export class SubAgentAdvancedSettingsDialogComponent {
    constructor(fb, cdr) {
        this.fb = fb;
        this.cdr = cdr;
        this.allSubAgents = []; // For execution order validation
        // Reactive state management
        this.destroy$ = new Subject();
        this.result = new Subject();
        this.isLoading$ = new BehaviorSubject(false);
        this.isSaving$ = new BehaviorSubject(false);
        // Dropdown data
        this.agentTypes$ = new BehaviorSubject([]);
        // Available options
        this.executionModeOptions = [
            {
                text: 'Sequential',
                value: 'Sequential',
                description: 'Child agents execute one after another in order',
                icon: 'fa-list-ol'
            },
            {
                text: 'Parallel',
                value: 'Parallel',
                description: 'Child agents execute simultaneously for faster processing',
                icon: 'fa-layer-group'
            }
        ];
        this.statusOptions = [
            { text: 'Active', value: 'Active' },
            { text: 'Disabled', value: 'Disabled' },
            { text: 'Pending', value: 'Pending' }
        ];
        // Execution order validation
        this.executionOrderError = null;
        this.DialogClose = new EventEmitter();
    }
    ngOnInit() {
        this.initializeForm();
        this.loadDropdownData();
    }
    ngOnDestroy() {
        this.destroy$.next();
        this.destroy$.complete();
    }
    initializeForm() {
        this.advancedForm = this.fb.group({
            executionOrder: [this.subAgent.ExecutionOrder || 0, [Validators.required, Validators.min(0)]],
            executionMode: [this.subAgent.ExecutionMode || 'Sequential', [Validators.required]],
            status: [this.subAgent.Status || 'Active', [Validators.required]],
            typeID: [this.subAgent.TypeID],
            exposeAsAction: [this.subAgent.ExposeAsAction || false]
        });
        this.setupValidationLogic();
    }
    setupValidationLogic() {
        // Execution order validation
        const executionOrderControl = this.advancedForm.get('executionOrder');
        executionOrderControl?.valueChanges.pipe(takeUntil(this.destroy$)).subscribe(order => {
            this.validateExecutionOrder(order);
        });
        // ExposeAsAction validation (sub-agents cannot be exposed as actions)
        const exposeAsActionControl = this.advancedForm.get('exposeAsAction');
        exposeAsActionControl?.valueChanges.pipe(takeUntil(this.destroy$)).subscribe(expose => {
            if (expose && this.subAgent.ParentID) {
                // Sub-agents cannot be exposed as actions
                exposeAsActionControl.setValue(false);
                MJNotificationService.Instance.CreateSimpleNotification('Sub-agents cannot be exposed as actions. Only root agents can be exposed.', 'warning', 4000);
            }
        });
    }
    validateExecutionOrder(order) {
        if (order == null) {
            this.executionOrderError = null;
            return;
        }
        // Check for conflicts with other sub-agents under the same parent (excluding current one)
        const conflictingAgent = this.allSubAgents.find(agent => !UUIDsEqual(agent.ID, this.subAgent.ID) &&
            UUIDsEqual(agent.ParentID, this.subAgent.ParentID) &&
            agent.ExecutionOrder === order);
        if (conflictingAgent) {
            this.executionOrderError = `Execution order ${order} is already used by "${conflictingAgent.Name}". Please choose a different order.`;
        }
        else {
            this.executionOrderError = null;
        }
        this.cdr.detectChanges();
    }
    async loadDropdownData() {
        this.isLoading$.next(true);
        try {
            const rv = new RunView();
            // Load AI Agent Types
            const agentTypesResult = await rv.RunView({
                EntityName: 'MJ: AI Agent Types',
                ExtraFilter: 'IsActive = 1',
                OrderBy: 'Name',
                ResultType: 'entity_object',
                MaxRows: 1000
            });
            if (agentTypesResult.Success) {
                this.agentTypes$.next(agentTypesResult.Results || []);
            }
        }
        catch (error) {
            console.error('Error loading dropdown data:', error);
            MJNotificationService.Instance.CreateSimpleNotification('Error loading form data. Please try again.', 'error', 3000);
        }
        finally {
            this.isLoading$.next(false);
        }
    }
    // === Validation Helpers ===
    isFieldInvalid(fieldName) {
        const field = this.advancedForm.get(fieldName);
        return !!(field && field.invalid && (field.dirty || field.touched));
    }
    getFieldError(fieldName) {
        const field = this.advancedForm.get(fieldName);
        if (field?.errors) {
            if (field.errors['required'])
                return `${fieldName} is required`;
            if (field.errors['min'])
                return `${fieldName} must be greater than or equal to ${field.errors['min'].min}`;
        }
        return '';
    }
    hasExecutionOrderError() {
        return !!this.executionOrderError;
    }
    // === Execution Mode Helpers ===
    getExecutionModeIcon(mode) {
        const option = this.executionModeOptions.find(opt => opt.value === mode);
        return option?.icon || 'fa-robot';
    }
    getExecutionModeDescription(mode) {
        const option = this.executionModeOptions.find(opt => opt.value === mode);
        return option?.description || '';
    }
    // === Dialog Actions ===
    cancel() {
        this.result.next(null);
        this.DialogClose.emit();
    }
    async save() {
        if (this.advancedForm.invalid || this.hasExecutionOrderError()) {
            this.advancedForm.markAllAsTouched();
            MJNotificationService.Instance.CreateSimpleNotification('Please fix validation errors before saving', 'error', 3000);
            return;
        }
        this.isSaving$.next(true);
        try {
            const formData = {
                executionOrder: this.advancedForm.get('executionOrder')?.value,
                executionMode: this.advancedForm.get('executionMode')?.value,
                status: this.advancedForm.get('status')?.value,
                typeID: this.advancedForm.get('typeID')?.value || null,
                exposeAsAction: false // Sub-agents cannot be exposed as actions
            };
            this.result.next(formData);
            this.DialogClose.emit();
        }
        catch (error) {
            console.error('Error saving advanced settings:', error);
            MJNotificationService.Instance.CreateSimpleNotification('Error saving settings. Please try again.', 'error', 3000);
        }
        finally {
            this.isSaving$.next(false);
        }
    }
    static { this.ɵfac = function SubAgentAdvancedSettingsDialogComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || SubAgentAdvancedSettingsDialogComponent)(i0.ɵɵdirectiveInject(i1.FormBuilder), i0.ɵɵdirectiveInject(i0.ChangeDetectorRef)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: SubAgentAdvancedSettingsDialogComponent, selectors: [["mj-sub-agent-advanced-settings-dialog"]], outputs: { DialogClose: "DialogClose" }, standalone: false, decls: 14, vars: 14, consts: [[1, "sub-agent-advanced-settings-dialog"], [1, "loading-state"], [1, "advanced-form", 3, "formGroup"], [1, "dialog-footer"], ["mjButton", "", "variant", "flat", 3, "click", "disabled"], ["mjButton", "", "variant", "primary", 3, "click", "disabled"], [1, "loading-spinner"], [1, "fa-solid", "fa-spinner", "fa-spin", "fa-2x"], [1, "form-section"], [1, "section-title"], [1, "fa-solid", "fa-play"], [1, "form-grid"], [1, "form-field"], ["for", "executionOrder"], ["formControlName", "executionOrder", "Format", "0", 1, "form-control", 3, "Min"], [1, "field-error"], [1, "field-hint"], ["for", "executionMode"], ["formControlName", "executionMode", "TextField", "text", "ValueField", "value", 1, "form-control", 3, "Data", "ValuePrimitive"], [1, "fa-solid", "fa-robot"], ["for", "typeID"], ["formControlName", "typeID", "TextField", "Name", "ValueField", "ID", 1, "form-control", 3, "Data", "ValuePrimitive", "DefaultItem"], ["for", "status"], ["formControlName", "status", "TextField", "text", "ValueField", "value", 1, "form-control", 3, "Data", "ValuePrimitive"], [1, "fa-solid", "fa-shield-alt"], [1, "form-field", "full-width"], [1, "checkbox-label", "disabled"], ["type", "checkbox", "formControlName", "exposeAsAction", 1, "mj-checkbox", 3, "disabled"], [1, "field-hint", "disabled-hint"], [1, "fa-solid", "fa-info-circle"], [1, "fa-solid", "fa-spinner", "fa-spin"], [1, "fa-solid", "fa-save"]], template: function SubAgentAdvancedSettingsDialogComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelementStart(0, "div", 0);
            i0.ɵɵconditionalCreate(1, SubAgentAdvancedSettingsDialogComponent_Conditional_1_Template, 5, 0, "div", 1);
            i0.ɵɵpipe(2, "async");
            i0.ɵɵconditionalBranchCreate(3, SubAgentAdvancedSettingsDialogComponent_Conditional_3_Template, 52, 20, "form", 2);
            i0.ɵɵelementStart(4, "div", 3)(5, "button", 4);
            i0.ɵɵpipe(6, "async");
            i0.ɵɵlistener("click", function SubAgentAdvancedSettingsDialogComponent_Template_button_click_5_listener() { return ctx.cancel(); });
            i0.ɵɵtext(7, " Cancel ");
            i0.ɵɵelementEnd();
            i0.ɵɵelementStart(8, "button", 5);
            i0.ɵɵpipe(9, "async");
            i0.ɵɵpipe(10, "async");
            i0.ɵɵlistener("click", function SubAgentAdvancedSettingsDialogComponent_Template_button_click_8_listener() { return ctx.save(); });
            i0.ɵɵconditionalCreate(11, SubAgentAdvancedSettingsDialogComponent_Conditional_11_Template, 2, 0);
            i0.ɵɵpipe(12, "async");
            i0.ɵɵconditionalBranchCreate(13, SubAgentAdvancedSettingsDialogComponent_Conditional_13_Template, 2, 0);
            i0.ɵɵelementEnd()()();
        } if (rf & 2) {
            i0.ɵɵadvance();
            i0.ɵɵconditional(i0.ɵɵpipeBind1(2, 4, ctx.isLoading$) ? 1 : 3);
            i0.ɵɵadvance(4);
            i0.ɵɵproperty("disabled", i0.ɵɵpipeBind1(6, 6, ctx.isSaving$) || false);
            i0.ɵɵadvance(3);
            i0.ɵɵproperty("disabled", i0.ɵɵpipeBind1(9, 8, ctx.isSaving$) || false || (i0.ɵɵpipeBind1(10, 10, ctx.isLoading$) || false) || ctx.hasExecutionOrderError());
            i0.ɵɵadvance(3);
            i0.ɵɵconditional(i0.ɵɵpipeBind1(12, 12, ctx.isSaving$) ? 11 : 13);
        } }, dependencies: [i1.ɵNgNoValidate, i1.CheckboxControlValueAccessor, i1.NgControlStatus, i1.NgControlStatusGroup, i1.FormGroupDirective, i1.FormControlName, i2.MJButtonDirective, i2.MJDropdownComponent, i2.MJNumericInputComponent, i3.AsyncPipe], styles: [".sub-agent-advanced-settings-dialog[_ngcontent-%COMP%] {\n  display: flex;\n  flex-direction: column;\n  height: 100%;\n  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;\n}\n\n\n\n[_nghost-%COMP%]     .k-dialog, \n[_nghost-%COMP%]     .k-window {\n  z-index: 10000 !important;\n}\n\n[_nghost-%COMP%]     .k-overlay {\n  z-index: 9999 !important;\n}\n\n\n\n.loading-state[_ngcontent-%COMP%] {\n  display: flex;\n  flex-direction: column;\n  align-items: center;\n  justify-content: center;\n  height: 300px;\n  color: var(--mj-text-muted);\n}\n\n.loading-spinner[_ngcontent-%COMP%] {\n  margin-bottom: 1rem;\n}\n\n.loading-spinner[_ngcontent-%COMP%]   i[_ngcontent-%COMP%] {\n  color: var(--mj-brand-primary);\n}\n\n.loading-state[_ngcontent-%COMP%]   p[_ngcontent-%COMP%] {\n  margin-top: 1rem;\n  font-size: 1.1rem;\n}\n\n\n\n.advanced-form[_ngcontent-%COMP%] {\n  flex: 1;\n  overflow-y: auto;\n  padding: 1.5rem;\n}\n\n.form-section[_ngcontent-%COMP%] {\n  margin-bottom: 2rem;\n  background: var(--mj-bg-surface);\n  border-radius: 8px;\n  border: 1px solid var(--mj-border-default);\n  overflow: hidden;\n}\n\n.section-title[_ngcontent-%COMP%] {\n  margin: 0;\n  padding: 1rem 1.5rem;\n  background: var(--mj-bg-surface-card);\n  border-bottom: 1px solid var(--mj-border-default);\n  color: var(--mj-text-secondary);\n  font-size: 1.1rem;\n  font-weight: 600;\n  display: flex;\n  align-items: center;\n  gap: 0.5rem;\n}\n\n.section-title[_ngcontent-%COMP%]   i[_ngcontent-%COMP%] {\n  color: var(--mj-brand-primary);\n}\n\n.form-grid[_ngcontent-%COMP%] {\n  display: grid;\n  grid-template-columns: 1fr 1fr;\n  gap: 1.5rem;\n  padding: 1.5rem;\n}\n\n.form-field[_ngcontent-%COMP%] {\n  display: flex;\n  flex-direction: column;\n  gap: 0.5rem;\n}\n\n.form-field.full-width[_ngcontent-%COMP%] {\n  grid-column: 1 / -1;\n}\n\n\n\nlabel[_ngcontent-%COMP%] {\n  font-weight: 600;\n  color: var(--mj-text-secondary);\n  font-size: 0.9rem;\n}\n\n.checkbox-label[_ngcontent-%COMP%] {\n  display: flex;\n  align-items: center;\n  gap: 0.5rem;\n  font-weight: 600;\n  color: var(--mj-text-secondary);\n  cursor: pointer;\n}\n\n.checkbox-label.disabled[_ngcontent-%COMP%] {\n  color: var(--mj-text-muted);\n  cursor: not-allowed;\n}\n\n.form-control[_ngcontent-%COMP%] {\n  width: 100%;\n}\n\n.field-hint[_ngcontent-%COMP%] {\n  color: var(--mj-text-muted);\n  font-size: 0.8rem;\n  margin-top: 0.25rem;\n  line-height: 1.3;\n}\n\n.disabled-hint[_ngcontent-%COMP%] {\n  color: var(--mj-text-disabled);\n  font-style: italic;\n  display: flex;\n  align-items: center;\n  gap: 0.5rem;\n}\n\n.disabled-hint[_ngcontent-%COMP%]   i[_ngcontent-%COMP%] {\n  color: var(--mj-brand-primary);\n}\n\n.field-error[_ngcontent-%COMP%] {\n  color: var(--mj-status-error);\n  font-size: 0.8rem;\n  margin-top: 0.25rem;\n}\n\n\n\n.form-control.ng-invalid.ng-touched[_ngcontent-%COMP%], \n.error-border[_ngcontent-%COMP%] {\n  border-color: var(--mj-status-error) !important;\n}\n\n.form-control.ng-valid.ng-touched[_ngcontent-%COMP%] {\n  border-color: var(--mj-status-success);\n}\n\n\n\n.execution-mode-option[_ngcontent-%COMP%] {\n  padding: 0.5rem 0;\n}\n\n.option-header[_ngcontent-%COMP%] {\n  display: flex;\n  align-items: center;\n  gap: 0.5rem;\n  margin-bottom: 0.25rem;\n}\n\n.option-header[_ngcontent-%COMP%]   i[_ngcontent-%COMP%] {\n  color: var(--mj-brand-primary);\n  width: 16px;\n}\n\n.option-title[_ngcontent-%COMP%] {\n  font-weight: 500;\n  color: var(--mj-text-primary);\n  font-size: 0.9rem;\n}\n\n.option-description[_ngcontent-%COMP%] {\n  font-size: 0.8rem;\n  color: var(--mj-text-secondary);\n  line-height: 1.3;\n  margin-left: 1.5rem;\n}\n\n\n\n.dialog-footer[_ngcontent-%COMP%] {\n  display: flex;\n  justify-content: flex-end;\n  gap: 1rem;\n  padding: 1rem 1.5rem;\n  border-top: 1px solid var(--mj-border-default);\n  background: var(--mj-bg-surface-card);\n}\n\n.dialog-footer[_ngcontent-%COMP%]   button[_ngcontent-%COMP%] {\n  min-width: 120px;\n}\n\n.dialog-footer[_ngcontent-%COMP%]   button[themeColor=\"primary\"][_ngcontent-%COMP%]   i[_ngcontent-%COMP%] {\n  margin-right: 0.5rem;\n}\n\n\n\n\n\n\n.form-section[_ngcontent-%COMP%]:first-child   .section-title[_ngcontent-%COMP%] {\n  background: color-mix(in srgb, var(--mj-brand-primary) 8%, var(--mj-bg-surface));\n}\n\n\n\n.form-section[_ngcontent-%COMP%]:nth-child(2)   .section-title[_ngcontent-%COMP%] {\n  background: color-mix(in srgb, var(--mj-brand-primary) 8%, var(--mj-bg-surface));\n}\n\n\n\n.form-section[_ngcontent-%COMP%]:nth-child(3)   .section-title[_ngcontent-%COMP%] {\n  background: color-mix(in srgb, var(--mj-status-warning) 8%, var(--mj-bg-surface));\n}\n\n\n\n@media (max-width: 768px) {\n  .form-grid[_ngcontent-%COMP%] {\n    grid-template-columns: 1fr;\n    gap: 1rem;\n    padding: 1rem;\n  }\n\n  .form-field.full-width[_ngcontent-%COMP%] {\n    grid-column: 1;\n  }\n\n  .advanced-form[_ngcontent-%COMP%] {\n    padding: 1rem;\n  }\n\n  .section-title[_ngcontent-%COMP%] {\n    padding: 0.75rem 1rem;\n    font-size: 1rem;\n  }\n\n  .dialog-footer[_ngcontent-%COMP%] {\n    padding: 1rem;\n    flex-direction: column;\n  }\n\n  .dialog-footer[_ngcontent-%COMP%]   button[_ngcontent-%COMP%] {\n    width: 100%;\n  }\n}\n\n\n\n.error-border[_ngcontent-%COMP%] {\n  border: 2px solid var(--mj-status-error) !important;\n  background-color: color-mix(in srgb, var(--mj-status-error) 4%, var(--mj-bg-surface));\n}"] }); }
}
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(SubAgentAdvancedSettingsDialogComponent, [{
        type: Component,
        args: [{ standalone: false, selector: 'mj-sub-agent-advanced-settings-dialog', template: "<!-- Sub-Agent Advanced Settings Dialog -->\n<div class=\"sub-agent-advanced-settings-dialog\">\n  \n  <!-- Loading State -->\n  @if (isLoading$ | async) {\n    <div class=\"loading-state\">\n      <div class=\"loading-spinner\">\n        <i class=\"fa-solid fa-spinner fa-spin fa-2x\"></i>\n      </div>\n      <p>Loading sub-agent settings...</p>\n    </div>\n  } @else {\n    \n    <!-- Form Content -->\n    <form [formGroup]=\"advancedForm\" class=\"advanced-form\">\n      \n      <!-- Execution Configuration Section -->\n      <div class=\"form-section\">\n        <h3 class=\"section-title\">\n          <i class=\"fa-solid fa-play\"></i>\n          Execution Configuration\n        </h3>\n        \n        <div class=\"form-grid\">\n          <!-- Execution Order -->\n          <div class=\"form-field\">\n            <label for=\"executionOrder\">Execution Order *</label>\n            <mj-numeric-input\n              formControlName=\"executionOrder\"\n              [Min]=\"0\"\n              Format=\"0\"\n              [class.error-border]=\"hasExecutionOrderError()\"\n              class=\"form-control\">\n            </mj-numeric-input>\n            @if (isFieldInvalid('executionOrder')) {\n              <div class=\"field-error\">{{ getFieldError('executionOrder') }}</div>\n            }\n            @if (hasExecutionOrderError()) {\n              <div class=\"field-error\">{{ executionOrderError }}</div>\n            }\n            <small class=\"field-hint\">Order in which this sub-agent executes among siblings (0 = first). Must be unique among sibling agents.</small>\n          </div>\n          \n          <!-- Execution Mode -->\n          <div class=\"form-field\">\n            <label for=\"executionMode\">Execution Mode *</label>\n            <mj-dropdown\n              formControlName=\"executionMode\"\n              [Data]=\"executionModeOptions\"\n              TextField=\"text\"\n              ValueField=\"value\"\n              [ValuePrimitive]=\"true\"\n              class=\"form-control\">\n            </mj-dropdown>\n            @if (isFieldInvalid('executionMode')) {\n              <div class=\"field-error\">{{ getFieldError('executionMode') }}</div>\n            }\n            <small class=\"field-hint\">{{ getExecutionModeDescription(advancedForm.get('executionMode')?.value) }}</small>\n          </div>\n        </div>\n      </div>\n\n      <!-- Agent Configuration Section -->\n      <div class=\"form-section\">\n        <h3 class=\"section-title\">\n          <i class=\"fa-solid fa-robot\"></i>\n          Agent Configuration\n        </h3>\n        \n        <div class=\"form-grid\">\n          <!-- Agent Type -->\n          <div class=\"form-field\">\n            <label for=\"typeID\">Agent Type</label>\n            <mj-dropdown\n              formControlName=\"typeID\"\n              [Data]=\"agentTypes$ | async\"\n              TextField=\"Name\"\n              ValueField=\"ID\"\n              [ValuePrimitive]=\"true\"\n              [DefaultItem]=\"{ Name: 'Default Type', ID: null }\"\n              class=\"form-control\">\n            </mj-dropdown>\n            <small class=\"field-hint\">Specialized agent type that defines behavior and capabilities</small>\n          </div>\n          \n          <!-- Status -->\n          <div class=\"form-field\">\n            <label for=\"status\">Status *</label>\n            <mj-dropdown\n              formControlName=\"status\"\n              [Data]=\"statusOptions\"\n              TextField=\"text\"\n              ValueField=\"value\"\n              [ValuePrimitive]=\"true\"\n              class=\"form-control\">\n            </mj-dropdown>\n            @if (isFieldInvalid('status')) {\n              <div class=\"field-error\">{{ getFieldError('status') }}</div>\n            }\n            <small class=\"field-hint\">Current operational status of this sub-agent</small>\n          </div>\n        </div>\n      </div>\n\n      <!-- Capability Restrictions Section -->\n      <div class=\"form-section\">\n        <h3 class=\"section-title\">\n          <i class=\"fa-solid fa-shield-alt\"></i>\n          Capability Restrictions\n        </h3>\n        \n        <div class=\"form-grid\">\n          <!-- Expose As Action (Disabled for Sub-Agents) -->\n          <div class=\"form-field full-width\">\n            <label class=\"checkbox-label disabled\">\n              <input type=\"checkbox\"\n                class=\"mj-checkbox\"\n                formControlName=\"exposeAsAction\"\n                [disabled]=\"true\">\n              Expose As Action\n            </label>\n            <small class=\"field-hint disabled-hint\">\n              <i class=\"fa-solid fa-info-circle\"></i>\n              Sub-agents cannot be exposed as actions. Only root agents (without parents) can be exposed as actions for use by other agents.\n            </small>\n          </div>\n        </div>\n      </div>\n    </form>\n  }\n\n  <!-- Dialog Footer -->\n  <div class=\"dialog-footer\">\n    <button mjButton\n            variant=\"flat\"\n            (click)=\"cancel()\"\n            [disabled]=\"(isSaving$ | async) || false\">\n      Cancel\n    </button>\n\n    <button mjButton\n            variant=\"primary\"\n            (click)=\"save()\"\n            [disabled]=\"((isSaving$ | async) || false) || ((isLoading$ | async) || false) || hasExecutionOrderError()\">\n      @if (isSaving$ | async) {\n        <i class=\"fa-solid fa-spinner fa-spin\"></i>\n        Saving...\n      } @else {\n        <i class=\"fa-solid fa-save\"></i>\n        Save Settings\n      }\n    </button>\n  </div>\n</div>", styles: [".sub-agent-advanced-settings-dialog {\n  display: flex;\n  flex-direction: column;\n  height: 100%;\n  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;\n}\n\n/* Ensure dialog appears above banner and other elements */\n:host ::ng-deep .k-dialog,\n:host ::ng-deep .k-window {\n  z-index: 10000 !important;\n}\n\n:host ::ng-deep .k-overlay {\n  z-index: 9999 !important;\n}\n\n/* === Loading State === */\n.loading-state {\n  display: flex;\n  flex-direction: column;\n  align-items: center;\n  justify-content: center;\n  height: 300px;\n  color: var(--mj-text-muted);\n}\n\n.loading-spinner {\n  margin-bottom: 1rem;\n}\n\n.loading-spinner i {\n  color: var(--mj-brand-primary);\n}\n\n.loading-state p {\n  margin-top: 1rem;\n  font-size: 1.1rem;\n}\n\n/* === Form Layout === */\n.advanced-form {\n  flex: 1;\n  overflow-y: auto;\n  padding: 1.5rem;\n}\n\n.form-section {\n  margin-bottom: 2rem;\n  background: var(--mj-bg-surface);\n  border-radius: 8px;\n  border: 1px solid var(--mj-border-default);\n  overflow: hidden;\n}\n\n.section-title {\n  margin: 0;\n  padding: 1rem 1.5rem;\n  background: var(--mj-bg-surface-card);\n  border-bottom: 1px solid var(--mj-border-default);\n  color: var(--mj-text-secondary);\n  font-size: 1.1rem;\n  font-weight: 600;\n  display: flex;\n  align-items: center;\n  gap: 0.5rem;\n}\n\n.section-title i {\n  color: var(--mj-brand-primary);\n}\n\n.form-grid {\n  display: grid;\n  grid-template-columns: 1fr 1fr;\n  gap: 1.5rem;\n  padding: 1.5rem;\n}\n\n.form-field {\n  display: flex;\n  flex-direction: column;\n  gap: 0.5rem;\n}\n\n.form-field.full-width {\n  grid-column: 1 / -1;\n}\n\n/* === Form Controls === */\nlabel {\n  font-weight: 600;\n  color: var(--mj-text-secondary);\n  font-size: 0.9rem;\n}\n\n.checkbox-label {\n  display: flex;\n  align-items: center;\n  gap: 0.5rem;\n  font-weight: 600;\n  color: var(--mj-text-secondary);\n  cursor: pointer;\n}\n\n.checkbox-label.disabled {\n  color: var(--mj-text-muted);\n  cursor: not-allowed;\n}\n\n.form-control {\n  width: 100%;\n}\n\n.field-hint {\n  color: var(--mj-text-muted);\n  font-size: 0.8rem;\n  margin-top: 0.25rem;\n  line-height: 1.3;\n}\n\n.disabled-hint {\n  color: var(--mj-text-disabled);\n  font-style: italic;\n  display: flex;\n  align-items: center;\n  gap: 0.5rem;\n}\n\n.disabled-hint i {\n  color: var(--mj-brand-primary);\n}\n\n.field-error {\n  color: var(--mj-status-error);\n  font-size: 0.8rem;\n  margin-top: 0.25rem;\n}\n\n/* === Validation States === */\n.form-control.ng-invalid.ng-touched,\n.error-border {\n  border-color: var(--mj-status-error) !important;\n}\n\n.form-control.ng-valid.ng-touched {\n  border-color: var(--mj-status-success);\n}\n\n/* === Execution Mode Option Template === */\n.execution-mode-option {\n  padding: 0.5rem 0;\n}\n\n.option-header {\n  display: flex;\n  align-items: center;\n  gap: 0.5rem;\n  margin-bottom: 0.25rem;\n}\n\n.option-header i {\n  color: var(--mj-brand-primary);\n  width: 16px;\n}\n\n.option-title {\n  font-weight: 500;\n  color: var(--mj-text-primary);\n  font-size: 0.9rem;\n}\n\n.option-description {\n  font-size: 0.8rem;\n  color: var(--mj-text-secondary);\n  line-height: 1.3;\n  margin-left: 1.5rem;\n}\n\n/* === Dialog Footer === */\n.dialog-footer {\n  display: flex;\n  justify-content: flex-end;\n  gap: 1rem;\n  padding: 1rem 1.5rem;\n  border-top: 1px solid var(--mj-border-default);\n  background: var(--mj-bg-surface-card);\n}\n\n.dialog-footer button {\n  min-width: 120px;\n}\n\n.dialog-footer button[themeColor=\"primary\"] i {\n  margin-right: 0.5rem;\n}\n\n/* === Section-Specific Styling === */\n\n/* Execution Configuration */\n.form-section:first-child .section-title {\n  background: color-mix(in srgb, var(--mj-brand-primary) 8%, var(--mj-bg-surface));\n}\n\n/* Agent Configuration */\n.form-section:nth-child(2) .section-title {\n  background: color-mix(in srgb, var(--mj-brand-primary) 8%, var(--mj-bg-surface));\n}\n\n/* Capability Restrictions */\n.form-section:nth-child(3) .section-title {\n  background: color-mix(in srgb, var(--mj-status-warning) 8%, var(--mj-bg-surface));\n}\n\n/* === Responsive Design === */\n@media (max-width: 768px) {\n  .form-grid {\n    grid-template-columns: 1fr;\n    gap: 1rem;\n    padding: 1rem;\n  }\n\n  .form-field.full-width {\n    grid-column: 1;\n  }\n\n  .advanced-form {\n    padding: 1rem;\n  }\n\n  .section-title {\n    padding: 0.75rem 1rem;\n    font-size: 1rem;\n  }\n\n  .dialog-footer {\n    padding: 1rem;\n    flex-direction: column;\n  }\n\n  .dialog-footer button {\n    width: 100%;\n  }\n}\n\n/* === Error Highlighting === */\n.error-border {\n  border: 2px solid var(--mj-status-error) !important;\n  background-color: color-mix(in srgb, var(--mj-status-error) 4%, var(--mj-bg-surface));\n}\n"] }]
    }], () => [{ type: i1.FormBuilder }, { type: i0.ChangeDetectorRef }], { DialogClose: [{
            type: Output
        }] }); })();
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(SubAgentAdvancedSettingsDialogComponent, { className: "SubAgentAdvancedSettingsDialogComponent", filePath: "src/lib/custom/AIAgents/sub-agent-advanced-settings-dialog.component.ts", lineNumber: 28 }); })();
//# sourceMappingURL=sub-agent-advanced-settings-dialog.component.js.map