import { Component, Output, EventEmitter } from '@angular/core';
import { Subject, BehaviorSubject, debounceTime, distinctUntilChanged, takeUntil } from 'rxjs';
import { FormControl } from '@angular/forms';
import { RunView } from '@memberjunction/core';
import { MJNotificationService } from '@memberjunction/ng-notifications';
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 _forTrack0 = ($index, $item) => $item.ID;
function PromptSelectorDialogComponent_Conditional_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 1)(1, "div", 8);
    i0.ɵɵelement(2, "i", 9);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(3, "p");
    i0.ɵɵtext(4, "Loading prompts...");
    i0.ɵɵelementEnd()();
} }
function PromptSelectorDialogComponent_Conditional_3_Conditional_13_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "span", 21);
    i0.ɵɵelement(1, "i", 24);
    i0.ɵɵtext(2);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate1(" ", ctx_r1.selectedPrompts.size, " selected ");
} }
function PromptSelectorDialogComponent_Conditional_3_Conditional_15_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 23);
    i0.ɵɵelement(1, "i", 25);
    i0.ɵɵelementStart(2, "h4");
    i0.ɵɵtext(3, "No prompts found");
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(4, "p");
    i0.ɵɵtext(5, "Try adjusting your search criteria or check that prompts are properly configured.");
    i0.ɵɵelementEnd()();
} }
function PromptSelectorDialogComponent_Conditional_3_Conditional_17_For_1_Conditional_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "i", 29);
} }
function PromptSelectorDialogComponent_Conditional_3_Conditional_17_For_1_Conditional_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "i", 30);
} }
function PromptSelectorDialogComponent_Conditional_3_Conditional_17_For_1_Conditional_4_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "i", 31);
} }
function PromptSelectorDialogComponent_Conditional_3_Conditional_17_For_1_Conditional_10_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "span", 36);
    i0.ɵɵelement(1, "i", 41);
    i0.ɵɵtext(2, " Linked ");
    i0.ɵɵelementEnd();
} }
function PromptSelectorDialogComponent_Conditional_3_Conditional_17_For_1_Conditional_13_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "p", 38);
    i0.ɵɵtext(1);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const prompt_r4 = i0.ɵɵnextContext().$implicit;
    i0.ɵɵadvance();
    i0.ɵɵtextInterpolate(prompt_r4.Description);
} }
function PromptSelectorDialogComponent_Conditional_3_Conditional_17_For_1_Conditional_15_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "span", 40);
    i0.ɵɵelement(1, "i", 42);
    i0.ɵɵtext(2);
    i0.ɵɵpipe(3, "date");
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const prompt_r4 = i0.ɵɵnextContext().$implicit;
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate1(" Created ", i0.ɵɵpipeBind2(3, 1, prompt_r4.__mj_CreatedAt, "short"), " ");
} }
function PromptSelectorDialogComponent_Conditional_3_Conditional_17_For_1_Template(rf, ctx) { if (rf & 1) {
    const _r3 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "div", 27);
    i0.ɵɵlistener("click", function PromptSelectorDialogComponent_Conditional_3_Conditional_17_For_1_Template_div_click_0_listener() { const prompt_r4 = i0.ɵɵrestoreView(_r3).$implicit; const ctx_r1 = i0.ɵɵnextContext(3); return i0.ɵɵresetView(ctx_r1.togglePromptSelection(prompt_r4)); });
    i0.ɵɵelementStart(1, "div", 28);
    i0.ɵɵconditionalCreate(2, PromptSelectorDialogComponent_Conditional_3_Conditional_17_For_1_Conditional_2_Template, 1, 0, "i", 29)(3, PromptSelectorDialogComponent_Conditional_3_Conditional_17_For_1_Conditional_3_Template, 1, 0, "i", 30)(4, PromptSelectorDialogComponent_Conditional_3_Conditional_17_For_1_Conditional_4_Template, 1, 0, "i", 31);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(5, "div", 32)(6, "div", 33)(7, "h4", 34);
    i0.ɵɵtext(8);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(9, "div", 35);
    i0.ɵɵconditionalCreate(10, PromptSelectorDialogComponent_Conditional_3_Conditional_17_For_1_Conditional_10_Template, 3, 0, "span", 36);
    i0.ɵɵelementStart(11, "span", 37);
    i0.ɵɵtext(12);
    i0.ɵɵelementEnd()()();
    i0.ɵɵconditionalCreate(13, PromptSelectorDialogComponent_Conditional_3_Conditional_17_For_1_Conditional_13_Template, 2, 1, "p", 38);
    i0.ɵɵelementStart(14, "div", 39);
    i0.ɵɵconditionalCreate(15, PromptSelectorDialogComponent_Conditional_3_Conditional_17_For_1_Conditional_15_Template, 4, 4, "span", 40);
    i0.ɵɵelementEnd()()();
} if (rf & 2) {
    const prompt_r4 = ctx.$implicit;
    const ctx_r1 = i0.ɵɵnextContext(3);
    i0.ɵɵclassProp("selected", ctx_r1.isPromptSelected(prompt_r4))("linked", ctx_r1.isPromptLinked(prompt_r4));
    i0.ɵɵadvance(2);
    i0.ɵɵconditional(ctx_r1.isPromptLinked(prompt_r4) ? 2 : ctx_r1.isPromptSelected(prompt_r4) ? 3 : 4);
    i0.ɵɵadvance(6);
    i0.ɵɵtextInterpolate(prompt_r4.Name);
    i0.ɵɵadvance(2);
    i0.ɵɵconditional(ctx_r1.isPromptLinked(prompt_r4) ? 10 : -1);
    i0.ɵɵadvance();
    i0.ɵɵstyleProp("background-color", ctx_r1.getPromptStatusColor(prompt_r4));
    i0.ɵɵadvance();
    i0.ɵɵtextInterpolate1(" ", ctx_r1.getPromptStatusText(prompt_r4), " ");
    i0.ɵɵadvance();
    i0.ɵɵconditional(prompt_r4.Description ? 13 : -1);
    i0.ɵɵadvance(2);
    i0.ɵɵconditional(prompt_r4.__mj_CreatedAt ? 15 : -1);
} }
function PromptSelectorDialogComponent_Conditional_3_Conditional_17_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵrepeaterCreate(0, PromptSelectorDialogComponent_Conditional_3_Conditional_17_For_1_Template, 16, 12, "div", 26, _forTrack0);
    i0.ɵɵpipe(2, "async");
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext(2);
    i0.ɵɵrepeater(i0.ɵɵpipeBind1(2, 0, ctx_r1.filteredPrompts$));
} }
function PromptSelectorDialogComponent_Conditional_3_Template(rf, ctx) { if (rf & 1) {
    const _r1 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "div", 10)(1, "div", 11)(2, "div", 12);
    i0.ɵɵelement(3, "i", 13)(4, "input", 14);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(5, "div", 15)(6, "button", 16);
    i0.ɵɵlistener("click", function PromptSelectorDialogComponent_Conditional_3_Template_button_click_6_listener() { i0.ɵɵrestoreView(_r1); const ctx_r1 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r1.toggleViewMode()); });
    i0.ɵɵelement(7, "i", 17);
    i0.ɵɵelementEnd()()()();
    i0.ɵɵelementStart(8, "div", 18)(9, "span", 19);
    i0.ɵɵelement(10, "i", 20);
    i0.ɵɵtext(11);
    i0.ɵɵpipe(12, "async");
    i0.ɵɵelementEnd();
    i0.ɵɵconditionalCreate(13, PromptSelectorDialogComponent_Conditional_3_Conditional_13_Template, 3, 1, "span", 21);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(14, "div", 22);
    i0.ɵɵconditionalCreate(15, PromptSelectorDialogComponent_Conditional_3_Conditional_15_Template, 6, 0, "div", 23);
    i0.ɵɵpipe(16, "async");
    i0.ɵɵconditionalBranchCreate(17, PromptSelectorDialogComponent_Conditional_3_Conditional_17_Template, 3, 2);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    let tmp_5_0;
    let tmp_9_0;
    const ctx_r1 = i0.ɵɵnextContext();
    i0.ɵɵadvance(4);
    i0.ɵɵproperty("formControl", ctx_r1.searchControl);
    i0.ɵɵadvance(2);
    i0.ɵɵclassProp("active", ctx_r1.viewMode === "list");
    i0.ɵɵadvance();
    i0.ɵɵclassProp("fa-list", ctx_r1.viewMode === "grid")("fa-th", ctx_r1.viewMode === "list");
    i0.ɵɵadvance(4);
    i0.ɵɵtextInterpolate1(" ", ((tmp_5_0 = i0.ɵɵpipeBind1(12, 14, ctx_r1.filteredPrompts$)) == null ? null : tmp_5_0.length) || 0, " prompt(s) ");
    i0.ɵɵadvance(2);
    i0.ɵɵconditional(ctx_r1.config.multiSelect && ctx_r1.selectedPrompts.size > 0 ? 13 : -1);
    i0.ɵɵadvance();
    i0.ɵɵclassProp("grid-view", ctx_r1.viewMode === "grid")("list-view", ctx_r1.viewMode === "list");
    i0.ɵɵadvance();
    i0.ɵɵconditional(((tmp_9_0 = i0.ɵɵpipeBind1(16, 16, ctx_r1.filteredPrompts$)) == null ? null : tmp_9_0.length) === 0 ? 15 : 17);
} }
function PromptSelectorDialogComponent_Conditional_6_Template(rf, ctx) { if (rf & 1) {
    const _r5 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "button", 6);
    i0.ɵɵlistener("click", function PromptSelectorDialogComponent_Conditional_6_Template_button_click_0_listener() { i0.ɵɵrestoreView(_r5); const ctx_r1 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r1.createNew()); });
    i0.ɵɵelement(1, "i", 43);
    i0.ɵɵtext(2, " Create New Prompt ");
    i0.ɵɵelementEnd();
} }
function PromptSelectorDialogComponent_Conditional_11_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "i", 44);
    i0.ɵɵtext(1);
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext();
    i0.ɵɵadvance();
    i0.ɵɵtextInterpolate2(" Add ", ctx_r1.selectedPrompts.size, " Prompt", ctx_r1.selectedPrompts.size === 1 ? "" : "s", " ");
} }
function PromptSelectorDialogComponent_Conditional_12_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "i", 44);
    i0.ɵɵtext(1, " Select Prompt ");
} }
/**
 * Unified prompt selector dialog that can be used for:
 * - Selecting context compression prompts (single select)
 * - Adding general prompts to agents (multi-select)
 * - Any other prompt selection scenario
 */
export class PromptSelectorDialogComponent {
    constructor(cdr) {
        this.cdr = cdr;
        // Input configuration
        this.config = { title: 'Select Prompts' };
        // State management
        this.destroy$ = new Subject();
        this.result = new Subject();
        // Data and UI state
        this.isLoading$ = new BehaviorSubject(false);
        this.prompts$ = new BehaviorSubject([]);
        this.filteredPrompts$ = new BehaviorSubject([]);
        // Search and selection
        this.searchControl = new FormControl('');
        this.selectedPrompts = new Set();
        this.linkedPrompts = new Set();
        // View mode
        this.viewMode = 'list';
        this.DialogClose = new EventEmitter();
    }
    ngOnInit() {
        this.setupSearch();
        this.loadPrompts();
        // Initialize selected prompts if provided
        if (this.config.selectedPromptIds) {
            this.selectedPrompts = new Set(this.config.selectedPromptIds);
        }
        // Initialize linked prompts if provided
        if (this.config.linkedPromptIds) {
            this.linkedPrompts = new Set(this.config.linkedPromptIds);
        }
    }
    ngOnDestroy() {
        this.destroy$.next();
        this.destroy$.complete();
    }
    setupSearch() {
        this.searchControl.valueChanges
            .pipe(debounceTime(300), distinctUntilChanged(), takeUntil(this.destroy$))
            .subscribe(searchTerm => {
            this.filterPrompts(searchTerm || '');
        });
    }
    async loadPrompts() {
        this.isLoading$.next(true);
        try {
            const rv = new RunView();
            // Build filter - default to active prompts
            let filter = "Status = 'Active'";
            if (this.config.extraFilter) {
                filter += ` AND ${this.config.extraFilter}`;
            }
            const result = await rv.RunView({
                EntityName: 'MJ: AI Prompts',
                ExtraFilter: filter,
                OrderBy: 'Name ASC',
                ResultType: 'entity_object',
                MaxRows: 1000
            });
            if (result.Success) {
                const prompts = result.Results || [];
                this.prompts$.next(prompts);
                this.filteredPrompts$.next(prompts);
            }
            else {
                throw new Error(result.ErrorMessage || 'Failed to load prompts');
            }
        }
        catch (error) {
            console.error('Error loading prompts:', error);
            MJNotificationService.Instance.CreateSimpleNotification('Error loading prompts. Please try again.', 'error', 3000);
            this.prompts$.next([]);
            this.filteredPrompts$.next([]);
        }
        finally {
            this.isLoading$.next(false);
        }
    }
    filterPrompts(searchTerm) {
        const allPrompts = this.prompts$.value;
        if (!searchTerm.trim()) {
            this.filteredPrompts$.next(allPrompts);
            return;
        }
        const filtered = allPrompts.filter(prompt => prompt.Name?.toLowerCase().includes(searchTerm.toLowerCase()) ||
            prompt.Description?.toLowerCase().includes(searchTerm.toLowerCase()));
        this.filteredPrompts$.next(filtered);
    }
    // === Selection Management ===
    togglePromptSelection(prompt) {
        // Prevent selection of already linked prompts
        if (this.isPromptLinked(prompt)) {
            MJNotificationService.Instance.CreateSimpleNotification(`"${prompt.Name}" is already linked to this agent`, 'info', 2000);
            return;
        }
        if (this.config.multiSelect) {
            if (this.selectedPrompts.has(prompt.ID)) {
                this.selectedPrompts.delete(prompt.ID);
            }
            else {
                this.selectedPrompts.add(prompt.ID);
            }
        }
        else {
            // Single select - replace current selection
            this.selectedPrompts.clear();
            this.selectedPrompts.add(prompt.ID);
        }
    }
    isPromptSelected(prompt) {
        return this.selectedPrompts.has(prompt.ID);
    }
    isPromptLinked(prompt) {
        return this.linkedPrompts.has(prompt.ID);
    }
    getSelectedPromptObjects() {
        const allPrompts = this.prompts$.value;
        return allPrompts.filter(prompt => this.selectedPrompts.has(prompt.ID));
    }
    // === UI Helpers ===
    toggleViewMode() {
        this.viewMode = this.viewMode === 'grid' ? 'list' : 'grid';
    }
    getPromptStatusColor(prompt) {
        switch (prompt.Status) {
            case 'Active': return 'var(--mj-status-success)';
            case 'Pending': return 'var(--mj-status-warning)';
            case 'Disabled': return 'var(--mj-text-muted)';
            default: return 'var(--mj-text-muted)';
        }
    }
    getPromptStatusText(prompt) {
        return prompt.Status || 'Unknown';
    }
    // === Dialog Actions ===
    selectPrompts() {
        const selectedPromptObjects = this.getSelectedPromptObjects();
        if (selectedPromptObjects.length === 0) {
            MJNotificationService.Instance.CreateSimpleNotification('Please select at least one prompt', 'warning', 2000);
            return;
        }
        const result = {
            selectedPrompts: selectedPromptObjects
        };
        this.result.next(result);
        this.DialogClose.emit();
    }
    createNew() {
        const result = {
            selectedPrompts: [],
            createNew: true
        };
        this.result.next(result);
        this.DialogClose.emit();
    }
    cancel() {
        this.result.next(null);
        this.DialogClose.emit();
    }
    static { this.ɵfac = function PromptSelectorDialogComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || PromptSelectorDialogComponent)(i0.ɵɵdirectiveInject(i0.ChangeDetectorRef)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: PromptSelectorDialogComponent, selectors: [["mj-prompt-selector-dialog"]], outputs: { DialogClose: "DialogClose" }, standalone: false, decls: 13, vars: 6, consts: [[1, "prompt-selector-dialog"], [1, "loading-state"], [1, "dialog-footer"], [1, "footer-left"], ["mjButton", "", "variant", "flat"], [1, "footer-right"], ["mjButton", "", "variant", "flat", 3, "click"], ["mjButton", "", "variant", "primary", 3, "click", "disabled"], [1, "loading-spinner"], [1, "fa-solid", "fa-spinner", "fa-spin", "fa-2x"], [1, "dialog-header"], [1, "search-section"], [1, "search-box"], [1, "fa-solid", "fa-search", "search-icon"], ["placeholder", "Search prompts by name or description...", 1, "mj-input", "search-input", 3, "formControl"], [1, "view-controls"], ["mjButton", "", "variant", "flat", "title", "Toggle between list and grid view", 3, "click"], [1, "fa-solid"], [1, "results-summary"], [1, "results-count"], [1, "fa-solid", "fa-comment-dots"], [1, "selected-count"], [1, "prompts-container"], [1, "no-results"], [1, "fa-solid", "fa-check-circle"], [1, "fa-solid", "fa-search", "fa-2x"], [1, "prompt-card", 3, "selected", "linked"], [1, "prompt-card", 3, "click"], [1, "selection-indicator"], ["title", "Already linked to this agent", 1, "fa-solid", "fa-link", "linked-icon"], [1, "fa-solid", "fa-check-circle", "selected-icon"], [1, "fa-regular", "fa-circle", "unselected-icon"], [1, "prompt-content"], [1, "prompt-header"], [1, "prompt-name"], [1, "prompt-badges"], [1, "linked-badge"], [1, "status-badge"], [1, "prompt-description"], [1, "prompt-metadata"], [1, "metadata-item"], [1, "fa-solid", "fa-link"], [1, "fa-solid", "fa-calendar"], [1, "fa-solid", "fa-plus"], [1, "fa-solid", "fa-check"]], template: function PromptSelectorDialogComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelementStart(0, "div", 0);
            i0.ɵɵconditionalCreate(1, PromptSelectorDialogComponent_Conditional_1_Template, 5, 0, "div", 1);
            i0.ɵɵpipe(2, "async");
            i0.ɵɵconditionalBranchCreate(3, PromptSelectorDialogComponent_Conditional_3_Template, 18, 18);
            i0.ɵɵelementStart(4, "div", 2)(5, "div", 3);
            i0.ɵɵconditionalCreate(6, PromptSelectorDialogComponent_Conditional_6_Template, 3, 0, "button", 4);
            i0.ɵɵelementEnd();
            i0.ɵɵelementStart(7, "div", 5)(8, "button", 6);
            i0.ɵɵlistener("click", function PromptSelectorDialogComponent_Template_button_click_8_listener() { return ctx.cancel(); });
            i0.ɵɵtext(9, " Cancel ");
            i0.ɵɵelementEnd();
            i0.ɵɵelementStart(10, "button", 7);
            i0.ɵɵlistener("click", function PromptSelectorDialogComponent_Template_button_click_10_listener() { return ctx.selectPrompts(); });
            i0.ɵɵconditionalCreate(11, PromptSelectorDialogComponent_Conditional_11_Template, 2, 2)(12, PromptSelectorDialogComponent_Conditional_12_Template, 2, 0);
            i0.ɵɵelementEnd()()()();
        } if (rf & 2) {
            i0.ɵɵadvance();
            i0.ɵɵconditional(i0.ɵɵpipeBind1(2, 4, ctx.isLoading$) ? 1 : 3);
            i0.ɵɵadvance(5);
            i0.ɵɵconditional(ctx.config.showCreateNew ? 6 : -1);
            i0.ɵɵadvance(4);
            i0.ɵɵproperty("disabled", ctx.selectedPrompts.size === 0);
            i0.ɵɵadvance();
            i0.ɵɵconditional(ctx.config.multiSelect ? 11 : 12);
        } }, dependencies: [i1.DefaultValueAccessor, i1.NgControlStatus, i1.FormControlDirective, i2.MJButtonDirective, i3.AsyncPipe, i3.DatePipe], styles: [".prompt-selector-dialog[_ngcontent-%COMP%] {\n  display: flex;\n  flex-direction: column;\n  height: 100%;\n  max-height: 70vh;\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-secondary);\n}\n\n.loading-spinner[_ngcontent-%COMP%] {\n  margin-bottom: 16px;\n}\n\n\n\n.dialog-header[_ngcontent-%COMP%] {\n  padding: 16px;\n  border-bottom: 1px solid var(--mj-border-default);\n  background: var(--mj-bg-surface-card);\n}\n\n.search-section[_ngcontent-%COMP%] {\n  display: flex;\n  align-items: center;\n  gap: 12px;\n}\n\n.search-box[_ngcontent-%COMP%] {\n  flex: 1;\n  position: relative;\n}\n\n.search-icon[_ngcontent-%COMP%] {\n  position: absolute;\n  left: 12px;\n  top: 50%;\n  transform: translateY(-50%);\n  color: var(--mj-text-secondary);\n  z-index: 2;\n}\n\n.search-input[_ngcontent-%COMP%] {\n  width: 100%;\n}\n\n.search-input[_ngcontent-%COMP%]   input[_ngcontent-%COMP%] {\n  padding-left: 36px !important;\n}\n\n.view-controls[_ngcontent-%COMP%]   button.active[_ngcontent-%COMP%] {\n  background-color: var(--mj-brand-primary);\n  color: var(--mj-text-inverse);\n}\n\n\n\n.results-summary[_ngcontent-%COMP%] {\n  padding: 12px 16px;\n  background: var(--mj-bg-surface-sunken);\n  display: flex;\n  align-items: center;\n  gap: 16px;\n  font-size: 14px;\n  color: var(--mj-text-secondary);\n  border-bottom: 1px solid var(--mj-border-default);\n}\n\n.results-count[_ngcontent-%COMP%], .selected-count[_ngcontent-%COMP%] {\n  display: flex;\n  align-items: center;\n  gap: 6px;\n}\n\n.selected-count[_ngcontent-%COMP%] {\n  color: var(--mj-brand-primary);\n  font-weight: 500;\n}\n\n\n\n.prompts-container[_ngcontent-%COMP%] {\n  flex: 1;\n  overflow-y: auto;\n  padding: 16px;\n}\n\n\n\n.prompts-container.list-view[_ngcontent-%COMP%] {\n  display: flex;\n  flex-direction: column;\n  gap: 12px;\n}\n\n\n\n.prompts-container.grid-view[_ngcontent-%COMP%] {\n  display: grid;\n  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));\n  gap: 16px;\n}\n\n\n\n.prompt-card[_ngcontent-%COMP%] {\n  border: 2px solid var(--mj-border-default);\n  border-radius: 8px;\n  padding: 16px;\n  cursor: pointer;\n  transition: all 0.2s ease;\n  background: var(--mj-bg-surface);\n  display: flex;\n  gap: 12px;\n  position: relative;\n}\n\n.prompt-card[_ngcontent-%COMP%]:hover {\n  border-color: var(--mj-brand-primary);\n  box-shadow: 0 2px 8px color-mix(in srgb, var(--mj-brand-primary) 15%, transparent);\n}\n\n.prompt-card.selected[_ngcontent-%COMP%] {\n  border-color: var(--mj-brand-primary);\n  background: color-mix(in srgb, var(--mj-brand-primary) 4%, var(--mj-bg-surface));\n  box-shadow: 0 2px 8px color-mix(in srgb, var(--mj-brand-primary) 25%, transparent);\n}\n\n.prompt-card.linked[_ngcontent-%COMP%] {\n  border-color: var(--mj-text-muted);\n  background: var(--mj-bg-surface-card);\n  opacity: 0.7;\n  cursor: not-allowed;\n}\n\n.prompt-card.linked[_ngcontent-%COMP%]:hover {\n  border-color: var(--mj-text-muted);\n  box-shadow: none;\n}\n\n\n\n.selection-indicator[_ngcontent-%COMP%] {\n  display: flex;\n  align-items: flex-start;\n  margin-top: 2px;\n}\n\n.selected-icon[_ngcontent-%COMP%] {\n  color: var(--mj-brand-primary);\n  font-size: 18px;\n}\n\n.unselected-icon[_ngcontent-%COMP%] {\n  color: var(--mj-border-strong);\n  font-size: 18px;\n}\n\n.linked-icon[_ngcontent-%COMP%] {\n  color: var(--mj-text-muted);\n  font-size: 18px;\n}\n\n\n\n.prompt-content[_ngcontent-%COMP%] {\n  flex: 1;\n  min-width: 0;\n}\n\n.prompt-header[_ngcontent-%COMP%] {\n  display: flex;\n  align-items: flex-start;\n  justify-content: space-between;\n  gap: 12px;\n  margin-bottom: 8px;\n}\n\n.prompt-name[_ngcontent-%COMP%] {\n  margin: 0;\n  font-size: 16px;\n  font-weight: 600;\n  color: var(--mj-text-primary);\n  line-height: 1.4;\n  flex: 1;\n}\n\n.prompt-badges[_ngcontent-%COMP%] {\n  display: flex;\n  gap: 6px;\n  align-items: center;\n}\n\n.status-badge[_ngcontent-%COMP%] {\n  padding: 4px 8px;\n  border-radius: 12px;\n  font-size: 12px;\n  font-weight: 500;\n  color: var(--mj-text-inverse);\n  white-space: nowrap;\n}\n\n.linked-badge[_ngcontent-%COMP%] {\n  padding: 4px 8px;\n  border-radius: 12px;\n  font-size: 12px;\n  font-weight: 500;\n  background: var(--mj-text-muted);\n  color: var(--mj-text-inverse);\n  white-space: nowrap;\n  display: flex;\n  align-items: center;\n  gap: 4px;\n}\n\n.prompt-description[_ngcontent-%COMP%] {\n  margin: 0 0 12px 0;\n  color: var(--mj-text-secondary);\n  font-size: 14px;\n  line-height: 1.4;\n  display: -webkit-box;\n  -webkit-line-clamp: 2;\n  -webkit-box-orient: vertical;\n  overflow: hidden;\n}\n\n\n\n.prompt-metadata[_ngcontent-%COMP%] {\n  display: flex;\n  gap: 16px;\n  font-size: 12px;\n  color: var(--mj-text-disabled);\n  flex-wrap: wrap;\n}\n\n.metadata-item[_ngcontent-%COMP%] {\n  display: flex;\n  align-items: center;\n  gap: 4px;\n}\n\n.metadata-item[_ngcontent-%COMP%]   i[_ngcontent-%COMP%] {\n  width: 12px;\n  font-size: 10px;\n}\n\n\n\n.no-results[_ngcontent-%COMP%] {\n  display: flex;\n  flex-direction: column;\n  align-items: center;\n  justify-content: center;\n  height: 200px;\n  color: var(--mj-text-secondary);\n  text-align: center;\n}\n\n.no-results[_ngcontent-%COMP%]   i[_ngcontent-%COMP%] {\n  margin-bottom: 16px;\n  color: var(--mj-border-strong);\n}\n\n.no-results[_ngcontent-%COMP%]   h4[_ngcontent-%COMP%] {\n  margin: 0 0 8px 0;\n  color: var(--mj-text-primary);\n}\n\n.no-results[_ngcontent-%COMP%]   p[_ngcontent-%COMP%] {\n  margin: 0;\n  color: var(--mj-text-disabled);\n  max-width: 300px;\n}\n\n\n\n.dialog-footer[_ngcontent-%COMP%] {\n  display: flex;\n  justify-content: space-between;\n  align-items: center;\n  padding: 16px;\n  border-top: 1px solid var(--mj-border-default);\n  background: var(--mj-bg-surface-card);\n}\n\n.footer-left[_ngcontent-%COMP%] {\n  display: flex;\n}\n\n.footer-right[_ngcontent-%COMP%] {\n  display: flex;\n  gap: 8px;\n}\n\n\n\n@media (max-width: 768px) {\n  .prompts-container.grid-view[_ngcontent-%COMP%] {\n    grid-template-columns: 1fr;\n  }\n\n  .prompt-header[_ngcontent-%COMP%] {\n    flex-direction: column;\n    align-items: flex-start;\n    gap: 8px;\n  }\n\n  .search-section[_ngcontent-%COMP%] {\n    flex-direction: column;\n    gap: 8px;\n  }\n\n  .view-controls[_ngcontent-%COMP%] {\n    align-self: flex-end;\n  }\n}"] }); }
}
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(PromptSelectorDialogComponent, [{
        type: Component,
        args: [{ standalone: false, selector: 'mj-prompt-selector-dialog', template: "<!-- Prompt Selector Dialog -->\n<div class=\"prompt-selector-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 prompts...</p>\n    </div>\n  } @else {\n    \n    <!-- Search and Controls Header -->\n    <div class=\"dialog-header\">\n      <div class=\"search-section\">\n        <div class=\"search-box\">\n          <i class=\"fa-solid fa-search search-icon\"></i>\n          <input\n            class=\"mj-input search-input\"\n            [formControl]=\"searchControl\"\n            placeholder=\"Search prompts by name or description...\">\n        </div>\n        \n        <div class=\"view-controls\">\n          <button mjButton\n                  variant=\"flat\"\n                  [class.active]=\"viewMode === 'list'\"\n                  (click)=\"toggleViewMode()\"\n                  title=\"Toggle between list and grid view\">\n            <i class=\"fa-solid\" [class.fa-list]=\"viewMode === 'grid'\" [class.fa-th]=\"viewMode === 'list'\"></i>\n          </button>\n        </div>\n      </div>\n    </div>\n\n    <!-- Results Summary -->\n    <div class=\"results-summary\">\n      <span class=\"results-count\">\n        <i class=\"fa-solid fa-comment-dots\"></i>\n        {{ (filteredPrompts$ | async)?.length || 0 }} prompt(s)\n      </span>\n      @if (config.multiSelect && selectedPrompts.size > 0) {\n        <span class=\"selected-count\">\n          <i class=\"fa-solid fa-check-circle\"></i>\n          {{ selectedPrompts.size }} selected\n        </span>\n      }\n    </div>\n\n    <!-- Prompts List/Grid -->\n    <div class=\"prompts-container\" [class.grid-view]=\"viewMode === 'grid'\" [class.list-view]=\"viewMode === 'list'\">\n      @if ((filteredPrompts$ | async)?.length === 0) {\n        <div class=\"no-results\">\n          <i class=\"fa-solid fa-search fa-2x\"></i>\n          <h4>No prompts found</h4>\n          <p>Try adjusting your search criteria or check that prompts are properly configured.</p>\n        </div>\n      } @else {\n        @for (prompt of filteredPrompts$ | async; track prompt.ID) {\n          <div class=\"prompt-card\" \n               [class.selected]=\"isPromptSelected(prompt)\"\n               [class.linked]=\"isPromptLinked(prompt)\"\n               (click)=\"togglePromptSelection(prompt)\">\n            \n            <!-- Selection indicator -->\n            <div class=\"selection-indicator\">\n              @if (isPromptLinked(prompt)) {\n                <i class=\"fa-solid fa-link linked-icon\" title=\"Already linked to this agent\"></i>\n              } @else if (isPromptSelected(prompt)) {\n                <i class=\"fa-solid fa-check-circle selected-icon\"></i>\n              } @else {\n                <i class=\"fa-regular fa-circle unselected-icon\"></i>\n              }\n            </div>\n\n            <!-- Prompt Content -->\n            <div class=\"prompt-content\">\n              <div class=\"prompt-header\">\n                <h4 class=\"prompt-name\">{{ prompt.Name }}</h4>\n                <div class=\"prompt-badges\">\n                  @if (isPromptLinked(prompt)) {\n                    <span class=\"linked-badge\">\n                      <i class=\"fa-solid fa-link\"></i>\n                      Linked\n                    </span>\n                  }\n                  <span class=\"status-badge\" \n                        [style.background-color]=\"getPromptStatusColor(prompt)\">\n                    {{ getPromptStatusText(prompt) }}\n                  </span>\n                </div>\n              </div>\n\n              @if (prompt.Description) {\n                <p class=\"prompt-description\">{{ prompt.Description }}</p>\n              }\n\n              <!-- Prompt Metadata -->\n              <div class=\"prompt-metadata\">\n                @if (prompt.__mj_CreatedAt) {\n                  <span class=\"metadata-item\">\n                    <i class=\"fa-solid fa-calendar\"></i>\n                    Created {{ prompt.__mj_CreatedAt | date:'short' }}\n                  </span>\n                }\n              </div>\n            </div>\n          </div>\n        }\n      }\n    </div>\n  }\n\n  <!-- Dialog Footer -->\n  <div class=\"dialog-footer\">\n    <div class=\"footer-left\">\n      @if (config.showCreateNew) {\n        <button mjButton\n                variant=\"flat\"\n                (click)=\"createNew()\">\n          <i class=\"fa-solid fa-plus\"></i>\n          Create New Prompt\n        </button>\n      }\n    </div>\n    \n    <div class=\"footer-right\">\n      <button mjButton\n              variant=\"flat\"\n              (click)=\"cancel()\">\n        Cancel\n      </button>\n\n      <button mjButton\n              variant=\"primary\"\n              (click)=\"selectPrompts()\"\n              [disabled]=\"selectedPrompts.size === 0\">\n        @if (config.multiSelect) {\n          <i class=\"fa-solid fa-check\"></i>\n          Add {{ selectedPrompts.size }} Prompt{{ selectedPrompts.size === 1 ? '' : 's' }}\n        } @else {\n          <i class=\"fa-solid fa-check\"></i>\n          Select Prompt\n        }\n      </button>\n    </div>\n  </div>\n</div>", styles: [".prompt-selector-dialog {\n  display: flex;\n  flex-direction: column;\n  height: 100%;\n  max-height: 70vh;\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-secondary);\n}\n\n.loading-spinner {\n  margin-bottom: 16px;\n}\n\n/* === Header Section === */\n.dialog-header {\n  padding: 16px;\n  border-bottom: 1px solid var(--mj-border-default);\n  background: var(--mj-bg-surface-card);\n}\n\n.search-section {\n  display: flex;\n  align-items: center;\n  gap: 12px;\n}\n\n.search-box {\n  flex: 1;\n  position: relative;\n}\n\n.search-icon {\n  position: absolute;\n  left: 12px;\n  top: 50%;\n  transform: translateY(-50%);\n  color: var(--mj-text-secondary);\n  z-index: 2;\n}\n\n.search-input {\n  width: 100%;\n}\n\n.search-input input {\n  padding-left: 36px !important;\n}\n\n.view-controls button.active {\n  background-color: var(--mj-brand-primary);\n  color: var(--mj-text-inverse);\n}\n\n/* === Results Summary === */\n.results-summary {\n  padding: 12px 16px;\n  background: var(--mj-bg-surface-sunken);\n  display: flex;\n  align-items: center;\n  gap: 16px;\n  font-size: 14px;\n  color: var(--mj-text-secondary);\n  border-bottom: 1px solid var(--mj-border-default);\n}\n\n.results-count, .selected-count {\n  display: flex;\n  align-items: center;\n  gap: 6px;\n}\n\n.selected-count {\n  color: var(--mj-brand-primary);\n  font-weight: 500;\n}\n\n/* === Prompts Container === */\n.prompts-container {\n  flex: 1;\n  overflow-y: auto;\n  padding: 16px;\n}\n\n/* List View */\n.prompts-container.list-view {\n  display: flex;\n  flex-direction: column;\n  gap: 12px;\n}\n\n/* Grid View */\n.prompts-container.grid-view {\n  display: grid;\n  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));\n  gap: 16px;\n}\n\n/* === Prompt Cards === */\n.prompt-card {\n  border: 2px solid var(--mj-border-default);\n  border-radius: 8px;\n  padding: 16px;\n  cursor: pointer;\n  transition: all 0.2s ease;\n  background: var(--mj-bg-surface);\n  display: flex;\n  gap: 12px;\n  position: relative;\n}\n\n.prompt-card:hover {\n  border-color: var(--mj-brand-primary);\n  box-shadow: 0 2px 8px color-mix(in srgb, var(--mj-brand-primary) 15%, transparent);\n}\n\n.prompt-card.selected {\n  border-color: var(--mj-brand-primary);\n  background: color-mix(in srgb, var(--mj-brand-primary) 4%, var(--mj-bg-surface));\n  box-shadow: 0 2px 8px color-mix(in srgb, var(--mj-brand-primary) 25%, transparent);\n}\n\n.prompt-card.linked {\n  border-color: var(--mj-text-muted);\n  background: var(--mj-bg-surface-card);\n  opacity: 0.7;\n  cursor: not-allowed;\n}\n\n.prompt-card.linked:hover {\n  border-color: var(--mj-text-muted);\n  box-shadow: none;\n}\n\n/* === Selection Indicator === */\n.selection-indicator {\n  display: flex;\n  align-items: flex-start;\n  margin-top: 2px;\n}\n\n.selected-icon {\n  color: var(--mj-brand-primary);\n  font-size: 18px;\n}\n\n.unselected-icon {\n  color: var(--mj-border-strong);\n  font-size: 18px;\n}\n\n.linked-icon {\n  color: var(--mj-text-muted);\n  font-size: 18px;\n}\n\n/* === Prompt Content === */\n.prompt-content {\n  flex: 1;\n  min-width: 0;\n}\n\n.prompt-header {\n  display: flex;\n  align-items: flex-start;\n  justify-content: space-between;\n  gap: 12px;\n  margin-bottom: 8px;\n}\n\n.prompt-name {\n  margin: 0;\n  font-size: 16px;\n  font-weight: 600;\n  color: var(--mj-text-primary);\n  line-height: 1.4;\n  flex: 1;\n}\n\n.prompt-badges {\n  display: flex;\n  gap: 6px;\n  align-items: center;\n}\n\n.status-badge {\n  padding: 4px 8px;\n  border-radius: 12px;\n  font-size: 12px;\n  font-weight: 500;\n  color: var(--mj-text-inverse);\n  white-space: nowrap;\n}\n\n.linked-badge {\n  padding: 4px 8px;\n  border-radius: 12px;\n  font-size: 12px;\n  font-weight: 500;\n  background: var(--mj-text-muted);\n  color: var(--mj-text-inverse);\n  white-space: nowrap;\n  display: flex;\n  align-items: center;\n  gap: 4px;\n}\n\n.prompt-description {\n  margin: 0 0 12px 0;\n  color: var(--mj-text-secondary);\n  font-size: 14px;\n  line-height: 1.4;\n  display: -webkit-box;\n  -webkit-line-clamp: 2;\n  -webkit-box-orient: vertical;\n  overflow: hidden;\n}\n\n/* === Prompt Metadata === */\n.prompt-metadata {\n  display: flex;\n  gap: 16px;\n  font-size: 12px;\n  color: var(--mj-text-disabled);\n  flex-wrap: wrap;\n}\n\n.metadata-item {\n  display: flex;\n  align-items: center;\n  gap: 4px;\n}\n\n.metadata-item i {\n  width: 12px;\n  font-size: 10px;\n}\n\n/* === No Results === */\n.no-results {\n  display: flex;\n  flex-direction: column;\n  align-items: center;\n  justify-content: center;\n  height: 200px;\n  color: var(--mj-text-secondary);\n  text-align: center;\n}\n\n.no-results i {\n  margin-bottom: 16px;\n  color: var(--mj-border-strong);\n}\n\n.no-results h4 {\n  margin: 0 0 8px 0;\n  color: var(--mj-text-primary);\n}\n\n.no-results p {\n  margin: 0;\n  color: var(--mj-text-disabled);\n  max-width: 300px;\n}\n\n/* === Dialog Footer === */\n.dialog-footer {\n  display: flex;\n  justify-content: space-between;\n  align-items: center;\n  padding: 16px;\n  border-top: 1px solid var(--mj-border-default);\n  background: var(--mj-bg-surface-card);\n}\n\n.footer-left {\n  display: flex;\n}\n\n.footer-right {\n  display: flex;\n  gap: 8px;\n}\n\n/* === Responsive Design === */\n@media (max-width: 768px) {\n  .prompts-container.grid-view {\n    grid-template-columns: 1fr;\n  }\n\n  .prompt-header {\n    flex-direction: column;\n    align-items: flex-start;\n    gap: 8px;\n  }\n\n  .search-section {\n    flex-direction: column;\n    gap: 8px;\n  }\n\n  .view-controls {\n    align-self: flex-end;\n  }\n}\n"] }]
    }], () => [{ type: i0.ChangeDetectorRef }], { DialogClose: [{
            type: Output
        }] }); })();
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(PromptSelectorDialogComponent, { className: "PromptSelectorDialogComponent", filePath: "src/lib/custom/AIAgents/prompt-selector-dialog.component.ts", lineNumber: 42 }); })();
//# sourceMappingURL=prompt-selector-dialog.component.js.map