import{a as S}from"./chunk-C7NDY7PV.js";import{a as y}from"./chunk-5OT2MLHH.js";import{a as W}from"./chunk-4IRXRL4C.js";import"./chunk-LAJI7RPC.js";import{a as D}from"./chunk-WFZJP5WR.js";import"./chunk-F6KLNSUK.js";import{a as E}from"./chunk-4MZCYQX4.js";import{b as J,c as V,d as K}from"./chunk-YOJ4KGSB.js";import"./chunk-I6FSQTEP.js";import"./chunk-CO3X7TQN.js";import{a as x}from"./chunk-VSFNMVXJ.js";import"./chunk-WQ6DP4JQ.js";import{J as b,Kb as Y,Ob as B,Ra as C,Sa as $,a as ae,c,d as U,h as M,i as P,l as j,o as L,wb as H}from"./chunk-YSQLW2JA.js";import"./chunk-NVJ2ZZFT.js";import{Aa as d,Dc as p,Fb as h,Mg as T,Ng as I,Te as z,Vc as w,Yg as F,ab as g,af as v,bb as f,bh as q,cd as k,dd as u,g as ne,gb as _,gg as s,hd as R,hg as A,jg as G,wa as N,ya as m}from"./chunk-SKPDQO4E.js";var X=`<div class="h-100">
  <side-navigation *ngIf="visibleComponent">
    <ng-template side-navigation-nav>
      <div class="row">
        <div class="col-12">
          <label class="report-form-label">{{'REPORT.REGION' | translate}}</label>
          <armon-select-search query="region" [allowMulti]="false" [(ngModel)]="filter.regionId"
            (onSelectedChanged)="onSelectedRegionChanged($event)">
          </armon-select-search>
        </div>
        <ng-container *ngIf="filter && filter.regionId">
          <div class="col-12" *ngIf="permissionSearchIdentity">
            <label class="report-form-label">{{'REPORT.IDENTITIES' | translate : languageService.userTranslate}}</label>
            <armon-select-search query="identity" [allowMulti]="true" [(ngModel)]="filter.userIds">
            </armon-select-search>
          </div>

          <div class="col-12" *ngIf="permissionSearchOrganizationUnit">
            <label class="report-form-label">{{'REPORT.ORGANIZATION_UNITS' | translate}}</label>
            <armon-select-search query="unit" [allowMulti]="true" [(ngModel)]="filter.organizationUnitIds">
            </armon-select-search>
            <label class="report-checkbox-label" nz-checkbox
              *ngIf="filter.organizationUnitIds && filter.organizationUnitIds.length > 0"
              [(ngModel)]="filter.applyOrganizationUnitFilterHierarchically">{{'REPORT.SHOW_HIERARCHICALLY' |
              translate}}</label>
          </div>
          <div class="col-12" *ngIf="permissionSearchUserGroup">
            <label class="report-form-label">{{'REPORT.USER_GROUPS' | translate :
              languageService.userTranslate}}</label>
            <armon-select-search query="group" [allowMulti]="true" [(ngModel)]="filter.userGroupIds">
            </armon-select-search>
          </div>
          <div class="col-12 mt-3">
            <label class="report-checkbox-label" nz-checkbox
              [(ngModel)]="filter.includePasses">{{'REPORT.REGION_INCLUDE_NON_DIRECTIONED' | translate}}</label>
          </div>
        </ng-container>
      </div>
      <!-- Buttons for filtering state -->
      <div class="row">
        <div class="col-12 d-flex justify-content-center column-gap-1 mt-3" *ngIf="filter && filter.regionId">
          <button class="btn btn-success btn-sm me-2" (click)="onGetExcelClicked($event)">{{'BUTTON.EXCEL' |
            translate}}</button>
          <button class="btn btn-primary btn-sm" (click)="onGetReportClicked($event)">{{'REPORT.GET_REPORT' |
            translate}}</button>
        </div>
      </div>
    </ng-template>
    <ng-template side-navigation-content>
      <div class="report-data-container">
        <div class="row report-filter-container">
          <div class="col-12">
            <div class="row">
              <div class="col-12">
                <armon-report-template-panel [reportType]="reportTemplateType" [filter]="filter"
                  [templateId]="reportTemplateId" [saveEnabled]="filter.regionId!=null"
                  (templateLoaded)="onTemplateLoaded($event)"></armon-report-template-panel>
              </div>
            </div>
          </div>
          <div class="col-12">
            <div class="row">
              <div class="col-12">
                <armon-date-picker [options]="datePickerOptions" (selectionChanged)="onDateSelectionChanged($event)"
                  [disabled]="filter.regionId == null">
                </armon-date-picker>
              </div>
            </div>
          </div>
          <div class="col-12">
            <div class="row">
              <div class="col-12">
                <armon-sorting-picker #sortingPicker [data]="sortingPickerData" [disabled]="filter.regionId == null"
                  (selectionChanged)="onSortingSelectionChanged($event)">
                </armon-sorting-picker>
              </div>
            </div>
          </div>
        </div>
        <div class="row mt-5" *ngIf="filter.regionId==null">
          <div class="col-12">
            <nz-empty [nzNotFoundContent]="contentTpl" [nzNotFoundImage]="'./assets/images/empty/search_generic.png'">
              <ng-template #contentTpl>
                <span>{{'REPORT.REGION_FILTER_INFO'|translate}}</span>
              </ng-template>
            </nz-empty>
          </div>
        </div>
        <div class="row pt-5" *ngIf="filter.regionId && items && items.length==0">
          <div class="col-12">
            <nz-empty [nzNotFoundContent]="contentTpl" [nzNotFoundImage]="'./assets/images/empty/empty_list.png'">
              <ng-template #contentTpl>
                <span>{{'COMMON.NO_DATA'|translate}}</span>
              </ng-template>
            </nz-empty>
          </div>
        </div>
        <div class="row report-data-table-container" id="report-data-table-container" *ngIf="items && items.length > 0">
          <div class="col-12">
            <p-table [value]="items" dataKey="user.id" [responsive]="true" rowExpandMode="single">
              <ng-template pTemplate="header">
                <tr>
                  <th>{{'IDENTITY.TITLE' | translate : languageService.userTranslate}}</th>
                  <th>{{'REPORT.REGION_DURATION' | translate}}</th>
                  <th>{{'REPORT.REGION' | translate}}</th>
                </tr>
              </ng-template>
              <ng-template pTemplate="body" let-item let-rowData let-expanded="expanded">
                <tr [pRowToggler]="rowData" [attr.expanded]="expanded" class="data-row">
                  <td>
                    <armon-captionlines [showBorder]="false" [captionlines]="item.user.captionLines">
                    </armon-captionlines>
                  </td>
                  <td>
                    <armon-duration-formatter [data]="item.durationData" [minimal]="false"
                      [className]="'color-primary-all'"></armon-duration-formatter>
                  </td>
                  <td>
                    <div class="report-multi-data-cell">
                      <span class="sub-text">{{region.name}}
                      </span>
                    </div>
                  </td>
                </tr>
              </ng-template>
              <ng-template pTemplate="rowexpansion" let-item>
                <tr>
                  <td [attr.colspan]="3" class="expanded-row">
                    <div class="d-flex flex-column p-2">
                      <armon-report-region-duration-detail [regionId]="filter.regionId" [userId]="item.user.id"
                        [range]="filter.range"
                        [includePasses]="filter.includePasses"></armon-report-region-duration-detail>
                    </div>
                  </td>
                </tr>
              </ng-template>
            </p-table>
          </div>
          <div class="col-12 mb-3 mt-3">
            <armon-pagination [paginationResponse]="paginationResponse" [scrollDomId]="'report-data-table-container'"
              (pageChanged)="pageChanged($event)"></armon-pagination>
          </div>
        </div>
      </div>
    </ng-template>
  </side-navigation>
</div>`;var Z=`.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 Q=`<ng-container *ngIf="visibleSpinner">
  <div class="row">
    <div class="col-12">
      <div class="spinner-grow spinner-grow-sm text-primary" role="status">
        <span class="sr-only"></span>
      </div>
    </div>
  </div>
</ng-container>
<ng-container *ngIf="!visibleSpinner">
  <div class="w-100">
    <div class="row report-data-table-container h-auto" id="report-data-table-container"
      *ngIf="items && items.length > 0">
      <div class="col-12">
        <p-table [value]="items" dataKey="id" [responsive]="true">
          <ng-template pTemplate="header">
            <tr>
              <th>{{'REPORT.REGION_DURATION' | translate}}</th>
              <th>{{'REPORT.REGION_START_DURATION' | translate}}</th>
              <th>{{'REPORT.REGION_END_DURATION' | translate}}</th>
            </tr>
          </ng-template>
          <ng-template pTemplate="body" let-item let-rowData let-expanded="expanded">
            <tr [pRowToggler]="rowData" [attr.expanded]="expanded" class="data-row">
              <td>
                <div class="d-flex align-items-center">
                  <armon-duration-formatter [data]="item.intersectionDurationData || item.durationData"
                    [minimal]="false" [className]="'color-primary-all me-0'"></armon-duration-formatter>
                  <ng-container *ngIf="item.intersectionDurationData">
                    <cds-icon shape="calendar" class="ms-1 cds-icon-16 text-secondary" nz-tooltip
                      nzTooltipTitle="{{'REPORT.REGION_INTERSECTION_DURATION'|translate}}"></cds-icon>
                  </ng-container>
                </div>
              </td>
              <td>
                <div class="report-multi-data-cell" *ngIf="item.start">
                  <span class="title-text">
                    <ng-template *ngTemplateOutlet="directionTemplate; context: {$implicit: item.start.direction}">
                    </ng-template>
                    {{item.start.intersectionUtc?item.start.intersectionHourText:item.start.actionHourText}}<armon-local-date
                      [dateUtc]="item.start.intersectionUtc?item.start.intersectionUtc:item.start.actionUtc"></armon-local-date>
                    <ng-container *ngIf="item.start.intersectionUtc">
                      <cds-icon shape="calendar" class="ms-2 cds-icon-16 text-secondary" nz-tooltip
                        nzTooltipTitle="{{'REPORT.REGION_INTERSECTION_TIME'|translate}}"></cds-icon>
                    </ng-container>
                  </span>
                  <span
                    class="sub-text">{{item.start.intersectionUtc?item.start.intersectionText:item.start.actionText}}</span>
                  <span class="sub-text"
                    *ngIf="item.start.accessControlPoint">{{item.start.accessControlPoint.name}}</span>
                </div>
              </td>
              <td>
                <div class="report-multi-data-cell" *ngIf="item.end">
                  <span class="title-text">
                    <ng-template *ngTemplateOutlet="directionTemplate; context: {$implicit: item.end.direction}">
                    </ng-template>
                    {{item.end.intersectionUtc?item.end.intersectionHourText:item.end.actionHourText}}<armon-local-date
                      [dateUtc]="item.end.intersectionUtc?item.end.intersectionUtc:item.end.actionUtc"></armon-local-date>
                    <ng-container *ngIf="item.end.intersectionUtc">
                      <cds-icon shape="calendar" class="ms-2 cds-icon-16 text-secondary" nz-tooltip
                        nzTooltipTitle="{{'REPORT.REGION_INTERSECTION_TIME'|translate}}"></cds-icon>
                    </ng-container>
                  </span>
                  <span
                    class="sub-text">{{item.end.intersectionUtc?item.end.intersectionText:item.end.actionText}}</span>
                  <span class="sub-text" *ngIf="item.end.accessControlPoint">{{item.end.accessControlPoint.name}}</span>
                </div>
              </td>
            </tr>
          </ng-template>
        </p-table>
      </div>
      <div class="col-12 mb-3 mt-3">
        <armon-pagination [paginationResponse]="paginationResponse"
          (pageChanged)="pageChanged($event)"></armon-pagination>
      </div>
    </div>
  </div>
</ng-container>

<ng-template #directionTemplate let-direction>
  @switch (direction) {
  @case (0) {
  <cds-icon shape="switch" class="me-1 cds-icon-16 text-primary" nz-tooltip
    nzTooltipTitle="{{'DIRECTIONTYPE.PASS'|translate}}"></cds-icon>
  }
  @case (1) {
  <cds-icon shape="login" class="me-1 cds-icon-16 text-primary" nz-tooltip
    nzTooltipTitle="{{'DIRECTIONTYPE.ENTRANCE'|translate}}"></cds-icon>
  }
  @case (2) {
  <cds-icon shape="logout" class="me-1 cds-icon-16 text-primary" nz-tooltip
    nzTooltipTitle="{{'DIRECTIONTYPE.EXIT'|translate}}"></cds-icon>
  }
  @default {
  <cds-icon shape="switch" class="me-1 cds-icon-16 text-primary" nz-tooltip
    nzTooltipTitle="{{'DIRECTIONTYPE.PASS'|translate}}"></cds-icon>
  }
  }
</ng-template>`;var ee=`.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 ce=function(o,e,t,n){var a=arguments.length,i=a<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(o,e,t,n);else for(var l=o.length-1;l>=0;l--)(r=o[l])&&(i=(a<3?r(i):a>3?r(e,t,i):r(e,t))||i);return a>3&&i&&Object.defineProperty(e,t,i),i},O=class{route;reportService;languageService;regionId;userId;range;includePasses=!1;filter;items;visibleSpinner=!0;paginationResponse=new I;paginationRequest=new T;constructor(e,t,n){this.route=e,this.reportService=t,this.languageService=n}ngOnInit(){this.filter=$.getEmptyModel(),this.filter.range=this.range,this.filter.includePasses=this.includePasses,this.fetchReportData()}ngAfterViewInit(){}ngOnDestroy(){}fetchReportData(){this.reportService.getRegionDurationReportDetail(this.regionId,this.userId,this.filter,!1).subscribe(e=>{this.items=e.items,this.paginationResponse=e.pagination,this.visibleSpinner=!1})}refreshReportData(e=!0){e&&(this.filter.pagination.skip=0),this.fetchReportData()}pageChanged(e){this.filter.pagination=e,this.refreshReportData(!1)}static ctorParameters=()=>[{type:h},{type:b},{type:v}];static propDecorators={regionId:[{type:d}],userId:[{type:d}],range:[{type:d}],includePasses:[{type:d}]}};O=ce([m({selector:"armon-report-region-duration-detail",template:Q,standalone:!0,imports:[f,_,u,g,y,E,F,D,x,S,W],styles:[ee]})],O);var ie=ne(ae());var pe=function(o,e,t,n){var a=arguments.length,i=a<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(o,e,t,n);else for(var l=o.length-1;l>=0;l--)(r=o[l])&&(i=(a<3?r(i):a>3?r(e,t,i):r(e,t))||i);return a>3&&i&&Object.defineProperty(e,t,i),i},te=class{route;authService;reportService;translate;languageService;filter;items;region;selectedRegion;visibleComponent=!1;reportTemplateType=U.RegionDuration;reportTemplateId;paginationResponse=new I;paginationRequest=new T;permissionSearchUserGroup;permissionSearchIdentity;permissionSearchOrganizationUnit;datePickerOptions=new A;sortingPicker;sortingPickerData;constructor(e,t,n,a,i){this.route=e,this.authService=t,this.reportService=n,this.translate=a,this.languageService=i}ngOnInit(){this.permissionSearchIdentity=this.authService.checkPermission(R.IDENTITY.getReadBasic()),this.permissionSearchOrganizationUnit=this.authService.checkPermission(R.ORGANIZATIONUNIT.getReadBasic()),this.permissionSearchUserGroup=this.authService.checkPermission(R.USERGROUP.getRead()),this.filter=C.getEmptyModel(),this.datePickerOptions.items=[{type:s.Today,selected:!0},{type:s.Yesterday},{type:s.SelectDay,max:p.local().endOf("day").toJSDate()},{type:s.CurrentWeek,hasDivider:!0},{type:s.PreviousWeek},{type:s.SelectMonth,hasDivider:!0},{type:s.CustomWithTimer,maxDays:31}],this.setDateSelection(G.getDateSelection(this.datePickerOptions.items[0])),this.sortingPickerData={items:[{value:1,label:"REPORT.SORTING_USERNAME",showDirection:!0,selected:!0,isAlpha:!0,directionDefault:P.ASC},{value:2,label:"REPORT.SORTING_DURATION",showDirection:!0,isAlpha:!0,directionDefault:P.ASC}]},this.setSortingSelection(this.sortingPickerData.items[0].value,w.ASC),this.visibleComponent=!0}ngAfterViewInit(){this.route.queryParams.subscribe(e=>{e&&(e[c.RegionId]&&e[c.RegionId]!=""&&(this.filter.regionId=e[c.RegionId]),e[c.ReportTemplateId]&&e[c.ReportTemplateId]!=""&&(this.reportTemplateId=e[c.ReportTemplateId]),this.filter.regionId&&this.fetchReportData())})}ngOnDestroy(){}setDateSelection(e){this.filter.range.start=e.startDate,this.filter.range.end=e.endDate}fetchReportData(){this.filter.regionId&&this.reportService.getRegionDurationReport(this.filter).subscribe(e=>{this._templateLoading=!1,this.items=e.items,this.region=e.region,this.paginationResponse=e.pagination})}refreshReportData(e=!0){e&&(this.filter.pagination.skip=0),this.fetchReportData()}onGetReportClicked(e){this.refreshReportData()}onGetExcelClicked(e){this.filter.regionId&&this.reportService.getRegionDurationReportAsExcel(this.filter).subscribe(t=>{this.translate.get(["PAGES.REPORT_REGION_DURATION"]).subscribe(n=>{ie.default.saveAs(t,n["PAGES.REPORT_REGION_DURATION"]+" "+this.selectedRegion.captionLines[0]+" "+p.fromJSDate(this.filter.range.start).toLocaleString(p.DATETIME_MED)+" "+p.fromJSDate(this.filter.range.end).toLocaleString(p.DATETIME_MED)+".xlsx")})})}pageChanged(e){this.filter.pagination=e,this.refreshReportData(!1)}onDateSelectionChanged(e){this.setDateSelection(e),this.refreshReportData()}setSortingSelection(e,t){this.filter.sortField=e,this.filter.sortType=t=="DESC"?1:2}onSortingSelectionChanged(e){this.setSortingSelection(e.value,e.direction),this.refreshReportData()}_templateLoading=!1;onTemplateLoaded(e){if(this._templateLoading=!0,e.filter){let t=C.getEmptyModel();t.range=this.filter.range,t.sortField=this.filter.sortField,t.sortType=this.filter.sortType,Object.assign(t,e.filter),this.filter=t}setTimeout(()=>{this.refreshReportData()},1e3)}onSelectedRegionChanged(e){e?.data&&(this.selectedRegion=e.data,this.filter.regionId=this.selectedRegion.id,this.filter.regionId&&this._templateLoading==!1&&this.refreshReportData())}static ctorParameters=()=>[{type:h},{type:B},{type:b},{type:k},{type:v}];static propDecorators={sortingPicker:[{type:N,args:["sortingPicker"]}]}};te=pe([m({selector:"armon-report-region-duration",template:X,standalone:!0,imports:[f,K,J,z,u,g,H,L,V,j,M,Y,q,y,E,D,x,S,O],styles:[Z]})],te);export{te as ReportRegionDurationComponent};
