import{a as Z}from"./chunk-LMQQ766H.js";import{a as E,b as q,c as X,d as Y,e as K,f as Q,g as ee}from"./chunk-SYO4PMIS.js";import{a as $}from"./chunk-IOLBSI3Y.js";import{a as V}from"./chunk-RBSSJWML.js";import{a as B}from"./chunk-C7NDY7PV.js";import{J as A,f as _,g as N,la as k}from"./chunk-YSQLW2JA.js";import{hc as J,ja as x,ra as ce,w as y,x as U}from"./chunk-NVJ2ZZFT.js";import{Aa as v,Ba as j,Bc as I,Cc as H,Dc as d,Pd as h,Qf as u,Rd as z,Vc as L,W as w,ab as T,bb as g,dd as R,fb as S,g as de,ha as W,hd as F,ya as f}from"./chunk-SKPDQO4E.js";var te=`<ng-container *ngIf="gridMonth">\r
    <div class="row" *ngIf="onlyOneWorkplanVisible">\r
        <div class="col-12">\r
            <div class="border border-1 rounded-1 py-2 px-3 text-sm bg-white">\r
                <span class="text-bold">{{onlyOneWorkplanName}}</span><span\r
                    class="ms-2">({{onlyOneWorkplanRange|translate}})</span>\r
            </div>\r
        </div>\r
    </div>\r
    <div class="row">\r
        <div class="col-12">\r
            <app-grid-wrapper-component [grid]="gridMonth" [options]="gridMonthOptions"\r
                (onCellMouseEnter)="onCellMouseEnter($event)" (onCellMouseLeave)="onCellMouseLeave($event)"\r
                (onCellClicked)="onCellClicked($event)" (onRangeMouseEnter)="onGridRangeMouseEnter($event)"\r
                (onRangeMouseLeave)="onGridRangeMouseLeave($event)" (onRangeClicked)="onGridRangeClicked($event)"\r
                (onLabelClicked)="onGridLabelClicked($event)"></app-grid-wrapper-component>\r
        </div>\r
    </div>\r
</ng-container>`;var oe=`.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}
`;var b=class extends E{height=8;showRangeLine=!1;rangeLineColor="#CCC";_ranges;addRange(e){this._ranges||(this._ranges=[]),this._ranges.push(e)}get ranges(){return this._ranges}get hasRange(){return this._ranges&&this._ranges.length>0}};var re=de(ce());var C=class extends E{startPos;endPos;clickable=!1;hoverable=!1;disable=!1;data;selected=!1;_color;_hoverColor;get color(){return this._color}set color(e){this._color=e;let t=(0,re.default)(this._color);this._hoverColor=t.isDark()?t.lighten(.3).hex():t.darken(.3).hex()}get hoverColor(){return this._hoverColor}constructor(){super()}};var ae=`<div class="tooltip-container p-3">\r
  <div class="row">\r
    <div class="col-12">\r
      <div class="d-flex flex-column">\r
        <span class="text-md text-bold">{{dayText}}</span>\r
        <ng-container *ngIf="record">\r
          <armon-pacs-user-score class="my-2" [score]="record.score?record.score:0"></armon-pacs-user-score>\r
        </ng-container>\r
      </div>\r
    </div>\r
  </div>\r
  <div class="row mb-2" *ngIf="workingHours && workingHours.length > 0">\r
    <div class="col-12 d-flex flex-column py-2">\r
      <ng-container *ngFor="let workingHour of workingHours">\r
        <span class="text-sm">{{workingHour.workPlanName}}</span>\r
        <span class="text-xs">\r
          <div class="workplan-dot me-1" [ngStyle]="{'background-color': '#'+workingHour.colorCode}"></div>\r
          {{workingHour.startDateText}} - {{workingHour.endDateText}}\r
        </span>\r
      </ng-container>\r
    </div>\r
  </div>\r
  <div class="row" *ngIf="durationData">\r
    <div class="col-12">\r
      <div class="row">\r
        <ng-container *ngFor="let duration of durationData">\r
          <div class="col-6" *ngIf="duration && duration.minutes && duration.minutes>0">\r
            <armon-duration-formatter [data]="duration" [minimal]="true"></armon-duration-formatter>\r
          </div>\r
        </ng-container>\r
      </div>\r
    </div>\r
  </div>\r
</div>`;var ie=`.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}.tooltip-container{width:240px;background-color:#f5f5f5;-webkit-border-radius:.375rem;-moz-border-radius:.375rem;border-radius:.375rem}.tooltip-container .workplan-dot{display:inline-block;width:8px;height:8px;-webkit-border-radius:.375rem;-moz-border-radius:.375rem;border-radius:.375rem}
`;var he=function(c,e,t,o){var s=arguments.length,r=s<3?e:o===null?o=Object.getOwnPropertyDescriptor(e,t):o,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(c,e,t,o);else for(var p=c.length-1;p>=0;p--)(n=c[p])&&(r=(s<3?n(r):s>3?n(e,t,r):n(e,t))||r);return s>3&&r&&Object.defineProperty(e,t,r),r},M=class{interactionService;sessionService;popoverRef;record;durationData;workingHours;dayText;constructor(e,t,o){this.interactionService=e,this.sessionService=t,this.popoverRef=o,o&&(o.data.event.data.dailyRecord&&(this.record=o.data.event.data.dailyRecord,this.durationData=this.record.getDurationData()),o.data.event.data.workingHours&&(this.workingHours=o.data.event.data.workingHours),this.dayText=d.fromISO(o.data.event.data.day).toLocaleString(d.DATE_HUGE))}ngOnInit(){}static ctorParameters=()=>[{type:u},{type:h},{type:_,decorators:[{type:w}]}]};M=he([f({selector:"armon-pacs-calendar-grid-employee-tooltip",template:ae,standalone:!0,imports:[g,V,T,S,B],styles:[ie]})],M);var P={WIDTH:240};var ne=`<div class="tooltip-container py-2 px-3" [ngStyle]="{'border-left-color': data.color}">
  <div class="row" *ngIf="data.titles && data.titles.length > 0">
    <div class="col-12 b-b-1 pb-1 mb-1">
      <ng-container *ngFor="let title of data.titles">
        <span class="text-sm text-bold">{{title|translate}}</span>
      </ng-container>
    </div>
  </div>
  <div class="row" *ngIf="data.subTitles && data.subTitles.length> 0">
    <div class="col-12">
      <ng-container *ngFor="let subTitle of data.subTitles">
        <span class="text-sm">{{subTitle|translate}}</span>
      </ng-container>
    </div>
  </div>
</div>`;var se=`.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}.tooltip-container{width:240px;background-color:#f5f5f5;-webkit-border-radius:.375rem;-moz-border-radius:.375rem;border-radius:.375rem;border-left:4px solid #CCC}
`;var xe=function(c,e,t,o){var s=arguments.length,r=s<3?e:o===null?o=Object.getOwnPropertyDescriptor(e,t):o,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(c,e,t,o);else for(var p=c.length-1;p>=0;p--)(n=c[p])&&(r=(s<3?n(r):s>3?n(e,t,r):n(e,t))||r);return s>3&&r&&Object.defineProperty(e,t,r),r},O=class{interactionService;sessionService;popoverRef;data;constructor(e,t,o){this.interactionService=e,this.sessionService=t,this.popoverRef=o,o&&o.data&&(this.data=o.data.data)}ngOnInit(){}static ctorParameters=()=>[{type:u},{type:h},{type:_,decorators:[{type:w}]}]};O=xe([f({selector:"armon-generic-tooltip",template:ne,standalone:!0,imports:[S,g,T,R],styles:[se]})],O);var G={WIDTH:240};var ve=function(c,e,t,o){var s=arguments.length,r=s<3?e:o===null?o=Object.getOwnPropertyDescriptor(e,t):o,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(c,e,t,o);else for(var p=c.length-1;p>=0;p--)(n=c[p])&&(r=(s<3?n(r):s>3?n(e,t,r):n(e,t))||r);return s>3&&r&&Object.defineProperty(e,t,r),r},le=class{modalService;interactionService;sessionService;reportService;popoverService;userId;view="month";selectedMonth;selectedDay;onUserCaptionUpdated=new W;visibleComponent=!1;gridMonth;selectedText;selectedDateTime;selectedStartDateTime;selectedEndDateTime;selectedUserCaptions;onlyOneWorkplanVisible=!1;onlyOneWorkplanName;onlyOneWorkplanRange;gridMonthOptions={fontFamily:"Poppins",paddingX:0,cellHeight:110};constructor(e,t,o,s,r){this.modalService=e,this.interactionService=t,this.sessionService=o,this.reportService=s,this.popoverService=r}ngOnInit(){this.getEmployeeSummary(this.userId)}ngOnChanges(e){e.userId&&!e.userId.isFirstChange()&&this.getEmployeeSummary(this.userId),e.selectedMonth&&!e.selectedMonth.isFirstChange()&&this.getEmployeeSummary(this.userId),e.selectedDay&&!e.selectedDay.isFirstChange()&&this.getEmployeeSummary(this.userId)}setDates(){switch(this.view){case"month":this.selectedMonth||(this.selectedMonth=d.local().toFormat("yyyy-MM")),this.selectedDateTime=d.fromISO(this.selectedMonth),this.selectedText=this.selectedDateTime.toFormat("LLLL yyyy"),this.selectedStartDateTime=this.selectedDateTime.startOf("month").startOf("week"),this.selectedEndDateTime=this.selectedDateTime.endOf("month").endOf("week");break;case"day":this.selectedDay||(this.selectedDay=d.local().toFormat("yyyy-MM-dd")),this.selectedDateTime=d.fromISO(this.selectedDay),this.selectedText=this.selectedDateTime.toFormat("LLLL yyyy"),this.selectedStartDateTime=this.selectedDateTime.startOf("week"),this.selectedEndDateTime=this.selectedDateTime.endOf("week");break}}getEmployeeSummary(e){if(this.setDates(),this.popoverService.closeAll(),this.userId){let t=J.getEmptyModel();t.userId=e,t.dateRange.startDateTime=this.selectedStartDateTime.toFormat("yyyy-MM-dd"),t.dateRange.endDateTime=this.selectedEndDateTime.toFormat("yyyy-MM-dd"),t.sortType=U.Date,t.sortOrder=L.DESC,t.paginationRequest.skip=0,t.paginationRequest.take=50,this.reportService.getPacsWorkingDetailEmployee(t).subscribe(o=>{this.selectedUserCaptions=o.userCaption,this.onUserCaptionUpdated.emit(o.userCaption),this.reportService.getPacsUserWorkplan(this.userId,t.dateRange).subscribe(s=>{this.createGridMonthData(o.items,s.workingSchedule,s.memberships,s.holidays)})})}}createGridMonthData(e,t,o,s){let r=new q;H.weekdays().forEach(i=>{let a=new X;a.title=i,r.addColumn(a)});for(var n=this.selectedStartDateTime;n<this.selectedEndDateTime;){let i=new Y;switch(i.data={day:n.toFormat("yyyy-MM-dd"),dayDateTime:n},i.title=n.toFormat("d"),i.subTitle=n.toFormat("EEEE"),this.view){case"month":i.bgColor=n.toFormat("yyyy-MM")==this.selectedMonth?"#fdfdfd":"#ededed",i.opacity=n.toFormat("yyyy-MM")==this.selectedMonth?1:.4;break;case"day":i.bgColor=n.toFormat("yyyy-MM-dd")==this.selectedDay?"#d4ffcc":"#fdfdfd",i.opacity=1;break}if(i.clickable=!0,e){let a=e.find(l=>l.day==i.data.day);if(a&&(i.data.dailyRecord=a,a.noRecord==!1)){let l=new Q,m=1440-(a.missingWorkDuration+a.normalWorkDuration+a.accountedOffTimePermissionDuration+a.extraWorkDuration);l.addValue(a.missingWorkDuration,x.getColor(!1,y.AtWorkingHours)),l.addValue(a.normalWorkDuration,x.getColor(!0,y.AtWorkingHours)),l.addValue(a.accountedOffTimePermissionDuration,x.getColor(!1,y.AtOffTimePermission)),l.addValue(a.extraWorkDuration,x.getColor(!0,y.AtOutOfWorkingHours)),l.addValue(m,x.getColor(!1,y.AtOutOfWorkingHours)),i.addPercentageChart(l)}}t&&(i.data.workingHours=[],t.forEach(a=>{a.workingHours&&a.workingHours.length>0&&a.workingHours.forEach(l=>{(d.fromJSDate(l.range.startDateTime).toFormat("yyyy-MM-dd")==i.data.day||d.fromJSDate(l.range.endDateTime).toFormat("yyyy-MM-dd")==i.data.day)&&i.data.workingHours.push(l)})}));var p=I.fromDateTimes(n,n.plus({days:1}));s.forEach(a=>{p.intersection(I.fromDateTimes(d.fromJSDate(a.originalRange.startDateTime),d.fromJSDate(a.originalRange.endDateTime)))&&i.addLabel(new K(a.name,"#a4289e"))}),r.addCell(i),n=n.plus({days:1})}let D=r.cellCount*864e5;if(o&&(this.onlyOneWorkplanVisible=!1,o.length==1&&o[0].ranges&&o[0].ranges.length==1&&this.selectedStartDateTime>=d.fromJSDate(o[0].ranges[0].intersectingRange.startDateTime)&&this.selectedEndDateTime<=d.fromJSDate(o[0].ranges[0].intersectingRange.endDateTime)&&(this.onlyOneWorkplanVisible=!0,this.onlyOneWorkplanName=o[0].workPlanName,this.onlyOneWorkplanRange=o[0].ranges[0].membershipRangeText),this.onlyOneWorkplanVisible==!1)){let i=new b;i.height=4,o.forEach(a=>{a.ranges&&a.ranges.length>0&&a.ranges.forEach(l=>{let m=new C;m.clickable=!0,m.startPos=k.getPercantageForDateTimes(this.selectedStartDateTime,d.fromJSDate(l.intersectingRange.startDateTime),D),m.endPos=k.getPercantageForDateTimes(this.selectedStartDateTime,d.fromJSDate(l.intersectingRange.endDateTime),D),m.color=a.color,m.data={membership:l,workplanMembership:a},i.addRange(m)})}),r.addRangeRow(i)}if(t){let i=new b;i.height=8,i.rangeLineColor="#BBBBBB",i.showRangeLine=!0,t.forEach(a=>{a.workingHours&&a.workingHours.length>0&&a.workingHours.forEach(l=>{let m=new C;m.clickable=!1,m.startPos=k.getPercantageForDateTimes(this.selectedStartDateTime,d.fromJSDate(l.range.startDateTime),D),m.endPos=k.getPercantageForDateTimes(this.selectedStartDateTime,d.fromJSDate(l.range.endDateTime),D),m.color="#"+l.colorCode,m.data={workingHour:l},i.addRange(m)})}),r.addRangeRow(i)}this.gridMonth=r}popoverReference;onCellClicked(e){this.popoverService.closeAll(),F.ATTENDANCEPLAN.getWrite()&&d.now().startOf("day")<d.fromISO(e.data.day)?this.modalService.open(Z,{settings:{size:"xxxl",centered:!1,scrollable:!0},props:{day:e.data.day,userId:this.userId,userCaptions:this.selectedUserCaptions}}).result.then(t=>{this.getEmployeeSummary(this.userId)}).catch(t=>{}):this.modalService.open($,{settings:{size:"xl"},props:{userId:this.userId,dayDateTime:e.data.dayDateTime,dailyRecord:e.data.dailyRecord?e.data.dailyRecord:null,workingHours:e.data.workingHours?e.data.workingHours:null}}).result.then(t=>{}).catch(t=>{})}onCellMouseEnter(e){this.popoverReference=this.popoverService.openGlobalPositon({content:M,width:P.WIDTH,height:0,left:e.posX-P.WIDTH-10,top:e.posY-10,data:{event:e}})}onCellMouseLeave(e){this.popoverReference&&this.popoverReference.close()}onGridRangeClicked(e){}onGridRangeMouseEnter(e){if(e.data.membership){let t={titles:[e.data.workplanMembership.workPlanName],subTitles:[e.data.membership.membershipRangeText],color:e.data.workplanMembership.color};this.popoverReference=this.popoverService.openGlobalPositon({content:O,width:G.WIDTH,height:0,left:e.posX-G.WIDTH-10,top:e.posY-10,data:{data:t}})}}onGridRangeMouseLeave(e){this.popoverReference&&this.popoverReference.close()}onGridLabelClicked(e){}static ctorParameters=()=>[{type:z},{type:u},{type:h},{type:A},{type:N}];static propDecorators={userId:[{type:v}],view:[{type:v}],selectedMonth:[{type:v}],selectedDay:[{type:v}],onUserCaptionUpdated:[{type:j}]}};le=ve([f({selector:"armon-pacs-calendar-grid-employee",template:te,standalone:!0,imports:[g,ee,R],styles:[oe]})],le);export{le as a};
