import { Component } 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 "@progress/kendo-angular-dialog";
import * as i2 from "@angular/forms";
import * as i3 from "@progress/kendo-angular-inputs";
import * as i4 from "@progress/kendo-angular-dropdowns";
import * as i5 from "@progress/kendo-angular-buttons";
import * as i6 from "@angular/common";
const _c0 = () => ({ Name: "Use Agent Default", ID: null });
function AgentPromptAdvancedSettingsDialogComponent_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 prompt settings...");
    i0.ɵɵelementEnd()();
} }
function AgentPromptAdvancedSettingsDialogComponent_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 AgentPromptAdvancedSettingsDialogComponent_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 AgentPromptAdvancedSettingsDialogComponent_Conditional_3_Conditional_24_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 AgentPromptAdvancedSettingsDialogComponent_Conditional_3_ng_template_36_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 29)(1, "div", 30);
    i0.ɵɵtext(2);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(3, "div", 31);
    i0.ɵɵtext(4);
    i0.ɵɵelementEnd()();
} if (rf & 2) {
    const dataItem_r2 = ctx.$implicit;
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate(dataItem_r2.text);
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate(dataItem_r2.description);
} }
function AgentPromptAdvancedSettingsDialogComponent_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("contextBehavior"));
} }
function AgentPromptAdvancedSettingsDialogComponent_Conditional_3_Conditional_40_Conditional_4_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 15);
    i0.ɵɵtext(1);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext(3);
    i0.ɵɵadvance();
    i0.ɵɵtextInterpolate(ctx_r0.getFieldError("contextMessageCount"));
} }
function AgentPromptAdvancedSettingsDialogComponent_Conditional_3_Conditional_40_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 12)(1, "label", 32);
    i0.ɵɵtext(2, "Message Count *");
    i0.ɵɵelementEnd();
    i0.ɵɵelement(3, "kendo-numerictextbox", 33);
    i0.ɵɵconditionalCreate(4, AgentPromptAdvancedSettingsDialogComponent_Conditional_3_Conditional_40_Conditional_4_Template, 2, 1, "div", 15);
    i0.ɵɵelementStart(5, "small", 16);
    i0.ɵɵtext(6);
    i0.ɵɵelementEnd()();
} if (rf & 2) {
    let tmp_5_0;
    const ctx_r0 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(3);
    i0.ɵɵproperty("min", 1)("format", "0");
    i0.ɵɵadvance();
    i0.ɵɵconditional(ctx_r0.isFieldInvalid("contextMessageCount") ? 4 : -1);
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate1("Number of messages to include for ", (tmp_5_0 = ctx_r0.advancedForm.get("contextBehavior")) == null ? null : tmp_5_0.value);
} }
function AgentPromptAdvancedSettingsDialogComponent_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, "kendo-numerictextbox", 14);
    i0.ɵɵconditionalCreate(10, AgentPromptAdvancedSettingsDialogComponent_Conditional_3_Conditional_10_Template, 2, 1, "div", 15);
    i0.ɵɵconditionalCreate(11, AgentPromptAdvancedSettingsDialogComponent_Conditional_3_Conditional_11_Template, 2, 1, "div", 15);
    i0.ɵɵelementStart(12, "small", 16);
    i0.ɵɵtext(13, "Order in which this prompt executes (0 = first). Must be unique among agent prompts.");
    i0.ɵɵelementEnd()();
    i0.ɵɵelementStart(14, "div", 12)(15, "label", 17);
    i0.ɵɵtext(16, "Purpose");
    i0.ɵɵelementEnd();
    i0.ɵɵelement(17, "kendo-textbox", 18);
    i0.ɵɵelementStart(18, "small", 16);
    i0.ɵɵtext(19, "Functional purpose of this prompt within the agent workflow");
    i0.ɵɵelementEnd()();
    i0.ɵɵelementStart(20, "div", 12)(21, "label", 19);
    i0.ɵɵtext(22, "Status *");
    i0.ɵɵelementEnd();
    i0.ɵɵelement(23, "kendo-dropdownlist", 20);
    i0.ɵɵconditionalCreate(24, AgentPromptAdvancedSettingsDialogComponent_Conditional_3_Conditional_24_Template, 2, 1, "div", 15);
    i0.ɵɵelementStart(25, "small", 16);
    i0.ɵɵtext(26, "Current status of this prompt mapping");
    i0.ɵɵelementEnd()()()();
    i0.ɵɵelementStart(27, "div", 8)(28, "h3", 9);
    i0.ɵɵelement(29, "i", 21);
    i0.ɵɵtext(30, " Context Behavior ");
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(31, "div", 11)(32, "div", 22)(33, "label", 23);
    i0.ɵɵtext(34, "Context Behavior *");
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(35, "kendo-dropdownlist", 24);
    i0.ɵɵtemplate(36, AgentPromptAdvancedSettingsDialogComponent_Conditional_3_ng_template_36_Template, 5, 2, "ng-template", 25);
    i0.ɵɵelementEnd();
    i0.ɵɵconditionalCreate(37, AgentPromptAdvancedSettingsDialogComponent_Conditional_3_Conditional_37_Template, 2, 1, "div", 15);
    i0.ɵɵelementStart(38, "small", 16);
    i0.ɵɵtext(39);
    i0.ɵɵelementEnd()();
    i0.ɵɵconditionalCreate(40, AgentPromptAdvancedSettingsDialogComponent_Conditional_3_Conditional_40_Template, 7, 4, "div", 12);
    i0.ɵɵelementEnd()();
    i0.ɵɵelementStart(41, "div", 8)(42, "h3", 9);
    i0.ɵɵelement(43, "i", 26);
    i0.ɵɵtext(44, " AI Configuration Override ");
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(45, "div", 11)(46, "div", 22)(47, "label", 27);
    i0.ɵɵtext(48, "AI Configuration");
    i0.ɵɵelementEnd();
    i0.ɵɵelement(49, "kendo-dropdownlist", 28);
    i0.ɵɵpipe(50, "async");
    i0.ɵɵelementStart(51, "small", 16);
    i0.ɵɵtext(52, "Override the agent's default AI configuration for this specific prompt");
    i0.ɵɵelementEnd()()()()();
} if (rf & 2) {
    let tmp_13_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)("format", "0");
    i0.ɵɵadvance();
    i0.ɵɵconditional(ctx_r0.isFieldInvalid("executionOrder") ? 10 : -1);
    i0.ɵɵadvance();
    i0.ɵɵconditional(ctx_r0.hasExecutionOrderError() ? 11 : -1);
    i0.ɵɵadvance(12);
    i0.ɵɵproperty("data", ctx_r0.statusOptions)("valuePrimitive", true);
    i0.ɵɵadvance();
    i0.ɵɵconditional(ctx_r0.isFieldInvalid("status") ? 24 : -1);
    i0.ɵɵadvance(11);
    i0.ɵɵproperty("data", ctx_r0.contextBehaviorOptions)("valuePrimitive", true);
    i0.ɵɵadvance(2);
    i0.ɵɵconditional(ctx_r0.isFieldInvalid("contextBehavior") ? 37 : -1);
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate(ctx_r0.getContextBehaviorDescription((tmp_13_0 = ctx_r0.advancedForm.get("contextBehavior")) == null ? null : tmp_13_0.value));
    i0.ɵɵadvance();
    i0.ɵɵconditional(ctx_r0.requiresMessageCount() ? 40 : -1);
    i0.ɵɵadvance(9);
    i0.ɵɵproperty("data", i0.ɵɵpipeBind1(50, 18, ctx_r0.configurations$))("valuePrimitive", true)("defaultItem", i0.ɵɵpureFunction0(20, _c0));
} }
function AgentPromptAdvancedSettingsDialogComponent_Conditional_11_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "i", 34);
    i0.ɵɵtext(1, " Saving... ");
} }
function AgentPromptAdvancedSettingsDialogComponent_Conditional_13_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "i", 35);
    i0.ɵɵtext(1, " Save Settings ");
} }
/**
 * Advanced Settings dialog for AI Agent Prompts.
 * Manages execution order, context behavior, and other advanced prompt configurations.
 */
export class AgentPromptAdvancedSettingsDialogComponent {
    constructor(dialogRef, fb, cdr) {
        this.dialogRef = dialogRef;
        this.fb = fb;
        this.cdr = cdr;
        this.allAgentPrompts = []; // 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.configurations$ = new BehaviorSubject([]);
        // Available options
        this.contextBehaviorOptions = [
            { text: 'Complete Context', value: 'Complete', description: 'Include entire conversation context' },
            { text: 'Smart Context', value: 'Smart', description: 'AI determines relevant context automatically' },
            { text: 'No Context', value: 'None', description: 'No conversation context included' },
            { text: 'Recent Messages', value: 'RecentMessages', description: 'Include only recent messages' },
            { text: 'Initial Messages', value: 'InitialMessages', description: 'Include only conversation start' },
            { text: 'Custom Context', value: 'Custom', description: 'Custom context filtering logic' }
        ];
        this.statusOptions = [
            { text: 'Active', value: 'Active' },
            { text: 'Inactive', value: 'Inactive' },
            { text: 'Deprecated', value: 'Deprecated' },
            { text: 'Preview', value: 'Preview' }
        ];
        // Execution order validation
        this.executionOrderError = null;
    }
    ngOnInit() {
        this.initializeForm();
        this.loadDropdownData();
    }
    ngOnDestroy() {
        this.destroy$.next();
        this.destroy$.complete();
    }
    initializeForm() {
        this.advancedForm = this.fb.group({
            executionOrder: [this.agentPrompt.ExecutionOrder || 0, [Validators.required, Validators.min(0)]],
            purpose: [this.agentPrompt.Purpose],
            configurationID: [this.agentPrompt.ConfigurationID],
            contextBehavior: [this.agentPrompt.ContextBehavior || 'Complete', [Validators.required]],
            contextMessageCount: [this.agentPrompt.ContextMessageCount],
            status: [this.agentPrompt.Status || 'Active', [Validators.required]]
        });
        this.setupValidationLogic();
    }
    setupValidationLogic() {
        // Context behavior validation
        const contextBehaviorControl = this.advancedForm.get('contextBehavior');
        const contextMessageCountControl = this.advancedForm.get('contextMessageCount');
        contextBehaviorControl?.valueChanges.pipe(takeUntil(this.destroy$)).subscribe(behavior => {
            if (behavior === 'RecentMessages' || behavior === 'InitialMessages') {
                contextMessageCountControl?.setValidators([Validators.required, Validators.min(1)]);
            }
            else {
                contextMessageCountControl?.clearValidators();
                if (behavior !== 'Custom') {
                    contextMessageCountControl?.setValue(null);
                }
            }
            contextMessageCountControl?.updateValueAndValidity();
        });
        // Execution order validation
        const executionOrderControl = this.advancedForm.get('executionOrder');
        executionOrderControl?.valueChanges.pipe(takeUntil(this.destroy$)).subscribe(order => {
            this.validateExecutionOrder(order);
        });
    }
    validateExecutionOrder(order) {
        if (order == null) {
            this.executionOrderError = null;
            return;
        }
        // Check for conflicts with other prompts (excluding current one)
        const conflictingPrompt = this.allAgentPrompts.find(p => !UUIDsEqual(p.ID, this.agentPrompt.ID) &&
            p.ExecutionOrder === order);
        if (conflictingPrompt) {
            this.executionOrderError = `Execution order ${order} is already used by another prompt. 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 Configurations
            const configurationsResult = await rv.RunView({
                EntityName: 'MJ: AI Configurations',
                ExtraFilter: "Status = 'Active'",
                OrderBy: 'Name',
                ResultType: 'entity_object',
                MaxRows: 1000
            });
            if (configurationsResult.Success) {
                this.configurations$.next(configurationsResult.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;
    }
    // === Context Behavior Helpers ===
    requiresMessageCount() {
        const behavior = this.advancedForm.get('contextBehavior')?.value;
        return behavior === 'RecentMessages' || behavior === 'InitialMessages';
    }
    getContextBehaviorDescription(value) {
        const option = this.contextBehaviorOptions.find(opt => opt.value === value);
        return option?.description || '';
    }
    // === Dialog Actions ===
    cancel() {
        this.result.next(null);
        this.dialogRef.close();
    }
    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,
                purpose: this.advancedForm.get('purpose')?.value || null,
                configurationID: this.advancedForm.get('configurationID')?.value || null,
                contextBehavior: this.advancedForm.get('contextBehavior')?.value,
                contextMessageCount: this.advancedForm.get('contextMessageCount')?.value || null,
                status: this.advancedForm.get('status')?.value
            };
            this.result.next(formData);
            this.dialogRef.close();
        }
        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 AgentPromptAdvancedSettingsDialogComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || AgentPromptAdvancedSettingsDialogComponent)(i0.ɵɵdirectiveInject(i1.WindowRef), i0.ɵɵdirectiveInject(i2.FormBuilder), i0.ɵɵdirectiveInject(i0.ChangeDetectorRef)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: AgentPromptAdvancedSettingsDialogComponent, selectors: [["mj-agent-prompt-advanced-settings-dialog"]], standalone: false, decls: 14, vars: 14, consts: [[1, "prompt-advanced-settings-dialog"], [1, "loading-state"], [1, "advanced-form", 3, "formGroup"], [1, "dialog-footer"], ["kendoButton", "", "look", "flat", 3, "click", "disabled"], ["kendoButton", "", "themeColor", "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-list-ol"], [1, "form-grid"], [1, "form-field"], ["for", "executionOrder"], ["formControlName", "executionOrder", 1, "form-control", 3, "min", "format"], [1, "field-error"], [1, "field-hint"], ["for", "purpose"], ["formControlName", "purpose", "placeholder", "e.g., Initialize, ProcessData, Summarize", 1, "form-control"], ["for", "status"], ["formControlName", "status", "textField", "text", "valueField", "value", 1, "form-control", 3, "data", "valuePrimitive"], [1, "fa-solid", "fa-comments"], [1, "form-field", "full-width"], ["for", "contextBehavior"], ["formControlName", "contextBehavior", "textField", "text", "valueField", "value", 1, "form-control", 3, "data", "valuePrimitive"], ["kendoDropDownListItemTemplate", ""], [1, "fa-solid", "fa-cog"], ["for", "configurationID"], ["formControlName", "configurationID", "textField", "Name", "valueField", "ID", 1, "form-control", 3, "data", "valuePrimitive", "defaultItem"], [1, "context-behavior-option"], [1, "option-title"], [1, "option-description"], ["for", "contextMessageCount"], ["formControlName", "contextMessageCount", 1, "form-control", 3, "min", "format"], [1, "fa-solid", "fa-spinner", "fa-spin"], [1, "fa-solid", "fa-save"]], template: function AgentPromptAdvancedSettingsDialogComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelementStart(0, "div", 0);
            i0.ɵɵconditionalCreate(1, AgentPromptAdvancedSettingsDialogComponent_Conditional_1_Template, 5, 0, "div", 1);
            i0.ɵɵpipe(2, "async");
            i0.ɵɵconditionalBranchCreate(3, AgentPromptAdvancedSettingsDialogComponent_Conditional_3_Template, 53, 21, "form", 2);
            i0.ɵɵelementStart(4, "div", 3)(5, "button", 4);
            i0.ɵɵpipe(6, "async");
            i0.ɵɵlistener("click", function AgentPromptAdvancedSettingsDialogComponent_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 AgentPromptAdvancedSettingsDialogComponent_Template_button_click_8_listener() { return ctx.save(); });
            i0.ɵɵconditionalCreate(11, AgentPromptAdvancedSettingsDialogComponent_Conditional_11_Template, 2, 0);
            i0.ɵɵpipe(12, "async");
            i0.ɵɵconditionalBranchCreate(13, AgentPromptAdvancedSettingsDialogComponent_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: [i2.ɵNgNoValidate, i2.NgControlStatus, i2.NgControlStatusGroup, i2.FormGroupDirective, i2.FormControlName, i3.TextBoxComponent, i3.NumericTextBoxComponent, i4.ItemTemplateDirective, i4.DropDownListComponent, i5.ButtonComponent, i6.AsyncPipe], styles: [".prompt-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.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.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.context-behavior-option[_ngcontent-%COMP%] {\n  padding: 0.5rem 0;\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  margin-top: 0.25rem;\n  line-height: 1.3;\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-success) 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(AgentPromptAdvancedSettingsDialogComponent, [{
        type: Component,
        args: [{ standalone: false, selector: 'mj-agent-prompt-advanced-settings-dialog', template: "<!-- Prompt Advanced Settings Dialog -->\n<div class=\"prompt-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 prompt 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-list-ol\"></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            <kendo-numerictextbox \n              formControlName=\"executionOrder\"\n              [min]=\"0\"\n              [format]=\"'0'\"\n              [class.error-border]=\"hasExecutionOrderError()\"\n              class=\"form-control\">\n            </kendo-numerictextbox>\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 prompt executes (0 = first). Must be unique among agent prompts.</small>\n          </div>\n          \n          <!-- Purpose -->\n          <div class=\"form-field\">\n            <label for=\"purpose\">Purpose</label>\n            <kendo-textbox \n              formControlName=\"purpose\"\n              placeholder=\"e.g., Initialize, ProcessData, Summarize\"\n              class=\"form-control\">\n            </kendo-textbox>\n            <small class=\"field-hint\">Functional purpose of this prompt within the agent workflow</small>\n          </div>\n          \n          <!-- Status -->\n          <div class=\"form-field\">\n            <label for=\"status\">Status *</label>\n            <kendo-dropdownlist \n              formControlName=\"status\"\n              [data]=\"statusOptions\"\n              textField=\"text\"\n              valueField=\"value\"\n              [valuePrimitive]=\"true\"\n              class=\"form-control\">\n            </kendo-dropdownlist>\n            @if (isFieldInvalid('status')) {\n              <div class=\"field-error\">{{ getFieldError('status') }}</div>\n            }\n            <small class=\"field-hint\">Current status of this prompt mapping</small>\n          </div>\n        </div>\n      </div>\n\n      <!-- Context Behavior Section -->\n      <div class=\"form-section\">\n        <h3 class=\"section-title\">\n          <i class=\"fa-solid fa-comments\"></i>\n          Context Behavior\n        </h3>\n        \n        <div class=\"form-grid\">\n          <!-- Context Behavior -->\n          <div class=\"form-field full-width\">\n            <label for=\"contextBehavior\">Context Behavior *</label>\n            <kendo-dropdownlist \n              formControlName=\"contextBehavior\"\n              [data]=\"contextBehaviorOptions\"\n              textField=\"text\"\n              valueField=\"value\"\n              [valuePrimitive]=\"true\"\n              class=\"form-control\">\n              <ng-template kendoDropDownListItemTemplate let-dataItem>\n                <div class=\"context-behavior-option\">\n                  <div class=\"option-title\">{{ dataItem.text }}</div>\n                  <div class=\"option-description\">{{ dataItem.description }}</div>\n                </div>\n              </ng-template>\n            </kendo-dropdownlist>\n            @if (isFieldInvalid('contextBehavior')) {\n              <div class=\"field-error\">{{ getFieldError('contextBehavior') }}</div>\n            }\n            <small class=\"field-hint\">{{ getContextBehaviorDescription(advancedForm.get('contextBehavior')?.value) }}</small>\n          </div>\n          \n          <!-- Context Message Count (conditional) -->\n          @if (requiresMessageCount()) {\n            <div class=\"form-field\">\n              <label for=\"contextMessageCount\">Message Count *</label>\n              <kendo-numerictextbox \n                formControlName=\"contextMessageCount\"\n                [min]=\"1\"\n                [format]=\"'0'\"\n                class=\"form-control\">\n              </kendo-numerictextbox>\n              @if (isFieldInvalid('contextMessageCount')) {\n                <div class=\"field-error\">{{ getFieldError('contextMessageCount') }}</div>\n              }\n              <small class=\"field-hint\">Number of messages to include for {{ advancedForm.get('contextBehavior')?.value }}</small>\n            </div>\n          }\n        </div>\n      </div>\n\n      <!-- AI Configuration Section -->\n      <div class=\"form-section\">\n        <h3 class=\"section-title\">\n          <i class=\"fa-solid fa-cog\"></i>\n          AI Configuration Override\n        </h3>\n        \n        <div class=\"form-grid\">\n          <!-- Configuration Override -->\n          <div class=\"form-field full-width\">\n            <label for=\"configurationID\">AI Configuration</label>\n            <kendo-dropdownlist \n              formControlName=\"configurationID\"\n              [data]=\"configurations$ | async\"\n              textField=\"Name\"\n              valueField=\"ID\"\n              [valuePrimitive]=\"true\"\n              [defaultItem]=\"{ Name: 'Use Agent Default', ID: null }\"\n              class=\"form-control\">\n            </kendo-dropdownlist>\n            <small class=\"field-hint\">Override the agent's default AI configuration for this specific prompt</small>\n          </div>\n        </div>\n      </div>\n    </form>\n  }\n\n  <!-- Dialog Footer -->\n  <div class=\"dialog-footer\">\n    <button kendoButton \n            look=\"flat\" \n            (click)=\"cancel()\"\n            [disabled]=\"(isSaving$ | async) || false\">\n      Cancel\n    </button>\n    \n    <button kendoButton \n            themeColor=\"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: [".prompt-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.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.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/* === Context Behavior Option Template === */\n.context-behavior-option {\n  padding: 0.5rem 0;\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  margin-top: 0.25rem;\n  line-height: 1.3;\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/* Context Behavior */\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/* AI Configuration */\n.form-section:nth-child(3) .section-title {\n  background: color-mix(in srgb, var(--mj-status-success) 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.WindowRef }, { type: i2.FormBuilder }, { type: i0.ChangeDetectorRef }], null); })();
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(AgentPromptAdvancedSettingsDialogComponent, { className: "AgentPromptAdvancedSettingsDialogComponent", filePath: "src/lib/custom/AIAgents/agent-prompt-advanced-settings-dialog.component.ts", lineNumber: 29 }); })();
//# sourceMappingURL=agent-prompt-advanced-settings-dialog.component.js.map