import{a as N}from"./chunk-IIY4IOHM.js";import{a as F}from"./chunk-HYAJENKW.js";import"./chunk-KCLQIV7M.js";import{a as _}from"./chunk-WFZJP5WR.js";import"./chunk-F6KLNSUK.js";import{a as R}from"./chunk-VSFNMVXJ.js";import"./chunk-WQ6DP4JQ.js";import{Ha as L,a as z,l as T,vb as O}from"./chunk-YSQLW2JA.js";import"./chunk-NVJ2ZZFT.js";import{Dc as l,Mb as u,Mg as E,Pd as x,Te as S,ab as g,bb as h,bh as k,cd as b,dd as V,g as M,gb as f,gg as c,hg as C,jg as I,nd as m,wa as p,ya as v,zc as P}from"./chunk-SKPDQO4E.js";var y=`<div class="view-container">
    <div class="row">
        <div class="col-12">
            <armon-date-picker [options]="datePickerOptions" (selectionChanged)="onDateSelectionChanged($event)"
                #datePicker></armon-date-picker>
        </div>
    </div>
    <div class="row">
        <div class="col-12">
            <div class="analysis-bar-chart-container">
                <div class="pt-3 px-3 mb-3 d-flex justify-content-between">
                    <span class="text-md text-bold">{{'ANALYZE.VISIT_COUNTS_VISITOR'|translate}}</span>
                    <button class="btn btn-success btn-sm" (click)="onVisitorExcelClicked($event)"
                        [disabled]="!listVisitor || listVisitor.length==0">{{'BUTTON.EXCEL'|translate}}</button>
                </div>
                <div class="pt-3 px-3 d-flex align-items-center">
                    <label class="me-2">{{'REPORT.VISITOR'|translate}}</label>
                    <armon-visitor-search #searchVisitor [multiselect]="false" [showActiveFilter]="false"
                        (itemSelected)="onVisitorSelected($event)" (itemRemoved)="onVisitorRemoved($event)"
                        [activeFilterSelected]="false"></armon-visitor-search>
                </div>
                <div class="p-3">
                    <div class="card-columns" *ngIf="listVisitor && listVisitor.length>0">
                        <div class="card list-item" *ngFor="let item of listVisitor">
                            <ng-template *ngTemplateOutlet="visitorTemplate;context: {$implicit:item, isvisitor:true}">
                            </ng-template>
                        </div>
                    </div>
                    <div class="row pt-3" *ngIf="listVisitor && listVisitor.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">
                        <div class="col-12 my-2">
                            <armon-pagination [paginationResponse]="visitorPaginationResponse"
                                (pageChanged)="onVisitorPageChanged($event)">
                            </armon-pagination>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="row" *ngIf="availableLicencePlate">
        <div class="col-12">
            <div class="analysis-bar-chart-container">
                <div class="pt-3 px-3 mb-3 d-flex justify-content-between">
                    <span class="text-md text-bold">{{'ANALYZE.VISIT_COUNTS_VISITOR_LICENCE_PLATE'|translate}}</span>
                    <button class="btn btn-success btn-sm" (click)="onLicencePlateExcelClicked($event)"
                        [disabled]="!listLicencePlate || listLicencePlate.length==0">{{'BUTTON.EXCEL'|translate}}</button>
                </div>
                <div class="pt-3 px-3 d-flex align-items-center">
                    <label class="me-2">{{'CREDENTIAL.TITLE_VEHICLE_PLATE'|translate}}</label>
                    <input type="text" maxlength="32" [(ngModel)]="vehiclePlateSearch"
                        class="form-control form-control-sm me-2" style="width: 160px;"
                        (keydown.enter)="onVehiclePlateSearch($event)">
                    <cds-icon shape="search" style="width: 20px; height: 20px;" class="ms-2 cursor-pointer" (click)="onVehiclePlateSearch($event)"></cds-icon>
                    <cds-icon shape="times" style="width: 20px; height: 20px;" class="ms-2 cursor-pointer" (click)="vehiclePlateSearch='';onVehiclePlateSearch($event)" [hidden]="!vehiclePlateSearch || vehiclePlateSearch==''"></cds-icon>
                </div>
                <div class="p-3">
                    <div class="card-columns" *ngIf="listLicencePlate && listLicencePlate.length>0">
                        <div class="card list-item" *ngFor="let item of listLicencePlate">
                            <ng-template *ngTemplateOutlet="visitorTemplate;context: {$implicit:item, isvisitor:true}">
                            </ng-template>
                        </div>
                    </div>
                    <div class="row pt-3" *ngIf="listLicencePlate && listLicencePlate.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">
                        <div class="col-12 my-2">
                            <armon-pagination [paginationResponse]="licencePlatePaginationResponse"
                                (pageChanged)="onLicencePlatePageChanged($event)">
                            </armon-pagination>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-12">
            <div class="analysis-bar-chart-container">
                <div class="pt-3 px-3 mb-3 d-flex justify-content-between">
                    <span class="text-md text-bold">{{'ANALYZE.VISIT_COUNTS_VISITED_PERSON'|translate}}</span>
                    <button class="btn btn-success btn-sm" (click)="onVisitedUserExcelClicked($event)"
                        [disabled]="!listVisitedUser || listVisitedUser.length==0">{{'BUTTON.EXCEL'|translate}}</button>
                </div>
                <div class="pt-3 px-3 d-flex align-items-center">
                    <label class="me-2">{{'REPORT.VISITOR_HISTORY_HEADER_VISITING_USER'|translate}}</label>
                    <armon-visitor-field-search #fieldSearchComponent [fieldName]="visitedPersonFilterField.name"
                        [isProfileField]="false" *ngIf="visitedPersonFilterField"
                        (itemSelected)="onVisitedUserSelected($event)" (itemRemoved)="onVisitedUserRemoved($event)"
                        [endPoint]="(visitedPersonFilterField && visitedPersonFilterField.options && visitedPersonFilterField.options.formFieldSearchEndPoint)?visitedPersonFilterField.options.formFieldSearchEndPoint:null">
                    </armon-visitor-field-search>
                </div>
                <div class="p-3">
                    <div class="card-columns" *ngIf="listVisitedUser && listVisitedUser.length>0">
                        <div class="card list-item" *ngFor="let item of listVisitedUser">
                            <ng-template *ngTemplateOutlet="visitorTemplate;context: {$implicit:item, isvisitor:false}">
                            </ng-template>
                        </div>
                    </div>
                    <div class="row pt-3" *ngIf="listVisitedUser && listVisitedUser.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">
                        <div class="col-12 my-2">
                            <armon-pagination [paginationResponse]="visitedUserPaginationResponse"
                                (pageChanged)="onVisitedUserPageChanged($event)">
                            </armon-pagination>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-12">
            <div class="analysis-bar-chart-container">
                <div class="pt-3 px-3 mb-3 d-flex justify-content-between">
                    <span class="text-md text-bold">{{'ANALYZE.VISIT_COUNTS_VISITOR_REASON'|translate}}</span>
                    <button class="btn btn-success btn-sm" (click)="onReasonExcelClicked($event)"
                        [disabled]="!listReason || listReason.length==0">{{'BUTTON.EXCEL'|translate}}</button>
                </div>
                <div class="p-3">
                    <div class="card-columns" *ngIf="listReason && listReason.length>0">
                        <div class="card list-item" *ngFor="let item of listReason">
                            <ng-template *ngTemplateOutlet="visitorTemplate;context: {$implicit:item, isvisitor:false}">
                            </ng-template>
                        </div>
                    </div>
                    <div class="row pt-3" *ngIf="listReason && listReason.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>
            </div>
        </div>
    </div>
</div>

<ng-template #visitorTemplate let-item let-isvisitor="isvisitor">
    <div class="d-flex align-items-center p-2">
        <div class="flex-grow-1 px-2" *ngIf="!item.captionLines || item.captionLines.length == 0">
            <span>{{item.name}}</span>
        </div>
        <div class="flex-grow-1 px-1" *ngIf="item.captionLines && item.captionLines.length >= 1">
            <armon-captionlines [showBorder]="false" [isVisitor]="isvisitor" [captionlines]="item.captionLines">
            </armon-captionlines>
        </div>
        <div class="text-xl px-3">
            {{item.count}}
        </div>
    </div>
</ng-template>`;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}.list-item{background-color:#fcfcfc;-webkit-border-radius:.375rem;-moz-border-radius:.375rem;border-radius:.375rem;box-shadow:0 0 2px #ccc;border:none;margin-bottom:.7rem;page-break-inside:avoid;break-inside:avoid-column;display:table;width:100%}.card-columns{column-count:2;column-gap:1em}@media screen and (max-width: 768px){.card-columns{column-count:1}}
`;var A=M(z());var U;(function(s){s[s.NoChange=1]="NoChange",s[s.DecreasedFail=2]="DecreasedFail",s[s.IncreasedSuccess=3]="IncreasedSuccess",s[s.IncreasedFail=4]="IncreasedFail",s[s.DecreasedSuccess=5]="DecreasedSuccess"})(U||(U={}));var i;(function(s){s[s.Visitor=1]="Visitor",s[s.Reason=2]="Reason",s[s.VisitedPerson=3]="VisitedPerson",s[s.LicencePlate=4]="LicencePlate"})(i||(i={}));var Y=function(s,e,n,t){var a=arguments.length,o=a<3?e:t===null?t=Object.getOwnPropertyDescriptor(e,n):t,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(s,e,n,t);else for(var d=s.length-1;d>=0;d--)(r=s[d])&&(o=(a<3?r(o):a>3?r(e,n,o):r(e,n))||o);return a>3&&o&&Object.defineProperty(e,n,o),o},D=class{translate;visitorService;sessionService;listVisitor;listReason;listVisitedUser;listLicencePlate;visitedUserPaginationResponse;visitorPaginationResponse;licencePlatePaginationResponse;datePicker;datePickerOptions=new C;datePickerSelection;visitor;visitedUser;vehiclePlateSearch="";visitedPersonFilterField;availableLicencePlate;reasons;constructor(e,n,t){this.translate=e,this.visitorService=n,this.sessionService=t}ngOnInit(){this.visitedPersonFilterField=this.sessionService.currentOrganization.visitorModuleSettings.visitFormFields.find(t=>t.name==m.VISIT.VisitedPerson),this.availableLicencePlate=this.sessionService.currentOrganization.visitorModuleSettings.availableCredentials.findIndex(t=>t==u.VehiclePlate)>-1;let e=this.sessionService.currentOrganization.visitorModuleSettings.visitFormFields.find(t=>t.name==m.VISIT.Reason);e&&(this.reasons=e.options.options),this.datePickerOptions.items=[{type:c.LastMonth,selected:!0},{type:c.Last3Months},{type:c.Custom}];let n=I.getDateSelection(this.datePickerOptions.items[0]);this.setDateSelection(n),this.getData()}ngAfterViewInit(){}ngOnDestroy(){}onDateSelectionChanged(e){this.setDateSelection(e),this.getData()}setDateSelection(e){this.datePickerSelection=e}getData(){this.getCounts(i.Visitor),this.reasons&&this.getCounts(i.Reason),this.visitedPersonFilterField&&this.getCounts(i.VisitedPerson),this.availableLicencePlate&&this.getCounts(i.LicencePlate)}getFilter(e,n=null){let t=L.getEmptyModel();switch(t.filterType=e,t.startDay=l.fromJSDate(this.datePickerSelection.startDate).toFormat("yyyy-MM-dd"),t.endDay=l.fromJSDate(this.datePickerSelection.endDate).toFormat("yyyy-MM-dd"),n?t.pagination=n:(t.pagination=new E,t.pagination.take=P.REQUEST_ITEM_LIMIT),e){case i.Visitor:this.visitor&&(t.filterValue=this.visitor.id);break;case i.VisitedPerson:this.visitedUser&&(t.filterValue=this.visitedUser.id);break;case i.Reason:break;case i.LicencePlate:this.vehiclePlateSearch&&this.vehiclePlateSearch!=""&&(t.filterValue=this.vehiclePlateSearch);break}return t}getCounts(e,n=null){this.visitorService.getVisitorCountsAnalysis(this.getFilter(e,n)).subscribe(t=>{switch(e){case i.Visitor:this.listVisitor=t.items,this.visitorPaginationResponse=t.pagination;break;case i.VisitedPerson:this.listVisitedUser=t.items,this.visitedUserPaginationResponse=t.pagination;break;case i.Reason:t.items.forEach(a=>{a.name=this.reasons.find(o=>o.value==a.name).captionLines[0]}),this.listReason=t.items;break;case i.LicencePlate:this.listLicencePlate=t.items,this.licencePlatePaginationResponse=t.pagination;break}})}getCountsAsExcel(e){let n=this.getFilter(e);this.visitorService.getVisitorCountsAnalysisAsExcel(this.getFilter(e)).subscribe(t=>{let a;switch(e){case i.Visitor:a="ANALYZE.VISIT_COUNTS_VISITOR";break;case i.VisitedPerson:a="ANALYZE.VISIT_COUNTS_VISITED_PERSON";break;case i.Reason:a="ANALYZE.VISIT_COUNTS_VISITOR_REASON";break;case i.LicencePlate:a="ANALYZE.VISIT_COUNTS_VISITOR_LICENCE_PLATE";break}this.translate.get([a]).subscribe(o=>{A.default.saveAs(t,o[a]+" "+l.fromISO(n.startDay).toLocaleString(l.DATETIME_MED)+" "+l.fromISO(n.endDay).toLocaleString(l.DATETIME_MED)+".xlsx")})})}onVisitorSelected(e){this.visitor=e,this.getCounts(i.Visitor)}onVisitorRemoved(e){this.visitor=null,this.getCounts(i.Visitor)}onVisitorPageChanged(e){this.getCounts(i.Visitor,e)}onVisitedUserSelected(e){this.visitedUser=e,this.getCounts(i.VisitedPerson)}onVisitedUserRemoved(e){this.visitedUser=null,this.getCounts(i.VisitedPerson)}onVisitedUserPageChanged(e){this.getCounts(i.VisitedPerson,e)}onVehiclePlateSearch(e){this.getCounts(i.LicencePlate)}onLicencePlatePageChanged(e){this.getCounts(i.LicencePlate,e)}onVisitorExcelClicked(e){this.listVisitor&&this.listVisitor.length>0&&this.getCountsAsExcel(i.Visitor)}onVisitedUserExcelClicked(e){this.listVisitedUser&&this.listVisitedUser.length>0&&this.getCountsAsExcel(i.VisitedPerson)}onReasonExcelClicked(e){this.listReason&&this.listReason.length>0&&this.getCountsAsExcel(i.Reason)}onLicencePlateExcelClicked(e){this.listLicencePlate&&this.listLicencePlate.length>0&&this.getCountsAsExcel(i.LicencePlate)}static ctorParameters=()=>[{type:b},{type:O},{type:x}];static propDecorators={datePicker:[{type:p,args:["datePicker",{static:!0}]}]}};D=Y([v({selector:"armon-analysis-visitor-counts",template:y,standalone:!0,imports:[T,F,h,g,f,k,R,S,N,_,V],styles:[w]})],D);export{D as AnalysisVisitorCountsComponent};
