1import{j as e}from"./enrg-design-BJyhgaee.js";import{o as re,r as i,a as xe}from"./redux-DmFS62g6.js";import{G as z,cT as Se,cS as de,P as U,bH as pe,t as oe,c$ as be,dl as je,aD as _e,i as He,Q as Ie,bB as qe,bP as Pe,d9 as Te,d0 as Ge,dk as Xe,d3 as Ye,d1 as Je,d2 as ge,d4 as Ue,d5 as Ke,dY as Re,di as Oe,cL as Le,cM as Me,cN as Ne,c_ as Qe,aA as me,d6 as Ze}from"./index-BbDh0bYL.js";import{s as Fe,e as et,a as tt,b as ze,d as Be,u as st,D as nt,f as at,c as lt,g as rt,h as it,i as ot,l as ct,C as dt,j as ut,k as mt}from"./CreateEventDrawer-CqxFg75y.js";import{a as ue,C as ft,b as xt,S as N}from"./ServicePicker-Dy25xY5Q.js";import{a as Ae}from"./index-CXXouJYn.js";import{C as pt}from"./Calendar-BIourHYk.js";import{g as le,C as fe}from"./Icon-D3nfDcaD.js";import{$ as ht,U as yt,R as gt}from"./ui-DZPGnD5D.js";import{a as vt,u as bt}from"./router-BaR8B-Cu.js";import"./utils-CSem7nyB.js";import"./firebase-CjfLkEUs.js";import"./index-BVTVXpKm.js";const jt="enrg-events-selected-service-id",ve=s=>{try{localStorage.setItem(jt,s)}catch(n){console.error("Error saving events service id to localStorage:",n)}},ce=7,ie=7,_t=({title:s,data:n,theme:t,language:o,onRowClick:a,columns:c,gridTemplateColumns:v})=>{const[p,r]=i.useState(!1),[f,b]=i.useState(1),x=Math.ceil(n.length/ce),C=n.length>ce,D=(f-1)*ce,B=n.slice(D,D+ce),T=()=>{if(x<=ie)return Array.from({length:x},(L,M)=>M+1);const u=Math.floor(ie/2);let h=Math.max(f-u,1),y=Math.min(h+ie-1,x);return y-h+1<ie&&(h=Math.max(y-ie+1,1)),Array.from({length:y-h+1},(L,M)=>h+M)};i.useEffect(()=>{b(1)},[n.length]);const S=u=>{const h=Math.round(u),y=Math.floor(h/1440),L=Math.floor(h%1440/60),M=h%60;return y>0?`${y}${o.events_duration_days} ${L}${o.events_duration_hours} ${M}${o.events_duration_minutes}`:`${L}${o.events_duration_hours} ${M}${o.events_duration_minutes}`},A=u=>o[u]||"",R=u=>({1:"content-color-red",2:"content-color-orange",3:"content-color-orange"})[u]??"",m=u=>({open:o.events_status_open,resolved:o.events_status_resolved})[u]??u,w=u=>u==="open"?"content-color-orange":"content-color-green",I=(u,h)=>{const y=u[h.key];switch(h.format){case"duration":return S(y);case"datetime":return y?U(Ae(new Date(y),5),"dd/MM/yyyy HH:mm"):o.events_status_open??"â";case"priority":return A(u.firebase_value);case"status":return m(y);default:return y??"â"}},P=(u,h)=>h.format==="priority"?R(u[h.key]):h.format==="status"?w(u[h.key]):"",k=T();return e.jsxs("div",{className:`d-flex flex-column gap-3 surface-bg-surface border-fill-medium rounded-16 overflow-hidden ${t}`,children:[e.jsxs("div",{className:`d-flex align-items-center justify-content-between gap-2 px-3 pt-3 ${t}`,children:[e.jsx("h3",{className:`label-medium-semibold content-default-primary m-0 ${t}`,children:s}),e.jsxs("div",{className:"d-flex gap-2",children:[e.jsx("div",{className:`d-flex align-items-center gap-1 surface-bg-on-surface-alpha rounded-pill px-2 py-1 ${t}`,children:e.jsxs("span",{className:`label-small-regular content-default-primary ${t}`,children:[n.length," ",o.events_records_label]})}),e.jsx("button",{onClick:()=>r(!p),className:`position-relative zindex-1 w-32 h-32 bg-transparent border-fill-medium rounded-16 hover-opacity-80 transition-all duration-200 ${t}`,children:e.jsx(z,{icon:p?Se:de,className:`text-sm content-default-primary ${t}`})})]})]}),e.jsxs("div",{className:`position-relative flex-fill d-flex flex-column gap-3 px-3 pb-0 overflow-x-auto scroll-without-border ${t}`,style:{maxHeight:p?"0px":"none",opacity:p?0:1},children:[e.jsx("div",{className:`d-grid sticky-top zindex-1 ${t}`,style:{gridTemplateColumns:v,minWidth:"700px"},children:c.map((u,h)=>e.jsxs("div",{className:`position-relative surface-bg-on-surface border-fill-medium-vertical border-fill-medium-left ${h===0?"rounded-start":""} ${h===c.length-1?"border-fill-medium-right rounded-end":""} ${t}`,children:[e.jsx("div",{className:`w-100 h-100 position-absolute top-0 zindex-n2 surface-bg-surface-gradient pointer-events-none ${t}`}),e.jsx("div",{className:`px-3 py-3 label-small-medium content-default-primary d-flex align-items-center gap-2 ${t}`,children:u.label})]},u.key))}),e.jsx("div",{className:`d-flex flex-column gap-3 ${C?"":"mb-3"} ${t}`,style:{minWidth:"700px"},children:B.map((u,h)=>e.jsx("div",{className:`h-46 d-grid py-2 bg-alpha-white-4 rounded ${a?"pe-pointer hover-opacity-80":""} ${t}`,style:{gridTemplateColumns:v},onClick:a?()=>
1a(u):void 0,children:c.map(y=>e.jsx("div",{className:`d-flex align-items-center px-2 text-truncate ${t}`,children:e.jsx(ue,{text:String(I(u,y)),position:"top",children:e.jsx("div",{className:`px-2 label-small-regular text-truncate ${P(u,y)||"content-default-primary"} ${t}`,children:I(u,y)})})},y.key))},u.id_event||u.id_service||h))}),C&&e.jsxs("div",{className:`d-flex gap-2 align-items-center justify-content-center pb-3 ${t}`,children:[e.jsx("button",{onClick:()=>b(u=>Math.max(u-1,1)),disabled:f===1,className:`surface-bg-on-surface-alpha border-fill-medium d-flex align-items-center justify-content-center p-2 rounded-pill hover-opacity-80 ${t}`,style:{width:"32px",height:"32px",opacity:f===1?.5:1,cursor:f===1?"not-allowed":"pointer"},children:e.jsx(z,{icon:de,className:`text-sm content-default-secondary ${t}`,style:{transform:"rotate(-90deg)"}})}),k.map(u=>e.jsx("button",{onClick:()=>b(u),className:`${u===f?"surface-bg-on-surface-alpha border-fill-medium":"button-fill-disabled"} d-flex align-items-center justify-content-center p-2 rounded-pill hover-opacity-80 ${t}`,style:{width:"32px",height:"32px",border:u===f?"1px solid":"none"},children:e.jsx("span",{className:`label-small-medium ${u===f?"content-default-primary":"content-default-secondary"} ${t}`,children:u})},u)),e.jsx("button",{onClick:()=>b(u=>Math.min(u+1,x)),disabled:f===x,className:`surface-bg-on-surface-alpha border-fill-medium d-flex align-items-center justify-content-center p-2 rounded-pill hover-opacity-80 ${t}`,style:{width:"32px",height:"32px",opacity:f===x?.5:1,cursor:f===x?"not-allowed":"pointer"},children:e.jsx(z,{icon:de,className:`text-sm content-default-secondary ${t}`,style:{transform:"rotate(90deg)"}})})]})]})]})},Nt=s=>({theme:s.theme.theme}),Ve=re(Nt)(_t),W={NONE:"none",OPEN:"open",RESOLVED:"resolved",CRITICAL:"critical",MAJOR:"major",MINOR:"minor"},ke={OPEN:"open",RESOLVED:"resolved"},ye={CRITICAL:1,MAJOR:2,MINOR:3},wt=({isOpen:s,onToggle:n,theme:t,language:o,triggerElement:a,appliedFilters:c,onFiltersChange:v,showStatusPriority:p=!0})=>{var H,Q,J,F,Y,X,ne,ee,te;const[r,f]=i.useState(!1),[b,x]=i.useState(!1),C=i.useRef(null),D=i.useRef(null),B=i.useRef(null),T=i.useRef(null),S={status:[],priority:[],dateRange:{start:null,end:null}},[A,R]=i.useState({...S,...c}),[m,w]=i.useState(()=>{var _,j;return(_=c==null?void 0:c.dateRange)!=null&&_.start&&((j=c==null?void 0:c.dateRange)!=null&&j.end)?[{startDate:new Date(c.dateRange.start),endDate:new Date(c.dateRange.end),key:"selection"}]:null}),[I,P]=i.useState(!1);i.useEffect(()=>{var _,j;R({...S,...c}),(_=c==null?void 0:c.dateRange)!=null&&_.start&&((j=c==null?void 0:c.dateRange)!=null&&j.end)?w([{startDate:new Date(c.dateRange.start),endDate:new Date(c.dateRange.end),key:"selection"}]):w(null)},[c]),i.useEffect(()=>{s||(R({...S,...c}),P(!1))},[s]),i.useEffect(()=>{if(!s)return;const _=j=>{if(r||b)return;const l=B.current&&!B.current.contains(j.target),d=T.current&&!T.current.contains(j.target);l&&d&&n(!1)};return setTimeout(()=>document.addEventListener("mousedown",_),100),()=>document.removeEventListener("mousedown",_)},[s,r,b,n]);const k=(_,j)=>{var l;return((l=A[_])==null?void 0:l.includes(j))||!1},u=(_,j)=>{R(l=>{const d=l[_]||[],E=d.includes(j)?d.filter(O=>O!==j):[...d,j];return{...l,[_]:E}})},h=_=>{const j=_.graphDateFrom;w([{startDate:j,endDate:pe(j,1),key:"selection"}]),P(!0)},y=_=>{var d;const j=_.graphDateFrom,l=((d=m==null?void 0:m[0])==null?void 0:d.startDate)||Fe(j,1);w([{startDate:l,endDate:j,key:"selection"}]),P(!0)},L=()=>{const _={...A,dateRange:m!=null&&m[0]?{start:m[0].startDate.toISOString(),end:m[0].endDate.toISOString()}:{start:null,end:null}};v==null||v(_),oe("Novelties Filtered",{date_range_value:!!(m!=null&&m[0])}),n(!1)},M=()=>{const _={...S};R(_),w(null),v==null||v(_),n(!1)},K=(((H=A.status)==null?void 0:H.length)||0)+(((Q=A.priority)==null?void 0:Q.length)||0)+(m?1:0),V=({show:_,buttonRef:j,children:l,onClose:d})=>{if(!_||!j.current)return null;const E=j.current.getBoundingClientRect();return xe.createPortal(e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{position:"fixed",inset:0,zIndex:10001,background:"transparent"},onMouseDown:O=>{O.stopPropagation(),O.preventDefault()},onClick:O=>{O.stopPropagation(),d()}}),e.jsx("div",{style:{position:"fixed",top:E.bottom+8,left:E.left,zIndex:10002},onMouseDown:O=>O.stopPropagation(),onClick:O=>O.stopPropagation(),children:l})]}),document.body)},$=(_,j,l,d)=>{const E=k(_,j);return e.jsxs("button",{onClick:()=>u(_,j),className:`d-flex align-items-center ps-2 pe-1 py-2 bg-transparent ${E?"border-color-green":"border-fill-bold"} rounded-pill cursor-pointer ${t}`,children:[e.jsx("div",{className:"d-flex align-items-center justify-content-center",children:e.jsx(le,{icon:d,iconType:"solid",size:"28",theme:t,iconClassName:E?"content-color-green":"content-default-primary"})}),e.jsx("div",{className:`d-flex gap-2 align-items-center px-1 label-small-medium ${E?"content-color-green":"content-default-primary"} ${t}`,children:l})]},j)};return e.jsx(ft,{zIndex:1e4,trigger:"click",placement:"bottomRight",className:`p-0 border-fill-medium surface-bg-surface rounded-16 ${t}`,style:{width:"320px"},isOpen:s,arrow:!1,onChangeOpen:n,content:e.jsx("div",{ref:B,className:`d-flex ${t}`,children:e.jsxs("div",{className:`d-flex flex-column ${t}`,style:{width:"320px",maxHeight:"560px"},children:[e.jsxs("div",{className:`d-flex align-items-center justify-content-between mx-3 py-3 border-fill-medium-bottom ${t}`,children:[e.jsx("span",{className:`label-large-semibold content-default-primary ${t}`,children:o.events_filters_title}),K>0&&e.jsx("button",{className:`label-small-regular content-color-green bg-transparent border-0 pe-pointer ${t}`,onClick:M,children:o.filters_clear})]}),e.jsxs("div",{className:`flex-fill d-flex flex-column gap-0 overflow-y-auto scroll-without-border ${t}`,children:[e.jsxs("div",{className:`d-flex flex-column gap-2 px-3 pt-3 pb-2 ${t}`,children:[e.jsx("span",{className:`label-medium-semibold content-default-primary ${t}`,children:o.events_filters_date_range_title}),e.jsxs("div",{className:"d-flex gap-2",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:`label-small-medium content-default-primary mb-2 ${t}`,children:o.events_filters_date_start}),e.jsxs("div",{ref:C,className:`d-flex align-items-center justify-content-between ps-3 pe-2 py-2 surface-bg-on-surface-alpha border-fill-regular rounded-pill cursor-pointer ${t}`,onClick:()=>f(!r),children:[e.jsx("span",{className:`label-small-regular content-default-secondary ${t}`,children:(J=m==null?void 0:m[0])!=null&&J.startDate?U(m[0].startDate,"yyyy-MM-dd"):"-- / -- / ----"}),e.jsx(le,{icon:"faCalendar",iconType:"light",size:"32",theme:t,iconClassName:"content-default-secondary"})]}),e.jsx(V,{show:r,buttonRef:C,onClose:()=>f(!1),children:e.jsx(fe,{show:r,setShow:f,interval:0,setDates:h,setIntervalGraph:()=>{},dateRangeEnergy:[{startDate:((F=m==null?void 0:m[0])==null?void 0:F.startDate)||new Date,endD
1ate:((Y=m==null?void 0:m[0])==null?void 0:Y.startDate)||new Date,key:"selection"}],language:o,theme:t,position:"right",right:-140})})]}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:`label-small-medium content-default-primary mb-2 ${t}`,children:o.events_filters_date_end}),e.jsxs("div",{ref:D,className:`d-flex align-items-center justify-content-between ps-3 pe-2 py-2 surface-bg-on-surface-alpha border-fill-regular rounded-pill cursor-pointer ${t}`,onClick:()=>x(!b),children:[e.jsx("span",{className:`label-small-regular content-default-secondary ${t}`,children:(X=m==null?void 0:m[0])!=null&&X.endDate?U(m[0].endDate,"yyyy-MM-dd"):"-- / -- / ----"}),e.jsx(le,{icon:"faCalendar",iconType:"light",size:"32",theme:t,iconClassName:"content-default-secondary"})]}),e.jsx(V,{show:b,buttonRef:D,onClose:()=>x(!1),children:e.jsx(fe,{show:b,setShow:x,interval:0,setDates:y,setIntervalGraph:()=>{},dateRangeEnergy:[{startDate:((ne=m==null?void 0:m[0])==null?void 0:ne.endDate)||new Date,endDate:((ee=m==null?void 0:m[0])==null?void 0:ee.endDate)||new Date,key:"selection"}],minDate:((te=m==null?void 0:m[0])==null?void 0:te.startDate)||void 0,language:o,theme:t,position:"right",right:-140})})]})]})]}),p&&e.jsxs("div",{className:`d-flex flex-column gap-2 px-3 py-2 ${t}`,children:[e.jsx("span",{className:`label-medium-semibold content-default-primary ${t}`,children:o.events_filters_status_title}),e.jsxs("div",{className:"d-flex flex-wrap gap-2",children:[$("status",ke.OPEN,o.events_filters_status_open,"faScrewdriverWrench"),$("status",ke.RESOLVED,o.events_filters_status_resolved,"faCircleCheck")]})]}),p&&e.jsxs("div",{className:`d-flex flex-column gap-2 px-3 pt-2 pb-3 ${t}`,children:[e.jsx("span",{className:`label-medium-semibold content-default-primary ${t}`,children:o.events_filters_priority_title}),e.jsxs("div",{className:"d-flex flex-wrap gap-2",children:[$("priority",ye.CRITICAL,o.events_priority_critical,"faLightEmergencyOn"),$("priority",ye.MAJOR,o.events_priority_major,"faBellOn"),$("priority",ye.MINOR,o.events_priority_minor,"faBell")]})]})]}),e.jsx("div",{className:`d-flex align-items-center justify-content-end mx-3 py-3 border-fill-medium-top ${t}`,children:e.jsx("button",{className:`px-3 py-2 rounded-pill button-fill-brand button-content-equal label-small-regular cursor-pointer ${t}`,onClick:L,children:I?o.events_filters_load_button:o.events_filters_show_button})})]})}),children:e.jsx("div",{ref:T,children:a})})},$t=({show:s,onHide:n,theme:t,language:o,dateRange:a,selectedServiceId:c,exportEvents:v})=>{const[p,r]=i.useState(()=>[{startDate:a!=null&&a.start?new Date(a.start):new Date,endDate:a!=null&&a.end?new Date(a.end):new Date,key:"selection"}]),[f,b]=i.useState(!1),[x,C]=i.useState(!1),[D,B]=i.useState(!1),T=i.useRef(null),S=i.useRef(null);i.useEffect(()=>{a!=null&&a.start&&(a!=null&&a.end)&&r([{startDate:new Date(a.start),endDate:new Date(a.end),key:"selection"}])},[a]);const A=I=>{r([{startDate:I.graphDateFrom,endDate:pe(I.graphDateFrom,1),key:"selection"}])},R=I=>{r([{startDate:p[0].startDate,endDate:I.graphDateFrom,key:"selection"}])},m=async()=>{D||(B(!0),await v(c,p[0].startDate,p[0].endDate),oe("Novelties Downloaded",{filters_context:a!=null&&a.start||a!=null&&a.end?"filtered":"unfiltered"}),B(!1),n())},w=({show:I,buttonRef:P,children:k,onClose:u})=>{if(!I||!P.current)return null;const h=P.current.getBoundingClientRect();return xe.createPortal(e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{position:"fixed",inset:0,zIndex:10001,background:"transparent"},onMouseDown:y=>{y.stopPropagation(),y.preventDefault()},onClick:y=>{y.stopPropagation(),u()}}),e.jsx("div",{style:{position:"fixed",top:h.bottom+8,left:h.left,zIndex:10002},onMouseDown:y=>y.stopPropagation(),onClick:y=>y.stopPropagation(),children:k})]}),document.body)};return e.jsx(ht,{size:"md",show:s,backdropClassName:`surface-bg-blackout cursor-pointer ${t}`,onHide:n,className:"alarm-export-modal d-flex align-items-center justify-content-center",style:{height:"calc(100vh - 60px)"},full:!0,children:e.jsx("div",{className:`h-100 w-100 d-flex align-items-center justify-content-center ${t}`,children:e.jsxs("div",{className:`position-relative surface-bg-surface border-fill-medium rounded-16 overflow-hidden ${t}`,style:{width:"480px"},children:[e.jsxs("div",{className:`h-64 d-flex align-items-center justify-content-center surface-bg-fill border-fill-medium-bottom ${t}`,children:[e.jsx("div",{className:`label-large-semibold content-default-primary text-center ${t}`,children:o.events_export_modal_title}),e.jsx(le,{icon:"faXmark",iconType:"light",circular:!0,size:"32",theme:t,onClick:n,iconClassName:"content-default-primary",className:"position-absolute end-0 me-3"})]}),e.jsx("div",{className:`d-flex flex-column align-items-center px-4 py-4 ${t}`,children:e.jsxs("div",{className:`d-flex flex-column gap-3 align-items-center w-100 ${t}`,children:[e.jsx("div",{className:`position-relative pb-2 w-219 h-114 ${t}`,children:e.jsx("img",{src:t===_e.DARK?be:je,alt:"",className:"w-100 h-100"})}),e.jsxs("div",{className:`d-flex flex-column gap-2 pb-3 text-center w-100 ${t}`,children:[e.jsx("div",{className:`label-large-semibold content-default-primary ${t}`,children:o.events_export_modal_message_title}),e.jsx("div",{className:`paragraph-small-regular content-default-primary ${t}`,children:o.events_export_modal_message_description})]}),e.jsxs("div",{className:`d-flex gap-3 w-100 ${t}`,children:[e.jsxs("div",{className:"flex-fill d-flex flex-column gap-2",children:[e.jsx("div",{className:`label-small-medium content-default-primary ${t}`,children:o.events_filters_date_start}),e.jsxs("div",{ref:T,className:`surface-bg-surface border-fill-regular d-flex gap-1 align-items-center ps-3 pe-2 py-2 rounded-pill cursor-pointer ${t}`,onClick:()=>b(!f),children:[e.jsx("span",{className:`flex-fill label-small-medium content-default-secondary ${t}`,children:U(p[0].startDate,"yyyy-MM-dd")}),e.jsx(le,{icon:"faCalendar",iconType:"light",size:"35",theme:t,iconClassName:"content-default-secondary"})]}),e.jsx(w,{show:f,buttonRef:T,onClose:()=>b(!1),children:e.jsx(fe,{show:f,setShow:b,interval:0,setDates:A,setIntervalGraph:()=>{}
1,dateRangeEnergy:[{startDate:p[0].startDate,endDate:p[0].startDate,key:"selection"}],language:o,theme:t,position:"left",verticalPosition:"top",topIncrement:45})})]}),e.jsxs("div",{className:"flex-fill d-flex flex-column gap-2",children:[e.jsx("div",{className:`label-small-medium content-default-primary ${t}`,children:o.events_filters_date_end}),e.jsxs("div",{ref:S,className:`surface-bg-surface border-fill-regular d-flex gap-1 align-items-center ps-3 pe-2 py-2 rounded-pill cursor-pointer ${t}`,onClick:()=>C(!x),children:[e.jsx("span",{className:`flex-fill label-small-medium content-default-secondary ${t}`,children:U(p[0].endDate,"yyyy-MM-dd")}),e.jsx(le,{icon:"faCalendar",iconType:"light",size:"35",theme:t,iconClassName:"content-default-secondary"})]}),e.jsx(w,{show:x,buttonRef:S,onClose:()=>C(!1),children:e.jsx(fe,{show:x,setShow:C,interval:0,setDates:R,setIntervalGraph:()=>{},dateRangeEnergy:[{startDate:p[0].endDate,endDate:p[0].endDate,key:"selection"}],minDate:p[0].startDate,language:o,theme:t,position:"left",verticalPosition:"top",topIncrement:45})})]})]})]})}),e.jsx("div",{className:`d-flex gap-3 align-items-center justify-content-end surface-bg-fill border-fill-medium-top px-3 py-3 ${t}`,children:e.jsx("button",{onClick:m,disabled:D,className:`${D?"button-fill-disabled button-content-disabled":"button-fill-brand"} d-flex align-items-center justify-content-center px-3 py-2 rounded-pill border-0 cursor-pointer ${t}`,style:{opacity:D?.5:1,cursor:D?"not-allowed":"pointer"},children:e.jsx("div",{className:`label-small-medium button-content-equal ${t}`,children:D?o.events_export_modal_downloading:o.events_export_modal_download_button})})})]})})})},Ct=s=>({theme:s.theme.theme,language:s.shared.language,selectedServiceId:s.events.selectedServiceId}),Dt=s=>({exportEvents:(n,t,o)=>s(et(n,t,o))}),Et=re(Ct,Dt)($t),kt=({totalIncidents:s,showSearch:n,showServicePicker:t,totalServices:o,selectedMonth:a,onMonthChange:c,onExport:v,onCreateEvent:p,theme:r,language:f,selectedServiceId:b,eventsAppliedFilters:x,setEventsSearchTerm:C,setShowBlackScreen:D,setEventsSelectedServiceId:B,setEventsAppliedFilters:T})=>{var l,d,E,O,q,se,ae,we,$e,Ce,De,Ee;const[S,A]=i.useState(!1),[R,m]=i.useState(!1),[w,I]=i.useState(!1),[P,k]=i.useState(""),[u,h]=i.useState(!1),[y,L]=i.useState(!1),M=i.useRef(null),K=x&&(((l=x.status)==null?void 0:l.length)||0)+(((d=x.priority)==null?void 0:d.length)||0)+(((E=x.client)==null?void 0:E.length)||0)+(((O=x.projectType)==null?void 0:O.length)||0)+(((q=x.businessType)==null?void 0:q.length)||0)+(((se=x.headquarter)==null?void 0:se.length)||0)>0,V=i.useCallback(()=>b&&o&&o.find(g=>g.id_service===b)||null,[b,o]),$=i.useCallback(()=>{if(b&&o){const g=o.find(G=>G.id_service===b);return g?g.service_name:f.events_select_service}return f.events_select_service},[b,o,f]),H=i.useCallback(()=>{if(a!=null&&a.start){const g=f.language_locale==="es"?Ie:qe;return U(a.start,"MMMM yyyy",{locale:g})}return f.events_select_month},[a,f]),Q=g=>{B(g.id_service),ve(g.id_service)},J=i.useCallback(g=>{const G=Pe(g),he=pe(Te(G,1),-1);c==null||c({start:G,end:he}),oe("Novelties Month Changed",{selected_month:U(G,"yyyy-MM")}),h(!1)},[c]),F=i.useCallback(g=>{T(g)},[T]),Y=i.useCallback(g=>{T({...x,[g]:[]})},[x,T]),X=i.useCallback(g=>{const G=typeof g=="boolean"?g:!S;A(G),D(G),G&&m(!1)},[S,D]),ne=i.useCallback(g=>{const G=typeof g=="boolean"?g:!R;m(G),D(G),G&&A(!1)},[R,D]),ee=i.useCallback(()=>{w&&P&&(k(""),C("")),I(!w)},[w,P,C]),te=i.useCallback(()=>{k(""),C(""),I(!1)},[C]);i.useEffect(()=>{const g=setTimeout(()=>{C(P),P.trim().length>0&&oe("Novelties Searched",{query_length:P.trim().length})},500);return()=>clearTimeout(g)},[P,C]);const _=x?[{key:"status",label:f.events_filters_status_title,count:((ae=x.status)==null?void 0:ae.length)||0},{key:"priority",label:f.events_filters_priority_title,count:((we=x.priority)==null?void 0:we.length)||0},{key:"client",label:f.filters_label_client,count:(($e=x.client)==null?void 0:$e.length)||0},{key:"projectType",label:f.filters_label_project_type,count:((Ce=x.projectType)==null?void 0:Ce.length)||0},{key:"businessType",label:f.filters_label_business_type,count:((De=x.businessType)==null?void 0:De.length)||0},{key:"headquarter",label:f.filters_label_headquarters,count:((Ee=x.headquarter)==null?void 0:Ee.length)||0}].filter(g=>g.count>0):[],j=i.useCallback(g=>{v==null||v(g),L(!1)},[v]);return e.jsxs(i.Fragment,{children:[e.jsxs("div",{className:"position-absolute w-100 pr-3 overflow-hidden zindex-2",children:[e.jsx("div",{className:`position-fixed surface-bg-fill zindex-2 top-0 ${r}`,style:{width:"calc(100% - 126px)",height:"120px"}}),e.jsx("div",{className:`position-fixed surface-bg-fill-gradient zindex-2 h-72 ${r}
1`,style:{top:"76px",width:"calc(100% - 126px)"}})]}),e.jsxs("div",{className:"sticky-top w-100 px-3 zindex-5",style:{top:"56px"},children:[(S||R)&&e.jsx("div",{className:`position-absolute w-100 left-0 surface-bg-blackout zindex-5 ${r}`,style:{height:"66px"}}),e.jsxs("div",{className:`surface-bg-surface ${K?"border-fill-medium-top border-fill-medium-horizontal rounded-16":"border-fill-medium rounded-16"} ${r}`,children:[e.jsxs("div",{className:`h-64 d-flex align-items-center justify-content-between p-2 ${r}`,children:[e.jsxs("div",{className:"d-flex align-items-center gap-2",children:[t&&o&&e.jsx(xt,{selectedService:V(),onServiceSelect:g=>{Q(g),A(!1),D(!1)},isOpen:S,onToggle:X,totalServices:o||[],theme:r,language:f,triggerElement:e.jsxs("div",{className:`position-relative surface-bg-on-surface-alpha border-fill-medium d-flex align-items-center justify-content-center p-2 gap-2 h-35 rounded-pill pe-pointer ${S?"zindex-5":"zindex-0"} ${r}`,children:[e.jsx("div",{className:`label-small-medium content-default-primary text-center px-1 ${r}`,children:$()}),e.jsx(z,{icon:Ge,className:`text-lg bg-transparent content-default-secondary ${r}`})]})}),s>0&&e.jsx("div",{className:`surface-on-surface-hover d-flex align-items-center justify-content-center px-2 py-1 rounded-pill ${r}`,children:e.jsxs("span",{className:`label-XSmall-regular content-default-secondary ${r}`,children:[s," ",f.events_total_label]})})]}),e.jsxs("div",{className:"d-flex gap-2 align-items-center align-self-stretch",children:[e.jsxs("div",{className:"position-relative d-flex gap-2 align-items-center",children:[e.jsx("div",{className:`label-small-medium content-default-secondary text-capitalize ${r}`,children:H()}),e.jsx("div",{ref:M,className:`position-relative w-35 h-35 surface-bg-on-surface-alpha ${u?"border-fill-bold":"border-fill-medium"} d-flex align-items-center justify-content-center rounded-pill pe-pointer hover-icon-border ${r}`,onClick:()=>h(!u),children:e.jsx(z,{icon:Xe,className:`text-lg position-absolute content-default-secondary ${r}`})}),u&&xe.createPortal(e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{position:"fixed",inset:0,zIndex:10001,background:"transparent"},onClick:()=>h(!1)}),e.jsx("div",{style:{position:"fixed",top:M.current?`${M.current.getBoundingClientRect().bottom+8}px`:0,right:M.current?`${window.innerWidth-M.current.getBoundingClientRect().right}px`:0,zIndex:10002,width:300},onClick:g=>g.stopPropagation(),children:e.jsx(pt,{next2Label:null,prev2Label:null,value:(a==null?void 0:a.start)||new Date,minDetail:"year",maxDetail:"year",maxDate:new Date,minDate:new Date("2019-07-01"),className:`surface-bg-surface border-fill-medium txt-phrase txt-8 p-2 rounded-8 ${r}`,nextLabel:e.jsx("div",{className:`column-center align-items-center surface-bg-on-surface rounded-30 p-2 ${r}`,style:{width:30,height:30},children:e.jsx("i",{className:`fa-regular fa-circle-chevron-right txt-10 content-default-tertiary pe-pointer ${r}`})}),prevLabel:e.jsx("div",{className:`column-center align-items-center surface-bg-on-surface rounded-30 p-2 ${r}`,style:{width:30,height:30},children:e.jsx("i",{className:`fa-regular fa-circle-chevron-left txt-10 content-default-tertiary pe-pointer ${r}`})}),onChange:J})})]}),document.body)]}),p&&e.jsx("button",{className:`button-fill-brand button-content-equal d-flex align-items-center justify-content-center px-3 py-2 rounded-pill border-0 cursor-pointer ${r}`,onClick:p,children:e.jsx("span",{className:`label-small-medium ${r}`,children:f.create_event_drawer_title})}),e.jsx("div",{className:`border-fill-medium-left ${r}`,style:{height:"35px"}}),e.jsx(wt,{isOpen:R,onToggle:ne,appliedFilters:x,onFiltersChange:F,showStatusPriority:t,theme:r,language:f,triggerElement:e.jsx(ue,{text:f.events_tooltip_filter,position:"bottom",children:e.jsx("div",{className:`position-relative w-35 h-35 surface-bg-on-surface-alpha ${R?"border-fill-bold":"border-fill-medium"} d-flex align-items-center justify-content-center p-2 rounded-pill pe-pointer hover-icon-border ${R?"zindex-5":"zindex-0"} ${r}`,children:e.jsx(z,{icon:Ye,className:`text-lg position-absolute content-default-secondary ${r}`})})})}),n&&e.jsx(e.Fragment,{children:e.jsx(ue,{text:f.events_tooltip_search,position:"bottom",children:e.jsxs("div",{className:`position-relative h-35 surface-bg-on-surface-alpha ${w?"border-fill-bold":"border-fill-medium"} d-flex align-items-center justify-content-center gap-2 p-2 rounded-pill pe-pointer hover-icon-border ${r}`,style:{width:w?"250px":"35px",transition:"width 300ms ease-in-out, border 300ms ease-in-out"},onClick:w?void 0:ee,children:[e.jsx("div",{className:`position-absolute d-flex align-items-center justify-content-center pe-pointer ${r}`,style:{minWidth:"20px",left:"calc(33px / 2)",transform:"translateX(-50%)"},children:e.jsx(z,{icon:Je,className:`text-lg content-default-secondary pe-pointer ${r}`})}),e.jsx("input",{type:"text",value:P,onChange:g=>k(g.target.value),placeholder:f.events_search_placeholder,className:`flex-1 border-0 bg-transparent content-default-primary label-small-regular ${w?"ps-4":"m-0 p-0"} ${r}`,style:{outline:"none",minWidth:0,width:w?"auto":"0px",opacity:w?"1":"0",pointerEvents:w?"auto":"none"},autoFocus:!0,onClick:g=>g.stopPropagation()}),w&&e.jsx("div",{className:`d-flex align-items-center justify-content-center pe-pointer ${r}`,style:{minWidth:"20px"},onClick:te,children:e.jsx(z,{icon:ge,className:`text-lg content-default-secondary ${r}`})})]})})}),e.jsx(ue,{text:f.events_tooltip_download,position:"bottom",offset:[-30,8],children:e.jsx("div",{className:`position-relative w-35 h-35 surface-bg-on-surface-alpha border-fill-medium d-flex align-items-center justify-content-center rounded-pill pe-pointer hover-icon-border ${r}`,onClick:()=>L(!0),children:e.jsx(z,{icon:Ue,className:`text-lg position-absolute content-default-secondary ${r}`})})})]})]}),K&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:`mx-3 border-fill-medium-top ${r}`}),e.jsxs("div",{className:`d-flex align-items-center justify-content-end gap-2 px-3 py-3 rounded-bottom-16 ${r}`,style:{transition:"max-height 0.3s ease-in-out",maxHeight:"200px",overflow:"hidden"},children:[e.jsxs("span",{className:`label-small-regular content-default-tertiary ${r}`,children:[f.filters_title,":"]}
1),e.jsx("div",{className:"d-flex align-items-center gap-2 flex-wrap",children:_.map(({key:g,label:G,count:he})=>e.jsxs("div",{className:`d-flex align-items-center gap-2 py-2 ps-3 pe-2 rounded-pill surface-bg-on-surface ${r}`,children:[e.jsxs("span",{className:`label-small-regular content-default-primary ${r}`,children:[G," (",he,")"]}),e.jsx("div",{className:`d-flex align-items-center justify-content-center pe-pointer ${r}`,onClick:()=>Y(g),children:e.jsx(z,{icon:Ke,className:`text-base content-default-tertiary ${r}`})})]},g))})]})]})]})]}),e.jsx(Et,{show:y,onHide:()=>L(!1),theme:r,language:f,onExport:j,dateRange:x==null?void 0:x.dateRange})]})},St=s=>({theme:s.theme.theme,language:s.shared.language,selectedServiceId:s.events.selectedServiceId,eventsAppliedFilters:s.events.eventsAppliedFilters}),It=s=>({setEventsSearchTerm:n=>s(Be(n)),setShowBlackScreen:n=>s(He(n)),setEventsSelectedServiceId:n=>s(ze(n)),setEventsAppliedFilters:n=>s(tt(n))}),We=re(St,It)(kt),Pt=({statusData:s,priorityData:n,theme:t,language:o,activeFilter:a,onFilterChange:c})=>{const[v,p]=i.useState({width:window.innerWidth});i.useEffect(()=>{const f=()=>p({width:window.innerWidth});return window.addEventListener("resize",f),()=>window.removeEventListener("resize",f)},[]);const r=f=>a===W.NONE||a===f?1:.3;return e.jsxs("div",{className:`d-grid gap-3 ${t}`,style:{gridTemplateColumns:v.width>1018?"1fr 1fr":"1fr"},children:[e.jsxs("div",{className:`surface-bg-surface border-fill-medium rounded-16 p-3 d-flex flex-column gap-2 ${t}`,children:[e.jsx("p",{className:`label-medium-medium content-default-primary m-0 ${t}`,children:o.events_indicators_status_title}),e.jsxs("div",{className:"d-flex align-items-center justify-content-end gap-2 w-100",children:[e.jsxs("div",{className:`bg-alpha-orange-32 border-color-orange rounded-8 px-2 py-1 d-flex align-items-center justify-content-between gap-2 ${t}`,style:{flex:"1",cursor:"pointer",opacity:r(W.OPEN),transition:"opacity 0.2s ease"},onClick:()=>c(W.OPEN),children:[e.jsxs("div",{className:"d-flex align-items-center gap-2",children:[e.jsx("div",{className:"d-flex align-items-center justify-content-center",style:{width:"15px",height:"15px"},children:e.jsx(z,{icon:Re,size:"md",className:`content-color-orange ${t}`})}),e.jsx("span",{className:`paragraph-small-regular content-color-orange ${t}`,children:o.events_indicators_open_title})]}),e.jsx("p",{className:`paragraph-medium-semibold content-color-orange m-0 ${t}`,children:s.open})]}),e.jsxs("div",{className:`bg-alpha-primary-brand-32 border-color-green rounded-8 px-2 py-1 d-flex align-items-center justify-content-between gap-2 ${t}`,style:{flex:"1",cursor:"pointer",opacity:r(W.RESOLVED),transition:"opacity 0.2s ease"},onClick:()=>c(W.RESOLVED),children:[e.jsxs("div",{className:"d-flex align-items-center gap-2",children:[e.jsx("div",{className:"d-flex align-items-center justify-content-center",style:{width:"15px",height:"15px"},children:e.jsx(z,{icon:Oe,size:"md",className:`content-color-green ${t}`})}),e.jsx("span",{className:`paragraph-small-regular content-color-green ${t}`,children:o.events_indicators_resolved_title})]}),e.jsx("p",{className:`paragraph-medium-semibold content-color-green m-0 ${t}`,children:s.resolved})]})]})]}),e.jsxs("div",{className:`surface-bg-surface border-fill-medium rounded-16 p-3 d-flex flex-column gap-2 ${t}`,children:[e.jsx("p",{className:`label-medium-medium content-default-primary m-0 ${t}`,children:o.events_indicators_priority_title}),e.jsxs("div",{className:"d-flex align-items-center justify-content-end gap-2 w-100",children:[e.jsx("div",{className:`surface-bg-on-surface border-fill-light flex-fill rounded-8 px-2 py-1 d-flex align-items-center ${t}`,style:{cursor:"pointer",opacity:r(W.CRITICAL),transition:"opacity 0.2s ease"},onClick:()=>c(W.CRITICAL),children:e.jsxs("div",{className:"flex-fill d-flex align-items-center justify-content-between gap-2 w-100",children:[e.jsxs("div",{className:"d-flex align-items-center gap-2 w-100",children:[e.jsx("div",{className:"d-flex align-items-center justify-content-center",style:{width:"15px",height:"15px"},children:e.jsx(z,{icon:Le,size:"md",className:`content-color-red ${t}`})}),e.jsx("p",{className:`paragraph-small-regular content-color-red m-0 ${t}`,children:o.events_priority_critical})]}),e.jsxs("div",{className:"d-flex align-items-center gap-1",children:[e.jsx("p",{className:`paragraph-medium-semibold content-default-primary m-0 ${t}`,children:n.critical}),e.jsxs("p",{className:`paragraph-XSmall-regular content-default-tertiary m-0 ${t}`,children:["/",n.total]})]})]})}),e.jsx("div",{className:`surface-bg-on-surface border-fill-light flex-fill rounded-8 px-2 py-1 d-flex align-items-center ${t}`,style:{cursor:"pointer",opacity:r(W.MAJOR),transition:"opacity 0.2s ease"},onClick:()=>c(W.MAJOR),children:e.jsxs("div",{className:"d-flex align-items-center justify-content-between gap-2 w-100",children:[e.jsxs("div",{className:"d-flex align-items-center gap-2 w-100",children:[e.jsx("div",{className:"d-flex align-items-center justify-content-center",style:{width:"15px",height:"15px"},children:e.jsx(z,{icon:Me,size:"md",className:`content-color-orange ${t}`})}),e.jsx("p",{className:`paragraph-small-medium content-color-orange m-0 ${t}`,children:o.events_priority_major})]}),e.jsxs("div",{className:"d-flex align-items-center gap-1",children:[e.jsx("p",{className:`paragraph-medium-semibold content-default-primary m-0 ${t}`,children:n.major}),e.jsxs("p",{className:`paragraph-XSmall-regular content-default-tertiary m-0 ${t}`,children:["/",n.total]})]})]})}),e.jsx("div",{className:`surface-bg-on-surface border-fill-light flex-fill rounded-8 px-2 py-1 d-flex align-items-center ${t}`,style:{cursor:"pointer",opacity:r(W.MINOR),transition:"opacity 0.2s ease"},onClick:()=>c(W.MINOR),children:e.jsxs("div",{className:"d-flex align-items-center justify-content-between gap-2 w-100",children:[e.jsxs("div",{className:"d-flex align-items-center gap-2 w-100",children:[e.jsx("div",{className:"d-flex align-items-center justify-content-center",style:{width:"15px",height:"15px"},children:e.jsx(z,{icon:Ne,size:"md",className:`content-color-orange ${t}`})}),e.jsx("p",{className:`paragraph-small-medium content-color-orange m-0 ${t}`,children:o.events_priority_minor})]}),e.jsxs("div",{className:"d-flex align-items-center gap-1",children:[e.jsx("p",{className:`paragraph-medium-semibold content-default-primary m-0 ${t}`,children:n.minor}),e.jsxs("p",{className:`paragraph-XSmall-regular content-default-tertiary m-0 ${t}`,children:["/",n.total]})]})]})})]})]})]})},Tt=(s,n)=>({theme:n.theme||s.theme.theme,language:n.language||s.shared.language}),Rt=re(Tt)(Pt),Ot={1:Le,2:Me,3:Ne},Lt={1:"content-color-red",2:"content-color-orange",3:"content-color-orange"},Mt={1:"border-color-red",2:"border-color-orange",3:"border-color-orange"},zt={1:"bg-alpha-red-8",2:"bg-alpha-orange-8",3:"bg-alpha-orange-8"},Bt=({show:s,onHide:n,event:t,serviceName:o,theme:a,language:c,onCommentAdded:v,onEventClosed:p,user:r,updateEvent:f})=>{var j;const b=((j=r==null?void 0:r.capabilities)==null?void 0:j.update_generation_events)||!1,[x,C]=i.useState(!1),[D,B]=i.useState(""),[T,S]=i.useState([]),[A,R]=i.useState(!1),[m,w]=i.useState(!1),[I,P]=i.useState(!1),[k,u]=i.useState(null),[h,y]=i.useState(!1),L=i.useRef(null);if(i.useEffect(()=>{s&&t&&(C(!1),B(""),P(!1),u(null),M())},[s,t]),!t)return null;const M=()=>{R(!0),setTimeout(()=>{S(t.comments||[]),R(!1)},300)},K=async()=>
1{if(m)return;w(!0);const l=D.trim();if(f(t.id_event,{...I&&k?{endDate:k}:{},...l?{comment:l}:{}}),l){const d={id_comment:`temp-${Date.now()}`,comment:l,user_name:r?`${r.name} ${r.lastname}`:"---",created_at:new Date().toISOString()};S(E=>[...E,d]),v==null||v(t.id_event,l),B("")}gt.info(c.events_alert_update_success),I&&k&&(p==null||p(t.id_event,k.toISOString()),n()),w(!1)},V=l=>{if(!l)return{date:"",time:""};const d=Ae(new Date(l),5);return{date:U(d,"yyyy-MM-dd"),time:U(d,"HH:mm")}},$=()=>t.start_date?((t.end_date?new Date(t.end_date):new Date)-new Date(t.start_date))/6e4:0,H=l=>{if(!l&&l!==0)return"";const d=Math.round(l),E=Math.floor(d/1440),O=Math.floor(d%1440/60),q=d%60;return E>0?`${E}${c.events_duration_days} ${O}${c.events_duration_hours} ${q}${c.events_duration_minutes}`:`${O}${c.events_duration_hours} ${q}${c.events_duration_minutes}`},Q=l=>l?U(new Date(l),"d 'de' MMMM yyyy HH:mm",{locale:Ie}):"",J=I&&!!k||!!D.trim(),F=V(t.start_date),Y=t.end_date?V(t.end_date):null,X=!t.end_date,ne=Ot[t.priority]||Ne,ee=Lt[t.priority]||"content-default-secondary",te=Mt[t.priority]||"border-fill-bold",_=zt[t.priority]||"button-fill-disabled";return e.jsx(yt,{show:s,size:"xs",placement:"right",backdropClassName:`pe-pointer ${a}`,onHide:n,children:e.jsxs("div",{className:`d-flex flex-column align-items-center vh-100 w-100 border-fill-medium-left overflow-y-hidden surface-bg-surface ${a}`,children:[e.jsxs("div",{className:"flex-1 d-flex flex-column gap-3 w-100 py-3 overflow-y-scroll scroll-without-border",children:[e.jsxs("div",{className:"d-flex gap-3 align-items-start w-100 mb-1 px-3",children:[e.jsx("div",{className:`surface-bg-on-surface border-fill-medium rounded-16 d-flex align-items-center justify-content-center p-2 cursor-pointer ${a}`,style:{width:"32px",height:"32px"},onClick:n,children:e.jsx(z,{icon:ge,className:`content-default-primary ${a}`,style:{fontSize:"16px"}})}),e.jsx("div",{className:"h-100 d-flex flex-column flex-grow-1 align-items-end justify-content-center",children:e.jsx("h6",{className:`heading-h6-semibold content-default-primary text-end w-100 m-0 ${a}`,children:c.events_section_title})})]}),e.jsx("div",{className:"d-flex flex-column gap-3 px-4",children:e.jsxs("div",{className:"d-flex flex-column gap-1",children:[e.jsx("p",{className:`heading-h6-semibold content-default-primary m-0 ${a}`,children:t.description||"---"}),e.jsx("p",{className:`label-medium-medium content-default-tertiary m-0 ${a}`,children:o||"---"})]})}),e.jsxs("div",{className:"d-flex gap-2 py-1 px-4",children:[e.jsxs("div",{className:`${_} ${te} d-flex align-items-center justify-content-center ps-1 pe-2 py-1 gap-1 rounded-pill ${a}`,children:[e.jsx(z,{icon:ne,size:"md",className:`${ee} ${a}`}),e.jsx("p",{className:`label-medium-regular ${ee} m-0 ${a}`,children:c[t.firebase_value]||""})]}),e.jsxs("div",{className:`${X?"bg-alpha-orange-8 content-color-orange border-color-orange":"bg-alpha-primary-brand-8 content-color-green border-color-green"} d-flex align-items-center justify-content-center ps-1 pe-2 py-1 gap-1 rounded-pill ${a}`,children:[e.jsx(z,{icon:X?Re:Oe,size:"md",className:`${X?"content-color-orange":"content-color-green"} ${a}`}),e.jsx("p",{className:`label-medium-regular m-0 ${X?"content-color-orange":"content-color-green"} ${a}`,children:X?c.events_status_open:c.events_status_resolved})]})]}),e.jsxs("div",{className:"d-flex gap-4 px-4",children:[e.jsxs("div",{className:"d-flex flex-column gap-2",style:{flex:2},children:[e.jsx("p",{className:`label-large-semibold content-default-primary m-0 text-nowrap ${a}`,children:c.events_drawer_detail_period}),e.jsxs("div",{className:"d-flex gap-3 align-items-center",children:[e.jsx("p",{className:`label-medium-medium content-default-secondary m-0 ${a}`,children:F.date||"-"}),e.jsx("div",{className:`border-fill-medium-left ${a}`,style:{width:"1px",height:"16px"}}),e.jsx("p",{className:`label-medium-medium content-default-secondary m-0 ${a}`,children:F.time||"-"})]}),X?I?e.jsxs("div",{className:"d-flex align-items-center gap-2",children:[e.jsxs("div",{ref:L,className:`flex-grow-1 d-flex align-items-center justify-content-between ps-3 pe-2 py-2 surface-bg-on-surface-alpha border-fill-regular rounded-pill cursor-pointer ${a}`,onClick:()=>y(!h),children:[e.jsx("span",{className:`label-small-regular content-default-secondary ${a}`,children:k?U(k,"yyyy-MM-dd HH:mm"):"-- / -- / ----"}),e.jsx(le,{icon:"faCalendar",iconType:"light",size:"32",theme:a,iconClassName:"content-default-secondary"})]}),e.jsx("div",{className:`surface-bg-on-surface-alpha border-fill-regular rounded-pill d-flex align-items-center justify-content-center cursor-pointer flex-shrink-0 ${a}`,style:{width:"32px",height:"32px"},onClick:()=>{P(!1),u(null)},children:e.jsx(z,{icon:ge,className:`content-default-primary ${a}`,style:{fontSize:"14px"}})}),h&&L.current&&xe.createPortal(e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{position:"fixed",inset:0,zIndex:10001,background:"transparent"},onClick:()=>y(!1)}
1),e.jsx("div",{style:{position:"fixed",top:L.current.getBoundingClientRect().bottom+8,right:window.innerWidth-L.current.getBoundingClientRect().right,zIndex:10002},onClick:l=>l.stopPropagation(),children:e.jsx(nt,{show:h,setShow:y,date:k,setDate:u,language:c,theme:a,disableInternalPositioning:!0})})]}),document.body)]}):e.jsxs("div",{className:"d-flex align-items-center justify-content-between gap-3",children:[e.jsx("p",{className:`label-medium-medium content-default-secondary m-0 ${a}`,children:c.events_drawer_detail_open}),b&&e.jsx("button",{className:`button-fill-brand button-content-equal d-flex align-items-center justify-content-center px-3 py-2 rounded-pill border-0 cursor-pointer ${a}`,onClick:()=>P(!0),children:e.jsx("span",{className:`label-small-medium ${a}`,children:c.events_drawer_detail_close_toggle})})]}):e.jsxs("div",{className:"d-flex gap-3 align-items-center",children:[e.jsx("p",{className:`label-medium-medium content-default-secondary m-0 ${a}`,children:(Y==null?void 0:Y.date)||"-"}),e.jsx("div",{className:`border-fill-medium-left ${a}`,style:{width:"1px",height:"16px"}}),e.jsx("p",{className:`label-medium-medium content-default-secondary m-0 ${a}`,children:(Y==null?void 0:Y.time)||"-"})]})]}),e.jsxs("div",{className:"d-flex flex-column gap-2",style:{flex:1.5},children:[e.jsx("p",{className:`label-large-semibold content-default-primary m-0 text-end ${a}`,children:c.events_drawer_detail_duration}),e.jsxs("p",{className:`label-medium-regular content-color-orange m-0 text-end ${a}`,children:[H($()),X?` (${c.events_drawer_detail_until_now})`:""]})]})]}),e.jsxs("div",{className:"d-flex flex-column gap-3 px-4",children:[e.jsxs("div",{className:"d-flex align-items-center justify-content-between",style:{height:"32px"},children:[e.jsx("p",{className:`label-large-semibold content-default-primary m-0 ${a}`,children:c.events_drawer_detail_comments_history}),e.jsx("div",{className:`surface-bg-on-surface border-fill-medium rounded-16 d-flex align-items-center justify-content-center cursor-pointer ${a}`,style:{width:"32px",height:"32px"},onClick:()=>C(!x),children:e.jsx(z,{icon:x?de:Se,className:`content-default-primary ${a}`,style:{fontSize:"16px"}})})]}),x&&e.jsx("div",{className:"d-flex flex-column gap-4 position-relative",style:{paddingLeft:"1px"},children:A?Array(3).fill(0).map((l,d)=>e.jsxs("div",{className:"d-flex gap-4 align-items-center",children:[e.jsx(N,{width:"28px",height:"28px",borderRadius:"50%",theme:a}),e.jsxs("div",{className:"d-flex flex-column gap-2 flex-grow-1",children:[e.jsx(N,{width:"200px",height:"16px",theme:a}),e.jsx(N,{width:"160px",height:"12px",theme:a})]})]},d)):e.jsxs(e.Fragment,{children:[T.map((l,d)=>d<T.length-1?e.jsx("div",{className:`position-absolute surface-on-surface-hover ${a}`,style:{left:"14px",top:`${34+d*56}px`,width:"2px",height:"20px"}},`connector-${d}`):null),T.map((l,d)=>e.jsxs("div",{className:"d-flex gap-4 align-items-center",children:[e.jsx("div",{className:`surface-bg-os-alpha border-fill-medium d-flex align-items-center justify-content-center rounded-pill ${a}`,style:{width:"28px",height:"28px"},children:e.jsx(z,{icon:Qe,className:`content-default-secondary ${a}`,style:{fontSize:"12px"}})}),e.jsxs("div",{className:"d-flex flex-column gap-1 flex-grow-1",children:[e.jsx("p",{className:`label-small-medium content-default-primary m-0 ${a}`,children:l.comment}),e.jsxs("p",{className:`label-XSmall-regular content-default-tertiary m-0 ${a}`,children:[l.user_name," - ",Q(l.created_at)]})]})]},`comment-${d}`)),T.length===0&&e.jsx("p",{className:`label-small-medium content-default-tertiary m-0 ${a}`,children:c.events_drawer_detail_no_comments})]})})]}),b&&e.jsxs("div",{className:"d-flex flex-column gap-3 px-4",children:[e.jsx("p",{className:`label-large-semibold content-default-primary m-0 ${a}`,children:c.events_drawer_detail_observations}),e.jsx("div",{className:`surface-bg-surface border-fill-regular d-flex gap-1 align-items-start px-3 py-2 rounded-16 ${a}`,style:{height:"115px"},children:e.jsx("textarea",{className:`flex-grow-1 border-0 surface-bg-surface label-medium-medium placeholder-content-default-tertiary content-default-primary ${a}`,style:{backgroundColor:"transparent",outline:"none",resize:"none",width:"100%",height:"100%"},placeholder:c.events_drawer_detail_additional_comments_placeholder,value:D,onChange:l=>B(l.target.value)})})]})]}),b&&e.jsx("div",{className:`surface-bg-surface border-fill-medium-top d-flex gap-3 align-items-center justify-content-end px-3 py-3 position-sticky w-100 ${a}`,style:{bottom:0,backdropFilter:"blur(25px)"},children:e.jsx("button",{className:`${J&&!m?"button-fill-brand button-content-equal":"button-fill-disabled button-content-disabled"} d-flex align-items-center justify-content-center px-3 py-2 rounded-pill border-0 ${a}`,style:{opacity:J&&!m?1:.5,cursor:J&&!m?"pointer":"not-allowed"},disabled:!J||m,onClick:K,children:e.jsx("p",{className:`label-medium-medium m-0 ${a}`,children:m?c.events_drawer_detail_sending_comments:I?c.events_drawer_detail_close_toggle:c.events_drawer_detail_send_comments})})})]})})},At=s=>({theme:s.theme.theme,user:s.users.user}),Vt=s=>({updateEvent:(n,t)=>s(st(n,t))}),Wt=re(At,Vt)(Bt),Ht=s=>[{key:"description",label:s.events_table_description},{key:"start_date",label:s.events_table_start,format:"datetime"},{key:"end_date",label:s.events_table_end,format:"datetime"},{key:"duration",label:s.events_table_duration,format:"duration"},{key:"priority",label:s.events_table_priority,format:"priority"}],qt={critical:1,major:2,minor:3},Gt={critical:"events_priority_critical",major:"events_priority_major",minor:"events_priority_minor"}
1,Xt=({theme:s,language:n,user:t,eventsDetail:o,eventsDetailLoading:a,eventsAppliedFilters:c,selectedServiceId:v,flatServices:p,selectedMonth:r,onMonthChange:f,onBack:b,loadEventsDetailAsync:x,setEventsDetail:C,setEventsDetailLoading:D,createEvent:B,addEventLocally:T,closeEventLocally:S})=>{var te,_,j;const A=((te=t==null?void 0:t.capabilities)==null?void 0:te.create_generation_events)||!1,[R,m]=i.useState(W.NONE),[w,I]=i.useState(null),[P,k]=i.useState(!1),[u,h]=i.useState(!1),[y,L]=i.useState([]);i.useEffect(()=>{L(o)},[o]),i.useEffect(()=>{v&&x(v,r.start,r.end)},[r,v]),i.useEffect(()=>()=>{C([]),D(!0)},[]);const M=l=>{switch(R){case W.OPEN:return l.filter(d=>d.status==="open");case W.RESOLVED:return l.filter(d=>d.status==="resolved");case W.CRITICAL:return l.filter(d=>d.priority===1);case W.MAJOR:return l.filter(d=>d.priority===2);case W.MINOR:return l.filter(d=>d.priority===3);default:return l}},V=((l,d)=>{var O,q;if(!d)return l;let E=l;return((O=d.status)==null?void 0:O.length)>0&&(E=E.filter(se=>d.status.includes(se.status))),((q=d.priority)==null?void 0:q.length)>0&&(E=E.filter(se=>d.priority.includes(se.priority))),E})(y,c),$=M(V),H={open:V.filter(l=>l.status==="open").length,resolved:V.filter(l=>l.status==="resolved").length},Q={critical:V.filter(l=>l.priority===1).length,major:V.filter(l=>l.priority===2).length,minor:V.filter(l=>l.priority===3).length,total:V.length},J=l=>{I(l),k(!0)},F=()=>{k(!1),I(null)},Y=l=>{m(d=>d===l?W.NONE:l)},X=(l,d)=>{S(l,v,d)},ne=l=>{var q,se;const d=((q=p==null?void 0:p.find(ae=>ae.id_service===v))==null?void 0:q.service_name)||((se=p==null?void 0:p.find(ae=>ae.id_service===v))==null?void 0:se.name),E=ae=>new Date(new Date(ae).getTime()-5*60*60*1e3).toISOString(),O={id_event:`temp-${Date.now()}`,description:l.description,start_date:E(l.start_date),end_date:l.end_date?E(l.end_date):null,duration:l.end_date?(new Date(l.end_date)-new Date(l.start_date))/6e4:0,status:l.end_date?"resolved":"open",priority:qt[l.priority],firebase_value:Gt[l.priority],comments:[]};T(O,v,d),B(v,l)},ee=(l,d)=>{const E={id_comment:`temp-${Date.now()}`,comment:d,user_name:t?`${t.name} ${t.lastname}`:"---",created_at:new Date().toISOString()};L(O=>O.map(q=>q.id_event===l?{...q,comments:[...q.comments||[],E]}:q))};return a?e.jsx(i.Fragment,{children:e.jsxs("div",{className:`position-relative w-100 d-flex flex-column surface-bg-fill overflow-y-auto pb-3 h-screen ${s}`,children:[e.jsx(me,{moduleName:n.events_section_title,backToButton:!0,onBackClick:b}),e.jsxs("div",{className:`flex-fill d-flex flex-column gap-3 px-3 rounded-16 ${s}`,children:[e.jsxs("div",{className:`surface-bg-surface border-fill-medium rounded-16 d-flex align-items-center justify-content-between px-2 py-3 ${s}`,children:[e.jsxs("div",{className:"d-flex gap-2 align-items-center",children:[e.jsx(N,{width:"150px",height:"25px",borderRadius:"20px",theme:s}),e.jsx(N,{width:"50px",height:"25px",borderRadius:"20px",theme:s})]}),e.jsxs("div",{className:"d-flex gap-2 align-items-center align-self-stretch",children:[e.jsx(N,{width:"35px",height:"35px",borderRadius:"50%",theme:s}),e.jsx(N,{width:"35px",height:"35px",borderRadius:"50%",theme:s}),e.jsx(N,{width:"35px",height:"35px",borderRadius:"50%",theme:s})]})]}),e.jsxs("div",{className:`d-grid gap-3 ${s}`,style:{gridTemplateColumns:"1fr 1fr"},children:[e.jsxs("div",{className:`surface-bg-surface border-fill-medium rounded-16 p-3 d-flex flex-column gap-3 ${s}`,children:[e.jsx(N,{width:"150px",height:"20px",theme:s}),e.jsxs("div",{className:"d-flex gap-2",children:[e.jsx(N,{width:"100%",height:"50px",theme:s}),e.jsx(N,{width:"100%",height:"50px",theme:s})]})]}),e.jsxs("div",{className:`surface-bg-surface border-fill-medium rounded-16 p-3 d-flex flex-column gap-3 ${s}`,children:[e.jsx(N,{width:"130px",height:"20px",theme:s}),e.jsxs("div",{className:"d-flex gap-2",children:[e.jsx(N,{width:"100%",height:"50px",theme:s}),e.jsx(N,{width:"100%",height:"50px",theme:s}),e.jsx(N,{width:"100%",height:"50px",theme:s})]})]})]}),e.jsxs("div",{className:`surface-bg-surface border-fill-medium rounded-16 p-3 d-flex flex-column gap-3 ${s}`,children:[e.jsxs("div",{className:"d-flex align-items-center justify-content-between gap-2",children:[e.jsx(N,{width:"200px",height:"24px",theme:s}),e.jsxs("div",{className:"d-flex gap-3 align-items-center",children:[e.jsx(N,{width:"80px",height:"20px",borderRadius:"20px",theme:s}),e.jsx(N,{width:"32px",height:"32px",borderRadius:"16px",theme:s})]})]}),e.jsx(N,{width:"100%",height:"40px",theme:s}),Array(5).fill(0).map((l,d)=>e.jsx(N,{width:"100%",height:"60px",theme:s},d))]})]})]})}):e.jsxs("div",{className:"position-relative w-100 h-screen d-flex flex-column overflow-y-auto",children:[e.jsx(me,{moduleName:n.events_section_title,backToButton:!0,onBackClick:b}),e.jsxs("div",{className:`flex-1 position-relative flex-fill d-flex flex-column gap-3 pb-3 rounded-16 ${s}`,children:[e.jsx(We,{showSearch:!1,showServicePicker:!0,totalServices:p,totalIncidents:$.length,selectedMonth:r,onMonthChange:f,onCreateEvent:A?()=>h(!0):void 0}),e.jsx("div",{className:"w-100 px-3",children:e.jsx(Rt,{statusData:H,priorityData:Q,activeFilter:R,onFilterChange:Y})}),$.length===0?e.jsxs("div",{className:`flex-1 d-flex flex-column align-items-center justify-content-center gap-4 px-3 py-5 ${s}`,children:[e.jsx("img",{src:s===_e.DARK?be:je,alt:"No events",style:{maxWidth:"300px"}}),e.jsxs("div",{className:"d-flex flex-column align-items-center gap-1",children:[e.jsx("h1",{className:`paragraph-large-semibold content-default-primary text-center ${s}`,children:n.events_empty_state_title}),e.jsx("p",{className:`max-width-500 paragraph-medium-regular content-default-tertiary text-center ${s}`,children:n.events_empty_state_message})]})]}):e.jsx("div",{className:`px-3 ${s}`,children:e.jsx(Ve,{title:n.events_section_title,data:$,columns:Ht(n),gridTemplateColumns:"2fr 1fr 1fr 130px 100px",onRowClick:J,language:n})})]}),e.jsx(Wt,{show:P,onHide:F,event:w,serviceName:((_=p==null?void 0:p.find(l=>l.id_service===v))==null?void 0:_.service_name)||((j=p==null?void 0:p.find(l=>l.id_service===v))==null?void 0:j.name),theme:s,language:n,onCommentAdded:ee,onEventClosed:X}),e.jsx(dt,{show:u,onHide:()=>h(!1),onSubmit:ne})]})},Yt=s=>({theme:s.theme.theme,language:s.shared.language,user:s.users.user,eventsDetail:s.events.eventsDetail,eventsDetail
1Loading:s.events.eventsDetailLoading,eventsAppliedFilters:s.events.eventsAppliedFilters,selectedServiceId:s.events.selectedServiceId}),Jt=s=>({loadEventsDetailAsync:(n,t,o)=>s(ct(n,t,o)),closeEventLocally:(n,t,o)=>s(ot(n,t,o)),setEventsDetail:n=>s(it(n)),setEventsDetailLoading:n=>s(rt(n)),createEvent:(n,t)=>s(lt(n,t)),addEventLocally:(n,t,o)=>s(at(n,t,o))}),Ut=re(Yt,Jt)(Xt),Z={summary:"summary",detail:"detail"},Kt=s=>{var M,K,V;const{theme:n,language:t,eventsData:o,eventsDataLoading:a,servicesWithDevices:c,servicesWithDevicesLoading:v,searchTerm:p}=s,r=vt(),f=bt(),[b,x]=i.useState(Z.summary),[C,D]=i.useState(()=>{const H=Pe(new Date),Q=pe(Te(H,1),-1);return{start:H,end:Q}}),B=i.useRef(!0),T=((M=r.state)==null?void 0:M.fromMenu)||!1,S=(V=(K=r.state)==null?void 0:K.data)==null?void 0:V.idService,A=[{key:"service_name",label:t.events_table_service_name},{key:"start_date",label:t.events_table_first_event,format:"datetime"},{key:"end_date",label:t.events_table_last_event,format:"datetime"},{key:"active_events",label:t.events_table_active_events},{key:"total_events",label:t.events_table_total_events}],R=c.flatMap($=>$.services.map(H=>({...H,id_headquarter:$.id_headquarter,headquarter_name:$.name}))),m=o.filter($=>$.service_name.toLowerCase().includes(p.toLowerCase())),w=m.reduce(($,H)=>$+(Number(H.total_events)||0),0),I=v||a&&b===Z.summary,P=()=>{b===Z.summary&&s.loadEventsDataAsync(C.start,C.end)},k=$=>{x($),s.setEventsSearchTerm("")},u=()=>{b===Z.detail?k(Z.summary):f(Ze())},h=$=>{s.setEventsSelectedServiceId($.id_service),ve($.id_service),k(Z.detail)};i.useEffect(()=>{if(B.current){B.current=!1;return}P()},[C,b]);const y=i.useRef(!1);i.useEffect(()=>{y.current||a||(y.current=!0,oe("Novelties Viewed",{incident_quantity:w}))},[a,w]),i.useEffect(()=>{s.loadServicesForEventsAsync().then(()=>P())},[]);const L=i.useRef(!1);return i.useEffect(()=>{S&&!L.current&&(L.current=!0,s.setEventsSelectedServiceId(S),ve(S),k(Z.detail))},[S]),I?e.jsx(i.Fragment,{children:e.jsxs("div",{className:`position-relative w-100 d-flex flex-column surface-bg-fill overflow-y-auto pb-3 h-screen ${n}`,children:[e.jsx(me,{moduleName:t.events_section_title,backToButton:!T,onBackClick:u,disableGrow:!0}),e.jsxs("div",{className:`flex-fill d-flex flex-column gap-3 px-3 rounded-16 ${n}`,children:[e.jsxs("div",{className:`surface-bg-surface border-fill-medium rounded-16 d-flex align-items-center justify-content-between px-2 py-3 ${n}`,children:[e.jsxs("div",{className:"d-flex gap-2 align-items-center",children:[e.jsx(N,{width:"150px",height:"25px",borderRadius:"20px",theme:n}),e.jsx(N,{width:"50px",height:"25px",borderRadius:"20px",theme:n})]}),e.jsxs("div",{className:"d-flex gap-2 align-items-center align-self-stretch",children:[e.jsx(N,{width:"35px",height:"35px",borderRadius:"50%",theme:n}),e.jsx(N,{width:"35px",height:"35px",borderRadius:"50%",theme:n}),e.jsx(N,{width:"35px",height:"35px",borderRadius:"50%",theme:n})]})]}),b!==Z.summary&&e.jsx("div",{className:`d-grid gap-3 ${n}`,style:{gridTemplateColumns:"1fr 1fr"},children:[1,2].map($=>e.jsxs("div",{className:`surface-bg-surface border-fill-medium rounded-16 p-3 d-flex flex-column gap-3 ${n}`,children:[e.jsx(N,{width:"150px",height:"20px",theme:n}),e.jsxs("div",{className:"d-flex gap-2",children:[e.jsx(N,{width:"100%",height:"50px",theme:n}),e.jsx(N,{width:"100%",height:"50px",theme:n})]})]},$))}),e.jsxs("div",{className:`surface-bg-surface border-fill-medium rounded-16 p-3 d-flex flex-column gap-3 ${n}`,children:[e.jsxs("div",{className:"d-flex align-items-center justify-content-between gap-2",children:[e.jsx(N,{width:"200px",height:"24px",theme:n}),e.jsxs("div",{className:"d-flex gap-3 align-items-center",children:[e.jsx(N,{width:"80px",height:"20px",borderRadius:"20px",theme:n}),e.jsx(N,{width:"32px",height:"32px",borderRadius:"16px",theme:n})]})]}),e.jsx(N,{width:"100%",height:"40px",theme:n}),Array(3).fill(0).map(($,H)=>e.jsx(N,{width:"100%",height:"60px",theme:n},H))]})]})]})}):b===Z.detail?e.jsx(Ut,{onBack:()=>k(Z.summary),flatServices:R,selectedMonth:C,onMonthChange:D}):e.jsxs("div",{className:"position-relative w-100 h-screen d-flex flex-column overflow-y-auto",children:[e.jsx(me,{moduleName:t.events_section_title,backToButton:!T,onBackClick:u,disableGrow:!0}),e.jsxs("div",{className:`flex-1 position-relative flex-fill d-flex flex-column gap-3 pb-3 rounded-16 ${n}`,children:[e.jsx(We,{showSearch:!0,showServicePicker:!1,totalIncidents:w,selectedMonth:C,onMonthChange:D}),m.length===0?e.jsxs("div",{className:`flex-1 d-flex flex-column align-items-center justify-content-center gap-4 px-3 py-5 ${n}`,children:[e.jsx("img",{src:n===_e.DARK?be:je,alt:"No events",style:{maxWidth:"300px"}}),e.jsxs("div",{className:"d-flex flex-column align-items-center gap-1",children:[e.jsx("h1",{className:`paragraph-large-semibold content-default-primary text-center ${n}`,children:t.events_empty_state_title}),e.jsx("p",{className:`max-width-500 paragraph-medium-regular content-default-tertiary text-center ${n}`,children:t.events_empty_state_message})]})]}):e.jsx("div",{className:`px-3 ${n}`,children:e.jsx(Ve,{title:t.events_section_title,data:m,columns:A,gridTemplateColumns:"1fr 1.5fr 1.5fr 130px 130px",onRowClick:h,language:t})})]})]})},Qt=s=>({theme:s.theme.theme,language:s.shared.language,eventsData:s.events.eventsData,eventsDataLoading:s.events.eventsDataLoading,searchTerm:s.events.searchTerm,servicesWithDevices:s.events.servicesWithDevices,servicesWithDevicesLoading:s.events.servicesWithDevicesLoading,user:s.users.user}),Zt=s=>({loadEventsDataAsync:(n,t)=>s(mt(n,t)),loadServicesForEventsAsync:()=>s(ut()),setEventsSelectedServiceId:n=>s(ze(n)),setEventsSearchTerm:n=>s(Be(n))}),ms=re(Qt,Zt)(Kt);export{ms as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.