import{a as _}from"./chunk-C7K6NHIV.js";import{a as k}from"./chunk-ZTPSCNCV.js";import{a as M}from"./chunk-TOMSDEUO.js";import{a as I}from"./chunk-7GYHTWED.js";import{Fb as E,Rb as N}from"./chunk-YSQLW2JA.js";import{H as s,Q as R,Sa as u,wa as O,ya as w}from"./chunk-NVJ2ZZFT.js";import{Aa as m,Nc as l,Pd as P,Qf as b,Rd as v,Sd as y,Te as x,Yg as T,_a as f,ab as p,bb as C,dc as g,dd as A,mg as S,wa as d,ya as h}from"./chunk-SKPDQO4E.js";var z=`<ng-container *ngIf="currentAccessControlPoint">
  <div class="modal-header d-flex flex-column align-items-start">
    <span class="text-lg" *ngIf="currentAccessControlPoint">{{ ( editMode ? currentAccessControlPoint.name :
      'ACCESSCONTROLPOINT.ADD_NEW' ) | translate }}</span>
  </div>

  <div class="modal-body">
    <div class="row" *ngIf="currentAccessControlPoint">
      <div class="col-xl-12">
        <div class="form-group">
          <label for="nameInput" class="required">{{'ACCESSCONTROLPOINT.NAME' | translate}}</label>
          <input class="form-control" type="text" id="nameInput" [(ngModel)]="currentAccessControlPoint.name"
            (ngModelChange)="onNameChanged($event)">
        </div>
      </div>
      <div class="col-xl-12" *ngIf="!currentAccessControlPoint.isVirtualPoint">
        <div class="form-group">
          <label for="locationInput">{{'ACCESSCONTROLPOINT.LOCATION' | translate}}</label>
          <input class="form-control" type="text" id="locationInput" [(ngModel)]="currentAccessControlPoint.location">
        </div>
      </div>
      <div class="col-xl-12" *ngIf="!currentAccessControlPoint.isBuiltinVirtualPoint">
        <div class="form-group">
          <label>{{'ACCESSCONTROLPOINT.GEOLOCATION' | translate}}</label>
          <div class="d-flex align-items-center">
            <armon-geolocation-control [(ngModel)]="currentAccessControlPoint.typedGeoLocation" class="flex-grow-1">
            </armon-geolocation-control>
            <cds-icon solid class="ms-2 text-danger cursor-pointer" shape="times-circle"
              style="width: 20px; height: 20px;" *ngIf="currentAccessControlPoint.typedGeoLocation"
              (click)="currentAccessControlPoint.typedGeoLocation=null" nz-tooltip
              nzTooltipTitle="{{'BUTTON.DELETE'|translate}}"></cds-icon>
          </div>
        </div>
      </div>
      <div class="col-xl-12" *ngIf="!currentAccessControlPoint.isVirtualPoint">
        <div class="form-group">
          <label class="required">{{'ACCESSCONTROLPOINT.TYPE' | translate}}</label>
          <select [(ngModel)]="currentAccessControlPoint.accessControlPointType" (ngModelChange)="onTypeChanged($event)"
            class="form-select">
            <option *ngFor="let type of accessControlPointTypes" [ngValue]="type.type">{{type.description |
              translate}}</option>
          </select>
        </div>
      </div>
      <div class="col-xl-12" *ngIf="!currentAccessControlPoint.isVirtualPoint">
        <div class="form-group">
          <nz-switch [(ngModel)]="currentAccessControlPoint.remoteAvailable"
            (ngModelChange)="onRemoteAvailableChanged($event)" nzSize="small">
          </nz-switch>
          <label class="ms-1">{{'IDENTITY.REMOTE_ACCESS' | translate}}</label>
        </div>
      </div>
    </div>
    <armon-identity-access-right #identityAccessRight *ngIf="accessRight" [accessRight]="accessRight"
      [editMode]="editMode" [visibleFooter]="false"></armon-identity-access-right>
    <armon-access-control-point-authentication-factors #selectionAuthenticationFactors
      [accessControlPoint]="currentAccessControlPoint" [editable]="true"
      *ngIf="currentAccessControlPoint && !currentAccessControlPoint.isVirtualPoint">
    </armon-access-control-point-authentication-factors>

  </div>

  <div class="modal-footer justify-content-end">
    <button type="button" class="btn btn-sm btn-outline-primary me-auto" *ngIf="remoteStatePermission && editMode"
      (click)="onAccessSettingsClicked()">
      <cds-icon shape="shield-check" solid class="cds-icon-18 me-2"></cds-icon>
      {{'REMOTECONTROL.ACCESS_CONTROL_SETTINGS'|translate}}
    </button>
    <button type="button" class="btn btn-outline-primary me-2" (click)="onCancelClicked($event)">{{'BUTTON.CANCEL' |
      translate}}</button>
    <button type="button" class="btn btn-success" (click)="onSaveClicked($event)" [disabled]="disableSaveButton">{{ (
      editMode ? 'BUTTON.SAVE' : 'ACCESSCONTROLPOINT.BUTTON_ADD_AND_MATCH' ) | translate }}</button>
  </div>
</ng-container>`;var L=`.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}:host .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;padding-top:6px;padding-bottom:6px}:host .form-layout>label:not(.custom-item){width:auto;margin-right:12px;min-width:140px}@media screen and (max-width: 576px){:host .form-layout>label:not(.custom-item){width:100%;margin-right:0;margin-bottom:0}}:host .form-layout>label[unit]{margin-left:3px}@media screen and (max-width: 576px){:host .form-layout>label[unit]{flex:0}}:host .form-layout input{flex:1}:host .form-layout .select{flex:1}:host .form-layout textarea{flex:1;margin-right:0}:host .form-layout .form-item{flex:1}:host .form-layout .checkbox{flex:1}:host .form-layout .custom-item{flex:1}:host .form-layout .radio-inline-container{position:relative}:host .form-layout .form-button{margin:0 0 0 12px}:host .form-layout .required:after{content:"*";font-size:1.1em;color:#c92100;margin-left:6px}
`;var G=function(c,o,t,e){var i=arguments.length,n=i<3?o:e===null?e=Object.getOwnPropertyDescriptor(o,t):e,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(c,o,t,e);else for(var a=c.length-1;a>=0;a--)(r=c[a])&&(n=(i<3?r(n):i>3?r(o,t,n):r(o,t))||n);return i>3&&n&&Object.defineProperty(o,t,n),n},D=class extends y{accessControlPointService;interactionService;sessionService;modalService;accessControlPoint;controlPanel;currentAccessControlPoint;accessControlPointTypes=g(R);disableSaveButton;accessRight;editMode=!1;remoteStatePermission=!1;selectionAuthenticationFactors;identityAccessRight;constructor(o,t,e,i){super(),this.accessControlPointService=o,this.interactionService=t,this.sessionService=e,this.modalService=i,this.accessControlPointTypes.unshift({type:null,description:"PACS.SELECT_ONE"})}onModalInitialized(){super.onModalInitialized(),this.accessControlPoint?(this.editMode=!0,this.getAccessControlPointDetails(this.accessControlPoint.id)):(this.editMode=!1,this.currentAccessControlPoint=new O,this.currentAccessControlPoint.remoteAvailable=!1,this.currentAccessControlPoint.accessControlPointType=this.accessControlPointTypes[0].type,this.accessRight=new u,this.validate())}onSaveClicked(o){let t=w.getEmptyModel();if(this.editMode?t.id=this.currentAccessControlPoint.id:t.deviceId=this.controlPanel?.deviceId||void 0,t.name=this.currentAccessControlPoint.name,t.location=this.currentAccessControlPoint.location,t.accessControlPointType=this.currentAccessControlPoint.accessControlPointType,t.remoteAvailable=this.currentAccessControlPoint.remoteAvailable,t.authenticationFactors=null,this.identityAccessRight&&this.accessRight)if(this.identityAccessRight.hasValid()){let e=this.identityAccessRight.getAccessRight();t.defaultPrivileges.access=e.access,t.defaultPrivileges.remoteAccess=e.remoteAccess,t.defaultPrivileges.read=e.read,t.defaultPrivileges.config=e.config,t.defaultPrivileges.grant=e.grant,t.defaultPrivileges.snapshot=e.snapshot}else{this.interactionService.showMessage("IDENTITY.INFO_NO_PERMISSION",null,l.Error);return}else delete t.defaultPrivileges;this.currentAccessControlPoint&&this.currentAccessControlPoint.typedGeoLocation&&(t.typedGeoLocation=this.currentAccessControlPoint.typedGeoLocation),this.selectionAuthenticationFactors&&(t.authenticationFactors=this.selectionAuthenticationFactors.getCurrentFactorList(),t.authenticationFactors&&t.authenticationFactors.forEach(e=>{e.id=void 0,e.and&&e.and.forEach(i=>{i.authenticatorDescription=void 0,i.factorDescription=void 0,i.id=void 0})})),this.editMode?this.accessControlPointService.updateAccessControlPoint(t).subscribe(e=>{this.interactionService.showMessage("ACCESSCONTROLPOINT.UPDATE_SUCCEED",null,l.Success),this.closeModal(this.currentAccessControlPoint)}):this.accessControlPointService.addAccessControlPoint(t).subscribe(e=>{this.interactionService.showMessage("ACCESSCONTROLPOINT.UPDATE_SUCCEED",null,l.Success),this.closeModal(e)})}getAccessControlPointDetails(o){this.accessControlPointService.getDetailsofAccessControlPoint(o).subscribe(t=>{if(this.currentAccessControlPoint=t,this.validate(),t.userRights.grant){let e=new u;e.userRights=t.userRights,e.access=t.defaultPrivileges.access,e.remoteAccess=t.defaultPrivileges.remoteAccess,e.read=t.defaultPrivileges.read,e.config=t.defaultPrivileges.config,e.grant=t.defaultPrivileges.grant,e.snapshot=t.defaultPrivileges.snapshot,e.accessControlPointRemoteAvailable=t.remoteAvailable,e.accessControlPointId=t.id,this.accessRight=e}this.remoteStatePermission=this.currentAccessControlPoint.userRights&&this.currentAccessControlPoint.userRights.config&&(this.getCountOfRelays(s.Entrance)>0||this.getCountOfRelays(s.Exit)>0||this.getCountOfRelays(s.All)>0)})}getCountOfRelays(o){return this.currentAccessControlPoint&&this.currentAccessControlPoint.relays?this.currentAccessControlPoint.relays.filter(t=>t.direction===o).length:0}validate(){this.disableSaveButton=!this.currentAccessControlPoint.name||this.currentAccessControlPoint.name==""||this.currentAccessControlPoint.name.length<3||this.currentAccessControlPoint.accessControlPointType==null}onNameChanged(o){this.validate()}onTypeChanged(o){this.validate()}onRemoteAvailableChanged(o){this.identityAccessRight&&this.identityAccessRight.setRemoteAvailable(this.currentAccessControlPoint.remoteAvailable)}onAccessSettingsClicked(){this.modalService.open(M,{settings:{size:"md"},props:{remoteAccessPointId:this.currentAccessControlPoint.id,remoteAccessPointName:this.currentAccessControlPoint.name,accessControlPointRemoteStates:this.currentAccessControlPoint.states,showEntrance:this.getCountOfRelays(s.Entrance)>0,showExit:this.getCountOfRelays(s.Exit)>0,showAll:this.getCountOfRelays(s.All)>0}}).result.then(o=>{o&&(this.currentAccessControlPoint.states=o)}).catch(o=>{})}static ctorParameters=()=>[{type:N},{type:b},{type:P},{type:v}];static propDecorators={accessControlPoint:[{type:m}],controlPanel:[{type:m}],selectionAuthenticationFactors:[{type:d,args:["selectionAuthenticationFactors"]}],identityAccessRight:[{type:d,args:["identityAccessRight"]}]}};D=G([h({selector:"armon-access-control-point-modal",template:z,standalone:!0,imports:[C,f,x,S,_,T,p,E,I,k,A],styles:[L]})],D);export{D as a};
