import{a as ie}from"./chunk-NWOU67BD.js";import{a as Ge}from"./chunk-TBSUMTHM.js";import{b as Le,c as H,d as Ne,f as Be}from"./chunk-CKJJI5MU.js";import"./chunk-TAT3HGQ4.js";import{a as Ie}from"./chunk-4SWKWV3M.js";import"./chunk-5SW267PH.js";import"./chunk-PU7DBJLZ.js";import"./chunk-3DDBG3AR.js";import"./chunk-5MLUVH77.js";import"./chunk-SMMBZMNL.js";import"./chunk-EFONMPAR.js";import"./chunk-YQXLYYOT.js";import"./chunk-6RITFGP2.js";import"./chunk-HGXDKXJP.js";import"./chunk-WQUXAKOL.js";import"./chunk-LYNKRDJC.js";import"./chunk-SKY4LXUD.js";import"./chunk-BZT47AWD.js";import{b as Ee,c as Se}from"./chunk-5WQBRAHK.js";import"./chunk-4FTRQKHH.js";import"./chunk-BYXBJQAS.js";import"./chunk-TTWRMELT.js";import"./chunk-EMJ4QQUL.js";import"./chunk-QPCAJSKO.js";import"./chunk-QV67LFVX.js";import"./chunk-4O3FVBGX.js";import"./chunk-TGWIHQDX.js";import{x as Pe}from"./chunk-Q5KZV54I.js";import{a as Fe}from"./chunk-YHVRQUSB.js";import"./chunk-3Z7PXZF3.js";import{a as Ae}from"./chunk-43BLBOSI.js";import"./chunk-IWSLIKCG.js";import"./chunk-2DXJE6G7.js";import"./chunk-7RP244JU.js";import"./chunk-LHGSJXTX.js";import{Q as xe,da as Te,ea as Me,fa as k,ga as D,ia as q,la as U,ma as X,na as C,oa as De}from"./chunk-ZKNPBXGB.js";import{b as Oe,d as we,f as ke}from"./chunk-S3ADKFO2.js";import{d as z,e as $,i as V,n as w}from"./chunk-I5MYHHJE.js";import{$b as f,Ab as B,Fb as a,Fc as te,Gb as p,Gc as ne,Hb as c,Ib as g,Jc as Ce,Mb as E,Nb as S,Ob as y,Pb as me,Ta as de,Tb as x,Vb as m,Wa as l,Wb as ge,Xb as G,Yb as _,Z as F,Zb as ue,_ as W,_b as u,aa as A,ca as M,dc as fe,f as pe,gb as Z,gc as R,ha as J,hc as h,ia as K,ic as v,jc as b,lb as P,mb as ee,nc as he,oc as _e,pb as I,pc as ve,qa as ce,qb as L,rb as d,tc as ye,vc as Q,wa as O,wc as be,xc as j,zb as N}from"./chunk-CKLXM6EG.js";import{a as le,b as se}from"./chunk-TSRGIXR5.js";var Re=`
    .p-timeline {
        display: flex;
        flex-grow: 1;
        flex-direction: column;
        direction: ltr;
    }

    .p-timeline-left .p-timeline-event-opposite {
        text-align: right;
    }

    .p-timeline-left .p-timeline-event-content {
        text-align: left;
    }

    .p-timeline-right .p-timeline-event {
        flex-direction: row-reverse;
    }

    .p-timeline-right .p-timeline-event-opposite {
        text-align: left;
    }

    .p-timeline-right .p-timeline-event-content {
        text-align: right;
    }

    .p-timeline-vertical.p-timeline-alternate .p-timeline-event:nth-child(even) {
        flex-direction: row-reverse;
    }

    .p-timeline-vertical.p-timeline-alternate .p-timeline-event:nth-child(odd) .p-timeline-event-opposite {
        text-align: right;
    }

    .p-timeline-vertical.p-timeline-alternate .p-timeline-event:nth-child(odd) .p-timeline-event-content {
        text-align: left;
    }

    .p-timeline-vertical.p-timeline-alternate .p-timeline-event:nth-child(even) .p-timeline-event-opposite {
        text-align: left;
    }

    .p-timeline-vertical.p-timeline-alternate .p-timeline-event:nth-child(even) .p-timeline-event-content {
        text-align: right;
    }

    .p-timeline-vertical .p-timeline-event-opposite,
    .p-timeline-vertical .p-timeline-event-content {
        padding: dt('timeline.vertical.event.content.padding');
    }

    .p-timeline-vertical .p-timeline-event-connector {
        width: dt('timeline.event.connector.size');
    }

    .p-timeline-event {
        display: flex;
        position: relative;
        min-height: dt('timeline.event.min.height');
    }

    .p-timeline-event:last-child {
        min-height: 0;
    }

    .p-timeline-event-opposite {
        flex: 1;
    }

    .p-timeline-event-content {
        flex: 1;
    }

    .p-timeline-event-separator {
        flex: 0;
        display: flex;
        align-items: center;
        flex-direction: column;
    }

    .p-timeline-event-marker {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        position: relative;
        align-self: baseline;
        border-width: dt('timeline.event.marker.border.width');
        border-style: solid;
        border-color: dt('timeline.event.marker.border.color');
        border-radius: dt('timeline.event.marker.border.radius');
        width: dt('timeline.event.marker.size');
        height: dt('timeline.event.marker.size');
        background: dt('timeline.event.marker.background');
    }

    .p-timeline-event-marker::before {
        content: ' ';
        border-radius: dt('timeline.event.marker.content.border.radius');
        width: dt('timeline.event.marker.content.size');
        height: dt('timeline.event.marker.content.size');
        background: dt('timeline.event.marker.content.background');
    }

    .p-timeline-event-marker::after {
        content: ' ';
        position: absolute;
        width: 100%;
        height: 100%;
        border-radius: dt('timeline.event.marker.border.radius');
        box-shadow: dt('timeline.event.marker.content.inset.shadow');
    }

    .p-timeline-event-connector {
        flex-grow: 1;
        background: dt('timeline.event.connector.color');
    }

    .p-timeline-horizontal {
        flex-direction: row;
    }

    .p-timeline-horizontal .p-timeline-event {
        flex-direction: column;
        flex: 1;
    }

    .p-timeline-horizontal .p-timeline-event:last-child {
        flex: 0;
    }

    .p-timeline-horizontal .p-timeline-event-separator {
        flex-direction: row;
    }

    .p-timeline-horizontal .p-timeline-event-connector {
        width: 100%;
        height: dt('timeline.event.connector.size');
    }

    .p-timeline-horizontal .p-timeline-event-opposite,
    .p-timeline-horizontal .p-timeline-event-content {
        padding: dt('timeline.horizontal.event.content.padding');
    }

    .p-timeline-horizontal.p-timeline-alternate .p-timeline-event:nth-child(even) {
        flex-direction: column-reverse;
    }

    .p-timeline-bottom .p-timeline-event {
        flex-direction: column-reverse;
    }
`;var Ke=["content"],Ze=["opposite"],et=["marker"],oe=t=>({$implicit:t});function tt(t,n){t&1&&y(0)}function nt(t,n){t&1&&y(0)}function it(t,n){if(t&1&&(E(0),d(1,nt,1,0,"ng-container",3),S()),t&2){let e=m().$implicit,i=m();l(),a("ngTemplateOutlet",i.markerTemplate||i._markerTemplate)("ngTemplateOutletContext",j(2,oe,e))}}function ot(t,n){if(t&1&&g(0,"div",2),t&2){let e=m(2);h(e.cx("eventMarker")),a("pBind",e.ptm("eventMarker"))}}function rt(t,n){if(t&1&&g(0,"div",2),t&2){let e=m(2);h(e.cx("eventConnector")),a("pBind",e.ptm("eventConnector"))}}function at(t,n){t&1&&y(0)}function lt(t,n){if(t&1&&(p(0,"div",2)(1,"div",2),d(2,tt,1,0,"ng-container",3),c(),p(3,"div",2),d(4,it,2,4,"ng-container",4)(5,ot,1,3,"ng-template",null,0,Ce)(7,rt,1,3,"div",5),c(),p(8,"div",2),d(9,at,1,0,"ng-container",3),c()()),t&2){let e=n.$implicit,i=n.last,o=fe(6),r=m();h(r.cx("event")),a("pBind",r.ptm("event")),l(),h(r.cx("eventOpposite")),a("pBind",r.ptm("eventOpposite")),l(),a("ngTemplateOutlet",r.oppositeTemplate||r._oppositeTemplate)("ngTemplateOutletContext",j(19,oe,e)),l(),h(r.cx("eventSeparator")),a("pBind",r.ptm("eventSeparator")),l(),a("ngIf",r.markerTemplate||r._markerTemplate)("ngIfElse",o),l(3),a("ngIf",!i),l(),h(r.cx("eventContent")),a("pBind",r.ptm("eventContent")),l(),a("ngTemplateOutlet",r.contentTemplate||r._contentTemplate)("ngTemplateOutletContext",j(21,oe,e))}}var st={root:({instance:t})=>["p-timeline p-component","p-timeline-"+t.align,"p-timeline-"+t.layout],event:"p-timeline-event",eventOpposite:"p-timeline-event-opposite",eventSeparator:"p-timeline-event-separator",eventMarker:"p-timeline-event-marker",eventConnector:"p-timeline-event-connector",eventContent:"p-timeline-event-content"},Qe=(()=>{class t extends q{name="timeline";style=Re;classes=st;static \u0275fac=(()=>{let e;return function(o){return(e||(e=O(t)))(o||t)}})();static \u0275prov=F({token:t,factory:t.\u0275fac})}return t})();var je=new A("TIMELINE_INSTANCE"),ae=(()=>{class t extends X{bindDirectiveInstance=M(C,{self:!0});$pcTimeline=M(je,{optional:!0,skipSelf:!0})??void 0;onAfterViewChecked(){this.bindDirectiveInstance.setAttrs(this.ptms(["host","root"]))}value;styleClass;align="left";layout="vertical";contentTemplate;oppositeTemplate;markerTemplate;templates;_contentTemplate;_oppositeTemplate;_markerTemplate;_componentStyle=M(Qe);getBlockableElement(){return this.el.nativeElement.children[0]}onAfterContentInit(){this.templates.forEach(e=>{switch(e.getType()){case"content":this._contentTemplate=e.template;break;case"opposite":this._oppositeTemplate=e.template;break;case"marker":this._markerTemplate=e.template;break}})}static \u0275fac=(()=>{let e;return function(o){return(e||(e=O(t)))(o||t)}})();static \u0275cmp=P({type:t,selectors:[["p-timeline"]],contentQueries:function(i,o,r){if(i&1&&(_(r,Ke,4),_(r,Ze,4),_(r,et,4),_(r,k,4)),i&2){let s;u(s=f())&&(o.contentTemplate=s.first),u(s=f())&&(o.oppositeTemplate=s.first),u(s=f())&&(o.markerTemplate=s.first),u(s=f())&&(o.templates=s)}},hostVars:2,hostBindings:function(i,o){i&2&&h(o.cn(o.cx("root"),o.styleClass))},inputs:{value:"value",styleClass:"styleClass",align:"align",layout:"layout"},features:[Q([Qe,{provide:je,useExisting:t},{provide:U,useExisting:t}]),L([C]),I],decls:1,vars:1,consts:[["marker",""],[3,"pBind","class",4,"ngFor","ngForOf"],[3,"pBind"],[4,"ngTemplateOutlet","ngTemplateOutletContext"],[4,"ngIf","ngIfElse"],[3,"pBind","class",4,"ngIf"]],template:function(i,o){i&1&&d(0,lt,10,23,"div",1),i&2&&a("ngForOf",o.value)},dependencies:[w,z,$,V,D,C],encapsulation:2,changeDetection:0})}return t})(),$e=(()=>{class t{static \u0275fac=function(i){return new(i||t)};static \u0275mod=ee({type:t});static \u0275inj=W({imports:[ae,D,D]})}return t})();var Ve=`
    .p-card {
        background: dt('card.background');
        color: dt('card.color');
        box-shadow: dt('card.shadow');
        border-radius: dt('card.border.radius');
        display: flex;
        flex-direction: column;
    }

    .p-card-caption {
        display: flex;
        flex-direction: column;
        gap: dt('card.caption.gap');
    }

    .p-card-body {
        padding: dt('card.body.padding');
        display: flex;
        flex-direction: column;
        gap: dt('card.body.gap');
    }

    .p-card-title {
        font-size: dt('card.title.font.size');
        font-weight: dt('card.title.font.weight');
    }

    .p-card-subtitle {
        color: dt('card.subtitle.color');
    }
`;var ct=["header"],dt=["title"],mt=["subtitle"],gt=["content"],ut=["footer"],ft=["*",[["p-header"]],[["p-footer"]]],ht=["*","p-header","p-footer"];function _t(t,n){t&1&&y(0)}function vt(t,n){if(t&1&&(p(0,"div",1),G(1,1),d(2,_t,1,0,"ng-container",2),c()),t&2){let e=m();h(e.cx("header")),a("pBind",e.ptm("header")),l(2),a("ngTemplateOutlet",e.headerTemplate||e._headerTemplate)}}function yt(t,n){if(t&1&&(E(0),v(1),S()),t&2){let e=m(2);l(),b(e.header)}}function bt(t,n){t&1&&y(0)}function Ct(t,n){if(t&1&&(p(0,"div",1),d(1,yt,2,1,"ng-container",3)(2,bt,1,0,"ng-container",2),c()),t&2){let e=m();h(e.cx("title")),a("pBind",e.ptm("title")),l(),a("ngIf",e.header&&!e._titleTemplate&&!e.titleTemplate),l(),a("ngTemplateOutlet",e.titleTemplate||e._titleTemplate)}}function xt(t,n){if(t&1&&(E(0),v(1),S()),t&2){let e=m(2);l(),b(e.subheader)}}function Tt(t,n){t&1&&y(0)}function Mt(t,n){if(t&1&&(p(0,"div",1),d(1,xt,2,1,"ng-container",3)(2,Tt,1,0,"ng-container",2),c()),t&2){let e=m();h(e.cx("subtitle")),a("pBind",e.ptm("subtitle")),l(),a("ngIf",e.subheader&&!e._subtitleTemplate&&!e.subtitleTemplate),l(),a("ngTemplateOutlet",e.subtitleTemplate||e._subtitleTemplate)}}function Pt(t,n){t&1&&y(0)}function Ot(t,n){t&1&&y(0)}function wt(t,n){if(t&1&&(p(0,"div",1),G(1,2),d(2,Ot,1,0,"ng-container",2),c()),t&2){let e=m();h(e.cx("footer")),a("pBind",e.ptm("footer")),l(2),a("ngTemplateOutlet",e.footerTemplate||e._footerTemplate)}}var kt=`
    ${Ve}

    .p-card {
        display: block;
    }
`,Dt={root:"p-card p-component",header:"p-card-header",body:"p-card-body",caption:"p-card-caption",title:"p-card-title",subtitle:"p-card-subtitle",content:"p-card-content",footer:"p-card-footer"},qe=(()=>{class t extends q{name="card";style=kt;classes=Dt;static \u0275fac=(()=>{let e;return function(o){return(e||(e=O(t)))(o||t)}})();static \u0275prov=F({token:t,factory:t.\u0275fac})}return t})();var Ue=new A("CARD_INSTANCE"),Xe=(()=>{class t extends X{$pcCard=M(Ue,{optional:!0,skipSelf:!0})??void 0;bindDirectiveInstance=M(C,{self:!0});_componentStyle=M(qe);onAfterViewChecked(){this.bindDirectiveInstance.setAttrs(this.ptms(["host","root"]))}header;subheader;set style(e){xe(this._style(),e)||(this._style.set(e),this.el?.nativeElement&&e&&Object.keys(e).forEach(i=>{this.el.nativeElement.style[i]=e[i]}))}get style(){return this._style()}styleClass;headerFacet;footerFacet;headerTemplate;titleTemplate;subtitleTemplate;contentTemplate;footerTemplate;_headerTemplate;_titleTemplate;_subtitleTemplate;_contentTemplate;_footerTemplate;_style=ce(null);getBlockableElement(){return this.el.nativeElement.children[0]}templates;onAfterContentInit(){this.templates.forEach(e=>{switch(e.getType()){case"header":this._headerTemplate=e.template;break;case"title":this._titleTemplate=e.template;break;case"subtitle":this._subtitleTemplate=e.template;break;case"content":this._contentTemplate=e.template;break;case"footer":this._footerTemplate=e.template;break;default:this._contentTemplate=e.template;break}})}static \u0275fac=(()=>{let e;return function(o){return(e||(e=O(t)))(o||t)}})();static \u0275cmp=P({type:t,selectors:[["p-card"]],contentQueries:function(i,o,r){if(i&1&&(_(r,Te,5),_(r,Me,5),_(r,ct,4),_(r,dt,4),_(r,mt,4),_(r,gt,4),_(r,ut,4),_(r,k,4)),i&2){let s;u(s=f())&&(o.headerFacet=s.first),u(s=f())&&(o.footerFacet=s.first),u(s=f())&&(o.headerTemplate=s.first),u(s=f())&&(o.titleTemplate=s.first),u(s=f())&&(o.subtitleTemplate=s.first),u(s=f())&&(o.contentTemplate=s.first),u(s=f())&&(o.footerTemplate=s.first),u(s=f())&&(o.templates=s)}},hostVars:4,hostBindings:function(i,o){i&2&&(R(o._style()),h(o.cn(o.cx("root"),o.styleClass)))},inputs:{header:"header",subheader:"subheader",style:"style",styleClass:"styleClass"},features:[Q([qe,{provide:Ue,useExisting:t},{provide:U,useExisting:t}]),L([C]),I],ngContentSelectors:ht,decls:8,vars:11,consts:[[3,"pBind","class",4,"ngIf"],[3,"pBind"],[4,"ngTemplateOutlet"],[4,"ngIf"]],template:function(i,o){i&1&&(ge(ft),d(0,vt,3,4,"div",0),p(1,"div",1),d(2,Ct,3,5,"div",0)(3,Mt,3,5,"div",0),p(4,"div",1),G(5),d(6,Pt,1,0,"ng-container",2),c(),d(7,wt,3,4,"div",0),c()),i&2&&(a("ngIf",o.headerFacet||o.headerTemplate||o._headerTemplate),l(),h(o.cx("body")),a("pBind",o.ptm("body")),l(),a("ngIf",o.header||o.titleTemplate||o._titleTemplate),l(),a("ngIf",o.subheader||o.subtitleTemplate||o._subtitleTemplate),l(),h(o.cx("content")),a("pBind",o.ptm("content")),l(2),a("ngTemplateOutlet",o.contentTemplate||o._contentTemplate),l(),a("ngIf",o.footerFacet||o.footerTemplate||o._footerTemplate))},dependencies:[w,$,V,D,De,C],encapsulation:2,changeDetection:0})}return t})();var Y=class t{event;static \u0275fac=function(e){return new(e||t)};static \u0275cmp=P({type:t,selectors:[["app-mesage-card"]],inputs:{event:"event"},decls:13,vars:5,consts:[[1,"fw-bold","text-gray","mb-3"],[1,"custom-card-style","reset-card","rounded-3","mb-5","ms-auto"],[1,"d-flex","justify-content-between"],[1,"d-flex","align-items-center","justify-content-end","mb-2"],["alt","Author",1,"quote-icon","rounded-circle",2,"width","40px","height","40px","object-fit","cover",3,"src"],[1,"fw-bold","mx-2"],[1,"d-flex","align-items-center","gap-2"],[1,"card-message-note"]],template:function(e,i){e&1&&(p(0,"small",0),v(1),c(),p(2,"p-card",1)(3,"div",2)(4,"div",3),g(5,"img",4),p(6,"div",5),v(7),c()(),p(8,"div"),v(9),c()(),p(10,"div",6)(11,"div",7),v(12),c()()()),e&2&&(l(),b(i.event.time),l(4),a("src",i.event.image,de),l(2),b(i.event.name),l(2),b(i.event.created_at),l(3),b(i.event.description))},dependencies:[Xe],styles:["[_nghost-%COMP%]     .p-timeline-event-opposite{display:none}.custom-card-style[_ngcontent-%COMP%]{padding:.5rem;background-color:#fdfeff;border-radius:8px;box-shadow:none}[_nghost-%COMP%]     .p-timeline-event-content div{background-color:#f8f8f8e3!important;border-radius:8px!important}.card-message-note[_ngcontent-ng-c4013311583][_ngcontent-%COMP%]{border-radius:50px;background-color:#fe5f5514!important;padding:.25rem .75rem;font-weight:500;font-size:.9rem;white-space:nowrap}.rtl[_ngcontent-%COMP%]{direction:rtl}.ltr[_ngcontent-%COMP%]{direction:ltr}.text-gray[_ngcontent-%COMP%]{color:gray!important}"]})};var St=()=>({width:"300px"});function Ft(t,n){if(t&1){let e=me();p(0,"div",10)(1,"app-search-filter",21),x("resValue",function(o){J(e);let r=m();return K(r.getData(o))})("formValueChanges",function(o){J(e);let r=m();return K(r.onFilterChange(o))}),c()()}if(t&2){let e=m();l(),a("filterSearch",e.filterFields)("values",e.filterValues)("url",e.apiUrl)("showFilter",!0)("translationPrefix",e.translationPrefix)}}function At(t,n){t&1&&g(0,"app-loader")}function It(t,n){t&1&&(p(0,"div",11)(1,"div",22)(2,"div",23),g(3,"app-empty-card",24),te(4,"translate"),c()()()),t&2&&(l(3),a("message",ne(4,1,"no-data")))}function Lt(t,n){if(t&1&&g(0,"app-mesage-card",33),t&2){let e=n.$implicit;a("event",e)}}function Nt(t,n){if(t&1&&(p(0,"li",25)(1,"div",26)(2,"div",27)(3,"div",28),g(4,"i",29),p(5,"span",30),v(6),c()()(),p(7,"p-timeline",31),d(8,Lt,1,1,"ng-template",32),c()()()),t&2){let e=n.$implicit,i=m();l(6),b(i.getDateLabel(e.label)),l(),a("value",e.events)("align",i.timelineAlign)}}var He=class t{constructor(n,e){this.apiService=n;this.translate=e}destroy$=new pe;translationPrefix="activity_log";apiUrl="procurement/activity-logs";currentPage=1;itemsPerPage=10;allEventGroups=[];displayedGroups=[];timelineAlign="right";isLoading=!1;data=[];dataNumber=0;filterFields=[{type:"select",title:"employee",options:[],optionName:"full_name",class:"col-4",controlName:"employee_id",optionsUrl:"procurement/public/employees/list?is_user=1"},{type:"dateWithOptions",title:"date_range",controlName:"date",fromControlName:"from",toControlName:"to",showQuickButtons:!0,class:"col-6",parentClass:"col-8"}];filterValues={};showFilter=!1;dateRanges=[{label:"Today",value:"today"},{label:"Yesterday",value:"yesterday"},{label:"Last 7 Days",value:"week"},{label:"Last 30 Days",value:"month"}];selectedRange=null;downloadDialog=!1;ngOnInit(){let n=localStorage.getItem("direction");this.timelineAlign=n==="rtl"?"right":"left"}onFullResponse(n){console.log("\u{1F4E6} Full response received:",n)}showFilteration=!1;onLoadingChange(n){this.isLoading=n,console.log("\u23F3 Loading state:",n)}transformData(n){return console.log("\u{1F504} Transforming data:",n),n.map(e=>{let o=(e.date||"").match(/\d{4}[/\-]\d{2}[/\-]\d{2}/),r=o?this.parseDate(o[0]):new Date,s=(e.logs||[]).map(T=>({id:T.id,name:T.user,time:T.time,description:`${T.description}`,created_at:T.created_at,image:T.image||"assets/images/profile.png"}));return console.log("\u{1F4C5} Processed entry:",{label:e.date,parsedDate:r.toISOString(),eventsCount:s.length}),{label:e.date,date:r,events:s}}).sort((e,i)=>i.date.getTime()-e.date.getTime())}parseDate(n){if(!n)return new Date;let e=n.split(/[/\-]/);return e.length===3?new Date(parseInt(e[0]),parseInt(e[1])-1,parseInt(e[2])):new Date(n)}paginationComponent;onFilterChange(n){console.log("\u{1F50D} Filter values changed:",n),this.paginationComponent&&(this.paginationComponent.testing=n,console.log("\u2705 Filters passed to pagination:",n),this.filterValues=n)}toggleFilter(){this.showFilter=!this.showFilter,console.log("\u{1F441}\uFE0F Filter visibility:",this.showFilter)}clearFilters(){this.filterValues={},this.selectedRange=null,console.log("\u{1F9F9} All filters cleared")}hasActiveFilters(){return Object.keys(this.filterValues).length>0}formatDateForAPI(n){let e=n.getFullYear(),i=("0"+(n.getMonth()+1)).slice(-2),o=("0"+n.getDate()).slice(-2);return`${i}-${o}-${e}`}resetTime(n){return new Date(n.getFullYear(),n.getMonth(),n.getDate())}showFilterationSection(){this.showFilteration=!this.showFilteration}getDateLabel(n){if(!n)return"";let e=n.match(/\d{4}[/\-]\d{2}[/\-]\d{2}/)?.[0];if(!e)return n;let i=this.parseDate(e),o=this.resetTime(new Date),r=new Date(o);r.setDate(o.getDate()-1);let s=this.resetTime(i).getTime(),T=o.getTime(),Ye=r.getTime(),We=this.translate.currentLang||"en";return s===T?this.translate.instant("TODAY"):s===Ye?this.translate.instant("YESTERDAY"):i.toLocaleDateString(We==="ar"?"ar-EG":"en-US",{weekday:"long",year:"numeric",month:"long",day:"numeric"})}openDownloadDialog(){if(!this.displayedGroups||this.displayedGroups.length===0){alert(this.translate.instant("ALERT.NO_DATA_TO_EXPORT")||"No data available to export");return}this.downloadDialog=!0}downloadPDF(){this.downloadDialog=!1,this.onPrint()}downloadExcel(){this.downloadDialog=!1,this.exportToExcel()}onPrint(){if(!this.displayedGroups||this.displayedGroups.length===0){alert(this.translate.instant("ALERT.NO_DATA_TO_PRINT")||"No data available to print");return}let n=this.generatePrintTable(),e=window.open("","_blank","width=900,height=700");if(!e)return;let i=this.translate.instant("activity_log.title")||"Activity Log",o=Array.from(document.querySelectorAll('link[rel="stylesheet"], style')).map(s=>s.outerHTML).join(`
`),r=localStorage.getItem("direction")||"ltr";e.document.open(),e.document.write(`
      <html>
        <head>
          <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css">
          ${o}
          <style>
            body { 
         direction: ${r}; 
              font-family: Arial, sans-serif;
            }
            table { 
              width: 100%; 
              table-layout: fixed; 
              border-collapse: collapse;
              margin-top: 20px;

            }
            th, td { 
              font-size: 11px; 
              border: 1px solid #ddd; 
              padding: 8px;
              word-break: break-word;
            }
            th {
              background-color: #f8f9fa;
              font-weight: bold;
            }
            .date-group {
              background-color: #e9ecef;
              font-weight: bold;
              padding: 10px;
              margin-top: 15px;
            }
            @media print {
              @page { size: A4; margin: 8mm; }
              table { page-break-inside: avoid; }
            }
          </style>
        </head>
        <body>
          <h2 class="mt-5 mb-3 fw-bold text-center">${i}</h2>
          ${n}
          <script>
            window.onafterprint = function () { window.close(); };
            window.onload = function () { window.print(); };
          <\/script>
        </body>
      </html>
    `),e.document.close()}generatePrintTable(){let n="";return this.displayedGroups.forEach(e=>{n+=`<div class="date-group">${this.getDateLabel(e.label)}</div>`,n+="<table>",n+="<thead><tr>",n+=`<th>${this.translate.instant("activity_log.user")||"User"}</th>`,n+=`<th>${this.translate.instant("activity_log.action")||"Action"}</th>`,n+=`<th>${this.translate.instant("activity_log.time")||"Time"}</th>`,n+="</tr></thead>",n+="<tbody>",e.events.forEach(i=>{n+="<tr>",n+=`<td>${i.name||""}</td>`,n+=`<td>${i.description||""}</td>`,n+=`<td>${i.created_at||""}</td>`,n+="</tr>"}),n+="</tbody></table>"}),n}exportToExcel(){let n=[];this.displayedGroups.forEach(r=>{n.push({[this.translate.instant("activity_log.date")||"Date"]:this.getDateLabel(r.label),[this.translate.instant("activity_log.user")||"User"]:"",[this.translate.instant("activity_log.action")||"Action"]:"",[this.translate.instant("activity_log.time")||"Time"]:""}),r.events.forEach(s=>{n.push({[this.translate.instant("activity_log.date")||"Date"]:"",[this.translate.instant("activity_log.user")||"User"]:s.name||"",[this.translate.instant("activity_log.action")||"Action"]:s.description||"",[this.translate.instant("activity_log.time")||"Time"]:s.created_at||""})}),n.push({[this.translate.instant("activity_log.date")||"Date"]:"",[this.translate.instant("activity_log.user")||"User"]:"",[this.translate.instant("activity_log.action")||"Action"]:"",[this.translate.instant("activity_log.time")||"Time"]:""})});let e=H.json_to_sheet(n),i=H.book_new();H.book_append_sheet(i,e,"Activity Log");let o=`${this.translate.instant("activity_log.title")||"Activity_Log"}_${new Date().getTime()}.xlsx`;Le(i,o)}ngOnDestroy(){this.destroy$.next(),this.destroy$.complete()}originalGroups=[];searchTerm="";applyGlobalFilter=n=>{if(this.searchTerm=n.toLowerCase().trim(),!this.searchTerm){this.displayedGroups=[...this.allEventGroups];return}this.displayedGroups=this.allEventGroups.map(e=>{let i=e.events.filter(o=>[o.name,o.description,o.time].join(" ").toLowerCase().includes(this.searchTerm));return se(le({},e),{events:i})}).filter(e=>e.events.length>0)};onSearchChange(n){if(!n.trim()){this.apiUrl="procurement/activity-logs",this.currentPage=1;return}this.apiUrl=`procurement/activity-logs?search=${encodeURIComponent(n)}`,this.currentPage=1}clear=()=>{this.searchTerm="",this.apiUrl="procurement/activity-logs",this.currentPage=1,console.log("\u{1F9F9} Search cleared")};paginationMeta=null;getData(n){console.log("\u{1F4CA} Filter response received:",n);let e=n.data||n;e&&Array.isArray(e)&&e.length>0?(this.allEventGroups=this.transformData(e),this.displayedGroups=[...this.allEventGroups],console.log("\u2705 Filtered data transformed:",this.displayedGroups)):(this.allEventGroups=[],this.displayedGroups=[],console.log("\u26A0\uFE0F No filtered data to display")),this.data=e,n.meta&&(this.paginationMeta=n.meta,console.log("\u2705 Pagination meta updated:",this.paginationMeta)),this.currentPage=1}onPaginationData(n){console.log("\u{1F4CA} Pagination data received:",n);let e=Array.isArray(n)?n:[n];e&&e.length>0?(this.allEventGroups=this.transformData(e),this.displayedGroups=[...this.allEventGroups],console.log("\u2705 Transformed groups:",this.displayedGroups),console.log("\u{1F4DD} Total events:",this.displayedGroups.reduce((i,o)=>i+o.events.length,0))):(console.log("\u26A0\uFE0F No data to display"),this.allEventGroups=[],this.displayedGroups=[])}static \u0275fac=function(e){return new(e||t)(Z(Fe),Z(Oe))};static \u0275cmp=P({type:t,selectors:[["app-activity-log"]],viewQuery:function(e,i){if(e&1&&ue(ie,5),e&2){let o;u(o=f())&&(i.paginationComponent=o.first)}},inputs:{showFilteration:"showFilteration"},decls:26,vars:29,consts:[[1,"activity-log-container"],["title","activity_log",3,"Translationprefix","showTitle","showBreadcrumb"],[1,"advanced-filters","d-flex","justify-content-end","flex-column","align-items-end"],[1,"action-buttons","d-flex","gap-2"],[3,"searchChange","searchApiIntegration","delay","data","clearSearch"],[1,"print-btn",3,"click","disabled"],[1,"pi","pi-print","primary-icon"],[1,"pi","pi-download","primary-icon"],[1,"print-btn",3,"click"],[1,"pi","pi-filter","primary-icon"],[1,"px-4"],[1,"no-data-container"],[1,"timeline-list"],["class","timeline-group",4,"ngFor","ngForOf"],["category","",3,"paginationResponse","fullResponse","loading","url","page","per_page","ShowNumberOfProducts","meta"],[3,"visibleChange","header","visible","modal","closable","dismissableMask"],[1,"download-options-vertical"],[1,"download-option","pdf",3,"click"],[1,"pi","pi-file-pdf"],[1,"download-option","excel",3,"click"],[1,"pi","pi-file-excel"],[3,"resValue","formValueChanges","filterSearch","values","url","showFilter","translationPrefix"],[1,"card","shadow-sm"],[1,"card-body","text-center","py-5"],[3,"message"],[1,"timeline-group"],[1,"timeline-wrapper"],[1,"date-label-container"],[1,"date-label"],[1,"fa-solid","fa-circle-check","text-muted","me-2"],[1,"fw-bold"],["layout","vertical",1,"custom-timeline",3,"value","align"],["pTemplate","content"],[3,"event"]],template:function(e,i){e&1&&(p(0,"div",0),g(1,"app-page-title",1),p(2,"div",2)(3,"div",3)(4,"app-search",4),x("searchChange",function(r){return i.onSearchChange(r)}),c(),p(5,"button",5),x("click",function(){return i.onPrint()}),g(6,"i",6),c(),p(7,"button",5),x("click",function(){return i.openDownloadDialog()}),g(8,"i",7),c(),p(9,"button",8),x("click",function(){return i.showFilterationSection()}),g(10,"i",9),c()(),N(11,Ft,2,5,"div",10),c(),N(12,At,1,0,"app-loader"),N(13,It,5,3,"div",11),p(14,"ul",12),d(15,Nt,9,3,"li",13),c(),p(16,"app-pagination",14),x("paginationResponse",function(r){return i.onPaginationData(r)})("fullResponse",function(r){return i.onFullResponse(r)})("loading",function(r){return i.onLoadingChange(r)}),c(),p(17,"p-dialog",15),te(18,"translate"),ve("visibleChange",function(r){return _e(i.downloadDialog,r)||(i.downloadDialog=r),r}),p(19,"div",16)(20,"button",17),x("click",function(){return i.downloadPDF()}),g(21,"i",18),v(22," PDF "),c(),p(23,"button",19),x("click",function(){return i.downloadExcel()}),g(24,"i",20),v(25," Excel "),c()()()()),e&2&&(l(),a("Translationprefix",i.translationPrefix)("showTitle",!0)("showBreadcrumb",!0),l(3),a("searchApiIntegration",!0)("delay",1e3)("data",i.data)("clearSearch",i.clear),l(),a("disabled",i.displayedGroups.length===0),l(2),a("disabled",i.displayedGroups.length===0),l(4),B(i.showFilteration?11:-1),l(),B(i.isLoading?12:-1),l(),B(!i.isLoading&&i.displayedGroups.length===0?13:-1),l(2),a("ngForOf",i.displayedGroups),l(),a("url",i.apiUrl)("page",i.currentPage)("per_page",i.itemsPerPage)("ShowNumberOfProducts",!0)("meta",i.paginationMeta),l(),R(be(28,St)),a("header",ye(ne(18,26,"DOWNLOAD"))),he("visible",i.downloadDialog),a("modal",!0)("closable",!0)("dismissableMask",!0))},dependencies:[$e,ae,k,Y,w,z,Pe,Be,ie,ke,Ae,Se,Ee,Ge,Ne,Ie,we],styles:['[dir="ltr"][_nghost-%COMP%]   .custom-timeline[_ngcontent-%COMP%], [dir="ltr"]   [_nghost-%COMP%]   .custom-timeline[_ngcontent-%COMP%]{direction:ltr}[dir="rtl"][_nghost-%COMP%]   .custom-timeline[_ngcontent-%COMP%], [dir="rtl"]   [_nghost-%COMP%]   .custom-timeline[_ngcontent-%COMP%]{direction:rtl}.timeline-list[_ngcontent-%COMP%]{list-style:none;padding:0;margin:0}.timeline-group[_ngcontent-%COMP%]{margin-bottom:3rem;position:relative}.timeline-wrapper[_ngcontent-%COMP%]{width:100%}[dir="rtl"][_nghost-%COMP%]   .date-label-container[_ngcontent-%COMP%], [dir="rtl"]   [_nghost-%COMP%]   .date-label-container[_ngcontent-%COMP%]{text-align:right;margin-bottom:1.5rem;padding-right:2rem}[dir="ltr"][_nghost-%COMP%]   .date-label-container[_ngcontent-%COMP%], [dir="ltr"]   [_nghost-%COMP%]   .date-label-container[_ngcontent-%COMP%]{text-align:left;margin-bottom:1.5rem;padding-left:2rem}.date-label[_ngcontent-%COMP%]{display:inline-flex;align-items:center;padding:.75rem 1.5rem;font-size:1.1rem;transition:all .3s ease}.date-label[_ngcontent-%COMP%]   .text-success[_ngcontent-%COMP%]{font-size:1.2rem}.date-label[_ngcontent-%COMP%]   small[_ngcontent-%COMP%]{color:#6c757d;font-weight:400}.custom-timeline[_ngcontent-%COMP%]{margin-right:2rem}  .custom-timeline .p-timeline-event-opposite,   .custom-timeline .p-timeline-event-content{padding:1rem 1.5rem}.custom-timeline.timeline-rtl[_ngcontent-%COMP%]     .p-timeline-event{text-align:right}.custom-timeline.timeline-rtl[_ngcontent-%COMP%]     .p-timeline-event-opposite{text-align:left}.custom-timeline.timeline-rtl[_ngcontent-%COMP%]     .p-timeline-event-content{text-align:right}.custom-timeline.timeline-ltr[_ngcontent-%COMP%]     .p-timeline-event{text-align:left}.custom-timeline.timeline-ltr[_ngcontent-%COMP%]     .p-timeline-event-opposite{text-align:right}.custom-timeline.timeline-ltr[_ngcontent-%COMP%]     .p-timeline-event-content{text-align:left}  .custom-timeline .p-timeline-event-marker{width:20px;height:20px;border:3px solid rgba(20,80,85,.16);background:#fff;box-shadow:none;transition:all .3s ease}  .p-timeline-event-marker:before{content:" ";border-radius:var(--p-timeline-event-marker-content-border-radius);width:var(--p-timeline-event-marker-content-size);height:var(--p-timeline-event-marker-content-size);background:var(--secondary-color)}  .custom-timeline .p-timeline-event:hover .p-timeline-event-marker{transform:scale(1.3);box-shadow:0 0 0 6px #667eea33}  .custom-timeline .p-timeline-event-connector{background:#14505529;width:3px}  .p-timeline-event-opposite{flex:0!important}.action-buttons[_ngcontent-%COMP%]{margin-bottom:20px}.print-btn[_ngcontent-%COMP%]{background:#fff;border:1px solid #dee2e6;border-radius:6px;padding:8px 12px;cursor:pointer;transition:all .3s ease}.print-btn[_ngcontent-%COMP%]:hover:not(:disabled){background-color:#f8f9fa;border-color:#adb5bd}.print-btn[_ngcontent-%COMP%]:disabled{opacity:.5;cursor:not-allowed}.primary-icon[_ngcontent-%COMP%]{font-size:16px;color:#0d6efd}.no-data-container[_ngcontent-%COMP%]{margin-top:2rem}.no-data-container[_ngcontent-%COMP%]   .card[_ngcontent-%COMP%]{border:2px dashed #dee2e6;border-radius:12px;background:#fafafa}.no-data-container[_ngcontent-%COMP%]   .fa-folder-open[_ngcontent-%COMP%]{color:#adb5bd}.advanced-filters[_ngcontent-%COMP%]{margin-bottom:20px}.items-per-page[_ngcontent-%COMP%]{padding-top:1rem;border-top:1px solid #e9ecef}.items-per-page[_ngcontent-%COMP%]   select[_ngcontent-%COMP%]{cursor:pointer;border-radius:6px;border:2px solid #e9ecef;padding:.375rem .75rem;transition:all .2s ease}.items-per-page[_ngcontent-%COMP%]   select[_ngcontent-%COMP%]:focus{border-color:#667eea;box-shadow:0 0 0 .2rem #667eea40}[_nghost-%COMP%]     .download-options-vertical{display:flex;flex-direction:column;gap:15px;padding:15px 5px}[_nghost-%COMP%]     .download-option{width:100%;padding:12px;border-radius:8px;border:none;font-weight:700;font-size:15px;cursor:pointer;display:flex;align-items:center;justify-content:center}[_nghost-%COMP%]     button.download-option.pdf{background-color:#f44336!important;color:#fff}[_nghost-%COMP%]     button.download-option.excel{background-color:#4caf50!important;color:#fff}[_nghost-%COMP%]     .download-option i{margin-right:10px;font-size:18px}[_nghost-%COMP%]     .custom-card-style{padding:.5rem!important;background-color:#14505514!important;border-radius:8px!important;box-shadow:none!important}[_nghost-%COMP%]     .btn__loader-text{background:transparent!important}[_nghost-%COMP%]     button{background:transparent!important}[_nghost-%COMP%]     .bg-filter{padding:.5rem}[_nghost-%COMP%]     .bg-filter, [_nghost-%COMP%]     .bg-delete{background:#e7ebec!important;color:var(--primary-color)!important;width:fit-content}[_nghost-%COMP%]     button span{color:var(--primary-color)!important}[_nghost-%COMP%]     button:disabled, [_nghost-%COMP%]     button.disabled, [_nghost-%COMP%]     .btn:disabled, [_nghost-%COMP%]     .btn.disabled{background:transparent!important}[_nghost-%COMP%]     button:focus, [_nghost-%COMP%]     select:focus{box-shadow:none}[_nghost-%COMP%]     .text-muted{color:#b9b9b9!important;margin-inline:.5rem}button[_ngcontent-%COMP%]:focus, select[_ngcontent-%COMP%]:focus{outline:2px solid transparent!important;outline-offset:2px}[dir=rtl][_ngcontent-%COMP%]   .timeline-wrapper[_ngcontent-%COMP%]{direction:rtl}[dir=rtl][_ngcontent-%COMP%]   .date-label-container[_ngcontent-%COMP%]{text-align:left;padding-left:2rem;padding-right:0}[dir=rtl][_ngcontent-%COMP%]   .custom-timeline[_ngcontent-%COMP%]{margin-left:2rem;margin-right:0}[dir=rtl][_ngcontent-%COMP%]   .date-label[_ngcontent-%COMP%]   i[_ngcontent-%COMP%]{margin-right:0;margin-left:8px}[dir=rtl][_ngcontent-%COMP%]   .action-buttons[_ngcontent-%COMP%]{flex-direction:row-reverse}[dir=rtl]   [_nghost-%COMP%]     .download-option i{margin-right:0;margin-left:10px}[dir=ltr][_ngcontent-%COMP%]   .timeline-wrapper[_ngcontent-%COMP%]{direction:ltr}[dir=ltr][_ngcontent-%COMP%]   .date-label-container[_ngcontent-%COMP%]{text-align:right;padding-right:2rem;padding-left:0}[dir=ltr][_ngcontent-%COMP%]   .custom-timeline[_ngcontent-%COMP%]{margin-right:2rem;margin-left:0}[dir=ltr][_ngcontent-%COMP%]   .date-label[_ngcontent-%COMP%]   i[_ngcontent-%COMP%]{margin-right:8px;margin-left:0}[dir=ltr]   [_nghost-%COMP%]     .download-option i{margin-right:10px;margin-left:0}.card[_ngcontent-%COMP%], .btn[_ngcontent-%COMP%], .page-link[_ngcontent-%COMP%], .date-label[_ngcontent-%COMP%]{transition:all .3s cubic-bezier(.4,0,.2,1)}.spinner-border[_ngcontent-%COMP%]{width:3rem;height:3rem;border-width:.3rem}@media (max-width: 768px){.date-label-container[_ngcontent-%COMP%]{padding-right:0;padding-left:0;text-align:center}.date-label[_ngcontent-%COMP%]{font-size:1rem;padding:.5rem 1rem}.custom-timeline[_ngcontent-%COMP%]{margin-right:0;margin-left:0}.timeline-group[_ngcontent-%COMP%]{margin-bottom:2rem}.action-buttons[_ngcontent-%COMP%]{flex-wrap:wrap}.download-option[_ngcontent-%COMP%]{font-size:14px;padding:10px 16px}[dir=rtl][_ngcontent-%COMP%]   .date-label-container[_ngcontent-%COMP%], [dir=ltr][_ngcontent-%COMP%]   .date-label-container[_ngcontent-%COMP%]{text-align:center;padding-right:0;padding-left:0}[dir=rtl][_ngcontent-%COMP%]   .custom-timeline[_ngcontent-%COMP%], [dir=ltr][_ngcontent-%COMP%]   .custom-timeline[_ngcontent-%COMP%]{margin-right:0;margin-left:0}}[_nghost-%COMP%]     .p-timeline-right .p-timeline-event{flex-direction:row!important}@media print{.filter-section[_ngcontent-%COMP%], .pagination-container[_ngcontent-%COMP%], .action-buttons[_ngcontent-%COMP%]{display:none}.timeline-group[_ngcontent-%COMP%]{page-break-inside:avoid}}']})};export{He as ActivityLogComponent};
