import{k as O,vb as C}from"./chunk-YSQLW2JA.js";import{ld as c,md as m}from"./chunk-NVJ2ZZFT.js";import{Aa as l,Dc as a,Qb as g,Sd as b,Te as y,Ve as x,Ye as T,_a as f,bb as v,cb as S,db as h,dd as u,mg as w,ya as p}from"./chunk-SKPDQO4E.js";var R=`<ng-container *ngIf="visibleComponent">
  <div class="modal-header">
    <ng-container [ngSwitch]="visitorState">
      <ng-container *ngSwitchCase="4">
        <span class="text-lg">
          <cds-icon shape="success-standard" class="color-dark-blue-color me-2" solid size="md"></cds-icon>{{'VISITOR.TEMPORARY_PERMITTED'
          | translate}}
        </span>
      </ng-container>
      <ng-container *ngSwitchCase="5">
        <span class="text-lg">
          <cds-icon shape="no-access" class="color-error me-2" solid size="md"></cds-icon>{{'VISITOR.BLACK_LIST' |
          translate}}
        </span>
      </ng-container>
    </ng-container>
  </div>
  <div class="modal-body">
    <div class="row" *ngIf="!isReadOnly">
      <div class="col-12">
        <div class="visitor-name">{{profile.values['name']}}</div>
      </div>
    </div>
    <div class="row">
      <div class="col-12">
        <div class="form-group">
          <label [ngClass]="{'required': !isReadOnly}">{{'VISITOR.STATE_START_DATE' | translate}}</label>
          <ng-container *ngIf="!isReadOnly">
            <input [(ngModel)]="profileState.startUtc" type="text" class="custom-item" readonly owlinput
              class="form-control form-control-sm bg-white" (ngModelChange)="onStartDateChanged($event)"
              [owlDateTime]="dt1" [owlDateTimeTrigger]="dt1" [min]="startOfDay">
            <owl-date-time [firstDayOfWeek]="1" #dt1 [pickerType]="'calendar'"></owl-date-time>
          </ng-container>
          <span class="text-md w-100" *ngIf="isReadOnly">{{profileState.startUtcText}}</span>
        </div>
      </div>
      <div class="col-12">
        <div class="form-group">
          <label>{{'VISITOR.STATE_END_DATE' | translate}}</label>
          <ng-container *ngIf="!isReadOnly">
            <input [(ngModel)]="profileState.endUtc" type="text" class="custom-item" readonly owlinput
              (ngModelChange)="onEndDateChanged($event)" class="form-control form-control-sm bg-white"
              [owlDateTime]="dt2" [owlDateTimeTrigger]="dt2" [min]="profileState.startUtc">
            <owl-date-time [firstDayOfWeek]="1" #dt2 [pickerType]="'calendar'"></owl-date-time>
          </ng-container>
          <span class="text-md w-100" *ngIf="isReadOnly">{{profileState.endUtcText?profileState.endUtcText:'-'}}</span>
        </div>
      </div>
      <div class="col-12">
        <div class="form-group">
          <label for="noteInput">{{'VISITOR.STATE_NOTE' | translate}}</label>
          <textarea name="note" id="noteTextArea" [(ngModel)]="profileState.note" rows="4" cols="20" maxlength="256"
            class="form-control form-control-sm" [disabled]="isReadOnly" style="resize:none"
            *ngIf="!isReadOnly"></textarea>
          <span class="text-md w-100" *ngIf="isReadOnly">{{profileState.note ? profileState.note:'-'}}</span>
        </div>
      </div>
    </div>
  </div>
  <div class="modal-footer">
    <button class="btn btn-outline-primary me-2"
      (click)="onCancelClicked($event)">{{'BUTTON.CLOSE' | translate}}</button>
    <button class="btn btn-primary" *ngIf="!isReadOnly" (click)="onSaveClicked($event)" [disabled]="disableSaveButton">{{'BUTTON.SAVE'
      | translate}}
    </button>
  </div>
</ng-container>`;var I=`.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}.visitor-name{font-size:.84rem;padding:.42rem 0}
`;var E=function(o,t,e,n){var s=arguments.length,i=s<3?t:n===null?n=Object.getOwnPropertyDescriptor(t,e):n,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(o,t,e,n);else for(var d=o.length-1;d>=0;d--)(r=o[d])&&(i=(s<3?r(i):s>3?r(t,e,i):r(t,e))||i);return s>3&&i&&Object.defineProperty(t,e,i),i},D=class extends b{visitorService;profile;visitorState;isReadOnly=!1;profileState;isEditMode=!1;startOfDay;disableSaveButton=!0;visibleComponent=!1;constructor(t){super(),this.visitorService=t}onModalInitialized(){super.onModalInitialized(),this.startOfDay=a.local().startOf("day").toJSDate();let t=this.profile.states.find(e=>e.state==this.visitorState);t?(this.isEditMode=!0,this.profileState=g(t)):(this.isEditMode=!1,this.profileState=c.getEmptyModel(),this.profileState.startUtc=a.local().startOf("day").toJSDate()),this.onModelChanged(),this.visibleComponent=!0}saveState(){let t=c.getRequestModel(this.profileState);switch(this.visitorState){case m.TemporaryPermit:this.visitorService.upsertVisitorTempPermitState(this.profile.id,t).subscribe(e=>{this.afterSaveState()});break;case m.Forbidden:this.visitorService.upsertVisitorBlacklistState(this.profile.id,t).subscribe(e=>{this.afterSaveState()});break}}afterSaveState(){this.closeModal(this.profile)}validateForm(){let t=!1;this.disableSaveButton=t}onModelChanged(t){this.validateForm()}onStartDateChanged(t){a.fromJSDate(this.profileState.startUtc)>=a.fromJSDate(this.profileState.endUtc)&&(this.profileState.endUtc=a.fromJSDate(this.profileState.startUtc).endOf("day").toJSDate())}onEndDateChanged(t){}onSaveClicked(t){this.saveState()}static ctorParameters=()=>[{type:C}];static propDecorators={profile:[{type:l}],visitorState:[{type:l}],isReadOnly:[{type:l}]}};D=E([p({selector:"armon-visitor-state-upsert",template:R,standalone:!0,providers:[{provide:x,useClass:O}],imports:[v,S,h,f,y,T,w,u],styles:[I]})],D);export{D as a};
