import{a as ut}from"./chunk-I5K7GPAI.js";import{a as mt,b as pt,c as gt}from"./chunk-VQU52MNH.js";import{a as ct,b as dt}from"./chunk-MXSLISEG.js";import{a as x}from"./chunk-7GYHTWED.js";import{d as st,e as lt}from"./chunk-5KCUTXXV.js";import{B as q,Bb as ot,Db as at,H as W,Ob as rt,Rb as C,s as H,v as $,wb as nt,y as Y}from"./chunk-YSQLW2JA.js";import{Fa as Q,Ga as J,Ha as N,Ia as tt,S,Sa as et,db as it,ee as y}from"./chunk-NVJ2ZZFT.js";import{$c as F,Aa as u,Ba as h,Gg as X,Hb as k,He as D,Nc as f,Pd as M,Qf as z,Rd as L,Sd as B,Se as G,Te as b,Ue as V,Yg as K,Zf as j,_a as A,ab as I,af as Z,bb as U,dd as T,fb as w,gb as _,ha as g,hd as m,ic as O,mg as R,va as P,wa as p,ya as v}from"./chunk-SKPDQO4E.js";var ht=`<div class="modal-header">
  <span class="text-lg">{{( hasOrganizationUnitDetailed ? currentOrganizationUnitDetailed.name :
    'ORGANIZATIONUNIT.TITLE_NEW_ORGANIZATION_UNIT' ) | translate }}</span>
</div>

<div class="modal-body mhs-25">
  <nz-tabset [nzAnimated]="false" *ngIf="visibleComponent">
    <nz-tab nzTitle="{{'ORGANIZATIONUNIT.TITLE_BASIC_INFO'|translate}}">
      <form [formGroup]="organizationUnitForm">
        <div class="row mx-0 mhs-15 align-content-start">
          <div class="col-12">
            <div class="form-group">
              <label for="name-input">{{'ORGANIZATIONUNIT.NAME' | translate}}</label>
              <input type="text" id="name-input" formControlName="name" maxlength="255"
                [ngClass]="{'is-invalid': organizationUnitForm.get('name').touched && organizationUnitForm.get('name').invalid}"
                class="form-control form-control-sm">
              <ng-template
                *ngTemplateOutlet="controlValidationTemplate; context: {$implicit: organizationUnitForm, control:organizationUnitForm.get('name')}">
              </ng-template>
            </div>
          </div>
          <div class="col-md-6 col-12">
            <div class="form-group">
              <label for="type-input">{{'ORGANIZATIONUNIT.TYPE' | translate}}</label>
              <armon-user-defined-list-input [type]="6" formControlName="typeId">
              </armon-user-defined-list-input>
              <ng-template
                *ngTemplateOutlet="controlValidationTemplate; context: {$implicit: organizationUnitForm, control:organizationUnitForm.get('typeId')}">
              </ng-template>
            </div>
          </div>
          <div class="col-md-6 col-12">
            <div class="form-group">
              <label for="shortcode-input">{{'ORGANIZATIONUNIT.SHORTCODE' | translate}}</label>
              <input type="text" id="shortcode-input" formControlName="shortCode" maxlength="128"
                [ngClass]="{'is-invalid': organizationUnitForm.get('shortCode').touched && organizationUnitForm.get('shortCode').invalid}"
                class="form-control form-control-sm">
              <ng-template
                *ngTemplateOutlet="controlValidationTemplate; context: {$implicit: organizationUnitForm, control:organizationUnitForm.get('shortCode')}">
              </ng-template>
            </div>
          </div>
          <div class="col-md-6 col-12">
            <div class="form-group">
              <label for="identity-input">{{'ORGANIZATIONUNIT.MANAGER' | translate}}</label>
              <armon-select-search query="identity" [allowMulti]="false" formControlName="managerUserId"
                [invalid]="organizationUnitForm.get('managerUserId').touched && organizationUnitForm.get('managerUserId').invalid"
                [allowClear]="true" [placeholder]="'COMMON.SELECT_ONE'|translate">
              </armon-select-search>
              <ng-template
                *ngTemplateOutlet="controlValidationTemplate; context: {$implicit: organizationUnitForm, control:organizationUnitForm.get('managerUserId')}">
              </ng-template>
            </div>
          </div>
          <div class="col-md-6 col-12">
            <div class="form-group">
              <label for="identity-input">{{'ORGANIZATIONUNIT.TITLE_PARENT_SELECTION' | translate}}</label>
              <armon-select-search query="unit" [allowMulti]="false" formControlName="parentId"
                [invalid]="organizationUnitForm.get('parentId').touched && organizationUnitForm.get('parentId').invalid"
                (onSelectedChanged)="onParentOrganizationUnitSelected($event)" [allowClear]="true"
                [placeholder]="'ORGANIZATIONUNIT.ROOT_OF_HIERARCHY'|translate">
              </armon-select-search>
              <ng-template
                *ngTemplateOutlet="controlValidationTemplate; context: {$implicit: organizationUnitForm, control:organizationUnitForm.get('parentId')}">
              </ng-template>
            </div>
          </div>
          <!-- <pre>{{organizationUnitForm.value|json}}</pre> -->
        </div>
      </form>
    </nz-tab>
    <nz-tab nzTitle="{{'ORGANIZATIONUNIT.TITLE_DEFAULT_ACCESSCONTROLPOINTS' | translate}}">
      <div class="row mhs-20 mxh-vh-70">
        <div class="col-12">
          <armon-access-control-point-search #searchAccessControlPoint [multiselect]="true" [hideChips]="true"
            [grant]="true" (itemSelected)="onAccessControlPointSelected($event)"
            (itemRemoved)="onAccessControlPointRemoved($event)">
          </armon-access-control-point-search>
        </div>
        <div class="col-12" *ngFor="let accessRight of currentIdentityAccessRights">
          <armon-identity-access-right #identityAccessRight [accessRight]="accessRight"
            (accessRightRemoved)="onAccessRightRemoved($event)" (accessRightUpdated)="onAccessRightUpdated($event)"
            [visibleFooter]="true"></armon-identity-access-right>
        </div>
      </div>
    </nz-tab>
    <nz-tab nzTitle="{{'ORGANIZATIONUNIT.TITLE_ORG_CUSTOM_SETTINGS' | translate}}" *ngIf="organizationSettingsForm">
      <div class="row mhs-20">
        <div class="col-12 px-4">
          <df-form [formData]="organizationSettingsForm" #dfForm (formInitialized)="onDynamicFormInitialized($event)">
          </df-form>
        </div>
      </div>
    </nz-tab>
  </nz-tabset>
</div>

<div class="modal-footer">
  <button class="btn btn-outline-primary" (click)="onCancelClicked($event)">{{'BUTTON.CANCEL' | translate}}</button>
  <button class="btn btn-success" (click)="onSaveClicked($event)"
    [disabled]="organizationUnitForm.invalid || ((dfForm && dfForm.form)?dfForm.form.invalid:false)">{{'BUTTON.SAVE' |
    translate}}</button>
</div>

<!-- FORM FIELD VALIDATION -->
<ng-template #controlValidationTemplate let-form let-control="control">
  <ng-container *ngIf="control.errors">
    <div class="invalid-feedback d-flex flex-column" style="display: initial;">
      <span *ngIf="control.errors.required">{{'VALIDATION.REQUIRED'|translate}}</span>
      <span *ngIf="control.errors.numeric">{{'VALIDATION.POSITIVE_NUMBER'|translate}}</span>
      <span *ngIf="control.errors.max">{{'VALIDATION.MAX_VALUE'|translate:control.errors.max}}</span>
      <span *ngIf="control.errors.maxlength">{{'VALIDATION.MAX_LENGTH'|translate: {
        max:control.errors.maxlength.requiredLength} }}</span>
      <span *ngIf="control.errors.min">{{'VALIDATION.MIN_VALUE'|translate:control.errors.min}}</span>
      <span *ngIf="control.errors.minlength">{{'VALIDATION.MIN_LENGTH'|translate: {
        min:control.errors.minlength.requiredLength} }}</span>
    </div>
  </ng-container>
</ng-template>`;var ft=`.justify-content-center{-webkit-box-pack:center;-moz-box-pack:center;-webkit-flex-pack:center;-ms-flex-pack:center;-moz-justify-content:center;-webkit-justify-content:center;justify-content:center}.justify-content-flex-end{-webkit-box-pack:end;-moz-box-pack:end;-webkit-flex-pack:end;-ms-flex-pack:end;-moz-justify-content:flex-end;-webkit-justify-content:flex-end;justify-content:flex-end}.card-footer{padding:.28rem .7rem}.alert{font-size:.756rem}@media screen and (min-width: 992px){.modal-xxl{max-width:1640px}}@media screen and (min-width: 1200px){.modal-xxxl{max-width:1860px}}.modal-fs{max-width:none;position:absolute;margin:auto;inset:16px;height:100vh;display:flex}.btn-link{text-decoration:none}.btn-link:hover{text-decoration:underline}.invalid-feedback{margin-top:0!important;font-size:.672rem!important}.form-layout{width:100%!important;display:-webkit-box;display:-moz-box;display:-webkit-flexbox;display:-ms-flexbox;display:-webkit-flex;display:flex;-webkit-box-orient:horizontal;-moz-box-orient:horizontal;-webkit-flex-direction:row;-moz-flex-direction:row;-ms-flex-direction:row;flex-direction:row;-webkit-box-pack:start;-moz-box-pack:start;-webkit-flex-pack:start;-ms-flex-pack:start;-moz-justify-content:flex-start;-webkit-justify-content:flex-start;justify-content:flex-start;-webkit-flex-wrap:wrap;-moz-flex-wrap:wrap;flex-wrap:wrap;margin-bottom:6px;padding-left:0}.form-layout>label:not(.custom-item){width:auto;margin-right:12px;position:relative!important;margin:0rem;min-width:130px}@media screen and (max-width: 576px){.form-layout>label:not(.custom-item){width:100%;margin-right:0;margin-bottom:0}}.form-layout>label[unit]{margin-left:3px;position:relative!important}@media screen and (max-width: 576px){.form-layout>label[unit]{flex:0}}.form-layout input{margin:0;flex:1}.form-layout .select{flex:1}.form-layout textarea{flex:1;margin-right:0}.form-layout .form-item,.form-layout .checkbox,.form-layout .custom-item{flex:1}.form-layout .radio-inline-container{position:relative}.form-layout .form-button{margin:0 0 0 12px}.chips{padding-top:24px}.chips>span{margin:4px}.chips cds-icon{cursor:pointer}.label>cds-icon{cursor:pointer}
`;var d;(function(s){s[s.Add=0]="Add",s[s.Remove=1]="Remove"})(d||(d={}));var Tt=function(s,t,e,n){var o=arguments.length,i=o<3?t:n===null?n=Object.getOwnPropertyDescriptor(t,e):n,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(s,t,e,n);else for(var c=s.length-1;c>=0;c--)(r=s[c])&&(i=(o<3?r(i):o>3?r(t,e,i):r(t,e))||i);return o>3&&i&&Object.defineProperty(t,e,i),i},E=class extends B{organizationUnitService;accessControlPointService;formBuilder;interactionService;dfDynamicFormService;sessionService;organizationUnit;parentOrganizationUnit;currentOrganizationUnitDetailed;currentOrganizationUnitBasic;currentAccessControlPoints=[];currentAccessControlPointActions=[];organizationUnitForm;organizationUnitFields=[];currentIdentityAccessRights=[];visibleComponent=!1;accessControlPointSearchbar;identityAccessRights;dfForm;organizationSettingsForm;constructor(t,e,n,o,i,r){super(),this.organizationUnitService=t,this.accessControlPointService=e,this.formBuilder=n,this.interactionService=o,this.dfDynamicFormService=i,this.sessionService=r}onModalInitialized(){super.onModalInitialized(),this.sessionService.currentOrganization.organizationUnitDynamicForm?(this.organizationSettingsForm=this.dfDynamicFormService.getFormUserDynamicContent(this.sessionService.currentOrganization.organizationUnitDynamicForm),this.organizationSettingsForm.uiType=mt.Minimalist):this.organizationSettingsForm=null,this.setOrganizationUnitData(),this.initializeForms()}get hasOrganizationUnitDetailed(){return this.currentOrganizationUnitDetailed!==null&&this.currentOrganizationUnitDetailed!==void 0}onAccessControlPointSelected(t){this.addAccessControlPoint(t)}onAccessControlPointRemoved(t){this.removeAccessControlPoint(t.id)}onRemoveAccessControlPointClicked(t){this.removeAccessControlPoint(t.id)}onParentOrganizationUnitSelected(t){this.organizationUnitService.getOrganizationUnitBasic(t.optionValue).subscribe(e=>{this.currentOrganizationUnitBasic&&e&&e.id===this.currentOrganizationUnitBasic.id?(this.interactionService.showMessage("ORGANIZATIONUNIT.ERROR_INVALID_PARENT_OWN",null,f.Error),this.organizationUnitForm.controls.parentId.setValue(null)):this.currentOrganizationUnitBasic&&e&&e.ancestorIds&&e.ancestorIds.indexOf(this.currentOrganizationUnitBasic.id)>=0&&(this.interactionService.showMessage("ORGANIZATIONUNIT.ERROR_INVALID_PARENT_HIERARCHICAL",null,f.Error,this.currentOrganizationUnitBasic),this.organizationUnitForm.controls.parentId.setValue(null))})}onSaveClicked(t){let e=new tt;e.name=this.organizationUnitForm.value.name,e.typeId=this.organizationUnitForm.value.typeId,e.shortCode=this.organizationUnitForm.value.shortCode,e.id=this.currentOrganizationUnitBasic?this.currentOrganizationUnitBasic.id:null,e.parentId=this.organizationUnitForm.value.parentId,e.managerUserId=this.organizationUnitForm.value.managerUserId,this.organizationSettingsForm&&this.dfForm.form.value&&(e.dynamicFormId=this.sessionService.currentOrganization.organizationUnitDynamicForm.id,e.dynamicFormData=this.dfForm.form.value),this.organizationUnitService.upsertOrganizationUnit(e).subscribe(n=>{e.id=n.id,this.currentAccessControlPointActions&&this.currentAccessControlPointActions.length>0?this.currentOrganizationUnitBasic?this.approveForApplyToMembers(n.id,e):this.upsertDefaultAccessControlPoints(n.id,!1,!1,e):this.closeModal(e)})}initializeForms(){this.organizationUnitForm=this.formBuilder.group({name:[null,D.required],typeId:[null,D.required],shortCode:[null],managerUserId:[this.currentOrganizationUnitBasic&&this.currentOrganizationUnitBasic.manager?this.currentOrganizationUnitBasic.manager.id:null],parentId:[this.parentOrganizationUnit?this.parentOrganizationUnit.id:null]}),setTimeout(()=>{this.visibleComponent=!0,setTimeout(()=>{this.accessControlPointSearchbar.setSelection(this.currentAccessControlPoints.map(t=>new X(t.id,t.name)))},600)},300)}checkPermissions(){let t=[];this.currentOrganizationUnitBasic&&(t=this.currentOrganizationUnitBasic.ancestorIds||[],t.push(this.currentOrganizationUnitBasic.id))}setOrganizationUnitData(){this.currentOrganizationUnitBasic=this.organizationUnit,this.checkPermissions(),this.organizationUnit&&this.organizationUnit.id&&this.getOrganizationUnitDetails(this.organizationUnit.id)}getOrganizationUnitDetails(t){this.organizationUnitService.getOrganizationUnitDetails(t).subscribe(e=>{this.currentOrganizationUnitDetailed=e,this.currentOrganizationUnitDetailed.parent&&this.organizationUnitForm.get("parentId").setValue(this.currentOrganizationUnitDetailed.parent.id),this.setFields()})}getAccessRight(t){let e=new et;return e.accessControlPointId=t.id,e.accessControlPointIsRemoteDefault=t.isRemoteDefault||!1,e.accessControlPointName=t.name,e.accessControlPointRemoteAvailable=t.remoteAvailable||!1,e.managable=!0,e.access=t.defaultPrivileges.access,e.config=t.defaultPrivileges.config,e.read=t.defaultPrivileges.read,e.grant=t.defaultPrivileges.grant,e.remoteAccess=t.defaultPrivileges.remoteAccess,e.snapshot=t.defaultPrivileges.snapshot,e.userRights=t.userRights,e}setFields(){this.organizationUnitForm.patchValue(this.currentOrganizationUnitDetailed),this.currentAccessControlPoints=this.currentOrganizationUnitDetailed.defaultAccessControlPoints||[],this.currentAccessControlPoints.forEach(t=>{this.currentIdentityAccessRights.push(this.getAccessRight(t))})}addAccessControlPoint(t){this.accessControlPointService.getAccessControlPointBasic(t.id).subscribe(e=>{this.currentAccessControlPoints.push(e),this.currentIdentityAccessRights.unshift(this.getAccessRight(e)),this.addAction(e.id,d.Add)})}removeAccessControlPoint(t){O(this.currentAccessControlPoints,"id",t),O(this.currentIdentityAccessRights,"accessControlPointId",t),this.accessControlPointSearchbar.removeSelection(t),this.addAction(t,d.Remove)}addAction(t,e){if(this.currentAccessControlPointActions.findIndex(n=>n.accessControlPointId==t&&n.action==e)==-1&&!O(this.currentAccessControlPointActions,"accessControlPointId",t)){let o=new J;o.accessControlPointId=t,o.action=e,this.currentAccessControlPointActions.push(o)}}upsertDefaultAccessControlPoints(t,e,n,o){let i=new Q;i.applyToMembers=e,i.applyHierarchically=n;let r=this.currentAccessControlPointActions?this.currentAccessControlPointActions.filter(a=>a.action===d.Add).map(a=>a.accessControlPointId):[],c=[];this.identityAccessRights.forEach(a=>{c.push(a.getAccessRight())}),i.addedAccessControlPoints=[],c.forEach(a=>{if(r.findIndex(l=>l==a.accessControlPointId)!=-1){let l=new S;l.access=a.access,l.grant=a.grant,l.read=a.read,l.config=a.config,l.remoteAccess=a.remoteAccess,l.snapshot=a.snapshot,l.id=a.accessControlPointId,i.addedAccessControlPoints.push(l)}}),i.removedAccessControlPointIds=this.currentAccessControlPointActions?this.currentAccessControlPointActions.filter(a=>a.action===d.Remove).map(a=>a.accessControlPointId):[],this.organizationUnitService.upsertOrganizationUnitDefaultAccessControlPoints(t,i).subscribe(()=>{this.closeModal(o)})}approveForApplyToMembers(t,e){this.interactionService.showDialog("ORGANIZATIONUNIT.TITLE_DEFAULT_ACCESSCONTROLPOINTS","ORGANIZATIONUNIT.APPROVE_APPLY_TO_MEMBERS",null,null,!0,"BUTTON.YES","BUTTON.NO",!1,()=>{this.approveForApplyHierarchically(t,!0,e)},()=>{this.approveForApplyHierarchically(t,!1,e)})}approveForApplyHierarchically(t,e,n){this.interactionService.showDialog("ORGANIZATIONUNIT.TITLE_DEFAULT_ACCESSCONTROLPOINTS","ORGANIZATIONUNIT.APPROVE_APPLY_HIERARCHICALLY",null,null,!0,"BUTTON.YES","BUTTON.NO",!1,()=>{this.upsertDefaultAccessControlPoints(t,e,!0,n)},()=>{this.upsertDefaultAccessControlPoints(t,e,!1,n)})}onAccessRightRemoved(t){this.removeAccessControlPoint(t)}onAccessRightUpdated(t){this.addAction(t.accessControlPointId,d.Add)}onDynamicFormInitialized(t){this.organizationSettingsForm&&this.currentOrganizationUnitDetailed.dynamicFormData&&(this.dfForm.form.setValue(this.currentOrganizationUnitDetailed.dynamicFormData),this.dfForm.form.updateValueAndValidity())}static ctorParameters=()=>[{type:y},{type:C},{type:G},{type:z},{type:pt},{type:M}];static propDecorators={organizationUnit:[{type:u}],parentOrganizationUnit:[{type:u}],accessControlPointSearchbar:[{type:p,args:["searchAccessControlPoint",{static:!1}]}],identityAccessRights:[{type:P,args:["identityAccessRight"]}],dfForm:[{type:p,args:["dfForm",{static:!1}]}]}};E=Tt([v({selector:"armon-organization-unit-modal",template:ht,standalone:!0,imports:[U,at,b,V,R,A,_,lt,nt,ot,I,x,gt,T],styles:[ft]})],E);var vt=`<div class="card mb-3" [ngClass]="{'clickable hover-secondary': toggleClickable}">

  <div class="position-relative card-body p-4 mhs-12" (mouseover)="onMouseOverBasicInfo($event)"
    (mouseout)="onMouseOutBasicInfo($event)" (click)="onShowChildrenRequested($event)">

    <cds-icon shape="search" *ngIf="organizationUnit.selected" class="position-absolute color-gray cds-icon-42"
      style="right: 12px; bottom: 12px;"></cds-icon>

    <div class="d-flex flex-column mb-3">
      <span class="text-lg pe-5">{{organizationUnit.name}}</span>
      <span *ngIf="organizationUnit.shortCode" nz-tooltip nzTooltipTitle="{{'ORGANIZATIONUNIT.SHORTCODE' | translate}}"
        style="width: fit-content;" class="text-sm fw-bold text-primary">{{organizationUnit.shortCode}}</span>
    </div>

    <div class="row">
      <div class="d-flex col-sm-6" *ngIf="organizationUnit.manager">

        <div class="d-flex justify-content-center align-items-center me-2 color-gray rounded-circle bg-body-secondary"
          style="width: 32px; height: 32px;">
          <cds-icon shape="user" solid [ngClass]="{'has-badge': organizationUnit.deputyOnDuty}" size="md">
          </cds-icon>
        </div>

        <div class="d-flex flex-column">
          <span class="text-md">{{'ORGANIZATIONUNIT.MANAGER' | translate}}</span>
          <span class="text-sm">{{organizationUnit.manager.fullname}}</span>
        </div>

      </div>

      <div class="d-flex col-sm-6" *ngIf="organizationUnit.deputy">

        <div class="d-flex justify-content-center align-items-center me-2 color-gray rounded-circle bg-body-secondary"
          style="width: 32px; height: 32px;">
          <cds-icon shape="user" [ngClass]="{'has-badge--success': organizationUnit.deputyOnDuty}" size="md"></cds-icon>
        </div>

        <div class="d-flex flex-column">
          <span class="text-md">{{'ORGANIZATIONUNIT.DEPUTY' | translate}}</span>
          <span class="text-sm">{{organizationUnit.deputy.fullname}}</span>
        </div>

      </div>
    </div>

    <div class="position-absolute rounded-bottom-1 text-sm fw-medium color-white px-2 py-1 shadow-box-1"
      [ngStyle]="{'background-color': organizationUnit.typeDefinition.color, 'right': '16px', 'top': '0px'}">
      {{organizationUnit.typeDefinition | languageTranslate}}
    </div>

  </div>

  <div class="card-footer px-2 py-3" *ngIf="visibleButtons.length > 0">

    <button class="btn btn-sm btn-link" *ngFor="let button of visibleButtons"
      (click)="onFooterButtonClicked($event, button.event)">{{button.text | translate :
      languageService.userTranslate}}</button>

    <button nz-dropdown [nzDropdownMenu]="menuSub" class="btn btn-link btn-sm me-2" *ngIf="hiddenButtons.length > 0"
      [nzClickHide]="true">
      <cds-icon shape="ellipsis-horizontal"></cds-icon>
    </button>
    <nz-dropdown-menu #menuSub="nzDropdownMenu">
      <ul nz-menu>
        <li nz-menu-item *ngFor="let button of hiddenButtons" (click)="onFooterButtonClicked($event, button.event)">
          {{button.text | translate : languageService.userTranslate}}</li>
      </ul>
    </nz-dropdown-menu>

  </div>

</div>

<ng-template #applySessionModalTemplate let-modal>
  <div class="modal-header">
    {{organizationUnit.name}}
  </div>
  <div class="modal-body">
    <ng-container *ngIf="addedCount>0">
      <div class="row mb-2">
        <div class="col-12">
          <cds-icon shape="users" class="me-2 cds-icon-20 text-success"></cds-icon>
          <span class="text-md text-success fw-medium">{{'IDENTITY.SELECTION_HEADER_ADDED' |
            translate:languageService.userTranslate}} ({{addedCount}})</span>
        </div>
      </div>
      <div class="row">
        <div class="col-12">
          <span class="text-md">{{'ORGANIZATIONUNIT.ADDED_USERS_ROLE'|translate:languageService.userTranslate}}</span>
        </div>
      </div>
      <div class="row">
        <div class="col-12">
          <label>{{'IDENTITY.ROLE' | translate}}</label>
          <select [(ngModel)]="selectedRole" class="form-select form-select-sm">
            <option *ngFor="let selectableUnitRole of selectableUnitRoles" [ngValue]="selectableUnitRole">
              {{selectableUnitRole.name | translate}}</option>
          </select>
        </div>
      </div>
      <ng-container *ngIf="currentIdentityAccessRights && currentIdentityAccessRights.length>0">
        <div class="row mt-3">
          <div class="col-12">
            <span>{{'ORGANIZATIONUNIT.ACP_DAFAULT_PERMISSIONS_ASK'|translate:languageService.userTranslate}}</span>
          </div>
        </div>
        <div class="row">
          <div class="col-12">
            <div class="form-group mb-0">
              <div class="form-check form-check-inline">
                <input type="checkbox" id="addAccessRightsCheck" [(ngModel)]="addAccessRights" class="form-check-input">
                <label class="form-check-label"
                  for="addAccessRightsCheck">{{'ORGANIZATIONUNIT.ACP_DAFAULT_PERMISSIONS_SELECTION' |
                  translate}}</label>
              </div>
            </div>
          </div>
          <div class="col-12 position-relative">
            <div class="row py-1" style="max-height: 30vh; overflow-y: auto;">
              <div class="col-12" *ngFor="let accessRight of currentIdentityAccessRights">
                <armon-identity-access-right #identityAccessRight [accessRight]="accessRight"
                  (accessRightUpdated)="onAccessRightUpdated($event)" [visibleFooter]="false">
                </armon-identity-access-right>
              </div>
            </div>
            <div class="disabled-overlay" *ngIf="!addAccessRights"></div>
          </div>
        </div>
        <div class="row mb-4">
          <div class="col-12">
            <div class="form-group">
              <label class="mb-2">{{'ACCESSCONTROLPOINT.APPLY_USERS_METHOD' |
                translate:languageService.userTranslate}}</label>
              <div class="form-check">
                <input class="form-check-input" id="expand-current" type="radio" name="expand-current"
                  [(ngModel)]="selectedScope" [value]="1" [disabled]="!addAccessRights">
                <label class="form-check-label" for="expand-current">
                  {{'ACCESSCONTROLPOINT.APPLY_USERS_METHOD_EXPAND_CURRENT'|translate}}
                </label>
              </div>
              <div class="form-check">
                <input class="form-check-input" id="ignore-current" type="radio" name="ignore-current"
                  [(ngModel)]="selectedScope" [value]="2" [disabled]="!addAccessRights">
                <label class="form-check-label" for="ignore-current">
                  {{'ACCESSCONTROLPOINT.APPLY_USERS_METHOD_IGNORE_CURRENT'|translate}}
                </label>
              </div>
              <div class="form-check">
                <input class="form-check-input" id="override-current" type="radio" name="override-current"
                  [(ngModel)]="selectedScope" [value]="3" [disabled]="!addAccessRights">
                <label class="form-check-label" for="override-current">
                  {{'ACCESSCONTROLPOINT.APPLY_USERS_METHOD_OVERRIDE_CURRENT'|translate}}
                </label>
              </div>
            </div>
          </div>
        </div>
      </ng-container>
    </ng-container>
    <ng-continer *ngIf="removedCount>0">
      <div class="row mb-2">
        <div class="col-12">
          <cds-icon shape="users" class="me-2 cds-icon-20 text-danger"></cds-icon>
          <span class="text-md text-danger fw-medium">{{'IDENTITY.SELECTION_HEADER_REMOVED' |
            translate:languageService.userTranslate}} ({{removedCount}})</span>
        </div>
      </div>
      <div class="row">
        <div class="col-12">
          <div class="form-group mb-0">
            <div class="form-check form-check-inline">
              <input type="checkbox" id="removeDefaultAccessRights" [(ngModel)]="removeDefaultAccessRights"
                class="form-check-input">
              <label class="form-check-label"
                for="removeDefaultAccessRights">{{'ORGANIZATIONUNIT.ACP_REMOVE_PERMISSIONS_SELECTION' |
                translate}}</label>
            </div>
          </div>
        </div>
      </div>
    </ng-continer>
  </div>
  <div class="modal-footer">
    <button class="btn btn-outline-primary me-2" (click)="modal.dismiss()">{{'BUTTON.CANCEL' |
      translate}}</button>
    <button class="btn btn-primary" (click)="modal.close()">{{'BUTTON.SAVE' | translate}}
    </button>
  </div>
</ng-template>

<ng-template #deleteUnitModalTemplate let-modal>
  <div class="modal-header">
    {{organizationUnit.name}}
  </div>
  <div class="modal-body">
    <div class="row mb-4">
      <div class="col-12">
        <span class="text-md">{{'ORGANIZATIONUNIT.APPROVE_FOR_DELETE'|translate}}</span>
      </div>
    </div>
    <div class="row">
      <div class="col-12">
        <div class="form-group">
          <label class="text-md my-3">{{'ORGANIZATIONUNIT.DELETE_ACTION' |
            translate}}</label>

          <div class="form-check mb-3">
            <input class="form-check-input" id="ignore-current" type="radio" name="ignore-current"
              [(ngModel)]="deleteActionSelection" [value]="removeOrganizationUnitAction.RemoveAccessRights">
            <label class="form-check-label" for="ignore-current">
              {{'ORGANIZATIONUNIT.DELETE_ACTIVE_USERS_REMOVE_ACPS'|translate}}
            </label>
          </div>
          <div class="form-check mb-3">
            <input class="form-check-input" id="override-current" type="radio" name="override-current"
              [(ngModel)]="deleteActionSelection" [value]="removeOrganizationUnitAction.None">
            <label class="form-check-label" for="override-current">
              {{'ORGANIZATIONUNIT.DELETE_ACTIVE_USERS'|translate}}
            </label>
          </div>
          <div class="form-check">
            <input class="form-check-input" id="delete-selection-passive" type="radio" name="expand-current"
              [(ngModel)]="deleteActionSelection" [value]="removeOrganizationUnitAction.MakeUsersPassive">
            <label class="form-check-label line-height-sm" for="delete-selection-passive">
              {{'ORGANIZATIONUNIT.DELETE_PASSIVE_USERS'|translate}}<br>
              <span
                class="text-xs color-gray-darkest text-italic">{{'ORGANIZATIONUNIT.DELETE_PASSIVE_USERS_DURATION'|translate}}</span>
            </label>
          </div>
        </div>
      </div>
    </div>
  </div>
  <div class="modal-footer">
    <button class="btn btn-outline-primary me-2" (click)="modal.dismiss()">{{'BUTTON.CANCEL' |
      translate}}</button>
    <button class="btn btn-danger" (click)="modal.close()">{{'BUTTON.DELETE' | translate}}
    </button>
  </div>
</ng-template>`;var At=`.card-footer{padding:.28rem .7rem}.alert{font-size:.756rem}@media screen and (min-width: 992px){.modal-xxl{max-width:1640px}}@media screen and (min-width: 1200px){.modal-xxxl{max-width:1860px}}.modal-fs{max-width:none;position:absolute;margin:auto;inset:16px;height:100vh;display:flex}.btn-link{text-decoration:none}.btn-link:hover{text-decoration:underline}.invalid-feedback{margin-top:0!important;font-size:.672rem!important}.justify-content-center{-webkit-box-pack:center;-moz-box-pack:center;-webkit-flex-pack:center;-ms-flex-pack:center;-moz-justify-content:center;-webkit-justify-content:center;justify-content:center}.justify-content-flex-end{-webkit-box-pack:end;-moz-box-pack:end;-webkit-flex-pack:end;-ms-flex-pack:end;-moz-justify-content:flex-end;-webkit-justify-content:flex-end;justify-content:flex-end}.clickable{cursor:pointer}.disabled-overlay{position:absolute;margin:auto;inset:0;cursor:default;background-color:#ffffffb3;z-index:1}
`;var Rt=function(s,t,e,n){var o=arguments.length,i=o<3?t:n===null?n=Object.getOwnPropertyDescriptor(t,e):n,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(s,t,e,n);else for(var c=s.length-1;c>=0;c--)(r=s[c])&&(i=(o<3?r(i):o>3?r(t,e,i):r(t,e))||i);return o>3&&i&&Object.defineProperty(t,e,i),i},It=class extends ut{router;interactionService;organizationUnitService;languageService;identitySelectionService;roleService;accessControlPointService;modalService;authService;organizationUnit;showChildrenRequested=new g;organizationUnitUpdated=new g;organizationUsersUpdated=new g;organizationUnitDeleted=new g;applySessionModalTemplate;deleteUnitModalTemplate;deleteActionSelection=N.RemoveAccessRights;addAccessRights=!0;currentIdentityAccessRights=[];selectedScope=j.InsertNewExpandCurrent;removeDefaultAccessRights=!0;addedCount=0;removedCount=0;get removeOrganizationUnitAction(){return N}toggleClickable;permissionShowChildren;selectableUnitRoles;selectedRole;constructor(t,e,n,o,i,r,c,a,l){super(l),this.router=t,this.interactionService=e,this.organizationUnitService=n,this.languageService=o,this.identitySelectionService=i,this.roleService=r,this.accessControlPointService=c,this.modalService=a,this.authService=l}ngOnInit(){this.initializeButtons(),this.checkPermissions()}onShowChildrenRequested(t){this.organizationUnit&&this.permissionShowChildren&&this.showChildrenRequested.emit(this.organizationUnit)}onMouseOverBasicInfo(t){this.toggleClickable=this.permissionShowChildren}onMouseOutBasicInfo(t){this.toggleClickable=!1}initializeButtons(){let t=this.organizationUnit.ancestorIds||[];t.push(this.organizationUnit.id),this.addButton("BUTTON.USERS",this.onEditUsersButtonClicked,m.IDENTITY.getEdit()),this.addButton("BUTTON.EDIT",this.onEditButtonClicked,[m.ORGANIZATIONUNIT.getReadDetailed(),m.ORGANIZATIONUNIT.getWrite()],t),this.addButton("BUTTON.DELETE",this.onDeleteButtonClicked,m.ORGANIZATIONUNIT.getWrite(),t),this.addButton("ORGANIZATIONUNIT.MANAGE_USERS",this.onShowUsersButtonClicked,m.IDENTITY.getReadBasic(),t)}checkPermissions(){let t=this.organizationUnit.ancestorIds||[];t.push(this.organizationUnit.id),this.permissionShowChildren=this.authService.checkPermission(m.ORGANIZATIONUNIT.getReadBasic(),t)}onShowUsersButtonClicked(){this.router.navigate([F.MANAGEMENT_IDENTITIES.fullPath],{queryParams:{oid:this.organizationUnit.id,t:new Date().getTime()}})}onEditButtonClicked(){this.modalService.open(E,{settings:{size:"lg",scrollable:!0},props:{organizationUnit:this.organizationUnit}}).result.then(t=>{this.organizationUnitUpdated.emit(t)}).catch(t=>{})}onEditUsersButtonClicked(){this.modalService.open(dt,{settings:{size:"xl"},props:{editable:!0,sessionFunction:this.getSessionIdForOrganizationUnit.bind(this),useCustomApply:!0}}).result.then(t=>{t&&(t.added>0||t.removed>0?(this.addedCount=t.added||0,this.removedCount=t.removed||0,this.selectableUnitRoles=this.roleService.allRoles.filter(e=>!e.isOrganizationWide&&e.typeId!=q.UNIT_ADMINISTRATOR),this.selectedRole=this.selectableUnitRoles[0],this.organizationUnitService.getOrganizationUnitDetails(this.organizationUnit.id).subscribe(e=>{this.currentIdentityAccessRights=e.defaultAccessControlPoints.map(n=>this.accessControlPointService.getIdentityAccessRight(n)),this.modalService.openTemplate(this.applySessionModalTemplate,{settings:{size:"lg",centered:!0}}).result.then(n=>{this.applySession(t.sessionId,this.selectedRole.id)}).catch(n=>{})})):this.applySession(t.sessionId))}).catch(t=>{})}onAccessRightUpdated(t){}applySession(t,e=null){let n=new it;n.roleId=e,n.removeDefaultAccessRights=this.removeDefaultAccessRights,n.acpAuthorize=this.addAccessRights?{accessRights:this.currentIdentityAccessRights.map(o=>{let i=S.getDummyModel();return i.id=o.accessControlPointId,i.access=o.access,i.remoteAccess=o.remoteAccess,i.read=o.read,i.config=o.config,i.grant=o.grant,i.snapshot=o.snapshot,i}),scope:this.selectedScope}:null,this.identitySelectionService.applySessionDataWithOrganizationUnitRole(t,n).subscribe(()=>{this.interactionService.showMessage("IDENTITY.SELECTION_SUCCEED",null,f.Success),this.organizationUsersUpdated.emit(this.organizationUnit.id)})}getSessionIdForOrganizationUnit(t){return this.identitySelectionService.getSessionForOrganizationUnit(this.organizationUnit.id,t)}onDeleteButtonClicked(){this.deleteActionSelection=N.RemoveAccessRights,this.modalService.openTemplate(this.deleteUnitModalTemplate,{settings:{size:"md",centered:!0}}).result.then(t=>{this.deleteOrganizationUnit()}).catch(t=>{})}deleteOrganizationUnit(){this.organizationUnitService.deleteOrganizationUnit(this.organizationUnit.id,this.deleteActionSelection).subscribe(()=>{this.organizationUnitDeleted.emit(this.organizationUnit.id)})}static ctorParameters=()=>[{type:k},{type:z},{type:y},{type:Z},{type:ct},{type:W},{type:C},{type:L},{type:rt}];static propDecorators={organizationUnit:[{type:u}],showChildrenRequested:[{type:h}],organizationUnitUpdated:[{type:h}],organizationUsersUpdated:[{type:h}],organizationUnitDeleted:[{type:h}],applySessionModalTemplate:[{type:p,args:["applySessionModalTemplate"]}],deleteUnitModalTemplate:[{type:p,args:["deleteUnitModalTemplate"]}]}};It=Rt([v({selector:"armon-organization-unit-basic",template:vt,standalone:!0,imports:[A,U,w,I,Y,$,H,K,b,R,x,st,T],styles:[At]})],It);export{E as a,It as b};
