import{b as G}from"./chunk-I6FSQTEP.js";import{j as h,k}from"./chunk-YSQLW2JA.js";import{ob as F,pb as Y,qb as J}from"./chunk-NVJ2ZZFT.js";import{Aa as c,Ba as A,Cc as E,Dc as o,De as R,He as y,Qf as b,Rd as T,S,Sd as N,Se as P,Te as f,Ue as V,Ve as w,Wb as M,Ye as z,_a as C,ab as g,bb as p,bh as U,dd as d,eh as j,gb as O,ha as I,jb as v,mg as L,ya as m}from"./chunk-SKPDQO4E.js";var B=`<div class="row justify-content-center" *ngIf="visibleComponent">\r
  <div class="col-xl-8 col-lg-12 col-md-12">\r
    <div class="row my-3">\r
      <div class="col-12 d-flex">\r
        <button class="btn btn-sm btn-primary"\r
          (click)="addVacationItem($event)">{{'PACS.ADD_VACATION'|translate}}</button>\r
        <div class="d-flex justify-content-end align-items-center ms-auto">\r
          <span class="pe-3">{{'PACS.YEAR'|translate}}</span>\r
          <select [(ngModel)]="selectedYear" (change)="onYearChanged($event)" class="form-select form-select-sm">\r
            <option *ngFor="let year of years" [ngValue]="year">{{year}}</option>\r
          </select>\r
        </div>\r
      </div>\r
    </div>\r
    <div *ngFor="let month of months">\r
      <div class="row" *ngIf="month.vacations.length > 0">\r
        <div class="col-12 mt-3 text-lg">\r
          <div class="b-b-1">\r
            <span>{{month.name}}</span>\r
          </div>\r
        </div>\r
        <div class="col-12 pt-2" *ngFor="let vacation of month.vacations">\r
          <armon-pacs-vacation-item [item]="vacation" (itemUpdated)="itemUpdated($event)"></armon-pacs-vacation-item>\r
        </div>\r
      </div>\r
    </div>\r
    <div *ngIf="visibleNoVacationsAlert" class="pt-5">\r
      <nz-empty [nzNotFoundContent]="contentTpl" [nzNotFoundImage]="'./assets/images/empty/empty_list.png'">\r
        <ng-template #contentTpl>\r
          <span> {{"PACS.NO_VACATIONS_FOR_YEAR"|translate}}</span>\r
        </ng-template>\r
      </nz-empty>\r
    </div>\r
  </div>\r
</div>`;var $="";var H=`<ng-container *ngIf="visibleComponent">
  <div class="modal-header">
    <span class="text-lg">{{(isEditMode ? 'PACS.EDIT_VACATION' : 'PACS.ADD_VACATION' ) | translate}}</span>
  </div>
  <div class="modal-body">
    <form class="form" [formGroup]="form">
      <div class="row">
        <div class="col-12">
          <div class="form-group">
            <label for="titleInput">{{'PACS.VACATION_NAME' | translate}}</label>
            <input type="text" id="titleInput" [formControl]="form.get('title')"
              [ngClass]="{'is-invalid': form.get('title').touched && form.get('title').invalid}"
              class="form-control form-control-sm">
            <ng-template
              *ngTemplateOutlet="controlValidationTemplate; context: {$implicit: form, control:form.get('title')}">
            </ng-template>
          </div>
        </div>
        <div class="col-12">
          <div class="form-group">
            <label>{{'PACS.VACATION_TYPE' | translate}}</label>
            <nz-select class="w-100" nzSize="small" [formControl]="form.get('type')"
              [ngClass]="{'nz-invalid': form.get('type').invalid}">
              <nz-option *ngFor="let option of vacationTypes" [nzValue]="option.type" [nzLabel]="option.description |
            translate"></nz-option>
            </nz-select>
            <ng-template
              *ngTemplateOutlet="controlValidationTemplate; context: {$implicit: form, control:form.get('type')}">
            </ng-template>
          </div>
        </div>
        <div class="col-12">
          <div class="form-group">
            <armon-days-range-input [formControl]="form.get('rangeDateTime')">
            </armon-days-range-input>
            <ng-template
              *ngTemplateOutlet="controlValidationTemplate; context: {$implicit: form, control:form.get('rangeDateTime')}">
            </ng-template>
          </div>
        </div>
      </div>
    </form>
    <!-- <pre>{{form.value|json}}</pre> -->
  </div>
  <div class="modal-footer">
    <button class="btn btn-outline-primary me-2" (click)="cancelClicked($event)">
      {{'BUTTON.CANCEL' | translate}}
    </button>
    <button class="btn btn-primary" (click)="saveClicked($event)" [disabled]="form.invalid">
      {{'BUTTON.SAVE' | translate}}
    </button>
  </div>
</ng-container>

<!--
<pre>{{item.startDateTime}}</pre>
<pre>{{item.endDateTime}}</pre>
-->

<!-- 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 q="";var X=`<div class="row mt-4 mb-2">
	<div class="col-5 position-relative d-flex flex-column align-items-end px-3 py-2 b-r-1">
		<input class="date-select-input" [(ngModel)]="startDateTime" (dateTimeChange)="onStartDayChanged($event)"
			[owlDateTimeTrigger]="dtStart" [owlDateTime]="dtStart" style="visibility: hidden;">
		<span class="text-sm mb-3">{{labels.startTitle| translate}}</span>
		<span class="text-xl text-bold">{{startDateTime | date:'d MMMM'}}</span>
		<span class="text-lg">{{startDateTime | date:'yyyy'}}</span>
		<div class="d-flex py-1 my-3">
			<button class="btn btn-sm btn-primary" [owlDateTimeTrigger]="dtStart">{{'BUTTON.EDIT' | translate}}</button>
		</div>
		<owl-date-time [firstDayOfWeek]="1" #dtStart [pickerType]="'calendar'"></owl-date-time>
		<!-- HALF DAY -->
		<div class="d-flex flex-column align-items-end align-self-end mt-4">
			<nz-radio-group name="startMorning" [(ngModel)]="startMorning"
				(ngModelChange)="onStartMorningChanged($event)">
				<label nz-radio [nzValue]="true" [nzDisabled]="disableStartMorning">
					{{'PACS.DIRECTION_ADD_PPERMISSION_DAY_MORNING'|translate}}</label>
				<label nz-radio [nzValue]="false" [nzDisabled]="disableStartMorning">
					{{'PACS.DIRECTION_ADD_PPERMISSION_DAY_AFTERNOON'|translate}}</label>
			</nz-radio-group>

			<span class="mt-2 text-xs text-bold text-secondary">{{(startMorning ? labels.startMorningTitle :
				labels.startAfternoonTitle) | translate}}</span>
		</div>
		<!-- HALF DAY -->
	</div>
	<div class="col-2 d-flex flex-column align-items-center px-3 py-2">
		<span class="text-sm mb-3 align-self-stretch text-center duration-title">{{labels.title|translate}}</span>
		<ng-container *ngIf="difference">
			<span class="text-md text-center text-bold text-primary">
				<ng-container *ngIf="difference == 0.5">{{'REPORT.PACS_UNIT_DAY_JUST_HALF'|translate}}</ng-container>
				<ng-container *ngIf="difference != 0.5">{{difference}}
					{{(differenceDaiyHalf ? 'REPORT.PACS_UNIT_DAY_HALF' : 'REPORT.PACS_UNIT_DAY' ) | translate}}
				</ng-container>
			</span>
		</ng-container>
	</div>
	<div class="col-5 d-flex flex-column align-items-start px-3 py-2 b-l-1">
		<input class="date-select-input" [(ngModel)]="endDateTime" [min]="minEndDate" [max]="maxEndDate"
			(dateTimeChange)="onEndDayChanged($event);" [owlDateTimeTrigger]="dtEnd" [owlDateTime]="dtEnd"
			style="visibility: hidden;">
		<span class="text-sm mb-3">{{labels.endTitle| translate}}</span>
		<span class="text-xl text-bold">{{endDateTime | date:'d MMMM'}}</span>
		<span class="text-lg">{{endDateTime | date:'yyyy'}}</span>
		<div class="d-flex py-1 my-3" [owlDateTimeTrigger]="dtEnd">
			<button class="btn btn-sm btn-primary" [owlDateTimeTrigger]="dtEnd">{{'BUTTON.EDIT' | translate}}</button>
		</div>
		<owl-date-time [firstDayOfWeek]="1" #dtEnd [pickerType]="'calendar'"></owl-date-time>
		<!-- HALF DAY -->
		<div class="d-flex flex-column align-items-start align-self-start mt-4">
			<nz-radio-group name="endMorning" [(ngModel)]="endMorning" (ngModelChange)="onEndMorningChanged($event)">
				<label nz-radio [nzValue]="true" [nzDisabled]="disableEndMorning">
					{{'PACS.DIRECTION_ADD_PPERMISSION_DAY_MORNING'|translate}}</label>
				<label nz-radio [nzValue]="false" [nzDisabled]="disableEndMorning">
					{{'PACS.DIRECTION_ADD_PPERMISSION_DAY_AFTERNOON'|translate}}</label>
			</nz-radio-group>
			<span class="mt-2 text-xs text-bold text-secondary">{{(endMorning ?
				labels.endMorningTitle : labels.endAfternoonTitle )
				|
				translate}}</span>
		</div>
		<!-- HALF DAY -->
	</div>
</div>`;var W=`.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}
`;var rt=function(s,t,e,n){var i=arguments.length,a=i<3?t:n===null?n=Object.getOwnPropertyDescriptor(t,e):n,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(s,t,e,n);else for(var l=s.length-1;l>=0;l--)(r=s[l])&&(a=(i<3?r(a):i>3?r(t,e,a):r(t,e))||a);return i>3&&a&&Object.defineProperty(t,e,a),a},st={provide:R,useExisting:S(()=>u),multi:!0},u=class{labels={title:"PACS.VACATION_DURATION",startTitle:"PACS.VACATION_START",endTitle:"PACS.DIRECTION_ADD_PPERMISSION_END_DAY_LABEL",startMorningTitle:"PACS.VACATION_START_MORNING",startAfternoonTitle:"PACS.VACATION_START_AFTERNOON",endMorningTitle:"PACS.DIRECTION_ADD_PPERMISSION_DAY_END_MORNING",endAfternoonTitle:"PACS.DIRECTION_ADD_PPERMISSION_DAY_END_AFTERNOON"};startDateTime;endDateTime;startMorning=!0;endMorning=!0;disableStartMorning=!1;disableEndMorning=!1;difference;differenceDaiyHalf=!1;maxEndDate=void 0;minEndDate=void 0;onChange;constructor(){}ngOnInit(){}ngAfterViewInit(){this.normalizeDaySelection(!0),this.normalizeDaySelection(!1),this.setDailyDifference()}ngOnDestroy(){}updateValue(){this.onChange&&this.onChange(this.startDateTime&&this.endDateTime?{startDateTime:this.startDateTime,endDateTime:this.endDateTime}:null)}writeValue(t){this.startDateTime=t.startDateTime,this.endDateTime=t.endDateTime,this.checkValueDates(),this.updateValue()}registerOnChange(t){this.onChange=t,this.updateValue()}registerOnTouched(t){}setDisabledState(t){}checkValueDates(){this.startDateTime&&o.fromJSDate(this.startDateTime)>=o.fromJSDate(this.startDateTime).startOf("day").plus({hours:12})?(this.startMorning=!1,this.startDateTime=o.fromJSDate(this.startDateTime).startOf("day").plus({hours:12}).toJSDate()):this.startDateTime=o.fromJSDate(this.startDateTime).startOf("day").toJSDate(),this.endDateTime&&o.fromJSDate(this.endDateTime)>=o.fromJSDate(this.endDateTime).startOf("day").plus({hours:12})?(this.endMorning=!1,this.endDateTime=o.fromJSDate(this.endDateTime).startOf("day").plus({hours:12}).toJSDate()):this.endDateTime=o.fromJSDate(this.endDateTime).startOf("day").toJSDate()}normalizeDaySelection(t){if(this.disableStartMorning=!1,this.disableEndMorning=!1,o.fromJSDate(this.startDateTime)>=o.fromJSDate(this.endDateTime)&&(this.endDateTime=o.fromJSDate(this.getDailyMinDate()).startOf("day").plus({hours:12}).toJSDate(),this.checkValueDates()),t==!0&&this.startDateTime){let e=o.fromJSDate(this.startDateTime).startOf("day");this.startMorning==!1&&(e=e.plus({hours:12})),this.startDateTime=e.toJSDate()}if(t==!1&&this.startDateTime){let e=o.fromJSDate(this.endDateTime).startOf("day");this.endMorning==!1&&(e=e.plus({hours:12})),this.endDateTime=e.toJSDate()}this.startDateTime&&this.endDateTime&&o.fromJSDate(this.startDateTime).toFormat("yyyy-MM-dd")==o.fromJSDate(this.endDateTime).toFormat("yyyy-MM-dd")&&(this.startMorning=!0,this.endMorning=!1,this.disableStartMorning=!0,this.disableEndMorning=!0)}setDailyDifference(){if(this.startDateTime&&this.endDateTime){let t=o.fromJSDate(this.endDateTime).diff(o.fromJSDate(this.startDateTime),["days"]).toObject().days;t<1?(this.differenceDaiyHalf=!0,this.difference=.5):(this.differenceDaiyHalf=!Number.isInteger(t),this.difference=Math.floor(t))}else this.difference=null;this.minEndDate=this.getDailyMinDate(),this.updateValue()}getDailyMinDate(){return o.fromJSDate(this.startDateTime).toJSDate()}onStartDayChanged(t){this.maxEndDate=null,this.normalizeDaySelection(!0),this.setDailyDifference()}onEndDayChanged(t){this.maxEndDate=null,this.normalizeDaySelection(!1),this.setDailyDifference()}onStartMorningChanged(t){this.normalizeDaySelection(!0),this.setDailyDifference()}onEndMorningChanged(t){this.normalizeDaySelection(!1),this.setDailyDifference()}static ctorParameters=()=>[];static propDecorators={labels:[{type:c}]}};u=rt([m({selector:"armon-days-range-input",template:X,standalone:!0,providers:[st,{provide:w,useClass:k}],imports:[f,z,L,G,p,v,d],styles:[W]})],u);var lt=function(s,t,e,n){var i=arguments.length,a=i<3?t:n===null?n=Object.getOwnPropertyDescriptor(t,e):n,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(s,t,e,n);else for(var l=s.length-1;l>=0;l--)(r=s[l])&&(a=(i<3?r(a):i>3?r(t,e,a):r(t,e))||a);return i>3&&a&&Object.defineProperty(t,e,a),a},D=class extends N{formBuilder;interactionService;pacsService;vacation;visibleComponent=!1;disableSaveButton=!0;isEditMode=!1;vacationTypes=J;form;constructor(t,e,n){super(),this.formBuilder=t,this.interactionService=e,this.pacsService=n}onModalInitialized(){super.onModalInitialized(),this.isEditMode=!M(this.vacation),this.createForm(),this.visibleComponent=!0}createForm(){this.form=this.formBuilder.group({title:[this.vacation?.title||void 0,[y.required]],type:[this.vacation?.type||Y.National,[y.required]],rangeDateTime:[this.vacation?{startDateTime:this.vacation.startDateTime,endDateTime:this.vacation.endDateTime}:{startDateTime:o.local().startOf("day").toJSDate(),endDateTime:o.local().plus({days:1}).startOf("day").toJSDate()},[y.required]]})}cancelClicked(t){this.cancelModal()}saveClicked(t){let e=new F;this.isEditMode&&(e.id=this.vacation.id),e.title=this.form.value.title,e.type=this.form.value.type,e.startDateTime=this.form.value.rangeDateTime.startDateTime,e.endDateTime=this.form.value.rangeDateTime.endDateTime,this.pacsService.upsertVacation(e).subscribe(n=>{this.closeModal(n)})}static ctorParameters=()=>[{type:P},{type:b},{type:h}];static propDecorators={vacation:[{type:c}]}};D=lt([m({selector:"armon-pacs-vacation-upsert",template:H,standalone:!0,imports:[p,f,V,C,O,j,g,u,d],styles:[q]})],D);var Q=`<div class="card mb-3">
    <div class="d-flex align-items-stretch">
        <div class="d-flex flex-column align-items-center p-4 justify-content-between border-end">
            <cds-icon shape="calendar" style="width: 30px; height: 30px;" class="color-gray"></cds-icon>
            <span class="text-xxl color-gray-dark">{{item.startDayOfMonth}}</span>
        </div>
        <div class="d-flex flex-column p-3 align-items-stretch flex-grow-1">
            <span class="text-md text-bold">{{item.title}}</span>
            <span class="text-md color-gray-dark mt-3">{{item.startDateTime | date:'d MMMM'}}<span> -
                </span>{{item.endDateTime | date:'d MMMM'}}</span>
            <span class="text-sm color-gray-dark">{{item.typeTitle | translate}}</span>
            <div class="d-flex justify-content-end py-2">
                <!-- Edit item button -->
                <button class="btn btn-sm btn-outline-primary me-2" (click)="editItemClicked($event)">
                    {{'BUTTON.EDIT' | translate}}
                </button>
                <!-- Delete item button -->
                <button class="btn btn-sm btn-outline-danger" (click)="deleteItemClicked($event)">
                    {{'BUTTON.DELETE' | translate}}
                </button>
            </div>
        </div>
    </div>
</div>`;var K=`.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}
`;var ct=function(s,t,e,n){var i=arguments.length,a=i<3?t:n===null?n=Object.getOwnPropertyDescriptor(t,e):n,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(s,t,e,n);else for(var l=s.length-1;l>=0;l--)(r=s[l])&&(a=(i<3?r(a):i>3?r(t,e,a):r(t,e))||a);return i>3&&a&&Object.defineProperty(t,e,a),a},x=class{interactionService;pacsService;modalService;item;itemUpdated=new I;constructor(t,e,n){this.interactionService=t,this.pacsService=e,this.modalService=n}ngOnInit(){}ngOnDestroy(){}editItemClicked(t){this.modalService.open(D,{settings:{size:"lg"},props:{vacation:this.item}}).result.then(e=>{this.itemUpdated.emit()}).catch(e=>{})}deleteItemClicked(t){this.interactionService.showDialog(this.item.title,"PACS.APPROVE_DELETE_VACATION",null,null,!0,"BUTTON.DELETE","",!0,()=>{this.pacsService.deleteVacation(this.item.id).subscribe(()=>{this.itemUpdated.emit()})})}static ctorParameters=()=>[{type:b},{type:h},{type:T}];static propDecorators={item:[{type:c}],itemUpdated:[{type:A}]}};x=ct([m({selector:"armon-pacs-vacation-item",template:Q,standalone:!0,imports:[v,d],styles:[K]})],x);var pt=function(s,t,e,n){var i=arguments.length,a=i<3?t:n===null?n=Object.getOwnPropertyDescriptor(t,e):n,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(s,t,e,n);else for(var l=s.length-1;l>=0;l--)(r=s[l])&&(a=(i<3?r(a):i>3?r(t,e,a):r(t,e))||a);return i>3&&a&&Object.defineProperty(t,e,a),a},Z=class{pacsService;modalService;visibleComponent=!0;years=[];selectedYear;months;visibleNoVacationsAlert=!1;constructor(t,e){this.pacsService=t,this.modalService=e}ngOnInit(){this.createYearOptions(2010),this.getVacationList(this.selectedYear)}ngOnDestroy(){}createYearOptions(t,e=10){let n=[];this.selectedYear=new Date().getFullYear();let i=this.selectedYear+10;for(var a=2010;a<=i;a++)n.push(a);this.years=n}getVacationList(t){this.visibleNoVacationsAlert=!1,this.pacsService.getVacationList(t).subscribe(e=>{this.months=this.divideIntoMonths(e,t),this.visibleNoVacationsAlert=e.items.length==0})}divideIntoMonths(t,e){let n=[];return E.months().forEach((a,r)=>{n.push(new _(a))}),t.items.forEach((a,r)=>{n[a.getMonthOfYearForList(e)].vacations.push(a)}),n}onYearChanged(t){this.getVacationList(this.selectedYear)}addVacationItem(t){this.modalService.open(D,{settings:{size:"lg"}}).result.then(e=>{this.getVacationList(this.selectedYear)}).catch(e=>{})}itemUpdated(){this.getVacationList(this.selectedYear)}static ctorParameters=()=>[{type:h},{type:T}]};Z=pt([m({selector:"armon-pacs-vacation-list",template:B,standalone:!0,imports:[p,f,g,x,U,d],styles:[$]})],Z);var _=class{name;vacations=[];constructor(t){this.name=t}};export{Z as PacsVacationListComponent};
