import { Component, Input } from '@angular/core';
import { Validators } from '@angular/forms';
import { Metadata } from '@memberjunction/core';
import { MJNotificationService } from '@memberjunction/ng-notifications';
import { BehaviorSubject } from 'rxjs';
import { AIEngineBase } from '@memberjunction/ai-engine-base';
import * as i0 from "@angular/core";
import * as i1 from "@angular/forms";
import * as i2 from "@memberjunction/ng-shared";
import * as i3 from "@memberjunction/ng-ui-components";
import * as i4 from "@angular/common";
function NewAgentDialogComponent_Conditional_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 2);
    i0.ɵɵelement(1, "i", 28);
    i0.ɵɵelementStart(2, "span");
    i0.ɵɵtext(3, "Creating sub-agent for: ");
    i0.ɵɵelementStart(4, "strong");
    i0.ɵɵtext(5);
    i0.ɵɵelementEnd()()();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance(5);
    i0.ɵɵtextInterpolate(ctx_r0.config.parentAgentName || "Parent Agent");
} }
function NewAgentDialogComponent_Conditional_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 3)(1, "div", 29);
    i0.ɵɵtext(2, "Loading...");
    i0.ɵɵelementEnd()();
} }
function NewAgentDialogComponent_Conditional_10_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 8);
    i0.ɵɵelement(1, "i", 30);
    i0.ɵɵtext(2, " Agent name is required ");
    i0.ɵɵelementEnd();
} }
function NewAgentDialogComponent_Conditional_20_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 8);
    i0.ɵɵelement(1, "i", 30);
    i0.ɵɵtext(2, " Please select an AI model ");
    i0.ɵɵelementEnd();
} }
function NewAgentDialogComponent_Conditional_59_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "span", 31);
    i0.ɵɵelementStart(1, "span");
    i0.ɵɵtext(2, "Creating...");
    i0.ɵɵelementEnd();
} }
function NewAgentDialogComponent_Conditional_60_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "i", 32);
    i0.ɵɵelementStart(1, "span");
    i0.ɵɵtext(2, "Create Agent");
    i0.ɵɵelementEnd();
} }
export class NewAgentDialogComponent {
    constructor(fb, navigationService) {
        this.fb = fb;
        this.navigationService = navigationService;
        this.config = {
            redirectToForm: true
        };
        this.isLoading$ = new BehaviorSubject(false);
        this.models$ = new BehaviorSubject([]);
        this.agentTypes$ = new BehaviorSubject([]);
        this.isSubmitting = false;
        /** Set by NewAgentDialogService after creation */
        this.dialogRef = null;
    }
    ngOnInit() {
        this.initializeForm();
        this.loadData();
    }
    initializeForm() {
        this.form = this.fb.group({
            name: ['', [Validators.required, Validators.maxLength(255)]],
            description: [''],
            modelId: ['', Validators.required],
            agentType: ['standard', Validators.required],
            systemPrompt: ['You are a helpful AI assistant.'],
            enableStreaming: [true],
            temperature: [0.7, [Validators.min(0), Validators.max(2)]],
            maxTokens: [2000, [Validators.min(1), Validators.max(8000)]]
        });
    }
    async loadData() {
        this.isLoading$.next(true);
        try {
            const engine = AIEngineBase.Instance;
            await engine.Config(false);
            const models = engine.Models;
            models.sort((a, b) => {
                return a.Name.localeCompare(b.Name);
            });
            this.models$.next(models || []);
            // Pre-select first model if available
            if (models && models.length > 0) {
                this.form.patchValue({ modelId: models[0].ID });
            }
            const agentTypes = engine.AgentTypes;
            this.agentTypes$.next(agentTypes || []);
        }
        catch (error) {
            console.error('Error loading data:', error);
            console.error('Failed to load required data');
        }
        finally {
            this.isLoading$.next(false);
        }
    }
    async onSubmit() {
        if (this.form.invalid || this.isSubmitting) {
            return;
        }
        this.isSubmitting = true;
        try {
            const md = new Metadata();
            const agent = await md.GetEntityObject('MJ: AI Agents');
            if (!agent) {
                throw new Error('Failed to create agent entity');
            }
            // Set agent properties
            agent.Name = this.form.value.name;
            agent.Description = this.form.value.description;
            // Set parent agent if provided
            if (this.config.parentAgentId) {
                agent.ParentID = this.config.parentAgentId;
            }
            // Set execution mode
            agent.ExecutionMode = 'Sequential';
            agent.ExecutionOrder = 0;
            agent.ExposeAsAction = false;
            // Save the agent
            const saveResult = await agent.Save();
            if (saveResult) {
                MJNotificationService.Instance.CreateSimpleNotification('Agent created successfully!', 'success', 3000);
                // Close dialog with the new agent
                this.dialogRef?.Close({ agent, action: 'created' });
                // Redirect to form if configured
                if (this.config.redirectToForm && !this.config.parentAgentId) {
                    // Only redirect for top-level agents - use NavigationService to open the record
                    setTimeout(() => {
                        this.navigationService.OpenEntityRecord('MJ: AI Agents', agent.PrimaryKey);
                    }, 100);
                }
            }
            else {
                throw new Error('Failed to save agent');
            }
        }
        catch (error) {
            const errorMessage = error instanceof Error ? error.message : 'Unknown error';
            console.error('Error creating agent:', error);
            MJNotificationService.Instance.CreateSimpleNotification('Failed to create agent: ' + errorMessage, 'error', 5000);
        }
        finally {
            this.isSubmitting = false;
        }
    }
    onCancel() {
        this.dialogRef?.Close({ action: 'cancelled' });
    }
    static { this.ɵfac = function NewAgentDialogComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || NewAgentDialogComponent)(i0.ɵɵdirectiveInject(i1.FormBuilder), i0.ɵɵdirectiveInject(i2.NavigationService)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: NewAgentDialogComponent, selectors: [["mj-new-agent-dialog"]], inputs: { config: "config" }, standalone: false, decls: 61, vars: 17, consts: [[1, "new-agent-dialog"], [3, "ngSubmit", "formGroup"], [1, "parent-info"], [1, "loading-overlay"], [1, "form-fields"], [1, "form-group"], [1, "required"], ["formControlName", "name", "placeholder", "Enter a descriptive name for your agent", 1, "mj-input", "full-width"], [1, "error-message"], ["formControlName", "description", "placeholder", "Describe what this agent does...", "rows", "3", 1, "mj-textarea", "full-width"], ["formControlName", "modelId", "TextField", "Name", "ValueField", "ID", "Placeholder", "Select an AI model...", 1, "full-width", 3, "Data"], ["formControlName", "systemPrompt", "placeholder", "Define the agent's behavior and personality...", "rows", "4", 1, "mj-textarea", "full-width"], [1, "field-hint"], [1, "fa-solid", "fa-info-circle"], [1, "advanced-settings"], [1, "section-header"], [1, "fa-solid", "fa-cog"], [1, "advanced-grid"], [1, "setting-group"], [1, "slider-container"], ["type", "range", "formControlName", "temperature", "min", "0", "max", "2", "step", "0.1", 1, "mj-input", "temperature-slider"], [1, "slider-value"], ["formControlName", "maxTokens", "Format", "n0", 1, "full-width", 3, "Min", "Max", "Step"], [1, "setting-group", "checkbox-group"], ["type", "checkbox", "formControlName", "enableStreaming", 1, "mj-checkbox"], [1, "dialog-actions"], ["type", "button", "mjButton", "", 3, "click", "disabled"], ["type", "submit", "mjButton", "", "variant", "primary", 3, "disabled"], [1, "fa-solid", "fa-robot"], [1, "spinner"], [1, "fa-solid", "fa-exclamation-circle"], [1, "spinner-small"], [1, "fa-solid", "fa-plus-circle"]], template: function NewAgentDialogComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelementStart(0, "div", 0)(1, "form", 1);
            i0.ɵɵlistener("ngSubmit", function NewAgentDialogComponent_Template_form_ngSubmit_1_listener() { return ctx.onSubmit(); });
            i0.ɵɵconditionalCreate(2, NewAgentDialogComponent_Conditional_2_Template, 6, 1, "div", 2);
            i0.ɵɵconditionalCreate(3, NewAgentDialogComponent_Conditional_3_Template, 3, 0, "div", 3);
            i0.ɵɵpipe(4, "async");
            i0.ɵɵelementStart(5, "div", 4)(6, "div", 5)(7, "label", 6);
            i0.ɵɵtext(8, "Agent Name");
            i0.ɵɵelementEnd();
            i0.ɵɵelement(9, "input", 7);
            i0.ɵɵconditionalCreate(10, NewAgentDialogComponent_Conditional_10_Template, 3, 0, "div", 8);
            i0.ɵɵelementEnd();
            i0.ɵɵelementStart(11, "div", 5)(12, "label");
            i0.ɵɵtext(13, "Description");
            i0.ɵɵelementEnd();
            i0.ɵɵelement(14, "textarea", 9);
            i0.ɵɵelementEnd();
            i0.ɵɵelementStart(15, "div", 5)(16, "label", 6);
            i0.ɵɵtext(17, "AI Model");
            i0.ɵɵelementEnd();
            i0.ɵɵelement(18, "mj-dropdown", 10);
            i0.ɵɵpipe(19, "async");
            i0.ɵɵconditionalCreate(20, NewAgentDialogComponent_Conditional_20_Template, 3, 0, "div", 8);
            i0.ɵɵelementEnd();
            i0.ɵɵelementStart(21, "div", 5)(22, "label");
            i0.ɵɵtext(23, "System Prompt");
            i0.ɵɵelementEnd();
            i0.ɵɵelement(24, "textarea", 11);
            i0.ɵɵelementStart(25, "div", 12);
            i0.ɵɵelement(26, "i", 13);
            i0.ɵɵtext(27, " This sets the agent's context and behavior ");
            i0.ɵɵelementEnd()();
            i0.ɵɵelementStart(28, "div", 14)(29, "div", 15);
            i0.ɵɵelement(30, "i", 16);
            i0.ɵɵtext(31, " Advanced Settings ");
            i0.ɵɵelementEnd();
            i0.ɵɵelementStart(32, "div", 17)(33, "div", 18)(34, "label");
            i0.ɵɵtext(35, "Temperature");
            i0.ɵɵelementEnd();
            i0.ɵɵelementStart(36, "div", 19);
            i0.ɵɵelement(37, "input", 20);
            i0.ɵɵelementStart(38, "span", 21);
            i0.ɵɵtext(39);
            i0.ɵɵelementEnd()();
            i0.ɵɵelementStart(40, "div", 12);
            i0.ɵɵtext(41, "Higher values make output more creative");
            i0.ɵɵelementEnd()();
            i0.ɵɵelementStart(42, "div", 18)(43, "label");
            i0.ɵɵtext(44, "Max Tokens");
            i0.ɵɵelementEnd();
            i0.ɵɵelement(45, "mj-numeric-input", 22);
            i0.ɵɵelementStart(46, "div", 12);
            i0.ɵɵtext(47, "Maximum response length");
            i0.ɵɵelementEnd()();
            i0.ɵɵelementStart(48, "div", 23)(49, "label");
            i0.ɵɵelement(50, "input", 24);
            i0.ɵɵelementStart(51, "span");
            i0.ɵɵtext(52, "Enable Response Streaming");
            i0.ɵɵelementEnd()();
            i0.ɵɵelementStart(53, "div", 12);
            i0.ɵɵtext(54, "Stream responses in real-time");
            i0.ɵɵelementEnd()()()()();
            i0.ɵɵelementStart(55, "div", 25)(56, "button", 26);
            i0.ɵɵlistener("click", function NewAgentDialogComponent_Template_button_click_56_listener() { return ctx.onCancel(); });
            i0.ɵɵtext(57, " Cancel ");
            i0.ɵɵelementEnd();
            i0.ɵɵelementStart(58, "button", 27);
            i0.ɵɵconditionalCreate(59, NewAgentDialogComponent_Conditional_59_Template, 3, 0)(60, NewAgentDialogComponent_Conditional_60_Template, 3, 0);
            i0.ɵɵelementEnd()()()();
        } if (rf & 2) {
            let tmp_3_0;
            let tmp_5_0;
            let tmp_6_0;
            i0.ɵɵadvance();
            i0.ɵɵproperty("formGroup", ctx.form);
            i0.ɵɵadvance();
            i0.ɵɵconditional(ctx.config.parentAgentId ? 2 : -1);
            i0.ɵɵadvance();
            i0.ɵɵconditional(i0.ɵɵpipeBind1(4, 13, ctx.isLoading$) ? 3 : -1);
            i0.ɵɵadvance(7);
            i0.ɵɵconditional(((tmp_3_0 = ctx.form.get("name")) == null ? null : tmp_3_0.invalid) && ((tmp_3_0 = ctx.form.get("name")) == null ? null : tmp_3_0.touched) ? 10 : -1);
            i0.ɵɵadvance(8);
            i0.ɵɵproperty("Data", i0.ɵɵpipeBind1(19, 15, ctx.models$));
            i0.ɵɵadvance(2);
            i0.ɵɵconditional(((tmp_5_0 = ctx.form.get("modelId")) == null ? null : tmp_5_0.invalid) && ((tmp_5_0 = ctx.form.get("modelId")) == null ? null : tmp_5_0.touched) ? 20 : -1);
            i0.ɵɵadvance(19);
            i0.ɵɵtextInterpolate((tmp_6_0 = ctx.form.get("temperature")) == null ? null : tmp_6_0.value);
            i0.ɵɵadvance(6);
            i0.ɵɵproperty("Min", 1)("Max", 8000)("Step", 100);
            i0.ɵɵadvance(11);
            i0.ɵɵproperty("disabled", ctx.isSubmitting);
            i0.ɵɵadvance(2);
            i0.ɵɵproperty("disabled", ctx.form.invalid || ctx.isSubmitting);
            i0.ɵɵadvance();
            i0.ɵɵconditional(ctx.isSubmitting ? 59 : 60);
        } }, dependencies: [i1.ɵNgNoValidate, i1.DefaultValueAccessor, i1.RangeValueAccessor, i1.CheckboxControlValueAccessor, i1.NgControlStatus, i1.NgControlStatusGroup, i1.FormGroupDirective, i1.FormControlName, i3.MJButtonDirective, i3.MJDropdownComponent, i3.MJNumericInputComponent, i4.AsyncPipe], styles: [".new-agent-dialog[_ngcontent-%COMP%] {\n  padding: 1.5rem;\n  min-width: 500px;\n  position: relative;\n}\n\n.new-agent-dialog[_ngcontent-%COMP%]   .parent-info[_ngcontent-%COMP%] {\n  background: color-mix(in srgb, var(--mj-brand-primary) 8%, var(--mj-bg-surface));\n  border: 1px solid color-mix(in srgb, var(--mj-brand-primary) 25%, var(--mj-bg-surface));\n  border-radius: 8px;\n  padding: 0.75rem 1rem;\n  margin-bottom: 1.5rem;\n  display: flex;\n  align-items: center;\n  gap: 0.5rem;\n}\n\n.new-agent-dialog[_ngcontent-%COMP%]   .parent-info[_ngcontent-%COMP%]   i[_ngcontent-%COMP%] {\n  color: var(--mj-brand-primary);\n  font-size: 1.1rem;\n}\n\n.new-agent-dialog[_ngcontent-%COMP%]   .parent-info[_ngcontent-%COMP%]   strong[_ngcontent-%COMP%] {\n  color: var(--mj-brand-primary);\n}\n\n.new-agent-dialog[_ngcontent-%COMP%]   .loading-overlay[_ngcontent-%COMP%] {\n  position: absolute;\n  top: 0;\n  left: 0;\n  right: 0;\n  bottom: 0;\n  background: color-mix(in srgb, var(--mj-bg-surface) 90%, transparent);\n  display: flex;\n  align-items: center;\n  justify-content: center;\n  z-index: 100;\n  border-radius: 8px;\n}\n\n.new-agent-dialog[_ngcontent-%COMP%]   .form-fields[_ngcontent-%COMP%]   .form-group[_ngcontent-%COMP%] {\n  margin-bottom: 1.5rem;\n}\n\n.new-agent-dialog[_ngcontent-%COMP%]   .form-fields[_ngcontent-%COMP%]   .form-group[_ngcontent-%COMP%]   label[_ngcontent-%COMP%] {\n  display: block;\n  font-weight: 500;\n  margin-bottom: 0.5rem;\n  color: var(--mj-text-secondary);\n}\n\n.new-agent-dialog[_ngcontent-%COMP%]   .form-fields[_ngcontent-%COMP%]   .form-group[_ngcontent-%COMP%]   label.required[_ngcontent-%COMP%]::after {\n  content: ' *';\n  color: var(--mj-status-error);\n}\n\n.new-agent-dialog[_ngcontent-%COMP%]   .form-fields[_ngcontent-%COMP%]   .form-group[_ngcontent-%COMP%]   .full-width[_ngcontent-%COMP%] {\n  width: 100%;\n}\n\n.new-agent-dialog[_ngcontent-%COMP%]   .form-fields[_ngcontent-%COMP%]   .form-group[_ngcontent-%COMP%]   .error-message[_ngcontent-%COMP%] {\n  color: var(--mj-status-error);\n  font-size: 0.875rem;\n  margin-top: 0.25rem;\n  display: flex;\n  align-items: center;\n  gap: 0.25rem;\n}\n\n.new-agent-dialog[_ngcontent-%COMP%]   .form-fields[_ngcontent-%COMP%]   .form-group[_ngcontent-%COMP%]   .error-message[_ngcontent-%COMP%]   i[_ngcontent-%COMP%] {\n  font-size: 0.75rem;\n}\n\n.new-agent-dialog[_ngcontent-%COMP%]   .form-fields[_ngcontent-%COMP%]   .form-group[_ngcontent-%COMP%]   .field-hint[_ngcontent-%COMP%] {\n  font-size: 0.875rem;\n  color: var(--mj-text-muted);\n  margin-top: 0.25rem;\n  display: flex;\n  align-items: center;\n  gap: 0.25rem;\n}\n\n.new-agent-dialog[_ngcontent-%COMP%]   .form-fields[_ngcontent-%COMP%]   .form-group[_ngcontent-%COMP%]   .field-hint[_ngcontent-%COMP%]   i[_ngcontent-%COMP%] {\n  font-size: 0.75rem;\n}\n\n.new-agent-dialog[_ngcontent-%COMP%]   .form-fields[_ngcontent-%COMP%]   .model-item[_ngcontent-%COMP%] {\n  display: flex;\n  align-items: center;\n  gap: 0.75rem;\n  padding: 0.5rem 0;\n}\n\n.new-agent-dialog[_ngcontent-%COMP%]   .form-fields[_ngcontent-%COMP%]   .model-item[_ngcontent-%COMP%]   .model-icon[_ngcontent-%COMP%] {\n  width: 36px;\n  height: 36px;\n  border-radius: 6px;\n  background: var(--mj-brand-primary);\n  display: flex;\n  align-items: center;\n  justify-content: center;\n  color: var(--mj-text-inverse);\n}\n\n.new-agent-dialog[_ngcontent-%COMP%]   .form-fields[_ngcontent-%COMP%]   .model-item[_ngcontent-%COMP%]   .model-icon[_ngcontent-%COMP%]   i[_ngcontent-%COMP%] {\n  font-size: 1rem;\n}\n\n.new-agent-dialog[_ngcontent-%COMP%]   .form-fields[_ngcontent-%COMP%]   .model-item[_ngcontent-%COMP%]   .model-details[_ngcontent-%COMP%] {\n  display: flex;\n  flex-direction: column;\n}\n\n.new-agent-dialog[_ngcontent-%COMP%]   .form-fields[_ngcontent-%COMP%]   .model-item[_ngcontent-%COMP%]   .model-details[_ngcontent-%COMP%]   .model-name[_ngcontent-%COMP%] {\n  font-weight: 500;\n}\n\n.new-agent-dialog[_ngcontent-%COMP%]   .form-fields[_ngcontent-%COMP%]   .model-item[_ngcontent-%COMP%]   .model-details[_ngcontent-%COMP%]   .model-vendor[_ngcontent-%COMP%] {\n  font-size: 0.75rem;\n  color: var(--mj-text-muted);\n}\n\n.new-agent-dialog[_ngcontent-%COMP%]   .form-fields[_ngcontent-%COMP%]   .k-textbox[_ngcontent-%COMP%], \n.new-agent-dialog[_ngcontent-%COMP%]   .form-fields[_ngcontent-%COMP%]   .k-textarea[_ngcontent-%COMP%], \n.new-agent-dialog[_ngcontent-%COMP%]   .form-fields[_ngcontent-%COMP%]   .k-dropdown[_ngcontent-%COMP%], \n.new-agent-dialog[_ngcontent-%COMP%]   .form-fields[_ngcontent-%COMP%]   .k-numerictextbox[_ngcontent-%COMP%] {\n  border-radius: 6px;\n}\n\n.new-agent-dialog[_ngcontent-%COMP%]   .advanced-settings[_ngcontent-%COMP%] {\n  margin-top: 1.5rem;\n  border-radius: 8px;\n  overflow: hidden;\n}\n\n.new-agent-dialog[_ngcontent-%COMP%]   .advanced-settings[_ngcontent-%COMP%]   .k-expander-header[_ngcontent-%COMP%] {\n  background: var(--mj-bg-surface-card);\n  padding: 1rem;\n}\n\n.new-agent-dialog[_ngcontent-%COMP%]   .advanced-settings[_ngcontent-%COMP%]   .k-expander-header[_ngcontent-%COMP%]   i[_ngcontent-%COMP%] {\n  margin-right: 0.5rem;\n  color: var(--mj-brand-primary);\n}\n\n.new-agent-dialog[_ngcontent-%COMP%]   .advanced-settings[_ngcontent-%COMP%]   .advanced-grid[_ngcontent-%COMP%] {\n  padding: 1rem;\n  display: grid;\n  gap: 1.5rem;\n}\n\n.new-agent-dialog[_ngcontent-%COMP%]   .advanced-settings[_ngcontent-%COMP%]   .advanced-grid[_ngcontent-%COMP%]   .setting-group[_ngcontent-%COMP%]   label[_ngcontent-%COMP%] {\n  display: block;\n  font-weight: 500;\n  margin-bottom: 0.5rem;\n  color: var(--mj-text-secondary);\n}\n\n.new-agent-dialog[_ngcontent-%COMP%]   .advanced-settings[_ngcontent-%COMP%]   .advanced-grid[_ngcontent-%COMP%]   .setting-group[_ngcontent-%COMP%]   .slider-container[_ngcontent-%COMP%] {\n  display: flex;\n  align-items: center;\n  gap: 1rem;\n}\n\n.new-agent-dialog[_ngcontent-%COMP%]   .advanced-settings[_ngcontent-%COMP%]   .advanced-grid[_ngcontent-%COMP%]   .setting-group[_ngcontent-%COMP%]   .slider-container[_ngcontent-%COMP%]   .temperature-slider[_ngcontent-%COMP%] {\n  flex: 1;\n}\n\n.new-agent-dialog[_ngcontent-%COMP%]   .advanced-settings[_ngcontent-%COMP%]   .advanced-grid[_ngcontent-%COMP%]   .setting-group[_ngcontent-%COMP%]   .slider-container[_ngcontent-%COMP%]   .slider-value[_ngcontent-%COMP%] {\n  min-width: 3rem;\n  text-align: right;\n  font-weight: 600;\n  color: var(--mj-brand-primary);\n}\n\n.new-agent-dialog[_ngcontent-%COMP%]   .advanced-settings[_ngcontent-%COMP%]   .advanced-grid[_ngcontent-%COMP%]   .setting-group.checkbox-group[_ngcontent-%COMP%]   label[_ngcontent-%COMP%] {\n  display: flex;\n  align-items: center;\n  gap: 0.5rem;\n  cursor: pointer;\n  font-weight: normal;\n}\n\n.new-agent-dialog[_ngcontent-%COMP%]   .advanced-settings[_ngcontent-%COMP%]   .advanced-grid[_ngcontent-%COMP%]   .setting-group.checkbox-group[_ngcontent-%COMP%]   label[_ngcontent-%COMP%]   input[type=\"checkbox\"][_ngcontent-%COMP%] {\n  cursor: pointer;\n}\n\n.new-agent-dialog[_ngcontent-%COMP%]   .dialog-actions[_ngcontent-%COMP%] {\n  display: flex;\n  justify-content: flex-end;\n  gap: 0.75rem;\n  margin-top: 2rem;\n  padding-top: 1.5rem;\n  border-top: 1px solid var(--mj-border-default);\n}\n\n.new-agent-dialog[_ngcontent-%COMP%]   .dialog-actions[_ngcontent-%COMP%]   button[_ngcontent-%COMP%] {\n  min-width: 120px;\n}\n\n.new-agent-dialog[_ngcontent-%COMP%]   .dialog-actions[_ngcontent-%COMP%]   button[_ngcontent-%COMP%]   i[_ngcontent-%COMP%] {\n  margin-right: 0.5rem;\n}"] }); }
}
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(NewAgentDialogComponent, [{
        type: Component,
        args: [{ standalone: false, selector: 'mj-new-agent-dialog', template: "<div class=\"new-agent-dialog\">\n  <form [formGroup]=\"form\" (ngSubmit)=\"onSubmit()\">\n    <!-- Parent Agent Info (if creating sub-agent) -->\n    @if (config.parentAgentId) {\n      <div class=\"parent-info\">\n        <i class=\"fa-solid fa-robot\"></i>\n        <span>Creating sub-agent for: <strong>{{ config.parentAgentName || 'Parent Agent' }}</strong></span>\n      </div>\n    }\n    \n    <!-- Loading State -->\n    @if (isLoading$ | async) {\n      <div class=\"loading-overlay\">\n        <div class=\"spinner\">Loading...</div>\n      </div>\n    }\n    \n    <!-- Form Fields -->\n    <div class=\"form-fields\">\n      <!-- Agent Name -->\n      <div class=\"form-group\">\n        <label class=\"required\">Agent Name</label>\n        <input\n          class=\"mj-input full-width\"\n          formControlName=\"name\"\n          placeholder=\"Enter a descriptive name for your agent\">\n        @if (form.get('name')?.invalid && form.get('name')?.touched) {\n          <div class=\"error-message\">\n            <i class=\"fa-solid fa-exclamation-circle\"></i>\n            Agent name is required\n          </div>\n        }\n      </div>\n      \n      <!-- Description -->\n      <div class=\"form-group\">\n        <label>Description</label>\n        <textarea\n          class=\"mj-textarea full-width\"\n          formControlName=\"description\"\n          placeholder=\"Describe what this agent does...\"\n          rows=\"3\"></textarea>\n      </div>\n      \n      <!-- AI Model Selection -->\n      <div class=\"form-group\">\n        <label class=\"required\">AI Model</label>\n        <mj-dropdown\n          formControlName=\"modelId\"\n          [Data]=\"models$ | async\"\n          TextField=\"Name\"\n          ValueField=\"ID\"\n          Placeholder=\"Select an AI model...\"\n          class=\"full-width\">\n        </mj-dropdown>\n        @if (form.get('modelId')?.invalid && form.get('modelId')?.touched) {\n          <div class=\"error-message\">\n            <i class=\"fa-solid fa-exclamation-circle\"></i>\n            Please select an AI model\n          </div>\n        }\n      </div>\n      \n      <!-- System Prompt -->\n      <div class=\"form-group\">\n        <label>System Prompt</label>\n        <textarea\n          class=\"mj-textarea full-width\"\n          formControlName=\"systemPrompt\"\n          placeholder=\"Define the agent's behavior and personality...\"\n          rows=\"4\"></textarea>\n        <div class=\"field-hint\">\n          <i class=\"fa-solid fa-info-circle\"></i>\n          This sets the agent's context and behavior\n        </div>\n      </div>\n      \n      <!-- Advanced Settings -->\n      <div class=\"advanced-settings\">\n        <div class=\"section-header\">\n          <i class=\"fa-solid fa-cog\"></i>\n          Advanced Settings\n        </div>\n        \n        <div class=\"advanced-grid\">\n          <!-- Temperature -->\n          <div class=\"setting-group\">\n            <label>Temperature</label>\n            <div class=\"slider-container\">\n              <input\n                type=\"range\"\n                class=\"mj-input temperature-slider\"\n                formControlName=\"temperature\"\n                min=\"0\"\n                max=\"2\"\n                step=\"0.1\">\n              <span class=\"slider-value\">{{ form.get('temperature')?.value }}</span>\n            </div>\n            <div class=\"field-hint\">Higher values make output more creative</div>\n          </div>\n          \n          <!-- Max Tokens -->\n          <div class=\"setting-group\">\n            <label>Max Tokens</label>\n            <mj-numeric-input\n              formControlName=\"maxTokens\"\n              [Min]=\"1\"\n              [Max]=\"8000\"\n              [Step]=\"100\"\n              Format=\"n0\"\n              class=\"full-width\">\n            </mj-numeric-input>\n            <div class=\"field-hint\">Maximum response length</div>\n          </div>\n          \n          <!-- Enable Streaming -->\n          <div class=\"setting-group checkbox-group\">\n            <label>\n              <input type=\"checkbox\" formControlName=\"enableStreaming\" class=\"mj-checkbox\" />\n              <span>Enable Response Streaming</span>\n            </label>\n            <div class=\"field-hint\">Stream responses in real-time</div>\n          </div>\n        </div>\n      </div>\n    </div>\n    \n    <!-- Dialog Actions -->\n    <div class=\"dialog-actions\">\n      <button\n        type=\"button\"\n        mjButton\n        (click)=\"onCancel()\"\n        [disabled]=\"isSubmitting\">\n        Cancel\n      </button>\n      <button\n        type=\"submit\"\n        mjButton\n        variant=\"primary\"\n        [disabled]=\"form.invalid || isSubmitting\">\n        @if (isSubmitting) {\n          <span class=\"spinner-small\"></span>\n          <span>Creating...</span>\n        } @else {\n          <i class=\"fa-solid fa-plus-circle\"></i>\n          <span>Create Agent</span>\n        }\n      </button>\n    </div>\n  </form>\n</div>", styles: [".new-agent-dialog {\n  padding: 1.5rem;\n  min-width: 500px;\n  position: relative;\n}\n\n.new-agent-dialog .parent-info {\n  background: color-mix(in srgb, var(--mj-brand-primary) 8%, var(--mj-bg-surface));\n  border: 1px solid color-mix(in srgb, var(--mj-brand-primary) 25%, var(--mj-bg-surface));\n  border-radius: 8px;\n  padding: 0.75rem 1rem;\n  margin-bottom: 1.5rem;\n  display: flex;\n  align-items: center;\n  gap: 0.5rem;\n}\n\n.new-agent-dialog .parent-info i {\n  color: var(--mj-brand-primary);\n  font-size: 1.1rem;\n}\n\n.new-agent-dialog .parent-info strong {\n  color: var(--mj-brand-primary);\n}\n\n.new-agent-dialog .loading-overlay {\n  position: absolute;\n  top: 0;\n  left: 0;\n  right: 0;\n  bottom: 0;\n  background: color-mix(in srgb, var(--mj-bg-surface) 90%, transparent);\n  display: flex;\n  align-items: center;\n  justify-content: center;\n  z-index: 100;\n  border-radius: 8px;\n}\n\n.new-agent-dialog .form-fields .form-group {\n  margin-bottom: 1.5rem;\n}\n\n.new-agent-dialog .form-fields .form-group label {\n  display: block;\n  font-weight: 500;\n  margin-bottom: 0.5rem;\n  color: var(--mj-text-secondary);\n}\n\n.new-agent-dialog .form-fields .form-group label.required::after {\n  content: ' *';\n  color: var(--mj-status-error);\n}\n\n.new-agent-dialog .form-fields .form-group .full-width {\n  width: 100%;\n}\n\n.new-agent-dialog .form-fields .form-group .error-message {\n  color: var(--mj-status-error);\n  font-size: 0.875rem;\n  margin-top: 0.25rem;\n  display: flex;\n  align-items: center;\n  gap: 0.25rem;\n}\n\n.new-agent-dialog .form-fields .form-group .error-message i {\n  font-size: 0.75rem;\n}\n\n.new-agent-dialog .form-fields .form-group .field-hint {\n  font-size: 0.875rem;\n  color: var(--mj-text-muted);\n  margin-top: 0.25rem;\n  display: flex;\n  align-items: center;\n  gap: 0.25rem;\n}\n\n.new-agent-dialog .form-fields .form-group .field-hint i {\n  font-size: 0.75rem;\n}\n\n.new-agent-dialog .form-fields .model-item {\n  display: flex;\n  align-items: center;\n  gap: 0.75rem;\n  padding: 0.5rem 0;\n}\n\n.new-agent-dialog .form-fields .model-item .model-icon {\n  width: 36px;\n  height: 36px;\n  border-radius: 6px;\n  background: var(--mj-brand-primary);\n  display: flex;\n  align-items: center;\n  justify-content: center;\n  color: var(--mj-text-inverse);\n}\n\n.new-agent-dialog .form-fields .model-item .model-icon i {\n  font-size: 1rem;\n}\n\n.new-agent-dialog .form-fields .model-item .model-details {\n  display: flex;\n  flex-direction: column;\n}\n\n.new-agent-dialog .form-fields .model-item .model-details .model-name {\n  font-weight: 500;\n}\n\n.new-agent-dialog .form-fields .model-item .model-details .model-vendor {\n  font-size: 0.75rem;\n  color: var(--mj-text-muted);\n}\n\n.new-agent-dialog .form-fields .k-textbox,\n.new-agent-dialog .form-fields .k-textarea,\n.new-agent-dialog .form-fields .k-dropdown,\n.new-agent-dialog .form-fields .k-numerictextbox {\n  border-radius: 6px;\n}\n\n.new-agent-dialog .advanced-settings {\n  margin-top: 1.5rem;\n  border-radius: 8px;\n  overflow: hidden;\n}\n\n.new-agent-dialog .advanced-settings .k-expander-header {\n  background: var(--mj-bg-surface-card);\n  padding: 1rem;\n}\n\n.new-agent-dialog .advanced-settings .k-expander-header i {\n  margin-right: 0.5rem;\n  color: var(--mj-brand-primary);\n}\n\n.new-agent-dialog .advanced-settings .advanced-grid {\n  padding: 1rem;\n  display: grid;\n  gap: 1.5rem;\n}\n\n.new-agent-dialog .advanced-settings .advanced-grid .setting-group label {\n  display: block;\n  font-weight: 500;\n  margin-bottom: 0.5rem;\n  color: var(--mj-text-secondary);\n}\n\n.new-agent-dialog .advanced-settings .advanced-grid .setting-group .slider-container {\n  display: flex;\n  align-items: center;\n  gap: 1rem;\n}\n\n.new-agent-dialog .advanced-settings .advanced-grid .setting-group .slider-container .temperature-slider {\n  flex: 1;\n}\n\n.new-agent-dialog .advanced-settings .advanced-grid .setting-group .slider-container .slider-value {\n  min-width: 3rem;\n  text-align: right;\n  font-weight: 600;\n  color: var(--mj-brand-primary);\n}\n\n.new-agent-dialog .advanced-settings .advanced-grid .setting-group.checkbox-group label {\n  display: flex;\n  align-items: center;\n  gap: 0.5rem;\n  cursor: pointer;\n  font-weight: normal;\n}\n\n.new-agent-dialog .advanced-settings .advanced-grid .setting-group.checkbox-group label input[type=\"checkbox\"] {\n  cursor: pointer;\n}\n\n.new-agent-dialog .dialog-actions {\n  display: flex;\n  justify-content: flex-end;\n  gap: 0.75rem;\n  margin-top: 2rem;\n  padding-top: 1.5rem;\n  border-top: 1px solid var(--mj-border-default);\n}\n\n.new-agent-dialog .dialog-actions button {\n  min-width: 120px;\n}\n\n.new-agent-dialog .dialog-actions button i {\n  margin-right: 0.5rem;\n}\n"] }]
    }], () => [{ type: i1.FormBuilder }, { type: i2.NavigationService }], { config: [{
            type: Input
        }] }); })();
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(NewAgentDialogComponent, { className: "NewAgentDialogComponent", filePath: "src/lib/custom/AIAgents/new-agent-dialog.component.ts", lineNumber: 24 }); })();
//# sourceMappingURL=new-agent-dialog.component.js.map