var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
import { Component } from '@angular/core';
import { PermissionEngine } from '@memberjunction/core-entities';
import { RegisterClass } from '@memberjunction/global';
import { BaseResourceComponent } from '@memberjunction/ng-shared';
import { groupPermissionsByDomain, loadPermissionsUsers, resolvePermissionsUser, } from './permissions-shared';
import * as i0 from "@angular/core";
import * as i1 from "@angular/forms";
import * as i2 from "@memberjunction/ng-ui-components";
import * as i3 from "@memberjunction/ng-shared-generic";
const _forTrack0 = ($index, $item) => $item.ID;
function PermissionsUserAccessResourceComponent_Conditional_5_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 3);
    i0.ɵɵelement(1, "i", 11);
    i0.ɵɵelementStart(2, "span");
    i0.ɵɵtext(3);
    i0.ɵɵelementEnd()();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance(3);
    i0.ɵɵtextInterpolate(ctx_r0.ErrorMessage);
} }
function PermissionsUserAccessResourceComponent_For_11_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "option", 7);
    i0.ɵɵtext(1);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const user_r2 = ctx.$implicit;
    i0.ɵɵproperty("ngValue", user_r2.ID);
    i0.ɵɵadvance();
    i0.ɵɵtextInterpolate2("", user_r2.Name, "", user_r2.Email ? " \u2014 " + user_r2.Email : "");
} }
function PermissionsUserAccessResourceComponent_Conditional_12_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 8);
    i0.ɵɵelement(1, "i", 12);
    i0.ɵɵelementStart(2, "span");
    i0.ɵɵtext(3);
    i0.ɵɵelementEnd()();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance(3);
    i0.ɵɵtextInterpolate(ctx_r0.SelectedUserRoles.join(", "));
} }
function PermissionsUserAccessResourceComponent_Conditional_13_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "mj-loading", 9);
} }
function PermissionsUserAccessResourceComponent_Conditional_14_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 10);
    i0.ɵɵelement(1, "i", 13);
    i0.ɵɵelementStart(2, "p");
    i0.ɵɵtext(3, "Select a user above to see their access report.");
    i0.ɵɵelementEnd()();
} }
function PermissionsUserAccessResourceComponent_Conditional_15_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 10);
    i0.ɵɵelement(1, "i", 14);
    i0.ɵɵelementStart(2, "p");
    i0.ɵɵtext(3, "This user has no permissions granted in any domain.");
    i0.ɵɵelementEnd()();
} }
function PermissionsUserAccessResourceComponent_Conditional_16_For_9_Conditional_9_For_14_Conditional_4_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "span", 29);
    i0.ɵɵtext(1);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const row_r5 = i0.ɵɵnextContext().$implicit;
    i0.ɵɵadvance();
    i0.ɵɵtextInterpolate(row_r5.ResourceID);
} }
function PermissionsUserAccessResourceComponent_Conditional_16_For_9_Conditional_9_For_14_For_10_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "span", 31);
    i0.ɵɵtext(1);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const action_r6 = ctx.$implicit;
    i0.ɵɵadvance();
    i0.ɵɵtextInterpolate(action_r6);
} }
function PermissionsUserAccessResourceComponent_Conditional_16_For_9_Conditional_9_For_14_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "tr")(1, "td", 27)(2, "span", 28);
    i0.ɵɵtext(3);
    i0.ɵɵelementEnd();
    i0.ɵɵconditionalCreate(4, PermissionsUserAccessResourceComponent_Conditional_16_For_9_Conditional_9_For_14_Conditional_4_Template, 2, 1, "span", 29);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(5, "td");
    i0.ɵɵtext(6);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(7, "td")(8, "div", 30);
    i0.ɵɵrepeaterCreate(9, PermissionsUserAccessResourceComponent_Conditional_16_For_9_Conditional_9_For_14_For_10_Template, 2, 1, "span", 31, i0.ɵɵrepeaterTrackByIdentity);
    i0.ɵɵelementEnd()();
    i0.ɵɵelementStart(11, "td")(12, "span", 32);
    i0.ɵɵtext(13);
    i0.ɵɵelementEnd()()();
} if (rf & 2) {
    const row_r5 = ctx.$implicit;
    i0.ɵɵadvance(3);
    i0.ɵɵtextInterpolate(row_r5.ResourceName || row_r5.ResourceID || "\u2014");
    i0.ɵɵadvance();
    i0.ɵɵconditional(row_r5.ResourceID && row_r5.ResourceName && row_r5.ResourceName !== row_r5.ResourceID ? 4 : -1);
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate(row_r5.ResourceType);
    i0.ɵɵadvance(3);
    i0.ɵɵrepeater(row_r5.Actions);
    i0.ɵɵadvance(3);
    i0.ɵɵclassProp("effect-allow", row_r5.Effect === "Allow")("effect-deny", row_r5.Effect === "Deny");
    i0.ɵɵadvance();
    i0.ɵɵtextInterpolate1(" ", row_r5.Effect, " ");
} }
function PermissionsUserAccessResourceComponent_Conditional_16_For_9_Conditional_9_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 25)(1, "table", 26)(2, "thead")(3, "tr")(4, "th");
    i0.ɵɵtext(5, "Resource");
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(6, "th");
    i0.ɵɵtext(7, "Type");
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(8, "th");
    i0.ɵɵtext(9, "Actions");
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(10, "th");
    i0.ɵɵtext(11, "Effect");
    i0.ɵɵelementEnd()()();
    i0.ɵɵelementStart(12, "tbody");
    i0.ɵɵrepeaterCreate(13, PermissionsUserAccessResourceComponent_Conditional_16_For_9_Conditional_9_For_14_Template, 14, 8, "tr", null, i0.ɵɵcomponentInstance().TrackByPermission, true);
    i0.ɵɵelementEnd()()();
} if (rf & 2) {
    const group_r4 = i0.ɵɵnextContext().$implicit;
    i0.ɵɵadvance(13);
    i0.ɵɵrepeater(group_r4.Rows);
} }
function PermissionsUserAccessResourceComponent_Conditional_16_For_9_Template(rf, ctx) { if (rf & 1) {
    const _r3 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "div", 18)(1, "button", 19);
    i0.ɵɵlistener("click", function PermissionsUserAccessResourceComponent_Conditional_16_For_9_Template_button_click_1_listener() { const group_r4 = i0.ɵɵrestoreView(_r3).$implicit; const ctx_r0 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r0.ToggleGroup(group_r4)); });
    i0.ɵɵelementStart(2, "div", 20);
    i0.ɵɵelement(3, "i", 21);
    i0.ɵɵelementStart(4, "span", 22);
    i0.ɵɵtext(5);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(6, "span", 23);
    i0.ɵɵtext(7);
    i0.ɵɵelementEnd()();
    i0.ɵɵelement(8, "i", 24);
    i0.ɵɵelementEnd();
    i0.ɵɵconditionalCreate(9, PermissionsUserAccessResourceComponent_Conditional_16_For_9_Conditional_9_Template, 15, 0, "div", 25);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const group_r4 = ctx.$implicit;
    i0.ɵɵclassProp("expanded", group_r4.Expanded);
    i0.ɵɵadvance(3);
    i0.ɵɵclassMap(group_r4.Icon);
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate(group_r4.DomainName);
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate(group_r4.Count);
    i0.ɵɵadvance();
    i0.ɵɵclassProp("rotated", group_r4.Expanded);
    i0.ɵɵadvance();
    i0.ɵɵconditional(group_r4.Expanded ? 9 : -1);
} }
function PermissionsUserAccessResourceComponent_Conditional_16_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 15)(1, "strong");
    i0.ɵɵtext(2);
    i0.ɵɵelementEnd();
    i0.ɵɵtext(3);
    i0.ɵɵelementStart(4, "strong");
    i0.ɵɵtext(5);
    i0.ɵɵelementEnd();
    i0.ɵɵtext(6);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(7, "div", 16);
    i0.ɵɵrepeaterCreate(8, PermissionsUserAccessResourceComponent_Conditional_16_For_9_Template, 10, 9, "div", 17, i0.ɵɵcomponentInstance().TrackByDomain, true);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate(ctx_r0.TotalCount);
    i0.ɵɵadvance();
    i0.ɵɵtextInterpolate1(" permission", ctx_r0.TotalCount === 1 ? "" : "s", " across ");
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate(ctx_r0.DomainGroups.length);
    i0.ɵɵadvance();
    i0.ɵɵtextInterpolate1(" domain", ctx_r0.DomainGroups.length === 1 ? "" : "s", " ");
    i0.ɵɵadvance(2);
    i0.ɵɵrepeater(ctx_r0.DomainGroups);
} }
/**
 * User Access Report resource — one of three tabs in the Permissions admin application.
 * Lets an admin pick any user and see every resource that user has access to across
 * every registered permission domain. Powered by `PermissionEngine.GetAllUserPermissions`.
 */
let PermissionsUserAccessResourceComponent = class PermissionsUserAccessResourceComponent extends BaseResourceComponent {
    cdr;
    Users = [];
    SelectedUserId = null;
    SelectedUserRoles = [];
    DomainGroups = [];
    IsLoadingUsers = true;
    IsLoadingPermissions = false;
    ErrorMessage = null;
    constructor(cdr) {
        super();
        this.cdr = cdr;
    }
    async GetResourceDisplayName(_data) {
        return 'User Access Report';
    }
    async GetResourceIconClass(_data) {
        return 'fa-solid fa-user';
    }
    async ngOnInit() {
        super.ngOnInit();
        await this.loadUsers();
        this.NotifyLoadComplete();
    }
    ngOnDestroy() {
        super.ngOnDestroy();
    }
    async loadUsers() {
        this.IsLoadingUsers = true;
        this.ErrorMessage = null;
        try {
            this.Users = await loadPermissionsUsers();
            const md = this.ProviderToUse;
            this.SelectedUserId = md.CurrentUser?.ID ?? null;
            if (this.SelectedUserId) {
                await this.loadPermissionsForSelectedUser();
            }
        }
        catch (e) {
            this.ErrorMessage = `Error loading users: ${e instanceof Error ? e.message : String(e)}`;
        }
        this.IsLoadingUsers = false;
        this.cdr.detectChanges();
    }
    async OnUserChanged(userId) {
        this.SelectedUserId = userId;
        await this.loadPermissionsForSelectedUser();
    }
    async loadPermissionsForSelectedUser() {
        this.IsLoadingPermissions = true;
        this.ErrorMessage = null;
        this.cdr.detectChanges();
        try {
            const user = await resolvePermissionsUser(this.SelectedUserId, this.Users);
            if (!user) {
                this.ErrorMessage = 'Could not load roles for the selected user.';
                this.DomainGroups = [];
                this.IsLoadingPermissions = false;
                this.cdr.detectChanges();
                return;
            }
            this.SelectedUserRoles = (user.UserRoles ?? []).map((ur) => ur.Role).filter((n) => !!n);
            const rows = await PermissionEngine.Instance.GetAllUserPermissions(user);
            const orderMap = new Map();
            for (const d of PermissionEngine.Instance.Domains) {
                orderMap.set(d.Name, d.DisplayOrder ?? 999);
            }
            this.DomainGroups = groupPermissionsByDomain(rows, orderMap);
        }
        catch (e) {
            this.ErrorMessage = `Error loading permissions: ${e instanceof Error ? e.message : String(e)}`;
            this.DomainGroups = [];
        }
        this.IsLoadingPermissions = false;
        this.cdr.detectChanges();
    }
    ToggleGroup(group) {
        group.Expanded = !group.Expanded;
        this.cdr.detectChanges();
    }
    TrackByDomain(_index, group) {
        return group.DomainName;
    }
    TrackByPermission(_index, row) {
        return row.SourceRecordID ?? `${row.DomainName}|${row.ResourceType}|${row.ResourceID ?? ''}|${row.GranteeID ?? ''}`;
    }
    ActionsLabel(actions) {
        return actions.join(', ');
    }
    get TotalCount() {
        return this.DomainGroups.reduce((sum, g) => sum + g.Count, 0);
    }
    static ɵfac = function PermissionsUserAccessResourceComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || PermissionsUserAccessResourceComponent)(i0.ɵɵdirectiveInject(i0.ChangeDetectorRef)); };
    static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: PermissionsUserAccessResourceComponent, selectors: [["mj-permissions-user-access-resource"]], standalone: false, features: [i0.ɵɵInheritDefinitionFeature], decls: 17, vars: 7, consts: [["Title", "User Access Report", "Icon", "fa-solid fa-user", "Subtitle", "See every resource a user can access across all registered permission domains"], ["actions", ""], [3, "Clicked", "Loading", "Disabled"], [1, "message", "error-message"], [1, "selector-row"], ["for", "user-select", 1, "selector-label"], ["id", "user-select", 1, "mj-input", 3, "ngModelChange", "ngModel", "disabled"], [3, "ngValue"], ["title", "Roles assigned to this user", 1, "roles-badge"], ["text", "Loading permissions...", "size", "medium"], [1, "empty-state"], [1, "fa-solid", "fa-circle-exclamation"], [1, "fa-solid", "fa-user-tag"], [1, "fa-solid", "fa-user-slash"], [1, "fa-solid", "fa-folder-open"], [1, "total-summary"], [1, "domain-groups"], [1, "domain-group", 3, "expanded"], [1, "domain-group"], ["type", "button", 1, "domain-header", 3, "click"], [1, "domain-header-left"], [1, "domain-icon"], [1, "domain-name"], [1, "domain-count"], [1, "fa-solid", "fa-chevron-down", "toggle-icon"], [1, "domain-body"], [1, "perms-table"], [1, "resource-cell"], [1, "resource-name"], [1, "resource-id"], [1, "action-chips"], [1, "action-chip"], [1, "effect-badge"]], template: function PermissionsUserAccessResourceComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelementStart(0, "mj-page-layout")(1, "mj-page-header", 0)(2, "div", 1)(3, "mj-refresh-button", 2);
            i0.ɵɵlistener("Clicked", function PermissionsUserAccessResourceComponent_Template_mj_refresh_button_Clicked_3_listener() { return ctx.loadUsers(); });
            i0.ɵɵelementEnd()()();
            i0.ɵɵelementStart(4, "mj-page-body");
            i0.ɵɵconditionalCreate(5, PermissionsUserAccessResourceComponent_Conditional_5_Template, 4, 1, "div", 3);
            i0.ɵɵelementStart(6, "div", 4)(7, "label", 5);
            i0.ɵɵtext(8, "User:");
            i0.ɵɵelementEnd();
            i0.ɵɵelementStart(9, "select", 6);
            i0.ɵɵlistener("ngModelChange", function PermissionsUserAccessResourceComponent_Template_select_ngModelChange_9_listener($event) { return ctx.OnUserChanged($event); });
            i0.ɵɵrepeaterCreate(10, PermissionsUserAccessResourceComponent_For_11_Template, 2, 3, "option", 7, _forTrack0);
            i0.ɵɵelementEnd();
            i0.ɵɵconditionalCreate(12, PermissionsUserAccessResourceComponent_Conditional_12_Template, 4, 1, "div", 8);
            i0.ɵɵelementEnd();
            i0.ɵɵconditionalCreate(13, PermissionsUserAccessResourceComponent_Conditional_13_Template, 1, 0, "mj-loading", 9)(14, PermissionsUserAccessResourceComponent_Conditional_14_Template, 4, 0, "div", 10)(15, PermissionsUserAccessResourceComponent_Conditional_15_Template, 4, 0, "div", 10)(16, PermissionsUserAccessResourceComponent_Conditional_16_Template, 10, 4);
            i0.ɵɵelementEnd()();
        } if (rf & 2) {
            i0.ɵɵadvance(3);
            i0.ɵɵproperty("Loading", ctx.IsLoadingUsers)("Disabled", ctx.IsLoadingPermissions);
            i0.ɵɵadvance(2);
            i0.ɵɵconditional(ctx.ErrorMessage ? 5 : -1);
            i0.ɵɵadvance(4);
            i0.ɵɵproperty("ngModel", ctx.SelectedUserId)("disabled", ctx.IsLoadingUsers || ctx.IsLoadingPermissions);
            i0.ɵɵadvance();
            i0.ɵɵrepeater(ctx.Users);
            i0.ɵɵadvance(2);
            i0.ɵɵconditional(ctx.SelectedUserRoles.length > 0 ? 12 : -1);
            i0.ɵɵadvance();
            i0.ɵɵconditional(ctx.IsLoadingPermissions ? 13 : !ctx.SelectedUserId ? 14 : ctx.DomainGroups.length === 0 ? 15 : 16);
        } }, dependencies: [i1.NgSelectOption, i1.ɵNgSelectMultipleOption, i1.SelectControlValueAccessor, i1.NgControlStatus, i1.NgModel, i2.MJPageHeaderComponent, i2.MJPageLayoutComponent, i2.MJPageBodyComponent, i2.MJRefreshButtonComponent, i3.LoadingComponent], styles: ["\n\n.tab-bar[_ngcontent-%COMP%] {\n  display: flex;\n  gap: 4px;\n  border-bottom: 1px solid var(--mj-border-default);\n  margin-bottom: 16px;\n}\n\n.tab[_ngcontent-%COMP%] {\n  background: transparent;\n  border: none;\n  padding: 10px 16px;\n  cursor: pointer;\n  color: var(--mj-text-secondary);\n  font: inherit;\n  font-weight: 500;\n  border-bottom: 2px solid transparent;\n  display: inline-flex;\n  align-items: center;\n  gap: 6px;\n}\n\n.tab[_ngcontent-%COMP%]:hover {\n  color: var(--mj-text-primary);\n  background: var(--mj-bg-surface-hover);\n}\n\n.tab-active[_ngcontent-%COMP%] {\n  color: var(--mj-brand-primary);\n  border-bottom-color: var(--mj-brand-primary);\n}\n\n.selector-row.wrap[_ngcontent-%COMP%] {\n  flex-wrap: wrap;\n}\n\n.mj-input.mono[_ngcontent-%COMP%] {\n  font-family: var(--mj-font-mono, monospace);\n  min-width: 300px;\n}\n\n.muted[_ngcontent-%COMP%] {\n  color: var(--mj-text-muted);\n}\n\n\n\n.message[_ngcontent-%COMP%] {\n  padding: 10px 14px;\n  border-radius: 6px;\n  margin-bottom: 16px;\n  display: flex;\n  align-items: center;\n  gap: 8px;\n  font-size: 14px;\n}\n\n.error-message[_ngcontent-%COMP%] {\n  background: var(--mj-status-error-bg);\n  color: var(--mj-status-error-text);\n  border: 1px solid var(--mj-status-error-border);\n}\n\n\n\n.user-selector-row[_ngcontent-%COMP%], \n.selector-row[_ngcontent-%COMP%] {\n  display: flex;\n  align-items: center;\n  gap: 12px;\n  margin-bottom: 20px;\n  flex-wrap: wrap;\n}\n\n.user-selector-label[_ngcontent-%COMP%], \n.selector-label[_ngcontent-%COMP%] {\n  font-weight: 600;\n  color: var(--mj-text-primary);\n}\n\n#user-select[_ngcontent-%COMP%], \n#domain-select[_ngcontent-%COMP%] {\n  min-width: 320px;\n  flex: 0 1 auto;\n}\n\n.roles-badge[_ngcontent-%COMP%] {\n  display: inline-flex;\n  align-items: center;\n  gap: 6px;\n  padding: 4px 10px;\n  background: color-mix(in srgb, var(--mj-brand-primary) 10%, var(--mj-bg-surface));\n  color: var(--mj-brand-primary);\n  border-radius: 12px;\n  font-size: 12px;\n  font-weight: 500;\n}\n\n\n\n.empty-state[_ngcontent-%COMP%] {\n  text-align: center;\n  padding: 48px 16px;\n  color: var(--mj-text-muted);\n  border: 1px dashed var(--mj-border-default);\n  border-radius: 8px;\n  background: var(--mj-bg-surface-card);\n}\n\n.empty-state[_ngcontent-%COMP%]   i[_ngcontent-%COMP%] {\n  font-size: 32px;\n  margin-bottom: 12px;\n  display: block;\n}\n\n.empty-state[_ngcontent-%COMP%]   p[_ngcontent-%COMP%] {\n  margin: 0;\n  font-size: 14px;\n}\n\n.total-summary[_ngcontent-%COMP%] {\n  color: var(--mj-text-secondary);\n  font-size: 13px;\n  margin-bottom: 12px;\n}\n\n.total-summary[_ngcontent-%COMP%]   strong[_ngcontent-%COMP%] {\n  color: var(--mj-text-primary);\n}\n\n\n\n.domain-groups[_ngcontent-%COMP%] {\n  display: flex;\n  flex-direction: column;\n  gap: 8px;\n}\n\n.domain-group[_ngcontent-%COMP%] {\n  border: 1px solid var(--mj-border-default);\n  border-radius: 8px;\n  overflow: hidden;\n  background: var(--mj-bg-surface);\n}\n\n.domain-header[_ngcontent-%COMP%] {\n  width: 100%;\n  display: flex;\n  align-items: center;\n  justify-content: space-between;\n  padding: 12px 16px;\n  background: var(--mj-bg-surface-card);\n  border: none;\n  cursor: pointer;\n  text-align: left;\n  color: var(--mj-text-primary);\n  font: inherit;\n}\n\n.domain-header[_ngcontent-%COMP%]:hover {\n  background: var(--mj-bg-surface-hover);\n}\n\n.domain-header-left[_ngcontent-%COMP%] {\n  display: flex;\n  align-items: center;\n  gap: 10px;\n}\n\n.domain-icon[_ngcontent-%COMP%] {\n  color: var(--mj-brand-primary);\n  font-size: 16px;\n}\n\n.domain-name[_ngcontent-%COMP%] {\n  font-weight: 600;\n  font-size: 15px;\n}\n\n.domain-count[_ngcontent-%COMP%] {\n  display: inline-flex;\n  align-items: center;\n  justify-content: center;\n  min-width: 24px;\n  height: 20px;\n  padding: 0 8px;\n  background: var(--mj-brand-primary);\n  color: var(--mj-text-inverse);\n  border-radius: 10px;\n  font-size: 12px;\n  font-weight: 600;\n}\n\n.toggle-icon[_ngcontent-%COMP%] {\n  transition: transform 0.15s ease;\n  color: var(--mj-text-muted);\n}\n\n.toggle-icon.rotated[_ngcontent-%COMP%] {\n  transform: rotate(180deg);\n}\n\n.domain-body[_ngcontent-%COMP%] {\n  padding: 0;\n  background: var(--mj-bg-surface);\n  overflow-x: auto;\n}\n\n\n\n.perms-table[_ngcontent-%COMP%] {\n  width: 100%;\n  border-collapse: collapse;\n  font-size: 13px;\n}\n\n.perms-table[_ngcontent-%COMP%]   th[_ngcontent-%COMP%], \n.perms-table[_ngcontent-%COMP%]   td[_ngcontent-%COMP%] {\n  padding: 8px 16px;\n  text-align: left;\n  border-bottom: 1px solid var(--mj-border-subtle);\n  vertical-align: top;\n}\n\n.perms-table[_ngcontent-%COMP%]   th[_ngcontent-%COMP%] {\n  background: var(--mj-bg-surface-sunken);\n  color: var(--mj-text-secondary);\n  font-weight: 600;\n  text-transform: uppercase;\n  font-size: 11px;\n  letter-spacing: 0.5px;\n}\n\n.perms-table[_ngcontent-%COMP%]   tbody[_ngcontent-%COMP%]   tr[_ngcontent-%COMP%]:last-child   td[_ngcontent-%COMP%] {\n  border-bottom: none;\n}\n\n.perms-table[_ngcontent-%COMP%]   tbody[_ngcontent-%COMP%]   tr[_ngcontent-%COMP%]:hover {\n  background: var(--mj-bg-surface-hover);\n}\n\n.resource-cell[_ngcontent-%COMP%] {\n  display: flex;\n  flex-direction: column;\n  gap: 2px;\n}\n\n.resource-name[_ngcontent-%COMP%] {\n  color: var(--mj-text-primary);\n  font-weight: 500;\n}\n\n.resource-id[_ngcontent-%COMP%] {\n  color: var(--mj-text-muted);\n  font-size: 11px;\n  font-family: var(--mj-font-mono, monospace);\n}\n\n\n\n.action-chips[_ngcontent-%COMP%] {\n  display: flex;\n  flex-wrap: wrap;\n  gap: 4px;\n}\n\n.action-chip[_ngcontent-%COMP%] {\n  display: inline-flex;\n  align-items: center;\n  padding: 2px 8px;\n  background: color-mix(in srgb, var(--mj-brand-primary) 10%, var(--mj-bg-surface));\n  color: var(--mj-brand-primary);\n  border-radius: 10px;\n  font-size: 11px;\n  font-weight: 500;\n}\n\n\n\n.effect-badge[_ngcontent-%COMP%] {\n  display: inline-flex;\n  align-items: center;\n  padding: 2px 8px;\n  border-radius: 10px;\n  font-size: 11px;\n  font-weight: 600;\n  text-transform: uppercase;\n  letter-spacing: 0.3px;\n}\n\n.effect-allow[_ngcontent-%COMP%] {\n  background: var(--mj-status-success-bg);\n  color: var(--mj-status-success-text);\n}\n\n.effect-deny[_ngcontent-%COMP%] {\n  background: var(--mj-status-error-bg);\n  color: var(--mj-status-error-text);\n}"] });
};
PermissionsUserAccessResourceComponent = __decorate([
    RegisterClass(BaseResourceComponent, 'PermissionsUserAccessResource')
], PermissionsUserAccessResourceComponent);
export { PermissionsUserAccessResourceComponent };
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(PermissionsUserAccessResourceComponent, [{
        type: Component,
        args: [{ standalone: false, selector: 'mj-permissions-user-access-resource', template: "<mj-page-layout>\n  <mj-page-header\n    Title=\"User Access Report\"\n    Icon=\"fa-solid fa-user\"\n    Subtitle=\"See every resource a user can access across all registered permission domains\">\n    <div actions>\n      <mj-refresh-button [Loading]=\"IsLoadingUsers\" [Disabled]=\"IsLoadingPermissions\" (Clicked)=\"loadUsers()\"></mj-refresh-button>\n    </div>\n  </mj-page-header>\n\n  <mj-page-body>\n\n  @if (ErrorMessage) {\n    <div class=\"message error-message\">\n      <i class=\"fa-solid fa-circle-exclamation\"></i>\n      <span>{{ ErrorMessage }}</span>\n    </div>\n  }\n\n  <div class=\"selector-row\">\n    <label class=\"selector-label\" for=\"user-select\">User:</label>\n    <select\n      id=\"user-select\"\n      class=\"mj-input\"\n      [ngModel]=\"SelectedUserId\"\n      (ngModelChange)=\"OnUserChanged($event)\"\n      [disabled]=\"IsLoadingUsers || IsLoadingPermissions\"\n    >\n      @for (user of Users; track user.ID) {\n        <option [ngValue]=\"user.ID\">{{ user.Name }}{{ user.Email ? ' \u2014 ' + user.Email : '' }}</option>\n      }\n    </select>\n\n    @if (SelectedUserRoles.length > 0) {\n      <div class=\"roles-badge\" title=\"Roles assigned to this user\">\n        <i class=\"fa-solid fa-user-tag\"></i>\n        <span>{{ SelectedUserRoles.join(', ') }}</span>\n      </div>\n    }\n  </div>\n\n  @if (IsLoadingPermissions) {\n    <mj-loading text=\"Loading permissions...\" size=\"medium\"></mj-loading>\n  } @else if (!SelectedUserId) {\n    <div class=\"empty-state\">\n      <i class=\"fa-solid fa-user-slash\"></i>\n      <p>Select a user above to see their access report.</p>\n    </div>\n  } @else if (DomainGroups.length === 0) {\n    <div class=\"empty-state\">\n      <i class=\"fa-solid fa-folder-open\"></i>\n      <p>This user has no permissions granted in any domain.</p>\n    </div>\n  } @else {\n    <div class=\"total-summary\">\n      <strong>{{ TotalCount }}</strong> permission{{ TotalCount === 1 ? '' : 's' }} across\n      <strong>{{ DomainGroups.length }}</strong> domain{{ DomainGroups.length === 1 ? '' : 's' }}\n    </div>\n\n    <div class=\"domain-groups\">\n      @for (group of DomainGroups; track TrackByDomain($index, group)) {\n        <div class=\"domain-group\" [class.expanded]=\"group.Expanded\">\n          <button type=\"button\" class=\"domain-header\" (click)=\"ToggleGroup(group)\">\n            <div class=\"domain-header-left\">\n              <i [class]=\"group.Icon\" class=\"domain-icon\"></i>\n              <span class=\"domain-name\">{{ group.DomainName }}</span>\n              <span class=\"domain-count\">{{ group.Count }}</span>\n            </div>\n            <i class=\"fa-solid fa-chevron-down toggle-icon\" [class.rotated]=\"group.Expanded\"></i>\n          </button>\n\n          @if (group.Expanded) {\n            <div class=\"domain-body\">\n              <table class=\"perms-table\">\n                <thead>\n                  <tr>\n                    <th>Resource</th>\n                    <th>Type</th>\n                    <th>Actions</th>\n                    <th>Effect</th>\n                  </tr>\n                </thead>\n                <tbody>\n                  @for (row of group.Rows; track TrackByPermission($index, row)) {\n                    <tr>\n                      <td class=\"resource-cell\">\n                        <span class=\"resource-name\">{{ row.ResourceName || row.ResourceID || '\u2014' }}</span>\n                        @if (row.ResourceID && row.ResourceName && row.ResourceName !== row.ResourceID) {\n                          <span class=\"resource-id\">{{ row.ResourceID }}</span>\n                        }\n                      </td>\n                      <td>{{ row.ResourceType }}</td>\n                      <td>\n                        <div class=\"action-chips\">\n                          @for (action of row.Actions; track action) {\n                            <span class=\"action-chip\">{{ action }}</span>\n                          }\n                        </div>\n                      </td>\n                      <td>\n                        <span class=\"effect-badge\" [class.effect-allow]=\"row.Effect === 'Allow'\" [class.effect-deny]=\"row.Effect === 'Deny'\">\n                          {{ row.Effect }}\n                        </span>\n                      </td>\n                    </tr>\n                  }\n                </tbody>\n              </table>\n            </div>\n          }\n        </div>\n      }\n    </div>\n  }\n  </mj-page-body>\n</mj-page-layout>\n", styles: ["/* Tab bar */\n.tab-bar {\n  display: flex;\n  gap: 4px;\n  border-bottom: 1px solid var(--mj-border-default);\n  margin-bottom: 16px;\n}\n\n.tab {\n  background: transparent;\n  border: none;\n  padding: 10px 16px;\n  cursor: pointer;\n  color: var(--mj-text-secondary);\n  font: inherit;\n  font-weight: 500;\n  border-bottom: 2px solid transparent;\n  display: inline-flex;\n  align-items: center;\n  gap: 6px;\n}\n\n.tab:hover {\n  color: var(--mj-text-primary);\n  background: var(--mj-bg-surface-hover);\n}\n\n.tab-active {\n  color: var(--mj-brand-primary);\n  border-bottom-color: var(--mj-brand-primary);\n}\n\n.selector-row.wrap {\n  flex-wrap: wrap;\n}\n\n.mj-input.mono {\n  font-family: var(--mj-font-mono, monospace);\n  min-width: 300px;\n}\n\n.muted {\n  color: var(--mj-text-muted);\n}\n\n/* Messages */\n.message {\n  padding: 10px 14px;\n  border-radius: 6px;\n  margin-bottom: 16px;\n  display: flex;\n  align-items: center;\n  gap: 8px;\n  font-size: 14px;\n}\n\n.error-message {\n  background: var(--mj-status-error-bg);\n  color: var(--mj-status-error-text);\n  border: 1px solid var(--mj-status-error-border);\n}\n\n/* User selector (legacy name kept for User Access tab, plus generic selector-row for Resource tab) */\n.user-selector-row,\n.selector-row {\n  display: flex;\n  align-items: center;\n  gap: 12px;\n  margin-bottom: 20px;\n  flex-wrap: wrap;\n}\n\n.user-selector-label,\n.selector-label {\n  font-weight: 600;\n  color: var(--mj-text-primary);\n}\n\n#user-select,\n#domain-select {\n  min-width: 320px;\n  flex: 0 1 auto;\n}\n\n.roles-badge {\n  display: inline-flex;\n  align-items: center;\n  gap: 6px;\n  padding: 4px 10px;\n  background: color-mix(in srgb, var(--mj-brand-primary) 10%, var(--mj-bg-surface));\n  color: var(--mj-brand-primary);\n  border-radius: 12px;\n  font-size: 12px;\n  font-weight: 500;\n}\n\n/* Empty state */\n.empty-state {\n  text-align: center;\n  padding: 48px 16px;\n  color: var(--mj-text-muted);\n  border: 1px dashed var(--mj-border-default);\n  border-radius: 8px;\n  background: var(--mj-bg-surface-card);\n}\n\n.empty-state i {\n  font-size: 32px;\n  margin-bottom: 12px;\n  display: block;\n}\n\n.empty-state p {\n  margin: 0;\n  font-size: 14px;\n}\n\n.total-summary {\n  color: var(--mj-text-secondary);\n  font-size: 13px;\n  margin-bottom: 12px;\n}\n\n.total-summary strong {\n  color: var(--mj-text-primary);\n}\n\n/* Domain groups */\n.domain-groups {\n  display: flex;\n  flex-direction: column;\n  gap: 8px;\n}\n\n.domain-group {\n  border: 1px solid var(--mj-border-default);\n  border-radius: 8px;\n  overflow: hidden;\n  background: var(--mj-bg-surface);\n}\n\n.domain-header {\n  width: 100%;\n  display: flex;\n  align-items: center;\n  justify-content: space-between;\n  padding: 12px 16px;\n  background: var(--mj-bg-surface-card);\n  border: none;\n  cursor: pointer;\n  text-align: left;\n  color: var(--mj-text-primary);\n  font: inherit;\n}\n\n.domain-header:hover {\n  background: var(--mj-bg-surface-hover);\n}\n\n.domain-header-left {\n  display: flex;\n  align-items: center;\n  gap: 10px;\n}\n\n.domain-icon {\n  color: var(--mj-brand-primary);\n  font-size: 16px;\n}\n\n.domain-name {\n  font-weight: 600;\n  font-size: 15px;\n}\n\n.domain-count {\n  display: inline-flex;\n  align-items: center;\n  justify-content: center;\n  min-width: 24px;\n  height: 20px;\n  padding: 0 8px;\n  background: var(--mj-brand-primary);\n  color: var(--mj-text-inverse);\n  border-radius: 10px;\n  font-size: 12px;\n  font-weight: 600;\n}\n\n.toggle-icon {\n  transition: transform 0.15s ease;\n  color: var(--mj-text-muted);\n}\n\n.toggle-icon.rotated {\n  transform: rotate(180deg);\n}\n\n.domain-body {\n  padding: 0;\n  background: var(--mj-bg-surface);\n  overflow-x: auto;\n}\n\n/* Permissions table */\n.perms-table {\n  width: 100%;\n  border-collapse: collapse;\n  font-size: 13px;\n}\n\n.perms-table th,\n.perms-table td {\n  padding: 8px 16px;\n  text-align: left;\n  border-bottom: 1px solid var(--mj-border-subtle);\n  vertical-align: top;\n}\n\n.perms-table th {\n  background: var(--mj-bg-surface-sunken);\n  color: var(--mj-text-secondary);\n  font-weight: 600;\n  text-transform: uppercase;\n  font-size: 11px;\n  letter-spacing: 0.5px;\n}\n\n.perms-table tbody tr:last-child td {\n  border-bottom: none;\n}\n\n.perms-table tbody tr:hover {\n  background: var(--mj-bg-surface-hover);\n}\n\n.resource-cell {\n  display: flex;\n  flex-direction: column;\n  gap: 2px;\n}\n\n.resource-name {\n  color: var(--mj-text-primary);\n  font-weight: 500;\n}\n\n.resource-id {\n  color: var(--mj-text-muted);\n  font-size: 11px;\n  font-family: var(--mj-font-mono, monospace);\n}\n\n/* Action chips */\n.action-chips {\n  display: flex;\n  flex-wrap: wrap;\n  gap: 4px;\n}\n\n.action-chip {\n  display: inline-flex;\n  align-items: center;\n  padding: 2px 8px;\n  background: color-mix(in srgb, var(--mj-brand-primary) 10%, var(--mj-bg-surface));\n  color: var(--mj-brand-primary);\n  border-radius: 10px;\n  font-size: 11px;\n  font-weight: 500;\n}\n\n/* Effect badge */\n.effect-badge {\n  display: inline-flex;\n  align-items: center;\n  padding: 2px 8px;\n  border-radius: 10px;\n  font-size: 11px;\n  font-weight: 600;\n  text-transform: uppercase;\n  letter-spacing: 0.3px;\n}\n\n.effect-allow {\n  background: var(--mj-status-success-bg);\n  color: var(--mj-status-success-text);\n}\n\n.effect-deny {\n  background: var(--mj-status-error-bg);\n  color: var(--mj-status-error-text);\n}\n"] }]
    }], () => [{ type: i0.ChangeDetectorRef }], null); })();
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(PermissionsUserAccessResourceComponent, { className: "PermissionsUserAccessResourceComponent", filePath: "src/Permissions/user-access-resource.component.ts", lineNumber: 27 }); })();
/** Tree-shaking prevention — referenced from `public-api.ts`. */
export function LoadPermissionsUserAccessResource() {
    // intentionally empty
}
//# sourceMappingURL=user-access-resource.component.js.map