import { Component, Input, Output, EventEmitter, ViewEncapsulation } from '@angular/core';
import { Metadata, RunView } from '@memberjunction/core';
import { DashboardEngine } from '@memberjunction/core-entities';
import { UUIDsEqual } from '@memberjunction/global';
import * as i0 from "@angular/core";
import * as i1 from "@angular/forms";
import * as i2 from "@memberjunction/ng-ui-components";
const _forTrack0 = ($index, $item) => $item.User.ID;
const _forTrack1 = ($index, $item) => $item.ID;
function DashboardShareDialogComponent_Conditional_0_Conditional_7_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 5);
    i0.ɵɵelement(1, "i", 27);
    i0.ɵɵelementStart(2, "span");
    i0.ɵɵtext(3);
    i0.ɵɵelementEnd()();
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(3);
    i0.ɵɵtextInterpolate(ctx_r1.Error);
} }
function DashboardShareDialogComponent_Conditional_0_Conditional_12_For_2_Conditional_5_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "span", 32);
    i0.ɵɵtext(1);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const user_r4 = i0.ɵɵnextContext().$implicit;
    i0.ɵɵadvance();
    i0.ɵɵtextInterpolate(user_r4.Email);
} }
function DashboardShareDialogComponent_Conditional_0_Conditional_12_For_2_Template(rf, ctx) { if (rf & 1) {
    const _r3 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "button", 29);
    i0.ɵɵlistener("click", function DashboardShareDialogComponent_Conditional_0_Conditional_12_For_2_Template_button_click_0_listener() { const user_r4 = i0.ɵɵrestoreView(_r3).$implicit; const ctx_r1 = i0.ɵɵnextContext(3); return i0.ɵɵresetView(ctx_r1.addUserShare(user_r4)); });
    i0.ɵɵelementStart(1, "span", 30);
    i0.ɵɵtext(2);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(3, "span", 31);
    i0.ɵɵtext(4);
    i0.ɵɵelementEnd();
    i0.ɵɵconditionalCreate(5, DashboardShareDialogComponent_Conditional_0_Conditional_12_For_2_Conditional_5_Template, 2, 1, "span", 32);
    i0.ɵɵelement(6, "i", 33);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const user_r4 = ctx.$implicit;
    const ctx_r1 = i0.ɵɵnextContext(3);
    i0.ɵɵproperty("disabled", ctx_r1.IsLoading);
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate(ctx_r1.getUserInitials(user_r4));
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate(user_r4.Name);
    i0.ɵɵadvance();
    i0.ɵɵconditional(user_r4.Email ? 5 : -1);
} }
function DashboardShareDialogComponent_Conditional_0_Conditional_12_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 10);
    i0.ɵɵrepeaterCreate(1, DashboardShareDialogComponent_Conditional_0_Conditional_12_For_2_Template, 7, 4, "button", 28, _forTrack1);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance();
    i0.ɵɵrepeater(ctx_r1.FilteredAvailableUsers);
} }
function DashboardShareDialogComponent_Conditional_0_Conditional_13_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 11);
    i0.ɵɵtext(1);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance();
    i0.ɵɵtextInterpolate1(" No users found matching \"", ctx_r1.UserSearchFilter, "\" ");
} }
function DashboardShareDialogComponent_Conditional_0_For_26_Conditional_6_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "span", 35);
    i0.ɵɵtext(1, "New");
    i0.ɵɵelementEnd();
} }
function DashboardShareDialogComponent_Conditional_0_For_26_Conditional_7_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "span", 36);
    i0.ɵɵtext(1);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const share_r6 = i0.ɵɵnextContext().$implicit;
    i0.ɵɵadvance();
    i0.ɵɵtextInterpolate(share_r6.User.Email);
} }
function DashboardShareDialogComponent_Conditional_0_For_26_Template(rf, ctx) { if (rf & 1) {
    const _r5 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "div", 34)(1, "span", 30);
    i0.ɵɵtext(2);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(3, "div", 16)(4, "span", 17);
    i0.ɵɵtext(5);
    i0.ɵɵconditionalCreate(6, DashboardShareDialogComponent_Conditional_0_For_26_Conditional_6_Template, 2, 0, "span", 35);
    i0.ɵɵelementEnd();
    i0.ɵɵconditionalCreate(7, DashboardShareDialogComponent_Conditional_0_For_26_Conditional_7_Template, 2, 1, "span", 36);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(8, "div", 37)(9, "label", 38);
    i0.ɵɵelement(10, "input", 39)(11, "i", 40);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(12, "label", 41)(13, "input", 42);
    i0.ɵɵlistener("change", function DashboardShareDialogComponent_Conditional_0_For_26_Template_input_change_13_listener() { const share_r6 = i0.ɵɵrestoreView(_r5).$implicit; const ctx_r1 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r1.toggleCanEdit(share_r6)); });
    i0.ɵɵelementEnd();
    i0.ɵɵelement(14, "i", 43);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(15, "label", 44)(16, "input", 42);
    i0.ɵɵlistener("change", function DashboardShareDialogComponent_Conditional_0_For_26_Template_input_change_16_listener() { const share_r6 = i0.ɵɵrestoreView(_r5).$implicit; const ctx_r1 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r1.toggleCanDelete(share_r6)); });
    i0.ɵɵelementEnd();
    i0.ɵɵelement(17, "i", 45);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(18, "label", 46)(19, "input", 42);
    i0.ɵɵlistener("change", function DashboardShareDialogComponent_Conditional_0_For_26_Template_input_change_19_listener() { const share_r6 = i0.ɵɵrestoreView(_r5).$implicit; const ctx_r1 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r1.toggleCanShare(share_r6)); });
    i0.ɵɵelementEnd();
    i0.ɵɵelement(20, "i", 47);
    i0.ɵɵelementEnd()();
    i0.ɵɵelementStart(21, "button", 48);
    i0.ɵɵlistener("click", function DashboardShareDialogComponent_Conditional_0_For_26_Template_button_click_21_listener() { const share_r6 = i0.ɵɵrestoreView(_r5).$implicit; const ctx_r1 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r1.removeUserShare(share_r6)); });
    i0.ɵɵelement(22, "i", 49);
    i0.ɵɵelementEnd()();
} if (rf & 2) {
    const share_r6 = ctx.$implicit;
    const ctx_r1 = i0.ɵɵnextContext(2);
    i0.ɵɵclassProp("share-person-new", share_r6.IsNew)("share-person-modified", share_r6.Permission.Dirty);
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate(ctx_r1.getUserInitials(share_r6.User));
    i0.ɵɵadvance(3);
    i0.ɵɵtextInterpolate1(" ", share_r6.User.Name, " ");
    i0.ɵɵadvance();
    i0.ɵɵconditional(share_r6.IsNew ? 6 : -1);
    i0.ɵɵadvance();
    i0.ɵɵconditional(share_r6.User.Email ? 7 : -1);
    i0.ɵɵadvance(3);
    i0.ɵɵproperty("checked", share_r6.Permission.CanRead);
    i0.ɵɵadvance(3);
    i0.ɵɵproperty("checked", share_r6.Permission.CanEdit);
    i0.ɵɵadvance(3);
    i0.ɵɵproperty("checked", share_r6.Permission.CanDelete);
    i0.ɵɵadvance(3);
    i0.ɵɵproperty("checked", share_r6.Permission.CanShare);
} }
function DashboardShareDialogComponent_Conditional_0_Conditional_27_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 20);
    i0.ɵɵelement(1, "i", 50);
    i0.ɵɵelementStart(2, "span");
    i0.ɵɵtext(3, "Not shared with anyone yet");
    i0.ɵɵelementEnd()();
} }
function DashboardShareDialogComponent_Conditional_0_Conditional_28_For_2_Template(rf, ctx) { if (rf & 1) {
    const _r7 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "div", 51)(1, "span", 52);
    i0.ɵɵtext(2);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(3, "span", 53);
    i0.ɵɵtext(4);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(5, "button", 54);
    i0.ɵɵlistener("click", function DashboardShareDialogComponent_Conditional_0_Conditional_28_For_2_Template_button_click_5_listener() { const share_r8 = i0.ɵɵrestoreView(_r7).$implicit; const ctx_r1 = i0.ɵɵnextContext(3); return i0.ɵɵresetView(ctx_r1.undoRemove(share_r8)); });
    i0.ɵɵelement(6, "i", 55);
    i0.ɵɵtext(7, " Undo ");
    i0.ɵɵelementEnd()();
} if (rf & 2) {
    const share_r8 = ctx.$implicit;
    const ctx_r1 = i0.ɵɵnextContext(3);
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate(ctx_r1.getUserInitials(share_r8.User));
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate(share_r8.User.Name);
} }
function DashboardShareDialogComponent_Conditional_0_Conditional_28_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 21);
    i0.ɵɵrepeaterCreate(1, DashboardShareDialogComponent_Conditional_0_Conditional_28_For_2_Template, 8, 2, "div", 51, _forTrack0);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance();
    i0.ɵɵrepeater(ctx_r1.RemovedShares);
} }
function DashboardShareDialogComponent_Conditional_0_Conditional_30_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "span", 23);
    i0.ɵɵelement(1, "i", 56);
    i0.ɵɵtext(2, " Unsaved changes ");
    i0.ɵɵelementEnd();
} }
function DashboardShareDialogComponent_Conditional_0_Conditional_35_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "i", 57);
    i0.ɵɵtext(1, " Saving... ");
} }
function DashboardShareDialogComponent_Conditional_0_Conditional_36_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵtext(0, " Save ");
} }
function DashboardShareDialogComponent_Conditional_0_Template(rf, ctx) { if (rf & 1) {
    const _r1 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "mj-window", 1);
    i0.ɵɵlistener("Close", function DashboardShareDialogComponent_Conditional_0_Template_mj_window_Close_0_listener() { i0.ɵɵrestoreView(_r1); const ctx_r1 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r1.onCancel()); });
    i0.ɵɵelementStart(1, "mj-window-titlebar")(2, "div", 2);
    i0.ɵɵelement(3, "i", 3);
    i0.ɵɵelementStart(4, "span");
    i0.ɵɵtext(5);
    i0.ɵɵelementEnd()()();
    i0.ɵɵelementStart(6, "div", 4);
    i0.ɵɵconditionalCreate(7, DashboardShareDialogComponent_Conditional_0_Conditional_7_Template, 4, 1, "div", 5);
    i0.ɵɵelementStart(8, "div", 6)(9, "div", 7);
    i0.ɵɵelement(10, "i", 8);
    i0.ɵɵelementStart(11, "input", 9);
    i0.ɵɵtwoWayListener("ngModelChange", function DashboardShareDialogComponent_Conditional_0_Template_input_ngModelChange_11_listener($event) { i0.ɵɵrestoreView(_r1); const ctx_r1 = i0.ɵɵnextContext(); i0.ɵɵtwoWayBindingSet(ctx_r1.UserSearchFilter, $event) || (ctx_r1.UserSearchFilter = $event); return i0.ɵɵresetView($event); });
    i0.ɵɵelementEnd()();
    i0.ɵɵconditionalCreate(12, DashboardShareDialogComponent_Conditional_0_Conditional_12_Template, 3, 0, "div", 10);
    i0.ɵɵconditionalCreate(13, DashboardShareDialogComponent_Conditional_0_Conditional_13_Template, 2, 1, "div", 11);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(14, "div", 6)(15, "div", 12);
    i0.ɵɵtext(16, "People with access");
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(17, "div", 13)(18, "span", 14);
    i0.ɵɵelement(19, "i", 15);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(20, "div", 16)(21, "span", 17);
    i0.ɵɵtext(22);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(23, "span", 18);
    i0.ɵɵtext(24, "Owner");
    i0.ɵɵelementEnd()()();
    i0.ɵɵrepeaterCreate(25, DashboardShareDialogComponent_Conditional_0_For_26_Template, 23, 12, "div", 19, _forTrack0);
    i0.ɵɵconditionalCreate(27, DashboardShareDialogComponent_Conditional_0_Conditional_27_Template, 4, 0, "div", 20);
    i0.ɵɵconditionalCreate(28, DashboardShareDialogComponent_Conditional_0_Conditional_28_Template, 3, 0, "div", 21);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(29, "div", 22);
    i0.ɵɵconditionalCreate(30, DashboardShareDialogComponent_Conditional_0_Conditional_30_Template, 3, 0, "span", 23);
    i0.ɵɵelementStart(31, "div", 24)(32, "button", 25);
    i0.ɵɵlistener("click", function DashboardShareDialogComponent_Conditional_0_Template_button_click_32_listener() { i0.ɵɵrestoreView(_r1); const ctx_r1 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r1.onCancel()); });
    i0.ɵɵtext(33, " Cancel ");
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(34, "button", 26);
    i0.ɵɵlistener("click", function DashboardShareDialogComponent_Conditional_0_Template_button_click_34_listener() { i0.ɵɵrestoreView(_r1); const ctx_r1 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r1.onSave()); });
    i0.ɵɵconditionalCreate(35, DashboardShareDialogComponent_Conditional_0_Conditional_35_Template, 2, 0)(36, DashboardShareDialogComponent_Conditional_0_Conditional_36_Template, 1, 0);
    i0.ɵɵelementEnd()()()()();
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext();
    i0.ɵɵproperty("Visible", true)("Width", 560)("MinHeight", 200)("Resizable", false)("Draggable", true);
    i0.ɵɵadvance(5);
    i0.ɵɵtextInterpolate1("Share \"", ctx_r1.Dashboard == null ? null : ctx_r1.Dashboard.Name, "\"");
    i0.ɵɵadvance(2);
    i0.ɵɵconditional(ctx_r1.Error ? 7 : -1);
    i0.ɵɵadvance(4);
    i0.ɵɵtwoWayProperty("ngModel", ctx_r1.UserSearchFilter);
    i0.ɵɵproperty("disabled", ctx_r1.IsLoading);
    i0.ɵɵadvance();
    i0.ɵɵconditional(ctx_r1.FilteredAvailableUsers.length > 0 ? 12 : -1);
    i0.ɵɵadvance();
    i0.ɵɵconditional(ctx_r1.UserSearchFilter && ctx_r1.FilteredAvailableUsers.length === 0 ? 13 : -1);
    i0.ɵɵadvance(9);
    i0.ɵɵtextInterpolate((ctx_r1.Dashboard == null ? null : ctx_r1.Dashboard.User) || "You");
    i0.ɵɵadvance(3);
    i0.ɵɵrepeater(ctx_r1.ActiveShares);
    i0.ɵɵadvance(2);
    i0.ɵɵconditional(ctx_r1.ActiveShares.length === 0 ? 27 : -1);
    i0.ɵɵadvance();
    i0.ɵɵconditional(ctx_r1.RemovedShares.length > 0 ? 28 : -1);
    i0.ɵɵadvance(2);
    i0.ɵɵconditional(ctx_r1.HasChanges ? 30 : -1);
    i0.ɵɵadvance(4);
    i0.ɵɵproperty("disabled", !ctx_r1.HasChanges || ctx_r1.IsLoading);
    i0.ɵɵadvance();
    i0.ɵɵconditional(ctx_r1.IsLoading ? 35 : 36);
} }
/**
 * Dialog component for sharing dashboards with other users.
 * Allows setting granular permissions (CanRead, CanEdit, CanDelete, CanShare).
 */
export class DashboardShareDialogComponent {
    cdr;
    Visible = false;
    Dashboard = null;
    Result = new EventEmitter();
    /** Current shares for this dashboard */
    UserShares = [];
    /** All available users for sharing (excludes owner and already shared) */
    AvailableUsers = [];
    /** All users in the system */
    allUsers = [];
    /** Loading state */
    IsLoading = false;
    /** Error message to display */
    Error = null;
    /** Search filter for available users */
    UserSearchFilter = '';
    constructor(cdr) {
        this.cdr = cdr;
    }
    ngOnChanges(changes) {
        if (changes['Visible'] && this.Visible && this.Dashboard) {
            this.resetDialog();
            this.loadData();
        }
    }
    /**
     * Reset dialog state
     */
    resetDialog() {
        this.Error = null;
        this.IsLoading = false;
        this.UserShares = [];
        this.AvailableUsers = [];
        this.UserSearchFilter = '';
    }
    /**
     * Load existing shares and available users
     */
    async loadData() {
        if (!this.Dashboard)
            return;
        this.IsLoading = true;
        this.cdr.detectChanges();
        try {
            const md = new Metadata();
            const rv = new RunView();
            // Load all users
            const usersResult = await rv.RunView({
                EntityName: 'MJ: Users',
                ExtraFilter: "IsActive = 1",
                OrderBy: 'Name',
                ResultType: 'entity_object'
            });
            if (usersResult.Success) {
                this.allUsers = usersResult.Results;
            }
            // Get existing shares from DashboardEngine
            const existingShares = DashboardEngine.Instance.GetDashboardShares(this.Dashboard.ID);
            // Build user shares list
            this.UserShares = [];
            for (const permission of existingShares) {
                const user = this.allUsers.find(u => UUIDsEqual(u.ID, permission.UserID));
                if (user) {
                    this.UserShares.push({
                        Permission: permission,
                        User: user,
                        IsNew: false,
                        MarkedForRemoval: false
                    });
                }
            }
            // Update available users
            this.updateAvailableUsers();
        }
        catch (error) {
            console.error('Error loading share data:', error);
            this.Error = 'Failed to load sharing data. Please try again.';
        }
        finally {
            this.IsLoading = false;
            this.cdr.detectChanges();
        }
    }
    /**
     * Update the list of available users (excludes owner and already shared)
     */
    updateAvailableUsers() {
        if (!this.Dashboard)
            return;
        const sharedUserIds = new Set(this.UserShares
            .filter(s => !s.MarkedForRemoval)
            .map(s => s.User.ID));
        // Exclude dashboard owner and already shared users
        this.AvailableUsers = this.allUsers.filter(user => !UUIDsEqual(user.ID, this.Dashboard.UserID) && !sharedUserIds.has(user.ID));
    }
    /**
     * Get filtered available users based on search
     */
    get FilteredAvailableUsers() {
        if (!this.UserSearchFilter.trim()) {
            return this.AvailableUsers.slice(0, 10); // Show first 10 by default
        }
        const filter = this.UserSearchFilter.toLowerCase();
        return this.AvailableUsers
            .filter(user => user.Name.toLowerCase().includes(filter) ||
            (user.Email && user.Email.toLowerCase().includes(filter)))
            .slice(0, 10);
    }
    /**
     * Check if there are unsaved changes
     */
    get HasChanges() {
        return this.UserShares.some(s => s.IsNew || s.MarkedForRemoval || s.Permission.Dirty);
    }
    /**
     * Add a user to the share list
     */
    async addUserShare(user) {
        if (!this.Dashboard)
            return;
        const md = new Metadata();
        const permission = await md.GetEntityObject('MJ: Dashboard Permissions');
        permission.NewRecord();
        permission.DashboardID = this.Dashboard.ID;
        permission.UserID = user.ID;
        permission.CanRead = true; // Default to read access
        permission.CanEdit = false;
        permission.CanDelete = false;
        permission.CanShare = false;
        this.UserShares.push({
            Permission: permission,
            User: user,
            IsNew: true,
            MarkedForRemoval: false
        });
        this.updateAvailableUsers();
        this.UserSearchFilter = '';
        this.cdr.detectChanges();
    }
    /**
     * Mark a share for removal
     */
    removeUserShare(share) {
        if (share.IsNew) {
            // If it's new, just remove from the array
            this.UserShares = this.UserShares.filter(s => s !== share);
        }
        else {
            // Otherwise mark for removal
            share.MarkedForRemoval = true;
        }
        this.updateAvailableUsers();
        this.cdr.detectChanges();
    }
    /**
     * Undo removal of a share
     */
    undoRemove(share) {
        share.MarkedForRemoval = false;
        this.updateAvailableUsers();
        this.cdr.detectChanges();
    }
    /**
     * Get shares that are not marked for removal
     */
    get ActiveShares() {
        return this.UserShares.filter(s => !s.MarkedForRemoval);
    }
    /**
     * Get shares marked for removal
     */
    get RemovedShares() {
        return this.UserShares.filter(s => s.MarkedForRemoval);
    }
    /**
     * Toggle CanEdit permission (also enables CanRead)
     */
    toggleCanEdit(share) {
        share.Permission.CanEdit = !share.Permission.CanEdit;
        if (share.Permission.CanEdit) {
            share.Permission.CanRead = true;
        }
        this.cdr.detectChanges();
    }
    /**
     * Toggle CanDelete permission (also enables CanRead and CanEdit)
     */
    toggleCanDelete(share) {
        share.Permission.CanDelete = !share.Permission.CanDelete;
        if (share.Permission.CanDelete) {
            share.Permission.CanRead = true;
            share.Permission.CanEdit = true;
        }
        this.cdr.detectChanges();
    }
    /**
     * Toggle CanShare permission (also enables CanRead)
     */
    toggleCanShare(share) {
        share.Permission.CanShare = !share.Permission.CanShare;
        if (share.Permission.CanShare) {
            share.Permission.CanRead = true;
        }
        this.cdr.detectChanges();
    }
    /**
     * Save all permission changes
     */
    async onSave() {
        if (!this.HasChanges) {
            this.onCancel();
            return;
        }
        this.IsLoading = true;
        this.Error = null;
        this.cdr.detectChanges();
        try {
            // Process removals first
            for (const share of this.UserShares.filter(s => s.MarkedForRemoval && !s.IsNew)) {
                const deleted = await share.Permission.Delete();
                if (!deleted) {
                    throw new Error(`Failed to remove share for ${share.User.Name}`);
                }
            }
            // Process new and modified shares
            for (const share of this.UserShares.filter(s => !s.MarkedForRemoval && (s.IsNew || s.Permission.Dirty))) {
                const saved = await share.Permission.Save();
                if (!saved) {
                    throw new Error(`Failed to save share for ${share.User.Name}: ${share.Permission.LatestResult?.Message}`);
                }
            }
            // Refresh the engine cache
            await DashboardEngine.Instance.Config(true);
            this.Result.emit({
                Action: 'save',
                Dashboard: this.Dashboard
            });
        }
        catch (error) {
            console.error('Error saving shares:', error);
            this.Error = error instanceof Error ? error.message : 'Failed to save sharing settings.';
        }
        finally {
            this.IsLoading = false;
            this.cdr.detectChanges();
        }
    }
    /**
     * Cancel and close the dialog
     */
    onCancel() {
        this.Result.emit({ Action: 'cancel' });
    }
    /**
     * Get initials for a user (for avatar display)
     */
    getUserInitials(user) {
        const name = user.Name || user.Email || '?';
        const parts = name.split(' ');
        if (parts.length >= 2) {
            return (parts[0][0] + parts[1][0]).toUpperCase();
        }
        return name.substring(0, 2).toUpperCase();
    }
    static ɵfac = function DashboardShareDialogComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || DashboardShareDialogComponent)(i0.ɵɵdirectiveInject(i0.ChangeDetectorRef)); };
    static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: DashboardShareDialogComponent, selectors: [["mj-dashboard-share-dialog"]], inputs: { Visible: "Visible", Dashboard: "Dashboard" }, outputs: { Result: "Result" }, standalone: false, features: [i0.ɵɵNgOnChangesFeature], decls: 1, vars: 1, consts: [[1, "mj-share-dialog-window", 3, "Visible", "Width", "MinHeight", "Resizable", "Draggable"], [1, "mj-share-dialog-window", 3, "Close", "Visible", "Width", "MinHeight", "Resizable", "Draggable"], [1, "share-dialog-header"], [1, "fa-solid", "fa-share-nodes"], [1, "share-dialog-body"], [1, "share-alert", "share-alert-error"], [1, "share-section"], [1, "share-search-box"], [1, "fa-solid", "fa-search"], ["type", "text", "placeholder", "Add people by name or email...", 3, "ngModelChange", "ngModel", "disabled"], [1, "share-user-dropdown"], [1, "share-no-results"], [1, "share-section-label"], [1, "share-person", "share-owner"], [1, "share-avatar", "share-avatar-owner"], [1, "fa-solid", "fa-crown"], [1, "share-person-info"], [1, "share-person-name"], [1, "share-person-role"], [1, "share-person", 3, "share-person-new", "share-person-modified"], [1, "share-empty"], [1, "share-removed-section"], [1, "share-footer"], [1, "share-changes-hint"], [1, "share-footer-actions"], ["type", "button", 1, "share-btn", "share-btn-secondary", 3, "click"], ["type", "button", 1, "share-btn", "share-btn-primary", 3, "click", "disabled"], [1, "fa-solid", "fa-exclamation-triangle"], ["type", "button", 1, "share-user-option", 3, "disabled"], ["type", "button", 1, "share-user-option", 3, "click", "disabled"], [1, "share-avatar"], [1, "share-user-name"], [1, "share-user-email"], [1, "fa-solid", "fa-plus"], [1, "share-person"], [1, "share-badge-new"], [1, "share-person-email"], [1, "share-permissions"], ["title", "Can view", 1, "share-perm"], ["type", "checkbox", "disabled", "", 3, "checked"], [1, "fa-solid", "fa-eye"], ["title", "Can edit", 1, "share-perm"], ["type", "checkbox", 3, "change", "checked"], [1, "fa-solid", "fa-edit"], ["title", "Can delete", 1, "share-perm"], [1, "fa-solid", "fa-trash"], ["title", "Can share", 1, "share-perm"], [1, "fa-solid", "fa-share"], ["type", "button", "title", "Remove", 1, "share-remove-btn", 3, "click"], [1, "fa-solid", "fa-times"], [1, "fa-solid", "fa-user-lock"], [1, "share-removed-item"], [1, "share-avatar", "share-avatar-removed"], [1, "share-removed-name"], ["type", "button", 1, "share-undo-btn", 3, "click"], [1, "fa-solid", "fa-undo"], [1, "fa-solid", "fa-circle"], [1, "fa-solid", "fa-spinner", "fa-spin"]], template: function DashboardShareDialogComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵconditionalCreate(0, DashboardShareDialogComponent_Conditional_0_Template, 37, 17, "mj-window", 0);
        } if (rf & 2) {
            i0.ɵɵconditional(ctx.Visible ? 0 : -1);
        } }, dependencies: [i1.DefaultValueAccessor, i1.NgControlStatus, i1.NgModel, i2.MJWindowComponent, i2.MJWindowTitlebarComponent], styles: ["/* Dashboard Share Dialog - Compact Design */\n\n/* Window Styling - use specific class to override Kendo defaults */\n.mj-share-dialog-window.k-window {\n    border-radius: 12px !important;\n    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2) !important;\n    overflow: hidden !important;\n}\n\n.mj-share-dialog-window .k-window-titlebar {\n    background: var(--mj-brand-primary) !important;\n    border: none !important;\n    padding: 16px 20px !important;\n}\n\n.mj-share-dialog-window .k-window-titlebar .k-window-title {\n    display: none !important;\n}\n\n.mj-share-dialog-window .k-window-titlebar .k-window-actions .k-button {\n    background: color-mix(in srgb, var(--mj-bg-surface) 15%, transparent) !important;\n    border: none !important;\n    color: var(--mj-text-inverse) !important;\n    border-radius: 4px !important;\n}\n\n.mj-share-dialog-window .k-window-titlebar .k-window-actions .k-button:hover {\n    background: color-mix(in srgb, var(--mj-bg-surface) 25%, transparent) !important;\n}\n\n.mj-share-dialog-window .k-window-content {\n    padding: 0 !important;\n    background: var(--mj-bg-surface) !important;\n}\n\n/* Header */\n.share-dialog-header {\n    display: flex;\n    align-items: center;\n    gap: 10px;\n    color: var(--mj-text-inverse);\n    font-size: 16px;\n    font-weight: 500;\n}\n\n.share-dialog-header i {\n    font-size: 18px;\n    opacity: 0.9;\n}\n\n/* Body */\n.share-dialog-body {\n    padding: 0;\n}\n\n/* Alert */\n.share-alert {\n    display: flex;\n    align-items: center;\n    gap: 10px;\n    padding: 12px 20px;\n    font-size: 13px;\n}\n\n.share-alert-error {\n    background: var(--mj-bg-error);\n    color: var(--mj-status-error);\n    border-bottom: 1px solid var(--mj-border-error);\n}\n\n/* Sections */\n.share-section {\n    padding: 16px 20px;\n}\n\n.share-section:not(:last-child) {\n    border-bottom: 1px solid var(--mj-border-default);\n}\n\n.share-section-label {\n    font-size: 11px;\n    font-weight: 600;\n    color: var(--mj-text-secondary);\n    text-transform: uppercase;\n    letter-spacing: 0.5px;\n    margin-bottom: 12px;\n}\n\n/* Search Box */\n.share-search-box {\n    display: flex;\n    align-items: center;\n    gap: 10px;\n    padding: 10px 14px;\n    background: var(--mj-bg-surface-card);\n    border-radius: 8px;\n    border: 1px solid transparent;\n    transition: all 0.15s;\n}\n\n.share-search-box:focus-within {\n    background: var(--mj-bg-surface);\n    border-color: var(--mj-brand-primary);\n    box-shadow: 0 0 0 3px color-mix(in srgb, var(--mj-brand-primary) 10%, transparent);\n}\n\n.share-search-box i {\n    color: var(--mj-text-disabled);\n    font-size: 14px;\n}\n\n.share-search-box input {\n    flex: 1;\n    border: none;\n    background: transparent;\n    font-size: 14px;\n    outline: none;\n}\n\n.share-search-box input::placeholder {\n    color: var(--mj-text-disabled);\n}\n\n/* User Dropdown */\n.share-user-dropdown {\n    margin-top: 8px;\n    max-height: 180px;\n    overflow-y: auto;\n    border: 1px solid var(--mj-border-default);\n    border-radius: 8px;\n    background: var(--mj-bg-surface-card);\n}\n\n/* User Option */\n.share-user-option {\n    display: flex;\n    align-items: center;\n    gap: 10px;\n    width: 100%;\n    padding: 10px 12px;\n    border: none;\n    background: transparent;\n    cursor: pointer;\n    text-align: left;\n    transition: background 0.1s;\n}\n\n.share-user-option:hover {\n    background: color-mix(in srgb, var(--mj-brand-primary) 8%, transparent);\n}\n\n.share-user-option:disabled {\n    opacity: 0.5;\n    cursor: not-allowed;\n}\n\n.share-user-option .share-user-name {\n    flex: 1;\n    font-size: 14px;\n    font-weight: 500;\n    color: var(--mj-text-primary);\n}\n\n.share-user-option .share-user-email {\n    font-size: 12px;\n    color: var(--mj-text-secondary);\n    margin-right: auto;\n}\n\n.share-user-option i.fa-plus {\n    color: var(--mj-brand-primary);\n    font-size: 12px;\n    opacity: 0;\n    transition: opacity 0.1s;\n}\n\n.share-user-option:hover i.fa-plus {\n    opacity: 1;\n}\n\n.share-no-results {\n    padding: 16px;\n    text-align: center;\n    color: var(--mj-text-secondary);\n    font-size: 13px;\n}\n\n/* Avatar */\n.share-avatar {\n    width: 32px;\n    height: 32px;\n    border-radius: 50%;\n    background: var(--mj-brand-primary);\n    color: var(--mj-text-inverse);\n    font-size: 12px;\n    font-weight: 600;\n    display: flex;\n    align-items: center;\n    justify-content: center;\n    flex-shrink: 0;\n}\n\n.share-avatar-owner {\n    background: var(--mj-status-warning);\n    font-size: 14px;\n}\n\n.share-avatar-removed {\n    background: var(--mj-border-strong);\n}\n\n/* Person Row */\n.share-person {\n    display: flex;\n    align-items: center;\n    gap: 12px;\n    padding: 10px 0;\n}\n\n.share-person:not(:last-child) {\n    border-bottom: 1px solid var(--mj-bg-surface-sunken);\n}\n\n.share-person-new {\n    background: color-mix(in srgb, var(--mj-status-success) 5%, transparent);\n    margin: 0 -20px;\n    padding: 10px 20px;\n}\n\n.share-person-modified {\n    background: color-mix(in srgb, var(--mj-brand-primary) 5%, transparent);\n    margin: 0 -20px;\n    padding: 10px 20px;\n}\n\n.share-person-info {\n    flex: 1;\n    min-width: 0;\n}\n\n.share-person-name {\n    display: flex;\n    align-items: center;\n    gap: 8px;\n    font-size: 14px;\n    font-weight: 500;\n    color: var(--mj-text-primary);\n}\n\n.share-person-email {\n    font-size: 12px;\n    color: var(--mj-text-secondary);\n    overflow: hidden;\n    text-overflow: ellipsis;\n    white-space: nowrap;\n}\n\n.share-person-role {\n    font-size: 12px;\n    color: var(--mj-status-warning);\n    font-weight: 500;\n}\n\n.share-badge-new {\n    padding: 2px 6px;\n    background: var(--mj-status-success);\n    color: var(--mj-text-inverse);\n    font-size: 10px;\n    font-weight: 600;\n    border-radius: 4px;\n}\n\n/* Permissions */\n.share-permissions {\n    display: flex;\n    gap: 4px;\n}\n\n.share-perm {\n    display: flex;\n    align-items: center;\n    justify-content: center;\n    width: 28px;\n    height: 28px;\n    border-radius: 4px;\n    cursor: pointer;\n    transition: all 0.1s;\n    position: relative;\n}\n\n.share-perm input {\n    position: absolute;\n    opacity: 0;\n    cursor: pointer;\n}\n\n.share-perm i {\n    font-size: 12px;\n    color: var(--mj-border-strong);\n    transition: color 0.1s;\n}\n\n.share-perm:hover {\n    background: var(--mj-bg-surface-sunken);\n}\n\n.share-perm input:checked + i {\n    color: var(--mj-brand-primary);\n}\n\n.share-perm input:disabled + i {\n    color: var(--mj-brand-primary);\n    opacity: 0.7;\n}\n\n/* Remove Button */\n.share-remove-btn {\n    width: 28px;\n    height: 28px;\n    border: none;\n    background: transparent;\n    color: var(--mj-border-strong);\n    border-radius: 4px;\n    cursor: pointer;\n    display: flex;\n    align-items: center;\n    justify-content: center;\n    transition: all 0.1s;\n}\n\n.share-remove-btn:hover {\n    background: var(--mj-bg-error);\n    color: var(--mj-status-error);\n}\n\n/* Empty State */\n.share-empty {\n    display: flex;\n    align-items: center;\n    gap: 10px;\n    padding: 20px;\n    color: var(--mj-text-disabled);\n    font-size: 13px;\n    background: var(--mj-bg-surface-card);\n    border-radius: 8px;\n    justify-content: center;\n}\n\n.share-empty i {\n    font-size: 16px;\n}\n\n/* Removed Section */\n.share-removed-section {\n    margin-top: 12px;\n    padding: 12px;\n    background: var(--mj-bg-warning);\n    border-radius: 8px;\n    border: 1px solid var(--mj-border-warning);\n}\n\n.share-removed-item {\n    display: flex;\n    align-items: center;\n    gap: 10px;\n    padding: 6px 0;\n}\n\n.share-removed-name {\n    flex: 1;\n    font-size: 13px;\n    color: var(--mj-text-secondary);\n    text-decoration: line-through;\n}\n\n.share-undo-btn {\n    padding: 4px 10px;\n    border: none;\n    background: transparent;\n    color: var(--mj-status-warning);\n    font-size: 12px;\n    font-weight: 500;\n    cursor: pointer;\n    display: flex;\n    align-items: center;\n    gap: 4px;\n}\n\n.share-undo-btn:hover {\n    text-decoration: underline;\n}\n\n/* Footer */\n.share-footer {\n    display: flex;\n    align-items: center;\n    justify-content: space-between;\n    padding: 16px 20px;\n    background: var(--mj-bg-surface-card);\n    border-top: 1px solid var(--mj-border-default);\n}\n\n.share-changes-hint {\n    display: flex;\n    align-items: center;\n    gap: 6px;\n    font-size: 12px;\n    color: var(--mj-brand-primary);\n}\n\n.share-changes-hint i {\n    font-size: 6px;\n}\n\n.share-footer-actions {\n    display: flex;\n    gap: 10px;\n    margin-left: auto;\n}\n\n.share-btn {\n    padding: 8px 18px;\n    border-radius: 6px;\n    font-size: 14px;\n    font-weight: 500;\n    cursor: pointer;\n    transition: all 0.15s;\n    display: flex;\n    align-items: center;\n    gap: 6px;\n}\n\n.share-btn:disabled {\n    opacity: 0.5;\n    cursor: not-allowed;\n}\n\n.share-btn-secondary {\n    background: var(--mj-bg-surface);\n    border: 1px solid var(--mj-border-strong);\n    color: var(--mj-text-secondary);\n}\n\n.share-btn-secondary:hover:not(:disabled) {\n    background: var(--mj-bg-surface-card);\n    border-color: var(--mj-border-strong);\n}\n\n.share-btn-primary {\n    background: var(--mj-brand-primary);\n    border: none;\n    color: var(--mj-text-inverse);\n}\n\n.share-btn-primary:hover:not(:disabled) {\n    background: var(--mj-brand-primary-hover);\n    box-shadow: 0 2px 8px color-mix(in srgb, var(--mj-brand-primary) 30%, transparent);\n}\n\n/* Owner row specific styling */\n.share-owner {\n    background: var(--mj-bg-warning);\n    margin: 0 -20px;\n    padding: 10px 20px;\n    border-radius: 0;\n}\n"], encapsulation: 2 });
}
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(DashboardShareDialogComponent, [{
        type: Component,
        args: [{ standalone: false, selector: 'mj-dashboard-share-dialog', encapsulation: ViewEncapsulation.None, template: "@if (Visible) {\n  <mj-window\n    [Visible]=\"true\"\n    [Width]=\"560\"\n    [MinHeight]=\"200\"\n    [Resizable]=\"false\"\n    [Draggable]=\"true\"\n    (Close)=\"onCancel()\"\n    class=\"mj-share-dialog-window\">\n    <mj-window-titlebar>\n      <div class=\"share-dialog-header\">\n        <i class=\"fa-solid fa-share-nodes\"></i>\n        <span>Share \"{{ Dashboard?.Name }}\"</span>\n      </div>\n    </mj-window-titlebar>\n    <div class=\"share-dialog-body\">\n      <!-- Error Alert -->\n      @if (Error) {\n        <div class=\"share-alert share-alert-error\">\n          <i class=\"fa-solid fa-exclamation-triangle\"></i>\n          <span>{{ Error }}</span>\n        </div>\n      }\n      <!-- Add Users Section -->\n      <div class=\"share-section\">\n        <div class=\"share-search-box\">\n          <i class=\"fa-solid fa-search\"></i>\n          <input\n            type=\"text\"\n            placeholder=\"Add people by name or email...\"\n            [(ngModel)]=\"UserSearchFilter\"\n            [disabled]=\"IsLoading\">\n        </div>\n        <!-- Available Users Dropdown -->\n        @if (FilteredAvailableUsers.length > 0) {\n          <div class=\"share-user-dropdown\">\n            @for (user of FilteredAvailableUsers; track user.ID) {\n              <button type=\"button\" class=\"share-user-option\" (click)=\"addUserShare(user)\" [disabled]=\"IsLoading\">\n                <span class=\"share-avatar\">{{ getUserInitials(user) }}</span>\n                <span class=\"share-user-name\">{{ user.Name }}</span>\n                @if (user.Email) {\n                  <span class=\"share-user-email\">{{ user.Email }}</span>\n                }\n                <i class=\"fa-solid fa-plus\"></i>\n              </button>\n            }\n          </div>\n        }\n        @if (UserSearchFilter && FilteredAvailableUsers.length === 0) {\n          <div class=\"share-no-results\">\n            No users found matching \"{{ UserSearchFilter }}\"\n          </div>\n        }\n      </div>\n      <!-- People with Access -->\n      <div class=\"share-section\">\n        <div class=\"share-section-label\">People with access</div>\n        <!-- Owner -->\n        <div class=\"share-person share-owner\">\n          <span class=\"share-avatar share-avatar-owner\">\n            <i class=\"fa-solid fa-crown\"></i>\n          </span>\n          <div class=\"share-person-info\">\n            <span class=\"share-person-name\">{{ Dashboard?.User || 'You' }}</span>\n            <span class=\"share-person-role\">Owner</span>\n          </div>\n        </div>\n        <!-- Shared Users -->\n        @for (share of ActiveShares; track share.User.ID) {\n          <div class=\"share-person\" [class.share-person-new]=\"share.IsNew\" [class.share-person-modified]=\"share.Permission.Dirty\">\n            <span class=\"share-avatar\">{{ getUserInitials(share.User) }}</span>\n            <div class=\"share-person-info\">\n              <span class=\"share-person-name\">\n                {{ share.User.Name }}\n                @if (share.IsNew) {\n                  <span class=\"share-badge-new\">New</span>\n                }\n              </span>\n              @if (share.User.Email) {\n                <span class=\"share-person-email\">{{ share.User.Email }}</span>\n              }\n            </div>\n            <div class=\"share-permissions\">\n              <label class=\"share-perm\" title=\"Can view\">\n                <input type=\"checkbox\" [checked]=\"share.Permission.CanRead\" disabled>\n                <i class=\"fa-solid fa-eye\"></i>\n              </label>\n              <label class=\"share-perm\" title=\"Can edit\">\n                <input type=\"checkbox\" [checked]=\"share.Permission.CanEdit\" (change)=\"toggleCanEdit(share)\">\n                <i class=\"fa-solid fa-edit\"></i>\n              </label>\n              <label class=\"share-perm\" title=\"Can delete\">\n                <input type=\"checkbox\" [checked]=\"share.Permission.CanDelete\" (change)=\"toggleCanDelete(share)\">\n                <i class=\"fa-solid fa-trash\"></i>\n              </label>\n              <label class=\"share-perm\" title=\"Can share\">\n                <input type=\"checkbox\" [checked]=\"share.Permission.CanShare\" (change)=\"toggleCanShare(share)\">\n                <i class=\"fa-solid fa-share\"></i>\n              </label>\n            </div>\n            <button type=\"button\" class=\"share-remove-btn\" (click)=\"removeUserShare(share)\" title=\"Remove\">\n              <i class=\"fa-solid fa-times\"></i>\n            </button>\n          </div>\n        }\n        @if (ActiveShares.length === 0) {\n          <div class=\"share-empty\">\n            <i class=\"fa-solid fa-user-lock\"></i>\n            <span>Not shared with anyone yet</span>\n          </div>\n        }\n        <!-- Pending Removals -->\n        @if (RemovedShares.length > 0) {\n          <div class=\"share-removed-section\">\n            @for (share of RemovedShares; track share.User.ID) {\n              <div class=\"share-removed-item\">\n                <span class=\"share-avatar share-avatar-removed\">{{ getUserInitials(share.User) }}</span>\n                <span class=\"share-removed-name\">{{ share.User.Name }}</span>\n                <button type=\"button\" class=\"share-undo-btn\" (click)=\"undoRemove(share)\">\n                  <i class=\"fa-solid fa-undo\"></i> Undo\n                </button>\n              </div>\n            }\n          </div>\n        }\n      </div>\n      <!-- Footer -->\n      <div class=\"share-footer\">\n        @if (HasChanges) {\n          <span class=\"share-changes-hint\">\n            <i class=\"fa-solid fa-circle\"></i> Unsaved changes\n          </span>\n        }\n        <div class=\"share-footer-actions\">\n          <button type=\"button\" class=\"share-btn share-btn-secondary\" (click)=\"onCancel()\">\n            Cancel\n          </button>\n          <button\n            type=\"button\"\n            class=\"share-btn share-btn-primary\"\n            (click)=\"onSave()\"\n            [disabled]=\"!HasChanges || IsLoading\">\n            @if (IsLoading) {\n              <i class=\"fa-solid fa-spinner fa-spin\"></i> Saving...\n            } @else {\n              Save\n            }\n          </button>\n        </div>\n      </div>\n    </div>\n  </mj-window>\n}\n", styles: ["/* Dashboard Share Dialog - Compact Design */\n\n/* Window Styling - use specific class to override Kendo defaults */\n.mj-share-dialog-window.k-window {\n    border-radius: 12px !important;\n    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2) !important;\n    overflow: hidden !important;\n}\n\n.mj-share-dialog-window .k-window-titlebar {\n    background: var(--mj-brand-primary) !important;\n    border: none !important;\n    padding: 16px 20px !important;\n}\n\n.mj-share-dialog-window .k-window-titlebar .k-window-title {\n    display: none !important;\n}\n\n.mj-share-dialog-window .k-window-titlebar .k-window-actions .k-button {\n    background: color-mix(in srgb, var(--mj-bg-surface) 15%, transparent) !important;\n    border: none !important;\n    color: var(--mj-text-inverse) !important;\n    border-radius: 4px !important;\n}\n\n.mj-share-dialog-window .k-window-titlebar .k-window-actions .k-button:hover {\n    background: color-mix(in srgb, var(--mj-bg-surface) 25%, transparent) !important;\n}\n\n.mj-share-dialog-window .k-window-content {\n    padding: 0 !important;\n    background: var(--mj-bg-surface) !important;\n}\n\n/* Header */\n.share-dialog-header {\n    display: flex;\n    align-items: center;\n    gap: 10px;\n    color: var(--mj-text-inverse);\n    font-size: 16px;\n    font-weight: 500;\n}\n\n.share-dialog-header i {\n    font-size: 18px;\n    opacity: 0.9;\n}\n\n/* Body */\n.share-dialog-body {\n    padding: 0;\n}\n\n/* Alert */\n.share-alert {\n    display: flex;\n    align-items: center;\n    gap: 10px;\n    padding: 12px 20px;\n    font-size: 13px;\n}\n\n.share-alert-error {\n    background: var(--mj-bg-error);\n    color: var(--mj-status-error);\n    border-bottom: 1px solid var(--mj-border-error);\n}\n\n/* Sections */\n.share-section {\n    padding: 16px 20px;\n}\n\n.share-section:not(:last-child) {\n    border-bottom: 1px solid var(--mj-border-default);\n}\n\n.share-section-label {\n    font-size: 11px;\n    font-weight: 600;\n    color: var(--mj-text-secondary);\n    text-transform: uppercase;\n    letter-spacing: 0.5px;\n    margin-bottom: 12px;\n}\n\n/* Search Box */\n.share-search-box {\n    display: flex;\n    align-items: center;\n    gap: 10px;\n    padding: 10px 14px;\n    background: var(--mj-bg-surface-card);\n    border-radius: 8px;\n    border: 1px solid transparent;\n    transition: all 0.15s;\n}\n\n.share-search-box:focus-within {\n    background: var(--mj-bg-surface);\n    border-color: var(--mj-brand-primary);\n    box-shadow: 0 0 0 3px color-mix(in srgb, var(--mj-brand-primary) 10%, transparent);\n}\n\n.share-search-box i {\n    color: var(--mj-text-disabled);\n    font-size: 14px;\n}\n\n.share-search-box input {\n    flex: 1;\n    border: none;\n    background: transparent;\n    font-size: 14px;\n    outline: none;\n}\n\n.share-search-box input::placeholder {\n    color: var(--mj-text-disabled);\n}\n\n/* User Dropdown */\n.share-user-dropdown {\n    margin-top: 8px;\n    max-height: 180px;\n    overflow-y: auto;\n    border: 1px solid var(--mj-border-default);\n    border-radius: 8px;\n    background: var(--mj-bg-surface-card);\n}\n\n/* User Option */\n.share-user-option {\n    display: flex;\n    align-items: center;\n    gap: 10px;\n    width: 100%;\n    padding: 10px 12px;\n    border: none;\n    background: transparent;\n    cursor: pointer;\n    text-align: left;\n    transition: background 0.1s;\n}\n\n.share-user-option:hover {\n    background: color-mix(in srgb, var(--mj-brand-primary) 8%, transparent);\n}\n\n.share-user-option:disabled {\n    opacity: 0.5;\n    cursor: not-allowed;\n}\n\n.share-user-option .share-user-name {\n    flex: 1;\n    font-size: 14px;\n    font-weight: 500;\n    color: var(--mj-text-primary);\n}\n\n.share-user-option .share-user-email {\n    font-size: 12px;\n    color: var(--mj-text-secondary);\n    margin-right: auto;\n}\n\n.share-user-option i.fa-plus {\n    color: var(--mj-brand-primary);\n    font-size: 12px;\n    opacity: 0;\n    transition: opacity 0.1s;\n}\n\n.share-user-option:hover i.fa-plus {\n    opacity: 1;\n}\n\n.share-no-results {\n    padding: 16px;\n    text-align: center;\n    color: var(--mj-text-secondary);\n    font-size: 13px;\n}\n\n/* Avatar */\n.share-avatar {\n    width: 32px;\n    height: 32px;\n    border-radius: 50%;\n    background: var(--mj-brand-primary);\n    color: var(--mj-text-inverse);\n    font-size: 12px;\n    font-weight: 600;\n    display: flex;\n    align-items: center;\n    justify-content: center;\n    flex-shrink: 0;\n}\n\n.share-avatar-owner {\n    background: var(--mj-status-warning);\n    font-size: 14px;\n}\n\n.share-avatar-removed {\n    background: var(--mj-border-strong);\n}\n\n/* Person Row */\n.share-person {\n    display: flex;\n    align-items: center;\n    gap: 12px;\n    padding: 10px 0;\n}\n\n.share-person:not(:last-child) {\n    border-bottom: 1px solid var(--mj-bg-surface-sunken);\n}\n\n.share-person-new {\n    background: color-mix(in srgb, var(--mj-status-success) 5%, transparent);\n    margin: 0 -20px;\n    padding: 10px 20px;\n}\n\n.share-person-modified {\n    background: color-mix(in srgb, var(--mj-brand-primary) 5%, transparent);\n    margin: 0 -20px;\n    padding: 10px 20px;\n}\n\n.share-person-info {\n    flex: 1;\n    min-width: 0;\n}\n\n.share-person-name {\n    display: flex;\n    align-items: center;\n    gap: 8px;\n    font-size: 14px;\n    font-weight: 500;\n    color: var(--mj-text-primary);\n}\n\n.share-person-email {\n    font-size: 12px;\n    color: var(--mj-text-secondary);\n    overflow: hidden;\n    text-overflow: ellipsis;\n    white-space: nowrap;\n}\n\n.share-person-role {\n    font-size: 12px;\n    color: var(--mj-status-warning);\n    font-weight: 500;\n}\n\n.share-badge-new {\n    padding: 2px 6px;\n    background: var(--mj-status-success);\n    color: var(--mj-text-inverse);\n    font-size: 10px;\n    font-weight: 600;\n    border-radius: 4px;\n}\n\n/* Permissions */\n.share-permissions {\n    display: flex;\n    gap: 4px;\n}\n\n.share-perm {\n    display: flex;\n    align-items: center;\n    justify-content: center;\n    width: 28px;\n    height: 28px;\n    border-radius: 4px;\n    cursor: pointer;\n    transition: all 0.1s;\n    position: relative;\n}\n\n.share-perm input {\n    position: absolute;\n    opacity: 0;\n    cursor: pointer;\n}\n\n.share-perm i {\n    font-size: 12px;\n    color: var(--mj-border-strong);\n    transition: color 0.1s;\n}\n\n.share-perm:hover {\n    background: var(--mj-bg-surface-sunken);\n}\n\n.share-perm input:checked + i {\n    color: var(--mj-brand-primary);\n}\n\n.share-perm input:disabled + i {\n    color: var(--mj-brand-primary);\n    opacity: 0.7;\n}\n\n/* Remove Button */\n.share-remove-btn {\n    width: 28px;\n    height: 28px;\n    border: none;\n    background: transparent;\n    color: var(--mj-border-strong);\n    border-radius: 4px;\n    cursor: pointer;\n    display: flex;\n    align-items: center;\n    justify-content: center;\n    transition: all 0.1s;\n}\n\n.share-remove-btn:hover {\n    background: var(--mj-bg-error);\n    color: var(--mj-status-error);\n}\n\n/* Empty State */\n.share-empty {\n    display: flex;\n    align-items: center;\n    gap: 10px;\n    padding: 20px;\n    color: var(--mj-text-disabled);\n    font-size: 13px;\n    background: var(--mj-bg-surface-card);\n    border-radius: 8px;\n    justify-content: center;\n}\n\n.share-empty i {\n    font-size: 16px;\n}\n\n/* Removed Section */\n.share-removed-section {\n    margin-top: 12px;\n    padding: 12px;\n    background: var(--mj-bg-warning);\n    border-radius: 8px;\n    border: 1px solid var(--mj-border-warning);\n}\n\n.share-removed-item {\n    display: flex;\n    align-items: center;\n    gap: 10px;\n    padding: 6px 0;\n}\n\n.share-removed-name {\n    flex: 1;\n    font-size: 13px;\n    color: var(--mj-text-secondary);\n    text-decoration: line-through;\n}\n\n.share-undo-btn {\n    padding: 4px 10px;\n    border: none;\n    background: transparent;\n    color: var(--mj-status-warning);\n    font-size: 12px;\n    font-weight: 500;\n    cursor: pointer;\n    display: flex;\n    align-items: center;\n    gap: 4px;\n}\n\n.share-undo-btn:hover {\n    text-decoration: underline;\n}\n\n/* Footer */\n.share-footer {\n    display: flex;\n    align-items: center;\n    justify-content: space-between;\n    padding: 16px 20px;\n    background: var(--mj-bg-surface-card);\n    border-top: 1px solid var(--mj-border-default);\n}\n\n.share-changes-hint {\n    display: flex;\n    align-items: center;\n    gap: 6px;\n    font-size: 12px;\n    color: var(--mj-brand-primary);\n}\n\n.share-changes-hint i {\n    font-size: 6px;\n}\n\n.share-footer-actions {\n    display: flex;\n    gap: 10px;\n    margin-left: auto;\n}\n\n.share-btn {\n    padding: 8px 18px;\n    border-radius: 6px;\n    font-size: 14px;\n    font-weight: 500;\n    cursor: pointer;\n    transition: all 0.15s;\n    display: flex;\n    align-items: center;\n    gap: 6px;\n}\n\n.share-btn:disabled {\n    opacity: 0.5;\n    cursor: not-allowed;\n}\n\n.share-btn-secondary {\n    background: var(--mj-bg-surface);\n    border: 1px solid var(--mj-border-strong);\n    color: var(--mj-text-secondary);\n}\n\n.share-btn-secondary:hover:not(:disabled) {\n    background: var(--mj-bg-surface-card);\n    border-color: var(--mj-border-strong);\n}\n\n.share-btn-primary {\n    background: var(--mj-brand-primary);\n    border: none;\n    color: var(--mj-text-inverse);\n}\n\n.share-btn-primary:hover:not(:disabled) {\n    background: var(--mj-brand-primary-hover);\n    box-shadow: 0 2px 8px color-mix(in srgb, var(--mj-brand-primary) 30%, transparent);\n}\n\n/* Owner row specific styling */\n.share-owner {\n    background: var(--mj-bg-warning);\n    margin: 0 -20px;\n    padding: 10px 20px;\n    border-radius: 0;\n}\n"] }]
    }], () => [{ type: i0.ChangeDetectorRef }], { Visible: [{
            type: Input
        }], Dashboard: [{
            type: Input
        }], Result: [{
            type: Output
        }] }); })();
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(DashboardShareDialogComponent, { className: "DashboardShareDialogComponent", filePath: "src/DashboardBrowser/dashboard-share-dialog.component.ts", lineNumber: 41 }); })();
//# sourceMappingURL=dashboard-share-dialog.component.js.map