import{a as Z}from"./chunk-IKQMUISD.js";import{a as V,b as Q}from"./chunk-MXSLISEG.js";import"./chunk-7GYHTWED.js";import"./chunk-7QEXVS2A.js";import"./chunk-HXEFMD5A.js";import"./chunk-KCLQIV7M.js";import"./chunk-5KCUTXXV.js";import"./chunk-JUDWAYYT.js";import"./chunk-LAJI7RPC.js";import"./chunk-WFZJP5WR.js";import"./chunk-F6KLNSUK.js";import"./chunk-CO3X7TQN.js";import"./chunk-VSFNMVXJ.js";import"./chunk-WQ6DP4JQ.js";import{$ as B,Y as H,Z as K,_ as q,aa as $,c as m,ca as Y,j as J,k as b,oa as G}from"./chunk-YSQLW2JA.js";import{L as g,sb as D}from"./chunk-NVJ2ZZFT.js";import{$c as L,Aa as C,Ba as _,Bc as w,Dc as r,Fb as R,Fc as N,Hb as M,Mc as j,Qf as W,Rd as F,Te as h,Ve as y,Ye as x,ab as A,bb as f,cd as z,dc as P,dd as u,gb as I,ha as O,mg as U,wa as E,ya as c}from"./chunk-SKPDQO4E.js";var X=`<div class="row justify-content-center">
    <div class="col-xl-8 col-lg-12 col-md-12">
        <div class="row" *ngIf="workplan">
            <div class="col-12 d-flex flex-column">
                <span class="text-xl">{{(modeAdd ? 'PACS.ADD_USER' : 'PACS.REMOVE_USER' ) | translate }}</span>
                <span class="text-lg">{{workplan.name}}</span>
            </div>
        </div>
        <div class="row mt-3" *ngIf="workplan">
            <div class="col-12">
                <div class="section-title">
                    <cds-icon shape="users" solid></cds-icon>
                    {{'PACS.WORKPLAN_EMPLOYEE_SELECTION'|translate}}
                </div>
                <ng-container *ngIf="hiddenDateSelection">
                    <div class="ms-4">
                        <span class="text-md">{{(modeAdd ? 'PACS.WORKPLAN_EMPLOYEE_SELECTION_INFO' :
                            'PACS.WORKPLAN_EMPLOYEE_SELECTION_REMOVE_INFO' ) |translate:workplan}}</span>
                    </div>
                    <button class="btn btn-primary btn-sm ms-4 mt-3" (click)="onAddEmployeeClicked($event)">
                        {{'PACS.WORKPLAN_EMPLOYEE_SELECTION_BUTTON' | translate}}
                    </button>
                </ng-container>
                <ng-container *ngIf="!hiddenDateSelection">
                    <div class="employee-count ms-4" *ngIf="modeAdd"><strong>{{numberOfEmployees}}</strong></div>
                    <div class="employee-count-remove ms-4" *ngIf="!modeAdd"><strong>{{numberOfEmployees}}</strong>
                    </div>
                    <div class="text-md ms-4">{{'PACS.WORKPLAN_EMPLOYEE_SELECTED'|translate}}</div>
                </ng-container>
            </div>
        </div>
        <div class="row mt-3" [hidden]="hiddenDateSelection">
            <div class="col-xl-12">
                <div class="section-title">
                    <cds-icon shape="calendar" solid></cds-icon>
                    {{'PACS.WORKPLAN_DATE_SELECTION'|translate}}
                </div>
                <ng-container *ngIf="hiddenRangeSelection">
                    <div class="ms-4">
                        <span class="text-md">{{(modeAdd ? 'PACS.WORKPLAN_DATE_SELECTION_INFO' :
                            'PACS.WORKPLAN_DATE_SELECTION_REMOVE_INFO' ) |translate}}</span>
                    </div>
                    <div class="mt-3 ms-4">
                        <div class="row">
                            <div class="col-xl-3 col-lg-4 col-md-6 col-12">
                                <div class="form-group">
                                    <label>{{'PACS.START_DATE' | translate}}</label>
                                    <div class="input-group input-group-sm">
                                        <input [(ngModel)]="request.ranges[0].startDateTime" type="text"
                                            class="form-control bg-white" readonly owlinput [owlDateTime]="dt1"
                                            [owlDateTimeTrigger]="dt1" [max]="request.ranges[0].endDateTime">
                                        <owl-date-time [firstDayOfWeek]="1" #dt1 [showSecondsTimer]="false"
                                            [stepMinute]="5" (afterPickerOpen)="onAfterPickerOpened($event)"
                                            [startAt]="defaultStart">
                                        </owl-date-time>                                       
                                            <button class="btn btn-sm btn-outline-danger"
                                                [disabled]="request.ranges[0].startDateTime==null"
                                                (click)="request.ranges[0].startDateTime=null;">{{'BUTTON.CLEAR'|translate}}</button>
                                    </div>
                                </div>
                            </div>
                            <div class="col-xl-3 col-lg-4 col-md-6 col-12">
                                <div class="form-group">
                                    <label class="text-md">{{'PACS.END_DATE' | translate}}</label>
                                    <div class="input-group input-group-sm">
                                        <input [(ngModel)]="request.ranges[0].endDateTime" type="text"
                                            class="form-control form-control-sm bg-white" readonly owlinput
                                            [owlDateTime]="dt2" [owlDateTimeTrigger]="dt2"
                                            [min]="request.ranges[0].startDateTime">
                                        <owl-date-time [firstDayOfWeek]="1" #dt2 [showSecondsTimer]="false"
                                            [stepMinute]="5" (afterPickerOpen)="onAfterPickerOpened($event)"
                                            [startAt]="defaultEnd">
                                        </owl-date-time>
                                            <button class="btn btn-sm btn-outline-danger"
                                                [disabled]="request.ranges[0].endDateTime==null"
                                                (click)="request.ranges[0].endDateTime=null;">{{'BUTTON.CLEAR'|translate}}</button>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div *ngIf="modeAdd" class="mt-3 ms-4">
                        <span class="text-md text-italic">{{'PACS.WORKPLAN_ASSIGN_DAYS_INFO' |translate}}</span><br>
                        <button class="btn btn-outline-primary btn-sm"
                            (click)="onShowDaysClicked($event)">{{'PACS.WORKPLAN_ASSIGN_DAYS_BUTTON' |
                            translate}}</button>
                    </div>
                </ng-container>
                <ng-template [ngTemplateOutlet]="viewButtons"></ng-template>
                <div class="col-12" [hidden]="hiddenRangeSelection">
                    <armon-pacs-timeline-range-selection #rangeSelection></armon-pacs-timeline-range-selection>
                </div>
                <ng-template [ngTemplateOutlet]="viewButtons" *ngIf="!hiddenRangeSelection"></ng-template>
            </div>
        </div>
    </div>
</div>


<ng-template #viewButtons>
    <div class="col-12 d-flex justify-content-end">
        <button class="btn btn-outline-primary me-2" (click)="backClicked($event)">{{'BUTTON.CANCEL' |
            translate}}</button>
        <button class="btn btn-primary" (click)="onSaveClicked($event)">
            {{'BUTTON.SAVE' | translate}}
        </button>
    </div>
</ng-template>`;var ee=`.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}.section-title{width:100%;padding:6px;border-bottom:solid 1px rgba(102,102,102,.2);color:#666;margin-bottom:12px}.employee-count,.employee-count-remove{font-size:2.52rem;color:#81b551;font-weight:lighter}.employee-count-remove{color:#c82602}
`;var p=class l extends N{ranges;enforce;static getEmptyModel(){let e=new l;e.ranges=[];let t=new g;return t.startDateTime=null,t.endDateTime=null,e.ranges.push(t),e.enforce=!1,e}static getRequestModel(e){let t=P(e);return t.enforce==!1&&delete t.enforce,t.ranges.length==1&&t.ranges[0]==null&&t.ranges[0]==null&&delete t.ranges[0],t.ranges.length==0&&delete t.ranges,t}};var te=`<div>
    <div class="data-navigation-container">
        <div class="data-arrow-button" (click)="onPrevMonthClicked($event)">
            <cds-icon shape="angle" direction="left" style="width: 20px; height: 20px;"></cds-icon>
        </div>
        <div class="data-navigation-title">
            <span class="data-title">{{months[selectedIndex].monthText}}</span>
        </div>
        <div class="data-arrow-button" (click)="onNextMonthClicked($event)">
            <cds-icon shape="angle" direction="right" style="width: 20px; height: 20px;"></cds-icon>
        </div>
    </div>
    <ng-container *ngFor="let day of months[selectedIndex].days">
        <armon-pacs-timeline-range-selection-day [day]="day" (copyDaySelected)="onCopyDaySelected($event, day)">
        </armon-pacs-timeline-range-selection-day>
    </ng-container>
</div>`;var ne=`.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}.data-navigation-container{padding:.2rem;-webkit-border-radius:.375rem;-moz-border-radius:.375rem;border-radius:.375rem;margin-top:6px;background-color:#f3f4f7;display:-webkit-box;display:-moz-box;display:-webkit-flexbox;display:-ms-flexbox;display:-webkit-flex;display:flex;-webkit-box-pack:justify;-moz-box-pack:justify;-webkit-flex-pack:justify;-ms-flex-pack:justify;-moz-justify-content:space-between;-webkit-justify-content:space-between;justify-content:space-between;-webkit-box-align:center;-ms-flex-align:center;-webkit-align-items:center;-moz-align-items:center;align-items:center}.data-navigation-container .data-navigation-title{display:-webkit-box;display:-moz-box;display:-webkit-flexbox;display:-ms-flexbox;display:-webkit-flex;display:flex;-webkit-box-orient:vertical;-moz-box-orient:vertical;-webkit-flex-direction:column;-moz-flex-direction:column;-ms-flex-direction:column;flex-direction:column;-webkit-box-align:center;-ms-flex-align:center;-webkit-align-items:center;-moz-align-items:center;align-items:center}.data-navigation-container .data-navigation-title .data-title{text-align:center;font-size:.714rem;line-height:.65rem;color:#0a2a5a;-webkit-flex-grow:1;-webkit-box-flex:1;-moz-flex-grow:1;-ms-flex-positive:1;flex-grow:1}.data-navigation-container .data-arrow-button{padding:3px;cursor:pointer;-webkit-border-radius:.375rem;-moz-border-radius:.375rem;border-radius:.375rem}.data-navigation-container .data-arrow-button:hover{background-color:#cde1ec}
`;var ie=`<div class="day-container" [attr.selected]="state!=1">
    <div class="button-container">
        <cds-icon shape="plus-circle" size="md" (click)="onAddClicked($event)"
            title="{{'PACS.WORKPLAN_ASSIGN_DAYS_SELECT_DAY'|translate}}"></cds-icon>
        <cds-icon shape="minus-circle" size="md" (click)="onRemoveClicked($event)"
            title="{{'PACS.WORKPLAN_ASSIGN_DAYS_REMOVE_DAY'|translate}}"></cds-icon>
    </div>
    <div class="info-container" (click)="onInfoContainerClicked($event)" [attr.timeline]="visibleTimeline"
        title="{{'PACS.WORKPLAN_ASSIGN_DAYS_TITLE'|translate}}">
        <div class="d-flex align-items-center">
            <div class="day-text">{{day.dayText}} - {{day.weekdayText}}</div>
            <div class="ms-auto pos-relative" *ngIf="state!=1">
                <span class="text-sm fw-medium cursor-pointer" [owlDateTimeTrigger]="dt8">{{'BUTTON.COPY'| translate}}</span>
                <input [(ngModel)]="copyDate" [owlDateTime]="dt8" class="date-select-input"
                    (dateTimeChange)="onCopyDateChanged($event)" [max]="endMonthDate" [min]="startMonthDate">
                <owl-date-time [firstDayOfWeek]="1" #dt8 [pickerType]="'calendar'">
                </owl-date-time>
            </div>
        </div>
        <ng-container *ngIf="visibleTimeline">
            <app-timeline-wrapper-component class="timeline-container" [timeline]="timelineSelection"
                [options]="timelineSelectionOptions" (onRangeMouseEnter)="onRangeMouseEnter($event)"
                (onRangeMouseLeave)="onRangeMouseLeave($event)" (onSelectionUpdated)="onSelectionUpdated($event)"
                (onRangeClicked)="onRangeClicked($event)">
            </app-timeline-wrapper-component>
        </ng-container>
        <span class="state-text">{{stateText|translate}}<span *ngIf="stateRangesText"> :
                {{stateRangesText}}</span></span>
        <!-- <pre>{{day.selectedDates|json}}</pre> -->
    </div>
</div>`;var oe=`.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}.day-container{box-shadow:0 0 4px #ccc;display:-webkit-box;display:-moz-box;display:-webkit-flexbox;display:-ms-flexbox;display:-webkit-flex;display:flex;margin:6px 0;-webkit-border-v-right-radius:.375rem;-moz-border-radius-bottomright:.375rem;border-bottom-right-radius:.375rem;-webkit-border-top-right-radius:.375rem;-moz-border-radius-topv:.375rem;border-top-right-radius:.375rem}.day-container[selected=true] .button-container{border-left-color:#abab66;background-color:#f3f3d9}.day-container[selected=true] .info-container{background-color:#f9f9ec}.day-container[selected=true] .info-container .day-text{font-weight:bolder}.day-container[selected=true] .info-container:hover{background-color:#f7f7e5!important}.day-container[selected=false] .info-container:hover{background-color:#e6f0f6!important}.day-container .button-container{display:-webkit-box;display:-moz-box;display:-webkit-flexbox;display:-ms-flexbox;display:-webkit-flex;display:flex;-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;-webkit-box-align:center;-ms-flex-align:center;-webkit-align-items:center;-moz-align-items:center;align-items:center;padding:6px;border-right:1px solid #ccc;border-left:5px solid #ccc}.day-container .button-container cds-icon{margin:3px;cursor:pointer;color:#b3b3b3}.day-container .button-container cds-icon:hover{color:#666}.day-container .info-container{display:-webkit-box;display:-moz-box;display:-webkit-flexbox;display:-ms-flexbox;display:-webkit-flex;display:flex;-webkit-box-orient:vertical;-moz-box-orient:vertical;-webkit-flex-direction:column;-moz-flex-direction:column;-ms-flex-direction:column;flex-direction:column;-webkit-flex-grow:1;-webkit-box-flex:1;-moz-flex-grow:1;-ms-flex-positive:1;flex-grow:1;-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;padding:6px 12px;cursor:pointer}.day-container .info-container[timeline=true]{cursor:initial}.day-container .info-container .day-text{font-size:.756rem;line-height:.7rem;color:#0a2a5a;margin-bottom:3px}.day-container .info-container .timeline-container{margin:6px 0}.day-container .info-container .state-text{font-size:.588rem;line-height:.5rem;color:#666}.date-select-input{visibility:hidden;width:0;position:absolute;top:0;left:0}
`;var fe=function(l,e,t,n){var a=arguments.length,i=a<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(l,e,t,n);else for(var o=l.length-1;o>=0;o--)(s=l[o])&&(i=(a<3?s(i):a>3?s(e,t,i):s(e,t))||i);return a>3&&i&&Object.defineProperty(e,t,i),i},S=class{day;copyDaySelected=new O;state;stateText;stateRangesText;visibleTimeline=!1;copyDate=null;startMonthDate;endMonthDate;timelineSelection;timelineSelectionOptions={enableZoom:!1,firstRowMarginTop:15,lastRowMarginBottom:5};constructor(){}ngOnInit(){!this.day||!this.day.selectedDates||this.day.selectedDates.length==0?this.setState(d.NotSelected):this.day.selectedDates.length==1&&r.fromJSDate(this.day.selectedDates[0][0])==r.fromISO(this.day.day).startOf("day")&&r.fromJSDate(this.day.selectedDates[0][1])==r.fromISO(this.day.day).plus({days:1}).startOf("day")?this.setState(d.FullSelected):(this.setState(d.PartialSelected),this.refreshTimeline(!0)),this.startMonthDate=r.fromISO(this.day.day).startOf("month").toJSDate(),this.endMonthDate=r.fromISO(this.day.day).endOf("month").toJSDate(),this.copyDate=r.fromISO(this.day.day).toJSDate()}ngAfterContentInit(){}ngOnDestroy(){}ngOnChanges(e){e.day&&!e.day.isFirstChange()&&this.refreshTimeline(!0)}setState(e,t=null){switch(this.state=e,e){case d.FullSelected:this.day.selectedDates=[[r.fromISO(this.day.day).startOf("day").toJSDate(),r.fromISO(this.day.day).plus({days:1}).startOf("day").toJSDate()]],this.stateText="DATEPICKER.ALL_DAY_SELECTED",this.stateRangesText=null,this.visibleTimeline&&this.createRangeSelectionData();break;case d.NotSelected:this.day.selectedDates=[],this.stateText="DATEPICKER.ALL_DAY_NOT_SELECTED",this.stateRangesText=null;break;case d.PartialSelected:let n=[];if(t){let a=[];t.forEach(i=>{a.push([i[0].data.startHour,i[1].data.endHour]),n.push(r.fromJSDate(i[0].data.startHour).toFormat("HH:mm")+" - "+r.fromJSDate(i[1].data.endHour).toFormat("HH:mm"))}),this.day.selectedDates=a}else this.day.selectedDates.forEach(a=>{n.push(r.fromJSDate(a[0]).toFormat("HH:mm")+" - "+r.fromJSDate(a[1]).toFormat("HH:mm"))});this.stateText="DATEPICKER.SELECTED_RANGES",this.stateRangesText=n.join(", ");break}}refreshTimeline(e){e?this.timelineSelection||(this.createRangeSelectionData(),this.visibleTimeline=!0):(this.visibleTimeline=!1,this.timelineSelection=null)}createRangeSelectionData(){let e=new H,t=new B,n=1/24;for(let s=0;s<=24;s++){let o=new $;o.label=s+":00",o.pos=s*n,t.addItem(o)}e.addDivider(t);let a=new K;a.height=20,a.enableSelection=!0;let i=1/96;for(let s=0;s<96;s++){let o=new q;switch(o.data={startHour:r.fromISO(this.day.day).startOf("day").plus({minutes:s*15}).toJSDate(),endHour:r.fromISO(this.day.day).startOf("day").plus({minutes:(s+1)*15}).toJSDate()},o.hoverable=!0,o.startPos=s*i,o.endPos=(s+1)*i,o.selectedColor="#D6D67F",o.color="#DBDBD3",this.state){case d.FullSelected:o.selected=!0;break;case d.NotSelected:o.selected=!1;break;case d.PartialSelected:o.selected=this.isRangeSelected(o.data.startHour,o.data.endHour);break}a.addRange(o)}e.addRow(a),this.timelineSelection=e}isRangeSelected(e,t){let n=!1,a=w.fromDateTimes(r.fromJSDate(e),r.fromJSDate(t));return this.day.selectedDates.forEach(i=>{a.overlaps(w.fromDateTimes(r.fromJSDate(i[0]),r.fromJSDate(i[1])))&&(n=!0)}),n}onRangeClicked(e){}onRangeMouseEnter(e){}onRangeMouseLeave(e){}onSelectionUpdated(e){e.row.ranges.findIndex(t=>t.selected==!0)==-1?this.setState(d.NotSelected):e.row.ranges.findIndex(t=>t.selected==!1)==-1?this.setState(d.FullSelected):this.setState(d.PartialSelected,Y.getSelectedRanges(e.row.ranges))}onInfoContainerClicked(e){this.refreshTimeline(!0)}onAddClicked(e){this.setState(d.FullSelected)}onRemoveClicked(e){this.setState(d.NotSelected),this.refreshTimeline(!1)}onCopyDateChanged(e){this.copyDaySelected.emit(r.fromJSDate(e.value).toFormat("yyyy-MM-dd"))}static ctorParameters=()=>[];static propDecorators={day:[{type:C}],copyDaySelected:[{type:_}]}};S=fe([c({selector:"armon-pacs-timeline-range-selection-day",template:ie,standalone:!0,providers:[{provide:y,useClass:b}],imports:[f,x,h,U,G,u],styles:[oe]})],S);var d;(function(l){l[l.NotSelected=1]="NotSelected",l[l.PartialSelected=2]="PartialSelected",l[l.FullSelected=3]="FullSelected"})(d||(d={}));var ue=function(l,e,t,n){var a=arguments.length,i=a<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(l,e,t,n);else for(var o=l.length-1;o>=0;o--)(s=l[o])&&(i=(a<3?s(i):a>3?s(e,t,i):s(e,t))||i);return a>3&&i&&Object.defineProperty(e,t,i),i},v=class{selectedIndex=0;months=[];constructor(){}ngOnInit(){this.months.push(this.createMonth(r.local().startOf("month").toFormat("yyyy-MM")))}ngAfterContentInit(){}ngOnDestroy(){}getSelectedDays(){let e=[];return this.months.forEach(t=>{e.push(...t.days.filter(n=>n.selectedDates&&n.selectedDates.length>0))}),e}createMonth(e){let t=new T,n=r.fromISO(e).startOf("month"),a=n.daysInMonth;t.monthDate=n.toJSDate(),t.month=n.toFormat("yyyy-MM"),t.monthText=n.toFormat("MMMM yyyy");for(let i=0;i<a;i++){let s=new k;s.day=n.toFormat("yyyy-MM-dd"),s.dayText=n.toFormat("d MMMM"),s.weekdayText=n.toFormat("EEEE"),t.days.push(s),n=n.plus({days:1})}return t}changeMonth(e){let t;e==!0?t=r.fromJSDate(this.months[this.selectedIndex].monthDate).plus({months:1}).startOf("month").toFormat("yyyy-MM"):t=r.fromJSDate(this.months[this.selectedIndex].monthDate).minus({months:1}).startOf("month").toFormat("yyyy-MM");let n=this.months.findIndex(a=>a.month==t);n==-1?(this.months.push(this.createMonth(t)),this.selectedIndex=this.months.length-1):this.selectedIndex=n}onPrevMonthClicked(e){this.changeMonth(!1)}onNextMonthClicked(e){this.changeMonth(!0)}onCopyDaySelected(e,t){let n=this.months[this.selectedIndex].days.find(o=>o.day==e),a=this.months[this.selectedIndex].days.findIndex(o=>o.day==e),i=new k;i.day=n.day,i.dayText=n.dayText,i.weekdayText=n.weekdayText;let s=[];t.selectedDates.forEach(o=>{s.push([r.fromISO(n.day).set({hour:o[0].getHours(),minute:o[0].getMinutes()}).toJSDate(),t.day!=r.fromJSDate(o[1]).toFormat("yyyy-MM-dd")?r.fromISO(n.day).set({hour:o[1].getHours(),minute:o[1].getMinutes()}).plus({days:1}).toJSDate():r.fromISO(n.day).set({hour:o[1].getHours(),minute:o[1].getMinutes()}).toJSDate()])}),i.selectedDates=s,this.months[this.selectedIndex].days[a]=i}static ctorParameters=()=>[]};v=ue([c({selector:"armon-pacs-timeline-range-selection",template:te,standalone:!0,imports:[A,S],styles:[ne]})],v);var T=class{month;monthDate;monthText;days=[]},k=class{day;dayText;weekdayText;selectedDates=[]};var he=function(l,e,t,n){var a=arguments.length,i=a<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(l,e,t,n);else for(var o=l.length-1;o>=0;o--)(s=l[o])&&(i=(a<3?s(i):a>3?s(e,t,i):s(e,t))||i);return a>3&&i&&Object.defineProperty(e,t,i),i},ae=class{router;route;pacsService;interactionService;identitySelectionService;accessControlPointUserService;translate;modalService;rangeSelection;workplan;workplanDetail;hiddenRangeSelection=!0;hiddenDateSelection=!0;modeAdd;sessionId;numberOfEmployees;request=p.getEmptyModel();defaultStart;defaultEnd;constructor(e,t,n,a,i,s,o,se){this.router=e,this.route=t,this.pacsService=n,this.interactionService=a,this.identitySelectionService=i,this.accessControlPointUserService=s,this.translate=o,this.modalService=se}ngOnInit(){this.defaultStart=r.local().startOf("month").toJSDate(),this.defaultEnd=r.local().plus({months:1}).startOf("month").toJSDate()}ngOnDestroy(){}ngAfterViewInit(){this.route.queryParams.subscribe(e=>{e&&e[m.WorkplanId]&&e[m.WorkplanType]&&e.action?(this.modeAdd=e.action==1,this.getWorkplanDetail(e[m.WorkplanId],e[m.WorkplanType])):this.backClicked()})}getWorkplanDetail(e,t){this.pacsService.getWorkplanDetail(e,t).subscribe(n=>{this.workplanDetail=n;let a=new D;a.createInstance(this.workplanDetail,D,a),this.workplan=a})}applySession(){this.hiddenRangeSelection==!1&&(this.request.ranges=[],this.rangeSelection&&this.rangeSelection.getSelectedDays().forEach(e=>{e.selectedDates.forEach(t=>{let n=new g;n.startDateTime=t[0],n.endDateTime=t[1],this.request.ranges.push(n)})})),this.pacsService.applySessionWorkplan(this.sessionId,p.getRequestModel(this.request)).subscribe(e=>{this.backClicked(),this.checkAllowMobileCheckins()},e=>{e&&e.status&&e.status===j.Conflict&&this.interactionService.showDialog(this.modeAdd?"PACS.ADD_USER":"PACS.REMOVE_USER","PACS.WORKPLAN_ASSIGN_CONFLICT_INFO",null,{numberOfEmployees:this.numberOfEmployees},!0,"BUTTON.SAVE","",!1,()=>{this.request.enforce=!0,this.applySession()},()=>{this.request.enforce=!1})})}onSaveClicked(e){this.applySession()}backClicked(e=null){this.router.navigate([L.PACS_WORKPLANS.fullPath])}checkAllowMobileCheckins(){this.workplan.allowMobileCheckins&&this.accessControlPointUserService.checkUserSelectionVirtualMobileCheckin(this.workplan.id,!0)}getSessionIdForWorkplan(e){return this.identitySelectionService.getSessionForWorkplan(this.workplan.id,this.modeAdd,e)}onAddEmployeeClicked(e){this.modalService.open(Q,{settings:{size:"xl"},props:{editable:!0,sessionFunction:this.getSessionIdForWorkplan.bind(this),useCustomApply:!0,disableAdd:!this.modeAdd}}).result.then(t=>{t&&(this.numberOfEmployees=this.modeAdd?t.added:t.removed,this.sessionId=t.sessionId,this.hiddenDateSelection=!1)}).catch(t=>{})}onShowDaysClicked(e){this.hiddenRangeSelection=!1}onAfterPickerOpened(e){setTimeout(()=>{Array.from(document.getElementsByClassName("owl-dt-timer-input")).forEach(t=>{t.setAttribute("disabled","true")})},100)}static ctorParameters=()=>[{type:M},{type:R},{type:J},{type:W},{type:V},{type:Z},{type:z},{type:F}];static propDecorators={rangeSelection:[{type:E,args:["rangeSelection"]}]}};ae=he([c({selector:"armon-pacs-workplan-upsert-employee",template:X,standalone:!0,providers:[{provide:y,useClass:b}],imports:[f,h,x,I,v,u],styles:[ee]})],ae);export{ae as PacsWorkplanUpsertEmployeeComponent};
