import{a as V}from"./chunk-FGMGXMBG.js";import{a as Z}from"./chunk-5OT2MLHH.js";import{a as H}from"./chunk-4IRXRL4C.js";import"./chunk-LAJI7RPC.js";import{a as F}from"./chunk-WFZJP5WR.js";import"./chunk-F6KLNSUK.js";import{a as Y}from"./chunk-4MZCYQX4.js";import{b as q,c as B,d as $}from"./chunk-YOJ4KGSB.js";import"./chunk-I6FSQTEP.js";import"./chunk-CO3X7TQN.js";import{a as j}from"./chunk-VSFNMVXJ.js";import"./chunk-WQ6DP4JQ.js";import{J as _,Kb as U,Ob as L,a as ee,c as r,d as w,h as O,i as s,m as k,o as C,pb as G,wb as M}from"./chunk-YSQLW2JA.js";import{Cc as z,K as m}from"./chunk-NVJ2ZZFT.js";import{Dc as p,Fb as b,Mg as A,Ng as P,Pb as v,Qf as y,Te as I,Vc as x,ab as h,af as E,bb as u,bh as D,cd as S,dd as T,eh as N,fb as R,g as J,hd as d,wa as f,ya as g}from"./chunk-SKPDQO4E.js";var K=`<div class="h-100">
  <side-navigation #sideNavigation>
    <ng-template side-navigation-nav>
      <div>
        <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"
              (ngModelChange)="onRegionChanged($event)">
            </armon-select-search>
          </div>
          <ng-container *ngIf="filter && filter.regionId">
            <div class="col-12">
              <label class="report-form-label">{{'REPORT.STATUS' | translate}}</label>
              <nz-select class="w-100" [(ngModel)]="filter.state" nzMode="multiple"
                nzPlaceHolder="{{'COMMON.ALL'|translate}}" nzSize="small">
                <nz-option *ngFor="let option of stateTypes" [nzValue]="option.type" [nzLabel]="option.description |
                  translate"></nz-option>
              </nz-select>
            </div>
            <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="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" *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 mt-2">
              <label class="report-form-label">{{'REPORT.USER_STATUS' | translate}}</label>
              <armon-identity-status [(ngModel)]="filter.status"></armon-identity-status>
            </div>
          </ng-container>
        </div>

        <!-- Buttons for filtering state -->
        <div class="centered filterButtons">
          <button class="btn btn-success btn-sm me-2" (click)="onGetExcelClicked($event)"
            *ngIf="records">{{'BUTTON.EXCEL'
            | translate}}</button>
          <button class="btn btn-primary btn-sm" (click)="onGetReportClicked($event)"
            *ngIf="filter.regionId">{{'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" style="min-height:0;">
            <armon-report-template-panel [reportType]="reportTemplateType" [filter]="filter"
              [templateId]="reportTemplateId" [saveEnabled]="filter && filter.regionId"
              (templateLoaded)="onTemplateLoaded($event)"></armon-report-template-panel>
          </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>
        <!-- REGIONCAPACITY -->
        <!-- <div class="mx-0 d-flex bg-white align-items-center shadow-box-1 px-3 py-2 my-2" *ngIf="selectedRegionDetailed && filter">
          <div class="flex-grow-1 d-flex">
            <span class="text-md"><cds-icon shape="region" size="md" class="region-icon me-2">
            </cds-icon>{{selectedRegionDetailed.name}}</span>
          </div>
          <div class="d-flex flex-column justify-content-end me-4 ms-2 b-l-1 ps-3">
            <span class="text-sm">{{'REGION.STATE_IN'|translate}}</span>
            <span class="text-xl fw-medium">{{selectedRegionDetailed.inRegionCount}}</span>
          </div>
          <div class="d-flex flex-column justify-content-end me-4 ms-2 b-l-1 ps-3" *ngIf="selectedRegionDetailed.capacity">
            <span class="text-sm">{{'REGION.CAPACITY_RATIO'|translate}}</span>
            <span class="text-xl fw-medium"
              [ngClass]="{'text-danger': (selectedRegionDetailed.capacityPercentage>90)}">%{{selectedRegionDetailed.capacityPercentage}}</span>
          </div>
        </div> -->
        <div class="row mt-5" *ngIf="!records">
          <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 report-data-table-container" id="report-data-table-container" *ngIf="records">
          <div class="col-12">
            <p-table [value]="records" dataKey="user.id" [responsive]="true" rowExpandMode="single">
              <ng-template pTemplate="header">
                <tr>
                  <th>{{'REPORT.REGION_STATE_HEADER_FULLNAME' | translate}}</th>
                  <th>{{'REPORT.REGION_STATE_HEADER_ACCESS_POINT' | translate}}</th>
                  <th>{{'REPORT.REGION_STATE_HEADER_LAST_ACTION' | translate}}</th>
                  <th>{{'REPORT.REGION_STATE_HEADER_STATUS' | translate}}</th>
                </tr>
              </ng-template>
              <ng-template pTemplate="body" let-record let-rowData let-expanded="expanded">
                <tr [pRowToggler]="rowData" [attr.expanded]="expanded" class="data-row">
                  <td>
                    <armon-captionlines *ngIf="record.userCaptions" [showBorder]="false"
                      [captionlines]="record.userCaptions"></armon-captionlines>
                  </td>
                  <td>
                    <span class="main-text">{{(record.accessControlPoint ? record.accessControlPoint.name : '')}}</span>
                  </td>
                  <td>
                    <div class="report-multi-data-cell" *ngIf="record.lastActionUtc">
                      <span class="title-text">{{record.lastActionUtcHourText}}<armon-local-date
                          [dateUtc]="record.lastActionUtc"></armon-local-date></span>
                      <span class="sub-text">{{record.lastActionUtcText}}</span>
                    </div>
                  </td>
                  <td>
                    <span class="d-flex resultItemStatus">
                      <div [ngStyle]="{background: record.stateColor}"></div>
                      {{record.stateDescription | translate}}
                    </span>
                  </td>
                </tr>
              </ng-template>
              <ng-template pTemplate="rowexpansion" let-record>
                <tr>
                  <td [attr.colspan]="4" class="expanded-row">
                    <div class="py-1">
                      <button class="btn btn-sm btn-outline-danger" (click)="onRemoveStateClicked(record)"
                        [disabled]="!record.state">{{'REGION.REMOVE_STATE'
                        | translate}}</button>
                    </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 Q=`.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}.filterArea{background:#fff;border:1px solid rgb(235,235,235);padding:12px;border-radius:4px;box-shadow:0 3px 6px #ebebeb;-moz-transition:width .25s ease;-webkit-transition:width .25s ease;-o-transition:width .25s ease;transition:width .25s ease}.filterArea>div:first-child>p:first-child{margin-top:0}.filterSummary>p:first-child{margin-top:0}.filterContent>div{margin-bottom:12px}.filterContent clr-checkbox{margin-top:12px}.filterButtons{margin-top:12px}.filterSmallButtons>button:last-child{margin-right:0!important}.filterMoreInfo p{margin-top:0}.filterMoreInfo div{margin-bottom:8px}.filterMoreInfo div:last-child{margin-bottom:0}.resultArea{position:relative}.resultDisabled{position:absolute;width:100%;height:100%;background:linear-gradient(to top,#f3f4f6,transparent 150%)}.required:after{content:"*";font-size:1.1em;color:#c92100;margin-left:6px}.report-data-container{height:100%;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}.report-data-container .report-filter-container{margin-bottom:.2rem}.report-data-container .report-data-table-container{overflow-y:auto;overflow-x:hidden;-webkit-flex-grow:1;-webkit-box-flex:1;-moz-flex-grow:1;-ms-flex-positive:1;flex-grow:1;height:0;display:block}.report-multi-data-cell{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;line-height:initial!important}.report-multi-data-cell .title-text{font-size:1.008rem}.report-multi-data-cell .main-text{font-size:.84rem}.report-multi-data-cell .sub-text{font-size:.672rem;color:#aaa}.report-form-label{font-size:.672rem;line-height:.84rem;font-weight:500;margin-top:.3rem;margin-bottom:.1rem!important}.report-form-label label{margin-bottom:0!important}.report-form-icon{position:absolute;color:#0a2a5a;right:15px;bottom:6px;cursor:pointer}.report-checkbox-label{font-size:.672rem}.resultItemStatus{align-items:center}.resultItemStatus>div{height:10px;width:10px;border-radius:50%;margin-right:4px}.resultItemInfo{margin-top:4px}
`;var X=J(ee());var re=function(c,e,t,o){var a=arguments.length,i=a<3?e:o===null?o=Object.getOwnPropertyDescriptor(e,t):o,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(c,e,t,o);else for(var l=c.length-1;l>=0;l--)(n=c[l])&&(i=(a<3?n(i):a>3?n(e,t,i):n(e,t))||i);return a>3&&i&&Object.defineProperty(e,t,i),i},W=class{interactionService;reportService;regionService;translate;languageService;route;authService;filter;records=null;selectedRegionDetailed;permissionSearchIdentity;permissionSearchOrganizationUnit;permissionSearchUserGroup;reportTemplateType=w.RegionState;reportTemplateId;sortingPicker;sortingPickerData;paginationResponse=new P;paginationRequest=new A;constructor(e,t,o,a,i,n,l){this.interactionService=e,this.reportService=t,this.regionService=o,this.translate=a,this.languageService=i,this.route=n,this.authService=l}get stateTypes(){return V}ngOnInit(){this.checkPermissions(),this.createFilter(),this.sortingPickerData={items:[{value:1,label:"REPORT.SORTING_USERNAME",showDirection:!0,selected:!0,isAlpha:!0,directionDefault:s.ASC},{value:2,label:"REPORT.SORTING_LAST_ACTION",showDirection:!0,isAlpha:!1,directionDefault:s.DESC},{value:3,label:"REPORT.SORTING_ACCESS_CONTROL_POINT",showDirection:!0,isAlpha:!0,directionDefault:s.ASC},{value:4,label:"REPORT.SORTING_STATE",showDirection:!0,isAlpha:!1,directionDefault:s.ASC}]},this.setSortingSelection(this.sortingPickerData.items[0].value,x.ASC)}ngOnDestroy(){}ngAfterViewInit(){this.route.queryParams.subscribe(e=>{e&&(e[r.RegionId]&&e[r.RegionId]!=""&&(this.filter.regionId=e[r.RegionId]),e[r.RegionState]&&e[r.RegionState]!=""&&(this.filter.state=[v(e[r.RegionState])]),e[r.ReportTemplateId]&&e[r.ReportTemplateId]!=""&&(this.reportTemplateId=e[r.ReportTemplateId]),this.filter.regionId&&this.fetchReportData())})}createFilter(){this.filter=m.getEmptyModel()}onGetReportClicked(e){this.refreshReportData()}onRemoveStateClicked(e){this.regionService.unlockUserState(this.filter.regionId,e.user.id).subscribe(()=>{e.state=z.Unset})}fetchReportData(){this.filter.regionId&&this.reportService.getRegionStateReport(m.getRequestModel(this.filter)).subscribe(e=>{this._templateLoading=!1,this.records=e.items||[],this.paginationResponse=e.pagination,this.records&&this.records.length>0&&(!this.selectedRegionDetailed||this.selectedRegionDetailed&&this.selectedRegionDetailed.id!=this.filter.regionId)&&this.regionService.getRegionDetailed(this.filter.regionId,!1).subscribe(t=>{this.selectedRegionDetailed=t})})}onGetExcelClicked(e){this.reportService.exportRegionStateAsExcel(this.filter).subscribe(t=>{this.translate.get(["PAGES.REPORT_REGION"]).subscribe(o=>{X.default.saveAs(t,o["PAGES.REPORT_REGION"]+" "+this.selectedRegionDetailed.name+" "+p.local().toLocaleString(p.DATETIME_MED)+".xlsx")})})}checkPermissions(){this.permissionSearchIdentity=this.authService.checkPermission(d.IDENTITY.getReadBasic()),this.permissionSearchOrganizationUnit=this.authService.checkPermission(d.ORGANIZATIONUNIT.getReadBasic()),this.permissionSearchUserGroup=this.authService.checkPermission(d.USERGROUP.getRead())}_templateLoading=!1;onTemplateLoaded(e){this._templateLoading=!0,e.filter&&(this.createFilter(),Object.assign(this.filter,e.filter)),setTimeout(()=>{this.refreshReportData()},1e3)}refreshReportData(e=!0){e&&(this.filter.pagination.skip=0),this.fetchReportData()}setSortingSelection(e,t){this.filter.sortType=e,this.filter.sortOrder=t}onSortingSelectionChanged(e){this.setSortingSelection(e.value,e.direction),this.refreshReportData()}pageChanged(e){this.filter.pagination=e,this.refreshReportData(!1)}onRegionChanged(e){this.filter.regionId&&this._templateLoading==!1&&this.refreshReportData()}static ctorParameters=()=>[{type:y},{type:_},{type:G},{type:S},{type:E},{type:b},{type:L}];static propDecorators={sortingPicker:[{type:f,args:["sortingPicker"]}]}};W=re([g({selector:"armon-report-region-state",template:K,standalone:!0,imports:[$,q,M,I,u,N,h,C,k,B,U,D,Z,Y,F,H,R,j,O,T],styles:[Q]})],W);export{W as ReportRegionStateComponent};
