PageSourceSearch

https://app.ionwater.io/_next/static/chunks/897-80f7a77c78958c8c.js

js ionwater.io collected 2026-10-08 23:49:25 UTC 551,545 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[897],{1275:(e,a,t)=>{t.d(a,{Sb:()=>x,US:()=>c,aD:()=>h,eC:()=>p,tE:()=>d,y8:()=>u});var l=t(95155),s=t(12115),r=t(65476),n=t(83101),i=t(65229),o=t(64269);let d=r.Kq,c=s.forwardRef((e,a)=>{let{className:t,...s}=e;return(0,l.jsx)(r.LM,{ref:a,className:(0,o.cn)("fixed top-0 z-100 flex max-h-screen w-full flex-col p-4 sm:right-0 md:max-w-[420px]",t),...s})});c.displayName=r.LM.displayName;let m=(0,n.F)("group pointer-events-auto relative flex w-full items-center justify-between gap-4 overflow-hidden rounded-md border p-4 pr-10 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-(--radix-toast-swipe-end-x) data-[swipe=move]:translate-x-(--radix-toast-swipe-move-x) data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full sm:data-[state=open]:slide-in-from-bottom-full",{variants:{variant:{default:"border bg-background text-foreground",destructive:"destructive group border-red-200 bg-red-200 text-brand-black"}},defaultVariants:{variant:"default"}}),u=s.forwardRef((e,a)=>{let{className:t,variant:s,...n}=e;return(0,l.jsx)(r.bL,{ref:a,className:(0,o.cn)(m({variant:s}),t),...n})});u.displayName=r.bL.displayName,s.forwardRef((e,a)=>{let{className:t,...s}=e;return(0,l.jsx)(r.rc,{ref:a,className:(0,o.cn)("inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors hover:bg-secondary focus:outline-hidden focus:ring-2 focus:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-brand-black hover:group-[.destructive]:border-brand-black hover:group-[.destructive]:bg-destructive hover:group-[.destructive]:text-destructive-foreground focus:group-[.destructive]:ring-destructive",t),...s})}).displayName=r.rc.displayName;let p=s.forwardRef((e,a)=>{let{className:t,...s}=e;return(0,l.jsx)(r.bm,{ref:a,className:(0,o.cn)("absolute right-4 top-4 roun
1ded-md text-base-black opacity-0 transition-opacity focus:opacity-100 focus:outline-hidden focus:ring-2 group-hover:opacity-100 group-[.destructive]:text-brand-black hover:group-[.destructive]:text-brand-black focus:group-[.destructive]:ring-red-400 focus:group-[.destructive]:ring-offset-red-600",t),"toast-close":"",...s,children:(0,l.jsx)(i.A,{className:"h-5 w-5"})})});p.displayName=r.bm.displayName;let x=s.forwardRef((e,a)=>{let{className:t,...s}=e;return(0,l.jsx)(r.hE,{ref:a,className:(0,o.cn)("text-sm font-semibold",t),...s})});x.displayName=r.hE.displayName;let h=s.forwardRef((e,a)=>{let{className:t,...s}=e;return(0,l.jsx)(r.VY,{ref:a,className:(0,o.cn)("text-sm opacity-90",t),...s})});h.displayName=r.VY.displayName},1800:(e,a,t)=>{t.d(a,{d:()=>r});var l=t(15056),s=t(8505);let r={createExportReport:e=>(0,l.$P)("/v1/export/reports",e),getReportsHistory:e=>(0,l.Vg)("/v1/export/reports/history",e),getReportsTypes:()=>(0,l.Vg)("/v1/export/reports/types"),async getReportFile(e){let a=await s.SP.get("/v1/export/reports/".concat(e,"/file"),{responseType:"blob"}),t="report-".concat(e,".xlsx"),l=a.headers["content-disposition"];if(l){let e=l.match(/filename="([^"]+)"/);(null==e?void 0:e[1])&&(t=e[1])}return{blob:a.data,filename:t}}}},3998:(e,a,t)=>{t.d(a,{$:()=>c,r:()=>d});var l=t(95155),s=t(12115),r=t(32467),n=t(83101),i=t(35299),o=t(64269);let d=(0,n.F)("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-ring [&_svg]:pointer-events-none [&_svg]:shrink-0 disabled:pointer-events-none data-[loading=true]:pointer-events-none disabled:opacity-50 data-[loading=true]:opacity-50",{variants:{variant:{primary:"bg-brand-dark-cyan text-white hover:bg-brand-deep-sea-blue active:bg-brand-black disabled:bg-gray-100 disabled:border-brand-dark-gray disabled:border disabled:text-brand-dark-gray data-[loading=true]:opacity-50 shadow-custom-button",secondary:"bg-brand-white text-brand-dark-cyan border border-brand-dark-cyan hover:text-brand-deep-sea-blue hover:border-brand-deep-sea-blue active:text-brand-black active:border-brand-black disabled:text-brand-dark-gray disabled:border-brand-dark-gray",tertiary:"bg-brand-white text-brand-dark-cyan hover:text-brand-deep-sea-blue active:text-brand-black disabled:text-brand-dark-gray",quaternary:"bg-transparent text-brand-black rounded-md border border-brand-stroke hover:text-brand-black active:text-brand-black disabled:text-brand-dark-gray shadow-custom-select opacity-50",quaternary1:"bg-transparent text-brand-black rounded-md border border-brand-stroke hover:text-brand-black active:text-brand-black disabled:text-brand-dark-gray",ghost:"bg-transparent text-brand-black hover:text-brand-black active:text-brand-black disabled:text-brand-dark-gray",alert:"bg-brand-red text-white hover:bg-red-900 active:bg-brand-black disabled:bg-gray-100 disabled:border-brand-dark-gray disabled:border disabled:text-brand-dark-gray data-[loading=true]:opacity-50 shadow-custom-button"},size:{default:"h-10 px-4 py-2 text-base",sm:"h-8 rounded-md px-3 text-sm",lg:"h-12 rounded-md px-8 text-base",icon:"h-9 w-9",extraSmall:"h-7 w-7"}},defaultVariants:{variant:"primary",size:"default"}}),c=s.forwardRef((e,a)=>{let{className:t,variant:s,size:n,asChild:c=!1,loading:m=!1,icon:u,iconPosition:p="left",children:x,...h}=e,g=c?r.DX:"button";return(0,l.jsx)(g,{className:(0,o.cn)(d({variant:s,size:n,className:t})),ref:a,disabled:h.disabled,"data-loading":m,...h,children:(0,l.jsxs)("div",{className:"relative flex items-center justify-center gap-2 w-full",children:[m&&(0,l.jsx)("div",{className:"absolute inset-0 flex items-center justify-center",children:(0,l.jsx)(i.A,{className:"sm"===n?"h-4 w-4 animate-spin":"h-5 w-5 animate-spin"})}),(0,l.jsxs)("div",{className:(0,o.cn)(m&&"opacity-0","flex items-center gap-2 transition-opacity duration-200"),children:[u&&"left"===p&&(0,l.jsx)(u,{className:"sm"===n?"h-4 w-4":"h-5 w-5"}),x,u&&"right"===p&&(0,l.jsx)(u,{className:"sm"===n?"h-4 w-4":"h-5 w-5"})]})]})})});c.displayName="Button"},6259:(e,a,t)=>{t.d(a,{SQ:()=>d,_2:()=>c,rI:()=>i,ty:()=>o});
1var l=t(95155),s=t(12115),r=t(37738),n=t(64269);let i=r.bL,o=r.l9,d=s.forwardRef((e,a)=>{let{className:t,sideOffset:s=4,...i}=e;return(0,l.jsx)(r.ZL,{children:(0,l.jsx)(r.UC,{ref:a,sideOffset:s,className:(0,n.cn)("z-50 min-w-32 overflow-hidden rounded-md border border-brand-stroke bg-white p-1 text-brand-black shadow-md","max-h-[300px] overflow-y-auto","data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...i})})});d.displayName=r.UC.displayName;let c=s.forwardRef((e,a)=>{let{className:t,...s}=e;return(0,l.jsx)(r.q7,{ref:a,className:(0,n.cn)("relative flex cursor-default select-none items-center rounded-xs px-2 py-1.5 text-sm outline-hidden transition-colors focus:bg-cyan-50 focus:text-brand-black data-disabled:pointer-events-none data-disabled:opacity-50",t),...s})});c.displayName=r.q7.displayName},7431:(e,a,t)=>{t.d(a,{Q:()=>s});var l=t(15056);let s={getPortfolioInsightsWaterUsageEfficiency:e=>(0,l.Vg)("/v1/reporting/portfolio-insights/water-usage-efficiency",e),getPortfolioInsightsCosts:e=>(0,l.Vg)("/v1/reporting/portfolio-insights/costs",e),getPortfolioInsightsPortfolioPerformance:e=>(0,l.Vg)("/v2/reporting/portfolio-insights/portfolio-performance",e),getPortfolioInsightsPerformanceRankingWatchlist(e){let a={...e,type:"watchlist"};return(0,l.Vg)("/v2/reporting/portfolio-insights/performance-ranking",a)},getPortfolioInsightsPerformanceRankingToplist(e){let a={...e,type:"toplist"};return(0,l.Vg)("/v2/reporting/portfolio-insights/performance-ranking",a)},getPortfolioInsightsPropertyPerformance:e=>(0,l.Vg)("/v2/reporting/portfolio-insights/properties/performance",e),getPortfolioInsightsPropertyPerformanceFilters:()=>(0,l.Vg)("/v1/reporting/portfolio-insights/properties/performance/filters"),getPortfolioInsightsFinancesCosts:e=>(0,l.Vg)("/v1/reporting/portfolio-insights/finances/costs",e),getPortfolioInsightsFinancesLeakTypeCosts:e=>(0,l.Vg)("/v2/reporting/portfolio-insights/finances/leak-type-costs",e),getPortfolioInsightsFinancesLeakOverview:e=>(0,l.Vg)("/v2/reporting/portfolio-insights/finances/leak-overview",e),getPortfolioInsightsFinancesWaterBudgetConsumption:e=>(0,l.Vg)("/v2/reporting/portfolio-insights/finances/water-budget-consumption",e),setPortfolioInsightsFinancesCosts:e=>(0,l.$P)("/v1/reporting/portfolio-insights/finances/unit-gallon-price",e),deletePortfolioInsightsFinancesUnitGallonPrice:e=>(0,l.Un)("/v1/reporting/portfolio-insights/finances/unit-gallon-price",e)}},12516:(e,a,t)=>{t.d(a,{Z:()=>o});var l=t(12115),s=t(20063),r=t(29141),n=t(15101);let i=[{name:"History",path:"/history",accessLevel:"property"},{name:"Top 5 Leaks",path:"/top5-leaks-home",accessLevel:"property"},{name:"Top 5 Details",path:"/top5-leaks-details",accessLevel:"property"},{name:"Gateway Device Health",path:"/gateway-device-health",accessLevel:"property"},{name:"Report Center",path:"/report-center",accessLevel:"property"},{name:"Performance",path:"/performance",accessLevel:"portfolio"},{name:"Properties",path:"/properties",accessLevel:"portfolio"},{name:"Finance",path:"/finance",accessLevel:"portfolio"},{name:"Portfolio Gateway Device Health",path:"/portfolio-gateway-device-health",accessLevel:"portfolio"},{name:"Municipal",path:"/municipal",accessLevel:"portfolio"},{name:"Admin Users",path:"/admin/users",accessLevel:"admin"},{name:"Admin Organizations",path:"/admin/organizations",accessLevel:"ion-admin"},{name:"Admin Properties",path:"/admin/properties",accessLevel:"ion-admin"}];function o(e){var a;let t=(0,s.useRouter)(),{user:o,isIONAdmin:d,isOrgAdmin:c,isStaff:m}=(0,r.J)(),{hasPropertyInsightsAccess:u,hasPortfolioInsightsAccess:p,activeOrganization:x}=(0,n.Z)(),h=e=>{switch(e){case"property":return u;case"portfolio":return p;case"admin":return d||c;case"ion-admin":return d;case"staff":return m;default:return!1}},g=e.requiredAccess.some(e=>h(e)),y=null!=(a=e.requiredPermissions)?a:[],f=0===y.length||y.every(e=>{var a;return null==o||null==(a=o.permissions)?void 0:a.some(a=>a.name===e)}),b=g&&f,v=()=>{for(let e of["portfolio","property","ion-admin","admin","staff"])if(h(e)){let a=i.find(a=>a.accessLevel===e);if(a)return a.path}return"/profile"};return(0,l.useEffect)(()=>
1{if(o&&x&&!b){if(e.allowNoAccess)return;let a=e.fallbackRoute||v();a!==window.location.pathname&&t.push(a)}},[o,x,u,p,d,c,e.requiredAccess,e.requiredPermissions,e.fallbackRoute,e.allowNoAccess,b,t]),{hasAccess:h,hasAnyRequiredAccess:g,hasAllRequiredPermissions:f,getFirstAvailableSection:v,getAvailableSections:()=>i.filter(e=>h(e.accessLevel)),hasPropertyAccess:u,hasPortfolioAccess:p,hasAdminAccess:d||c,hasIONAdminAccess:d,hasOrgAdminAccess:c,hasStaffAccess:m,isAccessGranted:b||e.allowNoAccess||!1,isUserLoaded:!!o}}},12933:(e,a,t)=>{t.d(a,{$:()=>b,e:()=>f});var l=t(95155),s=t(32897),r=t(12108),n=t(24033),i=t(35299),o=t(7125),d=t(6191),c=t(27937),m=t(77888),u=t(3998),p=t(12115),x=t(26493),h=t(64269),g=t(58873),y=t(40170);function f(e,a,t,s,m,p,x,g,f,b,v,N,j,_,w,k,C,S,E,L,A){return[{id:"property_name",accessorKey:"property_name",header:()=>{let e=a("property_name","Property","start");return(0,l.jsxs)("div",{className:(0,h.cn)(e.className,"min-w-24"),onClick:e.onClick,children:[(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(r.A,{className:e.upIconClassName}),(0,l.jsx)(n.A,{className:e.downIconClassName})]}),(0,l.jsx)("span",{children:e.label})]})},cell:e=>{var a,t;let{row:s}=e;if("isProperty"in s.original&&s.original.isProperty||"isMeter"in s.original&&s.original.isMeter||"isDaily"in s.original&&s.original.isDaily)return(0,l.jsx)("div",{className:"flex items-center w-full h-full min-w-28",children:s.original.property_name});if("isLoadMoreMeters"in s.original&&s.original.isLoadMoreMeters){let e=s.original.parent_property_id,t=null==p?void 0:p[e],r=null==g?void 0:g[e],n=(null==x||null==(a=x[e])?void 0:a.length)||0;return(0,l.jsx)("div",{className:"flex items-center justify-center py-2 w-full h-full absolute top-0 left-0",style:{width:"".concat(C,"px")},children:(0,l.jsxs)(u.$,{variant:"secondary",size:"sm",className:"flex items-center gap-2",disabled:r,onClick:a=>{a.stopPropagation(),null==f||f(e)},children:[r&&(0,l.jsx)(i.A,{className:"w-4 h-4 animate-spin"}),"Load More (",n," of ",(null==t?void 0:t.total)||0,")"]})})}if("isLoadMoreDaily"in s.original&&s.original.isLoadMoreDaily){let e=s.original,a=e.parent_meter_id,r=null==j?void 0:j[a],n=null==w?void 0:w[a],o=(null==_||null==(t=_[a])?void 0:t.length)||0;return(0,l.jsx)("div",{className:"flex items-center justify-center py-2 w-full h-full absolute top-0 left-0",style:{width:"".concat(C,"px")},children:(0,l.jsxs)(u.$,{variant:"secondary",size:"sm",className:"flex items-center gap-2",disabled:n,onClick:t=>{t.stopPropagation(),null==k||k(a,e.property_name,e.bedroom_count,e.gbd)},children:[n&&(0,l.jsx)(i.A,{className:"w-4 h-4 animate-spin"}),"Load More (",o," of ",(null==r?void 0:r.total)||0,")"]})})}return"isEmptyMeters"in s.original&&s.original.isEmptyMeters?(0,l.jsx)("div",{className:"flex items-center justify-center py-2 w-full h-full absolute top-0 left-0",style:{width:"".concat(C,"px")},children:(0,l.jsx)("span",{className:"text-brand-dark-gray text-center",children:"No meters found for this property"})}):"isEmptyDaily"in s.original&&s.original.isEmptyDaily?(0,l.jsx)("div",{className:"flex items-center justify-center py-2 w-full h-full absolute top-0 left-0",style:{width:"".concat(C,"px")},children:(0,l.jsx)("span",{className:"text-brand-dark-gray text-center",children:"No daily data found for this meter"})}):null},meta:{name:"Property",cellClassName:"relative"}},{id:"building_count",accessorKey:"building_count",header:()=>(0,l.jsx)("span",{className:"min-w-32",children:"Building"}),cell:e=>{let{row:a}=e;return"isProperty"in a.original&&a.original.isProperty?(0,l.jsx)("span",{children:a.original.building_count}):"isMeter"in a.original&&a.original.isMeter||"isDaily"in a.original&&a.original.isDaily?(0,l.jsx)("span",{children:a.original.building_name}):null},meta:{name:"Building"}},{id:"bedroom_count",accessorKey:"bedroom_count",header:()=>{let e=a("bedroom_count","Bedrooms");return(0,l.jsxs)("div",{className:e.className,onClick:e.onClick,children:[(0,l.jsx)("span",{className:"text-right",children:e.label}),(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(r.A,{className:e.upIconClassName}),(0,l.jsx)(n.A,{className:e.downIconClassName})]})]})},cell:e=>{let{row:a}=e;return"isLoadMoreMeters"in a.original&&a.original.isLoadMoreMeters||"isLoadMoreDaily"in a.original&&a.original.isLoadMoreDaily||"isEmptyMeters"in a.original&&a.original.isEmptyMeters||"isEmptyDaily"in a.original&&a.original.isEmptyDaily?null:(0,l.jsx)("div",{className:"flex justify-end w-full",children:(0,l.jsx)("span",{className:"text-right pr-6",children:a.original.bedroom_count})})},meta:{name:"Bedrooms"}},{id:"meter_serial_number",accessorKey:"meter_serial_number",header:()=>(0,l.jsx)("span",{className:"min-w-44",children:"Device Serial Number"}),cell:e=>{let{row:a}=e;if("isLoadMoreMeters"in a.original&&a.original.isLoadMoreMeters||"isLoadMoreDaily"in a.original&&a.original.isLoadMoreDaily||"isEmptyMeters"in a.original&&a.original.isEmptyMeters||"isEmptyDaily"in a.original&&a.original.isEmptyDaily)return null;if("isProperty"in a.original&&a.original.isProperty)return(0,l.jsx)("span",{className:"text-gray-400",children:"-"});if("isMeter"in a.original&&a.original.isMeter||"isDaily"in a.original&&a.original.isDaily){let e=a.original;return(0,l.jsx)("span",{className:"flex items-center w-full h-full cursor-pointer hover:underline hover:text-brand-dark-cyan transition-colors",onClick:()=>null==E?void 0:E(e.meter_serial_number),children:e.meter_serial_number})}return null},meta:{name:"Device Serial Number"}},{id:"period",accessorKey:"period",header:()=>{let e=a("period","Period","start");return(0,l.jsxs)("div",{className:(0,h.cn)(e.className,"min-w-24"),onClick:e.onClick,children:[(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(r.A,{className:e.upIconClassName}),(0,l.jsx)(n.A,{className:e.downIconClassName})]}),(0,l.jsx)("span",{children:e.label})]})},cell:e=>{let{row:a}=e;return"isLoadMoreMeters"in a.original&&a.original.isLoadMoreMeters||"isLoadMoreDaily"in a.original&&a.original.isLoadMoreDaily||"isEmptyMeters"in a.original&&a.original.isEmptyMeters||"isEmptyDaily"in a.original&&a.original.isEmptyDaily?null:"isProperty"in a.original&&a.original.isProperty||"isMeter"in a.original&&a.original.isMeter||"isDaily"in a.original&&a.original.isDaily?(0,l.jsx)("span",{children:a.original.period}):null},meta:{name:"Period"}},{id:"gallons_consumed",accessorKey:"gallons_consumed",header:()=>{let e=a("gallons_consumed","Gallons");return(0,l.jsxs)("div",{className:e.className,onClick:e.onClick,children:[(0,l.jsx)("span",{className:"text-right",children:e.label}),(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(r.A,{className:e.upIconClassName}),(0,l.jsx)(n.A,{className:e.downIconClassName})]})]})},cell:e=>{let{row:a}=e;if("isLoadMoreMeters"in a.original&&a.original.isLoadMoreMeters||"isLoadMoreDaily"in a.original&&a.original.isLoadMoreDaily||"isEmptyMeters"in a.original&&a.original.isEmptyMeters||"isEmptyDaily"in a.original&&a.original.isEmptyDaily)return null;let t=0;return"isProperty"in a.original&&a.original.isProperty?t=a.original.gallons_consumed:("isMeter"in a.original&&a.original.isMeter||"isDaily"in a.original&&a.original.isDaily)&&(t=a.original.gallons_consumed),(0,l.jsx)("div",{className:"flex justify-end w-full",children:(0,l.jsx)("span",{className:"text-right pr-6",children:t.toLocaleStr
1ing()})})},meta:{name:"Gallons"}},{id:"gbd",accessorKey:"gbd",header:()=>{let e=a("gbd","GBD");return(0,l.jsxs)("div",{className:e.className,onClick:e.onClick,children:[(0,l.jsx)("span",{className:"text-right",children:e.label}),(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(r.A,{className:e.upIconClassName}),(0,l.jsx)(n.A,{className:e.downIconClassName})]})]})},cell:e=>{let{row:a}=e;if("isLoadMoreMeters"in a.original&&a.original.isLoadMoreMeters||"isLoadMoreDaily"in a.original&&a.original.isLoadMoreDaily||"isEmptyMeters"in a.original&&a.original.isEmptyMeters||"isEmptyDaily"in a.original&&a.original.isEmptyDaily)return null;let t="gbd"in a.original?a.original.gbd:void 0;return(0,l.jsx)("div",{className:"flex justify-end w-full",children:(0,l.jsx)("span",{className:"text-right pr-6",children:null==t?void 0:t.toLocaleString()})})},meta:{name:"GBD"}},{id:"actions",size:140,enableResizing:!1,cell:e=>{let{row:a}=e;if("isLoadMoreMeters"in a.original&&a.original.isLoadMoreMeters||"isLoadMoreDaily"in a.original&&a.original.isLoadMoreDaily||"isEmptyMeters"in a.original&&a.original.isEmptyMeters||"isEmptyDaily"in a.original&&a.original.isEmptyDaily)return null;if("isProperty"in a.original&&a.original.isProperty){let e=a.original,r=null==t?void 0:t[e.property_id],n=null==s?void 0:s[e.property_id];return(0,l.jsx)("div",{className:"flex justify-end w-full",children:(0,l.jsx)(u.$,{variant:"secondary",size:"sm",className:"opacity-100 py-1 px-2 w-32 h-7",onClick:a=>{a.stopPropagation(),null==m||m(e.property_id)},children:n?(0,l.jsx)(i.A,{className:"w-5 h-5 animate-spin text-brand-dark-cyan"}):r?(0,l.jsxs)("div",{className:"flex items-center gap-0.5",children:["Hide meters",(0,l.jsx)(o.A,{className:"w-5 h-5",strokeWidth:2})]}):(0,l.jsxs)("div",{className:"flex items-center gap-0.5",children:["Show meters",(0,l.jsx)(d.A,{className:"w-5 h-5",strokeWidth:2})]})})})}if("isMeter"in a.original&&a.original.isMeter&&S){let e=a.original,t=null==b?void 0:b[e.meter_serial_number],s=null==v?void 0:v[e.meter_serial_number];return(0,l.jsx)("div",{className:"flex justify-end w-full",children:(0,l.jsx)(u.$,{variant:"secondary",size:"sm",className:"opacity-100 py-1 px-2 w-32 h-7 text-gray-500 border-gray-400 hover:text-brand-dark-gray hover:border-brand-dark-gray",onClick:a=>{a.stopPropagation(),null==N||N(e.meter_serial_number,String(e.property_name),e.bedroom_count,e.gbd)},children:s?(0,l.jsx)(i.A,{className:"w-5 h-5 animate-spin text-brand-dark-gray"}):t?(0,l.jsxs)("div",{className:"flex items-center gap-0.5",children:["Hide daily",(0,l.jsx)(o.A,{className:"w-5 h-5",strokeWidth:2})]}):(0,l.jsxs)("div",{className:"flex items-center gap-0.5",children:["Show daily",(0,l.jsx)(d.A,{className:"w-5 h-5",strokeWidth:2})]})})})}if("isDaily"in a.original&&a.original.isDaily||"isMeter"in a.original&&a.original.isMeter&&!S){let e=a.original,t=(0,y.sl)(e.period,null==A?void 0:A.start_date);return(0,l.jsx)("div",{className:"flex justify-end w-full",children:(0,l.jsx)(u.$,{variant:"secondary",size:"sm",className:"py-1 px-2 border-gray-400 w-28 h-7 text-brand-dark-gray hover:text-brand-dark-cyan hover:border-brand-dark-cyan",onClick:a=>{a.stopPropagation(),null==L||L(e.property_id,e.meter_serial_number,t)},children:(0,l.jsxs)("div",{className:"flex items-center gap-0.5",children:["Show hourly",(0,l.jsx)(c.A,{className:"w-4 h-4"})]})})})}return null},meta:{fixedWidth:!0}}]}function b(e){let{data:a,isLoading:t,totalCount:r=0,onPageChange:n,currentPage:i=0,params:o,onSort:d,columnVisibility:c,columnOrder:u,onColumnVisibilityChange:h,pageSize:y,onPageSizeChange:b,menuPlacement:v,onShowHourly:N}=e,j=Math.ceil(r/(y||10)),_=j>1,[w,k]=(0,p.useState)({}),[C,S]=(0,p.useState)({}),[E,L]=(0,p.useState)({}),[A,D]=(0,p.useState)({}),[O,T]=(0,p.useState)({}),[I,P]=(0,p.useState)({}),[R,M]=(0,p.useState)({}),[G,z]=(0,p.useState)({}),[F,H]=(0,p.useState)({}),[V,U]=(0,p.useState)({}),[B,K]=(0,p.useState)({}),[W,Y]=(0,p.useState)({}),[$,Z]=(0,p.useState)(0);(0,p.useEffect)(()=>{k({}),L({}),D({}),T({}),P({}),M({}),H({}),U({}),K({}),Y({})},[o.start_date,o.end_date,o.organization_id,o.property_id,o.meter_serial_number,o.ordering]),(0,p.useEffect)(()=>{let e=()=>{let e=window.document.querySelector("[data-day-property-table]");e&&Z(e.getBoundingClientRect().width)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[a]);let q=async e=>{let t=w[e],l=a.find(a=>a.property_id===e);if(k(a=>({...a,[e]:!t})),!t){S(a=>({...a,[e]:!0}));
1try{let a=await x.l.getLeakDetailsPropertiesMetersConsumption(e,{...o,page:1,page_size:5}),t=a.results.map((a,t)=>({...a,isMeter:!0,id:"".concat(e,"-meter-").concat(t,"-").concat(a.meter_serial_number)}));L(a=>({...a,[e]:t})),D(t=>({...t,[e]:{page:1,hasMore:null!==a.next,total:a.count||0}}))}catch(e){console.error("Error fetching meters data:",e),(0,g.N)("Failed to load meters","Unable to fetch meters data for ".concat((null==l?void 0:l.property_name)||"this property"))}finally{S(a=>({...a,[e]:!1}))}}},J=async e=>{let t=A[e];if(!(null==t?void 0:t.hasMore)||O[e])return;T(a=>({...a,[e]:!0}));let l=I[e],s=!l;try{let a=await x.l.getLeakDetailsPropertiesMetersConsumption(e,{...o,page:l?t.page+1:1,page_size:50}),r=a.results.map((a,s)=>({...a,isMeter:!0,id:"".concat(e,"-meter-").concat(l?t.page+1:1,"-").concat(s,"-").concat(a.meter_serial_number)}));L(a=>({...a,[e]:s?r:[...a[e]||[],...r]})),D(s=>({...s,[e]:{page:l?t.page+1:1,hasMore:null!==a.next,total:a.count||0}})),s&&P(a=>({...a,[e]:!0}))}catch(t){var r;console.error("Error loading more meters:",t),(0,g.N)("Failed to load more meters","Unable to fetch more meters data for ".concat((null==(r=a.find(a=>a.property_id===e))?void 0:r.property_name)||"this property"))}finally{T(a=>({...a,[e]:!1}))}},X=async e=>{let a=R[e];if(M(t=>({...t,[e]:!a})),!a){z(a=>({...a,[e]:!0}));let a=Object.fromEntries(Object.entries(o).filter(e=>{let[a]=e;return!["organization_id","property_id"].includes(a)}));try{let t=await x.l.getLeakReportMetersConsumptionDay(e,{...a,page:1,page_size:5}),l=t.results.map((a,t)=>({...a,organization_id:0,isDaily:!0,id:"".concat(e,"-daily-").concat(t,"-").concat(a.period),parent_meter_id:e}));H(a=>({...a,[e]:l})),U(a=>({...a,[e]:{page:1,hasMore:null!==t.next,total:t.count||0}}))}catch(a){console.error("Error fetching daily data:",a),(0,g.N)("Failed to load daily data","Unable to fetch daily data for ".concat(e))}finally{z(a=>({...a,[e]:!1}))}}},Q=async e=>{let a=V[e];if(!(null==a?void 0:a.hasMore)||B[e])return;K(a=>({...a,[e]:!0}));let t=Object.fromEntries(Object.entries(o).filter(e=>{let[a]=e;return!["organization_id","property_id"].includes(a)})),l=W[e],s=!l;try{let r=await x.l.getLeakReportMetersConsumptionDay(e,{...t,page:l?a.page+1:1,page_size:50}),n=r.results.map((t,s)=>({...t,organization_id:0,isDaily:!0,id:"".concat(e,"-daily-").concat(l?a.page+1:1,"-").concat(s,"-").concat(t.period),parent_meter_id:e}));H(a=>({...a,[e]:s?n:[...a[e]||[],...n]})),U(t=>({...t,[e]:{page:l?a.page+1:1,hasMore:null!==r.next,total:r.count||0}})),s&&Y(a=>({...a,[e]:!0}))}catch(a){console.error("Error loading more daily data:",a),(0,g.N)("Failed to load more daily data","Unable to fetch more daily data for ".concat(e))}finally{K(a=>({...a,[e]:!1}))}},{getSortableHeaderProps:ee}=(0,m.M)({params:o,onSort:d,isLoading:t,data:a}),ea=f(null!=t&&t,ee,w,C,q,A,E,O,J,R,G,X,V,F,B,Q,$,!(1===o.days_ago||o.start_date&&o.end_date&&o.start_date===o.end_date),void 0,N,o),et=a.reduce((e,a)=>{let t=a.property_id,l={...a,id:"property-".concat(t),isProperty:!0};if(e.push(l),w[t]){let l=E[t];if(l&&l.length>0){l.forEach(a=>{e.push(a);let t=a.meter_serial_number;if(R[t]){let l=F[t];if(l&&l.length>0){e.push(...l);let s=V[t];if(null==s?void 0:s.hasMore){let l={id:"load-more-daily-".concat(t),isLoadMoreDaily:!0,parent_meter_id:t,meter_serial_number:a.meter_serial_number,property_name:a.property_name,building_name:a.building_name,bedroom_count:a.bedroom_count,gbd:a.gbd};e.push(l)}}else l&&0===l.length&&e.push({id:"empty-daily-".concat(t),isEmptyDaily:!0,parent_meter_id:t})}});let s=A[t];if(null==s?void 0:s.hasMore){let l={id:"load-more-meters-".concat(t),isLoadMoreMeters:!0,parent_property_id:t,property_id:a.property_id,property_name:a.property_name,period:a.period,gallons_consumed:0,building_count:a.building_count,bedroom_count:a.bedroom_count,gbd:a.gbd};e.push(l)}}else l&&0===l.length&&e.push({id:"empty-meters-".concat(t),isEmptyMeters:!0,parent_property_id:t})}return e},[]);return(0,l.jsx)("div",{"data-day-property-table":!0,children:(0,l.jsx)(s.b,{columns:ea,data:et,columnVisibility:c,onColumnVisibilityChange:h||(()=>{}),columnOrder:u,getRowClassName:e=>{let a=[];return"isProperty"in e.original&&e.original.isProperty?a.push("hover:bg-gray-50"):"isMeter"in e.original&&e.original.isMeter?a.push("bg-cyan-50 hover:bg-cyan-100"):"isDaily"in e.original&&e.original.isDaily?a.push("bg-cyan-100 hover:bg-cyan-150"):"isLoadMoreMeters"in e.original&&e.original.isLoadMoreMeters||"isEmptyMeters"in e.original&&e.original.isEmptyMeters?a.push("bg-cyan-50 border-t-2 relative"):("isLoadMoreDaily"in e.original&&e.original.isLoadMoreDaily||"isEmptyDaily"in e.original&&e.original.isEmptyDaily)&&a.push("bg-cyan-100 border-t-2 relative"),a.join(" ")},isLoading:t,pageCount:_?j:void 0,pageIndex:_?i:void 0,onPageChange:_?n:void 0,headerClassName:"h-14",headerColor:"text-brand-black",showPageSizeSelector:!0,pageSize:y,onPageSizeChange:b,menuPlacement:v})})}},13016:(e,a,t)=>{t.d(a,{Qp:()=>o,TH:()=>n,nW:()=>r});
1var l=t(12115);let s="bed_count_filter",r=0,n=7,i=e=>Number.isInteger(e)&&e>=r&&e<=n;function o(){let[e,a]=(0,l.useState)({from:0,to:7}),[t,o]=(0,l.useState)(!1),[d,c]=(0,l.useState)(!0);(0,l.useEffect)(()=>{let e=localStorage.getItem(s);if(e)try{let t=JSON.parse(e);i(null==t?void 0:t.from)&&i(null==t?void 0:t.to)&&t.from<=t.to?a({from:t.from,to:t.to}):a({from:r,to:n})}catch(e){console.error("Failed to parse bed count filter from localStorage:",e),a({from:0,to:7})}else a({from:0,to:7});c(!1)},[]),(0,l.useEffect)(()=>{d||localStorage.setItem(s,JSON.stringify(e))},[e,d]);let m=0!==e.from||7!==e.to;return{selectedBedCount:e,isBedCountFilterOpen:t,setIsBedCountFilterOpen:o,onBedCountChange:e=>{a(e)},resetBedCountFilter:()=>{a({from:0,to:7})},hasActiveBedCountFilter:m}}},13553:(e,a,t)=>{t.d(a,{Xj:()=>n});var l=t(12115);let s={overview:{data:null,loading:!1},totalConsumption:{data:null,loading:!1},waterSavingOverview:{data:null,loading:!1},costSavingOverview:{data:null,loading:!1},savingsRanking:{data:null,loading:!1,count:0,page:0,pageSize:10,ordering:"total_dollars_saved"}};function r(e,a){switch(a.type){case"SET_OVERVIEW_LOADING":return{...e,overview:{...e.overview,loading:a.payload}};case"SET_OVERVIEW_DATA":return{...e,overview:{...e.overview,data:a.payload}};case"SET_TOTAL_CONSUMPTION_LOADING":return{...e,totalConsumption:{...e.totalConsumption,loading:a.payload}};case"SET_TOTAL_CONSUMPTION_DATA":return{...e,totalConsumption:{...e.totalConsumption,data:a.payload}};case"SET_WATER_SAVING_OVERVIEW_LOADING":return{...e,waterSavingOverview:{...e.waterSavingOverview,loading:a.payload}};case"SET_WATER_SAVING_OVERVIEW_DATA":return{...e,waterSavingOverview:{...e.waterSavingOverview,data:a.payload}};case"SET_COST_SAVING_OVERVIEW_LOADING":return{...e,costSavingOverview:{...e.costSavingOverview,loading:a.payload}};case"SET_COST_SAVING_OVERVIEW_DATA":return{...e,costSavingOverview:{...e.costSavingOverview,data:a.payload}};case"SET_SAVINGS_RANKING_LOADING":return{...e,savingsRanking:{...e.savingsRanking,loading:a.payload}};case"SET_SAVINGS_RANKING_DATA":var t;return{...e,savingsRanking:{...e.savingsRanking,data:null!=(t=a.payload)?t:[]}};case"SET_SAVINGS_RANKING_COUNT":return{...e,savingsRanking:{...e.savingsRanking,count:a.payload}};case"SET_SAVINGS_RANKING_PAGE":return{...e,savingsRanking:{...e.savingsRanking,page:a.payload}};case"SET_SAVINGS_RANKING_PAGE_SIZE":return{...e,savingsRanking:{...e.savingsRanking,pageSize:a.payload}};case"SET_SAVINGS_RANKING_ORDERING":return{...e,savingsRanking:{...e.savingsRanking,ordering:a.payload}};default:return e}}function n(){let[e,a]=(0,l.useReducer)(r,s);return{state:e,actions:{setOverviewLoading:e=>a({type:"SET_OVERVIEW_LOADING",payload:e}),setOverviewData:e=>a({type:"SET_OVERVIEW_DATA",payload:e}),setTotalConsumptionLoading:e=>a({type:"SET_TOTAL_CONSUMPTION_LOADING",payload:e}),setTotalConsumptionData:e=>a({type:"SET_TOTAL_CONSUMPTION_DATA",payload:e}),setWaterSavingOverviewLoading:e=>a({type:"SET_WATER_SAVING_OVERVIEW_LOADING",payload:e}),setWaterSavingOverviewData:e=>a({type:"SET_WATER_SAVING_OVERVIEW_DATA",payload:e}),setCostSavingOverviewLoading:e=>a({type:"SET_COST_SAVING_OVERVIEW_LOADING",payload:e}),setCostSavingOverviewData:e=>a({type:"SET_COST_SAVING_OVERVIEW_DATA",payload:e}),setSavingsRankingLoading:e=>a({type:"SET_SAVINGS_RANKING_LOADING",payload:e}),setSavingsRankingData:e=>a({type:"SET_SAVINGS_RANKING_DATA",payload:e}),setSavingsRankingCount:e=>a({type:"SET_SAVINGS_RANKING_COUNT",payload:e}),setSavingsRankingPage:e=>a({type:"SET_SAVINGS_RANKING_PAGE",payload:e}),setSavingsRankingPageSize:e=>a({type:"SET_SAVINGS_RANKING_PAGE_SIZE",payload:e}),setSavingsRankingOrdering:e=>a({type:"SET_SAVINGS_RANKING_ORDERING",payload:e}),setAllLoading:e=>a({type:"SET_ALL_LOADING",payload:e})}}}},15056:(e,a,t)=>{t.d(a,{$P:()=>r,$Y:()=>n,Al:()=>i,Un:()=>o,Vg:()=>s});var l=t(8505);async function s(e,a,t){let s=function(e){if(!e)return"";let a=Object.entries(e).filter(e=>{let[,a]=e;return void 0!==a}).map(e=>{let[a,t]=e;return"".concat(a,"=").concat(encodeURIComponent(t))}).join("&");return a?"?".concat(a):""}(a),r="".concat(e).concat(s);return l.FH.get(r,(null==t?void 0:t.headers)?{headers:t.headers}:void 0)}async function r(e,a,t){return l.FH.post(e,a,t)}async function n(e,a,t){return l.FH.patch(e,a,(null==t?void 0:t.headers)?{headers:t.headers}:void 0)}async function i(e,a){return l.FH.delete(e,(null==a?void 0:a.headers)?{headers:a.headers}:void 0)}async function o(e,a,t){return l.FH.deleteWithData(e,a,(null==t?void 0:t.headers)?{headers:t.headers}:void 0)}},26493:(e,a,t)=>{t.d(a,{l:()=>s});
1var l=t(15056);let s={getJobsOverview:()=>(0,l.Vg)("/v1/reporting/jobs/overview"),getUnitsStatistics:e=>(0,l.Vg)("/v2/reporting/units/statistics",e),getOrganizationsStatistics:e=>(0,l.Vg)("/v2/reporting/organizations/statistics",e),getMyProperties:e=>(0,l.Vg)("/v1/reporting/my-properties/",e),getTopLeakVolumeProperties:e=>(0,l.Vg)("/v2/reporting/top-leak-volume/properties",e),getTopLeakVolumeUnits:e=>(0,l.Vg)("/v2/reporting/top-leak-volume/units",e),getPropertyUnits:(e,a)=>(0,l.Vg)("/v2/reporting/top-leak-volume/units",{...a,property_id:[String(e)]}),getTopLeakVolumeMeters:e=>(0,l.Vg)("/v1/reporting/top-leak-volume/meters",e),getTopLeakVolumeMetersDay:e=>(0,l.Vg)("/v1/reporting/top-leak-volume/meters/day",e),getTopLeakVolumeMetersHour:e=>(0,l.Vg)("/v1/reporting/top-leak-volume/meters/hour",e),getGallonsDynamics:e=>(0,l.Vg)("/v1/reporting/leak-report/gallons-dynamics",e),getLeakVolumePercentage:e=>(0,l.Vg)("/v1/reporting/leak-report/leak-volume-percentage",e),getLeakOverviewFilters:e=>(0,l.Vg)("/v1/reporting/leak-report/leak-overview/filters",e),getLeakOverview:e=>(0,l.Vg)("/v2/reporting/leak-report/leak-overview",e),getTopMeters:e=>(0,l.Vg)("/v1/reporting/top-meters",e),getLeakDetailsOverview:(e,a)=>(0,l.Vg)("/v2/reporting/leak-report/leak-details/meters/".concat(e,"/overview"),a),getLeakDetailsFlow:(e,a)=>(0,l.Vg)("/v2/reporting/leak-report/leak-details/meters/".concat(e,"/flow/").concat(null==a?void 0:a.granularity_type),a),getDayLeakDetailsConsumption:(e,a)=>(0,l.Vg)("/v2/reporting/leak-report/leak-details/meters/".concat(e,"/consumption/day"),a),getHourLeakDetailsConsumption:(e,a)=>(0,l.Vg)("/v2/reporting/leak-report/leak-details/meters/".concat(e,"/consumption/hour"),a),getLeakDetailsPropertiesOverview:e=>(0,l.Vg)("/v1/reporting/leak-report/properties/".concat(e,"/overview")),getLeakDetailsPropertiesMeters:(e,a)=>(0,l.Vg)("/v1/reporting/leak-report/properties/".concat(e,"/meters"),a),getLeakDetailsMetersFilters:e=>(0,l.Vg)("/v2/reporting/leak-report/meters/filters",e),getLeakDetailsMetersDay:(e,a)=>(0,l.Vg)("/v1/reporting/leak-report/meters/".concat(e,"/day"),a),getLeakDetailsPropertiesConsumption:e=>(0,l.Vg)("/v1/reporting/leak-report/properties/consumption",e),getLeakDetailsPropertiesMetersConsumption:(e,a)=>(0,l.Vg)("/v1/reporting/leak-report/properties/".concat(e,"/meters/consumption/day"),a),getLeakReportMetersConsumptionDay:(e,a)=>(0,l.Vg)("/v1/reporting/leak-report/meters/".concat(e,"/consumption/day"),a),getLeakReportPropertiesMetersConsumptionHour:(e,a)=>(0,l.Vg)("/v1/reporting/leak-report/properties/".concat(e,"/meters/consumption/hour"),a)}},27331:(e,a,t)=>{t.d(a,{nD:()=>lS,ub:()=>lA,As:()=>lE,$m:()=>lL,_C:()=>t1,L_:()=>t2,Lt:()=>lO,Rx:()=>lF,Zr:()=>lH,EO:()=>lP,$v:()=>lz,ck:()=>lM,wd:()=>lR,r7:()=>lG,QF:()=>lB,Ll:()=>at,Bx:()=>as,$n:()=>e$.$,Sl:()=>lY,Sc:()=>lZ,Sn:()=>c,nW:()=>w,bQ:()=>eU.b,lr:()=>l0,Ur:()=>l1,hI:()=>t5.h,UD:()=>ej,$9:()=>e_,ds:()=>la,Z8:()=>ea,x8:()=>eE,lo:()=>ar,lG:()=>s.lG,HM:()=>s.HM,Cf:()=>s.Cf,rr:()=>s.rr,c7:()=>s.c7,L3:()=>s.L3,y9:()=>lt,oX:()=>aL,tR:()=>eO,nw:()=>E,UM:()=>eq,ou:()=>ac,S5:()=>T,$D:()=>P,Fv:()=>ll.F,J4:()=>eT,K6:()=>Y,uh:()=>V,br:()=>U,VD:()=>eI,AO:()=>ax,uj:()=>tX,Oy:()=>ah,Ak:()=>t6,Dd:()=>t8.D,mK:()=>t9.m,et:()=>t7,pd:()=>l2,JU:()=>l3,e_:()=>eN,V7:()=>l9,rw:()=>ls.r,hw:()=>eR,Hq:()=>aO,Df:()=>le,iF:()=>tl,fE:()=>aN,B:()=>ti,YD:()=>ty,cX:()=>tE,kS:()=>lr,Rh:()=>tD,vx:()=>tU,k8:()=>ln.k,IW:()=>aS,ov:()=>aj,Nk:()=>aT,Ju:()=>aI,yA:()=>ss,AM:()=>lJ,hl:()=>lQ,Wv:()=>lX,dB:()=>$,uW:()=>ld,tF:()=>aw,uF:()=>a_,kB:()=>eX,bY:()=>s_,GU:()=>sm,R9:()=>su.R,yI:()=>tQ,JF:()=>lx,r4:()=>ak,HV:()=>e0,Ap:()=>sx,A5:()=>sf.h,AN:()=>sy,Bq:()=>aE,kW:()=>sN,Ng:()=>lh,dO:()=>sv,xN:()=>sj.x,tU:()=>tW,av:()=>tJ,j7:()=>t$,Xi:()=>tq,vb:()=>aP,Lj:()=>aR,m_:()=>au.m_,ZI:()=>au.ZI,Bc:()=>au.TooltipProvider,k$:()=>au.k$,dv:()=>ly,x0:()=>lf,Y_:()=>e7,Lh:()=>lj,Al:()=>lk,VB:()=>lw,gV:()=>aM,cz:()=>X});
1var l=t(95155),s=t(51834),r=t(12115),n=t(72755),i=t(64269),o=t(42058);let d=e=>{let{activeItem:a,onHover:t}=e,s=e=>a?a===e?1:.3:1;return(0,l.jsxs)("div",{className:"flex items-start gap-12 overflow-x-auto [&::-webkit-scrollbar]:hidden mb-4",children:[(0,l.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,l.jsx)("h3",{className:"text-base font-medium text-brand-black",children:"Total Consumption (gallons) before ION:"}),(0,l.jsx)("div",{className:"flex items-center gap-8",children:(0,l.jsxs)("div",{className:"flex items-center gap-3 cursor-pointer transition-opacity duration-200",style:{opacity:s("baseline")},onMouseEnter:()=>t("baseline"),onMouseLeave:()=>t(null),children:[(0,l.jsx)("span",{className:"inline-block w-3 h-3 rounded-sm shrink-0",style:{backgroundColor:"#2DA8BA"}}),(0,l.jsx)("span",{className:"text-base font-medium text-brand-black text-nowrap",children:"Baseline Gallons"})]})})]}),(0,l.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,l.jsx)("h3",{className:"text-base font-medium text-brand-black",children:"Total Consumption (gallons) after ION:"}),(0,l.jsxs)("div",{className:"flex items-center gap-8",children:[(0,l.jsxs)("div",{className:"flex items-center gap-3 cursor-pointer transition-opacity duration-200",style:{opacity:s("baseline")},onMouseEnter:()=>t("baseline"),onMouseLeave:()=>t(null),children:[(0,l.jsx)("svg",{width:"12",height:"12",className:"shrink-0",children:(0,l.jsx)("rect",{x:"0",y:"0",width:"12",height:"12",fill:"none",stroke:"#ACE7EF",strokeWidth:"2",strokeDasharray:"2 2",rx:"4"})}),(0,l.jsx)("span",{className:"text-base font-medium text-brand-black text-nowrap",children:"Baseline Gallons"})]}),(0,l.jsxs)("div",{className:"flex items-center gap-3 cursor-pointer transition-opacity duration-200",style:{opacity:s("consumed")},onMouseEnter:()=>t("consumed"),onMouseLeave:()=>t(null),children:[(0,l.jsx)("span",{className:"inline-block w-3 h-3 rounded-sm shrink-0",style:{backgroundColor:"#22D3EE"}}),(0,l.jsx)("span",{className:"text-base font-medium text-brand-black text-nowrap",children:"Consumed Gallons"})]})]})]})]})};function c(e){let{data:a,className:t,height:s=300}=e,c=(0,r.useRef)(null),m=(0,r.useRef)(null),[u,p]=(0,r.useState)(null),x=e=>{p(e)};return(0,r.useEffect)(()=>{if(!c.current||!a||0===a.length)return;let e=c.current.clientWidth,t=s-70-50;n.Ltv(c.current).selectAll("*").remove();let l=n.Ltv(c.current).attr("width",e).attr("height",s).append("g").attr("transform","translate(".concat(70,",").concat(70,")")),r=e-70-30,i=n.WH().domain(a.map(e=>e.period.replace(" - ","\n"))).range([0,r]).padding(.3),d=n.T9B(a,e=>{var a;let t=e.baseline_gallons||0,l=null!=(a=e.consumed_gallons)?a:0;return Math.max(t,l>0?l:0)})||0,p=n.jkA(a,e=>{var a;return Math.min(0,null!=(a=e.consumed_gallons)?a:0)})||0,h=n.m4Y().domain([p,d]).nice().range([t,0]),g=((e,a)=>{let t=Math.abs(e),l=a?2:1;return t<=5e3?1e3*l:t<=1e4?2e3*l:t<=2e4?2500*l:t<=5e4?5e3*l:t<=1e5?1e4*l:1e3*Math.ceil(t/10/1e3)*l})(Math.max(Math.abs(d),Math.abs(p)),p<0),y=n.y17(Math.floor(p/g)*g,Math.ceil(d/g)*g+g,g);l.append("g").attr("class","grid").selectAll("line").data(y).enter().append("line").attr("x1",0).attr("x2",r).attr("y1",e=>h(e)).attr("y2",e=>h(e)).attr("stroke","#E5E7EB").attr("stroke-width",1),p<0&&l.append("line").attr("x1",0).attr("x2",r).attr("y1",h(0)).attr("y2",h(0)).attr("stroke","#666666").attr("stroke-width",2);let f=l.append("g").attr("transform","translate(0,".concat(t,")")).call(n.l78(i).tickSize(0).tick
1Format(e=>e.toString().replace("\n"," ")));f.select(".domain").remove(),f.selectAll("text").attr("fill","#666666").attr("font-size","12px").attr("text-anchor","middle").each(function(e){let a=n.Ltv(this),t=e.split("\n");a.text(""),t.forEach((e,t)=>{a.append("tspan").attr("x",0).attr("dy",0===t?"0.8em":"1.1em").text(e)})});let b=l.append("g").call(n.V4s(h).tickValues(y).tickSize(0).tickFormat(e=>(e=>{if(0===e)return"0 Gal";let a=Math.abs(e),t=e<0?"-":"";return e<0?a>=1e6?"".concat(t).concat((a/1e6).toFixed(1),"M Gal"):a>=1e3?"".concat(t).concat((a/1e3).toFixed(0),"K Gal"):"".concat(t).concat(a," Gal"):"".concat((0,o.I)(e,!1)," Gal")})(e)));b.select(".domain").remove(),b.selectAll("text").attr("fill","#666666").attr("font-size","12px");let v=n.Ltv(m.current),N=a.findIndex(e=>e.new_installations&&e.new_installations.length>0),j=(e,a)=>{let t=Math.round(e.baseline_gallons||0).toLocaleString(),l=Math.round(e.consumed_gallons||0).toLocaleString(),s=Math.round(e.saved_gallons||0).toLocaleString();switch(e.type){case"pre_ion":return'\n            <div class="bg-white border border-brand-stroke rounded-sm p-3 shadow-sm">\n              <div class="text-brand-black font-semibold mb-2">'.concat(a,'</div>\n              <p class="text-brand-black font-medium">Total Consumption (gallons) before ION:</p>\n              <div class="flex border-b border-brand-stroke pb-2 mb-2"></div>\n              <div class="flex flex-col gap-2">\n                <div class="flex items-center gap-4">\n                  <span class="inline-block w-3 h-3 rounded-sm shrink-0" style="background-color: #2DA8BA"></span>\n                  <span class="text-brand-black font-medium">Baseline Gallons: ').concat(t," gallons</span>\n                </div>\n              </div>\n            </div>");case"post_ion_completed":return'\n            <div class="bg-white border border-brand-stroke rounded-sm p-3 shadow-sm">\n              <div class="text-brand-black font-semibold mb-2">'.concat(a,'</div>\n              <p class="text-brand-black font-medium">Total Consumption (gallons) after ION:</p>\n              <div class="flex border-b border-brand-stroke pb-2 mb-2"></div>\n              <div class="flex flex-col gap-2">\n                <div class="flex items-center gap-4">\n                  <span class="inline-block w-3 h-3 rounded-sm shrink-0 border border-dashed" style="border-color: #ACE7EF"></span>\n                  <span class="text-brand-black font-medium">Baseline Gallons: ').concat(t,' gallons</span>\n                </div>\n                <div class="flex items-center gap-4">\n                  <span class="inline-block w-3 h-3 rounded-sm shrink-0" style="background-color: #22D3EE"></span>\n                  <span class="text-brand-black font-medium">Consumed Gallons: ').concat(l,' gallons</span>\n                </div>\n                <div class="text-sm text-brand-black/70">Saved Gallons: ').concat(s,"</div>\n              </div>\n            </div>");case"post_ion_incomplete":return'\n            <div class="bg-white border border-brand-stroke rounded-sm p-3 shadow-sm">\n              <div class="text-brand-black font-semibold mb-2">'.concat(a,'</div>\n              <p class="text-brand-black font-medium">Incomplete billing</p>\n              <p class="text-xs text-brand-black/70 mt-1 mb-2">Water billing is missing or incomplete for this month.</p>\n              <div class="flex border-b border-brand-stroke pb-2 mb-2"></div>\n              <div class="flex items-center gap-4">\n                <span class="inline-block w-3 h-3 rounded-sm shrink-0 border border-dashed" style="border-color: #ACE7EF"></span>\n                <span class="text-brand-black font-medium">Baseline Gallons: ').concat(t," gallons</span>\n              </div>\n            </div>");case"future":return'\n            <div class="bg-white border border-brand-stroke rounded-sm p-3 shadow-sm">\n              <div class="text-brand-black font-semibold mb-2">'.concat(a,'</div>\n              <p class="text-brand-black font-medium">Upcoming month</p>\n              <p class="text-xs text-brand-black/70 mt-1 mb-2">Baseline projection for this period.</p>\n              <div class="flex border-b border-brand-stroke pb-2 mb-2"></div>\n              <div class="flex items-center gap-4">
1\n                <span class="inline-block w-3 h-3 rounded-sm shrink-0 border border-dashed" style="border-color: #ACE7EF"></span>\n                <span class="text-brand-black font-medium">Baseline Gallons: ').concat(t," gallons</span>\n              </div>\n            </div>")}},_=(e,a)=>{v.html(a);let t=((e,a)=>{let t=a.offsetWidth,l=a.offsetHeight,s=window.innerWidth,r=window.innerHeight,n=e.clientX+10,i=e.clientY-10;return n+t>s&&(n=e.clientX-t-10),i+l>r&&(i=e.clientY-l-10),n<0&&(n=10),i<0&&(i=e.clientY+10),{left:n,top:i}})(e,v.node());v.style("opacity",1).style("left","".concat(t.left,"px")).style("top","".concat(t.top,"px"))},w=()=>{v.style("opacity",0)};if(a.forEach(e=>{let a=e.period.replace(" - ","\n"),t=a.replace("\n"," "),s=i(a)||0,r=i.bandwidth(),n=h(0);if("pre_ion"===e.type){let a=h(e.baseline_gallons),i=Math.abs(n-a);l.append("rect").attr("x",s).attr("y",a).attr("width",r).attr("height",i).attr("fill","#2DA8BA").attr("rx",6).attr("ry",6).style("cursor","pointer").style("opacity",null===u||"baseline"===u?1:.3).on("mouseenter",function(a){x("baseline"),_(a,j(e,t))}).on("mouseleave",function(){x(null),w()})}else if("post_ion_completed"===e.type){var o;let a=null!=(o=e.consumed_gallons)?o:0;if(0===a)return;let t=h(a),i=a<0,d=i?n:t,c=i?t:n;l.append("path").attr("d",i?"\n                M ".concat(s," ").concat(d,"\n                L ").concat(s+r," ").concat(d,"\n                L ").concat(s+r," ").concat(c-6,"\n                Q ").concat(s+r," ").concat(c," ").concat(s+r-6," ").concat(c,"\n                L ").concat(s+6," ").concat(c,"\n                Q ").concat(s," ").concat(c," ").concat(s," ").concat(c-6,"\n                L ").concat(s," ").concat(d,"\n                Z\n              "):"\n                M ".concat(s," ").concat(c,"\n                L ").concat(s," ").concat(d+6,"\n                Q ").concat(s," ").concat(d," ").concat(s+6," ").concat(d,"\n                L ").concat(s+r-6," ").concat(d,"\n                Q ").concat(s+r," ").concat(d," ").concat(s+r," ").concat(d+6,"\n                L ").concat(s+r," ").concat(c,"\n                Z\n              ")).attr("fill","#22D3EE").style("pointer-events","none").style("opacity",null===u||"consumed"===u?1:.3)}}),a.forEach(e=>{if("pre_ion"===e.type)return;let a=e.period.replace(" - ","\n"),t=a.replace("\n"," "),s=i(a)||0,r=i.bandwidth(),n=h(0),o=h(e.baseline_gallons),d=Math.abs(n-o);l.append("rect").attr("x",s).attr("y",o).attr("width",r).attr("height",d).attr("fill","transparent").attr("stroke","#ACE7EF").attr("stroke-width",2).attr("stroke-dasharray","4 4").attr("rx",6).attr("ry",6).style("cursor","pointer").style("opacity",null===u||"baseline"===u?1:.3).on("mouseenter",function(a){x("baseline"),_(a,j(e,t))}).on("mouseleave",function(){x(null),w()})}),N>=0){let e=a[N-1],s=a[N];if(e&&s){let a=e.period.replace(" - ","\n"),r=s.period.replace(" - ","\n"),n=((i(a)||0)+i.bandwidth()+(i(r)||0))/2;l.append("line").attr("x1",n).attr("x2",n).attr("y1",-35).attr("y2",t).attr("stroke","#F97316").attr("stroke-width",2),l.append("image").attr("xlink:href","/images/logo.png").attr("x",n-21.5).attr("y",-40).attr("width",43).attr("height",16)}}a.forEach((e,s)=>{if(e.new_installations&&e.new_installations.length>0){let r,n=i(e.period.replace(" - ","\n"))||0;r=0===s?n:((i(a[s-1].period.replace(" - ","\n"))||0)+i.bandwidth()+n)/2,l.append("line").attr("x1",r).attr("x2",r).attr("y1",-20).attr("y2",t).attr("stroke","#F97316").attr("stroke-width",2),l.append("image").attr("xlink:href","/images/logo.png").attr("x",r-21.5).attr("y",-40).attr("width",43).attr("height",16);let o=e.new_installations.length;l.append("text").attr("x",r).attr("y",-50).attr("text-anchor","middle").attr("fill","#666666").attr("font-size","12px").attr("font-weight","400").attr("text-decoration","underline").style("cursor","pointer").text("+".concat(o," ").concat(1===o?"Property":"Properties")).on("mouseenter",function(a){let t=e.new_installations.map(e=>e.property_name).join("<br/>");v.html('\n              <div class="bg-white border border-brand-stroke rounded-sm p-3 shadow-sm">\n                <div class="text-sm text-brand-black font-semibold mb-2 pb-2 border-b border-brand-stroke">'.concat(e.period,'</div>\n                <div class="flex flex-col gap-1 text-sm font-medium">\n                  ').concat(t,"\n                </div>\n              </div>\n            "));let l=v.node().offsetWidth,s=a.clientX-l/2,r=a.clientY+10+5;v.style("opacity",1).style("left","".concat(Math.max(10,s),"px")).style("top","".concat(r,"px"))}).on("mouseleave",function(){v.style("opacity",0)})}})},[s,u,a]),(0,l.jsxs)("div",{className:(0,i.cn)("w-full relative",t),children:[(0,l.jsx)(d,{activeItem:u,onHover:x}),(0,l.jsx)("div",{style:{height:s},children:(0,l.jsx)("svg",{ref:c,className:"w-full"})}),(0,l.jsx)("div",{ref:m,style:{position:"fixed",opacity:0,pointerEvents:"none",zIndex:1e3,transition:"opacity 0.2s"}})]})}var m=t(43482),u=t(26265),p=t(75271),x=t(33420),h=t(37665),g=t(68425),y=t(47734),f=t(73697),b=t(35120),v=t(68202);let N=e=>{let{payload:a,activeItem:t,onHover:s}=e;return a?(0,l.jsx)("div",{className:"flex items-center gap-6 overflow-x-auto [&::-webkit-scrollbar]:hidden",children:a.map(e=>{let a=e.dataKey||e.value.toLowerCase().replace(/ /g,"");return(0,l.jsxs)("div",{className:"flex items-center gap-3 cursor-pointer transition-opacity duration-200",style:{opacity:t?t===a?1:.3:1},onMouseEnter:()=>s(a),onMouseLeave:()=>s(null),children:[(0,l.jsx)("span",{className:"inline-block w-3 h-3 rounded-sm",style:{backgroundColor:e.color}}),(0,l.jsx)("span",{className:"text-base font-medium text-brand-black text-nowrap text-ellipsis",children:e.value})]},e.value)})}):null},j=e=>{let{x:a,y:t,payload:s}=e;if(!(null==s?void 0:s.value))return null;let r=s.value;if(r.includes(" - ")){let[e,s]=r.split(" - ");return(0,l.jsx)("g",{transform:"translate(".concat(a,",").concat(t,")"),children:(0,l.jsxs)("text",{x:0,y:0,textAnchor:"middle",fill:"#666666",fontSize:12,children:[(0,l.jsx)("tspan",{x:0,dy:"8",children:e}),(0,l.jsx)("tspan",{x:0,dy:"14",children:s})]})})}return(0,l.jsx)("g",{transform:"translate(".concat(a,",").concat(t,")"),children:(0,l.jsx)("text",{x:0,y:0,dy:8,textAnchor:"middle",fill:"#666666",fontSize:12,children:r})})},_=e=>{var a;let{active:t,payload:s,label:r,data:n}=e;if(!t||!s||0===s.length)return null;let i=n.findIndex(e=>e.new_installations&&e.new_installations.length>0),o=null==(a=s[0])?void 0:a.payload,d=n.findIndex(e=>e.period===(null==o?void 0:o.period));return -1===i||d<i?null:(0,l.jsxs)("div",{className:"bg-white border border-brand-stroke rounded-sm p-3 shadow-sm",children:[(0,l.jsx)("div",{className:"font-semibold mb-2",children:r}),(0,l.jsx)("div",{className:"flex flex-col gap-2",children:s.map((e,a)=>(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("span",{className:"inline-block w-3 h-3 rounded-sm",style:{backgroundColor:e.color}}),(0,l.jsxs)("span",{className:"text-sm font-medium",children:[e.name,": $",Math.round(e.value||0).toLocaleStr
1ing()]})]},a))})]})};function w(e){let{data:a,className:t,height:s=250}=e,[n,d]=(0,r.useState)(null),c=e=>{d(e)};return(0,l.jsx)("div",{style:{height:s},className:(0,i.cn)("w-full",t),children:(0,l.jsx)(u.u,{width:"99%",height:s,debounce:1,children:(0,l.jsxs)(p.X,{data:a,margin:{top:40,right:30,left:20,bottom:10},barCategoryGap:8,children:[(0,l.jsx)(x.m,{labelFormatter:(e,a)=>a&&a[0]?"Period: ".concat(a[0].payload.period):"",contentStyle:{backgroundColor:"white",border:"1px solid #CBD4E3"},content:(0,l.jsx)(_,{data:a})}),(0,l.jsx)(h.s,{content:(0,l.jsx)(N,{activeItem:n,onHover:c}),wrapperStyle:{position:"absolute",top:0,left:0,display:"flex"},verticalAlign:"top"}),(0,l.jsx)(g.d,{yAxisId:"left",strokeDasharray:"0 0",vertical:!1,stroke:"#E5E7EB"}),(0,l.jsx)(y.W,{dataKey:"period",axisLine:!1,tickLine:!1,tick:(0,l.jsx)(j,{}),height:20,interval:0}),(0,l.jsx)(f.h,{yAxisId:"left",axisLine:!1,tickLine:!1,tick:{fill:"#666666"},tickFormatter:e=>(0,o.I)(e,!0)}),(0,l.jsx)(b.yP,{yAxisId:"left",dataKey:"saved_dollars",fill:"#A1CEBC",name:"Cost Savings ($) after ION",opacity:n?"saved_dollars"===n?1:.3:1,onMouseEnter:()=>c("saved_dollars"),onMouseLeave:()=>c(null),radius:[6,6,6,6]}),(0,l.jsx)(v.e_,{yAxisId:"left",x:(()=>{let e=a.findIndex(e=>e.new_installations&&e.new_installations.length>0);if(e>0){var t;return null==(t=a[e-1])?void 0:t.period}})(),stroke:"#F97316",strokeWidth:2,label:{position:"top",content:e=>{let{viewBox:a}=e;if(!a||!("x"in a))return null;let{x:t,y:s}=a;return(0,l.jsx)("g",{children:(0,l.jsx)("foreignObject",{x:t-21.5,y:s-30,width:43,height:16,children:(0,l.jsx)("div",{style:{display:"flex",alignItems:"center",justifyContent:"center"},children:(0,l.jsx)("img",{src:"/images/logo.png",alt:"ION",width:43,height:16})})})})}},ifOverflow:"visible",position:"end"})]})})})}var k=t(12723),C=t(4035),S=t(69386);function E(e){let{data:a,className:t,innerRadius:s=60,outerRadius:n=95,title:o}=e,[d,c]=(0,r.useState)(null),m=[{name:"$ Saved",value:(null==a?void 0:a.expense_saved)||0,color:"#A1CEBC"},{name:"Total Expense",value:(null==a?void 0:a.total_expense)||0,color:"#BBF7D0"}],p=[{name:"$ Saved",value:(null==a?void 0:a.expense_saved)||0,color:"#A1CEBC",label:"$".concat(Math.round((null==a?void 0:a.expense_saved)||0).toLocaleString()||0),labelColor:"#15803D"},{name:"Total Expense",value:(null==a?void 0:a.total_expense)||0,color:"#BBF7D0",label:"$".concat(Math.round((null==a?void 0:a.total_expense)||0).toLocaleString()||0),labelColor:"#4ADE80"},{name:"Baseline Expense",value:(null==a?void 0:a.baseline_expense)||0,color:"#166534",label:"$".concat(Math.round((null==a?void 0:a.baseline_expense)||0).toLocaleString()||0),labelColor:"#166534",isCircle:!0}],x=(null==a?void 0:a.expense_saved)||0;return(0,l.jsxs)("div",{className:(0,i.cn)("flex items-center gap-8",t),children:[(0,l.jsxs)("div",{className:"w-[220px] h-[220px] relative",children:[(0,l.jsx)("svg",{className:"absolute inset-0 w-full h-full pointer-events-none",style:{transform:"rotate(-90deg)"},children:(0,l.jsx)("circle",{cx:"50%",cy:"50%",r:"47%",fill:"none",stroke:"#166534",strokeWidth:"2",strokeDasharray:"6 6"})}),(0,l.jsxs)("div",{className:"absolute inset-0 flex flex-col items-center justify-center transition-all duration-200",children:[(0,l.jsx)("span",{className:"font-bold text-brand-black text-xl transition-all duration-200",children:Math.round(x).toLocaleString()}),(0,l.jsx)("span",{className:"text-xs text-brand-dark-gray transition-all duration-200",children:"$"})]}),(0,l.jsx)(u.u,{width:220,height:220,debounce:1,children:(0,l.jsx)(k.r,{children:(0,l.jsx)(C.Fq,{data:m,cx:"50%",cy:"50%",innerRadius:s,outerRadius:n,paddingAngle:0,dataKey:"value",labelLine:!1,startAngle:90,endAngle:-270,className:"focus:outline-hidden",children:m.map((e,a)=>(0,l.jsx)(S.f,{fill:e.color,onMouseEnter:()=>c(a),onMouseLeave:()=>c(null),style:{opacity:null===d||d===a?1:.3,transition:"opacity 0.2s",outline:"none"},className:"focus:outline-hidden"},"cell-".concat(a)))})})})]}),(0,l.jsx)(()=>(0,l.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,l.jsxs)("h2",{className:"text-base font-semibold text-brand-black",children:["Gallons Saved ",(0,l.jsxs)("span",{className:"text-brand-dark-gray",children:["(",o,")"]})]}),p.map((e,a)=>(0,l.jsxs)("div",{className:(0,i.cn)("flex items-center gap-3 text-sm cursor-default transition-opacity duration-200",null===d||d===a?"":"opacity-30"),onMouseEnter:()=>e.isCircle?null:c(a),onMouseLeave:()=>e.isCircle?null:c(null),children:[(0,l.jsx)("div",{className:"w-2 h-2 rounded-[2px]",style:{backgroundColor:e.color}}),(0,l.jsxs)("span",{className:"font-medium text-brand-black",children:[e.name,":"]}),(0,l.jsx)("span",{style:{color:e.labelColor},className:"font-semibold text-nowrap underline",children:e.label})]},e.name))]}),{})]})}let L=["toilet_leaks_cost","other_leaks_cost"],A={toilet_leaks_cost:"Toilet Leaks",other_leaks_cost:"Other Leaks"},D=e=>{let{payload:a,activeItem:t,onHover:s}=e;if(!a)return null;let r=[...L.map(e=>a.find(a=>
1a.dataKey===e)).filter(Boolean).filter(e=>!!e)];return(0,l.jsx)("div",{className:"flex items-center gap-6 overflow-x-auto [&::-webkit-scrollbar]:hidden",children:r.map(e=>{let a=e.dataKey||e.value.toLowerCase().replace(/ /g,"");return(0,l.jsxs)("div",{className:"flex items-center gap-3 cursor-pointer transition-opacity duration-200",style:{opacity:t?t===a?1:.3:1},onMouseEnter:()=>s(a),onMouseLeave:()=>s(null),children:[(0,l.jsx)("div",{className:"w-2 h-2 rounded-xs",style:{backgroundColor:e.color}}),(0,l.jsx)("span",{className:"text-base font-medium text-brand-black text-nowrap text-ellipsis",children:A[Number(e.dataKey)]||e.value})]},e.value)})})},O=e=>{let{active:a,payload:t,label:s,granularity:r}=e;if(!a||!t||0===t.length)return null;let n=s?(0,o.d)(s,r,!0):"",i=[...t].filter((e,a,t)=>"percent_of_leaks"!==e.dataKey||t.findIndex(e=>"percent_of_leaks"===e.dataKey)===a).map(e=>"percent_of_leaks"===e.dataKey?{...e,color:"#4338CA"}:e).sort((e,a)=>L.indexOf(e.dataKey)-L.indexOf(a.dataKey));return(0,l.jsxs)("div",{className:"bg-white border border-gray-300 rounded-sm p-2 shadow-sm",children:[(0,l.jsx)("div",{className:"font-semibold mb-1",children:n}),i.map((e,a)=>(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("span",{className:"inline-block w-2 h-2 rounded-xs",style:{backgroundColor:e.color}}),(0,l.jsxs)("span",{children:[A[e.dataKey]||e.name,": $",e.value.toLocaleString(),"percent_of_leaks"===e.dataKey?"%":""]})]},a))]})};function T(e){let{data:a,className:t,height:s=250,granularity:n="day"}=e,[d,c]=(0,r.useState)(null),m=e=>{c(e)},v=e=>d?d===e?1:.3:1;return(0,l.jsx)("div",{style:{height:s},className:(0,i.cn)("w-full min-w-0",t),children:(0,l.jsx)(u.u,{width:"99%",height:s,debounce:1,children:(0,l.jsxs)(p.X,{data:a,margin:{top:20,right:30,left:30,bottom:5},barCategoryGap:8,children:[(0,l.jsx)(x.m,{formatter:(e,a)=>void 0===e?"":"% of Leaks"===a?"".concat(e,"%"):e.toLocaleString(),contentStyle:{backgroundColor:"white",border:"1px solid #CBD4E3"},content:(0,l.jsx)(O,{granularity:n})}),(0,l.jsx)(h.s,{content:(0,l.jsx)(D,{activeItem:d,onHover:m}),wrapperStyle:{position:"absolute",top:0,left:0},verticalAlign:"top",height:24}),(0,l.jsx)(g.d,{yAxisId:"left",strokeDasharray:"0 0",vertical:!1,stroke:"#CBD4E3"}),(0,l.jsx)(y.W,{dataKey:"date",axisLine:!1,tickLine:!1,tick:{fill:"#666666"},tickFormatter:e=>(0,o.d)(e,n)}),(0,l.jsx)(f.h,{yAxisId:"left",orientation:"left",axisLine:!1,tickLine:!1,tick:{fill:"#666666"},tickFormatter:e=>(0,o.I)(e,!0),width:30}),(0,l.jsx)(b.yP,{yAxisId:"left",dataKey:"toilet_leaks_cost",stackId:"date",fill:"#A5B4FC",radius:[2,2,2,2],opacity:v("toilet_leaks_cost"),onMouseEnter:()=>m("toilet_leaks_cost"),onMouseLeave:()=>m(null),name:"Toilet Leaks"},"toilet-leaks-bar"),(0,l.jsx)(b.yP,{yAxisId:"left",dataKey:"other_leaks_cost",stackId:"date",fill:"#67E8F9",radius:[2,2,2,2],opacity:v("other_leaks_cost"),onMouseEnter:()=>m("other_leaks_cost"),onMouseLeave:()=>m(null),name:"Other Leaks"},"other-leaks-bar")]})})})}var I=t(64789);function P(e){var a;let{data:t,className:s,innerRadius:n=60,outerRadius:o=100}=e,[d,c]=(0,r.useState)(null),m=(0,I.v)(null==t?void 0:t.total_cost),p=[{name:"Toilet Leak",value:null==t?void 0:t.toilet_leak_cost,color:"#A5B4FC",label:"".concat((0,I.v)(null==t?void 0:t.toilet_leak_cost)," (").concat(null==t?void 0:t.toilet_leak_percentage,"%)"),labelColor:"#4F46E5",performance:"toilet_leak"},{name:"Other Leaks",value:null==t?void 0:t.other_leak_cost,color:"#67E8F9",label:"".concat((0,I.v)(null==t?void 0:t.other_leak_cost)," (").concat(null==t?void 0:t.other_leak_percentage,"%)"),labelColor:"#098090",performance:"other_leaks"}];return(0,l.jsxs)("div",{className:(0,i.cn)("flex items-center gap-8",s),children:[(0,l.jsxs)("div",{className:"w-[200px] h-[200px] min-w-0 relative",children:[(0,l.jsxs)("div",{className:"absolute inset-0 flex flex-col items-center justify-center transition-all duration-200",children:[(0,l.jsx)("span",{className:(0,i.cn)("inset-0 font-semibold text-brand-black transition-all duration-200",m.length>7?"text-2xl":"text-3xl"),children:m}
1),(null==t||null==(a=t.total_cost)?void 0:a.toLocaleString())&&(0,l.jsx)("span",{className:"inset-0 text-sm text-brand-dark-gray transition-all duration-200",children:"Total Costs"})]}),(0,l.jsx)(u.u,{width:200,height:200,debounce:1,children:(0,l.jsx)(k.r,{children:(0,l.jsx)(C.Fq,{data:p,cx:"50%",cy:"50%",innerRadius:n,outerRadius:o,paddingAngle:1,dataKey:"value",labelLine:!1,className:"focus:outline-hidden",children:p.map((e,a)=>(0,l.jsx)(S.f,{fill:e.color,onMouseEnter:()=>c(a),onMouseLeave:()=>c(null),style:{opacity:null===d||d===a?1:.3,transition:"opacity 0.2s",outline:"none"},className:"focus:outline-hidden"},"cell-".concat(a)))})})})]}),(0,l.jsx)(()=>(0,l.jsx)("div",{className:"flex flex-col gap-4",children:p.map((e,a)=>(0,l.jsxs)("div",{className:(0,i.cn)("flex items-center gap-3 text-base font-semibold cursor-default transition-opacity duration-200",null===d||d===a?"":"opacity-30"),onMouseEnter:()=>c(a),onMouseLeave:()=>c(null),children:[(0,l.jsx)("div",{className:"w-2 h-2 rounded-xs",style:{backgroundColor:e.color}}),(0,l.jsxs)("span",{className:"truncate",children:[e.name,":"]}),(0,l.jsx)("span",{style:{color:e.labelColor},className:"text-nowrap",children:e.label})]},e.name))}),{})]})}var R=t(57095);let M=["normal_consumption","toilet_leaks","other_leaks","percent_of_leaks"],G=["percent_of_leaks","normal_consumption","toilet_leaks","other_leaks"],z={normal_consumption:"Normal Consumption",toilet_leaks:"Toilet Leaks",other_leaks:"Other Leaks",percent_of_leaks:"% of Leaks"},F=e=>{let{payload:a,activeItem:t,onHover:s}=e;if(!a)return null;let r=[...M.map(e=>a.find(a=>a.dataKey===e)).filter(Boolean).filter(e=>!!e).filter(e=>"percent_of_leaks"!==e.dataKey),{value:"% of Leaks",color:"#4338CA",dataKey:"percent_of_leaks",type:"line",key:"leak-percentage-line"},{value:"Goal (10%)",color:"#F97316",dataKey:"goal_percent",type:"line",key:"reference-line"}];return(0,l.jsx)("div",{className:"flex items-center gap-6 overflow-x-auto [&::-webkit-scrollbar]:hidden",children:r.map(e=>{let a=e.dataKey||e.value.toLowerCase().replace(/ /g,"");return(0,l.jsxs)("div",{className:"flex items-center gap-3 cursor-pointer transition-opacity duration-200",style:{opacity:t?t===a?1:.3:1},onMouseEnter:()=>s(a),onMouseLeave:()=>s(null),children:["percent_of_leaks"===e.dataKey||"goal_percent"===e.dataKey?(0,l.jsxs)("div",{className:"flex items-center relative",children:[(0,l.jsx)("span",{className:"inline-block w-5 h-0.5 rounded-xs",style:{backgroundColor:e.color}}),(0,l.jsx)("span",{className:"inline-block w-2 h-2 rounded-full absolute left-1.5 top-1/2 -translate-y-1/2",style:{backgroundColor:e.color}})]}):(0,l.jsx)("span",{className:"inline-block w-3 h-3 rounded-sm",style:{backgroundColor:e.color}}),(0,l.jsx)("span",{className:"text-base font-medium text-brand-black text-nowrap text-ellipsis",children:z[Number(e.dataKey)]||e.value})]},e.value)})})},H=e=>{var a,t,s;let{active:r,payload:n,label:d,granularity:c}=e;if(!r||!n||0===n.length)return null;let m=d?(0,o.d)(d,c,!0):"",u=null==(s=n[0])||null==(t=s.payload)||null==(a=t.total_consumed)?void 0:a.toLocaleString(),p=[...n].filter((e,a,t)=>"percent_of_leaks"!==e.dataKey||t.findIndex(e=>"percent_of_leaks"===e.dataKey)===a).map(e=>"percent_of_leaks"===e.dataKey?{...e,color:"#4338CA"}:e).sort((e,a)=>G.indexOf(e.dataKey)-G.indexOf(a.dataKey));return(0,l.jsxs)("div",{className:"bg-white border border-brand-stroke rounded-sm p-3 shadow-sm",children:[(0,l.jsx)("div",{className:"font-semibold mb-2",children:m}),(0,l.jsx)("div",{className:"flex flex-col gap-2 border-b border-brand-stroke pb-2 mb-2",children:p.map((e,a)=>(0,l.jsxs)("div",{className:(0,i.cn)("flex items-center","percent_of_leaks"===e.dataKey?"gap-2":"gap-4"),children:["percent_of_leaks"===e.dataKey?(0,l.jsxs)("div",{className:"flex items-center relative",children:[(0,l.jsx)("span",{className:"inline-block w-5 h-0.5 rounded-xs",style:{backgroundColor:e.color}}),(0,l.jsx)("span",{className:"inline-block w-2 h-2 rounded-full absolute left-1.5 top-1/2 -translate-y-1/2",style:{backgroundColor:e.color}})]}):(0,l.jsx)("span",{className:"inline-block w-3 h-3 rounded-sm",style:{backgroundColor:e.color}}),(0,l.jsxs)("span",{children:[z[e.dataKey]||e.name,":"," ",e.value.toLocaleStr
1ing(),"percent_of_leaks"===e.dataKey?"%":""]})]},a))}),(0,l.jsxs)("p",{className:"text-sm text-brand-dark-gray",children:["Total Gallons Consumed (Normal + Leaks): ",u," gallons"]})]})};function V(e){let{data:a,className:t,height:s=250,granularity:n="day"}=e,[d,c]=(0,r.useState)(null),[m,N]=(0,r.useState)(!0);(0,r.useEffect)(()=>{let e=setTimeout(()=>N(!1),1e3);return()=>window.clearTimeout(e)},[]);let j=e=>{c(e)},_=e=>d?d===e?1:.3:1;return(0,l.jsx)("div",{style:{height:s},className:(0,i.cn)("w-full",t),children:(0,l.jsx)(u.u,{width:"99%",height:s,debounce:1,children:(0,l.jsxs)(p.X,{data:a,margin:{top:20,right:30,left:30,bottom:5},barCategoryGap:8,children:[(0,l.jsx)(x.m,{formatter:(e,a)=>void 0===e?"":"% of Leaks"===a?"".concat(e,"%"):e.toLocaleString(),contentStyle:{backgroundColor:"white",border:"1px solid #CBD4E3"},content:(0,l.jsx)(H,{granularity:n})}),(0,l.jsx)(h.s,{content:(0,l.jsx)(F,{activeItem:d,onHover:j}),wrapperStyle:{position:"absolute",top:0,left:0},verticalAlign:"top",height:24}),(0,l.jsx)(g.d,{yAxisId:"left",strokeDasharray:"0 0",vertical:!1,stroke:"#CBD4E3"}),(0,l.jsx)(y.W,{dataKey:"date",axisLine:!1,tickLine:!1,tick:{fill:"#666666"},tickFormatter:e=>(0,o.d)(e,n)}),(0,l.jsx)(f.h,{yAxisId:"left",orientation:"left",axisLine:!1,tickLine:!1,tick:{fill:"#666666"},tickFormatter:e=>(0,o.I)(e,!1),width:30}),(0,l.jsx)(f.h,{yAxisId:"right",orientation:"right",axisLine:!1,tickLine:!1,tick:{fill:"#666666"},unit:"%",minTickGap:10,width:30}),(0,l.jsx)(b.yP,{yAxisId:"left",dataKey:"normal_consumption",stackId:"date",fill:"#2DA8BA",radius:[2,2,2,2],opacity:_("normal_consumption"),onMouseEnter:()=>j("normal_consumption"),onMouseLeave:()=>j(null),name:"Normal Consumption"},"normal-consumption-bar"),(0,l.jsx)(b.yP,{yAxisId:"left",dataKey:"toilet_leaks",stackId:"date",fill:"#A5B4FC",radius:[2,2,2,2],opacity:_("toilet_leaks"),onMouseEnter:()=>j("toilet_leaks"),onMouseLeave:()=>j(null),name:"Toilet Leaks"},"toilet-leaks-bar"),(0,l.jsx)(b.yP,{yAxisId:"left",dataKey:"other_leaks",stackId:"date",fill:"#67E8F9",radius:[2,2,2,2],opacity:_("other_leaks"),onMouseEnter:()=>j("other_leaks"),onMouseLeave:()=>j(null),name:"Other Leaks"},"other-leaks-bar"),(0,l.jsx)(R.N1,{type:"monotone",yAxisId:"right",dataKey:"percent_of_leaks",stroke:"#4338CA",strokeWidth:2,dot:{fill:"#472AB1",r:2},opacity:_("percent_of_leaks"),onMouseEnter:()=>j("percent_of_leaks"),onMouseLeave:()=>j(null),name:"% of Leaks",isAnimationActive:m},"leak-percentage-line"),(0,l.jsx)(v.e_,{y:10,yAxisId:"right",stroke:"#F97316",strokeWidth:2,strokeDasharray:"0 0",opacity:_("goal_percent"),onMouseEnter:()=>j("goal_percent"),onMouseLeave:()=>j(null),label:{value:"⚑",position:"right",fill:"#F97316",fontSize:12},name:""},"reference-line")]})})})}function U(e){let{data:a,className:t,innerRadius:s=60,outerRadius:n=95,title:o}=e,[d,c]=(0,r.useState)(null),m=[{name:"Gallons Saved",value:(null==a?void 0:a.gallons_saved)||0,color:"#CFFAFE"},{name:"Total Gallons",value:(null==a?void 0:a.total_gallons)||0,color:"#22D3EE"}],p=[{name:"Gallons Saved",value:(null==a?void 0:a.gallons_saved)||0,color:"#CFFAFE",label:"".concat(Math.round((null==a?void 0:a.gallons_saved)||0).toLocaleString()||0," gallons"),labelColor:"#06B6D4"},{name:"Total Gallons",value:(null==a?void 0:a.total_gallons)||0,color:"#22D3EE",label:"".concat(Math.round((null==a?void 0:a.total_gallons)||0).toLocaleString()||0," gallons"),labelColor:"#0E7490"},{name:"Baseline Gallons",value:(null==a?void 0:a.baseline_gallons)||0,color:"#2DA8BA",label:"".concat(Math.round((null==a?void 0:a.baseline_gallons)||0).toLocaleString()||0," gallons"),labelColor:"#27546E",isCircle:!0}],x=(null==a?void 0:a.gallons_saved)||0;return(0,l.jsxs)("div",{className:(0,i.cn)("flex items-center gap-8",t),children:[(0,l.jsxs)("div",{className:"w-[220px] h-[220px] relative",children:[(0,l.jsx)("svg",{className:"absolute inset-0 w-full h-full pointer-events-none",style:{transform:"rotate(-90deg)"},children:(0,l.jsx)("circle",{cx:"50%",cy:"50%",r:"47%",fill:"none",stroke:"#2DA8BA",strokeWidth:"2",strokeDasharray:"6 6"})}),(0,l.jsxs)("div",{className:"absolute inset-0 flex flex-col items-center justify-center transition-all duration-200",children:[(0,l.jsx)("span",{className:"font-bold text-brand-black text-base transition-all duration-200",children:x.toLocaleStr
1ing()}),(0,l.jsx)("span",{className:"text-xs text-brand-dark-gray transition-all duration-200",children:"Gallons"})]}),(0,l.jsx)(u.u,{width:220,height:220,debounce:1,children:(0,l.jsx)(k.r,{children:(0,l.jsx)(C.Fq,{data:m,cx:"50%",cy:"50%",innerRadius:s,outerRadius:n,paddingAngle:0,dataKey:"value",labelLine:!1,startAngle:90,endAngle:-270,className:"focus:outline-hidden",children:m.map((e,a)=>(0,l.jsx)(S.f,{fill:e.color,onMouseEnter:()=>c(a),onMouseLeave:()=>c(null),style:{opacity:null===d||d===a?1:.3,transition:"opacity 0.2s",outline:"none"},className:"focus:outline-hidden"},"cell-".concat(a)))})})})]}),(0,l.jsx)(()=>(0,l.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,l.jsxs)("h2",{className:"text-base font-semibold text-brand-black",children:["Gallons Saved ",(0,l.jsxs)("span",{className:"text-brand-dark-gray",children:["(",o,")"]})]}),p.map((e,a)=>(0,l.jsxs)("div",{className:(0,i.cn)("flex items-center gap-3 text-sm cursor-default transition-opacity duration-200",null===d||d===a?"":"opacity-30"),onMouseEnter:()=>e.isCircle?null:c(a),onMouseLeave:()=>e.isCircle?null:c(null),children:[(0,l.jsx)("div",{className:"w-2 h-2 rounded-[2px]",style:{backgroundColor:e.color}}),(0,l.jsxs)("span",{className:"font-medium text-brand-black",children:[e.name,":"]}),(0,l.jsx)("span",{style:{color:e.labelColor},className:"font-semibold text-nowrap underline",children:e.label})]},e.name))]}),{})]})}let B=e=>{let{activeItem:a,onHover:t,hasBeforeInstallation:s=!0}=e,r=[{label:"Gallons per Bedroom per Day before ION",color:"#FED7AA",dataKey:"gbd-before",show:s},{label:"Gallons per Bedroom per Day after ION",color:"#FB923C",dataKey:"gbd-after",show:!0}].filter(e=>e.show);return(0,l.jsx)("div",{className:"flex items-center gap-6 overflow-x-auto [&::-webkit-scrollbar]:hidden",children:r.map(e=>{var s;return(0,l.jsxs)("div",{className:"flex items-center gap-3 cursor-pointer transition-opacity duration-200",style:{opacity:(s=e.dataKey,a?a===s?1:.3:1)},onMouseEnter:()=>t(e.dataKey),onMouseLeave:()=>t(null),children:[(0,l.jsx)("span",{className:"inline-block w-3 h-3 rounded-sm",style:{backgroundColor:e.color}}),(0,l.jsx)("span",{className:"text-base font-medium text-brand-black text-nowrap text-ellipsis",children:e.label})]},e.dataKey)})})},K=e=>{let{x:a,y:t,payload:s}=e;if(!(null==s?void 0:s.value))return null;let r=s.value;if(r.includes(" - ")){let[e,s]=r.split(" - ");return(0,l.jsx)("g",{transform:"translate(".concat(a,",").concat(t,")"),children:(0,l.jsxs)("text",{x:0,y:0,textAnchor:"middle",fill:"#666666",fontSize:12,children:[(0,l.jsx)("tspan",{x:0,dy:"8",children:e}),(0,l.jsx)("tspan",{x:0,dy:"14",children:s})]})})}return(0,l.jsx)("g",{transform:"translate(".concat(a,",").concat(t,")"),children:(0,l.jsx)("text",{x:0,y:0,dy:8,textAnchor:"middle",fill:"#666666",fontSize:12,children:r})})},W=e=>{let{active:a,payload:t,label:s}=e;return a&&t&&0!==t.length?(0,l.jsxs)("div",{className:"bg-white border border-brand-stroke rounded-sm p-3 shadow-sm",children:[(0,l.jsx)("div",{className:"font-semibold mb-2",children:s}),(0,l.jsx)("div",{className:"flex flex-col gap-2",children:t.map((e,a)=>{var t,s;return(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("span",{className:"inline-block w-3 h-3 rounded-sm",style:{backgroundColor:null==(t=e.payload)?void 0:t.barColor}}),(0,l.jsxs)("span",{className:"text-sm font-medium",children:[null==(s=e.payload)?void 0:s.tooltipLabel,":"," ",Math.round(e.value||0).toLocaleString()," gallons"]})]},a)})})]}):null};function Y(e){let{data:a,className:t,height:s=280}=e,[n,d]=(0,r.useState)(null),c=e=>{d(e)},m=a.findIndex(e=>e.new_installations&&e.new_installations.length>0),N=a.map((e,a)=>{let t=-1===m||a<m;return{...e,barColor:t?"#FED7AA":"#FB923C",displayValue:t?e.baseline_gbd:e.gbd,tooltipLabel:t?"GBD before ION":"GBD after ION"}});return(0,l.jsx)("div",{style:{height:s},className:(0,i.cn)("w-full",t),children:(0,l.jsx)(u.u,{width:"100%",height:"100%",children:(0,l.jsxs)(p.X,{data:N,margin:{top:60,right:30,left:20,bottom:10},barCategoryGap:8,children:[(0,l.jsx)(x.m,{labelFormatter:(e,a)=>a&&a[0]?"Period: ".concat(a[0].payload.period):"",contentStyle:{backgroundColor:"white",border:"1px solid #CBD4E3"},content:(0,l.jsx)(W,{})}),(0,l.jsx)(h.s,{content:(0,l.jsx)(B,{activeItem:n,onHover:c,hasBeforeInstallation:m>0}),wrapperStyle:{position:"absolute",top:6,left:0,display:"flex"},verticalAlign:"top"}),(0,l.jsx)(g.d,{yAxisId:"left",strokeDasharray:"0 0",vertical:!1,stroke:"#E5E7EB"}
1),(0,l.jsx)(y.W,{dataKey:"period",axisLine:!1,tickLine:!1,tick:(0,l.jsx)(K,{}),height:20,interval:0}),(0,l.jsx)(f.h,{yAxisId:"left",axisLine:!1,tickLine:!1,tick:{fill:"#666666"},tickFormatter:e=>(0,o.I)(e,!1)}),(0,l.jsx)(b.yP,{yAxisId:"left",dataKey:"displayValue",name:"Gallons per Bedroom per Day",radius:[6,6,6,6],children:N.map((e,a)=>{let t=-1===m||a<m?"gbd-before":"gbd-after";return(0,l.jsx)(S.f,{fill:e.barColor,opacity:n?n===(-1===m||a<m?"gbd-before":"gbd-after")?1:.3:1,onMouseEnter:()=>c(t),onMouseLeave:()=>c(null),style:{cursor:"pointer"}},"cell-".concat(a))})}),(0,l.jsx)(v.e_,{yAxisId:"left",x:(()=>{let e=a.findIndex(e=>e.new_installations&&e.new_installations.length>0);if(e>0){var t;return null==(t=a[e-1])?void 0:t.period}})(),stroke:"#F97316",strokeWidth:2,label:{position:"top",content:e=>{let{viewBox:a}=e;if(!a||!("x"in a))return null;let{x:t,y:s}=a;return(0,l.jsx)("g",{id:"ion-reference-line",children:(0,l.jsx)("foreignObject",{x:t-21.5,y:s-30,width:43,height:16,children:(0,l.jsx)("div",{style:{display:"flex",alignItems:"center",justifyContent:"center"},children:(0,l.jsx)("img",{src:"/images/logo.png",alt:"ION",width:43,height:16})})})})}},ifOverflow:"visible",position:"end"})]})})})}function $(e){var a,t,s,n;let{data:o,handleGoToProperties:d,className:c,innerRadius:m=60,outerRadius:p=100}=e,[x,h]=(0,r.useState)(null),g=(e,a)=>{var t;let l=1===e?"Property":"Properties";return"".concat(null!=(t=null==e?void 0:e.toLocaleString())?t:0," ").concat(l," (").concat(null!=a?a:0,"%)")},y=[{name:"On Track",value:o.on_track,color:"#62AE90",label:g(o.on_track,o.on_track_percentage),labelColor:"#428067",performance:"on_track"},{name:"Opportunities",value:o.opportunities,color:"#FCCF85",label:g(o.opportunities,o.opportunities_percentage),labelColor:"#BD7E17",performance:"opportunities"},{name:"Critical",value:o.critical,color:"#EE5A4F",label:g(o.critical,o.critical_percentage),labelColor:"#B91C1C",performance:"critical"},{name:"Zero Usage",value:o.zero_usage,color:"#CBD4E3",label:g(o.zero_usage,o.zero_usage_percentage),labelColor:"#666",performance:"zero_usage"}];return(0,l.jsxs)("div",{className:(0,i.cn)("flex items-center gap-8",c),children:[(0,l.jsxs)("div",{className:"w-[200px] h-[200px] relative",children:[(0,l.jsxs)("div",{className:"absolute inset-0 flex flex-col items-center justify-center transition-all duration-200",children:[(0,l.jsx)("span",{className:(0,i.cn)("inset-0 font-semibold text-brand-black transition-all duration-200",(null!=(n=null==(a=o.total_leaks)?void 0:a.toLocaleString().length)?n:0)>6?"text-2xl":"text-3xl"),children:(null==(t=o.total_leaks)?void 0:t.toLocaleString())||""}
1),(null==(s=o.total_leaks)?void 0:s.toLocaleString())&&(0,l.jsx)("span",{className:"inset-0 text-sm text-brand-dark-gray transition-all duration-200",children:"Leaks"})]}),(0,l.jsx)(u.u,{width:200,height:200,debounce:1,children:(0,l.jsx)(k.r,{children:(0,l.jsx)(C.Fq,{data:y,cx:"50%",cy:"50%",innerRadius:m,outerRadius:p,paddingAngle:1,dataKey:"value",labelLine:!1,className:"focus:outline-hidden",children:y.map((e,a)=>(0,l.jsx)(S.f,{fill:e.color,onMouseEnter:()=>h(a),onMouseLeave:()=>h(null),onClick:()=>d(e.performance),style:{opacity:null===x||x===a?1:.3,transition:"opacity 0.2s",cursor:"pointer",outline:"none"},className:"focus:outline-hidden"},"cell-".concat(a)))})})})]}),(0,l.jsx)(()=>(0,l.jsx)("div",{className:"flex flex-col gap-4",children:y.map((e,a)=>(0,l.jsxs)("div",{className:(0,i.cn)("flex items-center gap-3 text-base font-semibold cursor-default transition-opacity duration-200",null===x||x===a?"":"opacity-30"),onMouseEnter:()=>h(a),onMouseLeave:()=>h(null),children:[(0,l.jsx)("div",{className:"w-2 h-2 rounded-xs",style:{backgroundColor:e.color}}),(0,l.jsxs)("span",{className:"truncate",children:[e.name,":"]}),(0,l.jsx)("span",{style:{color:e.labelColor},className:"text-nowrap underline cursor-pointer",onClick:()=>{d(e.performance)},children:e.label})]},e.name))}),{})]})}let Z=e=>{let{payload:a,activeItem:t,onHover:s}=e;return a?(0,l.jsx)("div",{className:"flex items-center gap-6 overflow-x-auto [&::-webkit-scrollbar]:hidden",children:a.map(e=>{let a=e.dataKey||e.value.toLowerCase().replace(/ /g,"");return(0,l.jsxs)("div",{className:"flex items-center gap-3 cursor-pointer transition-opacity duration-200",style:{opacity:t?t===a?1:.3:1},onMouseEnter:()=>s(a),onMouseLeave:()=>s(null),children:[(0,l.jsx)("span",{className:"inline-block w-3 h-3 rounded-sm",style:{backgroundColor:e.color}}),(0,l.jsx)("span",{className:"text-base font-medium text-brand-black text-nowrap text-ellipsis",children:e.value})]},e.value)})}):null},q=e=>{let{x:a,y:t,payload:s}=e;if(!(null==s?void 0:s.value))return null;let r=s.value;if(r.includes(" - ")){let[e,s]=r.split(" - ");return(0,l.jsx)("g",{transform:"translate(".concat(a,",").concat(t,")"),children:(0,l.jsxs)("text",{x:0,y:0,textAnchor:"middle",fill:"#666666",fontSize:12,children:[(0,l.jsx)("tspan",{x:0,dy:"8",children:e}),(0,l.jsx)("tspan",{x:0,dy:"14",children:s})]})})}return(0,l.jsx)("g",{transform:"translate(".concat(a,",").concat(t,")"),children:(0,l.jsx)("text",{x:0,y:0,dy:8,textAnchor:"middle",fill:"#666666",fontSize:12,children:r})})},J=e=>{var a;let{active:t,payload:s,label:r,data:n}=e;if(!t||!s||0===s.length)return null;let i=n.findIndex(e=>e.new_installations&&e.new_installations.length>0),o=null==(a=s[0])?void 0:a.payload,d=n.findIndex(e=>e.period===(null==o?void 0:o.period));return -1===i||d<i?null:(0,l.jsxs)("div",{className:"bg-white border border-brand-stroke rounded-sm p-3 shadow-sm",children:[(0,l.jsx)("div",{className:"font-semibold mb-2",children:r}),(0,l.jsx)("div",{className:"flex flex-col gap-2",children:s.map((e,a)=>(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("span",{className:"inline-block w-3 h-3 rounded-sm",style:{backgroundColor:e.color}}),(0,l.jsxs)("span",{className:"text-sm font-medium",children:[e.name,": ",Math.round(e.value||0).toLocaleString()," ","gallons"]})]},a))})]})};function X(e){let{data:a,className:t,height:s=280}=e,[n,d]=(0,r.useState)(null),c=e=>{d(e)};return(0,l.jsx)("div",{style:{height:s},className:(0,i.cn)("w-full",t),children:(0,l.jsx)(u.u,{width:"99%",height:s,debounce:1,children:(0,l.jsxs)(p.X,{data:a,margin:{top:60,right:30,left:20,bottom:10},barCategoryGap:8,children:[(0,l.jsx)(x.m,{labelFormatter:(e,a)=>a&&a[0]?"Period: ".concat(a[0].payload.period):"",contentStyle:{backgroundColor:"white",border:"1px solid #CBD4E3"},content:(0,l.jsx)(J,{data:a})}),(0,l.jsx)(h.s,{content:(0,l.jsx)(Z,{activeItem:n,onHover:c}),wrapperStyle:{position:"absolute",top:6,left:0,display:"flex"},verticalAlign:"top"}),(0,l.jsx)(g.d,{yAxisId:"left",strokeDasharray:"0 0",vertical:!1,stroke:"#E5E7EB"}
1),(0,l.jsx)(y.W,{dataKey:"period",axisLine:!1,tickLine:!1,tick:(0,l.jsx)(q,{}),height:20,interval:0}),(0,l.jsx)(f.h,{yAxisId:"left",axisLine:!1,tickLine:!1,tick:{fill:"#666666"},tickFormatter:e=>(0,o.I)(e,!0)}),(0,l.jsx)(b.yP,{yAxisId:"left",dataKey:"saved_gallons",fill:"#CFFAFE",name:"Water Savings (gallons) after ION",opacity:n?"saved_gallons"===n?1:.3:1,onMouseEnter:()=>c("saved_gallons"),onMouseLeave:()=>c(null),radius:[6,6,6,6]}),(0,l.jsx)(v.e_,{yAxisId:"left",x:(()=>{let e=a.findIndex(e=>e.new_installations&&e.new_installations.length>0);if(e>0){var t;return null==(t=a[e-1])?void 0:t.period}})(),stroke:"#F97316",strokeWidth:2,label:{position:"top",content:e=>{let{viewBox:a}=e;if(!a||!("x"in a))return null;let{x:t,y:s}=a;return(0,l.jsx)("g",{id:"ion-reference-line",children:(0,l.jsx)("foreignObject",{x:t-21.5,y:s-30,width:43,height:16,children:(0,l.jsx)("div",{style:{display:"flex",alignItems:"center",justifyContent:"center"},children:(0,l.jsx)("img",{src:"/images/logo.png",alt:"ION",width:43,height:16})})})})}},ifOverflow:"visible",position:"end"})]})})})}var Q=t(37193),ee=t(35299);function ea(e){let{data:a,isLoading:t,currentPage:s=0,onPageChange:n,baseParams:i={},module:o,view:d="status",isPropertiesNeedingAttention:c=!1,pageSize:m,onPageSizeChange:u}=e,p=Math.ceil(a.count/(m||10)),[x,h]=(0,r.useState)({}),[g,y]=(0,r.useState)(0),[f,b]=(0,r.useState)({}),[v,N]=(0,r.useState)(""),[j,_]=(0,r.useState)(m||10),[w,k]=(0,r.useState)(null),C=e=>{N(e),y(0)},S=()=>{let{property_id:e,...a}=i,t={...a};return v&&(t.ordering=v),j&&(t.page_size=j),g&&(t.page=g+1),t};return(0,r.useEffect)(()=>{t&&(k(null),h({}),y(0),N(""))},[t]),(0,r.useEffect)(()=>{w&&e();async function e(){try{b(e=>({...e,[Number(w)]:!0}));let e=S(),a="portfolio-insights"===o?await Q.js.getDeviceHealthPortfolioInsightsPropertiesMeters(Number(w),e):"consumption"===d?await Q.lZ.getTopLeakVolumeMetersDay({...e,property_id:[null!=w?w:""]}):await Q.js.getDeviceHealthPortfolioDetailPropertiesMeters(Number(w),e);h(e=>({...e,[Number(w)]:a}))}catch(e){console.error("Error fetching meters data:",e),h(e=>({...e,[Number(w)]:{count:0,next:"",previous:"",results:[]}}))}finally{b(e=>({...e,[Number(w)]:!1}))}}},[g,w,v,o,j]),(0,l.jsxs)("div",{children:[t?(0,l.jsx)("div",{className:"flex items-center justify-center min-h-[474px]",children:(0,l.jsx)(ee.A,{className:"w-10 h-10 animate-spin text-brand-dark-cyan"})}):(null==a?void 0:a.results.length)===0?(0,l.jsx)("div",{className:"flex items-center justify-center min-h-24",children:(0,l.jsx)("p",{className:"text-sm text-brand-black font-medium",children:"No data"})}):(0,l.jsx)(lS,{type:"single",collapsible:!0,value:null!=w?w:void 0,onValueChange:e=>{k(e),y(0),N("")},children:null==a?void 0:a.results.map(e=>{var a;let t=x[e.property_id],s=f[e.property_id];return(0,l.jsxs)(lE,{value:e.property_id.toString(),className:"border border-brand-stroke rounded-lg mb-4",children:[(0,l.jsx)(lL,{className:"rounded-lg px-5 py-6 data-[state=open]:border-b data-[state=open]:border-brand-stroke hover:text-inherit ".concat(e.device_reporting_ratio>=95?"bg-sky-50":e.device_reporting_ratio>=85&&e.device_reporting_ratio<95?"bg-orange-50":"bg-red-50"),children:(0,l.jsxs)("div",{className:"flex items-center justify-between flex-wrap w-full mr-4 gap-1",children:[(0,l.jsx)("h6",{className:"text-xl font-bold text-brand-black",children:e.property_name}),(0,l.jsxs)("div",{className:"flex items-center gap-4",children:[(0,l.jsxs)("div",{className:"flex items-center gap-2 text-base text-brand-dark-gray font-normal",children:[(0,l.jsx)("span",{children:"State:"}),(0,l.jsx)("span",{className:"font-semibold text-brand-black",children:e.state})]}),(0,l.jsxs)("div",{className:"flex items-center gap-2 text-base text-brand-dark-gray font-normal",children:[(0,l.jsx)("span",{children:"Device Reporting:"}),(0,l.jsxs)("span",{className:"font-semibold text-brand-black",children:[(null!=(a=e.device_reporting_ratio)?a:0).toFixed(1),"%"]})]}),(0,l.jsxs)("div",{className:"flex items-center gap-2 text-base text-brand-dark-gray font-normal",children:[(0,l.jsx)("span",{children:"Devices:"}),(0,l.jsxs)("span",{className:"font-semibold text-brand-black",children:[e.online_devices," / ",e.total_devices]})]})]})]})}),(0,l.jsx)(lA,{className:"px-5 pt-4 pb-6",children:"consumption"===d?(0,l.jsx)(le,{data:(null==t?void 0:t.results)||[],isLoading:s,params:S(),onPageChange:y,currentPage:g,onSort:C,totalCount:(null==t?void 0:t.count)||0,pageSize:j,onPageSizeChange:_,menuPlacement:"top"}):(0,l.jsx)(la,{data:(null==t?void 0:t.results)||[],isLoading:s,totalCount:(null==t?void 0:t.count)||0,params:S(),onPageChange:y,currentPage:g,onSort:C,module:o,isPropertiesNeedingAttention:c,pageSize:j,onPageSizeChange:_})})]},e.property_id)})}),p<=1&&10===m?null:(0,l.jsx)(sj.x,{pageCount:p,pageIndex:s,onPageChange:n,isLoading:t,showPageSizeSelector:!0,pageSize:m,onPageSizeChange:u})]})}var et=t(73730),el=t(92927),es=t(27937),er=t(16954),en=t(18810),ei=t(27949),eo=t(35626),ed=t(60163),ec=t(26493),em=t(12108),eu=t(24033),ep=t(77888),ex=t(41860);let eh=(e,a,t,s)=>[{id:"leak_type",accessorKey:"leak_type",header:()=>"Leak Type",cell:e=>{var a,t;let{row:s}=e;return s.original.leak_type&&"undefined"!==s.original.leak_type?(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("div",{className:"h-8 w-8 border border-brand-stroke rounded-lg flex items-center justify-center shrink-0",children:(0,l.jsx)(aO,{leakType:null!=(a=s.original.leak_type)?a:""})}),(0,l.jsx)("span",{className:"text-sm font-medium capitalize text-nowrap",children:(0,ex.WU)(null!=(t=s.original.leak_type)?t:"")})]}):null},meta:{name:"Leak Type"}},{id:"date",accessorKey:"date",header:()=>{let e=t("date","Date");return(0,l.jsxs)("div",{className:(0,i.cn)(e.className,"flex justify-between"),onClick:e.onClick,children:[(0,l.jsx)("span",{className:"text-brand-dark-gray",children:e.label}),(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(em.A,{className:e.upIconClassName}),(0,l.jsx)(eu.A,{className:e.downIconClassName})]})]})},meta:{name:"Date"}},{id:"total_leak_gallons",accessorKey:"total_leak_gallons",header:()=>{let e=t("total_leak_gallons","Total Leak Gallons since the leak started");return(0,l.jsxs)("div",{className:e.className,onClick:e.onClick,children:[(0,l.jsx)("span",{className:"text-right w-44",children:e.label}),(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(em.A,{className:e.upIconClassName}),(0,l.jsx)(eu.A,{className:e.downIconClassName})]})]})},cell:e=>{var a;let{row:t}=e;return(0,l.jsx)("div",{className:"flex justify-end w-full",children:(0,l.jsx)("span",{className:"text-right pr-6",children:(null!=(a=t.original.total_leak_gallons)?a:0).toLocaleStr
1ing()})})},meta:{name:"Total Leak Gallons"}},{id:"leak_gallons",accessorKey:"leak_gallons",header:()=>{let e=t("leak_gallons","Leak Gallons over the selected period");return(0,l.jsxs)("div",{className:e.className,onClick:e.onClick,children:[(0,l.jsx)("span",{className:"text-right w-44",children:e.label}),(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(em.A,{className:e.upIconClassName}),(0,l.jsx)(eu.A,{className:e.downIconClassName})]})]})},cell:e=>{var a;let{row:t}=e;return(0,l.jsx)("div",{className:"flex justify-end w-full",children:(0,l.jsx)("span",{className:"text-right pr-6",children:(null!=(a=t.original.leak_gallons)?a:0).toLocaleString()})})},meta:{name:"Leak Gallons"}},{id:"gallons_consumed",accessorKey:"gallons_consumed",header:()=>{let e=t("gallons_consumed","Gallons");return(0,l.jsxs)("div",{className:e.className,onClick:e.onClick,children:[(0,l.jsx)("span",{className:"text-right w-auto lg:w-36",children:e.label}),(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(em.A,{className:e.upIconClassName}),(0,l.jsx)(eu.A,{className:e.downIconClassName})]})]})},cell:e=>{var a;let{row:t}=e;return(0,l.jsx)("div",{className:"flex justify-end w-full",children:(0,l.jsx)("span",{className:"text-right pr-6",children:(null!=(a=t.original.gallons_consumed)?a:0).toLocaleString()})})},meta:{name:"Gallons"}},{id:"twenty_two_gallons",accessorKey:"twenty_two_gallons",header:()=>(0,l.jsx)("div",{className:"w-full flex justify-end",children:(0,l.jsx)("span",{className:"text-right w-auto lg:w-36",children:"22h+ Gallons"})}),cell:e=>{var a;let{row:t}=e;return(0,l.jsx)("div",{className:"flex justify-end w-full",children:(0,l.jsx)("span",{className:"text-right",children:(null!=(a=t.original.twenty_two_gallons)?a:0).toLocaleString()})})},meta:{name:"22h+ Gallons"}},{id:"flow_time",accessorKey:"flow_time",header:()=>(0,l.jsx)("div",{className:"w-full flex justify-end",children:(0,l.jsx)("span",{className:"text-right w-auto lg:w-36",children:"Flow Time"})}),cell:e=>{let{row:a}=e;return(0,l.jsx)("div",{className:"flex justify-end w-full",children:(0,l.jsx)("span",{className:"text-right",children:a.original.flow_time})})},meta:{name:"Flow Time"}},{id:"event",accessorKey:"events",header:()=>{let e=t("events","Event");return(0,l.jsxs)("div",{className:e.className,onClick:e.onClick,children:[(0,l.jsx)("span",{className:"text-right w-auto lg:w-24",children:e.label}),(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(em.A,{className:e.upIconClassName}),(0,l.jsx)(eu.A,{className:e.downIconClassName})]})]})},cell:e=>{let{row:a}=e;return(0,l.jsx)("div",{className:"flex justify-end w-full",children:(0,l.jsx)("span",{className:"text-right",children:a.original.events.toLocaleString()})})},meta:{name:"Event"}},{id:"actions",accessorKey:"actions",size:200,enableResizing:!1,header:"",cell:e=>{let{row:a}=e;return(0,l.jsx)("div",{className:"flex justify-end w-full",children:(0,l.jsx)(e$.$,{variant:"secondary",size:"sm",className:"py-1 px-2 border-gray-400 w-28 h-7 text-brand-dark-gray hover:text-brand-dark-cyan hover:border-brand-dark-cyan",onClick:e=>{e.stopPropagation(),s(a.original.date)},children:(0,l.jsxs)("div",{className:"flex items-center gap-0.5",children:["Show hourly",(0,l.jsx)(es.A,{className:"w-4 h-4"})]})})})},meta:{fixedWidth:!0}}];function eg(e){let{data:a,isLoading:t,columnVisibility:s,columnOrder:r,onColumnVisibilityChange:n,pageCount:o,pageIndex:d,onPageChange:c,params:m,onSort:u,onShowHourly:p}=e,{getSortableHeaderProps:x}=(0,ep.M)({params:m,onSort:u,isLoading:t,data:a}),h=eh(t,a,x,p);return(0,l.jsx)(eU.b,{columns:h,data:a,columnVisibility:s,columnOrder:r,onColumnVisibilityChange:n,getRowClassName:e=>{let a=!e.original.leak_type||"undefined"===e.original.leak_type;return(0,i.cn)({"bg-indigo-50":!a})},isLoading:t,pageCount:o,pageIndex:d,onPageChange:c})}var ey=t(23327);let ef=(e,a,t)=>[{id:"date",accessorKey:"date",header:()=>{let e=t("hour","Day");return(0,l.jsxs)("div",{className:(0,i.cn)(e.className,"flex justify-between"),onClick:e.onClick,children:[(0,l.jsx)("span",{className:"text-brand-dark-gray",children:e.label}),(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(em.A,{className:e.upIconClassName}),(0,l.jsx)(eu.A,{className:e.downIconClassName})]})]})},meta:{name:"Date"}},{id:"hour",accessorKey:"hour",header:"Hour"},{id:"gallons",accessorKey:"gallons",header:()=>{let e=t("gallons","Gallons");return(0,l.jsxs)("div",{className:e.className,onClick:e.onClick,children:[(0,l.jsx)("span",{className:"text-right",children:e.label}),(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(em.A,{className:e.upIconClassName}),(0,l.jsx)(eu.A,{className:e.downIconClassName})]})]})},cell:e=>{var a;let{row:t}=e;return(0,l.jsx)("div",{className:"flex justify-end w-full",children:(0,l.jsxs)("div",{className:"flex justify-end pr-6 gap-3",children:[(0,l.jsx)("span",{className:"text-right",children:(null!=(a=t.original.gallons)?a:0).toLocaleStr
1ing()}),"Catch-Up"===t.original.leak_status&&(0,l.jsxs)(au.m_,{children:[(0,l.jsx)(au.k$,{className:"pl-1 w-fit",children:(0,l.jsx)(ey.A,{className:"w-4 h-4 text-brand-red"})}),(0,l.jsx)(au.ZI,{align:"start",side:"bottom",className:"max-w-52",children:"Caused by delayed reporting rather than leak activity."})]})]})})},meta:{name:"Gallons"}},{id:"flow_time",accessorKey:"flow_time",header:()=>(0,l.jsx)("div",{className:"w-full flex justify-end",children:(0,l.jsx)("span",{className:"text-right",children:"Flow Time"})}),cell:e=>{let{row:a}=e;return(0,l.jsx)("div",{className:"w-full flex justify-end",children:(0,l.jsx)("span",{className:"text-right",children:a.original.flow_time})})},meta:{name:"Flow Time"}},{id:"event",accessorKey:"events",header:()=>{let e=t("events","Event");return(0,l.jsxs)("div",{className:e.className,onClick:e.onClick,children:[(0,l.jsx)("span",{className:"text-right w-auto lg:w-36",children:e.label}),(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(em.A,{className:e.upIconClassName}),(0,l.jsx)(eu.A,{className:e.downIconClassName})]})]})},cell:e=>{let{row:a}=e;return(0,l.jsx)("div",{className:"w-full flex justify-end",children:(0,l.jsx)("span",{className:"text-right",children:a.original.events.toLocaleString()})})},meta:{name:"Event"}},{id:"leak_details",accessorKey:"leak_details",header:"Leak Details",cell:e=>{let{row:a}=e;return(0,l.jsx)("div",{children:a.original.leak_details||"-"})}}];function eb(e){let{data:a,isLoading:t,columnVisibility:s,columnOrder:r,onColumnVisibilityChange:n,pageCount:o,pageIndex:d,onPageChange:c,params:m,onSort:u}=e,{getSortableHeaderProps:p}=(0,ep.M)({params:m,onSort:u,isLoading:t,data:a}),x=ef(t,a,p);return(0,l.jsx)(eU.b,{columns:x,data:a,columnVisibility:s,columnOrder:r,onColumnVisibilityChange:n,getRowClassName:e=>{let a=""!==e.original.leak_details&&"No Leak"!==e.original.leak_details;return(0,i.cn)({"bg-indigo-50":a})},isLoading:t,pageCount:o,pageIndex:d,onPageChange:c})}function ev(e){let{activeTab:a,description:t,data:s,isLoading:r}=e;return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("div",{className:"flex flex-col gap-2 mb-4",children:[(0,l.jsx)("h3",{className:"text-xl font-bold text-brand-black",children:"Leak Gallons vs Gallons (Per ".concat("day"===a?"Day":"Hour",")")}),(0,l.jsx)("p",{className:"text-base text-brand-dark-gray",children:t})]}),(0,l.jsx)("div",{className:"flex flex-col gap-4",children:r?(0,l.jsx)("div",{className:"flex justify-center items-center h-full",children:(0,l.jsx)(ee.A,{className:"w-12 h-60 text-brand-dark-cyan animate-spin"})}):s.length>0?(0,l.jsx)(lB,{data:s,isHourly:"hour"===a}):(0,l.jsx)("div",{className:"flex justify-center items-center h-60",children:(0,l.jsx)("p",{className:"text-lg font-semibold text-brand-black",children:"No data available"})})})]})}function eN(e){let{mainInfo:a,searchParams:t,router:s}=e,[n,i]=(0,r.useState)("day"),[o,d]=(0,r.useState)(!1),[c,m]=(0,r.useState)(!1),[u,p]=(0,r.useState)(!1),[x,h]=(0,r.useState)([]),[g,y]=(0,r.useState)([]),[f,b]=(0,r.useState)([]),[v,N]=(0,r.useState)([]),[j,_]=(0,r.useState)(!1),[w,k]=(0,r.useState)(!1),[C,S]=(0,r.useState)(!1),[E,L]=(0,r.useState)(0),[A,D]=(0,r.useState)(0),[O,T]=(0,r.useState)(0),[I,P]=(0,r.useState)(0),[R,M]=(0,r.useState)(0),[G,z]=(0,r.useState)(0),[F,H]=(0,r.useState)(""),[V,U]=(0,r.useState)(""),[B,K]=(0,r.useState)(""),[W,Y]=(0,r.useState)(null),[$,Z]=(0,r.useState)(!1),[q,J]=(0,r.useState)(!1),[X,Q]=(0,r.useState)(null),[ea,em]=(0,ed.Vc)("dayVisibleColumns",["leak_type","date","total_leak_gallons","leak_gallons","gallons_consumed","twenty_two_gallons","flow_time","event"]),[eu,ep]=(0,ed.Vc)("dayColumnOrder",["leak_type","date","total_leak_gallons","leak_gallons","gallons_consumed","twenty_two_gallons","flow_time","event"]),[ey,eN]=(0,ed.Vc)("hourVisibleColumns",["date","hour","gallons","flow_time","event","leak_details"]),[ej,e_]=(0,ed.Vc)("hourColumnOrder",["date","hour","gallons","flow_time","event","leak_details"]),ew=Object.fromEntries(Array.from(t.entries()).filter(e=>{let[a]=e;return!["meter","dateRangeLabel","organization_id","property_id"].includes(a)})),ek=(0,r.useRef)(""),eC=(0,r.useRef)(""),eS=(0,r.useRef)(""),eE=(0,r.useRef)(""),eL=(0,r.useCallback)(()=>({...ew,property_id:(null==a?void 0:a.propertyId)?[null==a?void 0:a.propertyId.toString()]:void 0,organization_id:(null==a?void 0:a.organizationId)?[null==a?void 0:a.organizationId.toString()]:void 0}),[ew,null==a?void 0:a.propertyId,null==a?void 0:a.organizationId]),eA=(0,r.useCallback)(()=>({...eL(),granularity_type:"day",...F&&{ordering:F},...E&&{page:E+1}
1}),[eL,F,E]),eD=(0,r.useCallback)(()=>({...eL(),granularity_type:"hour",...V&&{ordering:V},...A&&{page:A+1}}),[eL,V,A]),eO=(0,r.useCallback)(()=>{let{days_ago:e,...a}=eL();return{...a,granularity_type:"hour",...B&&{ordering:B},...O&&{page:O+1},...X&&{start_date:(0,et.GP)(X,"yyyy-MM-dd")},...X&&{end_date:(0,et.GP)(X,"yyyy-MM-dd")}}},[eL,B,O,X]),eT=(0,ed.Q0)({columns:eh(j,g,(0,ed.MG)({params:eA(),onSort:e=>{H(e),L(0)},isLoading:j,data:g}).getSortableHeaderProps,()=>{}),initialVisibleColumns:ea,initialColumnOrder:eu}),eI=(0,ed.Q0)({columns:ef(w,f,(0,ed.MG)({params:eD(),onSort:e=>{U(e),D(0)},isLoading:w,data:f}).getSortableHeaderProps),initialVisibleColumns:ey,initialColumnOrder:ej}),eP="day"===n?eT:eI,eR=(0,r.useCallback)(e=>{J(!0),Q(e),T(0),K("")},[J,Q]),eM=(0,r.useCallback)(()=>{J(!1),Q(null),T(0),K("")},[J,Q]);return(0,r.useEffect)(()=>{async function e(){try{_(!0);let e=await ec.l.getLeakDetailsFlow(null==a?void 0:a.deviceId,{...eA(),page_size:10});y(e.results),P(e.count)}catch(e){console.error("Error fetching day leak details:",e)}finally{_(!1)}}if("day"===n&&(null==a?void 0:a.propertyId)){let a=JSON.stringify(eA());a!==ek.current&&(ek.current=a,e())}},[eA,n]),(0,r.useEffect)(()=>{async function e(){try{k(!0);let e=await ec.l.getLeakDetailsFlow(null==a?void 0:a.deviceId,{...eD(),page_size:10});b(e.results),M(e.count)}catch(e){console.error("Error fetching day leak details:",e)}finally{k(!1)}}if("hour"===n&&(null==a?void 0:a.propertyId)){let a=JSON.stringify(eD());a!==eC.current&&(eC.current=a,e())}},[eD,n]),(0,r.useEffect)(()=>{async function e(){try{p(!0);let e="day"===n?await ec.l.getDayLeakDetailsConsumption(null==a?void 0:a.deviceId,{...eL(),granularity_type:"day"}):await ec.l.getHourLeakDetailsConsumption(null==a?void 0:a.deviceId,{...eL(),granularity_type:"hour"});h(e)}catch(e){console.error("Error fetching top leak volume consumption",e),h([])}finally{p(!1)}}if(null==a?void 0:a.propertyId){let a=JSON.stringify({...eL(),activeTab:n});a!==eS.current&&(eS.current=a,e())}},[n,eL]),(0,r.useEffect)(()=>{async function e(){try{S(!0);let e=await ec.l.getLeakDetailsFlow(null==a?void 0:a.deviceId,{...eO(),page_size:10});N(e.results),z(e.count)}catch(e){console.error("Failed to fetch hourly drilldown data:",e)}finally{S(!1)}}if(q&&X){let a=JSON.stringify(eO());a!==eE.current&&(eE.current=a,e())}},[eO,q,X]),(0,r.useEffect)(()=>{c&&(null==a?void 0:a.propertyId)&&c&&!W&&e();async function e(){try{Z(!0);let e=await ec.l.getLeakDetailsPropertiesOverview(a.propertyId);Y(e)}catch(e){console.error("Error fetching leak details properties overview",e)}finally{Z(!1)}}},[null==a?void 0:a.propertyId,c,W]),(0,r.useEffect)(()=>{em(eT.selectedColumns),ep(eT.orderedColumns)},[eT.selectedColumns,eT.orderedColumns,em,ep]),(0,r.useEffect)(()=>{eN(eI.selectedColumns),e_(eI.orderedColumns)},[eI.selectedColumns,eI.orderedColumns,eN,e_]),(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("div",{className:"bg-white rounded-xl shadow-custom-tile py-4 px-5 mb-5",children:a.isLoading?(0,l.jsx)("div",{className:"flex justify-center items-center h-10",children:(0,l.jsx)(ee.A,{className:"w-8 h-8 text-brand-dark-cyan animate-spin"})}):(0,l.jsxs)("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-6",children:[(0,l.jsxs)("div",{className:"flex items-center flex-wrap gap-4",children:[(0,ex.Cc)(a.leakType)&&(0,l.jsxs)("div",{className:"flex items-center gap-4",children:[(0,l.jsx)(aO,{leakType:a.leakType}),(0,l.jsx)("p",{className:"text-sm font-medium text-brand-black capitalize",children:(0,ex.PS)(a.leakType)})]}),(0,l.jsxs)("div",{className:"w-full md:w-auto flex shrink-0 items-center gap-3 pr-4 md:border-r border-brand-stroke",children:[(0,l.jsx)(el.A,{className:"w-6 h-6 text-brand-dark-gray shrink-0"}),(0,l.jsx)("p",{className:"text-base font-semibold text-brand-black truncate",children:a.propertyName}),(0,l.jsx)(e$.$,{variant:"secondary",size:"sm",className:"py-1 px-2 border-gray-400 h-7 text-brand-dark-gray hover:text-brand-dark-cyan hover:border-brand-dark-cyan",onClick:()=>{null==s||s.push("/history?building_id=".concat(a.buildingId,"&unit_id=").concat(a.unitId))},children:(0,l.jsxs)("div",{className:"flex items-center gap-0.5",children:["Unit details",(0,l.jsx)(es.A,{className:"w-4 h-4"})]})})]}),(0,l.jsxs)("div",{className:"w-full md:w-auto flex shrink-0 items-center gap-2",children:[(0,l.jsx)(er.A,{className:"w-5 h-5 text-brand-dark-gray shrink-0"}),(0,l.jsxs)("p",{className:"text-base font-semibold text-brand-black",children:[a.bedroomCount," Bd - ",a.bathroomCount," Ba"]})]}),(0,l.jsxs)("div",{className:"w-full md:w-auto flex shrink-0 items-center gap-2",children:[(0,l.jsx)(en.A,{className:"w-5 h-5 text-brand-dark-gray shrink-0"}),(0,l.jsx)("p",{className:"text-base font-semibold text-brand-black",children:a.deviceId})]}),(0,l.jsxs)("div",{className:"w-full md:w-auto flex shrink-0 items-center gap-2",children:[(0,l.jsx)(ei.A,{className:"w-5 h-5 text-brand-dark-gray shrink-0"}),(0,l.jsx)("p",{className:"text-base font-semibold text-brand-black",children:a.attachedTo})]})]}),(0,l.jsx)(e$.$,{variant:"tertiary",className:"font-semibold text-sm 2xl:text-base px-2 2xl:px-4",onClick:()=>m(!0),loading:$,children:"View Full Property Information"})]})}),(0,l.jsxs)(tW,{defaultValue:"day",onValueChange:e=>{i(e)},children:[(0,l.jsxs)(t$,{className:"mb-5",children:[(0,l.jsx)(tq,{value:"day",children:"Day"}),(0,l.jsx)(tq,{value:"hour",children:"Hour"})]}),(0,l.jsxs)("div",{className:"bg-white rounded-xl shadow-custom-tile py-6 px-5 mb-5",children:[(0,l.jsx)(tJ,{value:"day",children:(0,l.jsx)(ev,{activeTab:n,description:"Visualize the difference between daily water consumption and leak volume over time.",data:x,isLoading:u})}),(0,l.jsx)(tJ,{value:"hour",children:(0,l.jsx)(ev,{activeTab:n,description:"Explore hourly variations in water consumption vs. leak volume to identify trends.",data:x,isLoading:u})})]}),(0,l.jsxs)("div",{className:"bg-white rounded-xl shadow-custom-tile py-6 px-5 mb-5",children:[(0,l.jsxs)("div",{className:"flex flex-col md:flex-row md:justify-between gap-6 mb-5",children:[(0,l.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,l.jsx)("h3",{className:"text-xl font-bold text-brand-black",children:"Leak Updates"}),(0,l.jsx)("p",{className:"text-base text-brand-dark-gray",children:"Switch between Daily or Hourly views to track the leak's details since it began, based on the previously selected date period."})]}),(0,l.jsx)("div",{className:"flex gap-3",children:!q&&(0,l.jsx)(eq,{title:"Toggle Columns",options:eP.columnOptions,selectedValues:eP.selectedColumns,initialValues:"day"===n?["leak_type","date","total_leak_gallons","leak_gallons","gallons_consumed","twenty_two_gallons","flow_time","event"]:["date","hour","gallons","flow_time","event","leak_details"],displayMode:"count",onSelectedChange:eP.setSelectedColumns,onOrderChange:eP.setOrderedColumns,draggable:!0,isOpen:o,onOpenChange:d,className:"right-0",isToggleColumns:!0})})]}),(0,l.jsx)(tJ,{value:"day",children:q?(0,l.jsxs)("div",{className:"space-y-2",children:[(0,l.jsx)("div",{className:"flex items-center gap-4",children:(0,l.jsxs)(e$.$,{variant:"tertiary",size:"sm",onClick:eM,className:"flex items-center gap-3 text-brand-deep-sea-blue text-base font-semibold hover:text-brand-black",children:[(0,l.jsx)(eo.A,{className:"w-6 h-6 text-brand-dark-gray"}),"Go Back"]})}),(0,l.jsx)(eb,{data:v,isLoading:C,columnVisibility:eI.columnVisibility,columnOrder:eI.orderedColumns,onColumnVisibilityChange:()=>{},pageCount:Math.ceil(G/10),pageIndex:O,onPageChange:T,params:eO(),onSort:e=>{K(e),T(0)}})]}):(0,l.jsx)(eg,{data:g,isLoading:j,columnVisibility:eT.columnVisibility,columnOrder:eT.orderedColumns,onColumnVisibilityChange:e=>{let a="function"==typeof e?e({}):e;eT.setSelectedColumns(Object.entries(a).filter(e=>{let[,a]=e;return a}).map(e=>{let[a]=e;return a}))},pageCount:Math.ceil(I/10),pageIndex:E,onPageChange:L,params:eA(),onSort:e=>{H(e),L(0)},onShowHourly:eR})}),(0,l.jsx)(tJ,{value:"hour",children:(0,l.jsx)(eb,{data:f,isLoading:w,columnVisibility:eI.columnVisibility,columnOrder:eI.orderedColumns,onColumnVisibilityChange:e=>{let a="function"==typeof e?e({}):e;eI.setSelectedColumns(Object.entries(a).filter(e=>{let[,a]=e;return a}).map(e=>{let[a]=e;return a}))},pageCount:Math.ceil(R/10),pageIndex:A,onPageChange:D,params:eD(),onSort:e=>{U(e),D(0)}})})]})]}),(0,l.jsx)(eX,{open:c,onOpenChange:m,propertyInfo:W,propertyId:a.propertyId,searchParams:t,router:s})]})}let ej=e=>{let{open:a,onOpenChange:t,isLoading:s,onDeleteConfirm:r,onCancel:n}=e;return(0,l.jsx)(lO,{open:a,onOpenChange:t,children:(0,l.jsxs)(lP,{className:"max-w-2xl px-10",children:[(0,l.jsxs)(lR,{children:[(0,l.jsx)(sN,{variant:"error",className:"mb-4"}),(0,l.jsx)(lG,{className:"text-3xl font-semibold text-base-dark text-center mb-2",children:"Are you sure?"}),(0,l.jsx)(lz,{className:"text-base text-base-dark text-center",children:"Are you sure you want to delete this Custom Cost per Gallon?"})]}),(0,l.jsxs)(lM,{className:"flex items-center gap-4",children:[(0,l.jsx)(lH,{className:"w-full border-gray-400 text-gray-500",disabled:s,onClick:n,children:"Cancel"}),(0,l.jsx)(lF,{onClick:r,className:"w-full bg-brand-red text-white hover:bg-red-700 active:bg-red-900",disabled:s,children:"Delete"})]})]})})},e_=e=>{let{open:a,onOpenChange:t,isLoading:s,onDeleteConfirm:r}=e;return(0,l.jsx)(lO,{open:a,onOpenChange:t,children:(0,l.jsxs)(lP,{className:"max-w-2xl px-10",children:[(0,l.jsxs)(lR,{children:[(0,l.jsx)(sN,{variant:"error",className:"mb-4"}),(0,l.jsxs)(lG,{className:"text-[32px]/[48px] font-semibold text-base-dark text-center mb-2",children:["Are you sure you want",(0,l.jsx)("br",{}),"to delete this user?"]}),(0,l.jsx)(lz,{className:"text-base text-base-dark text-center mb-8",children:"This action cannot be undone."})]}),(0,l.jsxs)(lM,{className:"flex items-center gap-4",children:[(0,l.jsx)(lH,{className:"w-full",disabled:s,children:"Cancel"}),(0,l.jsx)(lF,{onClick:r,className:"w-full",disabled:s,children:"Delete"})]})]})})};var ew=t(22544),ek=t(65229),eC=t(29141);let eS=e=>{let a={healthyMin:"95",healthyMax:"100",warningMin:"85",warningMax:"94",criticalMin:"0",criticalMax:"84"};
1return e.forEach(e=>{e.id&&"string"==typeof e.id&&"healthy"===e.id&&Array.isArray(e.value)&&2===e.value.length?(a.healthyMin=e.value[0].toString(),a.healthyMax=e.value[1].toString()):e.id&&"string"==typeof e.id&&"warning"===e.id&&Array.isArray(e.value)&&2===e.value.length?(a.warningMin=e.value[0].toString(),a.warningMax=e.value[1].toString()):e.id&&"string"==typeof e.id&&"critical"===e.id&&Array.isArray(e.value)&&2===e.value.length&&(a.criticalMin=e.value[0].toString(),a.criticalMax=e.value[1].toString())}),a},eE=e=>{var a;let{open:t,onOpenChange:n,deviceHealthBoundaries:i}=e,{user:o,saveUserPreferences:d,isSavingPreferencesLoading:c}=(0,eC.J)(),{register:m,handleSubmit:u,reset:p,watch:x,formState:{errors:h,isSubmitting:g,isDirty:y,isValid:f}}=(0,ew.mN)({mode:"onChange",defaultValues:eS(i)}),b=x(),v=async e=>{try{if(!o)return;let a={...o.preferences,device_health_thresholds:{healthy:[parseInt(e.healthyMin),parseInt(e.healthyMax)],warning:[parseInt(e.warningMin),parseInt(e.warningMax)],critical:[parseInt(e.criticalMin),parseInt(e.criticalMax)]}};await d(a),n(!1)}catch(e){console.error("Error saving thresholds:",e)}},N=(0,r.useMemo)(()=>{let e=eS(i);return b.healthyMin===e.healthyMin&&b.healthyMax===e.healthyMax&&b.warningMin===e.warningMin&&b.warningMax===e.warningMax&&b.criticalMin===e.criticalMin&&b.criticalMax===e.criticalMax},[b,i]),j=async()=>{let e=eS(i);p(e),await v(e),n(!1)};return(0,r.useEffect)(()=>{var e,a,l,s,r,n,d;if(t&&(null==o||null==(e=o.preferences)?void 0:e.device_health_thresholds)){let e=o.preferences.device_health_thresholds,t=eS(i);p({healthyMin:(null==(a=e.healthy[0])?void 0:a.toString())||t.healthyMin,healthyMax:(null==(l=e.healthy[1])?void 0:l.toString())||t.healthyMax,warningMin:(null==(s=e.warning[0])?void 0:s.toString())||t.warningMin,warningMax:(null==(r=e.warning[1])?void 0:r.toString())||t.warningMax,criticalMin:(null==(n=e.critical[0])?void 0:n.toString())||t.criticalMin,criticalMax:(null==(d=e.critical[1])?void 0:d.toString())||t.criticalMax})}else t&&p(eS(i))},[t,null==o||null==(a=o.preferences)?void 0:a.device_health_thresholds,p,i]),(0,l.jsx)(s.lG,{open:t,onOpenChange:n,children:(0,l.jsxs)(s.Cf,{className:"px-10 py-6 max-w-[40vw] max-h-[80vh]",children:[(0,l.jsxs)(s.c7,{children:[(0,l.jsxs)("div",{className:"flex items-center justify-between border-b border-gray-200 pb-3 mb-3",children:[(0,l.jsx)(s.L3,{className:"text-xl font-bold text-brand-black",children:"Device Health Thresholds"}),(0,l.jsx)(s.HM,{asChild:!0,children:(0,l.jsx)(ek.A,{className:"w-6 h-6 text-brand-dark-gray cursor-pointer"})})]}),(0,l.jsx)(s.rr,{className:"text-base text-brand-black",children:"Customize the reporting percentage thresholds for device health status."})]}),(0,l.jsxs)("div",{className:"my-4 relative",children:[c&&(0,l.jsx)("div",{className:"absolute z-10 top-0 bottom-0 left-0 right-0 flex items-center justify-center bg-white/50",children:(0,l.jsx)(ee.A,{className:"w-10 h-10 text-brand-dark-cyan animate-spin"})}),(0,l.jsx)(l3,{className:"text-sm text-green-700 font-medium",children:"Healthy Range (%)"}),(0,l.jsxs)("div",{className:"grid grid-cols-2 gap-4 mb-4 mt-2",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)(l2,{id:"healthyMin",placeholder:"Min",...m("healthyMin",{required:"Minimum value is required",pattern:{value:/^[0-9]+$/,message:"Please enter a valid number"},min:{value:0,message:"Value must be at least 0"},max:{value:100,message:"Value must be at most 100"},validate:{lessThanMax:e=>{let a=parseInt(b.healthyMax),t=parseInt(e);return!(isNaN(t)||isNaN(a))&&t<a||"Healthy min must be less than healthy max"},greaterThanWarningMax:e=>{let a=parseInt(b.warningMax),t=parseInt(e);return!(isNaN(t)||isNaN(a))&&t>a||"Healthy min must be greater than warning max"}}})}),h.healthyMin&&(0,l.jsx)("span",{className:"text-red-500 text-xs mt-1",children:h.healthyMin.message})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)(l2,{id:"healthyMax",placeholder:"Max",...m("healthyMax",{required:"Maximum value is required",pattern:{value:/^[0-9]+$/,message:"Please enter a valid number"},min:{value:0,message:"Value must be at least 0"},max:{value:100,message:"Value must be at most 100"},validate:{greaterThanMin:e=>{let a=parseInt(b.healthyMin),t=parseInt(e);return!(isNaN(a)||isNaN(t))&&t>a||"Healthy max must be greater than healthy min"}}})}),h.healthyMax&&(0,l.jsx)("span",{className:"text-red-500 text-xs mt-1",children:h.healthyMax.message})]})]}),(0,l.jsx)(l3,{className:"text-sm text-[#BD7E17] font-medium",children:"Warning Range (%)"}),(0,l.jsxs)("div",{className:"grid grid-cols-2 gap-4 mb-4 mt-2",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)(l2,{id:"warningMin",placeholder:"Min",...m("warningMin",{required:"Minimum value is required",pattern:{value:/^[0-9]+$/,message:"Please enter a valid number"},min:{value:0,message:"Value must be at least 0"},max:{value:100,message:"Value must be at most 100"},validate:{lessThanMax:e=>{let a=parseInt(b.warningMax),t=parseInt(e);return!(isNaN(t)||isNaN(a))&&t<a||"Warning min must be less than warning max"},greaterThanCriticalMax:e=>{let a=parseInt(b.criticalMax),t=parseInt(e);return!(isNaN(t)||isNaN(a))&&t>a||"Warning min must be greater than critical max"}}})}),h.warningMin&&(0,l.jsx)("span",{className:"text-red-500 text-xs mt-1",children:h.warningMin.message})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)(l2,{id:"warningMax",placeholder:"Max",...m("warningMax",{required:"Maximum value is required",pattern:{value:/^[0-9]+$/,message:"Please enter a valid number"},min:{value:0,message:"Value must be at least 0"},max:{value:100,message:"Value must be at most 100"},validate:{greaterThanMin:e=>{let a=parseInt(b.warningMin),t=parseInt(e);return!(isNaN(a)||isNaN(t))&&t>a||"Warning max must be greater than warning min"},lessThanHealthyMin:e=>{let a=parseInt(b.healthyMin),t=parseInt(e);return!(isNaN(t)||isNaN(a))&&t<a||"Warning max must be less than healthy min"}}})}),h.warningMax&&(0,l.jsx)("span",{className:"text-red-500 text-xs mt-1",children:h.warningMax.message})]})]}),(0,l.jsx)(l3,{className:"text-sm text-brand-red font-medium",children:"Critical Range (%)"}),(0,l.jsxs)("div",{className:"grid grid-cols-2 gap-4 mt-2",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)(l2,{id:"criticalMin",placeholder:"Min",...m("criticalMin",{required:"Minimum value is required",pattern:{value:/^[0-9]+$/,message:"Please enter a valid number"},min:{value:0,message:"Value must be at least 0"},max:{value:100,message:"Value must be at most 100"}})}),h.criticalMin&&(0,l.jsx)("span",{className:"text-red-500 text-xs mt-1",children:h.criticalMin.message})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)(l2,{id:"criticalMax",placeholder:"Max",...m("criticalMax",{required:"Maximum value is required",pattern:{value:/^[0-9]+$/,message:"Please enter a valid number"},min:{value:0,message:"Value must be at least 0"},max:{value:100,message:"Value must be at most 100"},validate:{greaterThanMin:e=>{let a=parseInt(b.criticalMin),t=parseInt(e);return!(isNaN(a)||isNaN(t))&&t>a||"Critical max must be greater than critical min"},lessThanWarningMin:e=>{let a=parseInt(b.warningMin),t=parseInt(e);return!(isNaN(t)||isNaN(a))&&t<a||"Critical max must be less than warning min"}}})}),h.criticalMax&&(0,l.jsx)("span",{className:"text-red-500 text-xs mt-1",children:h.criticalMax.message})]})]})]}),(0,l.jsx)("form",{onSubmit:u(v),children:(0,l.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,l.jsx)(e$.$,{type:"button",variant:"secondary",onClick:j,disabled:g||c||N,children:"Reset to default"}),(0,l.jsx)(e$.$,{type:"submit",variant:"primary",disabled:g||c||!y||!f,loading:c,children:"Save Changes"})]})})]})})};var eL=t(16485),eA=t(7431),eD=t(91463);let eO=e=>{let{open:a,onOpenChange:t,onSuccess:n,organizationId:i,propertyId:o,editData:d,onReset:c}=e,{toast:m}=(0,eD.dj)(),[u,p]=(0,r.useState)({}),{control:x,handleSubmit:h,formState:{isSubmitting:g,isValid:y},reset:f,setValue:b,watch:v}=(0,ew.mN)({defaultValues:{selectedUnits:[],selectedOption:void 0,costPerGallon:"",startDate:void 0,endDate:void 0},mode:"onChange"});(0,r.useEffect)(()=>
1{if(a&&d){let e=d.unit_list.map(e=>e.unit_id),a={type:d.all_units?"property":"unit",propertyId:d.property_id,unitId:e,label:d.all_units?d.property_name:"".concat(d.property_name," | ").concat(d.unit_list.map(e=>e.unit_name).join(", "))};b("selectedOption",a),b("selectedUnits",e),b("costPerGallon",d.cost),b("startDate",new Date(d.start_date)),b("endDate",new Date(d.end_date)),f({selectedOption:a,selectedUnits:e,costPerGallon:d.cost,startDate:new Date(d.start_date),endDate:new Date(d.end_date)})}},[a,d,b,f]),(0,r.useEffect)(()=>{a||(f(),p({}),null==c||c())},[a,f]);let N=(e,a)=>{p(t=>({...t,[e]:a}))},j=e=>{p(a=>({...a,[e]:!1}))},_=async e=>{try{let a={unit_ids:e.selectedUnits,cost:e.costPerGallon,start_date:(0,et.GP)(e.startDate,"yyyy-MM-dd"),end_date:e.endDate?(0,et.GP)(e.endDate,"yyyy-MM-dd"):void 0};await eA.Q.setPortfolioInsightsFinancesCosts({costs:[a]}),m({title:"Success",description:"Custom cost has been updated successfully.",className:"bg-green-200 border-green-200 text-brand-black"}),null==n||n(),t(!1),f()}catch(e){console.error("Failed to update custom cost:",e),m({title:"Error",description:"Failed to update custom cost. Please try again.",className:"bg-red-200 border-red-200 text-brand-black"})}};return(0,l.jsx)(s.lG,{open:a,onOpenChange:t,children:(0,l.jsxs)(s.Cf,{className:"max-w-2xl max-h-[90vh] overflow-y-auto py-6 px-10 gap-0",children:[(0,l.jsxs)(s.c7,{className:"relative pb-3 border-b border-gray-200 mb-3",children:[(0,l.jsx)(s.L3,{className:"text-xl font-bold text-left",children:"Edit Custom Cost per Gallon"}),(0,l.jsx)(s.HM,{className:"absolute right-0 top-[-4px] hover:bg-gray-100",children:(0,l.jsx)(ek.A,{className:"w-6 h-6"})})]}),(0,l.jsx)(s.rr,{className:"text-base text-gray-600 mb-8",children:"Choose how you want to apply the cost per gallon —across all properties or to a specific one."}),(0,l.jsxs)("form",{onSubmit:h(_),className:"space-y-6",children:[(0,l.jsx)("div",{className:"space-y-4 p-4 border border-gray-200 rounded-lg",children:(0,l.jsxs)("div",{className:"space-y-4",children:[(0,l.jsxs)("div",{children:[(0,l.jsxs)(l3,{className:"text-sm font-medium",children:["Property ",(0,l.jsx)("span",{className:"text-red-500",children:"(*)"})]}),(0,l.jsx)(ew.xI,{name:"selectedUnits",control:x,render:()=>(0,l.jsx)(ew.xI,{name:"selectedOption",control:x,rules:{required:"Property is required"},render:e=>{let{field:{value:a,onChange:t},fieldState:{error:s}}=e;return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(s_,{value:a,onChange:(e,a)=>{t(e),b("selectedUnits",a)},placeholder:"Select property",error:!!s,className:"mt-2",organizationId:i,propertyId:o}),s&&(0,l.jsx)("p",{className:"text-red-500 text-xs mt-1",children:s.message})]})}})})]}),(0,l.jsxs)("div",{children:[(0,l.jsxs)(l3,{className:"text-sm font-medium",children:["Average Cost per Gallon"," ",(0,l.jsx)("span",{className:"text-red-500",children:"(*)"})]}),(0,l.jsx)(ew.xI,{name:"costPerGallon",control:x,rules:{required:"Average Cost per Gallon is required",validate:e=>{if(""===e||null==e)return"Please enter a valid number";let a=e.toString();if(a.match(/^\d*\.?\d*$/)&&""!==a){let e=a.split(".")[1];if(e&&e.length>3)return"Maximum 3 decimal places allowed";let t=parseFloat(a);return!!isNaN(t)||!(t<=0)||"Cost must be greater than 0"}return"Please enter a valid number"}},render:e=>{let{field:{value:a,onChange:t},fieldState:{error:s}}=e;return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(l2,{type:"text",placeholder:"0.015",value:a||"",onChange:e=>{let a=e.target.value;(""===a||a.match(/^\d*\.?\d{0,3}$/))&&t(a)},className:"mt-2 ".concat(s?"border-red-500 focus:border-red-500 focus:ring-red-500":"")}),s&&(0,l.jsx)("p",{className:"text-red-500 text-xs mt-1",children:s.message})]})}})]}),(0,l.jsxs)("div",{children:[(0,l.jsxs)(l3,{className:"text-sm font-medium",children:["Start Date for Cost ",(0,l.jsx)("span",{className:"text-red-500",children:"(*)"})]}),(0,l.jsx)(ew.xI,{name:"startDate",control:x,rules:{required:"Start Date for Cost is required",validate:e=>{if(!e)return!0;let a=v().endDate;return!a||!(e>a)||"Start date cannot be later than end date"}},render:e=>{let{field:{value:a,onChange:t},fieldState:{error:s}}=e,r="start";return(0,l.jsxs)("div",{className:"mt-2",children:[(0,l.jsxs)(lJ,{open:u[r]||!1,onOpenChange:e=>N(r,e),children:[(0,l.jsx)(lX,{asChild:!0,children:(0,l.jsxs)("button",{type:"button",className:"flex h-9 rounded-md border bg-transparent px-3 py-1 text-base shadow-sm transition-colors w-full justify-start items-center text-left font-normal focus:outline-none focus:ring-1 focus:ring-brand-dark-cyan ".concat(s?"border-red-500":"border-brand-stroke"),children:[(0,l.jsx)(eL.A,{className:"mr-2 h-4 w-4 text-brand-dark-gray"}),a?(0,l.jsx)("span",{className:"text-brand-black",children:(0,et.GP)(a,"MM/dd/yyyy")}):(0,l.jsx)("span",{className:"text-brand-dark-gray",children:"Select date"})]})}),(0,l.jsx)(lQ,{className:"w-auto p-0 z-[999] pointer-events-auto border-none",align:"start",children:(0,l.jsx)(lY,{mode:"single",selected:a,onSelect:e=>{t(e),j(r)}})})]}),s&&(0,l.jsx)("p",{className:"text-red-500 text-xs mt-1",children:s.message})]})}})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)(l3,{className:"text-sm font-medium",children:"End Date for Cost"}),(0,l.jsx)(ew.xI,{name:"endDate",control:x,rules:{validate:e=>{if(!e)return!0;let a=v().startDate;return!a||!(e<a)||"End date cannot be earlier than start date"}},render:e=>{let{field:{value:a,onChange:t},fieldState:{error:s}}=e;return(0,l.jsxs)("div",{className:"mt-2",children:[(0,l.jsxs)(lJ,{open:u.end||!1,onOpenChange:e=>N("end",e),children:[(0,l.jsx)(lX,{asChild:!0,children:(0,l.jsxs)("button",{type:"button",className:"flex h-9 rounded-md border bg-transparent px-3 py-1 text-base shadow-sm transition-colors w-full justify-start items-center text-left font-normal focus:outline-none focus:ring-1 focus:ring-brand-dark-cyan ".concat(s?"border-red-500":"border-brand-stroke"),children:[(0,l.jsx)(eL.A,{className:"mr-2 h-4 w-4 text-brand-dark-gray"}),a?(0,l.jsx)("span",{className:"text-brand-black",children:(0,et.GP)(a,"MM/dd/yyyy")}):(0,l.jsx)("span",{className:"text-brand-dark-gray",children:"Select date"})]})}),(0,l.jsx)(lQ,{className:"w-auto p-0 z-[999] pointer-events-auto border-none",align:"start",children:(0,l.jsx)(lY,{mode:"single",selected:a,onSelect:e=>{t(e),j("end")}})})]}),s&&(0,l.jsx)("p",{className:"text-red-500 text-xs mt-1",children:s.message})]})}})]})]})}),(0,l.jsx)("div",{children:(0,l.jsx)(e$.$,{type:"submit",disabled:!y||g,className:"w-full bg-brand-dark-cyan hover:bg-brand-dark-cyan/90 text-white py-3",children:g?"Updating...":"Update Cost"})})]})]})})},eT=e=>{let{open:a,onOpenChange:t,isLoading:r,data:n,granularity:i,setGranularity:o,height:d=400}=e;return(0,l.jsx)(s.lG,{open:a,onOpenChange:t,children:(0,l.jsxs)(s.Cf,{className:"px-10 py-12 max-w-[90vw] max-h-[90vh]",children:[(0,l.jsxs)(s.c7,{className:"mb-6",children:[(0,l.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,l.jsx)(s.L3,{className:"text-3xl font-bold text-cyan-900",children:"Leak-Related Costs"}),(0,l.jsxs)("div",{className:"flex items-center gap-5",children:[(0,l.jsx)(tW,{defaultValue:i,value:i,onValueChange:e=>o(e),children:(0,l.jsxs)(t$,{children:[(0,l.jsx)(tq,{value:"day",className:"w-auto",children:"Day"}),(0,l.jsx)(tq,{value:"week",className:"w-auto",children:"Week"}),(0,l.jsx)(tq,{value:"month",className:"w-auto",children:"Month"})]})}),(0,l.jsx)(s.HM,{asChild:!0,children:(0,l.jsx)(ek.A,{className:"w-8 h-8 text-brand-dark-gray cursor-pointer"})})]})]}),(0,l.jsx)(s.rr,{className:"text-base text-brand-dark-gray",children:"Analyze leak-related costs in daily, weekly, or monthly views based on the selected date range."})]}),(0,l.jsx)("div",{className:"flex justify-center items-center",children:r?(0,l.jsx)("div",{className:"h-[".concat(d,"px] flex justify-center items-center"),children:(0,l.jsx)(ee.A,{className:"h-12 w-12 animate-spin text-brand-dark-cyan"})}):(0,l.jsx)(T,{data:n,height:d,granularity:i})})]})})},eI=e=>{let{open:a,onOpenChange:t,isLoading:r,data:n,granularity:i,setGranularity:o,height:d=400}=e;return(0,l.jsx)(s.lG,{open:a,onOpenChange:t,children:(0,l.jsxs)(s.Cf,{className:"px-10 py-12 max-w-[90vw] max-h-[90vh]",children:[(0,l.jsxs)(s.c7,{className:"mb-6",children:[(0,l.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,l.jsx)(s.L3,{className:"text-3xl font-bold text-cyan-900",children:"Gallons & Leaks Dynamics"}),(0,l.jsxs)("div",{className:"flex items-center gap-5",children:[(0,l.jsx)(tW,{defaultValue:i,value:i,onValueChange:e=>o(e),children:(0,l.jsxs)(t$,{children:[(0,l.jsx)(tq,{value:"day",className:"w-auto",children:"Day"}),(0,l.jsx)(tq,{value:"week",className:"w-auto",children:"Week"}),(0,l.jsx)(tq,{value:"month",className:"w-auto",children:"Month"})]})}),(0,l.jsx)(s.HM,{asChild:!0,children:(0,l.jsx)(ek.A,{className:"w-8 h-8 text-brand-dark-gray cursor-pointer"})})]})]}),(0,l.jsx)(s.rr,{className:"text-base text-brand-dark-gray",children:"Analyze leak gallons and volume % trends in daily, weekly, or monthly views based on the selected date range."})]}),(0,l.jsx)("div",{className:"flex justify-center items-center",children:r?(0,l.jsx)("div",{className:"h-[".concat(d,"px] flex justify-center items-center"),children:(0,l.jsx)(ee.A,{className:"h-12 w-12 animate-spin text-brand-dark-cyan"})}):(0,l.jsx)(V,{data:n,height:d,granularity:i})})]})})};
1var eP=t(40170);let eR=e=>{let{open:a,onOpenChange:t,isLoading:r,data:n,granularity:i,setGranularity:o,height:d=400,activeTimePeriod:c,comparisonDisplay:u}=e;return(0,l.jsx)(s.lG,{open:a,onOpenChange:t,children:(0,l.jsxs)(s.Cf,{className:"px-10 py-12 max-w-[90vw] max-h-[90vh]",children:[(0,l.jsxs)(s.c7,{className:"mb-6",children:[(0,l.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,l.jsx)(s.L3,{className:"text-3xl font-bold text-cyan-900",children:"Leak-Related Costs"}),(0,l.jsxs)("div",{className:"flex items-center gap-5",children:["last-30-days"===c&&(0,l.jsx)(tW,{defaultValue:i,value:i,onValueChange:e=>o(e),children:(0,l.jsxs)(t$,{children:[(0,l.jsx)(tq,{value:"day",className:"w-auto",children:"Day"}),(0,l.jsx)(tq,{value:"week",className:"w-auto",children:"Week"}),(0,l.jsx)(tq,{value:"month",className:"w-auto",children:"Month"})]})}),(0,l.jsx)(s.HM,{asChild:!0,children:(0,l.jsx)(ek.A,{className:"w-8 h-8 text-brand-dark-gray cursor-pointer"})})]})]}),(0,l.jsx)(s.rr,{className:"text-base text-brand-dark-gray",children:"Analyze leak-related costs in daily, weekly, or monthly views based on the selected date range."})]}),(0,l.jsx)("div",{className:"flex justify-center items-center",children:r?(0,l.jsx)("div",{className:"h-[".concat(d,"px] flex justify-center items-center"),children:(0,l.jsx)(ee.A,{className:"h-12 w-12 animate-spin text-brand-dark-cyan"})}):(0,l.jsx)(m.y,{data:n,height:d,granularity:i,activeTimePeriod:(0,eP.qt)(c,void 0),comparisonDisplay:u})})]})})};var eM=t(16854),eG=t(21873),ez=t(19408),eF=t(88777),eH=t(69141),eV=t(23664),eU=t(32897),eB=t(15056),eK=t(87270),eW=t(49476),eY=t(5917),e$=t(3998),eZ=t(31113);function eq(e){var a;let{title:t,options:s,selectedValues:n,onSelectedChange:o,onOrderChange:d,isOpen:c,onOpenChange:m,className:u,draggable:p,onApply:x,initialValues:h=[],displayMode:g="count",isDisabled:y=!1,isToggleColumns:f=!1,onReset:b}=e,[v,N]=r.useState(s),[j,_]=r.useState(n),w=r.useRef(null),k=e=>{_(j.includes(e)?j.filter(a=>a!==e):[...j,e])};return r.useEffect(()=>{c&&(N(s),_(n))},[c,s,n]),r.useEffect(()=>{if("undefined"==typeof document)return;let e=e=>{c&&w.current&&!w.current.contains(e.target)&&m(!1)};return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[c,m]),(0,l.jsxs)("div",{ref:w,className:(0,i.cn)("relative",y&&"pointer-events-none opacity-50"),children:[(0,l.jsxs)("div",{onClick:e=>{e.preventDefault(),m(!c)},className:(0,i.cn)("h-9 flex items-center justify-between gap-3 px-4 py-3 text-sm border rounded-md transition-all duration-200 select-none hover:border-brand-dark-cyan",c?"border-brand-dark-cyan":"border-brand-stroke"),children:[(0,l.jsx)("span",{className:"text-nowrap",children:t}),null==(a=0===n.length||n.length===s.length?null:"count"===g?[n.length.toString()]:n.map(e=>{var a;return(null==(a=s.find(a=>a.value===e))?void 0:a.label)||e}))?void 0:a.map(e=>(0,l.jsx)("span",{className:"px-2.5 py-1 bg-gray-100 text-xs font-medium rounded-md shadow-custom-button",children:e},e)),(0,l.jsx)(eu.A,{className:(0,i.cn)("w-5 h-5 text-brand-dark-gray transition-transform duration-200",c&&"rotate-180")})]}),c&&(0,l.jsxs)("div",{className:(0,i.cn)("absolute z-50 mt-2 bg-white rounded-lg shadow-custom-select-dropdown border border-brand-stroke",u),children:[p?(0,l.jsx)(eZ.JY,{onDragEnd:e=>{if(!e.destination)return;let a=Array.from(v),[t]=a.splice(e.source.index,1);a.splice(e.destination.index,0,t),N(a)},children:(0,l.jsx)(eZ.gL,{droppableId:"columns",children:e=>(0,l.jsxs)("div",{...e.droppableProps,ref:e.innerRef,children:[v.map((e,a)=>(0,l.jsx)(eZ.sx,{draggableId:e.value,index:a,children:a=>(0,l.jsxs)("div",{ref:a.innerRef,...a.draggableProps,...a.dragHandleProps,className:"flex items-center flex-nowrap gap-2 m-1 pl-2 pr-8 py-1.5 hover:bg-cyan-50 rounded-xs cursor-move",children:[(0,l.jsx)(eW.A,{className:"w-4 h-4 text-brand-dark-gray"}),(0,l.jsxs)("div",{className:"flex items-center gap-2 flex-nowrap",onClick:a=>{a.stopPropagation(),k(e.value)},children:[(0,l.jsx)("div",{className:(0,i.cn)("w-5 h-5 rounded-sm border border-brand-dark-cyan flex items-center justify-center",j.includes(e.value)&&"bg-brand-dark-cyan"),
1children:j.includes(e.value)&&(0,l.jsx)(eY.A,{className:"w-4 h-4 text-white"})}),(0,l.jsx)("span",{className:"text-sm text-nowrap",children:e.label})]})]})},e.value)),e.placeholder]})})}):(0,l.jsx)("div",{className:"max-h-60 overflow-y-auto",children:v.map(e=>(0,l.jsxs)("div",{className:"flex items-center gap-2 m-1 pl-2 pr-8 py-1.5 hover:bg-cyan-50 cursor-pointer rounded-sm",onClick:a=>{a.stopPropagation(),k(e.value)},children:[(0,l.jsx)("div",{className:(0,i.cn)("w-5 h-5 rounded-sm border border-brand-dark-cyan flex items-center justify-center",j.includes(e.value)&&"bg-brand-dark-cyan"),children:j.includes(e.value)&&(0,l.jsx)(eY.A,{className:"w-4 h-4 text-white"})}),(0,l.jsx)("span",{className:"text-sm text-nowrap",children:e.label})]},e.value))}),(0,l.jsxs)("div",{className:"flex gap-3 pt-3 px-3 pb-2 border-t border-brand-stroke",children:[(0,l.jsx)(e$.$,{variant:"tertiary",size:"sm",onClick:()=>{f?o(h):o([]),null==d||d(h),N(s),_(h),m(!1),null==b||b()},className:"w-full",children:"Reset"}),(0,l.jsx)(e$.$,{size:"sm",onClick:()=>{null==d||d(v.map(e=>e.value)),o(j),null==x||x(),m(!1)},className:"w-full",children:"Apply"})]})]})]})}let eJ=[{accessorKey:"bedroom_type",header:"Bedroom Type"},{accessorKey:"total_gallons",header:()=>(0,l.jsx)("div",{className:"flex justify-end w-full",children:"Total Gallons"}),cell:e=>{let{row:a}=e;return(0,l.jsx)("div",{className:"flex justify-end w-full",children:a.original.total_gallons})}},{accessorKey:"flow_time",header:()=>(0,l.jsx)("div",{className:"flex justify-end w-full",children:"Flow Time"}),cell:e=>{let{row:a}=e;return(0,l.jsx)("div",{className:"flex justify-end w-full",children:a.original.flow_time})}},{accessorKey:"events",header:()=>(0,l.jsx)("div",{className:"flex justify-end w-full",children:"Events"}),cell:e=>{let{row:a}=e;return(0,l.jsx)("div",{className:"flex justify-end w-full",children:a.original.events})}}],eX=e=>{let{open:a,onOpenChange:t,propertyInfo:n,propertyId:o,searchParams:d,router:c}=e,[m,u]=(0,r.useState)([]),[p,x]=(0,r.useState)(null),[h,g]=(0,r.useState)(!1),[y,f]=(0,r.useState)(0),[b,v]=(0,r.useState)(0),[N,j]=(0,r.useState)([]),[_,w]=(0,r.useState)([]),[k,C]=(0,r.useState)(!1),[S,E]=(0,r.useState)(!1),[L,A]=(0,r.useState)([]),[D,O]=(0,r.useState)([]),[T,I]=(0,r.useState)(!1),P=(0,r.useRef)(null),R=(0,r.useRef)(null),M=(0,r.useRef)(null),G=(0,r.useRef)(!1),z=Object.fromEntries(Array.from(d.entries()).filter(e=>{let[a]=e;return!["meter","dateRangeLabel","organization_id","property_id"].includes(a)})),F=(0,r.useCallback)(e=>{P.current=e,null!==e&&f(e=>e+1)},[]),H=(0,r.useCallback)(e=>{R.current=e,null!==e&&v(e=>e+1)},[]);(0,r.useEffect)(()=>{M.current=p},[p]),(0,r.useEffect)(()=>{a&&(u([]),x(null),o&&(V(),U()))},[o,a]);let V=async e=>{g(!0);try{let a;a=e?await (0,eB.Vg)(e):await ec.l.getLeakDetailsPropertiesMeters(o,{...z,...L.length>0&&{building_id:L},...D.length>0&&{unit_id:D},page:1,page_size:10}),u(e=>[...e,...a.results]),x(a.next)}finally{g(!1)}};(0,r.useEffect)(()=>{a&&o&&(u([]),x(null),V())},[L,D]);let U=async()=>{try{I(!0);let e=await ec.l.getLeakOverviewFilters({property_id:[o.toString()]}),a=e.buildings.map(e=>({value:e.id.toString(),label:e.building_name})),t=e.units.map(e=>({value:e.id.toString(),label:e.name}));j(a),w(t)}catch(e){console.error("Error fetching filters:",e)}finally{I(!1)}};return((0,r.useEffect)(()=>{if(!a||!p||h)return;let e=P.current,t=R.current;if(!e||!t)return;let l=new IntersectionObserver(e=>{e[0].isIntersecting&&!h&&!G.current&&M.current&&(G.current=!0,V(M.current).finally(()=>{G.current=!1}))},{threshold:.1,root:t});return l.observe(e),()=>{l.disconnect()}},[a,h,p,y,b]),n)?(0,l.jsx)(s.lG,{open:a,onOpenChange:t,children:(0,l.jsxs)(s.Cf,{className:"max-w-[90vw] p-10 gap-6","aria-describedby":"property-info-description",children:[(0,l.jsx)(s.rr,{id:"property-info-description",className:"sr-only",children:"Detailed information about the selected property, including meters and average consumption."}),(0,l.jsx)(s.c7,{children:(0,l.jsxs)("div",{className:"flex items-center justify-between",children:[(0,l.jsx)(s.L3,{className:"text-3xl font-bold text-cyan-900",children:"Property Information"}),(0,l.jsx)(s.HM,{asChild:!0,children:(0,l.jsx)(ek.A,{className:"w-8 h-8 text-brand-dark-gray cursor-pointer",onClick:()=>t(!1)})})]})}),(0,l.jsxs)("div",{className:"flex flex-wrap gap-5 bg-brand-white rounded-xl border border-gray-100 px-6 py-4 shadow-custom-tile",children:[(0,l.jsxs)("div",{className:"flex items-center gap-3",children:[(0,l.jsx)(eM.A,{strokeWidth:1.5,className:"w-6 h-6 text-brand-dark-gray"}),(0,l.jsx)("span",{className:"text-base font-semibold",children:n.organization_name})]}),(0,l.jsxs)("div",{className:"flex items-center gap-3",children:[(0,l.jsx)(el.A,{strokeWidth:1.5,className:"w-6 h-6 text-brand-dark-gray"}),(0,l.jsx)("span",{className:"text-base font-semibold",children:n.name})]}),(0,l.jsxs)("div",{className:"flex items-center gap-3",children:[(0,l.jsx)(eG.A,{strokeWidth:1.5,className:"w-6 h-6 text-brand-dark-gray"}),(0,l.jsxs)("span",{className:"text-base font-semibold",children:[n.city,", ",n.state]})]}),(0,l.jsxs)("div",{className:"flex items-center gap-3",children:[(0,l.jsx)(ez.A,{strokeWidth:1.5,className:"w-6 h-6 text-brand-dark-gray"}),(0,l.jsx)("span",{className:"text-base font-semibold",children:n.street})]}),(0,l.jsxs)("div",{className:"flex items-center gap-3",children:[(0,l.jsx)(eF.A,{strokeWidth:1.5,className:"w-6 h-6 text-brand-dark-gray"}),(0,l.jsx)("span",{className:"text-base font-semibold",children:n.zip_code})]}),(0,l.jsxs)("div",{className:"flex items-center gap-3",children:[(0,l.jsx)(eH.A,{strokeWidth:1.5,className:"w-6 h-6 text-brand-dark-gray"}),(0,l.jsx)("span",{className:"text-base font-semibold",children:n.contact_phone})]}),(0,l.jsxs)("div",{className:"flex items-center gap-3",children:[(0,l.jsx)(eV.A,{strokeWidth:1.5,className:"w-6 h-6 text-brand-dark-gray"}),(0,l.jsx)("span",{className:"text-base font-semibold",children:n.contact_email})]})]}),(0,l.jsxs)("div",{className:"grid grid-cols-2 gap-6",children:[(0,l.jsxs)("div",{className:"bg-white rounded-xl border border-gray-100 px-5 py-6 gap-4 shadow-custom-tile relative",children:[(0,l.jsxs)("div",{className:"flex flex-col xl:flex-row items-start xl:items-center gap-3 mb-6 justify-between",children:[(0,l.jsx)("h3",{className:"text-xl font-semibold text-brand-black",children:"Property Details"}),T?(0,l.jsx)(ee.A,{className:"absolute bottom-4 left-0 right-0 h-6 w-6 animate-spin text-brand-dark-cyan mx-auto my-1"}):(0,l.jsxs)("div",{className:"flex items-center gap-3",children:[(0,l.jsx)(eq,{title:"Building",options:N,initialValues:[],selectedValues:L,onSelectedChange:A,isOpen:k,onOpenChange:C,isDisabled:0===N.length}),(0,l.jsx)(eq,{title:"Unit",options:_,initialValues:[],selectedValues:D,onSelectedChange:O,isOpen:S,onOpenChange:E,isDisabled:0===_.length})]})]}),(0,l.jsxs)("div",{className:"h-64 overflow-y-auto relative",ref:H,children:[m&&m.length>0&&(0,l.jsxs)("div",{className:"relative",children:[(0,l.jsxs)("table",{className:"w-full",children:[(0,l.jsx)(eK.A0,{className:"[&_tr]:border-b-0 sticky top-0 bg-white z-10",children:(0,l.jsxs)(eK.Hj,{className:"relative after:absolute after:-bottom-px after:left-0 after:w-full after:h-px after:bg-gray-200 border-b-0",children:[(0,l.jsx)(eK.nd,{
1className:"h-10 py-2 px-2 text-left",children:"Building"}),(0,l.jsx)(eK.nd,{className:"h-10 py-2 px-2 text-left",children:"Unit"}),(0,l.jsx)(eK.nd,{className:"h-10 py-2 px-2 text-left",children:"Attached To"})]})}),(0,l.jsx)("tbody",{children:m.map((e,a)=>(0,l.jsxs)(eK.Hj,{className:(0,i.cn)("border-b last:border-b-0 hover:bg-cyan-100 transition-colors",a%2==0?"bg-gray-50":"bg-white"),children:[(0,l.jsx)(eK.nA,{className:"py-2 px-2",children:e.building_name}),(0,l.jsx)(eK.nA,{className:"py-2 px-2",children:e.unit_name}),(0,l.jsx)(eK.nA,{className:"py-2 px-2",children:e.attached_to}),(0,l.jsx)(eK.nA,{className:"py-2 px-2 flex justify-end",children:(0,l.jsx)(e$.$,{variant:"secondary",size:"sm",className:"py-1 px-2 border-gray-400 h-7 text-brand-dark-gray hover:text-brand-dark-cyan hover:border-brand-dark-cyan",onClick:()=>{c.push("/history?building_id=".concat(e.building_id,"&unit_id=").concat(e.unit_id))},children:(0,l.jsxs)("div",{className:"flex items-center gap-0.5",children:["Unit details",(0,l.jsx)(es.A,{className:"w-4 h-4"})]})})})]},a))})]}),p&&(0,l.jsx)("div",{ref:F,style:{height:24}})]}),m&&0===m.length&&!h&&(0,l.jsx)("p",{className:"text-center text-gray-500 m-auto",children:"No property details available"})]}),h&&(0,l.jsx)(ee.A,{className:"absolute bottom-4 left-0 right-0 h-6 w-6 animate-spin text-brand-dark-cyan mx-auto my-1"})]}),(0,l.jsxs)("div",{className:"bg-white rounded-xl border border-gray-100 px-5 py-6 gap-4 shadow-custom-tile",children:[(0,l.jsx)("h3",{className:"text-xl font-semibold text-brand-black mb-6",children:"Average Consumption"}),(0,l.jsx)(eU.b,{columns:eJ,data:n.average_consumption,columnVisibility:{},onColumnVisibilityChange:()=>{},columnOrder:[]})]})]})]})}):null};var eQ=t(6191);let e0=e=>{let{open:a,onOpenChange:t,onSuccess:n,organizationId:i,propertyId:o}=e,{toast:d}=(0,eD.dj)(),[c,m]=(0,r.useState)({}),{control:u,handleSubmit:p,formState:{isSubmitting:x,isValid:h},reset:g,setValue:y,watch:f}=(0,ew.mN)({defaultValues:{propertyCosts:[{selectedUnits:[],selectedOption:void 0,costPerGallon:"0.015",startDate:void 0,endDate:void 0}]},mode:"onChange"}),{fields:b,append:v,remove:N}=(0,ew.jz)({control:u,name:"propertyCosts"});r.useEffect(()=>{a||(g(),m({}))},[a,g]);let j=(e,a)=>"".concat(e,"-").concat(a),_=(e,a)=>{m(t=>({...t,[e]:a}))},w=e=>{m(a=>({...a,[e]:!1}))},k=async e=>{try{let a=e.propertyCosts.map(e=>({unit_ids:e.selectedUnits,cost:parseFloat(e.costPerGallon),start_date:e.startDate?(0,et.GP)(e.startDate,"yyyy-MM-dd"):void 0,end_date:e.endDate?(0,et.GP)(e.endDate,"yyyy-MM-dd"):void 0}));await eA.Q.setPortfolioInsightsFinancesCosts({costs:a}),d({title:"Success",description:"Custom costs have been saved successfully.",className:"bg-green-200 border-green-200 text-brand-black"}),null==n||n(),t(!1),g()}catch(e){console.error("Failed to save custom costs:",e),d({title:"Error",description:"Failed to save custom costs. Please try again.",className:"bg-red-200 border-red-200 text-brand-black"})}};return(0,l.jsx)(s.lG,{open:a,onOpenChange:t,children:(0,l.jsxs)(s.Cf,{className:"max-w-2xl max-h-[90vh] overflow-y-auto py-6 px-10 gap-0",children:[(0,l.jsxs)(s.c7,{className:"relative pb-3 border-b border-gray-200 mb-3",children:[(0,l.jsx)(s.L3,{className:"text-xl font-bold text-left",children:"Set Custom Cost per Gallon"}),(0,l.jsx)(s.HM,{className:"absolute right-0 top-[-4px] hover:bg-gray-100",children:(0,l.jsx)(ek.A,{className:"w-6 h-6"})})]}),(0,l.jsx)(s.rr,{className:"text-base text-gray-600 mb-8",children:"Choose how you want to apply the cost per gallon—across all properties or to a specific one."}),(0,l.jsxs)("form",{onSubmit:p(k),className:"space-y-6",children:[(0,l.jsx)("div",{className:"max-h-[500px] overflow-y-auto flex flex-col gap-4",children:b.map((e,a)=>(0,l.jsxs)("div",{className:"p-4 border border-gray-200 rounded-lg flex flex-col gap-4",children:[b.length>1&&(0,l.jsxs)("div",{className:"flex justify-between items-center",children:[(0,l.jsxs)("h4",{className:"font-medium",children:["Property Cost #",a+1]}),(0,l.jsx)(e$.$,{type:"button",variant:"ghost",size:"sm",onClick:()=>{b.length>1&&N(a)},className:"text-red-500 hover:text-red-700 hover:bg-red-50",children:(0,l.jsx)(ek.A,{className:"w-4 h-4"})})]}),(0,l.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,l.jsxs)("div",{children:[(0,l.jsxs)(l3,{className:"text-sm font-medium",children:["Property ",(0,l.jsx)("span",{className:"text-red-500",children:"(*
1)"})]}),(0,l.jsx)(ew.xI,{name:"propertyCosts.".concat(a,".selectedUnits"),control:u,render:()=>(0,l.jsx)(ew.xI,{name:"propertyCosts.".concat(a,".selectedOption"),control:u,rules:{required:"Property is required"},render:e=>{let{field:{value:t,onChange:s},fieldState:{error:r}}=e;return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(s_,{value:t,onChange:(e,t)=>{s(e),y("propertyCosts.".concat(a,".selectedUnits"),t)},placeholder:"Select property",error:!!r,className:"mt-2",organizationId:i,propertyId:o}),r&&(0,l.jsx)("p",{className:"text-red-500 text-xs mt-1",children:r.message})]})}})})]}),(0,l.jsxs)("div",{children:[(0,l.jsxs)(l3,{className:"text-sm font-medium",children:["Average Cost per Gallon"," ",(0,l.jsx)("span",{className:"text-red-500",children:"(*)"})]}),(0,l.jsx)(ew.xI,{name:"propertyCosts.".concat(a,".costPerGallon"),control:u,rules:{required:"Average Cost per Gallon is required",validate:e=>{if(""===e||null==e)return"Please enter a valid number";let a=e.toString();if(a.match(/^\d*\.?\d*$/)&&""!==a){let e=a.split(".")[1];if(e&&e.length>3)return"Maximum 3 decimal places allowed";let t=parseFloat(a);return!!isNaN(t)||!(t<=0)||"Cost must be greater than 0"}return"Please enter a valid number"}},render:e=>{let{field:{value:a,onChange:t},fieldState:{error:s}}=e;return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(l2,{type:"text",placeholder:"0.015",value:a||"",onChange:e=>{let a=e.target.value;(""===a||a.match(/^\d*\.?\d{0,3}$/))&&t(a)},className:"mt-2 ".concat(s?"border-red-500 focus:border-red-500 focus:ring-red-500":"")}),s&&(0,l.jsx)("p",{className:"text-red-500 text-xs mt-1",children:s.message})]})}})]}),(0,l.jsxs)("div",{children:[(0,l.jsxs)(l3,{className:"text-sm font-medium",children:["Start Date for Cost"," ",(0,l.jsx)("span",{className:"text-red-500",children:"(*)"})]}),(0,l.jsx)(ew.xI,{name:"propertyCosts.".concat(a,".startDate"),control:u,rules:{required:"Start Date for Cost is required",validate:e=>{if(!e)return!0;let t=f().propertyCosts[a],l=null==t?void 0:t.endDate;return!l||!(e>l)||"Start date cannot be later than end date"}},render:e=>{let{field:{value:t,onChange:s},fieldState:{error:r}}=e,n=j(a,"start");return(0,l.jsxs)("div",{className:"mt-2",children:[(0,l.jsxs)(lJ,{open:c[n]||!1,onOpenChange:e=>_(n,e),children:[(0,l.jsx)(lX,{asChild:!0,children:(0,l.jsxs)("button",{type:"button",className:"flex h-9 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-colors w-full justify-start items-center text-left font-normal focus:outline-hidden focus:ring-1 focus:ring-brand-dark-cyan ".concat(r?"border-red-500":"border-brand-stroke"),children:[(0,l.jsx)(eL.A,{className:"mr-2 h-4 w-4 text-brand-dark-gray"}),t?(0,l.jsx)("span",{className:"text-brand-black",children:(0,et.GP)(t,"MM/dd/yyyy")}):(0,l.jsx)("span",{className:"text-brand-dark-gray",children:"Select date"})]})}),(0,l.jsx)(lQ,{className:"w-auto p-0 z-999 pointer-events-auto border-none",align:"start",children:(0,l.jsx)(lY,{mode:"single",selected:t,onSelect:e=>{s(e),w(n)}})})]}),r&&(0,l.jsx)("p",{className:"text-red-500 text-xs mt-1",children:r.message})]})}})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)(l3,{className:"text-sm font-medium",children:"End Date for Cost"}),(0,l.jsx)(ew.xI,{name:"propertyCosts.".concat(a,".endDate"),control:u,rules:{validate:e=>{if(!e)return!0;let t=f().propertyCosts[a],l=null==t?void 0:t.startDate;return!l||!(e<l)||"End date cannot be earlier than start date"}},render:e=>{let{field:{value:t,onChange:s},fieldState:{error:r}}=e,n=j(a,"end");return(0,l.jsxs)("div",{className:"mt-2",children:[(0,l.jsxs)(lJ,{open:c[n]||!1,onOpenChange:e=>_(n,e),children:[(0,l.jsx)(lX,{asChild:!0,children:(0,l.jsxs)("button",{type:"button",className:"flex h-9 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-colors w-full justify-start items-center text-left font-normal focus:outline-hidden focus:ring-1 focus:ring-brand-dark-cyan ".concat(r?"border-red-500":"border-brand-stroke"),children:[(0,l.jsx)(eL.A,{className:"mr-2 h-4 w-4 text-brand-dark-gray"}),t?(0,l.jsx)("span",{className:"text-brand-black",children:(0,et.GP)(t,"MM/dd
1/yyyy")}):(0,l.jsx)("span",{className:"text-brand-dark-gray",children:"Select date"})]})}),(0,l.jsx)(lQ,{className:"w-auto p-0 z-999 pointer-events-auto border-none",align:"start",children:(0,l.jsx)(lY,{mode:"single",selected:t,onSelect:e=>{s(e),w(n)}})})]}),r&&(0,l.jsx)("p",{className:"text-red-500 text-xs mt-1",children:r.message})]})}})]})]})]},e.id))}),(0,l.jsx)(e$.$,{type:"button",variant:"tertiary",onClick:()=>{v({selectedUnits:[],selectedOption:void 0,costPerGallon:"",startDate:void 0,endDate:void 0})},className:"w-full",icon:eQ.A,iconPosition:"left",children:"Add New Property Cost"}),(0,l.jsx)("div",{children:(0,l.jsx)(e$.$,{type:"submit",disabled:!h||x,className:"w-full bg-brand-dark-cyan hover:bg-brand-dark-cyan/90 text-white py-3",children:x?"Saving...":"Confirm"})})]})]})})};var e1=t(66942),e2=t(3611),e5=t(8505),e3=t(60919),e4=t(15101),e6=t(38731),e8=t(96374);let e9={EMAIL_EXISTS:{title:"Account Already Exists!",description:"An account is already registered with this email address."},DEFAULT:{title:"Error Creating User",description:"An unexpected error occurred. Please try again."}};function e7(e){var a,t,s,n,i,o,d,c,m,u,p;let{open:x,onOpenChange:h,isOrgAdmin:g,user:y=null,setUser:f,setShouldBeRefreshed:b}=e,{isStaff:v}=(0,eC.J)(),{activeOrganization:N,organizations:j}=(0,e4.Z)(),[_,w]=(0,r.useState)(!1),[k,C]=(0,r.useState)(!1),[S,E]=(0,r.useState)({title:"",description:""}),[L,A]=(0,r.useState)(!0),[D,O]=(0,r.useState)([]),[T,I]=(0,r.useState)(null),[P,R]=(0,r.useState)([]),[M,G]=(0,r.useState)([]),[z,F]=(0,r.useState)(!1),H=(0,r.useRef)(null),V=()=>{setTimeout(()=>{H.current&&H.current.scrollTo({top:H.current.scrollTop+200,behavior:"smooth"})},100)},U=e2.Ikc({role:e2.aig({error:"Role is required"}),email:e2.Rpp("Invalid email format"),first_name:e2.YjP().optional(),last_name:e2.YjP().optional(),business_title:e2.YjP().max(80,"Business title must be less than 80 characters"),permissions:e2.YOg(e2.YjP(),{error:"At least one permission is required"}).min(1,{error:"At least one permission is required"}),assigned_organizations:e2.YOg(e2.YjP(),{error:"At least one organization is required"}).min(1,{error:"At least one organization is required"}),assigned_properties:e2.YOg(e2.YjP()).optional(),mailing_list:e2.Ikc({top5_enabled:e2.zMY(),monthly_enabled:e2.zMY()}).optional()}).superRefine((e,a)=>{!T||T.is_staff||e.assigned_properties&&0!==e.assigned_properties.length||a.addIssue({code:"custom",error:"At least one property is required",path:["assigned_properties"]})}),{register:B,handleSubmit:K,control:W,formState:{errors:Y,isSubmitting:$},watch:Z,reset:q,setValue:J,clearErrors:X}=(0,ew.mN)({resolver:(0,e1.u)(U)}),Q=()=>{q({role:void 0,email:"",business_title:"",permissions:[],assigned_organizations:[],assigned_properties:[],mailing_list:{top5_enabled:!0,monthly_enabled:!0}}),I(null),G([]),E({title:"",description:""})};(0,r.useEffect)(()=>{x&&(async()=>{try{A(!0);let a=await e5.FH.common.getEnums(),t=a.results.roles,l=a.results.permissions;
1if(O(t),R(l),J("permissions",l.map(e=>e.id.toString())),y){var e;q({role:y.roles[0].id,email:y.email,first_name:y.first_name,last_name:y.last_name,business_title:y.business_title,permissions:y.permissions.filter(e=>(0,e8.n6)(e.name)).map(e=>e.name),assigned_organizations:y.assigned_organizations.map(e=>e.id.toString()),assigned_properties:y.assigned_properties.map(e=>e.id.toString()),mailing_list:null!=(e=y.mailing_list)?e:{top5_enabled:!0,monthly_enabled:!0}}),1===y.assigned_organizations.length&&et(y.assigned_organizations[0].id.toString()),I(t.find(e=>e.id===y.roles[0].id))}else Q()}catch(e){console.error("Failed to fetch data:",e),(0,eD.oR)({title:"Error Loading Data",description:"Failed to load form data. Please try again.",className:"bg-red-200 border-red-200 text-brand-black"}),Q()}finally{A(!1)}})()},[x,y,q]),(0,r.useEffect)(()=>{x&&g&&(null==N?void 0:N.id)&&(J("assigned_organizations",[null==N?void 0:N.id.toString()]),et(null==N?void 0:N.id))},[x,g,null==N?void 0:N.id]);let ea=e=>{w(!1),C(!1),I(null),G([]),E({title:"",description:""}),y&&f&&f(null),e&&h(!1)},et=async e=>{try{var a;F(!0);let t=await e5.FH.inventory.getOrganizationProperties(e);G(t);let l=new Set(t.map(e=>e.id.toString())),s=null!=(a=null==y?void 0:y.assigned_organizations.some(a=>a.id.toString()===e))&&a;y&&s?J("assigned_properties",y.assigned_properties.map(e=>e.id.toString()).filter(e=>l.has(e))):J("assigned_properties",t.map(e=>e.id.toString()))}catch(e){console.error("Failed to fetch organization properties:",e)}finally{F(!1)}},el=async e=>{var a,t,l;C(!1);let{assigned_properties:s,assigned_organizations:r,...n}=e,i=r[0],o={...n,mailing_list:null!=(a=n.mailing_list)?a:null};try{y?(v?y.is_staff?await e6.d.updateStaffUser(y.id.toString(),{...o,assigned_organizations:r.map(Number)}):await e6.d.updateStaffExternalUser(y.id.toString(),{...o,organization_id:Number(i),assigned_properties:(null==s?void 0:s.map(Number))||[]}):await e6.d.updateOrganizationUser(i,y.id.toString(),{...o,assigned_properties:(null==s?void 0:s.map(Number))||[]}),h(!1),(0,eD.oR)({title:"User Updated Successfully!",description:"The changes have been saved without issues.",className:"bg-green-200 border-green-200 text-brand-black"})):(v?(null==T?void 0:T.is_staff)?await e6.d.createStaffUser({...o,assigned_organizations:r.map(Number)}):await e6.d.createStaffExternalUser({...o,organization_id:Number(i),assigned_properties:(null==s?void 0:s.map(Number))||[]}):await e6.d.createOrganizationUser(i,{...o,assigned_properties:(null==s?void 0:s.map(Number))||[]}),w(!0)),Q()}catch(e){y?(h(!1),Q(),(0,eD.oR)({title:"Error Updating User!",description:"An unexpected error occurred. Please try again.",className:"bg-red-200 border-red-200 text-brand-black"})):(C(!0),e instanceof e3.pe&&(null==(l=e.response)||null==(t=l.data)?void 0:t.email)?E(e9.EMAIL_EXISTS):E(e9.DEFAULT))}finally{b(!0)}},es=null==(a=Z("assigned_organizations"))?void 0:a[0],er=T&&!T.is_staff&&!!es||g,en=!g&&!!T&&!(null==T?void 0:T.is_staff)&&!es;return(0,l.jsx)(lO,{open:x,onOpenChange:h,children:(0,l.jsx)(au.TooltipProvider,{delayDuration:50,children:(0,l.jsx)(lP,{className:"md:max-w-[652px] max-w-[calc(100%-40px)] bg-brand-white px-5 py-6 md:px-10 max-h-[calc(100vh-142px-40px)]",children:_?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(lR,{className:"space-y-1",children:[(0,l.jsx)(sN,{variant:"success",className:"mb-5"}),(0,l.jsx)(lG,{className:"text-3xl font-semibold text-center mb-4 text-brand-black",children:"User created successfully!"}),(0,l.jsx)(lz,{className:"text-base font-regular text-center text-brand-black",children:"The user will receive an email to set their password and complete the account setup."})]}),(0,l.jsxs)("div",{className:"flex justify-between gap-4",children:[(0,l.jsx)(e$.$,{variant:"primary",className:"w-full",onClick:()=>ea(!1),children:"Add new user"}),(0,l.jsx)(e$.$,{type:"button",variant:"secondary",className:"w-full",onClick:()=>ea(!0),children:"Close"})]})]}):k?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(lR,{className:"space-y-1",children:[(0,l.jsx)(sN,{variant:"error",className:"mb-5"}),(0,l.jsx)(lG,{className:"text-3xl font-semibold text-center mb-4 text-brand-black",children:S.title}),(0,l.jsx)(lz,{className:"text-base font-regular text-center text-brand-black",children:S.description})]}),(0,l.jsxs)("div",{className:"flex justify-between gap-4",children:[(0,l.jsx)(e$.$,{variant:"primary",className:"w-full",onClick:()=>void(C(!1),E({title:"",description:""})),children:"Try again"}),(0,l.jsx)(e$.$,{type:"button",variant:"secondary",className:"w-full",onClick:()=>ea(!0),children:"Close"})]})]}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(lR,{children:[(0,l.jsxs)("div",{className:"flex items-center justify-between border-b border-gray-200 pb-3 mb-1 sticky top-0 bg-brand-white",children:[(0,l.jsx)(lG,{className:"text-xl font-semibold text-brand-black",children:y?"Edit User":"Create User"}),(0,l.jsx)(e$.$,{variant:"tertiary",className:"h-6 w-6 text-brand-dark-gray hover:text-brand-black hover:bg-gray-100 p-0",onClick:()=>ea(!0),icon:ek.A})]}),(0,l.jsx)(lz,{className:"text-left text-base text-brand-black",children:y?"Edit the details below to update the user account.":"Fill in the details below to create a new user account."})]}),L?(0,l.jsx)("div",{className:"flex justify-center p-4",children:(0,l.jsx)(ee.A,{className:"h-6 w-6 animate-spin text-brand-dark-cyan"})}):(0,l.jsxs)("form",{onSubmit:K(el),children:[(0,l.jsxs)("div",{ref:H,className:"overflow-y-auto max-h-[calc(100vh-395px)] no-scrollbar px-1 mx-[-4px]",children:[(0,l.jsx)("div",{className:"text-brand-black font-semibold text-lg mb-4",children:"User Information"}),(0,l.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,l.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,l.jsx)("p",{className:"text-xs font-medium uppercase tracking-wide text-brand-dark-gray",children:"Step 1 of 2"}),(0,l.jsx)(l3,{htmlFor:"role",required:!0,children:"Role"}),(0,l.jsx)(ew.xI,{control:W,name:"role",render:e=>{var a,t;let{field:s}=e;return(0,l.jsx)(su.R,{...s,value:s.value?{label:(null==(a=D.find(e=>e.id===s.value))?void 0:a.name)||"",value:s.value.toString()}:void 0,options:D.map(e=>({label:e.name,value:e.id.toString()})),error:null==(t=Y.role)?void 0:t.message,placeholder:"Select",onChange:e=>{(e=>{if(!e)return;let a=D.find(a=>a.id===e);J("role",e,{shouldValidate:!0}),I(a||null),T&&T.is_staff!==(null==a?void 0:a.is_staff)&&(J("assigned_organizations",g&&(null==N?void 0:N.id)?[N.id.toString()]:[]),J("assigned_properties",[]),G([]),J("permissions",P.map(e=>e.id.toString())),X(["assigned_organizations","assigned_properties","permissions","role"]),g&&(null==N?void 0:N.id)&&et(N.id.toString()))})((null==e?void 0:e.value)?Number(e.value):null)},isSearchable:!1})}})]}),(0,l.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,l.jsx)(l3,{htmlFor:"email",required:!0,children:"Email"}),(0,l.jsx)(l2,{id:"email",type:"email",placeholder:"Enter email",error:null==(t=Y.email)?void 0:t.message,...B("email")})]}),(0,l.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,l.jsx)(l3,{htmlFor:"first_name",children:"First Name"}),(0,l.jsx)(l2,{id:"first_name",placeholder:"Enter first name",error:null==(s=Y.first_name)?void 0:s.message,...B("first_name")}
1)]}),(0,l.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,l.jsx)(l3,{htmlFor:"last_name",children:"Last Name"}),(0,l.jsx)(l2,{id:"last_name",placeholder:"Enter last name",error:null==(n=Y.last_name)?void 0:n.message,...B("last_name")})]}),(0,l.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,l.jsxs)("div",{className:"flex justify-between items-center",children:[(0,l.jsx)(l3,{htmlFor:"businessTitle",children:"Business Title"}),(0,l.jsxs)("span",{className:"text-sm text-brand-dark-gray",children:[(null==(i=Z("business_title"))?void 0:i.length)||0,"/80"]})]}),(0,l.jsx)(l2,{id:"businessTitle",placeholder:"Enter business title",error:null==(o=Y.business_title)?void 0:o.message,maxLength:80,...B("business_title")})]}),(null==T?void 0:T.is_staff)&&(0,l.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,l.jsxs)("div",{className:"flex items-center justify-between gap-2 mb-2",children:[(0,l.jsx)(l3,{htmlFor:"permissions",required:!0,children:"Choose the options the user will have access to"}),(0,l.jsxs)(au.m_,{children:[(0,l.jsx)(au.k$,{children:(0,l.jsx)(ey.A,{className:"w-6 h-6 text-brand-dark-gray"})}),(0,l.jsx)(au.ZI,{align:"end",children:(0,l.jsx)("p",{className:"text-xs font-regular text-brand-white",children:"Select permissions for staff user"})})]})]}),(0,l.jsx)("div",{className:"flex flex-wrap gap-4",children:(0,l.jsx)(ew.xI,{control:W,name:"permissions",defaultValue:P.map(e=>e.id.toString()),render:e=>{let{field:a}=e;return(0,l.jsx)(l.Fragment,{children:P.map(e=>{var t;return(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)(lZ,{id:e.id.toString(),checked:null==(t=a.value)?void 0:t.includes(e.id.toString()),onCheckedChange:t=>{var l;let s=t?[...a.value||[],e.id.toString()]:(null==(l=a.value)?void 0:l.filter(a=>a!==e.id.toString()))||[];a.onChange(s)}}),(0,l.jsx)(l3,{htmlFor:e.id.toString(),children:e.name})]},e.id)})})}})}),(null==(d=Y.permissions)?void 0:d.message)&&(0,l.jsx)("p",{className:"text-sm text-brand-red",children:Y.permissions.message})]}),(0,l.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,l.jsx)("div",{className:"text-brand-black font-semibold text-lg mt-4",children:"User Access"}),(0,l.jsx)("p",{className:"text-xs font-medium uppercase tracking-wide text-brand-dark-gray -mt-2",children:"Step 2 of 2"}),!g&&(0,l.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,l.jsx)(l3,{htmlFor:"organizations",required:!0,children:"Organization"}),(null==T?void 0:T.is_staff)?(0,l.jsx)(sm,{control:W,name:"assigned_organizations",options:j.map(e=>({label:e.name,value:e.id.toString()})),error:null==(c=Y.assigned_organizations)?void 0:c.message,description:"At least one Organization must be selected.",showSelectAll:!0,onMenuOpen:()=>V()}):(0,l.jsx)(ew.xI,{control:W,name:"assigned_organizations",render:e=>{var a,t,s;let{field:r}=e;return(0,l.jsx)(su.R,{value:(null==(a=r.value)?void 0:a[0])?{label:(null==(t=j.find(e=>{var a;return e.id.toString()===(null==(a=r.value[0])?void 0:a.toString())}))?void 0:t.name)||"",value:r.value[0].toString()}:null,placeholder:"Select",options:j.map(e=>({label:e.name,value:e.id.toString()})),onMenuOpen:()=>V(),onChange:async e=>{let a=null==e?void 0:e.value;a?(r.onChange([a]),J("assigned_properties",[]),G([]),X("assigned_properties"),await et(a)):(r.onChange([]),J("assigned_properties",[]),G([]),X("assigned_properties"))},error:null==(s=Y.assigned_organizations)?void 0:s.message,description:"At least one Organization must be selected."})}})]}),en&&(0,l.jsx)("div",{className:"rounded-md border border-brand-stroke bg-gray-50 p-3",children:(0,l.jsx)("p",{className:"text-sm text-brand-dark-gray",children:"Select one organization first to load and assign properties."})}),er&&(0,l.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,l.jsx)("div",{className:"flex justify-between items-center",children:(0,l.jsx)("h3",{className:"text-lg font-semibold",children:null==(m=j.find(e=>g?Number(e.id)===Number(null==N?void 0:N.id):Number(e.id)===Number(es)))?void 0:m.name})}),(0,l.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,l.jsxs)("div",{className:"flex items-center justify-between gap-2 mb-2",children:[(0,l.jsx)(l3,{htmlFor:"permissions",required:!0,children:"Choose the options the user will have access to"}),(0,l.jsxs)(au.m_,{children:[(0,l.jsx)(au.k$,{children:(0,l.jsx)(ey.A,{className:"w-6 h-6 text-brand-dark-gray"})}),(0,l.jsx)(au.ZI,{align:"end",children:(0,l.jsx)("p",{className:"text-xs font-regular text-brand-white",children:"Select permissions for organization user"})})]})]}),(0,l.jsx)("div",{className:"flex flex-wrap gap-4",children:(0,l.jsx)(ew.xI,{control:W,name:"permissions",defaultValue:P.map(e=>e.id.toString()),render:e=>{let{field:a}=e;return(0,l.jsx)(l.Fragment,{children:P.map(e=>{var t;return(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)(lZ,{id:e.id.toString(),checked:null==(t=a.value)?void 0:t.includes(e.id.toString()),onCheckedChange:t=>{var l;let s=t?[...a.value||[],e.id.toString()]:(null==(l=a.value)?void 0:l.filter(a=>a!==e.id.toString()))||[];a.onChange(s)}}),(0,l.jsx)(l3,{htmlFor:e.id.toString(),children:e.name})]},e.id)})})}})}),(null==(u=Y.permissions)?void 0:u.message)&&(0,l.jsx)("p",{className:"text-sm text-brand-red",children:Y.permissions.message})]}),(0,l.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,l.jsx)(l3,{htmlFor:"assigned_properties",required:!0,children:"Properties"}),z?(0,l.jsx)("div",{className:"flex justify-center p-4",children:(0,l.jsx)(ee.A,{className:"h-6 w-6 animate-spin text-brand-dark-cyan"})}
1):(0,l.jsx)(sm,{control:W,name:"assigned_properties",options:M.map(e=>({label:e.name,value:e.id.toString()})),showSelectAll:!0,error:null==(p=Y.assigned_properties)?void 0:p.message,description:"At least one Property must be selected.",onMenuOpen:()=>V()})]})]})]}),(0,l.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,l.jsx)("div",{className:"text-brand-black font-semibold text-lg mt-4",children:"Leak Email Notifications"}),(0,l.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,l.jsx)(l3,{htmlFor:"mailing_list",children:"Choose whether the user receives Daily or Monthly leak report emails"}),(0,l.jsx)("div",{className:"flex flex-wrap gap-8",children:(0,l.jsx)(ew.xI,{control:W,name:"mailing_list",render:e=>{var a,t;let{field:s}=e;return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)(lZ,{id:"top5_enabled",checked:null==(a=s.value)?void 0:a.top5_enabled,onCheckedChange:e=>s.onChange({...s.value,top5_enabled:!0===e})}),(0,l.jsx)(l3,{htmlFor:"top5_enabled",children:"Daily Emails"})]}),(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)(lZ,{id:"monthly_enabled",checked:null==(t=s.value)?void 0:t.monthly_enabled,onCheckedChange:e=>s.onChange({...s.value,monthly_enabled:!0===e})}),(0,l.jsx)(l3,{htmlFor:"monthly_enabled",children:"Monthly Emails"})]})]})}})})]})]})]})]}),(0,l.jsx)("div",{className:"flex mt-4",children:(0,l.jsx)(e$.$,{type:"submit",className:"w-full",disabled:$,loading:$,children:y?"Save Changes":"Continue"})})]})]})})})})}var ae=t(13016);let aa=(e,a)=>{let t=parseInt(e);return Number.isNaN(t)?a:Math.min(Math.max(t,ae.nW),ae.TH)};function at(e){var a,t,s,n,i,o;let{isPopoverOpen:d,setIsPopoverOpen:c,selectedBedCount:m,onBedCountChange:u,isDisabled:p}=e,[x,h]=(0,r.useState)((null==(a=m.from)?void 0:a.toString())||""),[g,y]=(0,r.useState)((null==(t=m.to)?void 0:t.toString())||""),[f,b]=(0,r.useState)([null!=(s=m.from)?s:0,null!=(n=m.to)?n:7]);(0,r.useEffect)(()=>{var e,a,t,l;h((null==(e=m.from)?void 0:e.toString())||""),y((null==(a=m.to)?void 0:a.toString())||""),b([null!=(t=m.from)?t:0,null!=(l=m.to)?l:7])},[m]);let v=()=>aa(x,ae.nW)>aa(g,ae.TH),N=0!==m.from||7!==m.to;return(0,l.jsxs)(lJ,{open:d,onOpenChange:c,children:[(0,l.jsx)(lX,{asChild:!0,children:(0,l.jsxs)(e$.$,{variant:"secondary",className:"h-[38px] flex items-center gap-3 border border-brand-stroke text-brand-dark-gray text-sm font-normal relative hover:border-brand-dark-cyan",disabled:p,children:[(0,l.jsxs)("span",{className:"relative",children:["Bed Count",N&&(0,l.jsxs)("span",{className:"ml-1",children:["(",null!=(i=m.from)?i:0,"-",null!=(o=m.to)?o:7,")"]}),(0,l.jsx)("span",{className:"inline-block absolute right--2 top-0 rounded-full bg-brand-clean-blue w-1.5 h-1.5 transition-opacity duration-200 ".concat(N?"opacity-100":"opacity-0")})]}),(0,l.jsx)(eu.A,{className:"h-5 w-5 text-brand-dark-gray transition-transform duration-200 ".concat(d?"rotate-180":"")})]})}),(0,l.jsxs)(lQ,{className:"w-[280px] p-0",align:"start",children:[(0,l.jsxs)("div",{className:"space-y-6 px-3 pt-3 pb-6",children:[(0,l.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,l.jsxs)("div",{className:"space-y-2",children:[(0,l.jsx)("label",{className:"text-sm font-medium text-gray-700",children:"From"}),(0,l.jsx)(l2,{type:"number",placeholder:"0",value:x,onChange:e=>{let a=e.target.value;h(a),b([a?parseInt(a):0,f[1]])},min:"0",max:"6",className:"w-full ".concat(v()?"border-red-500 focus:ring-red-500":"")})]}),(0,l.jsxs)("div",{className:"space-y-2",children:[(0,l.jsx)("label",{className:"text-sm font-medium text-gray-700",children:"To"}),(0,l.jsx)(l2,{type:"number",placeholder:"7",value:g,onChange:e=>{let a=e.target.value;y(a);let t=a?parseInt(a):7;b([f[0],t])},min:"0",max:"7",className:"w-full ".concat(v()?"border-red-500 focus:ring-red-500":"")})]})]}),(0,l.jsx)("div",{children:(0,l.jsxs)("div",{className:"px-2",children:[(0,l.jsx)(sx,{value:f,onValueChange:e=>{b(e),h(e[0].toString()),y(e[1].toString())},min:0,max:7,step:1,className:"w-full"}),(0,l.jsxs)("div",{className:"flex justify-between text-xs text-brand-dark-gray mt-1",children:[(0,l.jsx)("span",{children:"0"}),(0,l.jsx)("span",{children:"7"})]})]})}),v()&&(0,l.jsx)("p",{className:"text-sm text-red-600",children:'"From" value cannot be greater than "To" value'})]}),(0,l.jsxs)("div",{className:"flex justify-between gap-3 pt-3 px-4 pb-2 border-t border-brand-stroke",children:[(0,l.jsx)(e$.$,{variant:"tertiary",className:"w-full",onClick:()=>{h("0"),y("7"),b([0,7]),u({from:0,to:7}),c(!1)},children:"Clear"}),(0,l.jsx)(e$.$,{variant:"primary",className:"w-full disabled:bg-gray-300 disabled:cursor-not-allowed",onClick:()=>{let e=aa(x,ae.nW),a=aa(g,ae.TH);e>a||(u({from:e,to:a}),c(!1))},disabled:v(),children:"Apply"})]})]})]})}var al=t(86651);function as(e){let{isPopoverOpen:a,setIsPopoverOpen:t,buildings:s,selectedBuilding:n,tempSelectedBuilding:i,setTempSelectedBuilding:o,handleReset:d,handleApply:c,onSearchChange:m,searchValue:u,disabled:p}=e,x=(0,r.useMemo)(()=>u.trim()?s.filter(e=>e.name.toLowerCase().includes(u.toLowerCase())):s,[s,u]);return(0,l.jsxs)(lJ,{open:a,onOpenChange:t,children:[(0,l.jsx)(lX,{asChild:!0,children:(0,l.jsxs)(e$.$,{variant:"secondary",className:"h-9.5 flex items-center gap-3 border border-brand-stroke text-brand-dark-gray text-sm font-normal relative",disabled:p,children:["Building",(null==n?void 0:n.length)>0&&" (".concat(n.length,")"),(0,l.jsx)(eu.A,{className:"h-5 w-5 text-brand-dark-gray transition-transform duration-200 ".concat(a?"rotate-180":"")}),(0,l.jsx)("div",{className:"absolute right-5 top-0 rounded-full bg-brand-clean-blue w-1.5 h-1.5 transition-opacity duration-200 ".concat((null==n?void 0:n.length)>0?"opacity-100":"opacity-0")})]})}),(0,l.jsx)(lQ,{className:"w-[274px] p-0",align:"start",children:(0,l.jsxs)("div",{className:"space-y-3",children:[(0,l.jsxs)("div",{className:"space-y-1",children:[(0,l.jsx)("div",{className:"px-3 pt-2",children:(0,l.jsx)(l2,{placeholder:"Search by building name",value:u,onChange:e=>m(e.target.value),className:"h-8",icon:al.A})}),(0,l.jsxs)("div",{className:"space-y-1 pt-1 max-h-60 overflow-y-auto",children:[(0,l.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded-md hover:bg-cyan-50 pointer-events-auto hover:cursor-pointer",onClick:()=>{let e=x.map(e=>e.id);e.every(e=>i.includes(e))?o(i.filter(a=>!e.includes(a))):o([...i,...e.filter(e=>!i.includes(e))])},children:[(0,l.jsx)(lZ,{id:"select-all-buildings",checked:x.length>0&&x.every(e=>i.includes(e.id)),onCheckedChange:e=>{let a=x.map(e=>e.id);e?o([...i,...a.filter(e=>!i.includes(e))]):o(i.filter(e=>!a.includes(e)))}}),(0,l.jsxs)("span",{className:"text-sm select-none cursor-pointer",children:["Select All (",x.length,")"]})]}),x.length>0?x.map(e=>(0,l.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded-md hover:bg-cyan-50 pointer-events-auto hover:cursor-pointer",onClick:()=>{o(i.includes(e.id)?i.filter(a=>a!==e.id):[...i,e.id])},children:[(0,l.jsx)(lZ,{checked:i.includes(e.id),onCheckedChange:a=>{o(a?[...i,e.id]:i.filter(a=>a!==e.id))}}),(0,l.jsxs)("div",{className:"flex flex-row text-sm select-none flex-wrap",children:[(0,l.jsx)("span",{children:e.property_name}),(0,l.jsx)("span",{className:"mx-1 shrink-0",children:"|"}),(0,l.jsx)("span",{className:"font-medium",children:e.name})]})]},e.id)):(0,l.jsx)("div",{className:"px-2 py-3 text-center text-sm text-gray-500",children:"No buildings found"})]})]}),(0,l.jsxs)("div",{className:"flex justify-between gap-6 px-4 py-3 border-t border-brand-stroke",children:[(0,l.jsx)(e$.$,{variant:"tertiary",className:"w-full",onClick:d,children:"Reset"}),(0,l.jsx)(e$.$,{className:"w-full",onClick:c,children:"Apply"})]})]})})]})}function ar(e){let{isPopoverOpen:a,setIsPopoverOpen:t,deviceTypes:s,selectedDeviceType:r,tempSelectedDeviceType:n,setTempSelectedDeviceType:i,handleReset:o,handleApply:d,disabled:c}=e;return(0,l.jsxs)(lJ,{open:a,onOpenChange:t,children:[(0,l.jsx)(lX,{asChild:!0,children:(0,l.jsxs)(e$.$,{variant:"secondary",className:"h-9.5 flex items-center gap-3 border border-brand-stroke text-brand-dark-gray text-sm font-normal relative",disabled:c,
1children:["Device Type",r.length>0&&" (".concat(r.length,")"),(0,l.jsx)(eu.A,{className:"h-5 w-5 text-brand-dark-gray transition-transform duration-200 ".concat(a?"rotate-180":"")}),(0,l.jsx)("div",{className:"absolute right-5 top-0 rounded-full bg-brand-clean-blue w-1.5 h-1.5 transition-opacity duration-200 ".concat(r.length>0?"opacity-100":"opacity-0")})]})}),(0,l.jsx)(lQ,{className:"w-60 p-0",align:"start",children:(0,l.jsxs)("div",{className:"space-y-3",children:[(0,l.jsx)("div",{className:"space-y-1",children:(0,l.jsxs)("div",{className:"space-y-1 pt-1",children:[(0,l.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded-md hover:bg-cyan-50 pointer-events-auto hover:cursor-pointer",onClick:()=>{n.length===s.length?i([]):i(s.map(e=>e.id.toString()))},children:[(0,l.jsx)(lZ,{id:"select-all-device-types",checked:s.length>0&&n.length===s.length,onCheckedChange:e=>{e?i(s.map(e=>e.id.toString())):i([])}}),(0,l.jsxs)("span",{className:"text-sm select-none cursor-pointer",children:["Select All (",s.length,")"]})]}),s.map(e=>(0,l.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded-md hover:bg-cyan-50 pointer-events-auto hover:cursor-pointer",onClick:()=>{i(n.includes(e.id.toString())?n.filter(a=>
1a!==e.id.toString()):[...n,e.id.toString()])},children:[(0,l.jsx)(lZ,{checked:n.includes(e.id.toString()),onCheckedChange:a=>{i(a?[...n,e.id.toString()]:n.filter(a=>a!==e.id.toString()))}}),(0,l.jsx)("span",{className:"text-sm select-none",children:e.name})]},e.id))]})}),(0,l.jsxs)("div",{className:"flex justify-between gap-6 px-4 py-3 border-t border-brand-stroke",children:[(0,l.jsx)(e$.$,{variant:"tertiary",className:"w-full select-none",onClick:o,children:"Reset"}),(0,l.jsx)(e$.$,{className:"w-full select-none",onClick:d,children:"Apply"})]})]})})]})}var an=t(66955);function ai(e){var a;let{params:t}=e,{statistics:s,isLoading:n}=function(e){let[a,t]=(0,r.useState)(null),[l,s]=(0,r.useState)(!1),n=JSON.stringify({days_ago:e.days_ago,start_date:e.start_date,end_date:e.end_date,include_today:e.include_today,organization_id:e.organization_id}),i=(0,r.useRef)("");return(0,r.useEffect)(()=>{i.current!==n&&(i.current=n,s(!0),ec.l.getOrganizationsStatistics(JSON.parse(n)).then(e=>{i.current===n&&t(e)}).catch(e=>{console.error("Failed to fetch organization statistics:",e)}).finally(()=>{i.current===n&&s(!1)}))},[n]),{statistics:a,isLoading:l}}(t),i=null!=(a=null==s?void 0:s.organizations)?a:[],o=i[0],d=Math.max(i.length-1,0);return(0,l.jsxs)("div",{className:"flex flex-wrap flex-col md:flex-row md:items-center text-sm 2xl:text-base font-semibold text-cyan-800",children:[(0,l.jsxs)("span",{className:"w-fit flex items-center gap-1",children:["Developer:"," ",(0,l.jsxs)(au.m_,{children:[(0,l.jsx)(au.k$,{className:"w-fit",children:(0,l.jsx)("span",{className:"inline-block max-w-40 3xl:max-w-60 truncate align-bottom",children:null!=o?o:"-"})}),(0,l.jsx)(au.ZI,{align:"start",side:"bottom",className:"max-w-96",children:null!=o?o:"-"})]}),d>0&&(0,l.jsxs)(au.m_,{children:[(0,l.jsx)(au.k$,{className:"pl-1 w-fit",children:(0,l.jsxs)("span",{className:"text-brand-dark-gray",children:["(+",d,")"]})}),(0,l.jsx)(au.ZI,{align:"start",side:"bottom",className:"max-w-96",children:(0,l.jsx)("div",{className:"flex flex-row flex-wrap gap-1",children:i.slice(1).map((e,a,t)=>(0,l.jsxs)("span",{children:[e,a<t.length-1?", ":""]},e))})})]})]}),n?(0,l.jsx)(ee.A,{className:"h-4 w-4 animate-spin text-brand-dark-cyan ml-4"}):s?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("div",{className:"flex items-center",children:[(0,l.jsx)("span",{className:"px-3 hidden md:inline",children:"|"}),"Total Properties:"," ",s.total_properties_count.toLocaleString()]}),(0,l.jsxs)("div",{className:"flex items-center",children:[(0,l.jsx)("span",{className:"px-3 hidden md:inline",children:"|"}),"Units (total/installed): ",s.total_units_count.toLocaleString(),"/",s.installed_units_count.toLocaleString(),(0,l.jsxs)(au.m_,{children:[(0,l.jsx)(au.k$,{children:(0,l.jsx)(ey.A,{className:"w-6 h-6 text-brand-dark-gray ml-2"})}),(0,l.jsx)(au.ZI,{side:"bottom",align:"start",className:"w-52",children:"Total units across the selected organizations; the installed count reflects units active during the selected period."})]})]})]}):null]})}var ao=t(33275);let ad=e=>{let a=[{label:"No Comparison",value:"false"}];return"yesterday"===e?a.push({label:"Previous Day (N-2)",value:"true"}):"last-7-days"===e?a.push({label:"Previous 7 days (days 8-14)",value:"true"}):"last-30-days"===e&&a.push({label:"Previous 30 days (days 31-60)",value:"true"}),a};function ac(e){var a;let{title:t,organizations:s,selectedOrganizations:n,tempSelectedOrganizations:o,setTempSelectedOrganizations:d,selectedProperties:c,tempSelectedProperties:m,setTempSelectedProperties:u,isSwitcherChecked:p,setIsSwitcherChecked:x,activeTimePeriod:h,dateRange:g,tempDateRange:y,isCalendarOpen:f,isLoadingProperties:b,propertyOptions:v,control:N,isDataLoading:j,statisticsParams:_,handleOrganizationsChange:w,handlePropertiesChange:k,handleTimePeriodChange:C,handleCalendarOpenChange:S,handleTempDateRangeChange:E,handleDateRangeReset:L,handleDateRangeApply:A,showUnitsCount:D=!0,showCustomDateRange:O=!0,showTimePeriodTabs:T=!0,showTodaysData:I=!0,showOnlyActiveLeaks:P=!1,showComparisonSelect:R=!1,comparison:M,handleComparisonChange:G,showBackButton:z=!1,handleBackButtonClick:F,showBedCount:H=!1,selectedBedCount:V,onBedCountChange:U,isBedCountFilterOpen:B,setIsBedCountFilterOpen:K,excludeFromSelectAll:W=[ao.f]}=e,{isOrgAdmin:Y,isOrgMember:$}=(0,eC.J)(),Z=Y||$,[q,J]=(0,r.useState)(!1);return(0,l.jsxs)("div",{children:[(0,l.jsxs)("div",{className:(0,i.cn)("flex flex-wrap",D?"xl:flex-row xl:items-center":"md:flex-row md:items-center","justify-between gap-3 mb-3"),children:[(0,l.jsxs)("div",{className:(0,i.cn)("flex items-center",z&&"gap-2"),children:[z&&(0,l.jsx)(eo.A,{className:"w-8 h-8 text-brand-dark-gray cursor-pointer",onClick:()=>{null==F||F()}}),(0,l.jsx)("h1",{className:"text-lg 2xl:text-xl font-bold text-cyan-900",children:t})]}),(0,l.jsxs)("div",{className:"flex flex-row items-center justify-between gap-3 lg:gap-8 flex-wrap",children:[(0,l.jsx)("div",{className:"flex flex-col gap-3",children:D&&n.length>0&&(0,l.jsx)("div",{className:"flex shrink-0 items-center gap-3",children:(0,l.jsx)(ai,{params:_})})}),(0,l.jsxs)(e$.$,{variant:"tertiary",className:"w-36 h-12 px-3 border border-cyan-300 text-brand-dark-gray hover:bg-cyan-50",onClick:()=>J(!q),children:[(0,l.jsx)(an.A,{className:"w-5 h-5"}),q?"Show Filters":"Hide Filters"]})]})]}),(0,l.jsx)("div",{className:(0,i.cn)("bg-white rounded-xl shadow-custom-tile py-3 px-5 mb-5 transition-all duration-300 ease-in-out",q?"max-h-0 py-0 mb-0 opacity-0 pointer-events-none":"max-h-[500px] opacity-100"),children:(0,l.jsxs)("div",{className:"flex items-center flex-wrap justify-between gap-4",children:[(0,l.jsxs)("div",{className:(0,i.cn)("w-full md:w-auto flex flex-col items-start gap-3",P||H?"lg:flex-row lg:items-center":"md:flex-row md:items-center"),children:[s.length>1&&!Z&&(0,l.jsx)("div",{className:"w-full md:w-60 2xl:w-80",children:(0,l.jsx)(sm,{placeholder:"Select Organizations",control:N,name:"organizations",options:s.map(e=>({label:e.name,value:e.id.toString()})),showSelectAll:!0,onSelectionChange:d,onMenuClose:()=>o!==n&&w(o),clearButton:!1,isDisabled:j})}),(0,l.jsx)("div",{className:"w-full md:w-60 2xl:w-80",children:b?(0,l.jsx)("div",{className:"flex justify-center p-4",children:(0,l.jsx)(ee.A,{className:"h-6 w-6 animate-spin text-brand-dark-cyan"})}):!Z||(null==v?void 0:v.length)>1&&Z?(0,l.jsx)(sm,{placeholder:"Select Properties",control:N,name:"properties",o
1ptions:v,showSelectAll:!0,excludeFromSelectAll:W,onSelectionChange:u,onMenuClose:()=>m!==c&&k(m),clearButton:!1,isDisabled:j}):(0,l.jsxs)("div",{className:"flex items-center",children:[(0,l.jsx)(el.A,{strokeWidth:1.5,className:"w-6 h-6 text-brand-dark-gray mr-3"}),(0,l.jsx)("span",{className:"text-base font-semibold text-brand-black max-w-[calc(100%-36px)] truncate",children:null==v||null==(a=v[0])?void 0:a.label})]})}),P&&(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)(sv,{checked:p,onCheckedChange:x}),(0,l.jsx)("span",{className:"text-sm font-medium cursor-pointer select-none",onClick:()=>x(!p),children:"Only Active Leaks"})]}),H&&(0,l.jsx)(at,{isPopoverOpen:null!=B&&B,setIsPopoverOpen:null!=K?K:()=>{},selectedBedCount:null!=V?V:{from:0,to:7},onBedCountChange:null!=U?U:()=>{},isDisabled:j})]}),(0,l.jsxs)("div",{className:(0,i.cn)("flex items-center flex-wrap gap-4",R?"overflow-x-visible":"overflow-hidden"),children:[I&&(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("span",{className:"text-sm font-medium cursor-pointer select-none",onClick:()=>x(!p),children:"Show Today's Data"}),(0,l.jsx)(sv,{checked:p,onCheckedChange:x})]}),T&&(0,l.jsx)(tW,{value:h,onValueChange:e=>C(e),className:(0,i.cn)(j?"opacity-50 pointer-events-none":"","w-full md:w-auto overflow-x-auto md:overflow-x-hidden whitespace-nowrap flex-nowrap flex snap-x snap-mandatory scroll-smooth no-scrollbar"),children:(0,l.jsxs)(t$,{size:"lg",children:[(0,l.jsx)(tq,{size:"lg",value:"yesterday",children:"Yesterday"}),(0,l.jsx)(tq,{size:"lg",value:"last-7-days",children:"Last 7 days"}),(0,l.jsx)(tq,{size:"lg",value:"last-30-days",children:"Last 30 days"})]})}),O&&(0,l.jsx)(l1,{dateRange:g||{from:new Date,to:new Date},tempDateRange:y||{from:new Date,to:new Date},isCalendarOpen:f,onCalendarOpenChange:S,onTempDateRangeChange:E,onReset:L,onApply:A,isActive:"custom-date-range"===h,isDisabled:j}),R&&(0,l.jsx)("div",{className:"w-64",children:(0,l.jsx)(su.R,{placeholder:"Select Comparison",name:"comparison",options:ad(h),value:ad(h).find(e=>e.value===M),onChange:e=>{null==G||G((null==e?void 0:e.value)||"")},className:"bg-white rounded-lg",isSearchable:!1,height:"h-11"},h)})]})]})})]})}var am=t(15870),au=t(46767);let ap="Enabled for single-property reports";function ax(e){var a;let{statuses:t,deviceTypes:s,buildings:n,organizations:o,selectedProperties:d,tempSelectedOrganizations:c,setTempSelectedOrganizations:m,tempSelectedProperties:u,setTempSelectedProperties:p,date:x,tempDate:h,selectedBuilding:g,tempSelectedBuilding:y,selectedStatus:f,tempSelectedStatus:b,selectedDeviceType:v,tempSelectedDeviceType:N,isCalendarOpen:j,isBuildingOpen:_,isStatusOpen:w,isDeviceTypeOpen:k,isLoadingProperties:C,propertyOptions:S,control:E,isDataLoading:L,handleOrganizationsChange:A,handlePropertiesChange:D,handleCalendarOpenChange:O,handleBuildingOpenChange:T,handleStatusOpenChange:I,handleDeviceTypeOpenChange:P,handleTempDateChange:R,handleDateReset:M,handleDateApply:G,handleResetAll:z,handleBuildingChange:F,handleStatusChange:H,handleDeviceTypeChange:V,handleApplyBuilding:U,handleApplyStatus:B,handleApplyDeviceType:K,handleResetBuilding:W,handleResetStatus:Y,handleResetDeviceType:$,buildingSearch:Z,handleBuildingSearchChange:q,isLoadingBuildings:J,isLoadingStatuses:X,showSettingsButton:Q=!1,deviceHealthBoundaries:ea}=e,{isOrgAdmin:et,isOrgMember:es}=(0,eC.J)(),er=et||es,[en,ei]=(0,r.useState)(!1),[eo,ed]=(0,r.useState)(!1),ec=1===d.length;return(0,l.jsxs)("div",{children:[(0,l.jsxs)("div",{className:"flex justify-between items-center mb-3",children:[(0,l.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,l.jsx)("h1",{className:"text-xl font-bold text-cyan-900",children:"Gateway & Device Health"}),(0,l.jsx)("p",{className:"text-base text-brand-dark-gray",children:"Monitor and manage device connectivity across properties"})]}),(0,l.jsxs)(e$.$,{variant:"tertiary",className:"w-36 h-12 px-3 border border-cyan-300 text-brand-dark-gray hover:bg-cyan-50",onClick:()=>ei(!en),children:[(0,l.jsx)(an.A,{className:"w-5 h-5"}),en?"Show Filters":"Hide Filters"]})]}),(0,l.jsx)("div",{className:(0,i.cn)("bg-white rounded-xl shadow-custom-tile py-3 px-5 mb-5 transition-all duration-300 ease-in-out",en?"max-h-0 py-0 mb-0 opacity-0 pointer-events-none":"max-h-[500px] opacity-100"),children:(0,l.jsxs)("div",{className:(0,i.cn)("flex items-center justify-between gap-3",Q?"flex-wrap align-start":""),children:[(0,l.jsxs)("div",{className:"flex flex-row items-center flex-wrap gap-2 2xl:gap-3",children:[o.length>1&&!er&&(0,l.jsx)("div",{className:(0,i.cn)("w-full md:w-60",Q?"4xl:w-80":"2xl:w-80"),children:(0,l.jsx)(sm,{placeholder:"Select Organizations",control:E,name:"organizations",options:o.map(e=>({label:e.name,value:e.id.toString()})),showSelectAll:!0,onSelectionChange:m,onMenuClose:()=>c&&A(c),clearButton:!1,isDisabled:L,labelMaxWidth:"4xl:max-w-64"})}),(0,l.jsx)("div",{className:(0,i.cn)("w-full md:w-60",Q?"4xl:w-80":"2xl:w-80"),children:C?(0,l.jsx)("div",{className:"flex justify-center p-4",children:(0,l.jsx)(ee.A,{className:"h-6 w-6 animate-spin text-brand-dark-cyan"})}):!er||(null==S?void 0:S.length)>1&&er?(0,l.jsx)(sm,{placeholder:"Select Properties",control:E,name:"properties",o
1ptions:S,showSelectAll:!0,excludeFromSelectAll:[ao.f],onSelectionChange:p,onMenuClose:()=>D(u),clearButton:!1,isDisabled:L,labelMaxWidth:"4xl:max-w-64"}):(0,l.jsxs)("div",{className:"flex items-center",children:[(0,l.jsx)(el.A,{strokeWidth:1.5,className:"w-6 h-6 text-brand-dark-gray mr-3"}),(0,l.jsx)("span",{className:"text-base font-semibold text-brand-black max-w-[calc(100%-36px)] truncate",children:null==S||null==(a=S[0])?void 0:a.label})]})}),J?(0,l.jsx)("div",{className:"flex justify-center p-4",children:(0,l.jsx)(ee.A,{className:"h-6 w-6 animate-spin text-brand-dark-cyan"})}):(0,l.jsx)(au.TooltipProvider,{delayDuration:150,children:(0,l.jsxs)(au.m_,{children:[(0,l.jsx)(au.k$,{asChild:!0,children:(0,l.jsx)("div",{children:(0,l.jsx)(as,{isPopoverOpen:_,setIsPopoverOpen:T,buildings:n.map(e=>({id:e.id,name:e.name,property_name:e.property_name||""})),selectedBuilding:g,tempSelectedBuilding:y,setTempSelectedBuilding:F,handleReset:W,handleApply:U,searchValue:Z,onSearchChange:q,disabled:L||!ec})})}),!ec&&(0,l.jsx)(au.ZI,{children:ap})]})}),X?(0,l.jsx)("div",{className:"flex justify-center p-4",children:(0,l.jsx)(ee.A,{className:"h-6 w-6 animate-spin text-brand-dark-cyan"})}):(0,l.jsx)(aE,{isPopoverOpen:w,setIsPopoverOpen:I,statuses:t,selectedStatus:f,tempSelectedStatus:b,setTempSelectedStatus:H,handleReset:Y,handleApply:B,disabled:L}),X?(0,l.jsx)("div",{className:"flex justify-center p-4",children:(0,l.jsx)(ee.A,{className:"h-6 w-6 animate-spin text-brand-dark-cyan"})}):(0,l.jsx)(ar,{isPopoverOpen:k,setIsPopoverOpen:P,deviceTypes:s,selectedDeviceType:v,tempSelectedDeviceType:N,setTempSelectedDeviceType:V,handleReset:$,handleApply:K,disabled:L}),(0,l.jsx)(e$.$,{variant:"tertiary",onClick:()=>z(),disabled:L,className:"text-sm font-medium text-brand-dark-gray underline p-0 hover:text-brand-dark-cyan",children:"Reset filters"})]}),(0,l.jsxs)("div",{className:"flex flex-row items-center gap-2 2xl:gap-3 flex-wrap",children:[Q&&(0,l.jsx)(e$.$,{variant:"secondary",icon:am.A,className:"h-12 text-sm 2xl:text-base px-2 2xl:px-4 [&_svg]:block xl:[&_svg]:hidden 2xl:[&_svg]:block",onClick:()=>ed(!0),children:"Device Reporting Thresholds"}),(0,l.jsx)(l0,{date:x,tempDate:h,isCalendarOpen:j,onCalendarOpenChange:O,onTempDateChange:R,onReset:M,onApply:G,isDisabled:L})]})]})}),(0,l.jsx)(eE,{open:eo,onOpenChange:ed,deviceHealthBoundaries:ea})]})}function ah(e){var a;let{title:t,organizations:s,selectedOrganizations:n,tempSelectedOrganizations:o,setTempSelectedOrganizations:d,selectedProperties:c,tempSelectedProperties:m,setTempSelectedProperties:u,isSwitcherChecked:p,setIsSwitcherChecked:x,activeTimePeriod:h,dateRange:g,tempDateRange:y,isCalendarOpen:f,isLoadingProperties:b,propertyOptions:v,control:N,isDataLoading:j,statisticsParams:_,handleOrganizationsChange:w,handlePropertiesChange:k,handleCalendarOpenChange:C,handleTempDateRangeChange:S,handleDateRangeReset:E,handleDateRangeApply:L,buildingFilters:A,unitFilters:D,selectedBuildings:O,setSelectedBuildings:T,selectedUnits:I,setSelectedUnits:P,buildingFilterOpen:R,setBuildingFilterOpen:M,unitFilterOpen:G,setUnitFilterOpen:z,handleResetAll:F,showUnitsCount:H=!0}=e,{isOrgAdmin:V,isOrgMember:U}=(0,eC.J)(),B=V||U,[K,W]=(0,r.useState)(!1),Y=1===c.length;return(0,l.jsxs)("div",{children:[(0,l.jsxs)("div",{className:(0,i.cn)("flex flex-wrap",H?"xl:flex-row xl:items-center":"md:flex-row md:items-center","justify-between gap-3 mb-3"),children:[(0,l.jsx)("div",{className:(0,i.cn)("flex items-center"),children:(0,l.jsx)("h1",{className:"text-xl font-bold text-cyan-900",children:t})}),(0,l.jsxs)("div",{className:"flex flex-col lg:flex-row lg:items-center justify-between gap-3 lg:gap-8",children:[(0,l.jsx)("div",{className:"flex flex-col gap-3",children:H&&n.length>0&&(0,l.jsx)("div",{className:"flex shrink-0 items-center gap-3",children:(0,l.jsx)(ai,{params:_})})}),(0,l.jsxs)(e$.$,{variant:"tertiary",className:"w-36 h-12 px-3 border border-cyan-300 text-brand-dark-gray hover:bg-cyan-50",onClick:()=>W(!K),children:[(0,l.jsx)(an.A,{className:"w-5 h-5"}),K?"Show Filters":"Hide Filters"]})]})]}),(0,l.jsx)("div",{className:(0,i.cn)("bg-white rounded-xl shadow-custom-tile py-3 px-5 mb-5 transition-all duration-300 ease-in-out",K?"max-h-0 py-0 mb-0 opacity-0 pointer-events-none":"max-h-[500px] opacity-100"),children:(0,l.jsxs)("div",{className:"flex items-center flex-wrap justify-between gap-4",children:[(0,l.jsxs)("div",{className:"w-full md:w-auto flex flex-col items-start gap-3 md:flex-row md:items-center md:flex-wrap",children:[s.length>1&&!B&&(0,l.jsx)("div",{className:"w-full md:w-60 2xl:w-80",children:(0,l.jsx)(sm,{placeholder:"Select Organizations",control:N,name:"organizations",options:s.map(e=>({label:e.name,value:e.id.toString()})),showSelectAll:!0,onSelectionChange:d,onMenuClose:()=>o!==n&&w(o),clearButton:!1,isDisabled:j})}),(0,l.jsx)("div",{className:"w-full md:w-60 2xl:w-80",children:b?(0,l.jsx)("div",{className:"flex justify-center p-4",children:(0,l.jsx)(ee.A,{className:"h-6 w-6 animate-spin text-brand-dark-cyan"})}):!B||(null==v?void 0:v.length)>1&&B?(0,l.jsx)(sm,{placeholder:"Select Properties",control:N,name:"properties",o
1ptions:v,showSelectAll:!0,excludeFromSelectAll:[ao.f],onSelectionChange:u,onMenuClose:()=>m!==c&&k(m),clearButton:!1,isDisabled:j}):(0,l.jsxs)("div",{className:"flex items-center",children:[(0,l.jsx)(el.A,{strokeWidth:1.5,className:"w-6 h-6 text-brand-dark-gray mr-3"}),(0,l.jsx)("span",{className:"text-base font-semibold text-brand-black max-w-[calc(100%-36px)] truncate",children:null==v||null==(a=v[0])?void 0:a.label})]})}),(0,l.jsxs)(au.TooltipProvider,{delayDuration:150,children:[(0,l.jsxs)(au.m_,{children:[(0,l.jsx)(au.k$,{asChild:!0,children:(0,l.jsx)("div",{children:(0,l.jsx)(eq,{title:"Building",options:A.data,initialValues:A.initial,selectedValues:O,onSelectedChange:T,isOpen:R,onOpenChange:M,isDisabled:!Y||0===A.initial.length||A.loading||j})})}),!Y&&(0,l.jsx)(au.ZI,{children:ap})]}),(0,l.jsxs)(au.m_,{children:[(0,l.jsx)(au.k$,{asChild:!0,children:(0,l.jsx)("div",{children:(0,l.jsx)(eq,{title:"Unit",options:D.data,initialValues:D.initial,selectedValues:I,onSelectedChange:P,isOpen:G,onOpenChange:z,isDisabled:!Y||0===O.length||0===D.initial.length||D.loading||j})})}),!Y&&(0,l.jsx)(au.ZI,{children:ap})]})]}),(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)(sv,{checked:p,onCheckedChange:x}),(0,l.jsx)("span",{className:"text-sm font-medium cursor-pointer select-none",onClick:()=>x(!p),children:"Only Active Leaks"})]}),(0,l.jsx)(e$.$,{variant:"tertiary",onClick:()=>F(),disabled:j,className:"text-sm font-medium text-brand-dark-gray underline p-0 hover:text-brand-dark-cyan",children:"Reset filters"})]}),(0,l.jsx)(l1,{dateRange:g||{from:new Date,to:new Date},tempDateRange:y||{from:new Date,to:new Date},isCalendarOpen:f,onCalendarOpenChange:C,onTempDateRangeChange:S,onReset:E,onApply:L,isActive:"custom-date-range"===h,isDisabled:j})]})})]})}let ag=[{value:"yearly",label:"Yearly"},{value:"monthly",label:"Monthly"},{value:"bills",label:"Per bill"}],ay=[{value:"both",label:"Both"},{value:"pre",label:"Pre-ION"},{value:"post",label:"Post-ION"}],af=[{value:"water",label:"Water"},{value:"sewer",label:"Sewer"},{value:"storm_water",label:"Storm water"},{value:"irrigation",label:"Irrigation"}],ab=[{value:"installed",label:"Installed only"},{value:"not_installed",label:"Not installed"},{value:"all",label:"All properties"}],av=[{value:"all",label:"All"},{value:"new_construction",label:"New construction"},{value:"operating",label:"Operating"},{value:"unknown",label:"Type not on file"}];function aN(e){var a,t,s,n,i;let{title:o,organizations:d,control:c,selectedOrganizations:m,tempSelectedOrganizations:u,setTempSelectedOrganizations:p,onOrganizationsApply:x,propertyOptions:h,selectedProperties:g,tempSelectedProperties:y,setTempSelectedProperties:f,onPropertiesApply:b,isLoadingProperties:v,isLoading:N,grain:j,onGrainChange:_,phase:w,onPhaseChange:k,utility:C,onUtilityChange:S,coverage:E,onCoverageChange:L,constructionType:A,onConstructionTypeChange:D,buildTypeCounts:O}=e,T=(0,r.useMemo)(()=>[...d].sort((e,a)=>e.name.localeCompare(a.name)).map(e=>({value:String(e.id),label:e.name})),[d]),I=(0,r.useMemo)(()=>av.map(e=>{var a;if("all"===e.value||!O)return e;let t=null!=(a=O[e.value])?a:0;return{...e,label:"".concat(e.label," (").concat(t,")")}}),[O]);return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("div",{className:"flex flex-wrap justify-between gap-3 mb-3",children:(0,l.jsx)("h1",{className:"text-lg 2xl:text-xl font-bold text-cyan-900",children:o})}),(0,l.jsx)("div",{className:"bg-white rounded-xl shadow-custom-tile py-3 px-5 mb-5 transition-all duration-300 ease-in-out",children:(0,l.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,l.jsxs)("div",{className:"w-full flex flex-col items-start gap-3 md:flex-row md:items-center",children:[(0,l.jsx)("div",{className:"w-full md:w-60 2xl:w-80",children:(0,l.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,l.jsx)(l3,{children:"Organization"}),(0,l.jsx)(sm,{placeholder:"Select Organization",control:c,name:"organizations",options:T,onSelectionChange:e=>p(e.slice(-1)),onMenuClose:()=>u!==m&&x(u),clearButton:!1,isDisabled:N||0===T.length})]})}),m.length>0&&(0,l.jsx)("div",{className:"w-full md:w-60 2xl:w-80",children:(0,l.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,l.jsx)(l3,{children:"Property"}),v?(0,l.jsx)("div",{className:"flex justify-center p-2",children:(0,l.jsx)(ee.A,{className:"h-5 w-5 animate-spin text-brand-dark-cyan"})}):(0,l.jsx)(sm,{placeholder:"All properties",control:c,name:"properties",o
1ptions:h,showSelectAll:!0,onSelectionChange:f,onMenuClose:()=>y!==g&&b(y),clearButton:!1,isDisabled:N})]})}),(0,l.jsx)("div",{className:"w-full md:w-52",children:(0,l.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,l.jsx)(l3,{htmlFor:"municipal-build-type",children:"Property type"}),(0,l.jsx)(su.R,{inputId:"municipal-build-type",options:I,value:null!=(a=I.find(e=>e.value===(null!=A?A:"all")))?a:null,onChange:e=>e&&D("all"===e.value?null:e.value),isSearchable:!1,isClearable:!1})]})}),(0,l.jsx)("div",{className:"w-full md:w-48",children:(0,l.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,l.jsx)(l3,{htmlFor:"municipal-grain",children:"Grain"}),(0,l.jsx)(su.R,{inputId:"municipal-grain",options:ag,value:null!=(t=ag.find(e=>e.value===j))?t:null,onChange:e=>e&&_(e.value),isSearchable:!1,isClearable:!1})]})})]}),(0,l.jsxs)("div",{className:"w-full flex flex-col items-start gap-3 md:flex-row md:items-center",children:[(0,l.jsx)("div",{className:"w-full md:w-44",children:(0,l.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,l.jsx)(l3,{htmlFor:"municipal-phase",children:"Install phase"}),(0,l.jsx)(su.R,{inputId:"municipal-phase",options:ay,value:null!=(s=ay.find(e=>e.value===w))?s:null,onChange:e=>e&&k(e.value),isSearchable:!1,isClearable:!1})]})}),(0,l.jsx)("div",{className:"w-full md:w-44",children:(0,l.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,l.jsx)(l3,{htmlFor:"municipal-utility",children:"Utility"}),(0,l.jsx)(su.R,{inputId:"municipal-utility",options:af,value:null!=(n=af.find(e=>e.value===C))?n:null,onChange:e=>e&&S(e.value),isSearchable:!1,isClearable:!1})]})}),(0,l.jsx)("div",{className:"w-full md:w-48",children:(0,l.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,l.jsx)(l3,{htmlFor:"municipal-coverage",children:"Platform coverage"}),(0,l.jsx)(su.R,{inputId:"municipal-coverage",options:ab,value:null!=(i=ab.find(e=>e.value===E))?i:null,onChange:e=>e&&L(e.value),isSearchable:!1,isClearable:!1})]})})]})]})})]})}function aj(e){let{isPopoverOpen:a,setIsPopoverOpen:t,organizationSearch:s,setOrganizationSearch:r,filteredOrganizations:n,selectedOrganizations:i,tempSelectedOrganizations:o,setTempSelectedOrganizations:d,handleReset:c,handleApply:m}=e;return(0,l.jsxs)(lJ,{open:a,onOpenChange:t,children:[(0,l.jsx)(lX,{asChild:!0,children:(0,l.jsxs)(e$.$,{variant:"secondary",className:"h-9 flex items-center gap-3 border border-brand-stroke text-brand-dark-gray text-sm font-normal relative",children:[(0,l.jsxs)("span",{className:"relative",children:["Organization",i.length>0&&" (".concat(i.length,")"),(0,l.jsx)("span",{className:"inline-block absolute right--2 top-0 rounded-full bg-brand-clean-blue w-1.5 h-1.5 transition-opacity duration-200 ".concat(i.length>0?"opacity-100":"opacity-0")})]}),(0,l.jsx)(eu.A,{className:"h-5 w-5 text-brand-dark-gray transition-transform duration-200 ".concat(a?"rotate-180":"")})]})}),(0,l.jsx)(lQ,{className:"w-[274px] h-96 overflow-hidden p-0",align:"end",children:(0,l.jsxs)("div",{className:"h-full",children:[(0,l.jsx)("div",{className:"px-3 pt-2",children:(0,l.jsx)(l2,{placeholder:"Search by organization name",value:s,onChange:e=>r(e.target.value),className:"h-8",icon:al.A})}),(0,l.jsx)("div",{className:"space-y-1 h-[280px] overflow-y-auto p-1",children:n.map(e=>(0,l.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded-md hover:bg-cyan-light",children:[(0,l.jsx)(lZ,{id:"org-".concat(e.id),checked:o.includes(e.id.toString()),onCheckedChange:a=>{d(t=>a?[...t,e.id.toString()]:t.filter(a=>a!==e.id.toString()))}}),(0,l.jsx)("label",{htmlFor:"org-".concat(e.id),className:"text-sm font-normal leading-none truncate flex-1 peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:e.name})]},e.id))}),(0,l.jsxs)("div",{className:"flex gap-2 pt-3 px-4 border-t border-blue-medium",children:[(0,l.jsx)(e$.$,{variant:"tertiary",className:"w-full",onClick:c,children:"Clear"}),(0,l.jsx)(e$.$,{variant:"primary",className:"w-full",onClick:m,children:"Apply"})]})]})})]})}function a_(e){let{isPopoverOpen:a,setIsPopoverOpen:t,properties:s,selectedProperties:r,tempSelectedProperties:n,setTempSelectedProperties:i,handleReset:o,handleApply:d}=e;return(0,l.jsxs)(lJ,{open:a,onOpenChange:t,children:[(0,l.jsx)(lX,{asChild:!0,children:(0,l.jsxs)(e$.$,{variant:"secondary",className:"h-9 flex items-center gap-3 border border-brand-stroke text-brand-dark-gray text-sm font-normal relative",children:["Properties",r.length>0&&" (".concat(r.length,")"),(0,l.jsx)(eu.A,{className:"h-5 w-5 text-brand-dark-gray transition-transform duration-200 ".concat(a?"rotate-180":"")}),(0,l.jsx)("div",{className:"absolute right-10 top-2 rounded-full bg-brand-clean-blue w-1.5 h-1.5 transition-opacity duration-200 ".concat(r.length>0?"opacity-100":"opacity-0")})]})}),(0,l.jsx)(lQ,{className:"w-60 p-0",align:"end",children:(0,l.jsxs)("div",{className:"space-y-3",children:[(0,l.jsx)("div",{className:"space-y-1",children:(0,l.jsx)("div",{className:"space-y-1 pt-1",children:s.map(e=>(0,l.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded-md hover:bg-cyan-50 pointer-events-auto hover:cursor-pointer",onClick:()=>{i(n.includes(e.id.toString())?n.filter(a=>
1a!==e.id.toString()):[...n,e.id.toString()])},children:[(0,l.jsx)(lZ,{checked:n.includes(e.id.toString()),onCheckedChange:a=>{i(a?[...n,e.id.toString()]:n.filter(a=>a!==e.id.toString()))}}),(0,l.jsx)("span",{className:"text-sm select-none",children:e.name})]},e.id))})}),(0,l.jsxs)("div",{className:"flex justify-between gap-6 px-4 py-3 border-t border-brand-stroke",children:[(0,l.jsx)(e$.$,{variant:"tertiary",className:"w-full",onClick:o,children:"Reset"}),(0,l.jsx)(e$.$,{className:"w-full",onClick:d,children:"Apply"})]})]})})]})}function aw(e){let{isSwitcherChecked:a,setIsSwitcherChecked:t,activeTimePeriod:s,dateRange:r,tempDateRange:n,isCalendarOpen:o,isDataLoading:d,handleTimePeriodChange:c,handleCalendarOpenChange:m,handleTempDateRangeChange:u,handleDateRangeReset:p,handleDateRangeApply:x,buildingFilters:h,unitFilters:g,selectedBuildings:y,setSelectedBuildings:f,selectedUnits:b,setSelectedUnits:v,buildingFilterOpen:N,setBuildingFilterOpen:j,unitFilterOpen:_,setUnitFilterOpen:w,handleResetAll:k}=e;return(0,l.jsx)("div",{className:"bg-white rounded-xl shadow-custom-tile py-3 px-6 mb-8",children:(0,l.jsxs)("div",{className:"flex items-center flex-wrap justify-between gap-4",children:[(0,l.jsxs)("div",{className:"flex flex-row items-center gap-3 flex-wrap",children:[(0,l.jsx)(eq,{title:"Building",options:h.data,initialValues:h.initial,selectedValues:y,onSelectedChange:f,isOpen:N,onOpenChange:j,isDisabled:0===h.initial.length||h.loading||d}),(0,l.jsx)(eq,{title:"Unit",options:g.data,initialValues:g.initial,selectedValues:b,onSelectedChange:v,isOpen:_,onOpenChange:w,isDisabled:0===g.initial.length||g.loading||d}),(0,l.jsxs)("div",{className:"flex items-center gap-2 ".concat(d?"opacity-50 cursor-not-allowed":""),children:[(0,l.jsx)(sv,{checked:a,onCheckedChange:t}),(0,l.jsx)("span",{className:"text-sm font-medium cursor-pointer select-none",onClick:()=>t(!a),children:"Only Active Leaks"})]}),(0,l.jsx)(e$.$,{variant:"tertiary",onClick:()=>k(),disabled:d,className:"text-sm font-medium text-brand-dark-gray underline p-0 hover:text-brand-dark-cyan",children:"Reset filters"})]}),(0,l.jsxs)("div",{className:"flex items-center flex-wrap gap-4 overflow-hidden",children:[(0,l.jsx)(tW,{value:s,onValueChange:e=>c(e),className:(0,i.cn)(d?"opacity-50 pointer-events-none":"","w-full md:w-auto overflow-x-auto md:overflow-x-hidden whitespace-nowrap flex-nowrap flex snap-x snap-mandatory scroll-smooth no-scrollbar"),children:(0,l.jsxs)(t$,{size:"lg",children:[(0,l.jsx)(tq,{size:"lg",value:"yesterday",children:"Yesterday"}),(0,l.jsx)(tq,{size:"lg",value:"last-7-days",children:"Last 7 days"}),(0,l.jsx)(tq,{size:"lg",value:"last-30-days",children:"Last 30 days"})]})}),(0,l.jsx)(l1,{dateRange:r||{from:new Date,to:new Date},tempDateRange:n||{from:new Date,to:new Date},isCalendarOpen:o,onCalendarOpenChange:m,onTempDateRangeChange:u,onReset:p,onApply:x,isActive:"custom-date-range"===s,isDisabled:d})]})]})})}function ak(e){let{isPopoverOpen:a,setIsPopoverOpen:t,roles:s,selectedRole:r,tempSelectedRole:n,setTempSelectedRole:i,handleReset:o,handleApply:d}=e;return(0,l.jsxs)(lJ,{open:a,onOpenChange:t,children:[(0,l.jsx)(lX,{asChild:!0,children:(0,l.jsxs)(e$.$,{variant:"secondary",className:"h-9 flex items-center gap-3 border border-brand-stroke text-brand-dark-gray text-sm font-normal relative",children:[(0,l.jsxs)("span",{className:"relative",children:["Role",r.length>0&&" (".concat(r.length,")"),(0,l.jsx)("span",{className:"inline-block absolute right--2 top-0 rounded-full bg-brand-clean-blue w-1.5 h-1.5 transition-opacity duration-200 ".concat(r.length>0?"opacity-100":"opacity-0")})]}),(0,l.jsx)(eu.A,{className:"h-5 w-5 text-brand-dark-gray transition-transform duration-200 ".concat(a?"rotate-180":"")})]})}),(0,l.jsx)(lQ,{className:"w-60 p-0",align:"start",children:(0,l.jsxs)("div",{className:"space-y-3",children:[(0,l.jsx)("div",{className:"space-y-1",children:(0,l.jsx)("div",{className:"space-y-1 pt-1",children:s.map(e=>(0,l.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded-md hover:bg-cyan-50 pointer-events-auto hover:cursor-pointer",onClick:()=>{i(n.includes(e.id.toString())?n.filter(a=>
1a!==e.id.toString()):[...n,e.id.toString()])},children:[(0,l.jsx)(lZ,{checked:n.includes(e.id.toString()),onCheckedChange:a=>{i(a?[...n,e.id.toString()]:n.filter(a=>a!==e.id.toString()))}}),(0,l.jsx)("span",{className:"text-sm select-none",children:e.name})]},e.id))})}),(0,l.jsxs)("div",{className:"flex justify-between gap-6 px-4 py-3 border-t border-brand-stroke",children:[(0,l.jsx)(e$.$,{variant:"tertiary",className:"w-full",onClick:o,children:"Reset"}),(0,l.jsx)(e$.$,{className:"w-full",onClick:d,children:"Apply"})]})]})})]})}var aC=t(82983);function aS(e){let{isPopoverOpen:a,setIsPopoverOpen:t,organizationSearch:s,setOrganizationSearch:r,filteredOrganizations:n,selectedOrganizations:i,selectedProperties:o,organizationProperties:d,loadingProperties:c,tempSelectedOrganizations:m,setTempSelectedOrganizations:u,tempSelectedProperties:p,setTempSelectedProperties:x,handleReset:h,handleApply:g,fetchOrganizationProperties:y}=e,f=(0,aC.r)(i,m)&&(0,aC.r)(Object.values(o).flat(),Object.values(p).flat());return(0,l.jsxs)(lJ,{open:a,onOpenChange:t,children:[(0,l.jsx)(lX,{asChild:!0,children:(0,l.jsxs)(e$.$,{variant:"secondary",className:"h-9 flex items-center gap-3 border border-brand-stroke text-brand-dark-gray text-sm font-normal relative",children:[(0,l.jsxs)("span",{className:"relative",children:["Organizations | Properties",i.length>0&&" (".concat(i.length,")"),(0,l.jsx)("span",{className:"inline-block absolute right--2 top-0 rounded-full bg-brand-clean-blue w-1.5 h-1.5 transition-opacity duration-200 ".concat(i.length>0||Object.values(o).flat().length>0?"opacity-100":"opacity-0")})]}),(0,l.jsx)(eu.A,{className:"h-5 w-5 text-brand-dark-gray transition-transform duration-200 ".concat(a?"rotate-180":"")})]})}),(0,l.jsx)(lQ,{className:"w-80 p-0",align:"end",children:(0,l.jsxs)("div",{className:"space-y-3 h-96 overflow-hidden",children:[(0,l.jsx)("div",{className:"px-2 pt-2",children:(0,l.jsx)(l2,{placeholder:"Search organizations",value:s,onChange:e=>r(e.target.value),className:"h-8",icon:al.A})}),(0,l.jsx)("div",{className:"space-y-1 h-64 overflow-y-auto",children:n.map(e=>{var a;return(0,l.jsx)(lS,{type:"single",collapsible:!0,onValueChange:a=>{a&&!d[e.id.toString()]&&y(e.id.toString())},children:(0,l.jsxs)(lE,{value:e.id.toString(),className:"border-0",children:[(0,l.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded-md hover:bg-cyan-light",children:[(0,l.jsx)(lZ,{id:"org-".concat(e.id),checked:m.includes(e.id.toString()),onCheckedChange:a=>{u(a?[...m,e.id.toString()]:m.filter(a=>a!==e.id.toString()))}}),(0,l.jsx)("label",{htmlFor:"org-".concat(e.id),className:"text-sm font-normal leading-none truncate flex-1 peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:e.name}),(0,l.jsx)(lL,{className:"hover:no-underline py-0 ml-2 [&_svg]:w-5 [&_svg]:h-5"})]}),(0,l.jsx)(lA,{className:"pl-6 pb-1",children:(0,l.jsx)("div",{className:"space-y-1 pt-1",children:c[e.id.toString()]?(0,l.jsx)("div",{className:"flex justify-center py-2",children:(0,l.jsx)(ee.A,{className:"h-4 w-4 animate-spin"})}):null==(a=d[e.id.toString()])?void 0:a.map(a=>{var t;return(0,l.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded-md hover:bg-cyan-light",children:[(0,l.jsx)(lZ,{checked:null==(t=p[e.id.toString()])?void 0:t.includes(a.id.toString()),onCheckedChange:t=>{x({...p,[e.id.toString()]:t?[...p[e.id.toString()]||[],a.id.toString()]:(p[e.id.toString()]||[]).filter(e=>e!==a.id.toString())})}}),(0,l.jsx)("span",{className:"text-sm",children:a.name})]},a.id)})})})]})},e.id)})}),(0,l.jsxs)("div",{className:"flex justify-between gap-6 px-4 py-3 border-t border-brand-stroke",children:[(0,l.jsx)(e$.$,{variant:"tertiary",className:"w-full",onClick:h,children:"Reset"}),(0,l.jsx)(e$.$,{className:"w-full",onClick:g,disabled:f,children:"Apply"})]})]})})]})}function aE(e){let{isPopoverOpen:a,setIsPopoverOpen:t,statuses:s,selectedStatus:r,tempSelectedStatus:n,setTempSelectedStatus:i,handleReset:o,handleApply:d,disabled:c}=e;return(0,l.jsxs)(lJ,{open:a,onOpenChange:t,children:[(0,l.jsx)(lX,{asChild:!0,children:(0,l.jsxs)(e$.$,{variant:"secondary",className:"h-9.5 flex items-center gap-3 border border-brand-stroke text-brand-dark-gray text-sm font-normal relative",disabled:c,
1children:["Status",r.length>0&&" (".concat(r.length,")"),(0,l.jsx)(eu.A,{className:"h-5 w-5 text-brand-dark-gray transition-transform duration-200 ".concat(a?"rotate-180":"")}),(0,l.jsx)("div",{className:"absolute right-5 top-0 rounded-full bg-brand-clean-blue w-1.5 h-1.5 transition-opacity duration-200 ".concat(r.length>0?"opacity-100":"opacity-0")})]})}),(0,l.jsx)(lQ,{className:"w-60 p-0",align:"start",children:(0,l.jsxs)("div",{className:"space-y-3",children:[(0,l.jsx)("div",{className:"space-y-1",children:(0,l.jsxs)("div",{className:"space-y-1 pt-1",children:[(0,l.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded-md hover:bg-cyan-50 pointer-events-auto hover:cursor-pointer",onClick:()=>{n.length===s.length?i([]):i(s.map(e=>e.id.toString()))},children:[(0,l.jsx)(lZ,{id:"select-all-statuses",checked:s&&s.length>0&&n.length===s.length,onCheckedChange:e=>{e?i(s.map(e=>e.id.toString())):i([])}}),(0,l.jsxs)("span",{className:"text-sm select-none cursor-pointer",children:["Select All (",null==s?void 0:s.length,")"]})]}),null==s?void 0:s.map(e=>(0,l.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded-md hover:bg-cyan-50 pointer-events-auto hover:cursor-pointer",onClick:()=>{i(n.includes(e.id.toString())?n.filter(a=>
1a!==e.id.toString()):[...n,e.id.toString()])},children:[(0,l.jsx)(lZ,{checked:n.includes(e.id.toString()),onCheckedChange:a=>{i(a?[...n,e.id.toString()]:n.filter(a=>a!==e.id.toString()))}}),(0,l.jsx)("span",{className:"text-sm select-none",children:e.name})]},e.id))]})}),(0,l.jsxs)("div",{className:"flex justify-between gap-6 px-4 py-3 border-t border-brand-stroke",children:[(0,l.jsx)(e$.$,{variant:"tertiary",className:"w-full",onClick:o,children:"Clear"}),(0,l.jsx)(e$.$,{className:"w-full",onClick:d,children:"Apply"})]})]})})]})}function aL(e){let{size:a=32,backgroundColor:t="#CFFAFE",color:s="#098090",dotColor:r="#FFFFFF",className:n}=e;return(0,l.jsxs)("svg",{className:n,width:a,height:a,viewBox:"0 0 32 33",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,l.jsx)("rect",{y:"0.5",width:"32",height:"32",rx:"7.38462",fill:t}),(0,l.jsx)("path",{d:"M16.0003 10.7715L19.4834 14.2546C20.1722 14.9429 20.6414 15.8201 20.8316 16.7752C21.0219 17.7303 20.9246 18.7203 20.552 19.6201C20.1795 20.5198 19.5485 21.2889 18.7389 21.83C17.9292 22.3711 16.9772 22.6599 16.0034 22.6599C15.0296 22.6599 14.0776 22.3711 13.268 21.83C12.4583 21.2889 11.8273 20.5198 11.4548 19.6201C11.0822 18.7203 10.9849 17.7303 11.1752 16.7752C11.3654 15.8201 11.8346 14.9429 12.5234 14.2546L16.0003 10.7715Z",fill:s}),(0,l.jsx)("circle",{cx:"17.9999",cy:"19.1149",r:"0.769231",fill:r})]})}let aA={"toilet leak":aR,"other leak":aL,"water heater":aM,"other leak-toilet leak":aI,"other leak-water heater":aT,"toilet leak-water heater":aP,"other leak-toilet leak-water heater":aI};function aD(e){let{Icon:a,className:t}=e;return(0,l.jsxs)(au.m_,{children:[(0,l.jsx)(au.k$,{children:(0,l.jsx)(a,{className:t})}),(0,l.jsx)(au.ZI,{align:"start",side:"bottom",children:"This leak has more than one type."})]})}function aO(e){let{leakType:a,className:t}=e,s=aA[a];return s?"toilet leak"===a||"other leak"===a||"water heater"===a?(0,l.jsx)(s,{className:t}):(0,l.jsx)(aD,{Icon:s,className:t}):null}function aT(e){let{size:a=32,className:t}=e;return(0,l.jsxs)("svg",{className:t,width:a,height:a,viewBox:"0 0 32 32",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,l.jsxs)("g",{clipPath:"url(#clip0_8770_33506)",children:[(0,l.jsx)("rect",{width:a,height:a,rx:"7.38462",fill:"#FFEDD5"}),(0,l.jsx)("path",{d:"M31.1602 0L48.8848 17.7246L16.7256 49.8838L-0.999024 32.1592L31.1602 0Z",fill:"#CFFAFE"}),(0,l.jsx)("path",{d:"M-0.999024 32.1592L-0.645471 32.5127L31.5137 0.353553L31.1602 0L30.8066 -0.353553L-1.35258 31.8056L-0.999024 32.1592Z",fill:"#CBD4E3"}),(0,l.jsx)("path",{d:"M23.0012 19.123L25.3595 21.4814C25.8259 21.9475 26.1436 22.5414 26.2724 23.1881C26.4012 23.8347 26.3353 24.5051 26.0831 25.1143C25.8308 25.7235 25.4036 26.2442 24.8554 26.6106C24.3072 26.977 23.6626 27.1725 23.0033 27.1725C22.3439 27.1725 21.6993 26.977 21.1511 26.6106C20.6029 26.2442 20.1757 25.7235 19.9234 25.1143C19.6712 24.5051 19.6053 23.8347 19.7341 23.1881C19.8629 22.5414 20.1806 21.9475 20.647 21.4814L23.0012 19.123Z",fill:"#098090"}),(0,l.jsx)("circle",{cx:"24.3558",cy:"24.7708",r:"0.520833",fill:"white"}),(0,l.jsxs)("g",{clipPath:"url(#clip1_8770_33506)",children:[(0,l.jsx)("path",{d:"M9.43921 13.8535C9.43921 13.9344 9.50478 14 9.58569 14H10.7576C10.8385 14 10.9041 13.9344 10.9041 13.8535V13.4336H9.43921V13.8535Z",fill:"#9A3412"}),(0,l.jsx)("path",{d:"M9.63428 6.14844H8.36475C8.2032 6.14844 8.07178 6.27986 8.07178 6.44141C8.07178 6.60295 8.2032 6.73438 8.36475 6.73438H9.63428C9.79582 6.73438 9.92725 6.60295 9.92725 6.44141C9.92725 6.27986 9.79582 6.14844 9.63428 6.14844Z",fill:"#9A3412"}),(0,l.jsx)("path",{d:"M11.1684 4H6.83081C6.34618 4 5.9519 4.39428 5.9519 4.87891V11.9688C5.9519 12.4534 6.34618 12.8477 6.83081 12.8477H11.1684C11.653 12.8477 12.0473 12.4534 12.0473 11.9688V4.87891C12.0473 4.39428 11.653 4 11.1684 4ZM7.82853 11.6758C7.66716 11.6758 7.53556 11.5442 7.53556 11.3828C7.53556 11.2215 7.66716 11.0898 7.82853 11.0898C7.98989 11.0898 8.12149 11.2215 8.12149 11.3828C8.12149 11.5442 7.98989 11.6758 7.82853 11.6758ZM10.1723 11.6758C10.0109 11.6758 9.87931 11.5442 9.87931 11.3828C9.87931 11.2215 10.0109 11.0898 10.1723 11.0898C10.3336 11.0898 10.4652 11.2215 10.4652 11.3828C10.4653 11.5442 10.3336 11.6758 10.1723 11.6758ZM9.63437 7.32031H8.36483C7.8802
11 7.32031 7.48593 6.92604 7.48593 6.44141C7.48593 5.95678 7.88021 5.5625 8.36483 5.5625H9.63437C10.119 5.5625 10.5133 5.95678 10.5133 6.44141C10.5133 6.92604 10.119 7.32031 9.63437 7.32031Z",fill:"#9A3412"}),(0,l.jsx)("path",{d:"M7.09595 13.8535C7.09595 13.9344 7.16153 14 7.24243 14H8.41431C8.4952 14 8.56079 13.9344 8.56079 13.8535V13.4336H7.09595V13.8535Z",fill:"#9A3412"})]})]}),(0,l.jsx)("rect",{x:"0.5",y:"0.5",width:"31",height:"31",rx:"6.88462",stroke:"#CBD4E3"}),(0,l.jsxs)("defs",{children:[(0,l.jsx)("clipPath",{id:"clip0_8770_33506",children:(0,l.jsx)("rect",{width:a,height:a,rx:"7.38462",fill:"white"})}),(0,l.jsx)("clipPath",{id:"clip1_8770_33506",children:(0,l.jsx)("rect",{width:"10",height:"10",fill:"white",transform:"translate(4 4)"})})]})]})}function aI(e){let{size:a=32,className:t}=e;return(0,l.jsxs)("svg",{className:t,width:a,height:a,viewBox:"0 0 32 32",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,l.jsxs)("g",{clipPath:"url(#clip0_8770_32868)",children:[(0,l.jsx)("rect",{width:a,height:a,rx:"7.38462",fill:"#E0E7FF"}),(0,l.jsx)("path",{d:"M31.1602 0L48.8848 17.7246L16.7256 49.8838L-0.999024 32.1592L31.1602 0Z",fill:"#CFFAFE"}),(0,l.jsx)("path",{d:"M-0.999024 32.1592L-0.645471 32.5127L31.5137 0.353553L31.1602 0L30.8066 -0.353553L-1.35258 31.8056L-0.999024 32.1592Z",fill:"#CBD4E3"}),(0,l.jsx)("path",{d:"M23.0012 19.123L25.3595 21.4814C25.8259 21.9475 26.1436 22.5414 26.2724 23.1881C26.4012 23.8347 26.3353 24.5051 26.0831 25.1143C25.8308 25.7235 25.4036 26.2442 24.8554 26.6106C24.3072 26.977 23.6626 27.1725 23.0033 27.1725C22.3439 27.1725 21.6993 26.977 21.1511 26.6106C20.6029 26.2442 20.1757 25.7235 19.9234 25.1143C19.6712 24.5051 19.6053 23.8347 19.7341 23.1881C19.8629 22.5414 20.1806 21.9475 20.647 21.4814L23.0012 19.123Z",fill:"#098090"}),(0,l.jsx)("circle",{cx:"24.3558",cy:"24.7708",r:"0.520833",fill:"white"}),(0,l.jsxs)("g",{clipPath:"url(#clip1_8770_32868)",children:[(0,l.jsx)("path",{d:"M13.4141 7.51562H8.72656C8.40355 7.51562 8.14062 7.77855 8.14062 8.10156V8.6875H13.4141C13.7371 8.6875 14 8.42457 14 8.10156C14 7.77855 13.7371 7.51562 13.4141 7.51562Z",fill:"#4F46E5"}),(0,l.jsx)("path",{d:"M13.4141 9.27344H7.55469V4H4L4.65934 9.27344H5.79687C5.79687 11.2435 7.52535 11.9425 7.55469 11.9631V13.4141H6.38281V14C6.49219 14 12.9515 14 12.8281 14V13.4141H11.6562V11.9631C11.7149 11.9103 13.4141 11.2662 13.4141 9.27344ZM5.79687 5.17188H6.38281V6.34375H5.79687V5.17188Z",fill:"#4F46E5"})]})]}),(0,l.jsx)("rect",{x:"0.5",y:"0.5",width:"31",height:"31",rx:"6.88462",stroke:"#CBD4E3"}),(0,l.jsxs)("defs",{children:[(0,l.jsx)("clipPath",{id:"clip0_8770_32868",children:(0,l.jsx)("rect",{width:a,height:a,rx:"7.38462",fill:"white"})}),(0,l.jsx)("clipPath",{id:"clip1_8770_32868",children:(0,l.jsx)("rect",{width:"10",height:"10",fill:"white",transform:"translate(4 4)"})})]})]})}function aP(e){let{size:a=32,className:t}=e;return(0,l.jsxs)("svg",{className:t,width:a,height:a,viewBox:"0 0 32 32",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,l.jsxs)("g",{clipPath:"url(#clip0_8770_33493)",children:[(0,l.jsx)("rect",{width:a,height:a,rx:"7.38462",fill:"#E0E7FF"}),(0,l.jsx)("path",{d:"M31.1602 0L48.8848 17.7246L16.7256 49.8838L-0.999024 32.1592L31.1602 0Z",fill:"#FFEDD5"}),(0,l.jsx)("path",{d:"M-0.999024 32.1592L-0.645471 32.5127L31.5137 0.353553L31.1602 0L30.8066 -0.353553L-1.35258 31.8056L-0.999024 32.1592Z",fill:"#CBD4E3"}),(0,l.jsxs)("g",{clipPath:"url(#clip1_8770_33493)",children:[(0,l.jsx)("path",{d:"M23.4392 27.8535C23.4392 27.9344 23.5048 28 23.5857 28H24.7576C24.8385 28 24.9041 27.9344 24.9041 27.8535V27.4336H23.4392V27.8535Z",fill:"#9A3412"}),(0,l.jsx)("path",{d:"M23.6343 20.1484H22.3647C22.2032 20.1484 22.0718 20.2799 22.0718 20.4414C22.0718 20.6029 22.2032 20.7344 22.3647 20.7344H23.6343C23.7958 20.7344 23.9272 20.6029 23.9272 20.4414C23.9272 20.2799 23.7958 20.1484 23.6343 20.1484Z",fill:"#9A3412"}),(0,l.jsx)("path",{d:"M25.1684 18H20.8308C20.3462 18 19.9519 18.3943 19.9519 18.8789V25.9688C19.9519 26.4534 20.3462 26.8477 20.8308 26.8477H25.1684C25.653 26.8477 26.0473 26.4534 26.0473 25.9688V18.8789C26.0473 18.3943 25.653 18 25.1684 18ZM21.8285 25.6758C21.6672 25.6758 21.5356 25.5442 21.5356 25.3828C2
11.5356 25.2215 21.6672 25.0898 21.8285 25.0898C21.9899 25.0898 22.1215 25.2215 22.1215 25.3828C22.1215 25.5442 21.9899 25.6758 21.8285 25.6758ZM24.1723 25.6758C24.0109 25.6758 23.8793 25.5442 23.8793 25.3828C23.8793 25.2215 24.0109 25.0898 24.1723 25.0898C24.3336 25.0898 24.4652 25.2215 24.4652 25.3828C24.4653 25.5442 24.3336 25.6758 24.1723 25.6758ZM23.6344 21.3203H22.3648C21.8802 21.3203 21.4859 20.926 21.4859 20.4414C21.4859 19.9568 21.8802 19.5625 22.3648 19.5625H23.6344C24.119 19.5625 24.5133 19.9568 24.5133 20.4414C24.5133 20.926 24.119 21.3203 23.6344 21.3203Z",fill:"#9A3412"}),(0,l.jsx)("path",{d:"M21.0959 27.8535C21.0959 27.9344 21.1615 28 21.2424 28H22.4143C22.4952 28 22.5608 27.9344 22.5608 27.8535V27.4336H21.0959V27.8535Z",fill:"#9A3412"})]}),(0,l.jsxs)("g",{clipPath:"url(#clip2_8770_33493)",children:[(0,l.jsx)("path",{d:"M13.4141 7.51562H8.72656C8.40355 7.51562 8.14062 7.77855 8.14062 8.10156V8.6875H13.4141C13.7371 8.6875 14 8.42457 14 8.10156C14 7.77855 13.7371 7.51562 13.4141 7.51562Z",fill:"#4F46E5"}),(0,l.jsx)("path",{d:"M13.4141 9.27344H7.55469V4H4L4.65934 9.27344H5.79687C5.79687 11.2435 7.52535 11.9425 7.55469 11.9631V13.4141H6.38281V14C6.49219 14 12.9515 14 12.8281 14V13.4141H11.6562V11.9631C11.7149 11.9103 13.4141 11.2662 13.4141 9.27344ZM5.79687 5.17188H6.38281V6.34375H5.79687V5.17188Z",fill:"#4F46E5"})]})]}),(0,l.jsx)("rect",{x:"0.5",y:"0.5",width:"31",height:"31",rx:"6.88462",stroke:"#CBD4E3"}),(0,l.jsxs)("defs",{children:[(0,l.jsx)("clipPath",{id:"clip0_8770_33493",children:(0,l.jsx)("rect",{width:a,height:a,rx:"7.38462",fill:"white"})}),(0,l.jsx)("clipPath",{id:"clip1_8770_33493",children:(0,l.jsx)("rect",{width:"10",height:"10",fill:"white",transform:"translate(18 18)"})}),(0,l.jsx)("clipPath",{id:"clip2_8770_33493",children:(0,l.jsx)("rect",{width:"10",height:"10",fill:"white",transform:"translate(4 4)"})})]})]})}function aR(e){let{size:a=32,backgroundColor:t="#E0E7FF",color:s="#4F46E5",className:r}=e;return(0,l.jsxs)("svg",{className:r,width:a,height:a,viewBox:"0 0 32 32",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,l.jsx)("rect",{width:"32",height:"32",rx:"7.38462",fill:t}),(0,l.jsxs)("g",{clipPath:"url(#clip0_5934_298538)",children:[(0,l.jsx)("path",{d:"M22.5189 13.8086H15.5959C15.1188 13.8086 14.7305 14.1969 14.7305 14.674V15.5394H22.5189C22.996 15.5394 23.3843 15.151 23.3843 14.674C23.3843 14.1969 22.996 13.8086 22.5189 13.8086Z",fill:s}),(0,l.jsx)("path",{d:"M22.5191 16.4037H13.8652V8.61523H8.61523L9.58902 16.4037H11.2691C11.2691 19.3133 13.8219 20.3458 13.8652 20.3761V22.5191H12.1345V23.3845C12.296 23.3845 21.8359 23.3845 21.6537 23.3845V22.5191H19.9229V20.3761C20.0095 20.2982 22.5191 19.3469 22.5191 16.4037ZM11.2691 10.346H12.1345V12.0768H11.2691V10.346Z",fill:s})]}),(0,l.jsx)("defs",{children:(0,l.jsx)("clipPath",{id:"clip0_5934_298538",children:(0,l.jsx)("rect",{width:"14.7692",height:"14.7692",fill:"white",transform:"translate(8.61523 8.61523)"})})})]})}function aM(e){let{size:a=32,backgroundColor:t="#FFEDD5",color:s="#9A3412",className:r}=e;return(0,l.jsxs)("svg",{className:r,width:a,height:a,viewBox:"0 0 32 33",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,l.jsx)("rect",{x:"0.5",y:"0.5",width:a,height:a,rx:"6.88462",fill:t}),(0,l.jsxs)("g",{clipPath:"url(#clip0_8851_6188)",children:[(0,l.jsx)("path",{d:"M16.7026 23.7659C16.7026 23.8953 16.8075 24.0003 16.937 24.0003H18.812C18.9415 24.0003 19.0464 23.8953 19.0464 23.7659V23.094H16.7026V23.7659Z",fill:s}),(0,l.jsx)("path",{d:"M17.0149 11.4374H14.9836C14.7252 11.4374 14.5149 11.6477 14.5149 11.9061C14.5149 12.1646 14.7252 12.3749 14.9836 12.3749H17.0149C17.2734 12.3749 17.4836 12.1646 17.4836 11.9061C17.4836 11.6477 17.2734 11.4374 17.0149 11.4374Z",fill:s}),(0,l.jsx)("path",{d:"M19.4694 8.00012H12.5293C11.7539 8.00012 11.123 8.63097 11.123 9.40637V20.7501C11.123 21.5255 11.7539 22.1564 12.5293 22.1564H19.4694C20.2448 22.1564 20.8756 21.5255 20.8756 20.7501V9.40637C20.8756 8.63097 20.2448 8.00012 19.4694 8.00012ZM14.1256 20.2814C13.8675 20.2814 13.6569 20.0708 13.6569 19.8126C13.6569 19.5545 13.8675 19.3439 14.1256 19.3439C14.3838 19.3439 14.5944 19.5545 14.5944 19.8126C14.5944 20.0708 14.3838 20.2814 14.1256 20.2814ZM17.8756 20.2814C17.6175 20.2814 17.4069 20.0708 17.4069 19.8126C17.4069 
119.5545 17.6175 19.3439 17.8756 19.3439C18.1338 19.3439 18.3444 19.5545 18.3444 19.8126C18.3444 20.0708 18.1338 20.2814 17.8756 20.2814ZM17.015 13.3126H14.9837C14.2083 13.3126 13.5775 12.6818 13.5775 11.9064C13.5775 11.131 14.2083 10.5001 14.9837 10.5001H17.015C17.7904 10.5001 18.4212 11.131 18.4212 11.9064C18.4212 12.6818 17.7904 13.3126 17.015 13.3126Z",fill:s}),(0,l.jsx)("path",{d:"M12.9536 23.7659C12.9536 23.8953 13.0586 24.0003 13.188 24.0003H15.063C15.1924 24.0003 15.2974 23.8953 15.2974 23.7659V23.094H12.9536V23.7659Z",fill:s})]}),(0,l.jsx)("defs",{children:(0,l.jsx)("clipPath",{id:"clip0_8851_6188",children:(0,l.jsx)("rect",{width:"16",height:"16",fill:"white",transform:"translate(8 8)"})})})]})}let aG="h-auto w-auto min-w-0 p-0 font-normal",az={good:"text-green-600",warn:"text-orange-600",bad:"text-brand-red"},aF=e=>Math.round(e).toLocaleString(),aH=e=>e.toFixed(1),aV=e=>"".concat(e.toFixed(1)," %"),aU=e=>"$".concat(e.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})),aB=e=>"$".concat(Math.round(e).toLocaleString()),aK=e=>e>0?"+":e<0?"−":"",aW=e=>"".concat(aK(e)).concat(aF(Math.abs(e))),aY=e=>"".concat(aK(e)).concat(aV(Math.abs(e))),a$="No municipal bills for this property in this window.",aZ="No platform reads on this day.";function aq(e){return 0===e.days.billed?a$:"Needs bedroom counts for GBD."}function aJ(e){return 0===e.days.billed?a$:"No platform reads on these billed days."}function aX(e){return e.days.matched>0?"No GBD Daily reads with bedrooms on the matched days.":aJ(e)}function aQ(e){return 0===e.days.billed?a$:"No billed cost on file for this window."}function a0(e){return e.days.matched>0?"No matched municipal gallons to compare against.":aJ(e)}function a1(e){return e.days.matched>0?"Platform reads total 0 gallons over the matched days.":aJ(e)}function a2(e,a,t){return null===e?(0,l.jsxs)(au.m_,{children:[(0,l.jsx)(au.k$,{asChild:!0,children:(0,l.jsx)(e$.$,{type:"button",variant:"ghost",size:"sm",className:"".concat(aG," text-brand-dark-gray hover:text-brand-dark-gray active:text-brand-dark-gray"),children:"—"})}),(0,l.jsx)(au.ZI,{children:a})]}):(0,l.jsx)("span",{children:t(e)})}function a5(e,a,t,s){return null===e?a2(e,t,s):(0,l.jsx)("span",{className:a?az[a]:void 0,children:s(e)})}function a3(e,a){return 0===e?(0,l.jsx)("span",{className:"text-brand-dark-gray",children:"—"}):(0,l.jsxs)(au.m_,{children:[(0,l.jsx)(au.k$,{asChild:!0,children:(0,l.jsxs)(e$.$,{type:"button",variant:"ghost",size:"sm",className:"".concat(aG," inline-flex items-center px-2 py-1 rounded-md bg-orange-100 text-orange-700 hover:text-orange-700 active:text-orange-700 text-xs font-medium"),children:[e," flagged"]})}),(0,l.jsx)(au.ZI,{children:a.map(e=>e.replace(/_/g," ")).join(", ")})]})}function a4(e){return(0,l.jsx)("span",{className:"inline-block mt-1 px-2 py-0.5 rounded-md bg-gray-200 text-brand-dark-gray text-xs font-medium",children:e})}function a6(e){return 0===e.length?(0,l.jsx)("span",{className:"text-brand-dark-gray",children:"—"}):(0,l.jsx)("div",{className:"flex flex-wrap gap-1",children:e.map(e=>(0,l.jsx)("span",{className:"inline-flex items-center px-2 py-1 rounded-md bg-orange-100 text-orange-700 text-xs font-medium",children:e.replace(/_/g," ")},e))})}let a8={all_days:"All days",p90_99:"90–99%",p50_89:"50–89%",p1_49:"1–49%",never_online:"Never online"},a9=e=>e.toLocaleString();function a7(e){let a="never_online"===e.key&&e.meters>0;return(0,l.jsxs)("div",{className:"rounded border border-brand-stroke bg-white px-2 py-1.5",children:[(0,l.jsx)("p",{className:"text-[10px] uppercase tracking-wider text-brand-dark-gray",children:a8[e.key]}),(0,l.jsx)("p",{className:"text-base font-bold tabular-nums ".concat(a?"text-brand-red":"text-brand-black"),children:a9(e.meters)}),(0,l.jsx)("p",{className:"text-[10px] text-brand-dark-gray",children:"never_online"===e.key?"0 online days":"of installed days"})]},e.key)}function te(e){var a,t,s,r;let{health:n,breakdown:i,inWindow:o,open:d,onToggle:c}=e;if(!n||"no_window"===n.reason)return null;if("no_device_data"===n.reason)return(0,l.jsxs)("p",{className:"mb-3 text-sm text-brand-dark-gray",children:[(0,l.jsx)("span",{className:"font-medium text-brand-black",children:"Meter & unit health"})," ","\xb7 No meter installations on file for this window."]});let m=null!=(t=n.installed_meters)?t:0,u=null!=(s=n.days_with_data)?s:0;return(0,l.jsxs)("div",{className:"mb-3 rounded border border-brand-stroke bg-white p-3 text-sm",children:[(0,l.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,l.jsx)("span",{className:"font-medium text-brand-black",children:"Meter & unit health"}),(0,l.jsxs)("span",{className:"text-brand-dark-gray",children:[a9(null!=(r=n.meters_online_once)?r:0)," of ",a9(m)," meters online at least once \xb7 ",null==(a=n.online_percent)?void 0:a.toFixed(1),"% online meter-days"]}),u<o&&(0,l.jsxs)("span",{className:"inline-flex items-center px-2 py-1 rounded-md bg-gray-200 text-brand-dark-gray text-xs font-medium",children:["device data for ",u," of ",o," days"]}),(0,l.jsx)(e$.$,{type:"button",variant:"ghost",size:"sm",className:"".concat(aG," ml-auto text-xs font-medium uppercase text-brand-dark-cyan"),"aria-expanded":d,onClick:c,children:d?"Hide detail":"Show detail"})]}),d&&function(e,a){var t,s,r,n,i,o,d;if(!a||a.loading)return(0,l.jsxs)("div",{className:"mt-2 flex items-center gap-2 text-brand-dark-gray",children:[(0,l.jsx)(ee.A,{className:"h-4 w-4 animate-spin text-brand-dark-cyan"}),"Loading meter health…"]});if(a.failed||!a.data)return(0,l.jsx)("p",{className:"mt-2 text-brand-dark-gray",children:"Could not load the meter health for this period."});let c=null!=(s=e.installed_meters)?s:0;return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("div",{className:"mt-2 flex flex-wrap gap-x-6 gap-y-1 text-brand-dark-gray",children:[(0,l.jsxs)("span",{children:["Installed meters"," ",(0,l.jsx)("b",{className:"text-brand-black",children:a9(c)})]}),(0,l.jsxs)("span",{children:["Online at least once"," ",(0,l.jsxs)("b",{className:"text-brand-black",children:[a9(null!=(r=e.meters_online_once)?r:0)," of ",a9(c)]})]}),(0,l.jsxs)("span",{children:["Online meter-days"," ",(0,l.jsxs)("b",{className:"text-brand-black",children:[a9(null!=(n=e.online_meter_days)?n:0)," of"," ",a9(null!=(i=e.installed_meter_days)?i:0)," (",null==(t=e.online_percent)?void 0:t.toFixed(1),"%)"]})]}),(0,l.jsxs)("span",{children:["Days with all meters online"," ",(0,l.jsxs)("b",{className:"text-brand-black",children:[null!=(o=a.data.days_all_online)?o:0," of"," ",null!=(d=e.days_with_data)?d:0]})]})]}),(0,l.jsx)("div",{className:"mt-2 grid grid-cols-2 gap-2 sm:grid-cols-5",children:a.data.bands.map(a7)})]})}(n,i)]})}let ta=e=>
1e.toLocaleString(),tt="No device data for this day.";function tl(e){var a;let{panel:t,loading:s,meterHealth:n,onLoadMeterHealth:i}=e,o=(0,r.useId)(),[d,c]=(0,r.useState)(!1);if(s)return(0,l.jsx)("div",{className:"flex items-center justify-center p-6",children:(0,l.jsx)(ee.A,{className:"h-6 w-6 animate-spin text-brand-dark-cyan"})});if(!t)return(0,l.jsx)("p",{className:"p-6 text-center text-base text-brand-dark-gray",children:"Could not load the daily reads for this period."});if(0===t.rows.length)return(0,l.jsx)("p",{className:"p-6 text-center text-base text-brand-dark-gray",children:"No bills on file for this property in this window."});let m=Math.max(1,...t.rows.map(e=>{var a;return null!=(a=e.platform_gallons)?a:0})),u=(null==n?void 0:n.data)?new Map(n.data.days.map(e=>[e.date,e])):null,p=d&&null!==u;return(0,l.jsxs)("div",{role:"region","aria-labelledby":o,className:"p-4 bg-gray-50",children:[(0,l.jsx)("h4",{id:o,className:"sr-only",children:"".concat(t.property.name," — daily platform reads")}),function(e){let a=[];return(e.days.without_reads>0&&a.push((0,l.jsxs)("span",{className:"inline-flex items-center px-2 py-1 rounded-md bg-red-100 text-brand-red text-xs font-medium",children:["needs telemetry — ",e.days.without_reads," day",1===e.days.without_reads?"":"s"," with no reads"]},"no-reads")),e.days.zero_gallon>0&&a.push((0,l.jsxs)("span",{className:"inline-flex items-center px-2 py-1 rounded-md bg-gray-200 text-brand-dark-gray text-xs font-medium",children:[e.days.zero_gallon," zero-gallon day",1===e.days.zero_gallon?"":"s"]},"zero-gallon")),0===a.length)?null:(0,l.jsx)("div",{className:"flex flex-wrap gap-2 mb-3",children:a})}(t.totals),(0,l.jsx)(te,{health:t.meter_health,breakdown:n,inWindow:t.totals.days.in_window,open:d,onToggle:()=>{d||n&&!n.failed||null==i||i(),c(e=>!e)}}),(0,l.jsx)("div",{className:"overflow-x-auto",children:(0,l.jsxs)("table",{className:"w-full text-sm text-left",children:[(0,l.jsx)("thead",{className:"text-xs text-brand-dark-gray",children:(0,l.jsxs)("tr",{children:[(0,l.jsx)("th",{className:"p-2 font-medium",children:"Date"}),(0,l.jsx)("th",{className:"p-2 font-medium",children:"Muni gal"}),(0,l.jsx)("th",{className:"p-2 font-medium",children:"Platform gal"}),(0,l.jsx)("th",{className:"p-2 font-medium",children:"Leak gal"}),(0,l.jsx)("th",{className:"p-2 font-medium",children:"Units installed"}),p&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("th",{className:"p-2 font-medium",children:"Meters online"}),(0,l.jsx)("th",{className:"p-2 font-medium",children:"Units online"})]}),(0,l.jsx)("th",{className:"p-2 font-medium",children:"GBD"}),(0,l.jsx)("th",{className:"p-2 font-medium",children:"Daily gallons"})]})}),(0,l.jsx)("tbody",{children:t.rows.map(e=>(function(e,a,t,s){var r;let n=null==s?void 0:s.get(e.date);return(0,l.jsxs)("tr",{className:"border-b border-brand-stroke",children:[(0,l.jsxs)("td",{className:"p-2",children:[e.date,!t&&(n&&!(n.meters_online>=n.meters_installed)?(0,l.jsxs)("span",{className:"ml-2 inline-flex items-center px-1.5 py-0.5 rounded bg-orange-100 text-orange-600 text-[10px] font-medium",children:[ta(n.meters_online)," of ",ta(n.meters_installed)," meters"]}):null)]}),(0,l.jsx)("td",{className:"p-2",children:a2(e.municipal_gallons,"This day is not on a municipal bill.",aF)}),(0,l.jsx)("td",{className:"p-2",children:a2(e.platform_gallons,aZ,aF)}),(0,l.jsx)("td",{className:"p-2",children:a2(e.leak_gallons,aZ,aF)}),(0,l.jsx)("td",{className:"p-2",children:a2(e.units_installed,aZ,ta)}),t&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("td",{className:"p-2",children:function(e){if(!e)return a2(null,tt,ta);let a=0===e.meters_online?"text-brand-red":e.meters_online<e.meters_installed?"text-orange-600":"";return(0,l.jsxs)("span",{className:a,children:[ta(e.meters_online)," of ",ta(e.meters_installed)]})}(n)}),(0,l.jsx)("td",{className:"p-2",children:a2(null!=(r=null==n?void 0:n.units_online)?r:null,tt,ta)})]}),(0,l.jsx)("td",{className:"p-2",children:a2(e.gbd,aZ,aH)}),(0,l.jsx)("td",{className:"p-2",children:function(e,a){if(null===e)return(0,l.jsx)("span",{className:"text-brand-dark-gray",children:"—"});let t=Math.round(e/a*100);return(0,l.jsx)("div",{className:"h-2 w-24 rounded bg-gray-200",children:(0,l.jsx)("div",{className:"h-2 rounded bg-brand-dark-cyan",style:{width:"".concat(t,"%")}})})}(e.platform_gallons,a)})]},e.date)})(e,m,p,u))}),(0,l.jsx)("tfoot",{children:function(e,a,t){var s,r;let n=aJ(e);return(0,l.jsxs)("tr",{className:"font-medium text-brand-black",children:[(0,l.jsx)("td",{className:"p-2",children:"Total"}),(0,l.jsx)("td",{className:"p-2",children:a2(e.municipal_gallons,a$,aF)}),(0,l.jsx)("td",{className:"p-2",children:a2(e.platform_gallons,n,aF)}),(0,l.jsx)("td",{className:"p-2",children:a2(e.leak_gallons,n,aF)}),(0,l.jsx)("td",{className:"p-2 text-brand-dark-gray",children:"—"}),t&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("td",{className:"p-2",children:(null==a?void 0:a.reason)===null?"".concat(ta(null!=(s=a.meters_online_once)?s:0)," of ").concat(ta(null!=(r=a.installed_meters)?r:0)," meters"):"—"}),(0,l.jsx)("td",{className:"p-2 text-brand-dark-gray",children:"—"})]}),(0,l.jsx)("td",{className:"p-2 text-brand-dark-gray",children:"—"}),(0,l.jsx)("td",{className:"p-2 text-brand-dark-gray",children:"—"})]})}(t.totals,t.meter_health,p)})]})}),(a=t.totals,(0,l.jsxs)("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3 mb-3 text-sm",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("p",{className:"text-xs text-brand-dark-gray",children:"Muni GBD"}),(0,l.jsx)("p",{className:"font-medium text-brand-black",children:a2(a.municipal_gbd,aq(a),aH)})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)("p",{className:"text-xs text-brand-dark-gray",children:"Platform GBD"}),(0,l.jsx)("p",{className:"font-medium text-brand-black",children:a2(a.platform_gbd,aX(a),aH)})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)("p",{className:"text-xs text-brand-dark-gray",children:"Δ gal"}),(0,l.jsx)("p",{className:"font-medium",children:a5(a.delta_gallons,a.delta_tone,a0(a),aW)})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)("p",{className:"text-xs text-brand-dark-gray",children:"Δ %"}),(0,l.jsx)("p",{className:"font-medium",children:a5(a.delta_percent,a.delta_tone,a0(a),aY)})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)("p",{className:"text-xs text-brand-dark-gray",children:"Leak share"}),(0,l.jsx)("p",{className:"font-medium",children:a5(a.leak_share,a.leak_tone,a1(a),aV)})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)("p",{className:"text-xs text-brand-dark-gray",children:"Water $"}),(0,l.jsx)("p",{className:"font-medium text-brand-black",children:a2(a.cost.water,aQ(a),aU)})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)("p",{className:"text-xs text-brand-dark-gray",children:"Sewer $"}),(0,l.jsx)("p",{className:"font-medium text-brand-black",children:a2(a.cost.sewer,aQ(a),aU)})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)("p",{className:"text-xs text-brand-dark-gray",children:"Total $"}),(0,l.jsx)("p",{className:"font-medium text-brand-black",children:a2(a.cost.combined,aQ(a),aU)})]})]}))]})}let ts={municipalGallons:"#ace7ef",platformGallons:"#2da8ba",water:"#27546e",sewer:"#098090",municipalGbd:"#6341dd",platformGbd:"#428067",target:"#ee5a4f"};function tr(e){return{label:e.label,municipalGallons:e.municipal_gallons,platformGallons:e.platform_gallons,municipalGbd:e.municipal_gbd,platformGbd:e.platform_gbd,waterCost:e.cost.water,sewerCost:e.cost.sewer,row:e}}let tn=e=>{let{active:a,payload:t,label:s}=e;if(!a||!(null==t?void 0:t.length))return null;let{row:r}=t[0].payload,n=[["Municipal gallons",null===r.municipal_gallons?a$:aF(r.municipal_gallons)],["Platform gallons",null===r.platform_gallons?aJ(r):aF(r.platform_gallons)],["Municipal GBD",null===r.municipal_gbd?aq(r):aH(r.municipal_gbd)],["Platform GBD",null===r.platform_gbd?aX(r):aH(r.platform_gbd)],["Water",null===r.cost.water?aQ(r):aU(r.cost.water)],["Sewer",null===r.cost.sewer?aQ(r):aU(r.cost.sewer)]];return(0,l.jsxs)("div",{className:"bg-white border border-brand-stroke rounded-sm p-3 shadow-sm max-w-xs",children:[(0,l.jsx)("div",{className:"font-semibold mb-2",children:s}),(0,l.jsx)("div",{className:"flex flex-col gap-1",children:n.map(e=>{let[a,t]=e;return(0,l.jsxs)("div",{className:"text-sm",children:[(0,l.jsxs)("span",{className:"font-medium",children:[a,":"]})," ",t]},a)})})]})};function ti(e){let{panel:a,height:t=300}=e,s=a.rows.map(tr);if(0===s.length)return(0,l.jsxs)("div",{className:"px-3 py-4 text-xs text-brand-dark-gray",children:["No periods in the current filter for ",a.property.name,"."]});let r=a.property.target_gbd;return(0,l.jsxs)("div",{className:"space-y-2 px-3 py-4",children:[(0,l.jsxs)("div",{className:"flex flex-wrap items-baseline gap-x-3 gap-y-1",children:[(0,l.jsx)("span",{className:"text-xs font-semibold uppercase tracking-wider text-brand-black",children:"Consumption & GBD timeline"}),(0,l.jsxs)("span",{className:"text-[11px] text-brand-dark-gray",children:["Bars = gallons \xb7 stacked bars = billed water / sewer cost \xb7 lines = gallons per bedroom per day \xb7 dashed rule = ",Math.round(r)," GBD target"]}),(function(e){let a=e.filter(e=>0===e.row.municipal_bedroom_days),t=e.filter(e=>e.row.municipal_bedroom_days>0),l=t.reduce((e,a)=>e+a.row.municipal_bedroom_days,0),s=t.reduce((e,a)=>e+a.row.platform_bedroom_days,0),r=t.filter(e=>e.row.platform_bedroom_days/e.row.municipal_bedroom_days<.8),n=[];if(a.length>0&&n.push("needs bedroom count \xb7 ".concat(a.length," period").concat(1===a.length?"":"s"," without GBD")),r.length>0&&l>0){let e=Math.round(s/l*100);n.push("platform saw ".concat(e," % of bedroom-days \xb7 ").concat(r.length," period").concat(1===r.length?"":"s"," below ").concat(Math.round(80)," %"))}return n})(s).map(e=>(0,l.jsx)("span",{className:"rounded border border-brand-red/40 bg-brand-red/10 px-1.5 py-0.5 text-[10px] font-semibold text-brand-red",children:e},e))]}),(0,l.jsx)("div",{style:{height:t},className:"w-full",children:(0,l.jsx)(u.u,{width:"100%",height:"100%",children:(0,l.jsxs)(p.X,{data:s,margin:{top:8,right:16,bottom:8,left:8},children:[(0,l.jsx)(g.d,{stroke:"#E5E7EB",vertical:!1}
1),(0,l.jsx)(y.W,{dataKey:"label",axisLine:!1,tickLine:!1,tick:{fill:"#666666",fontSize:11},interval:"preserveStartEnd",minTickGap:12}),(0,l.jsx)(f.h,{yAxisId:"gal",axisLine:!1,tickLine:!1,tick:{fill:"#666666",fontSize:11},tickFormatter:e=>(0,o.I)(e,!1)}),(0,l.jsx)(f.h,{yAxisId:"gbd",orientation:"right",axisLine:!1,tickLine:!1,tick:{fill:"#666666",fontSize:11},width:44}),(0,l.jsx)(f.h,{yAxisId:"cost",orientation:"right",axisLine:!1,tickLine:!1,tick:{fill:"#666666",fontSize:11},tickFormatter:e=>(0,o.I)(e),width:56}),(0,l.jsx)(x.m,{content:(0,l.jsx)(tn,{})}),(0,l.jsx)(h.s,{wrapperStyle:{fontSize:11}}),(0,l.jsx)(b.yP,{yAxisId:"gal",dataKey:"municipalGallons",name:"Municipal gal",fill:ts.municipalGallons,stroke:ts.municipalGbd,strokeOpacity:.35,barSize:14}),(0,l.jsx)(b.yP,{yAxisId:"gal",dataKey:"platformGallons",name:"Platform gal",fill:ts.platformGallons,fillOpacity:.5,barSize:14}),(0,l.jsx)(b.yP,{yAxisId:"cost",dataKey:"waterCost",name:"Water $",stackId:"cost",fill:ts.water,fillOpacity:.75,barSize:10}),(0,l.jsx)(b.yP,{yAxisId:"cost",dataKey:"sewerCost",name:"Sewer $",stackId:"cost",fill:ts.sewer,fillOpacity:.9,barSize:10}),(0,l.jsx)(v.e_,{yAxisId:"gbd",y:r,stroke:ts.target,strokeDasharray:"4 4",label:{value:"".concat(Math.round(r)," GBD target"),position:"right",fontSize:10,fill:ts.target}}),(0,l.jsx)(R.N1,{yAxisId:"gbd",type:"monotone",dataKey:"municipalGbd",name:"Municipal GBD",stroke:ts.municipalGbd,strokeWidth:2,dot:{r:2},connectNulls:!1}),(0,l.jsx)(R.N1,{yAxisId:"gbd",type:"monotone",dataKey:"platformGbd",name:"Platform GBD",stroke:ts.platformGbd,strokeWidth:2,dot:{r:2},connectNulls:!1})]})})})]})}var to=t(7125),td=t(37965);function tc(e,a){return e&&a?(0,l.jsxs)("span",{className:"text-xs text-brand-dark-gray",children:[e," → ",a]}):(0,l.jsx)("span",{className:"text-brand-dark-gray",children:"—"})}function tm(e,a){return(0,l.jsxs)("span",{className:"block text-xs text-brand-dark-gray",children:["Filed ",null===e?"—":a(e)]})}function tu(e){return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("td",{className:"p-2",children:a2(e.municipal_gbd,aq(e),aH)}),(0,l.jsx)("td",{className:"p-2",children:a2(e.platform_gallons,aJ(e),aF)}),(0,l.jsx)("td",{className:"p-2",children:a2(e.platform_gbd,aX(e),aH)}),(0,l.jsx)("td",{className:"p-2",children:a5(e.delta_gallons,e.delta_tone,a0(e),aW)}),(0,l.jsx)("td",{className:"p-2",children:a5(e.delta_percent,e.delta_tone,a0(e),aY)}),(0,l.jsx)("td",{className:"p-2",children:a5(e.leak_share,e.leak_tone,a1(e),aV)})]})}function tp(e){let{expandable:a,canExpand:t,isOpen:s,isActiveDestination:r,onToggle:n,label:i,detailId:o}=e;if(!a)return null;let d=s&&!r,c=r?to.A:d?td.A:eQ.A;return(0,l.jsx)(e$.$,{type:"button",variant:"ghost",size:"extraSmall",onClick:t?n:void 0,"aria-disabled":!t,className:t?void 0:"pointer-events-none opacity-50","aria-expanded":s,"aria-controls":s&&t?o:void 0,"aria-label":r?"Hide details for ".concat(i):d?"Switch to details for ".concat(i):"Show details for ".concat(i),children:(0,l.jsx)(c,{className:"h-4 w-4"})})}let tx="".concat(aG," text-xs text-brand-dark-gray hover:text-brand-dark-gray active:text-brand-dark-gray underline decoration-dotted underline-offset-2");
1function th(e){let{row:a,isOpen:t,onToggle:s,renderDetail:n,expandable:i}=e,o=(0,r.useId)(),d=i&&null!==a.start&&null!==a.end;return(0,l.jsxs)(r.Fragment,{children:[(0,l.jsxs)("tr",{className:"border-b border-brand-stroke",children:[(0,l.jsx)("td",{className:"p-2",children:(0,l.jsxs)("div",{className:"flex items-start gap-2",children:[(0,l.jsx)(tp,{expandable:i,canExpand:d,isOpen:t,isActiveDestination:t,onToggle:s,label:a.label,detailId:o}),(0,l.jsxs)("div",{children:[(0,l.jsx)("p",{className:"font-medium text-brand-black",children:a.label}),"months"in a&&(0,l.jsxs)("p",{className:"text-xs text-brand-dark-gray",children:[a.months," mo"]}),tc(a.start,a.end)]})]})}),(0,l.jsxs)("td",{className:"p-2",children:[a.days.matched,"/",a.days.billed]}),(0,l.jsx)("td",{className:"p-2",children:a2(a.municipal_gallons,a$,aF)}),tu(a),(0,l.jsx)("td",{className:"p-2",children:a2(a.cost.water,aQ(a),aU)}),(0,l.jsx)("td",{className:"p-2",children:a2(a.cost.sewer,aQ(a),aU)}),(0,l.jsx)("td",{className:"p-2",children:a2(a.cost.combined,aQ(a),aU)}),(0,l.jsx)("td",{className:"p-2",children:a3(a.flagged_bills,a.flags)})]}),t&&d&&(0,l.jsx)("tr",{children:(0,l.jsx)("td",{id:o,colSpan:13,className:"p-0",children:n(a)})})]})}function tg(e){let{row:a,isOpen:t,isReadDatesOpen:s,onToggle:n,onOpenReadDates:i,renderDetail
1:o,expandable:d}=e,c=(0,r.useId)(),m=d&&null!==a.start&&null!==a.end;return(0,l.jsxs)(r.Fragment,{children:[(0,l.jsxs)("tr",{className:"border-b border-brand-stroke",children:[(0,l.jsx)("td",{className:"p-2",children:(0,l.jsxs)("div",{className:"flex items-start gap-2",children:[(0,l.jsx)(tp,{expandable:d,canExpand:m,isOpen:t,isActiveDestination:t&&!s,onToggle:n,label:a.label,detailId:c}),(0,l.jsxs)("div",{children:[(0,l.jsx)("p",{className:"font-medium text-brand-black",children:a.label}),tc(a.start,a.end),0===a.owned_days&&a4("0 owned days")]})]})}),(0,l.jsxs)("td",{className:"p-2",children:[(0,l.jsxs)("span",{className:"block",children:[a.days.matched,"/",a.days.billed]}),(0,l.jsxs)(au.m_,{children:[(0,l.jsx)(au.k$,{asChild:!0,children:(0,l.jsxs)(e$.$,{type:"button",variant:"ghost",size:"sm",onClick:m?i:void 0,"aria-disabled":!m,className:m?tx:"".concat(tx," pointer-events-none opacity-50"),"aria-expanded":s,"aria-controls":s?c:void 0,"aria-label":s?"Hide read dates for ".concat(a.label):"Show read dates for ".concat(a.label),children:[a.period_owned_days,"/",a.period_days," period days owned"]})}),(0,l.jsxs)(au.ZI,{children:[a.contested_days," contested day",1===a.contested_days?"":"s"]})]})]}),(0,l.jsxs)("td",{className:"p-2",children:[a2(a.municipal_gallons,a$,aF),tm(a.filed.gallons,aF)]}),tu(a),(0,l.jsxs)("td",{className:"p-2",children:[a2(a.cost.water,aQ(a),aU),tm(a.filed.water,aU)]}),(0,l.jsxs)("td",{className:"p-2",children:[a2(a.cost.sewer,aQ(a),aU),tm(a.filed.sewer,aU)]}),(0,l.jsx)("td",{className:"p-2",children:a2(a.cost.combined,aQ(a),aU)}),(0,l.jsx)("td",{className:"p-2",children:a6(a.flags)})]}),t&&m&&(0,l.jsx)("tr",{children:(0,l.jsx)("td",{id:c,colSpan:13,className:"p-0",children:o(a)})})]})}function ty(e){let{panel:a,loading:t,openPeriodKey:s,openDetailKind:n=null,onTogglePeriod:i,onOpenReadDates:o,renderPeriodDetail:d,showFooter:c=!0,expandable:m=!0}=e,u=(0,r.useId)();return t?(0,l.jsx)("div",{className:"flex items-center justify-center p-6",children:(0,l.jsx)(ee.A,{className:"h-6 w-6 animate-spin text-brand-dark-cyan"})}):a?0===a.rows.length?(0,l.jsx)("p",{className:"p-6 text-center text-base text-brand-dark-gray",children:"No bills on file for this property in this window."}):(0,l.jsxs)("div",{role:"region","aria-labelledby":u,className:"p-4 bg-gray-50",children:[(0,l.jsx)("h4",{id:u,className:"sr-only",children:"".concat(a.property.name," — ").concat(a.grain," periods")}),"bills"===a.grain&&c&&(0,l.jsx)("p",{className:"text-xs text-brand-dark-gray mb-2",children:"Each row is one bill's whole-day figures over the days it owns; a day can be owned by more than one bill, so the rows do not add up to the total below."}),(0,l.jsx)("div",{className:"overflow-x-auto",children:(0,l.jsxs)("table",{className:"w-full text-sm text-left",children:[(0,l.jsx)("thead",{className:"text-xs text-brand-dark-gray",children:(0,l.jsxs)("tr",{children:[(0,l.jsx)("th",{className:"p-2 font-medium",children:"Period"}),(0,l.jsx)("th",{className:"p-2 font-medium",children:"Days"}),(0,l.jsx)("th",{className:"p-2 font-medium",children:"Muni gal"}),(0,l.jsx)("th",{className:"p-2 font-medium",children:"Muni GBD"}),(0,l.jsx)("th",{className:"p-2 font-medium",children:"Platform gal"}),(0,l.jsx)("th",{className:"p-2 font-medium",children:"Platform GBD"}),(0,l.jsx)("th",{className:"p-2 font-medium",children:"Δ gal"}),(0,l.jsx)("th",{className:"p-2 font-medium",children:"Δ %"}),(0,l.jsx)("th",{className:"p-2 font-medium",children:"Leak share"}),(0,l.jsx)("th",{className:"p-2 font-medium",children:"Water $"}),(0,l.jsx)("th",{className:"p-2 font-medium",children:"Sewer $"}),(0,l.jsx)("th",{className:"p-2 font-medium",children:"Total $"}),(0,l.jsx)("th",{className:"p-2 font-medium",children:"Flags"})]})}),(0,l.jsx)("tbody",{children:"bills"===a.grain?a.rows.map(e=>(0,l.jsx)(tg,{row:e,isOpen:m&&s===e.key,isReadDatesOpen:m&&s===e.key&&"read-dates"===n,onToggle:()=>i(e.key),onOpenReadDates:()=>
1null==o?void 0:o(e.key),renderDetail:d,expandable:m},e.key)):a.rows.map(e=>(0,l.jsx)(th,{row:e,isOpen:m&&s===e.key,onToggle:()=>i(e.key),renderDetail:d,expandable:m},e.key))}),c&&(0,l.jsx)("tfoot",{children:function(e){let a="bill_owned_days"in e?e.bill_owned_days:null;return(0,l.jsxs)("tr",{className:"font-medium text-brand-black",children:[(0,l.jsx)("td",{className:"p-2",children:"Total"}),(0,l.jsxs)("td",{className:"p-2",children:[e.days.matched,"/",e.days.billed,null!==a&&a!==e.days.billed&&(0,l.jsxs)("span",{className:"block text-xs font-normal text-brand-dark-gray",children:["Bills own ",a," day",1===a?"":"s"]})]}),(0,l.jsx)("td",{className:"p-2",children:a2(e.municipal_gallons,a$,aF)}),tu(e),(0,l.jsx)("td",{className:"p-2",children:a2(e.cost.water,aQ(e),aU)}),(0,l.jsx)("td",{className:"p-2",children:a2(e.cost.sewer,aQ(e),aU)}),(0,l.jsx)("td",{className:"p-2",children:a2(e.cost.combined,aQ(e),aU)}),(0,l.jsx)("td",{className:"p-2",children:a3(e.flagged_bills,e.flags)})]})}(a.totals)})]})})]}):(0,l.jsx)("p",{className:"p-6 text-center text-base text-brand-dark-gray",children:"Could not load the periods for this property."})}var tf=t(4480),tb=t(38271),tv=t(70968),tN=t(91761),tj=t(74474);let t_={neutral:{iconBgColor:"bg-cyan-100",iconColor:"text-brand-dark-cyan",borderColor:"border-brand-dark-cyan"},good:{iconBgColor:"bg-green-100",iconColor:"text-green-500",borderColor:"border-green-500"},warn:{iconBgColor:"bg-orange-100",iconColor:"text-orange-500",borderColor:"border-orange-500"},bad:{iconBgColor:"bg-red-100",iconColor:"text-brand-red",borderColor:"border-brand-red"}},tw=(e,a)=>null===e?"—":"".concat(e>0?"+":"").concat(a(e)),tk=(e,a)=>null===e?"—":a(e),tC=e=>"$".concat(e.toFixed(4)," / gal"),tS=[{id:"billed_gbd_before",icon:tf.A,title:"Billed GBD before"},{id:"billed_gbd_after",icon:tf.A,title:"Billed GBD after"},{id:"gallons_per_year_before",icon:tb.A,title:"Gallons billed / yr before"},{id:"gallons_per_year_after",icon:tv.A,title:"Gallons billed / yr after"},{id:"variable_expense",icon:tN.A,title:"Variable expense before → after"},{id:"annualized_savings",icon:tj.A,title:"Annualized savings"}];function tE(e){var a,t;let{data:s,loading:r}=e,n=s?function(e){var a,t,l,s,r;let n=e.tiles;return[{id:"billed_gbd_before",icon:tf.A,title:"Billed GBD before",value:null!=(a=n.billed_gbd_before.value)?a:"—",format:aH,subTitle:"bedroom-weighted"},{id:"billed_gbd_after",icon:tf.A,title:"Billed GBD after",value:null!=(t=n.billed_gbd_after.value)?t:"—",format:aH,tone:n.billed_gbd_after.tone,subValue:"".concat(tw(n.billed_gbd_after.reduction,aH)," \xb7 ").concat(tw(n.billed_gbd_after.reduction_percent,aV))},{id:"gallons_per_year_before",icon:tb.A,title:"Gallons billed / yr before",value:null!=(l=n.gallons_per_year_before.value)?l:"—",format:aF,subTitle:"GBD \xd7 bedrooms \xd7 365"},{id:"gallons_per_year_after",icon:tv.A,title:"Gallons billed / yr after",value:null!=(s=n.gallons_per_year_after.value)?s:"—",format:aF,subValue:"".concat(tk(n.gallons_per_year_after.conserved,aF)," conserved")},{id:"variable_expense",icon:tN.A,title:"Variable expense before → after",value:"".concat(tk(n.variable_expense.before,aB)," → ").concat(tk(n.variable_expense.after,aB)),subTitle:"annualized at the post-install rate"},{id:"annualized_savings",icon:tj.A,title:"Annualized savings",value:null!=(r=n.annualized_savings.value)?r:"—",format:aB,tone:n.annualized_savings.tone,subValue:"".concat(tk(n.annualized_savings.per_unit,aB)," / unit / yr").concat(n.annualized_savings.provisional_share?" \xb7 includes ".concat(aB(n.annualized_savings.provisional_share)," provisional"):"")}]}(s):null,i=r&&!s;return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("div",{className:"bg-white rounded-xl shadow-custom-tile p-5 mb-5 relative",children:[(0,l.jsxs)("div",{className:"flex flex-col md:flex-row md:items-center md:justify-between gap-2 mb-4",children:[(0,l.jsx)("h3",{className:"text-xl font-bold text-brand-black",children:"Pre-install → post-install, on the bill"}),(0,l.jsx)("div",{className:"text-sm 2xl:text-base font-semibold text-cyan-800",children:s?["".concat(s.properties.counted," properties with bills on both sides"),s.properties.provisional>
10?"".concat(s.properties.confirmed," confirmed, ").concat(s.properties.provisional," provisional"):null,"".concat(s.properties.units," units"),"".concat(s.properties.bedrooms," bedrooms"),"all bills on file","".concat(null!=(t=null==(a=s.scope)?void 0:a.utility)?t:"—"," gallons, every billed utility in the rate")].filter(e=>null!==e).join(" \xb7 "):"…"})]}),(0,l.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-3 gap-5 mb-5",children:n?n.map(e=>(function(e,a){var t;let s=null!=(t=e.tone)?t:"neutral";return(0,l.jsx)(sf.h,{icon:e.icon,iconBgColor:t_[s].iconBgColor,iconColor:t_[s].iconColor,borderColor:t_[s].borderColor,title:e.title,value:e.value,valueFormatter:e.format,isLoading:a,subTitle:e.subTitle,subValue:e.subValue,titleWrap:!0},e.id)})(e,r)):i&&tS.map(e=>(0,l.jsx)(sf.h,{icon:e.icon,iconBgColor:t_.neutral.iconBgColor,iconColor:t_.neutral.iconColor,borderColor:t_.neutral.borderColor,title:e.title,value:"Not available",isLoading:!0,titleWrap:!0},e.id))}),s&&(0===s.rows.length?(0,l.jsx)("p",{className:"text-base text-brand-dark-gray",children:"No property here has municipal bills on both sides of its install date yet, so there is no billed before-and-after to show. Every property is named below with what it is missing — most commonly the pre-install invoices, which do not exist at all for new construction."}):(0,l.jsx)("div",{className:"overflow-x-auto",children:(0,l.jsxs)("table",{className:"w-full text-sm text-left",children:[(0,l.jsx)("thead",{className:"text-xs text-brand-dark-gray",children:(0,l.jsxs)("tr",{children:[(0,l.jsx)("th",{className:"p-2 font-medium",children:"Property"}),(0,l.jsx)("th",{className:"p-2 font-medium",children:"Units"}),(0,l.jsx)("th",{className:"p-2 font-medium",children:"Bedrooms"}),(0,l.jsx)("th",{className:"p-2 font-medium",children:"Billed GBD before"}),(0,l.jsx)("th",{className:"p-2 font-medium",children:"Billed GBD after"}),(0,l.jsx)("th",{className:"p-2 font-medium",children:"Δ GBD"}),(0,l.jsx)("th",{className:"p-2 font-medium",children:"Platform GBD (30d)"}),(0,l.jsx)("th",{className:"p-2 font-medium",children:"Bill − platform"}),(0,l.jsx)("th",{className:"p-2 font-medium",children:"Conserved gal / yr"}),(0,l.jsx)("th",{className:"p-2 font-medium",children:"$ / gal"}),(0,l.jsx)("th",{className:"p-2 font-medium",children:"Annualized savings"})]})}),(0,l.jsx)("tbody",{children:s.rows.map(e=>(function(e,a){var t,s,r;let n=null!==e.platform_gbd_30d&&Date.now()-Date.parse(e.platform_gbd_30d.last_read_day)>2592e6,i=null!==e.annualized_savings&&e.annualized_savings<0,o=!i&&null!==e.annualized_savings&&e.annualized_savings>0&&null!==e.delta_gbd&&e.delta_gbd<0;return(0,l.jsxs)("tr",{className:"border-b border-brand-stroke",children:[(0,l.jsxs)("td",{className:"p-2",children:[(0,l.jsx)("p",{className:"font-medium text-brand-black",children:e.name}),(0,l.jsxs)("p",{className:"text-xs text-brand-dark-gray",children:["Installed ",e.installation_date]}),e.provisional&&(0,l.jsxs)("span",{className:"inline-block mt-1 px-2 py-0.5 rounded-md bg-orange-100 text-orange-700 text-xs font-medium",children:["Provisional \xb7 ",e.provisional_reason]})]}),(0,l.jsx)("td",{className:"p-2",children:e.units}),(0,l.jsx)("td",{className:"p-2",children:e.bedrooms}),(0,l.jsx)("td",{className:"p-2",children:tk(e.pre.gbd,aH)}),(0,l.jsx)("td",{className:"p-2",children:tk(e.post.gbd,aH)}),(0,l.jsx)("td",{className:"p-2",children:tw(e.delta_gbd,aH)}),(0,l.jsx)("td",{className:"p-2",children:null===e.platform_gbd_30d?(0,l.jsx)("span",{className:"text-brand-dark-gray",children:"—"}):(0,l.jsx)("span",{className:n?"text-brand-dark-gray":void 0,title:n?e.platform_gbd_30d.last_read_day:void 0,children:tk(e.platform_gbd_30d.value,aH)})}),(0,l.jsx)("td",{className:"p-2",children:tw(e.bill_minus_platform,aH)}),(0,l.jsx)("td",{className:"p-2",children:tk(e.gallons_per_year.conserved,aF)}),(0,l.jsx)("td",{className:"p-2",children:tk(e.rate_per_gallon,tC)}),(0,l.jsx)("td",{className:"p-2",title:o?(t=a.alerts,s=e.property_id,null==(r=t.find(e=>e.property_id===s&&"negative_rate"===e.code))?void 0:r.message):void 0,children:(0,l.jsx)("span",{className:i?"text-brand-red":o?"text-orange-600":void 0,children:tk(e.annualized_savings,aB)})})]},e.property_id)})(e,s))})]})})),(0,l.jsx)("p",{className:"text-base text-brand-dark-gray mt-5",children:"Each phase is annualized on its own billed days — billed gallons \xf7 (bedrooms \xd7 billed days) \xd7 bedrooms \xd7 365 — and savings are the conserved gallons priced at the blended rate of that property's post-install invoices. A property with fewer than two post-install invoices, or under 120 post-install days, is marked provisional and still counted. \"Bill − platform\" is the spread between the post-install invoice and ION's own trailing 30-day read, not a correction to either number."})]}),s&&s.alerts.length>0&&(0,l.jsx)(lS,{type:"single",collapsible:!0,children:(0,l.jsxs)(lE,{value:"alerts",className:"border border-brand-stroke rounded-lg mb-4",children:[(0,l.jsxs)(lL,{className:"rounded-lg px-5 py-6 data-[state=open]:border-b data-[state=open]:border-brand-stroke hover:text-inherit",children:["Bill alerts \xb7 ",s.alerts.length]}),(0,l.jsx)(lA,{className:"px-5 pt-4 pb-6",children:(0,l.jsx)("ul",{className:"flex flex-col gap-2 text-sm text-brand-dark-gray",children:s.alerts.map((e,a)=>(0,l.jsxs)("li",{children:[(0,l.jsx)("span",{className:"font-medium text-brand-black",children:e.name})," ","— ",e.message]},"".concat(e.property_id,"-").concat(e.code,"-").concat(a)))})})]})})]})}let tL="Not filed on this bill.";function tA(e){return(0,l.jsxs)("tr",{className:"border-b border-brand-stroke",children:[(0,l.jsxs)("td",{className:"p-2",children:[(0,l.jsxs)("p",{className:"font-medium text-brand-black",children:["Billed ",e.billed_month]}),(0,l.jsxs)("span",{className:"block text-xs text-brand-dark-gray",children:[e.service_period_start," → ",e.service_period_end]}),0===e.owned_days&&a4("0 owned days"),!e.usable&&a4("not normalized")]}),(0,l.jsx)("td",{className:"p-2",children:e.period_days}),(0,l.jsx)("td",{className:"p-2",children:e.read_days}),(0,l.jsxs)("td",{className:"p-2",children:[e.owned_days,(0,l.jsxs)("span",{className:"block text-xs text-brand-dark-gray",children:[e.owned_days_in_window," in window"]})]}),(0,l.jsx)("td",{className:"p-2",children:e.contested_days}),(0,l.jsx)("td",{className:"p-2",children:a2(e.gallons,tL,aF)}),(0,l.jsx)("td",{className:"p-2",children:a2(e.water,tL,aU)}),(0,l.jsx)("td",{className:"p-2",children:a2(e.sewer,tL,aU)}),(0,l.jsx)("td",{className:"p-2",children:a2(e.other,tL,aU)}),(0,l.jsx)("td",{className:"p-2",children:a6(e.flags)})]},"".concat(e.source,":").concat(e.raw_bill_id))}function tD(e){var a,t;let{panel:s,loading:n}=e,i=(0,r.useId)();return n?(0,l.jsx)("div",{className:"flex items-center justify-center p-6",children:(0,l.jsx)(ee.A,{className:"h-6 w-6 animate-spin text-brand-dark-cyan"})}):s?0===s.segments.length?(0,l.jsx)("p",{className:"p-6 text-center text-base text-brand-dark-gray",children:"No bills on file for this property in this window."}):(0,l.jsxs)("div",{role:"region","aria-labelledby":i,className:"p-4 bg-gray-50",children:[(0,l.jsx)("h4",{id:i,className:"sr-only",children:"".concat(s.property.name," — read dates")}),(0,l.jsx)("div",{className:"overflow-x-auto",children:(0,l.jsxs)("table",{className:"w-full text-sm text-left",children:[(0,l.jsx)("thead",{className:"text-xs text-brand-dark-gray",children:(0,l.jsxs)("tr",{children:[(0,l.jsx)("th",{className:"p-2 font-medium",children:"Bill"}),(0,l.jsx)("th",{className:"p-2 font-medium",children:"Period days"}),(0,l.jsx)("th",{className:"p-2 font-medium",children:"Read days (filed)"}),(0,l.jsx)("th",{className:"p-2 font-medium",children:"Owned days"}),(0,l.jsx)("th",{className:"p-2 font-medium",children:"Contested days"}),(0,l.jsx)("th",{className:"p-2 font-medium",children:"Filed gallons"}),(0,l.jsx)("th",{className:"p-2 font-medium",children:"Water $"}),(0,l.jsx)("th",{className:"p-2 font-medium",children:"Sewer $"}),(0,l.jsx)("th",{className:"p-2 font-medium",children:"Other $"}),(0,l.jsx)("th",{className:"p-2 font-medium",children:"Flags"})]})}),(0,l.jsx)("tbody",{children:s.segments.map(tA)}),(0,l.jsx)("tfoot",{children:(a=s.totals,(0,l.jsxs)("tr",{className:"font-medium text-brand-black",children:[(0,l.jsxs)("td",{className:"p-2",children:["Total (",a.bills," bill",1===a.bills?"":"s",")"]}),(0,l.jsx)("td",{className:"p-2",children:a.period_days}),(0,l.jsx)("td",{className:"p-2",children:a.read_days}),(0,l.jsx)("td",{className:"p-2",children:a.owned_days}),(0,l.jsx)("td",{className:"p-2",children:a.contested_days}),(0,l.jsx)("td",{className:"p-2 text-brand-dark-gray",children:"—"}),(0,l.jsx)("td",{className:"p-2 text-brand-dark-gray",children:"—"}),(0,l.jsx)("td",{className:"p-2 text-brand-dark-gray",children:"—"}),(0,l.jsx)("td",{className:"p-2 text-brand-dark-gray",children:"—"}),(0,l.jsx)("td",{className:"p-2 text-brand-dark-gray",children:"—"})]}))})]})}),(t=s.totals,(0,l.jsxs)("div",{className:"mt-2 text-xs text-brand-dark-gray",children:[(0,l.jsx)("p",{children:"Contested days sum every listed bill's own column; the normalize job can only drop days from a bill it processed."}),(0,l.jsxs)("p",{className:"mt-1 text-sm font-medium text-brand-black",children:[t.days_dropped," day",1===t.days_dropped?"":"s"," dropped to later statements."]})]}))]}):(0,l.jsx)("p",{className:"p-6 text-center text-base text-brand-dark-gray",children:"Could not load the read dates for this bill."})}var tO=t(85843),tT=t(19204);let tI="Not available",tP="no day-matched municipal gallons",tR={both:"all phases",pre:"pre-ION",post:"post-ION"},tM={installed:"installed properties",not_installed:"properties not installed",all:"all properties"}
1,tG={new_construction:"new construction",operating:"operating",unknown:"type not on file"},tz={neutral:{iconBgColor:"bg-cyan-100",iconColor:"text-brand-dark-cyan",borderColor:"border-brand-dark-cyan"},good:{iconBgColor:"bg-green-100",iconColor:"text-green-500",borderColor:"border-green-500"},warn:{iconBgColor:"bg-orange-100",iconColor:"text-orange-500",borderColor:"border-orange-500"},bad:{iconBgColor:"bg-red-100",iconColor:"text-brand-red",borderColor:"border-brand-red"}},tF={comparison:[{id:"municipal_gallons",icon:tb.A,title:"Municipal gal (all phases)",gapCode:"no_bills"},{id:"platform_gallons",icon:tv.A,title:"Platform gal (matched)",gapCode:"platform_days_missing"},{id:"municipal_gbd",icon:tf.A,title:"Municipal GBD",gapCode:"needs_bedrooms"},{id:"platform_gbd",icon:tf.A,title:"Platform GBD",gapCode:"platform_days_missing"},{id:"delta_gallons",icon:tO.A,title:"Δ gal (platform − municipal)",gapCode:"platform_days_missing"},{id:"leak_share",icon:tT.A,title:"Leak share (ION leak trigger)",gapCode:"no_platform_gallons"}],cost:[{id:"water",icon:tN.A,title:"Water cost",gapCode:"no_billed_cost",stackedAtXl:!0},{id:"sewer",icon:tN.A,title:"Sewer cost",gapCode:"no_billed_cost",stackedAtXl:!0},{id:"other",icon:tN.A,title:"Other utilities",gapCode:"no_billed_cost",stackedAtXl:!0},{id:"combined",icon:tN.A,title:"Combined",gapCode:"no_billed_cost",stackedAtXl:!0},{id:"blended",icon:ez.A,title:"Blended cost",gapCode:"no_billed_cost",stackedAtXl:!0}]};function tH(e,a,t){var s,r;let n=null!=(s=a.tone)?s:"neutral",i=null===a.value;return(0,l.jsx)(sf.h,{icon:a.icon,iconBgColor:tz[i?"neutral":n].iconBgColor,iconColor:tz[i?"neutral":n].iconColor,borderColor:tz[i?"neutral":n].borderColor,title:a.title,value:i?tI:a.value,valueFormatter:a.format,isLoading:t,subTitle:a.subTitle,subValue:i?null!=(r=a.nullSubValue)?r:function(e,a){var t,l;let s=e.gaps.find(e=>e.code===a),r="no_bills"===a?e.gaps.find(e=>"no_bills_in_cohort"===e.code):void 0;return null!=(l=null==(t=null!=s?s:r)?void 0:t.message)?l:tI}(e,a.gapCode):a.subValue,titleTooltip:a.titleTooltip,titleWrap:!0,stackedAtXl:a.stackedAtXl},a.id)}function tV(e){return(0,l.jsx)(sf.h,{icon:e.icon,iconBgColor:tz.neutral.iconBgColor,iconColor:tz.neutral.iconColor,borderColor:tz.neutral.borderColor,title:e.title,value:tI,isLoading:!0,subValue:void 0,titleWrap:!0,stackedAtXl:e.stackedAtXl},e.id)}function tU(e){var a,t,s,r,n;let{data:i,loading:o}=e;if(!o&&i&&0===i.days.billed){let e=null!=(r=null==(a=i.gaps.find(e=>"no_bills"===e.code||"no_bills_in_cohort"===e.code))?void 0:a.message)?r:"No municipal bills on file for ".concat(null!=(s=null==(t=i.organization)?void 0:t.name)?s:"this developer",".");return(0,l.jsxs)("div",{className:"bg-white rounded-xl shadow-custom-tile p-5 mb-5 relative",children:[(0,l.jsx)("h3",{className:"text-xl font-bold text-brand-black mb-4",children:"Period roll-up"}),(0,l.jsx)("p",{className:"h-[250px] flex items-center justify-center text-base text-brand-dark-gray",children:e})]})}let d=i?function(e){let a=e.tiles;return{comparison:[{id:"municipal_gallons",icon:tb.A,title:"Municipal gal (all phases)",value:a.municipal_gallons.value,format:aF,subTitle:"".concat(e.days.billed.toLocaleString()," billed days"),gapCode:"no_bills"},{id:"platform_gallons",icon:tv.A,title:"Platform gal (matched)",value:a.platform_gallons.value,format:aF,subTitle:"".concat(e.days.matched.toLocaleString()," matched days"),gapCode:"platform_days_missing"},{id:"municipal_gbd",icon:tf.A,title:"Municipal GBD",value:a.municipal_gbd.value,format:aH,subTitle:"gal / bedroom / day, billed days",gapCode:"needs_bedrooms",titleTooltip:"Billed gallons over inventory bedrooms \xd7 billed days"},{id:"platform_gbd",icon:tf.A,title:"Platform GBD",value:a.platform_gbd.value,format:aH,subTitle:"gal / bedroom / day, matched days",gapCode:e.days.matched>0?"platform_gbd_missing":"platform_days_missing",titleTooltip:"GBD Daily gallons over the recorded bedroom-days of the reporting units, matched days"},{id:"delta_gallons",icon:tO.A,title:"Δ gal (platform − municipal)",value:a.delta_gallons.value,format:aW,tone:a.delta_gallons.tone,subValue:null===a.delta_gallons.percent?tP:"".concat(aY(a.delta_gallons.percent)," of day-matched municipal"),nullSubValue:tP,gapCode:"platform_days_missing"},{id:"leak_share",icon:tT.A,title:"Leak share (ION leak trigger)",value:a.leak_share.value,format:aV,tone:a.leak_share.tone,subValue:null===a.leak_share.leak_gallons?void 0:"".concat(aF(a.leak_share.leak_gallons)," gal of platform gal"),gapCode:null===a.platform_gallons.value?"platform_days_missing":"no_platform_gallons"}],cost:[{id:"water",icon:tN.A,title:"Water cost",value:a.cost.water,format:aB,gapCode:"no_billed_cost",stackedAtXl:!0},{id:"sewer",icon:tN.A,title:"Sewer cost",value:a.cost.sewer,format:aB,gapCode:"no_billed_cost",stackedAtXl:!0},{id:"other",icon:tN.A,title:"Other utilities",value:a.cost.other,format:aB,subTitle:"storm water + irrigation",gapCode:"no_billed_cost",stackedAtXl:!0},{id:"combined",icon:tN.A,title:"Combined",value:a.cost.combined,format:aB,subTitle:"".concat(a.cost.billed_months," billed months"),gapCode:"no_billed_cost",stackedAtXl:!0},{id:"blended",icon:ez.A,title:"Blended cost",value:a.cost_per_kgal.value,format:e=>"$".concat(e.toFixed(2)," / kgal"),subValue:null===a.cost_per_unit_month.value?"needs unit count":"".concat(aB(a.cost_per_unit_month.value)," / unit / month"),gapCode:null===a.cost.combined?"no_billed_cost":"no_billed_gallons",stackedAtXl:!0}]}}(i):null,c=o&&!i,m=(null==i?void 0:i.window)?"".concat(i.window.start," → ").concat(i.window.end," \xb7 ").concat(i.properties.in_cohort," properties \xb7 ")+"".concat(i.days.billed.toLocaleStr
1ing()," billed days, ").concat(i.days.matched.toLocaleString()," matched \xb7 ")+"".concat(function(e){var a,t,l;let s=[e.utility.replace("_"," "),null!=(a=tR[e.phase])?a:e.phase.replace(/_/g," "),null!=(t=tM[e.coverage])?t:e.coverage.replace(/_/g," ")];return e.construction_type&&s.push(null!=(l=tG[e.construction_type])?l:e.construction_type.replace(/_/g," ")),s.join(" \xb7 ")}(i.parameters)," \xb7 platform reads as of ").concat(null!=(n=i.platform_as_of)?n:"—"):"…";return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("div",{className:"bg-white rounded-xl shadow-custom-tile p-5 mb-5 relative",children:[(0,l.jsx)("h3",{className:"text-xl font-bold text-brand-black mb-4",children:"Period roll-up"}),(0,l.jsx)("div",{className:"flex flex-wrap flex-col md:flex-row md:items-center text-sm 2xl:text-base font-semibold text-cyan-800 mb-4",children:m}),(0,l.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-3 gap-5 mb-5",children:d?d.comparison.map(e=>tH(i,e,o)):c&&tF.comparison.map(e=>tV(e))}),(0,l.jsx)("h3",{className:"text-xl font-bold text-brand-black mb-4",children:"Billed utility cost over the same window"}),(0,l.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-5 gap-5 mb-5",children:d?d.cost.map(e=>tH(i,e,o)):c&&tF.cost.map(e=>tV(e))}),i&&(0,l.jsx)("p",{className:"text-base text-brand-dark-gray",children:"Consumption tiles use the ".concat(i.parameters.utility.replace("_"," ")," usage on the bills; cost tiles sum every utility billed to these properties.")})]}),i&&i.gaps.length>0&&(0,l.jsx)(lS,{type:"single",collapsible:!0,children:(0,l.jsxs)(lE,{value:"alerts",className:"border border-brand-stroke rounded-lg mb-4",children:[(0,l.jsxs)(lL,{className:"rounded-lg px-5 py-6 data-[state=open]:border-b data-[state=open]:border-brand-stroke hover:text-inherit",children:["Data alerts (",i.gaps.length,")"]}),(0,l.jsx)(lA,{className:"px-5 pt-4 pb-6",children:(0,l.jsx)("ul",{className:"flex flex-col gap-2 text-sm text-brand-dark-gray",children:i.gaps.map(e=>(0,l.jsx)("li",{children:e.message},e.code))})})]})})]})}var tB=t(25667),tK=t(83101);let tW=tB.bL,tY=(0,tK.F)("inline-flex items-center gap-2 p-1 bg-gray-200 rounded-lg",{variants:{size:{default:"h-9",lg:"h-12"}},defaultVariants:{size:"default"}}),t$=r.forwardRef((e,a)=>{let{className:t,size:s,...r}=e;return(0,l.jsx)(tB.B8,{ref:a,className:(0,i.cn)(tY({size:s,className:t})),...r})});t$.displayName=tB.B8.displayName;let tZ=(0,tK.F)("rounded-md text-sm font-medium transition-colors whitespace-nowrap",{variants:{size:{default:"px-3 py-1 w-32",lg:"px-4 py-2 h-10"},theme:{default:"data-[state=active]:bg-white data-[state=active]:text-cyan-600 data-[state=active]:border-cyan-300 data-[state=inactive]:hover:text-brand-dark-cyan",red:"data-[state=active]:bg-red-50 data-[state=active]:text-brand-black data-[state=active]:border-red-400 data-[state=inactive]:hover:text-brand-black",sky:"data-[state=active]:bg-sky-50 data-[state=active]:text-brand-black data-[state=active]:border-sky-400 data-[state=inactive]:hover:text-brand-black",orange:"data-[state=active]:bg-orange-50 data-[state=active]:text-brand-black data-[state=active]:border-orange-400 data-[state=inactive]:hover:text-brand-black"}},defaultVariants:{size:"default",theme:"default"}}),tq=r.forwardRef((e,a)=>{let{className:t,size:s,theme:r,...n}=e;return(0,l.jsx)(tB.l9,{ref:a,className:(0,i.cn)(tZ({size:s,className:t,theme:r}),"data-[state=active]:shadow-xs data-[state=active]:border data-[state=inactive]:text-brand-dark-gray"),...n})});tq.displayName=tB.l9.displayName;let tJ=r.forwardRef((e,a)=>{let{className:t,...s}=e;return(0,l.jsx)(tB.UC,{ref:a,className:(0,i.cn)("mt-2 ring-offset-background focus-visible:outline-hidden",t),...s})});function tX(e){let{organizations:a,selectedOrganizations:t,setTempSelectedOrganizations:s,handleOrganizationsChange:r,commitTempOrganizations:n,propertyOptions:i,allPropertyOptions:o,selectedProperties:d,setTempSelectedProperties:c,handlePropertiesChange:m,commitTempProperties:u,isLoadingProperties:p,buildingOptions:x,isLoadingBuildings:h,selectedBuildings:g,setTempSelectedBuildings:y,handleBuildingsChange:f,commitTempBuildings:b,unitOptions:v,isLoadingUnits:N,selectedUnits:j,setTempSelectedUnits:_,handleUnitsChange:w,commitTempUnits:k,
1control:C,orderedReportsTypes:S,activeReportType:E,onActiveReportTypeChange:L,requiresDateRange:A,contentOptions:D,isLoadingReportsTypes:O,selectedContents:T,setTempSelectedContents:I,handleContentsChange:P,commitTempContents:R,dateRange:M,tempDateRange:G,isCalendarOpen:z,handleCalendarOpenChange:F,handleTempDateRangeChange:H,handleDateRangeReset:V,handleDateRangeApply:U,isGenerating:B,isDisabled:K,onGenerate:W,handleReset:Y}=e;return(0,l.jsxs)("div",{className:"bg-white rounded-xl shadow-custom-tile py-6 px-5 mb-6",children:[(0,l.jsx)("div",{className:"flex justify-between items-start mb-2",children:(0,l.jsx)("h3",{className:"text-xl font-bold",children:"Generate Report"})}),(0,l.jsx)("p",{className:"text-base text-brand-dark-gray mb-6",children:"Use Yesterday Reports for data from the previous day, or Historical Reports to generate reports for any custom date range."}),(0,l.jsxs)("div",{className:"flex items-center justify-between gap-4",children:[(0,l.jsxs)("div",{className:"flex items-center flex-wrap gap-4",children:[S.length>0&&(0,l.jsx)(tW,{value:E,onValueChange:L,children:(0,l.jsx)(t$,{children:S.map(e=>(0,l.jsx)(tq,{value:e.type,className:"w-auto px-4",disabled:O||B,children:e.name},e.type))})}),(0,l.jsx)("div",{className:"w-full md:w-60 2xl:w-80",children:(0,l.jsx)(sm,{placeholder:"Select Organizations",control:C,name:"organizations",options:a.map(e=>({label:e.name,value:e.id.toString()})),showSelectAll:!0,onSelectionChange:e=>{s(e),e.length<t.length&&r(e)},onMenuClose:n,clearButton:!1,isDisabled:p})}),(0,l.jsx)("div",{className:"w-full md:w-60 2xl:w-80",children:p?(0,l.jsx)("div",{className:"flex justify-center p-4",children:(0,l.jsx)(ee.A,{className:"h-6 w-6 animate-spin text-brand-dark-cyan"})}):(0,l.jsx)(sm,{placeholder:"Select Properties",control:C,name:"properties",options:null!=o?o:i,showSelectAll:!0,excludeFromSelectAll:[ao.f],onSelectionChange:e=>{c(e),e.length<d.length&&m(e)},onMenuClose:u,clearButton:!1,isDisabled:p})}),(()=>{let e=1===d.length;return(0,l.jsxs)(au.TooltipProvider,{delayDuration:150,children:[(0,l.jsx)("div",{className:"w-full md:w-60 2xl:w-80",children:h?(0,l.jsx)("div",{className:"flex justify-center p-4",children:(0,l.jsx)(ee.A,{className:"h-6 w-6 animate-spin text-brand-dark-cyan"})}):(0,l.jsxs)(au.m_,{children:[(0,l.jsx)(au.k$,{asChild:!0,children:(0,l.jsx)("div",{children:(0,l.jsx)(sm,{placeholder:"Select Buildings",control:C,name:"buildings",options:x,showSelectAll:!0,onSelectionChange:e=>{y(e),e.length<g.length&&f(e)},onMenuClose:b,clearButton:!1,isDisabled:!e||0===x.length||h})})}),!e&&(0,l.jsx)(au.ZI,{children:ap})]})}),(0,l.jsx)("div",{className:"w-full md:w-60 2xl:w-80",children:N?(0,l.jsx)("div",{className:"flex justify-center p-4",children:(0,l.jsx)(ee.A,{className:"h-6 w-6 animate-spin text-brand-dark-cyan"})}):(0,l.jsxs)(au.m_,{children:[(0,l.jsx)(au.k$,{asChild:!0,children:(0,l.jsx)("div",{children:(0,l.jsx)(sm,{placeholder:"Select Units",control:C,name:"units",options:v,showSelectAll:!0,onSelectionChange:e=>{_(e),e.length<j.length&&w(e)},onMenuClose:k,clearButton:!1,isDisabled:!e||0===g.length||0===v.length||N})})}),!e&&(0,l.jsx)(au.ZI,{children:ap})]})})]})})(),(0,l.jsx)("div",{className:"w-full md:w-60 2xl:w-80",children:O?(0,l.jsx)("div",{className:"flex justify-center p-4",children:(0,l.jsx)(ee.A,{className:"h-6 w-6 animate-spin text-brand-dark-cyan"})}):(0,l.jsx)(sm,{placeholder:"Select Contents",control:C,name:"reportsTypes",options:D,showSelectAll:!0,onSelectionChange:e=>{I(e),e.length<T.length&&P(e)},onMenuClose:R,clearButton:!1,isDisabled:O})}),A&&(0,l.jsx)(l1,{dateRange:M,tempDateRange:G,isCalendarOpen:z,onCalendarOpenChange:F,onTempDateRangeChange:H,onReset:V,onApply:U,isActive:!!M.from&&!!M.to,isDisabled:O,className:"h-[38px]"}),(0,l.jsx)(e$.$,{variant:"tertiary",onClick:Y,disabled:O||p,className:"text-sm font-medium text-brand-dark-gray underline p-0 hover:text-brand-dark-cyan",children:"Reset"})]}),(0,l.jsx)(e$.$,{variant:"primary",onClick:W,disabled:K,loading:B,children:"Generate Report"})]})]})}function tQ(e){let{reports:a,isLoadingReports:t,totalCount:s,page:r,pageSize:n,exportReportStatuses:i,isLoadingStatuses:o,selectedStatuses:d,isStatusFilterOpen:c,setSelectedStatuses:m,setIsStatusFilterOpen:u,handleSort:p,handlePageChange:x,handlePageSizeChange:h,handleStatusFilterApply:g,handleStatusFilterReset:y,buildReportsParams:f}=e;return(0,l.jsxs)("div",{className:"bg-white rounded-xl shadow-custom-tile py-6 px-5 mb-6",children:[(0,l.jsxs)("div",{className:"flex justify-between items-start mb-6",children:[(0,l.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,l.jsx)("h3",{className:"text-xl font-bold",children:"Report History"}),(0,l.jsx)("p",{className:"text-base text-brand-dark-gray",children:"View all Reports requested by you."})]}),o?(0,l.jsx)("div",{className:"flex justify-center p-4",children:(0,l.jsx)(ee.A,{className:"h-6 w-6 animate-spin text-brand-dark-cyan"})}):(0,l.jsx)(eq,{title:"Status",options:i.map(e=>({label:e.name,value:e.id.toString()})),selectedValues:d,onSelectedChange:m,isOpen:c,onOpenChange:u,isDisabled:0===i.length,onApply:g,onReset:y,className:"right-0"})]}),(0,l.jsx)(lx,{data:a,isLoading:t,params:f(),onSort:p,totalCount:s,onPageChange:x,currentPage:r,pageSize:n,onPageSizeChange:h})]})}tJ.displayName=tB.UC.displayName;var t0=t(52056);function t1(e){let{data:a,params:t,onSort:s,isLoading:r,totalCount:n=0,onPageChange:i,currentPage:o=0,onViewProperties:d,pageSize:c,onPageSizeChange:m}=e,u=Math.ceil(n/(c||10)),p=u>1,{getSortableHeaderProps:x}=(0,ep.M)({params:t,onSort:s,isLoading:r,data:a}),h=[{accessorKey:"name",header:()=>{let e=x("name","Organization Name","start");return(0,l.jsxs)("div",{className:e.className,onClick:e.onClick,children:[(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(em.A,{className:e.upIconClassName}),(0,l.jsx)(eu.A,{className:e.downIconClassName})]}),(0,l.jsx)("span",{children:e.label})]})},cell:e=>{let{row:a}=e;return a.original.is_default?(0,l.jsxs)("div",{className:"text-orange-900 flex items-center gap-2",children:[(0,l.jsx)(t0.A,{className:"w-5 h-5 text-orange-400"}),"Default Organization"]}
1):a.original.name||"-"}},{accessorKey:"properties_count",header:"Properties",cell:e=>{let{row:a}=e;return(0,l.jsx)("div",{children:a.original.properties_count})}},{accessorKey:"units_count",header:"Units"},{id:"actions",header:"Actions",size:180,enableResizing:!1,cell:e=>{let{row:a}=e;return(0,l.jsx)("div",{className:"flex items-center gap-3",children:(0,l.jsx)(e$.$,{variant:"secondary",onClick:()=>null==d?void 0:d(a.original.id),size:"sm",children:"View Properties"})})},meta:{fixedWidth:!0}}];return(0,l.jsx)(eU.b,{columns:h,data:a,columnVisibility:{},onColumnVisibilityChange:()=>{},columnOrder:[],isLoading:r,pageCount:p?u:void 0,pageIndex:p?o:void 0,onPageChange:p?i:void 0,showPageSizeSelector:!0,pageSize:c,onPageSizeChange:m})}function t2(e){let{data:a,params:t,onSort:s,isLoading:n,totalCount:i=0,onPageChange:o,currentPage:d=0,selectedRowIds:c,onSelectionChange:m,pageSize:u,onPageSizeChange:p}=e,[x,h]=(0,r.useState)(new Set),g=Math.ceil(i/(u||10)),y=g>1,{getSortableHeaderProps:f}=(0,ep.M)({params:t,onSort:s,isLoading:n,data:a}),b=(0,r.useMemo)(()=>c?new Set(c):x,[c,x]),v=(0,r.useMemo)(()=>{let e={};return a.forEach((a,t)=>{e[t]=b.has(a.id.toString())}),e},[a,b]),N=[{id:"select",header:()=>{let e=null!=a&&!!a.length&&a.every(e=>b.has(e.id.toString()));return(0,l.jsx)(lZ,{id:"select-all",checked:e,onCheckedChange:e=>{let t=new Set(b);a.forEach(a=>{let l=a.id.toString();e?t.add(l):t.delete(l)}),h(t),null==m||m(Array.from(t))},"aria-label":"Select all"})},cell:e=>{let{row:a}=e;return(0,l.jsx)(lZ,{checked:b.has(a.original.id.toString()),onCheckedChange:e=>{let t=new Set(b),l=a.original.id.toString();e?t.add(l):t.delete(l),h(t),null==m||m(Array.from(t))},"aria-label":"Select ".concat(a.original.name)})}},{accessorKey:"name",header:()=>{let e=f("name","Property Name","start");return(0,l.jsxs)("div",{className:e.className,onClick:e.onClick,children:[(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(em.A,{className:e.upIconClassName}),(0,l.jsx)(eu.A,{className:e.downIconClassName})]}),(0,l.jsx)("span",{children:e.label})]})}},{accessorKey:"address",header:"Address"},{accessorKey:"buildings_count",header:"Buildings"},{accessorKey:"units_count",header:"Units"},{accessorKey:"organization_name",header:"Organization",cell:e=>{let{row:a}=e;return a.original.organization_is_default?(0,l.jsxs)("div",{className:"text-orange-900 flex items-center gap-2",children:[(0,l.jsx)(t0.A,{className:"w-5 h-5 text-orange-400"}),"Default Organization"]}):a.original.organization_name}}];return(0,l.jsx)(eU.b,{columns:N,data:a,columnVisibility:{},onColumnVisibilityChange:()=>{},columnOrder:[],isLoading:n,pageCount:y?g:void 0,pageIndex:y?d:void 0,onPageChange:y?o:void 0,selectedRows:v,onRowSelectionChange:e=>{let t="function"==typeof e?e(v):e,l=new Set(b);a.forEach((e,a)=>{let s=e.id.toString();t[a]?l.add(s):l.delete(s)}),h(l),null==m||m(Array.from(l))},cellHeight:"",showPageSizeSelector:!0,pageSize:u,onPageSizeChange:p})}var t5=t(89837),t3=t(12933),t4=t(52956);function t6(e){var a,t;let{activeMainTab:s,activeMeterTab:r,activePropertyTab:n,leakOverview:i,meterLevelConsumption:o,propertyLevelConsumption:d,leakOverviewColumns:c,meterLevelColumns:m,propertyLevelColumns:u,buildLeakOverviewParams:p,buildMeterLevelConsumptionParams:x,buildPropertyLevelConsumptionParams:h,onLeakOverviewSort:g,onMeterLevelSort:y,onPropertyLevelSort:f,onLeakOverviewPageChange:b,onMeterLevelPageChange:v,onPropertyLevelPageChange:N,dateRangeLabel:j,onFilterClick:_,onLeakOverviewPageSizeChange:w,onMeterLevelPageSizeChange:k,onPropertyLevelPageSizeChange:C,isPropertyPage:S,onPropertyFilterClick:E,onBuildingFilterClick:L,onUnitFilterClick:A,onMetersFiltersClick:D,hourlyDrilldown:O,hourlyDrilldownData:T,onShowHourly:I,onGoBackFromHourly:P,onHourlyDrilldownPageChange:R,onHourlyDrilldownPageSizeChange:M,onHourlyDrilldownSort:G,buildHourlyDrilldownDataParams:z,propertyHourlyDrilldown:F,propertyHourlyDrilldownData:H,onShowPropertyHourly:V,onGoBackFromPropertyHourly:U,onPropertyHourlyDrilldownPageChange:B,onPropertyHourlyDrilldownPageSizeChange:K,onPropertyHourlyDrilldownSort:W,buildPropertyHourlyDrilldownDataParams:Y}=e;if("leak-overview"===s)return(0,l.jsx)(ls.r,{data:i.data,isLoading:i.loading,columnVisibility:c.columnVisibility,columnOrder:c.orderedColumns,onColumnVisibilityChange:e=>{let a=Object.entries(e).filter(e=>{let[,a]=e;return a}).map(e=>{let[a]=e;return a});c.setSelectedColumns(a)},params:p(),onSort:g,pageCount:Math.ceil(i.count/i.pageSize),pageIndex:i.page,onPageChange:b,dateRangeLabel:j,onFilterClick:_,pageSize:i.pageSize,onPageSizeChange:w,isPropertyPage:S,onPropertyFilterClick:E,onBuildingFilterClick:L,onUnitFilterClick:A});
1if("tenant-consumption"===s){let e={isLoading:o.loading,params:x(),onSort:y,totalCount:o.count,currentPage:o.page,onPageChange:v,columnVisibility:m.columnVisibility,columnOrder:m.orderedColumns,onColumnVisibilityChange:e=>{let a=Object.entries("function"==typeof e?e(m.columnVisibility):e).filter(e=>{let[,a]=e;return a}).map(e=>{let[a]=e;return a});m.setSelectedColumns(a)},pageSize:o.pageSize,onPageSizeChange:k};return"day"===r&&O&&T?(0,l.jsxs)("div",{className:"space-y-2",children:[(0,l.jsx)("div",{className:"flex items-center gap-4",children:(0,l.jsxs)(e$.$,{variant:"tertiary",size:"sm",onClick:P,className:"flex items-center gap-3 text-brand-deep-sea-blue text-base font-semibold hover:text-brand-black",children:[(0,l.jsx)(eo.A,{className:"w-6 h-6 text-brand-dark-gray"}),"Go Back"]})}),(0,l.jsx)(t9.m,{data:T.data,isLoading:T.loading,totalCount:T.count,currentPage:T.page,onPageChange:R,params:null!=(a=null==z?void 0:z())?a:{},onSort:G,columnVisibility:m.columnVisibility,columnOrder:m.orderedColumns,onColumnVisibilityChange:()=>{},pageSize:T.pageSize,onPageSizeChange:M,onBuildingFilterClick:L,onUnitFilterClick:A,onMetersFiltersClick:D})]}):(0,l.jsxs)(l.Fragment,{children:["day"===r&&(0,l.jsx)(t5.h,{...e,data:o.data,onBuildingFilterClick:L,onUnitFilterClick:A,onMetersFiltersClick:D,onShowHourly:I}),"hour"===r&&(0,l.jsx)(t9.m,{...e,data:o.data,onBuildingFilterClick:L,onUnitFilterClick:A,onMetersFiltersClick:D})]})}if("property-consumption"===s){let e={isLoading:d.loading,params:h(),onSort:f,totalCount:d.count,currentPage:d.page,onPageChange:N,columnVisibility:u.columnVisibility,columnOrder:u.orderedColumns,onColumnVisibilityChange:e=>{let a=Object.entries("function"==typeof e?e(u.columnVisibility):e).filter(e=>{let[,a]=e;return a}).map(e=>{let[a]=e;return a});u.setSelectedColumns(a)},pageSize:d.pageSize,onPageSizeChange:C};return"day"===n&&F&&H?(0,l.jsxs)("div",{className:"space-y-2",children:[(0,l.jsx)("div",{className:"flex items-center gap-4",children:(0,l.jsxs)(e$.$,{variant:"tertiary",size:"sm",onClick:U,className:"flex items-center gap-3 text-brand-deep-sea-blue text-base font-semibold hover:text-brand-black",children:[(0,l.jsx)(eo.A,{className:"w-6 h-6 text-brand-dark-gray"}),"Go Back"]})}),(0,l.jsx)(t7,{data:H.data,isLoading:H.loading,pageCount:Math.ceil(H.count/H.pageSize),pageIndex:H.page,onPageChange:null!=B?B:()=>{},params:null!=(t=null==Y?void 0:Y())?t:{},onSort:W,columnVisibility:Object.fromEntries(t4.RO.map(e=>[e,!0])),columnOrder:t4.RO,onColumnVisibilityChange:()=>{},pageSize:H.pageSize,onPageSizeChange:K})]}):(0,l.jsxs)(l.Fragment,{children:["day"===n&&(0,l.jsx)(t3.$,{...e,data:d.data,onMetersFiltersClick:D,onShowHourly:V}),"hour"===n&&(0,l.jsx)(t8.D,{...e,data:d.data,onMetersFiltersClick:D})]})}return null}var t8=t(55699),t9=t(58518);function t7(e){let{data:a,isLoading:t,columnVisibility:s,columnOrder:r,onColumnVisibilityChange:n,pageCount:o,pageIndex:d,onPageChange:c,params:m,pageSize:u,onSort:p,onPageSizeChange:x}=e,{getSortableHeaderProps:h}=(0,ep.M)({params:m,onSort:p,isLoading:t,data:a}),g=[{id:"property_name",accessorKey:"property_name",header:()=>{let e=h("property_name","Property","start");return(0,l.jsxs)("div",{className:(0,i.cn)(e.className,"min-w-24"),onClick:e.onClick,children:[(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(em.A,{className:e.upIconClassName}),(0,l.jsx)(eu.A,{className:e.downIconClassName})]}),(0,l.jsx)("span",{children:e.label})]})}},{id:"building_name",accessorKey:"building_name",header:"Building"},{id:"meter_serial_number",accessorKey:"meter_serial_number",header:"Device Serial Number"},{id:"period",accessorKey:"period",header:()=>{let e=h("period","Period","start");return(0,l.jsxs)("div",{className:(0,i.cn)(e.className,"min-w-24"),onClick:e.onClick,children:[(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(em.A,{className:e.upIconClassName}),(0,l.jsx)(eu.A,{className:e.downIconClassName})]}),(0,l.jsx)("span",{children:e.label})]})}},{id:"hour",accessorKey:"hour",header:"Hour"},{id:"gallons_consumed",accessorKey:"gallons_consumed",header:()=>{let e=h("gallons_consumed","Gallons","end");return(0,l.jsxs)("div",{className:e.className,onClick:e.onClick,children:[(0,l.jsx)("span",{className:"text-right",children:e.label}),(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(em.A,{className:e.upIconClassName}),(0,l.jsx)(eu.A,{className:e.downIconClassName})]})]})},cell:e=>{var a;let{row:t}=e;return(0,l.jsx)("div",{className:"flex justify-end w-full",children:(0,l.jsx)("span",{className:"text-right pr-6",children:(null!=(a=t.original.gallons_consumed)?a:0).toLocaleStr
1ing()})})}}];return(0,l.jsx)(eU.b,{columns:g,data:a,columnVisibility:s,columnOrder:r,onColumnVisibilityChange:n,isLoading:t,pageCount:o,pageIndex:d,onPageChange:c,onPageSizeChange:x,showPageSizeSelector:!0,pageSize:u})}function le(e){let{data:a,isLoading:t,totalCount:s=0,onPageChange:r,currentPage:n=0,params:i,onSort:o,columnVisibility:d,columnOrder:c,onColumnVisibilityChange:m,pageSize:u,onPageSizeChange:p,menuPlacement:x,onBuildingFilterClick:h,onUnitFilterClick:g}=e,y=Math.ceil(s/(u||10)),f=y>1,{getSortableHeaderProps:b}=(0,ep.M)({params:i,onSort:o,isLoading:t,data:a}),v=[{id:"building_name",accessorKey:"building_name",header:()=>{let e=b("building_name","Building","start");return(0,l.jsxs)("div",{className:e.className,onClick:e.onClick,children:[(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(em.A,{className:e.upIconClassName}),(0,l.jsx)(eu.A,{className:e.downIconClassName})]}),(0,l.jsx)("span",{children:e.label})]})},cell:e=>{let{row:a}=e;return(0,l.jsx)("div",{className:"flex items-center w-full h-full min-w-28 cursor-pointer hover:underline hover:text-brand-dark-cyan transition-colors",onClick:()=>null==h?void 0:h(a.original.property_id,a.original.building_id),children:a.original.building_name})},meta:{name:"Building"}},{id:"unit_name",accessorKey:"unit_name",header:()=>{let e=b("unit_name","Unit","start");return(0,l.jsxs)("div",{className:e.className,onClick:e.onClick,children:[(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(em.A,{className:e.upIconClassName}),(0,l.jsx)(eu.A,{className:e.downIconClassName})]}),(0,l.jsx)("span",{children:e.label})]})},cell:e=>{let{row:a}=e;return(0,l.jsx)("div",{className:"flex items-center w-full h-full cursor-pointer hover:underline hover:text-brand-dark-cyan transition-colors",onClick:()=>null==g?void 0:g(a.original.property_id,a.original.building_id,a.original.unit_id),children:a.original.unit_name})},meta:{name:"Unit"}},{id:"attached_to",accessorKey:"attached_to",header:()=>(0,l.jsx)("span",{className:"min-w-24",children:"Attached To"}),meta:{name:"Attached To"}},{id:"meter_serial_number",accessorKey:"meter_serial_number",header:()=>(0,l.jsx)("span",{className:"min-w-44",children:"Device Serial Number"}),meta:{name:"Device Serial Number"}},{id:"date",accessorKey:"date",header:()=>{let e=b("date","Date","start");return(0,l.jsxs)("div",{className:e.className,onClick:e.onClick,children:[(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(em.A,{className:e.upIconClassName}),(0,l.jsx)(eu.A,{className:e.downIconClassName})]}),(0,l.jsx)("span",{children:e.label})]})},cell:e=>{let{row:a}=e;return(0,l.jsx)("div",{children:a.original.date?(0,et.GP)(a.original.date,"MMM dd, yyyy"):"-"})},meta:{name:"Date"}},{id:"gallons_consumed",accessorKey:"gallons_consumed",header:()=>{let e=b("gallons_consumed","Gallons");return(0,l.jsxs)("div",{className:e.className,onClick:e.onClick,children:[(0,l.jsx)("span",{className:"text-right",children:e.label}),(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(em.A,{className:e.upIconClassName}),(0,l.jsx)(eu.A,{className:e.downIconClassName})]})]})},cell:e=>{let{row:a}=e;return(0,l.jsx)("div",{className:"flex justify-end w-full",children:(0,l.jsx)("span",{className:"text-right pr-6",children:Math.round(a.original.gallons_consumed).toLocaleString()})})},meta:{name:"Gallons"}},{id:"events",accessorKey:"events",header:()=>{let e=b("events","Events");return(0,l.jsxs)("div",{className:e.className,onClick:e.onClick,children:[(0,l.jsx)("span",{className:"text-right",children:e.label}),(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(em.A,{className:e.upIconClassName}),(0,l.jsx)(eu.A,{className:e.downIconClassName})]})]})},cell:e=>{let{row:a}=e;return(0,l.jsx)("div",{className:"flex justify-end w-full",children:(0,l.jsx)("span",{className:"text-right pr-6",children:a.original.events.toLocaleString()})})},meta:{name:"Events"}},{id:"gallons_leaked",accessorKey:"gallons_leaked",header:()=>{let e=b("gallons_leaked","Leak Gallons");return(0,l.jsxs)("div",{className:e.className,onClick:e.onClick,children:[(0,l.jsx)("span",{className:"text-right",children:e.label}),(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(em.A,{className:e.upIconClassName}),(0,l.jsx)(eu.A,{className:e.downIconClassName})]})]})},cell:e=>{let{row:a}=e;return(0,l.jsx)("div",{className:"flex justify-end w-full",children:(0,l.jsx)("span",{className:"text-right pr-6",children:Math.round(a.original.gallons_leaked).toLocaleStr
1ing()})})},meta:{name:"Leak Gallons"}},{id:"toilet_leaks",accessorKey:"toilet_leaks",header:()=>{let e=b("toilet_leaks","Toilet Leaks");return(0,l.jsxs)("div",{className:e.className,onClick:e.onClick,children:[(0,l.jsx)("span",{className:"text-right",children:e.label}),(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(em.A,{className:e.upIconClassName}),(0,l.jsx)(eu.A,{className:e.downIconClassName})]})]})},cell:e=>{let{row:a}=e;return(0,l.jsx)("div",{className:"flex justify-end w-full",children:(0,l.jsx)("span",{className:"text-right pr-6",children:Math.round(a.original.toilet_leaks).toLocaleString()})})},meta:{name:"Toilet Leaks"}},{id:"other_leaks",accessorKey:"other_leaks",header:()=>{let e=b("other_leaks","Other Leaks");return(0,l.jsxs)("div",{className:e.className,onClick:e.onClick,children:[(0,l.jsx)("span",{className:"text-right",children:e.label}),(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(em.A,{className:e.upIconClassName}),(0,l.jsx)(eu.A,{className:e.downIconClassName})]})]})},cell:e=>{let{row:a}=e;return(0,l.jsx)("div",{className:"flex justify-end w-full",children:(0,l.jsx)("span",{className:"text-right pr-6",children:Math.round(a.original.other_leaks).toLocaleString()})})},meta:{name:"Other Leaks"}},{id:"leak_volume_percentage",accessorKey:"leak_volume_percentage",header:()=>{let e=b("leak_volume_percentage","Leak Volume %");return(0,l.jsxs)("div",{className:e.className,onClick:e.onClick,children:[(0,l.jsx)("span",{className:"text-right min-w-22",children:e.label}),(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(em.A,{className:e.upIconClassName}),(0,l.jsx)(eu.A,{className:e.downIconClassName})]})]})},cell:e=>{let{row:a}=e;return(0,l.jsx)("div",{className:"flex justify-end w-full",children:(0,l.jsxs)("span",{className:"text-right pr-6",children:[Math.round(a.original.leak_volume_percentage).toLocaleString(),"%"]})})},meta:{name:"Leak Volume %"}}];return(0,l.jsx)(eU.b,{columns:v,data:a,columnVisibility:d||{},onColumnVisibilityChange:m||(()=>{}),columnOrder:c||[],getRowClassName:()=>"",isLoading:t,pageCount:f?y:void 0,pageIndex:f?n:void 0,onPageChange:f?r:void 0,headerClassName:"h-14",headerColor:"text-brand-black",showPageSizeSelector:!0,pageSize:u,onPageSizeChange:p,menuPlacement:x})}function la(e){let{data:a,isLoading:t,totalCount:s=0,onPageChange:r,currentPage:n=0,params:o,onSort:d,pageSize:c,onPageSizeChange:m}=e,u=Math.ceil(s/(c||10)),p=u>1,{getSortableHeaderProps:x}=(0,ep.M)({params:o,onSort:d,isLoading:t,data:a}),h=[{accessorKey:"source",header:()=>(0,l.jsx)("span",{children:"Source"})},{accessorKey:"building_name",header:()=>{let e=x("building_name","Building","start");return(0,l.jsxs)("div",{className:e.className,onClick:e.onClick,children:[(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(em.A,{className:e.upIconClassName}),(0,l.jsx)(eu.A,{className:e.downIconClassName})]}),(0,l.jsx)("span",{children:e.label})]})}},{accessorKey:"unit_name",header:()=>{let e=x("unit_name","Unit","start");return(0,l.jsxs)("div",{className:e.className,onClick:e.onClick,children:[(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(em.A,{className:e.upIconClassName}),(0,l.jsx)(eu.A,{className:e.downIconClassName})]}),(0,l.jsx)("span",{children:e.label})]})}},{accessorKey:"attached_to",header:()=>(0,l.jsx)("span",{className:"min-w-24",children:"Attached To"})},{accessorKey:"meter_serial_number",header:()=>(0,l.jsx)("span",{className:"min-w-44",children:"Device Serial Number"})},{accessorKey:"device_type",header:()=>{let e=x("device_type","Device Type","start");return(0,l.jsxs)("div",{className:e.className,onClick:e.onClick,children:[(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(em.A,{className:e.upIconClassName}),(0,l.jsx)(eu.A,{className:e.downIconClassName})]}),(0,l.jsx)("span",{className:"min-w-28",children:e.label})]})},cell:e=>{let{row:a}=e;return(0,l.jsx)("div",{className:"capitalize",children:a.original.device_type.replace(/_/g," ")})}},{accessorKey:"status",header:()=>{let e=x("status","Status","start");return(0,l.jsxs)("div",{className:e.className,onClick:e.onClick,children:[(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(em.A,{className:e.upIconClassName}),(0,l.jsx)(eu.A,{className:e.downIconClassName})]}),(0,l.jsx)("span",{children:e.label})]})},cell:e=>{let{row:a}=e;return(0,l.jsx)("div",{className:(0,i.cn)("px-2 py-1 rounded-md","offline"===a.original.status||a.original.status.includes("delayed")?"bg-red-100 text-brand-red":"online"===a.original.status?"bg-green-100 text-green-600":"bg-gray-100 text-gray-600"),children:(0,l.jsx)("span",{className:"text-sm font-medium whitespace-nowrap",children:a.original.status.charAt(0).toUpperCase()+a.original.status.slice(1).toLowerCase()})})}},{accessorKey:"days_offline",size:135,enableResizing:!1,header:()=>{let e=x("days_offline","Days Offline","start");return(0,l.jsxs)("div",{className:e.className,onClick:e.onClick,children:[(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(em.A,{className:e.upIconClassName}),(0,l.jsx)(eu.A,{className:e.downIconClassName})]}),(0,l.jsx)("span",{children:e.label})]})},cell:e=>{let{row:a}=e;return(0,l.jsx)("div",{className:"flex items-center justify-end w-full",children:(0,l.jsx)("span",{children:a.original.days_offline})})},meta:{fixedWidth:!0}}];return(0,l.jsx)(eU.b,{columns:h,data:a,columnVisibility:{},onColumnVisibilityChange:()=>{},columnOrder:[],getRowClassName:()=>"",isLoading:t,pageCount:p?u:void 0,pageIndex:p?n:void 0,onPageChange:p?r:void 0,headerClassName:"h-14",headerColor:"text-brand-black",showPageSizeSelector:!0,pageSize:c,onPageSizeChange:m,menuPlacement:"top"})}function lt(e){let{data:a,isLoading:t,totalCount:s=0,onPageChange:r,currentPage:n=0,params:i,onSort:o,headerClassName:d,pageSize:c,onPageSizeChange:m,isDownGateways:u}=e,p=Math.ceil(s/(c||10)),x=p>1,{getSortableHeaderProps:h}=(0,ep.M)({params:i,onSort:o,isLoading:t,data:a}),g=[...u?[{accessorKey:"state",header:()=>(0,l.jsx)("span",{children:"State"})}]:[],...u?[]:[{accessorKey:"source",header:()=>(0,l.jsx)("span",{children:"Source"})},{accessorKey:"state",header:()=>(0,l.jsx)("span",{children:"State"})}],{accessorKey:"property_name",header:()=>(0,l.jsx)("span",{children:"Property"})},{accessorKey:"building_name",header:()=>{let e=h("building_name","Building","start");return(0,l.jsxs)("div",{className:e.className,onClick:e.onClick,children:[(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(em.A,{className:e.upIconClassName}),(0,l.jsx)(eu.A,{className:e.downIconClassName})]}),(0,l.jsx)("span",{children:e.label})]})}},{accessorKey:"unit_name",header:()=>{let e=h("unit_name","Unit","start");return(0,l.jsxs)("div",{className:e.className,onClick:e.onClick,children:[(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(em.A,{className:e.upIconClassName}),(0,l.jsx)(eu.A,{className:e.downIconClassName})]}),(0,l.jsx)("span",{children:e.label})]})}},{accessorKey:"attached_to",header:()=>(0,l.jsx)("span",{className:"min-w-24",children:"Attached To"})},...u?[{accessorKey:"location",header:()=>(0,l.jsx)("span",{className:"min-w-24",children:"Location"})}]:[],{accessorKey:"meter_serial_number",header:()=>(0,l.jsx)("span",{className:"min-w-24",children:"Device Serial Number"})},{accessorKey:"device_type",header:()=>{let e=h("device_type","Device Type","start");return(0,l.jsxs)("div",{className:e.className,onClick:e.onClick,children:[(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(em.A,{className:e.upIconClassName}),(0,l.jsx)(eu.A,{className:e.downIconClassName})]}),(0,l.jsx)("span",{className:"min-w-28",children:e.label})]})},cell:e=>{let{row:a}=e;return(0,l.jsx)("div",{className:"capitalize",children:a.original.device_type})}},{accessorKey:"days_offline",size:135,enableResizing:!1,header:()=>{let e=h("days_offline","Days Offline","start");return(0,l.jsxs)("div",{className:e.className,onClick:e.onClick,children:[(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(em.A,{className:e.upIconClassName}),(0,l.jsx)(eu.A,{className:e.downIconClassName})]}),(0,l.jsx)("span",{children:e.label})]})},cell:e=>{let{row:a}=e;return(0,l.jsx)("div",{className:"flex items-center justify-end w-full",children:(0,l.jsx)("span",{children:a.original.days_offline})})},meta:{fixedWidth:!0}}];return(0,l.jsx)(eU.b,{columns:g,data:a,columnVisibility:{},onColumnVisibilityChange:()=>{},columnOrder:[],getRowClassName:()=>"",isLoading:t,pageCount:x?p:void 0,pageIndex:x?n:void 0,onPageChange:x?r:void 0,headerClassName:d,headerColor:"text-brand-black",showPageSizeSelector:!0,pageSize:c,onPageSizeChange:m})}var ll=t(75134),ls=t(56375);function lr(e){let{data:a,count:t,page:s,pageSize:r,ordering:n,isLoading:i,onPageChange:o,onPageSizeChange:d,onSort:c,exp
1andedPropertyId:m,chartOpen:u,periodsOpen:p,onToggleDisclosure:x,renderExpanded:h}=e,g=Math.ceil(t/(r||10)),{getSortableHeaderProps:y}=(0,ep.M)({params:{ordering:n},onSort:c,isLoading:i,data:a}),f=[{accessorKey:"name",header:()=>{let e=y("name","Property","start");return(0,l.jsxs)("div",{className:e.className,onClick:e.onClick,children:[(0,l.jsx)("span",{children:e.label}),(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(em.A,{className:e.upIconClassName}),(0,l.jsx)(eu.A,{className:e.downIconClassName})]})]})},cell:e=>{let{row:a}=e,t=a.original,s=t.property_id===m,r=s&&p,n=s&&u;return(0,l.jsxs)("div",{className:"flex items-start gap-2 min-w-56",children:[(0,l.jsx)(e$.$,{variant:"ghost",size:"extraSmall",onClick:e=>{e.stopPropagation(),x(t.property_id,"periods")},"aria-expanded":r,"aria-label":r?"Hide details for ".concat(t.name):"Show details for ".concat(t.name),children:r?(0,l.jsx)(to.A,{className:"h-4 w-4"}):(0,l.jsx)(eQ.A,{className:"h-4 w-4"})}),(0,l.jsxs)("div",{children:[(0,l.jsx)("p",{className:"font-medium text-brand-black",children:t.name}),(0,l.jsxs)("p",{className:"text-xs text-brand-dark-gray",children:[t.units," units \xb7 ",t.bedrooms," bedrooms"]}),(0,l.jsx)(e$.$,{variant:"ghost",size:"extraSmall",className:"h-auto w-auto min-w-0 p-0 mt-1 text-[10px] font-semibold uppercase tracking-wider text-brand-dark-gray",onClick:e=>{e.stopPropagation(),x(t.property_id,"chart")},"aria-expanded":n,"aria-label":n?"Hide GBD chart for ".concat(t.name):"Show GBD chart for ".concat(t.name),children:n?"Hide GBD chart":"Show GBD chart"})]})]})}},{id:"days",header:"Days",cell:e=>{let{row:a}=e;return(0,l.jsxs)("span",{children:[a.original.days.matched,"/",a.original.days.billed]})}},{id:"municipal_gallons",header:"Muni gal",cell:e=>{let{row:a}=e;return a2(a.original.municipal_gallons,a$,aF)}},{id:"municipal_gbd",header:"Muni GBD",cell:e=>{let{row:a}=e;return a2(a.original.municipal_gbd,aq(a.original),aH)}},{id:"platform_gallons",header:"Platform gal",cell:e=>{let{row:a}=e;return a2(a.original.platform_gallons,aJ(a.original),aF)}},{id:"platform_gbd",header:"Platform GBD",cell:e=>{let{row:a}=e;return a2(a.original.platform_gbd,aX(a.original),aH)}},{id:"delta_gallons",header:"Δ gal",cell:e=>{let{row:a}=e;return a5(a.original.delta_gallons,a.original.delta_tone,a0(a.original),aW)}},{id:"delta_percent",header:"Δ %",cell:e=>{let{row:a}=e;return a5(a.original.delta_percent,a.original.delta_tone,a0(a.original),aY)}},{id:"leak_share",header:()=>(0,l.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,l.jsx)("span",{children:"Leak share"}),(0,l.jsxs)(au.m_,{children:[(0,l.jsx)(au.k$,{"aria-label":"Leak share definition",children:(0,l.jsx)(ey.A,{className:"w-4 h-4 text-brand-dark-gray"})}),(0,l.jsx)(au.ZI,{children:"Share of platform gallons ION flagged as leaking over the matched days (ION leak trigger)."})]})]}),cell:e=>{let{row:a}=e;return a5(a.original.leak_share,a.original.leak_tone,a1(a.original),aV)}},{id:"cost_water",header:"Water $",cell:e=>{let{row:a}=e;return a2(a.original.cost.water,aQ(a.original),aU)}},{id:"cost_sewer",header:"Sewer $",cell:e=>{let{row:a}=e;return a2(a.original.cost.sewer,aQ(a.original),aU)}},{id:"cost_combined",header:"Total $",cell:e=>{let{row:a}=e;return a2(a.original.cost.combined,aQ(a.original),aU)}},{id:"flags",header:"Flags",cell:e=>{let{row:a}=e;return a3(a.original.flagged_bills,a.original.flags)}}];return(0,l.jsx)(eU.b,{columns:f,data:a,columnVisibility:{},onColumnVisibilityChange:()=>{},columnOrder:[],isLoading:i,cellHeight:"min-h-[44px]",pageCount:g>1?g:void 0,pageIndex:g>1?s:void 0,onPageChange:g>1?o:void 0,showPageSizeSelector:!0,pageSize:r,onPageSizeChange:d,pageSizeOptions:[10,25,50,100],isRowExpanded:e=>e.original.property_id===m&&(u||p),renderExpandedRow:e=>h(e.original)})}var ln=t(39735),li=t(8803),lo=t(20562);function ld(e){let{data:a,params:t,onSort:s,onPageChange:n,onPageSizeChange:i,pageIndex:o,pageSize:d,isLoading:c}=e,[m]=(0,r.useState)({}),u=!c&&a.length>0,[p,x]=(0,r.useState)({consumptionSavings:null,financialSavings:null}),h=(0,r.useRef)(null),g=(0,r.useCallback)(()=>
1{if(!h.current)return;let e=h.current.getBoundingClientRect(),a=h.current.querySelector('[data-column-key="saved_gallons"]'),t=h.current.querySelector('[data-column-key="avg_dollar_per_gallon"]');if(a){let t=a.getBoundingClientRect();x(a=>({...a,consumptionSavings:new DOMRect(t.left-e.left,-34,t.width,20)}))}if(t){let a=t.getBoundingClientRect();x(t=>({...t,financialSavings:new DOMRect(a.left-e.left,-34,a.width,20)}))}},[]);(0,r.useEffect)(()=>{let e=window.setTimeout(g,0),a=new ResizeObserver(g);return h.current&&a.observe(h.current),window.addEventListener("resize",g),()=>{window.clearTimeout(e),a.disconnect(),window.removeEventListener("resize",g)}},[g]),(0,r.useEffect)(()=>{g()},[a,c,g]);let{getSortableHeaderProps:y}=(0,ep.M)({params:t,onSort:s,isLoading:c,data:a}),f=[{id:"index",header:"",cell:e=>{let{row:a}=e;return(0,l.jsxs)("span",{className:"text-sm font-medium",children:["#",a.index+1]})}},{id:"property",accessorKey:"property_name",header:"Property",cell:e=>{let{row:a}=e;return(0,l.jsx)("div",{className:"font-medium text-brand-black",children:a.original.property_name})}},{id:"saved_gallons",accessorKey:"saved_gallons",header:()=>{let e=y("saved_gallons","Gallons Saved");return(0,l.jsxs)("div",{className:e.className,onClick:e.onClick,children:[(0,l.jsx)("span",{className:"text-right",children:e.label}),(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(em.A,{className:e.upIconClassName}),(0,l.jsx)(eu.A,{className:e.downIconClassName})]})]})},cell:e=>{var a;let{row:t}=e;return(0,l.jsx)("div",{className:"flex justify-end w-full",children:(0,l.jsx)("span",{className:"text-right pr-6",children:Math.round(null!=(a=t.original.saved_gallons)?a:0).toLocaleString()})})},meta:{borderBottom:!0,className:u&&"border-l border-t border-cyan-300 rounded-tl-md",cellClassName:u&&"border-l border-cyan-300",lastCellClassName:u&&"rounded-bl-md"}},{id:"saved_dollars_percentage",accessorKey:"saved_dollars_percentage",header:()=>{let e=y("saved_dollars_percentage","% Savings vs Assessed");return(0,l.jsxs)("div",{className:e.className,onClick:e.onClick,children:[(0,l.jsx)("span",{className:"text-right",children:e.label}),(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(em.A,{className:e.upIconClassName}),(0,l.jsx)(eu.A,{className:e.downIconClassName})]})]})},cell:e=>{var a;let{row:t}=e;return(0,l.jsx)("div",{className:"flex justify-end w-full",children:(0,l.jsxs)("span",{className:"text-right pr-6",children:[Math.round(null!=(a=t.original.saved_dollars_percentage)?a:0).toLocaleString(),"%"]})})},meta:{borderBottom:!0,className:u&&"border-t border-cyan-300"}},{id:"gbd",accessorKey:"gbd",header:()=>{let e=y("gbd","GBD");return(0,l.jsxs)("div",{className:e.className,onClick:e.onClick,children:[(0,l.jsx)("span",{className:"text-right",children:e.label}),(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(em.A,{className:e.upIconClassName}),(0,l.jsx)(eu.A,{className:e.downIconClassName})]})]})},cell:e=>{let{row:a}=e;return(0,l.jsxs)("div",{className:"flex justify-end w-full gap-1 pr-5",children:[(0,l.jsx)("span",{children:Math.round(a.original.gbd||0).toLocaleString()}),"down"===a.original.gbd_change?(0,l.jsx)(li.A,{className:"w-4 h-4 text-red-500"}):"up"===a.original.gbd_change?(0,l.jsx)(lo.A,{className:"w-4 h-4 text-green-500"}):null]})},meta:{borderBottom:!0,className:u&&"border-t border-r border-cyan-300 rounded-tr-md",cellClassName:u&&"border-r border-cyan-300",lastCellClassName:u&&"rounded-br-md"}},{accessorKey:"before_avg_cost_per_gallon",header:()=>(0,l.jsx)("div",{className:"text-right"})},{id:"avg_dollar_per_gallon",accessorKey:"avg_dollar_per_gallon",header:()=>{let e=y("avg_dollar_per_gallon","Avg Cost per Gallon ($)");return(0,l.jsxs)("div",{className:e.className,onClick:e.onClick,children:[(0,l.jsx)("span",{className:"text-right",children:e.label}),(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(em.A,{className:e.upIconClassName}),(0,l.jsx)(eu.A,{className:e.downIconClassName})]})]})},cell:e=>{var a;let{row:t}=e;return(0,l.jsx)("div",{className:"flex justify-end w-full",children:(0,l.jsxs)("span",{className:"text-right pr-6",children:["$",null==(a=t.original.avg_dollar_per_gallon)?void 0:a.toLocaleStr
1ing()]})})},meta:{borderBottom:!0,className:u&&"border-l border-t border-cyan-300 rounded-tl-md",cellClassName:u&&"border-l border-cyan-300",lastCellClassName:u&&"rounded-bl-md"}},{id:"total_dollars_saved",accessorKey:"total_dollars_saved",header:()=>{let e=y("total_dollars_saved","Total $ Saved");return(0,l.jsxs)("div",{className:e.className,onClick:e.onClick,children:[(0,l.jsx)("span",{className:"text-right font-medium text-brand-black",children:e.label}),(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(em.A,{className:e.upIconClassName}),(0,l.jsx)(eu.A,{className:e.downIconClassName})]})]})},cell:e=>{var a;let{row:t}=e;return(0,l.jsx)("div",{className:"flex justify-end w-full",children:(0,l.jsxs)("span",{className:"text-right pr-6",children:["$",Math.round(null!=(a=t.original.total_dollars_saved)?a:0).toLocaleString()]})})},meta:{borderBottom:!0,className:u&&"border-r border-t border-cyan-300 rounded-tr-md",cellClassName:u&&"border-r border-cyan-300",lastCellClassName:u&&"rounded-br-md"}}];return(0,l.jsxs)("div",{className:"relative mt-[-32px] overflow-x-auto [&::-webkit-scrollbar]:h-1 [&::-webkit-scrollbar-track]:bg-gray-100 [&::-webkit-scrollbar-thumb]:bg-gray-400 [&::-webkit-scrollbar-thumb]:rounded-full lg:[&::-webkit-scrollbar]:hidden",ref:h,children:[(0,l.jsxs)("div",{className:"hidden lg:flex relative h-7 top-0 z-10",children:[u&&p.consumptionSavings&&(0,l.jsx)("div",{className:"text-cyan-600 text-base text-nowrap",style:{position:"absolute",left:"".concat(p.consumptionSavings.x,"px"),top:"0px"},children:"Gallons"}),u&&p.financialSavings&&(0,l.jsx)("div",{className:"text-cyan-600 text-base text-nowrap",style:{position:"absolute",left:"".concat(p.financialSavings.x,"px"),top:"0px"},children:"Dollars"})]}),(0,l.jsx)(eU.b,{columns:f.map(e=>({...e,meta:{...e.meta,columnKey:"accessorKey"in e?e.accessorKey:e.id}})),data:a,columnVisibility:m,onColumnVisibilityChange:()=>{},columnOrder:[],pageSize:d,pageIndex:o,onPageChange:n,onPageSizeChange:i,showPageSizeSelector:!0})]})}var lc=t(1800),lm=t(58873);function lu(e){if(!e||0===e.length)return"-";if(e.length<=2)return e.join(", ");let a=e.slice(0,2).join(", ");return"".concat(a," +").concat(e.length-2," more")}function lp(e){let{title:a,items:t}=e,[s,n]=(0,r.useState)(!1),i=t.length>5,o=s||!i?t:t.slice(0,5),d=t.length-5;return(0,l.jsxs)("div",{children:[(0,l.jsx)("h4",{className:"text-sm font-semibold text-brand-dark-gray mb-2",children:a}),(0,l.jsx)("ul",{className:"space-y-1",children:o.map((e,a)=>(0,l.jsx)("li",{className:"text-sm",children:e},"".concat(e,"-").concat(a)))}),i&&(0,l.jsx)("button",{type:"button",onClick:()=>n(e=>!e),className:"mt-2 text-sm font-medium text-brand-dark-cyan hover:underline",children:s?"Show less":"Show ".concat(d," more")})]})}function lx(e){let{data:a,isLoading:t,params:s,onSort:n,totalCount:o=0,onPageChange:d,currentPage:c=0,pageSize:m,onPageSizeChange:u}=e,p=Math.ceil(o/m),x=p>1,[h,g]=(0,r.useState)(new Set),{getSortableHeaderProps:y}=(0,ep.M)({params:s,onSort:n,isLoading:t,data:a}),f=async e=>{try{let{blob:a,filename:t}=await lc.d.getReportFile(e),l=window.URL.createObjectURL(a),s=window.document.createElement("a");s.href=l,s.download=t,window.document.body.appendChild(s),s.click(),window.document.body.removeChild(s),window.URL.revokeObjectURL(l),(0,eD.oR)({title:"Downloaded Successfully!",description:"The report has been downloaded successfully.",className:"bg-green-200 border-green-200 text-brand-black"})}catch(a){console.error("Failed to download report:",a),(0,lm.N)("Failed to download report",void 0,()=>{f(e)})}},b=[{accessorKey:"created_at",header:()=>{let e=y("created_at","Timestamp","start");return(0,l.jsxs)("div",{className:e.className,onClick:e.onClick,children:[(0,l.jsx)("span",{children:e.label}),(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(em.A,{className:e.upIconClassName}),(0,l.jsx)(eu.A,{className:e.downIconClassName})]})]})},cell:e=>{let{row:a}=e;return(0,l.jsx)("span",{className:"whitespace-nowrap",children:(0,et.GP)(a.original.created_at,"MMM dd, yyyy HH:mm")}
1)}},{accessorKey:"organizations",header:"Organizations",cell:e=>{let{row:a}=e;return(0,l.jsx)("span",{className:"truncate",children:a.original.all_organizations?"All":lu(a.original.organizations)})}},{accessorKey:"properties",header:"Properties",cell:e=>{let{row:a}=e;return(0,l.jsx)("span",{className:"truncate",children:a.original.all_properties?"All":lu(a.original.properties)})}},{accessorKey:"report_type_name",header:"Contents"},{accessorKey:"status",header:"Status",cell:e=>{let{row:a}=e;return(0,l.jsx)("span",{className:(0,i.cn)("capitalize px-2 py-1 rounded-md","done"===a.original.status?"bg-green-100 text-green-700":"failed"===a.original.status?"bg-red-100 text-red-700":"generating"===a.original.status?"bg-orange-100 text-orange-700":"bg-gray-100 text-gray-700"),children:a.original.status})}},{id:"download",header:"Download",cell:e=>{let{row:a}=e;return"done"===a.original.status?(0,l.jsx)(e$.$,{variant:"tertiary",size:"sm",onClick:()=>f(a.original.id.toString()),children:"Download"}):(0,l.jsx)("span",{className:"text-brand-dark-gray",children:"-"})}},{id:"expand",header:"",cell:e=>{let{row:a}=e,t=h.has(a.original.id);return(0,l.jsxs)(e$.$,{variant:"tertiary",size:"sm",onClick:()=>{var e;return e=a.original.id,void g(a=>{let t=new Set(a);return t.has(e)?t.delete(e):t.add(e),t})},"aria-expanded":t,"aria-label":t?"Hide details":"Show details",className:"border border-brand-dark-cyan text-brand-dark-cyan rounded-md px-3 py-1 hover:bg-cyan-50",children:[(0,l.jsx)("span",{className:"mr-1",children:t?"Hide details":"Show details"}),t?(0,l.jsx)(to.A,{className:"h-4 w-4"}):(0,l.jsx)(eQ.A,{className:"h-4 w-4"})]})}}];return(0,l.jsx)(eU.b,{columns:b,data:a,columnVisibility:{},onColumnVisibilityChange:()=>{},columnOrder:[],isLoading:t,pageCount:x?p:void 0,pageIndex:x?c:void 0,onPageChange:x?d:void 0,cellHeight:"",showPageSizeSelector:!0,pageSize:m,onPageSizeChange:u,isRowExpanded:e=>h.has(e.original.id),renderExpandedRow:e=>{let{organizations:a,properties:t,report_content:s,all_organizations:r,all_properties:n}=e.original;return(0,l.jsx)("div",{className:"px-12 py-6 bg-cyan-50/30 border-l-2 border-brand-dark-cyan",children:(0,l.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-8",children:[a&&a.length>0&&(0,l.jsx)(lp,{title:r?"Organizations (All)":"Organizations",items:a}),t&&t.length>0&&(0,l.jsx)(lp,{title:n?"Properties (All)":"Properties",items:t}),s&&s.length>0&&(0,l.jsx)(lp,{title:"Contents",items:s.map(e=>e.name)})]})})}})}function lh(e){let{data:a,isLoading:t,totalCount:s=0,onPageChange:r,currentPage:n=0,params:i,onSort:o,pageSize:d,onPageSizeChange:c}=e,m=Math.ceil(s/(d||10)),u=m>1,{getSortableHeaderProps:p}=(0,ep.M)({params:i,onSort:o,isLoading:t,data:a}),x=[{accessorKey:"property_name",header:"Property"},{accessorKey:"state",header:"State"},{accessorKey:"building_name",header:()=>{let e=p("building_name","Building","start");return(0,l.jsxs)("div",{className:e.className,onClick:e.onClick,children:[(0,l.jsx)("span",{children:e.label}),(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(em.A,{className:e.upIconClassName}),(0,l.jsx)(eu.A,{className:e.downIconClassName})]})]})}},{accessorKey:"unit_name",header:()=>{let e=p("unit_name","Unit","start");return(0,l.jsxs)("div",{className:e.className,onClick:e.onClick,children:[(0,l.jsx)("span",{children:e.label}),(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(em.A,{className:e.upIconClassName}),(0,l.jsx)(eu.A,{className:e.downIconClassName})]})]})}},{accessorKey:"attached_to",header:()=>(0,l.jsx)("span",{className:"min-w-24",children:"Attached To"})},{accessorKey:"last_7_days_gallons",header:()=>{let e=p("last_7_days_gallons","Last 7 Days Gallons");return(0,l.jsxs)("div",{className:e.className,onClick:e.onClick,children:[(0,l.jsx)("span",{className:"text-right",children:e.label}),(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(em.A,{className:e.upIconClassName}),(0,l.jsx)(eu.A,{className:e.downIconClassName})]})]})},cell:e=>{let{row:a}=e;return(0,l.jsx)("div",{className:"flex justify-end w-full",children:(0,l.jsx)("span",{className:"text-right pr-6",children:Math.round(a.original.last_7_days_gallons).toLocaleStr
1ing()})})}},{accessorKey:"occupancy",header:"Occupation (Yardi Data)"}];return(0,l.jsx)(eU.b,{columns:x,data:a,columnVisibility:{},onColumnVisibilityChange:()=>{},columnOrder:[],getRowClassName:()=>"",isLoading:t,pageCount:u?m:void 0,pageIndex:u?n:void 0,onPageChange:u?r:void 0,headerClassName:"bg-orange-50 h-14",headerColor:"text-brand-black",showPageSizeSelector:!0,pageSize:d,onPageSizeChange:c})}var lg=t(20063);function ly(e){let{data:a,params:t,onSort:s,isLoading:n,dateRangeLabel:o="Yesterday",shouldScrollOnDataChange:d=!1,handlePropertyRowClick:c,showConnection:m}=e,u=(0,lg.useRouter)(),[p,x]=(0,r.useState)({}),[h,g]=(0,r.useState)({}),[y,f]=(0,r.useState)({}),[b,v]=(0,r.useState)({}),[N,j]=(0,r.useState)({}),[_,w]=(0,r.useState)({}),[k,C]=(0,r.useState)({}),[S,E]=(0,r.useState)({yesterday:null,runningLeak:null}),[L,A]=(0,r.useState)(0),D=(0,r.useRef)(null),O=(0,r.useRef)(null),T=(0,r.useCallback)(()=>{if(!D.current)return;let e=D.current.getBoundingClientRect();A(e.width);let a=D.current.querySelector('[data-column-key="gallons_leaked"]'),t=D.current.querySelector('[data-column-key="leak_days"]');if(a){let t=a.getBoundingClientRect();E(a=>({...a,yesterday:new DOMRect(t.left-e.left,-34,t.width,20)}))}if(t){let a=t.getBoundingClientRect();E(t=>({...t,runningLeak:new DOMRect(a.left-e.left,-34,a.width,20)}))}},[]);(0,r.useEffect)(()=>{let e=window.setTimeout(T,0),a=new ResizeObserver(T);return D.current&&a.observe(D.current),window.addEventListener("resize",T),()=>{window.clearTimeout(e),a.disconnect(),window.removeEventListener("resize",T)}},[T]),(0,r.useEffect)(()=>{T()},[a,n,T,m]);let{getSortableHeaderProps:I}=(0,ep.M)({params:t,onSort:s,isLoading:n,data:a});(0,r.useEffect)(()=>{let e=async()=>{let e=Object.keys(h).filter(e=>h[e]);if(0===e.length)return;let l=Object.fromEntries(Object.entries(t).filter(e=>{let[a]=e;return!["organization_id","property_id"].includes(a)}));for(let s of e)try{let e=await ec.l.getPropertyUnits(parseInt(s),{...l,page:1,page_size:5,...t.ordering&&{ordering:t.ordering}}),r=e.results.map(e=>{var t;return{...e,isUnit:!0,id:e.unit_id.toString(),property_name:(null==(t=a.find(e=>e.property_id.toString()===s))?void 0:t.property_name)||"",parent_id:s}});v(e=>({...e,[s]:r})),j(a=>({...a,[s]:{page:1,hasMore:null!==e.next,total:e.count||0}})),C(e=>({...e,[s]:!1}))}catch(e){console.error("Error refetching units for property:",s,e)}};t.ordering&&e()},[t.ordering]);let P=async(e,a)=>{let l=h[e];if(g(a=>({...a,[e]:!l})),l){v(a=>{let t={...a};return delete t[e],t}),j(a=>{let t={...a};return delete t[e],t}),C(a=>{let t={...a};return delete t[e],t});return}if(!l){f(a=>({...a,[e]:!0}));let l=Object.fromEntries(Object.entries(t).filter(e=>{let[a]=e;return!["organization_id","property_id"].includes(a)}));try{let t=await ec.l.getPropertyUnits(parseInt(e),{...l,page:1,page_size:5}),s=t.results.map(t=>({...t,isUnit:!0,id:t.unit_id.toString(),property_name:a,parent_id:e}));v(a=>({...a,[e]:s})),j(a=>({...a,[e]:{page:1,hasMore:null!==t.next,total:t.count||0}})),setTimeout(()=>{{let a=window.document.querySelector('[data-row-id="'.concat(e,'"]'));a&&a.scrollIntoView({behavior:"smooth",block:"center"})}},100)}catch(e){console.error("Error fetching unit data:",e)}finally{f(a=>({...a,[e]:!1}))}}},R=async(e,a)=>{let l=N[e];if(!(null==l?void 0:l.hasMore)||_[e])return;w(a=>({...a,[e]:!0}));let s=Object.fromEntries(Object.entries(t).filter(e=>{let[a]=e;return!["organization_id","property_id"].includes(a)})),r=k[e],n=!r;try{let t=await ec.l.getPropertyUnits(parseInt(e),{...s,page:r?l.page+1:1,page_size:50}),i=t.results.map(t=>({...t,isUnit:!0,id:t.unit_id.toString(),property_name:a,parent_id:e}));v(a=>({...a,[e]:n?i:[...a[e]||[],...i]})),j(a=>({...a,[e]:{page:r?l.page+1:1,hasMore:null!==t.next,total:t.count||0}})),n&&C(a=>({...a,[e]:!0}))}catch(e){console.error("Error loading more units:",e)}finally{w(a=>({...a,[e]:!1}))}},M=!n&&a.length>0,G=e=>{if("isLoadMore"in e.original&&e.original.isLoadMore)return void R(e.original.parent_id,e.original.property_name);if("isUnit"in e.original){if("isUnit"in e.original&&e.original.isUnit){let a=new URLSearchParams;Object.entries({meter:e.original.meter_serial_number,property_id:e.original.parent_id}
1).forEach(e=>{let[t,l]=e;l&&a.set(t,Array.isArray(l)?l[0]:l)}),u.push("/top5-leaks-details?".concat(a.toString()))}}else P(e.original.id,e.original.property_name)},z=[{accessorKey:"property_name",header:"Property",cell:e=>{let{row:a}=e;if("isLoadMore"in a.original&&a.original.isLoadMore){var t;let e=N[a.original.parent_id],s=_[a.original.parent_id],r=(null==(t=b[a.original.parent_id])?void 0:t.length)||0;return(0,l.jsx)("div",{className:"flex items-center justify-center py-2 w-full h-full absolute top-0 left-0",style:{width:"".concat(L,"px")},children:(0,l.jsxs)(e$.$,{variant:"secondary",size:"sm",className:"flex items-center gap-2",disabled:s,onClick:e=>{e.stopPropagation(),R(a.original.parent_id,a.original.property_name)},children:[s&&(0,l.jsx)(ee.A,{className:"w-4 h-4 animate-spin"}),"Load More (",r," of ",(null==e?void 0:e.total)||0,")"]})})}return"isUnit"in a.original&&a.original.isUnit?(0,l.jsxs)("div",{className:"min-w-48",children:[a.original.building_name," / ",a.original.unit_name]}):(0,l.jsx)("div",{className:"min-w-48",children:(0,l.jsx)("p",{onClick:()=>{"isUnit"in a.original||null==c||c(a.original.property_id.toString())},className:"cursor-pointer hover:text-brand-dark-cyan hover:underline w-fit",children:a.original.property_name})})},meta:{cellClassName:"relative"}},{accessorKey:"units_with_leakage",header:()=>(0,l.jsx)("div",{className:"w-24",children:"Identified Leaks"}),cell:e=>{let{row:a}=e;return"isLoadMore"in a.original&&a.original.isLoadMore?null:"isUnit"in a.original?(0,l.jsx)("div",{className:"h-8 w-8 border border-brand-stroke rounded-lg flex items-center justify-center shrink-0",children:(0,l.jsx)(aO,{leakType:a.original.leak_type})}):(0,l.jsx)("div",{children:"".concat(a.original.units_with_leakage)})}},...m?[{accessorKey:"attached_to",header:"Attached to",cell:e=>{let{row:a}=e;return"isLoadMore"in a.original&&a.original.isLoadMore?null:(0,l.jsx)("span",{children:"isUnit"in a.original&&a.original.isUnit?a.original.attached_to:"-"})}},{accessorKey:"bedroom_count",header:()=>(0,l.jsx)("span",{className:"min-w-20",children:"Bd - Ba"}),cell:e=>{let{row:a}=e;return"isLoadMore"in a.original&&a.original.isLoadMore?null:(0,l.jsx)("span",{children:"isUnit"in a.original&&a.original.isUnit?a.original.bedroom_count+" Bd - "+a.original.bathroom_count+" Ba":"-"})}}]:[],{accessorKey:"gallons_leaked",header:()=>{let e=I("gallons_leaked","Leak Gallons over the selected period");return(0,l.jsxs)("div",{className:e.className,onClick:e.onClick,children:[(0,l.jsx)("span",{className:"text-right w-44 font-medium text-brand-black",children:e.label}),(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(em.A,{className:(0,i.cn)(e.upIconClassName,!t.ordering&&"text-brand-dark-cyan")}),(0,l.jsx)(eu.A,{className:e.downIconClassName})]})]})},cell:e=>{let{row:a}=e;return"isLoadMore"in a.original&&a.original.isLoadMore?null:(0,l.jsx)("div",{className:"flex justify-end w-full",children:(0,l.jsx)("span",{className:"text-right pr-6",children:Math.round(a.original.gallons_leaked).toLocaleString()})})},meta:{borderBottom:!0,className:M&&"border-l border-t border-cyan-300 rounded-tl-md",cellClassName:M&&"border-l border-cyan-300",lastCellClassName:M&&"rounded-bl-md"}},{accessorKey:"flow_time",header:()=>(0,l.jsx)("div",{className:"w-full flex justify-end",children:(0,l.jsx)("span",{className:"text-right ".concat(1===t.days_ago?"w-16":"w-24"),children:1===t.days_ago?"Flow Time":"Average Flow Time"})}),cell:e=>{let{row:a}=e;return"isLoadMore"in a.original&&a.original.isLoadMore?null:(0,l.jsx)("div",{className:"w-full flex justify-end",children:(0,l.jsx)("span",{className:"text-right",children:"isUnit"in a.original&&a.original.isUnit?a.original.flow_time:"-"})})},meta:{borderBottom:!0,className:M&&"border-t border-cyan-300"}},{accessorKey:"events",header:()=>(0,l.jsx)("div",{className:"w-full flex justify-end",children:(0,l.jsx)("span",{className:"text-right ".concat(1===t.days_ago?"w-auto":"w-20"),children:1===t.days_ago?"Events":"Average Events"})}),cell:e=>{let{row:a}=e;return"isLoadMore"in a.original&&a.original.isLoadMore?null:(0,l.jsx)("div",{className:"w-full flex justify-end",children:(0,l.jsx)("span",{className:"text-right",children:"isUnit"in a.original&&a.original.isUnit?Math.round(a.original.events).toLocaleStr
1ing():"-"})})},meta:{borderBottom:!0,className:M&&"border-t border-r border-cyan-300 rounded-tr-md",cellClassName:M&&"border-r border-cyan-300",lastCellClassName:M&&"rounded-br-md"}},{accessorKey:"before_leak_days_top_properties",header:()=>(0,l.jsx)("div",{className:"text-right"})},{id:"leak_days",accessorKey:"leak_days",header:()=>(0,l.jsx)("div",{className:"w-full flex justify-end",children:(0,l.jsx)("span",{className:"text-right w-20",children:"Days Leak Repeating"})}),cell:e=>{let{row:a}=e;return"isLoadMore"in a.original&&a.original.isLoadMore?null:(0,l.jsx)("div",{className:"w-full flex justify-end",children:(0,l.jsx)("span",{className:"text-right",children:"isUnit"in a.original?a.original.leak_days.toLocaleString():"-"})})},meta:{borderBottom:!0,className:M&&"border-l border-t border-cyan-300 rounded-tl-md",cellClassName:M&&"border-l border-cyan-300",lastCellClassName:M&&"rounded-bl-md"}},{accessorKey:"total_gallons_leaked",header:()=>{let e=I("total_gallons_leaked","Total Leak Gallons since the leak started");return(0,l.jsxs)("div",{className:e.className,onClick:e.onClick,children:[(0,l.jsx)("span",{className:"text-right w-44",children:e.label}),(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(em.A,{className:e.upIconClassName}),(0,l.jsx)(eu.A,{className:e.downIconClassName})]})]})},cell:e=>{let{row:a}=e;return"isLoadMore"in a.original&&a.original.isLoadMore?null:(0,l.jsx)("div",{className:"w-full flex justify-end",children:(0,l.jsx)("span",{className:"text-right pr-6",children:Math.round(a.original.total_gallons_leaked).toLocaleString()})})},meta:{borderBottom:!0,className:M&&"border-r border-t border-cyan-300 rounded-tr-md",cellClassName:M&&"border-r border-cyan-300",lastCellClassName:M&&"rounded-br-md"}},{id:"expander",size:130,enableResizing:!1,cell:e=>{let{row:a}=e;if("isLoadMore"in a.original&&a.original.isLoadMore)return null;if(!("isUnit"in a.original)){let e=h[a.original.id],t=y[a.original.id];return(0,l.jsx)("div",{className:"flex justify-end w-full",children:(0,l.jsx)(e$.$,{variant:"secondary",size:"sm",className:"opacity-100 py-1 px-2 w-28 h-7",onClick:e=>{e.stopPropagation(),G(a)},children:t?(0,l.jsx)(ee.A,{className:"w-5 h-5 animate-spin text-brand-dark-cyan"}):e?(0,l.jsxs)("div",{className:"flex items-center gap-0.5",children:["Hide Leak",(0,l.jsx)(to.A,{className:"w-5 h-5",strokeWidth:2})]}):(0,l.jsxs)("div",{className:"flex items-center gap-0.5",children:["Show Leak",(0,l.jsx)(eQ.A,{className:"w-5 h-5",strokeWidth:2})]})})})}return(0,l.jsx)("div",{className:"flex justify-end w-full",children:(0,l.jsx)(e$.$,{variant:"secondary",size:"sm",className:"py-1 px-2 border-gray-400 w-28 h-7 text-brand-dark-gray hover:text-brand-dark-cyan hover:border-brand-dark-cyan",onClick:e=>{e.stopPropagation(),G(a)},children:(0,l.jsxs)("div",{className:"flex items-center gap-0.5",children:["Details",(0,l.jsx)(es.A,{className:"w-4 h-4"})]})})})},meta:{fixedWidth:!0}}],F=a.reduce((e,a)=>{let t=a.property_id.toString();if(e.push({...a,id:t}),h[t]&&b[t]){e.push(...b[t]);let l=N[t];if(null==l?void 0:l.hasMore){let l={id:"load-more-".concat(t),isLoadMore:!0,parent_id:t,property_name:a.property_name,gallons_leaked:0,leak_days:0,total_gallons_leaked:0,leak_volume_percentage:0,building:"",unit:"",leak_type:"",isUnit:!1,attached_to:"",bedroom_count:0,bathroom_count:0};e.push(l)}}return e},[]);return(0,r.useEffect)(()=>{g({}),v({}),j({}),w({})},[t.days_ago,t.start_date,t.end_date,t.organization_id,t.property_id]),(0,r.useEffect)(()=>{!n&&a.length>0&&O.current&&d&&O.current.scrollTo({top:O.current.scrollHeight,behavior:"smooth"})},[a,n,d]),(0,l.jsxs)("div",{className:"relative mt-[-32px] overflow-x-auto [&::-webkit-scrollbar]:h-1 [&::-webkit-scrollbar-track]:bg-gray-100 [&::-webkit-scrollbar-thumb]:bg-gray-400 [&::-webkit-scrollbar-thumb]:rounded-full lg:[&::-webkit-scrollbar]:hidden",ref:D,children:[(0,l.jsxs)("div",{className:"hidden lg:flex relative h-7 top-0 z-10",children:[M&&S.yesterday&&(0,l.jsx)("div",{className:"text-cyan-600 text-base text-nowrap",style:{position:"absolute",left:"".concat(S.yesterday.x,"px"),top:"0px"},children:o}),M&&S.runningLeak&&(0,l.jsx)("div",{className:"text-cyan-600 text-base text-nowrap",style:{position:"absolute",left:"".concat(S.runningLeak.x,"px"),top:"0px"},children:"Running Leak"})]}),(0,l.jsx)("div",{ref:O,children:(0,l.jsx)(eU.b,{columns:z.map(e=>({...e,meta:{...e.meta,columnKey:"accessorKey"in e?e.accessorKey:e.id}})),data:F,columnVisibility:p,onColumnVisibilityChange:x,columnOrder:[],isLoading:n,getRowClassName:e=>{let a=[];return"isUnit"in e.original&&e.original.isUnit&&a.push("bg-cyan-50"),"isLoadMore"in e.original&&e.original.isLoadMore?a.push("bg-cyan-50 border-t-2 relative"):a.push("hover:bg-gray-50"),a.join(" ")},onRowClick:G})})]})}function lf(e){let{data:a,params:t,onSort:s,isLoading:n,shouldScrollOnDataChange:o=!1,handleUnitRowClick:d,showConnection:c}=e,m=(0,lg.useRouter)(),{getSortableHeaderProps:u}=(0,ep.M)({params:t,onSort:s,isLoading:n,data:a}),p=(0,r.useRef)(null),x=(0,r.useRef)(null),[h,g]=(0,r.useState)({runningLeak:null}),y=!n&&a.length>0,f=(0,r.useCallback)(()=>
1{if(!p.current)return;let e=p.current.querySelector('[data-column-key="leak_days"]');if(e){let a=e.getBoundingClientRect(),t=p.current.getBoundingClientRect();g(e=>({...e,runningLeak:new DOMRect(a.left-t.left,-34,a.width,20)}))}},[]);(0,r.useEffect)(()=>(f(),window.addEventListener("resize",f),()=>{window.removeEventListener("resize",f)}),[f]),(0,r.useEffect)(()=>{f()},[a,n,f]),(0,r.useEffect)(()=>{!n&&a.length>0&&x.current&&o&&x.current.scrollTo({top:x.current.scrollHeight,behavior:"smooth"})},[a,n,o]);let b=e=>{let a=new URLSearchParams;Object.entries({meter:e.original.meter_serial_number}).forEach(e=>{let[t,l]=e;l&&a.set(t,l)}),m.push("/top5-leaks-details?".concat(a.toString()))},v=[{id:"index",header:"",cell:e=>{let{row:a}=e;return(0,l.jsxs)("span",{className:"text-sm font-medium",children:["#",a.index+1]})}},{accessorKey:"leak_type",header:"Leak Type",cell:e=>{var a;let{row:t}=e;return(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("div",{className:"h-8 w-8 border border-brand-stroke rounded-lg flex items-center justify-center shrink-0",children:(0,l.jsx)(aO,{leakType:t.original.leak_type})}),(0,l.jsx)("span",{className:"text-sm font-medium capitalize text-nowrap",children:(0,ex.WU)(null!=(a=t.original.leak_type)?a:"")})]})}},{accessorKey:"property_name",header:()=>(0,l.jsx)("div",{className:"flex items-center gap-2",children:(0,l.jsx)("span",{className:"w-48",children:"Property | Building | Unit"})}),cell:e=>{let{row:a}=e;return(0,l.jsx)("div",{className:"flex items-center gap-2",children:(0,l.jsxs)("span",{className:"text-sm font-medium",children:[(0,l.jsx)("span",{onClick:()=>null==d?void 0:d(a.original.property_id.toString()),className:"cursor-pointer hover:text-brand-dark-cyan hover:underline",children:a.original.property_name})," ","| ",a.original.building_name," | ",a.original.unit_name]})})}},...c?[{accessorKey:"attached_to",header:"Attached to"},{accessorKey:"bedroom_count",header:()=>(0,l.jsx)("span",{className:"min-w-20",children:"Bd - Ba"}),cell:e=>{let{row:a}=e;return(0,l.jsxs)("span",{children:[a.original.bedroom_count," Bd -"," ",a.original.bathroom_count," Ba"]})}}]:[],{accessorKey:"gallons_consumed",header:()=>{let e=u("gallons_consumed","Gallons");return(0,l.jsxs)("div",{className:e.className,onClick:e.onClick,children:[(0,l.jsx)("span",{className:"text-right",children:e.label}),(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(em.A,{className:e.upIconClassName}),(0,l.jsx)(eu.A,{className:e.downIconClassName})]})]})},cell:e=>{let{row:a}=e;return(0,l.jsx)("div",{className:"flex justify-end w-full",children:(0,l.jsx)("span",{className:"text-right pr-6",children:Math.round(a.original.gallons_consumed).toLocaleString()})})}},{accessorKey:"gallons_leaked",header:()=>{let e=u("gallons_leaked","Leak Gallons over the selected period");return(0,l.jsxs)("div",{className:e.className,onClick:e.onClick,children:[(0,l.jsx)("span",{className:"text-right w-44 font-medium text-brand-black",children:e.label}),(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(em.A,{className:(0,i.cn)(e.upIconClassName,!t.ordering&&"text-brand-dark-cyan")}),(0,l.jsx)(eu.A,{className:e.downIconClassName})]})]})},cell:e=>{let{row:a}=e;return(0,l.jsx)("div",{className:"flex justify-end w-full",children:(0,l.jsx)("span",{className:"text-right pr-6",children:Math.round(a.original.gallons_leaked).toLocaleString()})})}},{accessorKey:"flow_time",header:()=>(0,l.jsx)("div",{className:"w-full flex justify-end",children:(0,l.jsx)("span",{className:"text-right w-16",children:"Flow Time"})}),cell:e=>{let{row:a}=e;return(0,l.jsx)("div",{className:"flex justify-end w-full",children:(0,l.jsx)("span",{className:"text-right",children:a.original.flow_time})})}},{accessorKey:"events",header:()=>(0,l.jsx)("div",{className:"w-full flex justify-end",children:(0,l.jsx)("span",{className:"text-right",children:"Events"})}),cell:e=>{let{row:a}=e;return(0,l.jsx)("div",{className:"flex justify-end w-full",children:(0,l.jsx)("span",{className:"text-right",children:Math.round(a.original.events).toLocaleStr
1ing()})})}},{accessorKey:"before_leak_days",header:()=>(0,l.jsx)("div",{className:"text-right"})},{accessorKey:"leak_days",header:()=>(0,l.jsx)("div",{className:"w-full flex justify-end",children:(0,l.jsx)("span",{className:"text-right w-20",children:"Days Leak Repeating"})}),cell:e=>{let{row:a}=e;return(0,l.jsx)("div",{className:"flex justify-end w-full",children:(0,l.jsx)("span",{className:"text-right",children:a.original.leak_days.toLocaleString()})})},meta:{borderBottom:!0,className:y&&"border-l border-t border-cyan-300 rounded-tl-md",cellClassName:y&&"border-l border-cyan-300",lastCellClassName:y&&"rounded-bl-md"}},{accessorKey:"total_gallons_leaked",header:()=>{let e=u("total_gallons_leaked","Total Leak Gallons since the leak started");return(0,l.jsxs)("div",{className:e.className,onClick:e.onClick,children:[(0,l.jsx)("span",{className:"text-right w-44",children:e.label}),(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(em.A,{className:e.upIconClassName}),(0,l.jsx)(eu.A,{className:e.downIconClassName})]})]})},cell:e=>{let{row:a}=e;return(0,l.jsx)("div",{className:"flex justify-end w-full",children:(0,l.jsx)("span",{className:"text-right pr-6",children:Math.round(a.original.total_gallons_leaked).toLocaleString()})})},meta:{borderBottom:!0,className:y&&"border-r border-t border-cyan-300 rounded-tr-md",cellClassName:y&&"border-r border-cyan-300",lastCellClassName:y&&"rounded-br-md"}},{accessorKey:"before_actions",header:()=>(0,l.jsx)("div",{className:"text-right"})},{id:"actions",size:130,enableResizing:!1,cell:e=>{let{row:a}=e;return(0,l.jsx)(e$.$,{variant:"secondary",size:"sm",className:"py-1 px-2 border-gray-400 w-24 h-7 text-brand-dark-gray hover:text-brand-dark-cyan hover:border-brand-dark-cyan",onClick:()=>b(a),children:(0,l.jsxs)("div",{className:"flex items-center gap-0.5",children:["Details",(0,l.jsx)(es.A,{className:"w-4 h-4"})]})})},meta:{fixedWidth:!0}}];return(0,l.jsxs)("div",{className:"relative mt-[-32px] overflow-x-auto [&::-webkit-scrollbar]:h-1 [&::-webkit-scrollbar-track]:bg-gray-100 [&::-webkit-scrollbar-thumb]:bg-gray-400 [&::-webkit-scrollbar-thumb]:rounded-full lg:[&::-webkit-scrollbar]:hidden",ref:p,children:[(0,l.jsx)("div",{className:"hidden lg:flex relative h-7 top-0 z-10",children:y&&h.runningLeak&&(0,l.jsx)("div",{className:"text-cyan-600 text-base text-nowrap",style:{position:"absolute",left:"".concat(h.runningLeak.x,"px"),top:"0px"},children:"Running Leak"})}),(0,l.jsx)("div",{ref:x,children:(0,l.jsx)(eU.b,{columns:v.map(e=>({...e,meta:{...e.meta,columnKey:"accessorKey"in e?e.accessorKey:e.id}})),data:a,columnVisibility:{},onColumnVisibilityChange:()=>{},columnOrder:[],isLoading:n,onRowClick:b})})]})}var lb=t(18514),lv=t(71360),lN=t(80501);function lj(e){let{data:a,isLoading:t,params:s,onSort:r,totalCount:n=0,onPageChange:i,currentPage:o=0,onDeleteUser:d,onEditUser:c,currentUser:m,pageSize:u,onPageSizeChange:p}=e,x=Math.ceil(n/u),h=x>1,{getSortableHeaderProps:g}=(0,ep.M)({params:s,onSort:r,isLoading:t,data:a}),y=[{accessorKey:"email",header:()=>{let e=g("email","Email","start");return(0,l.jsxs)("div",{className:e.className,onClick:e.onClick,children:[(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(em.A,{className:e.upIconClassName}),(0,l.jsx)(eu.A,{className:e.downIconClassName})]}),(0,l.jsx)("span",{children:e.label})]})}},{accessorKey:"first_name",header:()=>{let e=g("first_name","First Name","start");return(0,l.jsxs)("div",{className:e.className,onClick:e.onClick,children:[(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(em.A,{className:e.upIconClassName}),(0,l.jsx)(eu.A,{className:e.downIconClassName})]}),(0,l.jsx)("span",{className:"whitespace-nowrap",children:e.label})]})}},{accessorKey:"last_name",header:()=>{let e=g("last_name","Last Name","start");return(0,l.jsxs)("div",{className:e.className,onClick:e.onClick,children:[(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(em.A,{className:e.upIconClassName}),(0,l.jsx)(eu.A,{className:e.downIconClassName})]}),(0,l.jsx)("span",{className:"whitespace-nowrap",children:e.label})]})}},{accessorKey:"roles",header:"Role",cell:e=>{let{row:a}=e;return(0,l.jsx)("div",{className:"flex items-center gap-1",children:[...new Set(a.original.roles.map(e=>e.name))].join(", ")})}},{accessorKey:"organizations",header:"Organizations",cell:e=>{let{row:a}=e,t=a.original.assigned_organizations.map(e=>e.name),s=t.slice(0,2),r=t.length-2;return(0,l.jsxs)("div",{className:"flex items-center gap-1 flex-wrap",children:[s.map((e,a)=>(0,l.jsxs)("span",{className:"whitespace-nowrap",children:[e,a<s.length-1||r>0?",":""]},e)),r>0&&(0,l.jsxs)("span",{className:"text-cyan-700 ml-1",children:["(","+".concat(r),")"]})]})}},{accessorKey:"properties",header:"Properties",cell:e=>{let{row:a}=e,t=a.original.assigned_properties.map(e=>e.name),s=t.slice(0,2),r=t.length-2;return(0,l.jsxs)("div",{className:"flex items-center gap-1 flex-wrap",children:[s.map((e,a)=>(0,l.jsxs)("span",{className:"whitespace-nowrap",children:[e,a<s.length-1||r>0?",":""]},e)),r>0&&(0,l.jsxs)("span",{className:"text-cyan-700 ml-1",children:["(","+".concat(r),")"]})]})}},{accessorKey:"permissions",header:"Permissions",cell:e=>{let{row:a}=e,t={"reporting.view_asset_data_report":"Portfolio Insights","reporting.view_property_data_report":"Property Insights"},s=[...new Set((a.original.permissions||[]).map(e=>
1t[e.name]).filter(Boolean))].join(", ");return(0,l.jsx)("div",{className:"flex items-center gap-1",children:s})}},{accessorKey:"last_login",header:()=>{let e=g("last_login","Last Activity","start");return(0,l.jsxs)("div",{className:e.className,onClick:e.onClick,children:[(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(em.A,{className:e.upIconClassName}),(0,l.jsx)(eu.A,{className:e.downIconClassName})]}),(0,l.jsx)("span",{className:"whitespace-nowrap",children:e.label})]})}},{accessorKey:"modified_at",header:()=>{let e=g("modified_at","Last updated","start");return(0,l.jsxs)("div",{className:e.className,onClick:e.onClick,children:[(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(em.A,{className:e.upIconClassName}),(0,l.jsx)(eu.A,{className:e.downIconClassName})]}),(0,l.jsx)("span",{className:"whitespace-nowrap",children:e.label})]})},cell:e=>{let{row:a}=e;return(0,l.jsx)("span",{className:"whitespace-nowrap",children:a.original.modified_at})}},{id:"actions",cell:e=>{let{row:a}=e;return(0,l.jsxs)("div",{className:"flex items-center gap-1",children:[(0,l.jsxs)(au.m_,{children:[(0,l.jsx)(au.k$,{asChild:!0,children:(0,l.jsx)(e$.$,{variant:"secondary",size:"icon",className:"border-brand-stroke text-gray-400",onClick:()=>c(a.original),disabled:a.original.roles.length>1,children:(0,l.jsx)(lb.A,{className:"h-5 w-5"})})}),(0,l.jsx)(au.ZI,{align:"center",side:"bottom",className:"bg-gray-100 shadow-custom-tooltip",children:(0,l.jsx)("p",{className:"text-xs font-regular text-brand-black",children:"Edit"})})]}),(0,l.jsxs)(au.m_,{children:[(0,l.jsx)(au.k$,{asChild:!0,children:(0,l.jsx)(e$.$,{variant:"secondary",size:"icon",className:"border-brand-stroke text-red-400",onClick:()=>d(a.original),disabled:(null==m?void 0:m.id)===a.original.id,children:(null==m?void 0:m.is_staff)?(0,l.jsx)(lv.A,{className:"h-5 w-5"}):(0,l.jsx)(lN.A,{className:"h-5 w-5"})})}),(0,l.jsx)(au.ZI,{align:"center",side:"bottom",className:"bg-gray-100 shadow-custom-tooltip",children:(0,l.jsx)("p",{className:"text-xs font-regular text-brand-black",children:(null==m?void 0:m.is_staff)?"Delete":"Revoke access"})})]})]})}}];return(0,l.jsx)(eU.b,{columns:y,data:a,columnVisibility:{},onColumnVisibilityChange:()=>{},columnOrder:[],isLoading:t,pageCount:h?x:void 0,pageIndex:h?o:void 0,onPageChange:h?i:void 0,cellHeight:"",showPageSizeSelector:!0,pageSize:u,onPageSizeChange:p})}var l_=t(34334);function lw(e){let{data:a,isLoading:t=!1,onEdit:s=()=>{},onDelete:r=()=>{},pageCount:n,pageIndex:i,onPageChange:o,params:d,onSort:c,pageSize:m,onPageSizeChange:u}=e,{getSortableHeaderProps:p}=(0,ed.MG)({params:d,onSort:c,isLoading:t,data:a}),x=[{id:"property_name",header:()=>{let e=p("property_name","Property","start");return(0,l.jsxs)("div",{className:e.className,onClick:e.onClick,children:[(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(em.A,{className:e.upIconClassName}),(0,l.jsx)(eu.A,{className:e.downIconClassName})]}),(0,l.jsx)("span",{children:e.label})]})},accessorKey:"property_name"},{id:"unit_name",header:"Unit",accessorKey:"unit_name",cell:e=>{var a;let{row:t}=e;return(0,l.jsx)("div",{className:"flex flex-col gap-1 truncate",children:t.original.all_units?"All Units":null==(a=t.original.unit_list)?void 0:a.map(e=>e.unit_name).join(", ")})}},{id:"cost",header:()=>{let e=p("cost","Average Cost per Gallon");return(0,l.jsxs)("div",{className:e.className,onClick:e.onClick,children:[(0,l.jsx)("span",{className:"text-right",children:e.label}),(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(em.A,{className:e.upIconClassName}),(0,l.jsx)(eu.A,{className:e.downIconClassName})]})]})},accessorKey:"cost",cell:e=>{let{row:a}=e;return(0,l.jsx)("div",{className:"flex justify-end w-full",children:(0,l.jsxs)("span",{className:"text-right pr-6",children:["$",a.original.cost]})})}},{id:"start_date",header:()=>{let e=p("start_date","Start Date for Cost","start");return(0,l.jsxs)("div",{className:e.className,onClick:e.onClick,children:[(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(em.A,{className:e.upIconClassName}),(0,l.jsx)(eu.A,{className:e.downIconClassName})]}),(0,l.jsx)("span",{children:e.label})]})},accessorKey:"start_date",cell:e=>{let{row:a}=e;return(0,l.jsx)("div",{children:a.original.start_date?(0,et.GP)((0,l_.qg)(a.original.start_date,"yyyy-MM-dd",new Date),"MMM dd, yyyy"):"-"})}},{id:"end_date",header:()=>{let e=p("end_date","End Date for Cost","start");return(0,l.jsxs)("div",{className:e.className,onClick:e.onClick,children:[(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(em.A,{className:e.upIconClassName}),(0,l.jsx)(eu.A,{className:e.downIconClassName})]}),(0,l.jsx)("span",{children:e.label})]})},accessorKey:"end_date",cell:e=>{let{row:a}=e;return(0,l.jsx)("div",{children:a.original.end_date?(0,et.GP)((0,l_.qg)(a.original.end_date,"yyyy-MM-dd",new Date),"MMM dd, yyyy"):"-"})}},{id:"actions",header:"",size:180,enableResizing:!1,cell:e=>{let{row:a}=e;return(0,l.jsxs)("div",{className:"flex items-center gap-2 justify-end w-full",children:[(0,l.jsx)(e$.$,{variant:"secondary",size:"sm",onClick:()=>s(a.original),className:"h-7 px-2 text-brand-dark-cyan border-brand-dark-cyan",icon:lb.A,iconPosition:"right",children:"Edit"}),(0,l.jsx)(e$.$,{variant:"secondary",size:"sm",onClick:()=>r(a.original),className:"h-7 px-2 text-red-600 border-red-700 hover:border-red-700 hover:text-red-700",icon:lv.A,iconPosition:"right",children:"Delete"})]})},meta:{fixedWidth:!0}}];return(0,l.jsx)(eU.b,{columns:x,data:a,columnVisibility:{},columnOrder:[],onColumnVisibilityChange:()=>{},isLoading:t,pageCount:n,pageIndex:i,onPageChange:o,showPageSizeSelector:!0,pageSize:m,onPageSizeChange:u,menuPlacement:"top"})}function lk(e){let{data:a,isLoading:t,totalCount:s=0,onPageChange:r,currentPage:n=0}=e,i=Math.ceil(s/10),o=i>1,d=[{id:"index",header:"",cell:e=>{let{row:a}=e;return(0,l.jsxs)("span",{children:["#",a.index+1]})}},{accessorKey:"property_name",header:"Property"},{accessorKey:"total_units",header:()=>(0,l.jsx)("div",{className:"flex justify-end w-full",children:(0,l.jsx)("span",{className:"text-right",children:"Total Units"})}),cell:e=>{let{row:a}=e;return(0,l.jsx)("div",{className:"flex justify-end w-full",children:(0,l.jsx)("span",{className:"text-right",children:a.original.total_units.toLocaleStr
1ing()})})}},{accessorKey:"units_with_leaks",header:()=>(0,l.jsx)("div",{className:"flex justify-end w-full",children:(0,l.jsx)("span",{className:"text-right",children:"Leaking Units"})}),cell:e=>{let{row:a}=e;return(0,l.jsx)("div",{className:"flex justify-end w-full",children:(0,l.jsx)("span",{className:"text-right",children:a.original.units_with_leaks.toLocaleString()})})}},{accessorKey:"total_gallons_leaked_toilet",header:()=>(0,l.jsx)("div",{className:"flex justify-end w-full",children:(0,l.jsx)("span",{className:"text-right",children:"Leaking Toilets (gal)"})}),cell:e=>{let{row:a}=e;return(0,l.jsx)("div",{className:"flex justify-end w-full",children:(0,l.jsx)("span",{className:"text-right",children:a.original.total_gallons_leaked_toilet.toLocaleString()})})}},{accessorKey:"total_gallons_leaked_other",header:()=>(0,l.jsx)("div",{className:"flex justify-end w-full",children:(0,l.jsx)("span",{className:"text-right",children:"Leaking Other (gal)"})}),cell:e=>{let{row:a}=e;return(0,l.jsx)("div",{className:"flex justify-end w-full",children:(0,l.jsx)("span",{className:"text-right",children:a.original.total_gallons_leaked_other.toLocaleString()})})}},{accessorKey:"total_gallons_leaked",header:()=>(0,l.jsx)("div",{className:"flex justify-end w-full",children:(0,l.jsx)("span",{className:"text-right",children:"Total Gallons Leaked"})}),cell:e=>{let{row:a}=e;return(0,l.jsx)("div",{className:"flex justify-end w-full",children:(0,l.jsx)("span",{className:"text-right",children:a.original.total_gallons_leaked.toLocaleString()})})}},{accessorKey:"leak_volume",header:()=>(0,l.jsx)("div",{className:"flex justify-end w-full",children:(0,l.jsx)("span",{className:"text-right",children:"Leak Volume %"})}),cell:e=>{let{row:a}=e;return(0,l.jsx)("div",{className:"flex justify-end w-full",children:(0,l.jsxs)("span",{className:"text-right",children:[a.original.leak_volume.toLocaleString(),"%"]})})}}];return(0,l.jsx)(eU.b,{columns:d,data:a,columnVisibility:{},onColumnVisibilityChange:()=>{},columnOrder:[],getRowClassName:e=>{let a=[];return"red"===e.original.ranking?a.push("bg-red-100"):"yellow"===e.original.ranking?a.push("bg-orange-100"):a.push("bg-green-100"),a.join(" ")},isLoading:t,pageCount:o?i:void 0,pageIndex:o?n:void 0,onPageChange:o?r:void 0})}var lC=t(16083);let lS=lC.bL,lE=r.forwardRef((e,a)=>{let{className:t,...s}=e;return(0,l.jsx)(lC.q7,{ref:a,className:(0,i.cn)("border-b border-brand-stroke",t),...s})});lE.displayName="AccordionItem";let lL=r.forwardRef((e,a)=>{let{className:t,children:s,...r}=e;return(0,l.jsx)(lC.Y9,{className:"flex",children:(0,l.jsxs)(lC.l9,{ref:a,className:(0,i.cn)("cursor-pointer flex flex-1 items-center justify-between py-4 text-sm font-medium transition-all hover:text-brand-dark-cyan hover:shadow-custom-button [&[data-state=open]>svg]:rotate-180",t),...r,children:[s,(0,l.jsx)(eu.A,{className:"h-8 w-8 shrink-0 text-brand-dark-gray transition-transform duration-200"})]})})});lL.displayName=lC.l9.displayName;let lA=r.forwardRef((e,a)=>{let{className:t,children:s,...r}=e;return(0,l.jsx)(lC.UC,{ref:a,className:"overflow-hidden text-sm data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",...r,children:(0,l.jsx)("div",{className:(0,i.cn)("pb-4 pt-0",t),children:s})})});lA.displayName=lC.UC.displayName;var lD=t(52498);let lO=lD.bL;lD.l9;let lT=lD.ZL,lI=r.forwardRef((e,a)=>{let{className:t,...s}=e;return(0,l.jsx)(lD.hJ,{className:(0,i.cn)("fixed inset-0 z-50 bg-black/50 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...s,ref:a})});lI.displayName=lD.hJ.displayName;let lP=r.forwardRef((e,a)=>{let{className:t,...s}=e;return(0,l.jsxs)(lT,{children:[(0,l.jsx)(lI,{}),(0,l.jsx)(lD.UC,{ref:a,className:(0,i.cn)("fixed left-[50%] top-[50%] z-50 grid w-full translate-x-[-50%] translate-y-[-50%] gap-8 bg-brand-white p-6 shadow-custom-auth duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] rounded-[20px]",t),...s})]})});lP.displayName=lD.UC.displayName;let lR=e=>{let{className:a,...t}=e;return(0,l.jsx)("div",{className:(0,i.cn)("flex flex-col space-y-2 text-center sm:text-left",a),...t})};lR.displayName="AlertDialogHeader";let lM=e=>{let{className:a,...t}=e;return(0,l.jsx)("div",{className:(0,i.cn)("flex flex-col-reverse sm:flex-row sm:justify-end sm:gap-2",a),...t})};lM.displayName="AlertDialogFooter";let lG=r.forwardRef((e,a)=>{let{className:t,...s}=e;return(0,l.jsx)(lD.hE,{ref:a,className:(0,i.cn)("font-metropolis text-lg font-semibold",t),...s})});lG.displayName=lD.hE.displayName;let lz=r.forwardRef((e,a)=>{let{className:t,...s}=e;return(0,l.jsx)(lD.VY,{ref:a,className:(0,i.cn)("font-metropolis text-sm text-muted-foreground",t),...s})});
1lz.displayName=lD.VY.displayName;let lF=r.forwardRef((e,a)=>{let{className:t,...s}=e;return(0,l.jsx)(lD.rc,{ref:a,className:(0,i.cn)((0,e$.r)({variant:"primary"}),t),...s})});lF.displayName=lD.rc.displayName;let lH=r.forwardRef((e,a)=>{let{className:t,...s}=e;return(0,l.jsx)(lD.ZD,{ref:a,className:(0,i.cn)((0,e$.r)({variant:"secondary"}),"mt-2 sm:mt-0",t),...s})});lH.displayName=lD.ZD.displayName;var lV=t(94621);let lU=e=>e.toLocaleString();function lB(e){var a;let{data:t,className:s,isHourly:n}=e,o=n?0:Math.round(t.length/10),d=(a=t.length)>1500?5:a>1e3?4:a>500?3:a>200?2:1,c=r.useMemo(()=>{let e=new Set,a="";return t.forEach((t,l)=>{let s=t.label||"";if(s.toLowerCase().includes("12 am"))try{let t=(0,l_.qg)(s,"MM/dd h a",new Date),r=parseInt((0,et.GP)(t,"d"),10),n=(0,et.GP)(t,"MM/dd");n!==a&&r%d==0&&(e.add(l),a=n)}catch(e){}}),e},[t,d]);return(0,l.jsx)("div",{className:(0,i.cn)("w-full h-[250px]",s),children:(0,l.jsx)(u.u,{width:"99%",height:250,debounce:1,children:(0,l.jsxs)(p.X,{data:t,margin:{top:20,right:30,left:20,bottom:5},children:[(0,l.jsxs)("defs",{children:[(0,l.jsxs)("linearGradient",{id:"gallonsConsumed",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,l.jsx)("stop",{offset:"20.21%",stopColor:"#B9E9F0",stopOpacity:1}),(0,l.jsx)("stop",{offset:"100%",stopColor:"#B9E9F0",stopOpacity:.1})]}),(0,l.jsxs)("linearGradient",{id:"gallonsLeaked",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,l.jsx)("stop",{offset:"17%",stopColor:"#EE5A4F",stopOpacity:.4}),(0,l.jsx)("stop",{offset:"100%",stopColor:"#EE5A4F",stopOpacity:.16})]})]}),(0,l.jsx)(g.d,{yAxisId:"right",strokeDasharray:"0 0",vertical:!1,stroke:"#E5E7EB"}),(0,l.jsx)(y.W,{dataKey:"label",axisLine:!1,tickLine:!0,height:45,tick:n?e=>{let{x:a,y:t,payload:s,index:r}=e,n=c.has(r);return(0,l.jsx)("g",{transform:"translate(".concat(a,",").concat(t,")"),children:n&&(0,l.jsxs)("text",{x:0,y:20,textAnchor:"middle",fill:"#666",children:[(0,l.jsx)("tspan",{x:0,dy:"0",children:s.value.split(" ")[0]}),(0,l.jsx)("tspan",{x:0,dy:"16",children:s.value.split(" ").slice(1).join(" ")})]})})}:void 0,interval:o}),(0,l.jsx)(f.h,{yAxisId:"left",axisLine:!1,tickLine:!1,tick:{fill:"#666666"},tickFormatter:e=>lU(e)}),(0,l.jsx)(f.h,{yAxisId:"right",orientation:"right",axisLine:!1,tickLine:!1,tick:{fill:"#666666"},tickFormatter:e=>lU(e),allowDecimals:!1,width:30}),(0,l.jsx)(x.m,{formatter:(e,a)=>"Events"===a?[null!=e?lU(e):e,a]:["".concat(null!=e?lU(e):e," Gal"),a]}),(0,l.jsx)(h.s,{align:"right",verticalAlign:"top",iconType:"line",wrapperStyle:{paddingBottom:20,paddingRight:0}}),(0,l.jsx)(lV.Gk,{yAxisId:"left",type:"linear",dataKey:"gallons_consumed",stroke:"#0891B2",strokeWidth:2,fill:"url(#gallonsConsumed)",name:"Gallons"}),t.length>0&&"gallons_leaked"in t[0]&&(0,l.jsx)(lV.Gk,{yAxisId:"left",type:"linear",dataKey:"gallons_leaked",stroke:"#EE5A4F",strokeWidth:2,strokeDasharray:"12 2",fill:"url(#gallonsLeaked)",name:"Leak Gallons"}),(0,l.jsx)(R.N1,{yAxisId:"right",type:"linear",dataKey:"events",stroke:"#6341DD",strokeWidth:2,dot:!1,name:"Events"})]})})})}var lK=t(90368),lW=t(54024);function lY(e){let{className:a,classNames:t,showOutsideDays:s=!0,...r}=e;return(0,l.jsx)(lW.h,{showOutsideDays:s,className:(0,i.cn)("p-0",a),classNames:{months:"flex flex-col sm:flex-row relative",month:(0,i.cn)("border border-brand-stroke rounded-lg p-3","range"===r.mode&&"last:ml-4"),month_caption:"flex justify-center pt-1 relative items-center mb-4",caption_label:"text-sm font-medium",button_previous:(0,i.cn)((0,e$.r)({variant:"quaternary",size:"extraSmall"}),"h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100 absolute top-3 left-3 z-10"),button_next:(0,i.cn)((0,e$.r)({variant:"quaternary",size:"extraSmall"}),"h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100 absolute top-3 right-3 z-10"),month_grid:"w-full border-collapse",weekdays:"flex",weekday:"text-muted-foreground rounded-md w-8 font-normal text-[0.8rem]",week:"flex w-full mt-2",day:(0,i.cn)("relative p-0 text-center text-sm focus-within:relative focus-within:z-20 [&:has([aria-selected])]:bg-cyan-100 [&:has([aria-selected].day-range-end)]:rounded-r-md"),day_button:(0,i.cn)("h-8 w-8 p-0 font-normal text-sm aria-selected:opacity-100","data-selected:bg-brand-dark-cyan data-selected:text-brand-white data-selected:hover:bg-brand-dark-cyan data-selected:hover:text-brand-white data-selected:focus:bg-brand-dark-cyan data-selected:focus:text-brand-white"),range_start:"day-range-start rounded-l-md data-outside:bg-brand-dark-cyan data-selected:text-brand-white",range_end:"day-range-end rounded-r-md data-outside:bg-brand-dark-cyan data-selected:text-brand-white",selected:"bg-brand-dark-cyan text-primary-foreground hover:bg-brand-dark-cyan hover:text-primary-foreground focus:bg-brand-dark-cyan focus:text-primary-foreground",today:"bg-gray-100 text-brand-black rounded-md",outside:"text-brand-dark-gray opacity-50",disabled:"text-muted-foreground opacity-50",range_middle:"aria-selected:bg-cyan-100 aria-selected:text-accent-foreground",hidden:"invisible",...t}
1,components:{Chevron:e=>{let{...a}=e;return"left"===a.orientation?(0,l.jsx)(lK.A,{className:"h-4 w-4",...a}):(0,l.jsx)(es.A,{className:"h-4 w-4",...a})}},...r})}lY.displayName="Calendar";var l$=t(38162);let lZ=r.forwardRef((e,a)=>{let{className:t,...s}=e;return(0,l.jsx)(l$.bL,{ref:a,className:(0,i.cn)("peer h-4 w-4 shrink-0 rounded-xs border border-brand-dark-cyan shadow-sm focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-brand-dark-cyan data-[state=checked]:text-primary-foreground",t),...s,children:(0,l.jsx)(l$.C1,{className:(0,i.cn)("flex items-center justify-center text-current"),children:(0,l.jsx)(eY.A,{className:"h-4 w-4"})})})});lZ.displayName=l$.bL.displayName;var lq=t(31138);let lJ=lq.bL,lX=lq.l9;lq.Mz;let lQ=r.forwardRef((e,a)=>{let{className:t,align:s="center",sideOffset:r=4,...n}=e;return(0,l.jsx)(lq.ZL,{children:(0,l.jsx)(lq.UC,{ref:a,align:s,sideOffset:r,className:(0,i.cn)("z-50 w-72 rounded-md border border-brand-stroke bg-popover p-4 text-popover-foreground shadow-custom-popover outline-hidden data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-(--radix-popover-content-transform-origin)",t),...n})})});function l0(e){let{date:a,tempDate:t,isCalendarOpen:s,onCalendarOpenChange:r,onTempDateChange:n,onReset:i,onApply:o,isDisabled:d}=e;return(0,l.jsxs)(lJ,{open:s,onOpenChange:r,children:[(0,l.jsx)(lX,{asChild:!0,children:(0,l.jsx)(e$.$,{variant:"tertiary",className:"h-12 text-sm px-3 border border-cyan-300 text-cyan-700 hover:bg-cyan-50",disabled:d,icon:eL.A,children:a?(0,et.GP)(a,"MM/dd/yy"):"Select Date"})}),(0,l.jsxs)(lQ,{className:"w-auto p-0",sideOffset:18,alignOffset:-20,align:"end",children:[(0,l.jsxs)("div",{className:"px-5 pt-4 pb-2",children:[(0,l.jsx)("div",{className:"flex items-center justify-center px-4 py-3 border border-brand-stroke mb-3 rounded-md",children:(0,l.jsx)("p",{className:"text-base text-brand-black",children:t?(0,et.GP)(t,"MM/dd/yy"):"Select Date"})}),(0,l.jsx)(lY,{mode:"single",defaultMonth:t,selected:t,onSelect:e=>{if(!e)return void n(void 0);n(e)},disabled:{after:new Date}})]}),(0,l.jsxs)("div",{className:"flex justify-between gap-6 px-4 py-3 border-t border-brand-stroke",children:[(0,l.jsx)(e$.$,{variant:"tertiary",className:"w-full",onClick:i,children:"Reset"}),(0,l.jsx)(e$.$,{className:"w-full",onClick:o,children:"Apply"})]})]})]})}function l1(e){let{dateRange:a,tempDateRange:t,isCalendarOpen:s,onCalendarOpenChange:r,onTempDateRangeChange:n,onReset:o,onApply:d,isDisabled:c,
1className:m}=e;return(0,l.jsxs)(lJ,{open:s,onOpenChange:r,children:[(0,l.jsx)(lX,{asChild:!0,children:(0,l.jsx)(e$.$,{variant:"tertiary",className:(0,i.cn)("h-12 text-sm px-3 border border-cyan-300 text-cyan-700 hover:bg-cyan-50",m),disabled:c,icon:eL.A,children:a.from?a.to?(0,l.jsxs)(l.Fragment,{children:[(0,et.GP)(a.from,"d MMM, y")," -"," ",(0,et.GP)(a.to,"d MMM, y")]}):(0,et.GP)(a.from,"d MMM, y"):"Custom Date Range"})}),(0,l.jsxs)(lQ,{className:"w-auto p-0",sideOffset:18,alignOffset:-20,align:"end",children:[(0,l.jsxs)("div",{className:"px-5 pt-4 pb-2",children:[(0,l.jsx)("div",{className:"flex items-center justify-center px-4 py-3 border border-brand-stroke mb-3 rounded-md",children:(0,l.jsx)("p",{className:"text-base text-brand-black",children:t.from?t.to?(0,l.jsxs)(l.Fragment,{children:[(0,et.GP)(t.from,"d MMM, y")," -"," ",(0,et.GP)(t.to,"d MMM, y")]}):(0,et.GP)(t.from,"d MMM, y"):"Select Date Range"})}),(0,l.jsx)(lY,{mode:"range",defaultMonth:t.from||a.from,selected:{from:t.from,to:t.to},disabled:{after:new Date},onSelect:e=>{if(!e)return void n({from:void 0,to:void 0});n({from:e.from?new Date(new Date(e.from).toDateString()):void 0,to:e.to?new Date(new Date(e.to).toDateString()):void 0})},numberOfMonths:2}),(0,l.jsx)("p",{className:"text-xs text-brand-dark-gray pt-2 max-w-[512px]",children:"Hourly data is available from yesterday up to three months ago. Data between three and six months is aggregated daily. Data beyond six months is available upon request."})]}),(0,l.jsxs)("div",{className:"flex justify-between gap-6 px-4 py-3 border-t border-brand-stroke",children:[(0,l.jsx)(e$.$,{variant:"tertiary",className:"w-full",onClick:o,children:"Reset"}),(0,l.jsx)(e$.$,{className:"w-full",onClick:d,children:"Apply"})]})]})]})}lQ.displayName=lq.UC.displayName,t(6259),t(93893);let l2=r.forwardRef((e,a)=>{let{className:t,type:s,icon:r,error:n,errorClassName:o,onIconClick:d,onClearInput:c,showClearIcon:m,...u}=e;return(0,l.jsxs)("div",{className:"w-full",children:[(0,l.jsxs)("div",{className:"relative",children:[r&&(0,l.jsx)("div",{className:"absolute inset-y-0 left-3 flex items-center ".concat(d?"cursor-pointer":"cursor-default"),onClick:d||void 0,children:(0,l.jsx)(r,{className:"h-5 w-5 text-brand-dark-gray"})}),m&&(0,l.jsx)("div",{className:"absolute inset-y-0 right-3 flex items-center cursor-pointer",onClick:c,children:(0,l.jsx)(ek.A,{className:"h-5 w-5 text-brand-dark-gray"})}),(0,l.jsx)("input",{type:s,className:(0,i.cn)("flex h-9 w-full rounded-md border border-brand-stroke bg-transparent px-3 py-1 text-base shadow-xs transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-brand-dark-cyan disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",n&&"border-brand-red focus-visible:ring-0 focus-visible:ring-brand-red",r&&"pl-10",m&&"pr-10",t),ref:a,...u})]}),n&&(0,l.jsx)("p",{className:(0,i.cn)("mt-1 text-sm text-brand-red",o),children:n})]})});l2.displayName="Input";var l5=t(32894);let l3=r.forwardRef((e,a)=>{let{className:t,required:s,disabled:r,children:n,...o}=e;return(0,l.jsxs)(l5.b,{ref:a,className:(0,i.cn)("text-sm text-brand-black font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",r&&"cursor-not-allowed opacity-70",t),...o,children:[n,s&&(0,l.jsx)("span",{className:"text-sm text-brand-red",children:" (*)"})]})});l3.displayName=l5.b.displayName;var l4=t(20639),l6=t(25276),l8=t(24589);function l9(e){var a;let{percentage:t,size:s="md"}=e,r=(a=t)<5?{icon:l4.A,color:"text-brand-dark-cyan",tooltip:"Excellent Performance! Minimal water loss detected—you're setting a great example."}:a>=5&&a<10?{icon:l6.A,color:"text-green-600",tooltip:"On Track! Your water usage is within the optimal range, with slight room for improvement."}:a>=10&&a<25?{icon:t0.A,color:"text-orange-400",tooltip:"Attention Needed! Moderate water loss—investigating early can save costs."}:{icon:l8.A,color:"text-brand-red",tooltip:"Urgent Attention Required! High leakage levels—take action now!"},n=r.icon;return(0,l.jsxs)(au.m_,{children:[(0,l.jsx)(au.k$,{children:(0,l.jsx)(n,{className:"w-".concat("sm"===s?"4":"6"," h-").concat("sm"===s?"4":"6"," ").concat(r.color)})}),(0,l.jsx)(au.ZI,{align:"end",className:"w-52",children:(0,l.jsx)("p",{className:"text-xs text-brand-white",children:r.tooltip})})]})}var l7=t(70532),se=t(57828);let sa={minLength:"At least 10 characters",uppercase:"At least one uppercase letter (A-Z)",digit:"At least one digit (0-9)",special:'At least one special character (!@#$%^&*(),.?":{}|<>)'},st={weak:"text-red-300",good:"text-brand-light-blue",excellent:"text-brand-light-blue"},sl={weak:"Weak",good:"Good",excellent:"Excellent!"},ss=r.forwardRef((e,a)=>{let{className:t,error:s,errorClassName:n,showStrength:o=!1,showMatchError:d=!1,matchTarget:c="",onCh
1ange:m,...u}=e,[p,x]=r.useState(!1),[h,g]=(0,r.useState)(null),[y,f]=(0,r.useState)(""),[b,v]=(0,r.useState)(null);(0,r.useEffect)(()=>{d&&((y||c)&&y&&c&&y!==c?v("Passwords do not match. Please try again."):v(null))},[y,c,d]);let N=y.length>=10,j=/[A-Z]/.test(y),_=/[0-9]/.test(y),w=/[!@#$%^&*(),.?":{}|<>]/.test(y),k=[{met:N,text:sa.minLength},{met:j,text:sa.uppercase},{met:_,text:sa.digit},{met:w,text:sa.special}];return(0,l.jsxs)("div",{className:"w-full",children:[(0,l.jsxs)("div",{className:"relative",children:[(0,l.jsx)(l2,{type:p?"text":"password",className:(0,i.cn)("pr-10",t),ref:a,error:d?b:s,errorClassName:n,onChange:e=>{let a=e.target.value;f(a),o&&g(function(e){if(!e)return null;let a=e.length>=10,t=/[A-Z]/.test(e),l=/[0-9]/.test(e),s=[a,t,l,/[!@#$%^&*(),.?":{}|<>]/.test(e)].filter(Boolean).length;return s<=2?"weak":3===s?"good":"excellent"}(a)),null==m||m(e)},...u}),(0,l.jsx)("button",{type:"button",onClick:()=>x(!p),className:"absolute right-3 top-2.5 text-brand-dark-gray hover:text-brand-black",children:p?(0,l.jsx)(l7.A,{className:"h-4 w-4"}):(0,l.jsx)(se.A,{className:"h-4 w-4"})})]}),o&&(0,l.jsx)("div",{className:"mt-2 space-y-2",children:h&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("p",{children:[(0,l.jsx)("span",{className:"text-sm font-regular text-brand-white",children:"Password Strength:"})," ",(0,l.jsx)("span",{className:(0,i.cn)("text-sm font-semibold",st[h]),children:sl[h]})]}),(0,l.jsx)("ul",{className:"text-xs space-y-1.5",children:k.map((e,a)=>(0,l.jsxs)("li",{className:(0,i.cn)("flex items-center gap-2 text-sm py-0.5 px-2.5",e.met?"text-brand-light-blue":"text-brand-white"),children:[(0,l.jsx)(eY.A,{className:(0,i.cn)("h-4 w-4",e.met?"opacity-100":"opacity-30")}),(0,l.jsx)("span",{children:e.text})]},a))})]})})]})});ss.displayName="PasswordInput";var sr=t(45953),sn=t(588),si=t(38600);let so=e=>(0,l.jsx)(sr.c.ValueContainer,{...e,children:(0,l.jsx)("div",{className:"flex items-center pl-3 py-2",children:e.children})}),sd=e=>{let{index:a}=e,t=e.getValue();return 0===a?(0,l.jsx)(sr.c.MultiValue,{...e}):1===a?(0,l.jsxs)("div",{className:"bg-gray-100 rounded-[6px] px-2 py-0.5 mr-1 text-xs font-medium text-brand-black shadow-custom-select-dropdown",children:["+",t.length-1]}):null},sc=e=>{let a=r.Children.toArray(e.children),t=Math.min(e.maxHeight,36*a.length);return a.length<=1?(0,l.jsx)(sr.c.MenuList,{...e}):(0,l.jsx)(si.Y1,{height:t,itemCount:a.length,itemSize:36,width:"100%",children:e=>{let{index:t,style:s}=e;return(0,l.jsx)("div",{style:s,children:a[t]})}})};function sm(e){let{control:a,name:t,options:s,error:n,showSelectAll:o,description:d,onSelectionChange:c,onMenuClose:m,onMenuOpen:u,clearButton:p=!0,placeholder:x="Select...",isDisabled:h=!1,labelMaxWidth:g="2xl:max-w-64",excludeFromSelectAll:y=[]}=e,[f,b]=(0,r.useState)(!1),v=(0,r.useRef)(null),N=o&&s.length>1?[{label:"All",value:"all"},...s]:s;return(0,r.useEffect)(()=>{if(!f)return;let e=e=>{v.current&&!v.current.contains(e.target)&&(b(!1),null==m||m())};return window.document.addEventListener("mousedown",e),()=>{window.document.removeEventListener("mousedown",e)}},[f,m]),(0,l.jsxs)("div",{className:"w-full",ref:v,children:[(0,l.jsx)(ew.xI,{control:a,name:t,render:e=>{let{field:a}=e,t=s.filter(e=>!y.includes(e.value)),r=t.length>0&&t.every(e=>{var t;return null==(t=a.value)?void 0:t.includes(e.value)});return(0,l.jsx)(sn.Ay,{...a,isMulti:!0,unstyled:!0,maxMenuHeight:160,menuPlacement:"auto",options:N,value:r&&o?s.filter(e=>{var t;return null==(t=a.value)?void 0:t.includes(e.value)}):s.filter(e=>{var t;return null==(t=a.value)?void 0:t.includes(e.value)}),menuIsOpen:f,onMenuOpen:()=>{b(!0),null==u||u()},onMenuClose:()=>{b(!1),null==m||m()},closeMenuOnSelect:!1,hideSelectedOptions:!1,backspaceRemovesValue:!0,isClearable:p,placeholder:x,isDisabled:h,components:{Option:e=>(0,l.jsx)(sr.c.Option,{...e,children:(0,l.jsxs)("div",{className:"flex items-center justify-between w-full",children:[(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("div",{className:"w-4 h-4 shrink-0 rounded-xs border border-brand-dark-cyan shadow-sm",children:("all"===e.data.value?r:e.isSelected)&&(0,l.jsx)("div",{className:"flex items-center justify-center bg-brand-dark-cyan",children:(0,l.jsx)(eY.A,{size:16,className:"text-white"})})}),e.children]}),("all"===e.data.value?r:e.isSelected)&&(0,l.jsx)(eY.A,{size:16,className:"ml-auto text-brand-dark-cyan"})]})}),MultiValueRemove:e=>{let{...a}=e;return(0,l.jsx)(sr.c.MultiValueRemove,{...a,children:(0,l.jsx)(ek.A,{size:16,className:"ml-2.5 cursor-pointer text-brand-dark-gray"})})},ClearIndicator:e=>{let{...a}=e;return(0,l.jsx)(sr.c.ClearIndicator,{...a,children:(0,l.jsx)(ek.A,{size:16,className:"cursor-pointer text-brand-dark-gray"})})},ValueContainer:so,MultiValue:sd,MenuList:sc},classNames:{control:e=>(0,i.cn)("flex min-h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-brand-stroke bg-transparent pr-3 text-sm shadow-xs ring-offset-background focus:outline-hidden focu
1s:border-brand-dark-cyan hover:border-brand-dark-cyan disabled:cursor-not-allowed disabled:opacity-50",n&&"border-brand-red focus:border-brand-red",e.isFocused&&"border-brand-dark-cyan",e.isDisabled&&"cursor-not-allowed opacity-50"),placeholder:()=>"text-brand-dark-gray",multiValue:()=>"bg-gray-100 rounded-[6px] px-2 py-0.5 mr-1 text-xs font-medium text-brand-black shadow-custom-select-dropdown md:max-w-48 ".concat(g," truncate"),menu:()=>"text-sm bg-white border border-[rgba(15,23,42,0.10)] rounded-md shadow-custom-select-dropdown mt-1",option:e=>(0,i.cn)("p-2 cursor-pointer",e.isFocused&&"bg-cyan-50"),dropdownIndicator:e=>(0,i.cn)("text-brand-dark-gray transition-all! duration-200 pointer-events-auto",e.selectProps.menuIsOpen&&"rotate-180")},onChange:e=>{let t=e.map(e=>e.value),l=a.value||[],r=s.filter(e=>!y.includes(e.value)).map(e=>e.value),n=r.length>0&&r.every(e=>l.includes(e));if(t.includes("all"))return void(n?(a.onChange([]),null==c||c([])):(a.onChange(r),null==c||c(r)));if(y.length>0){let e=t.filter(e=>y.includes(e)),s=l.some(e=>y.includes(e)),r=e.filter(e=>!l.includes(e));if(r.length>0){a.onChange(r),null==c||c(r);return}if(s&&t.length>e.length){let e=t.filter(e=>!y.includes(e));a.onChange(e),null==c||c(e);return}}a.onChange(t),null==c||c(t)}})}}),n?(0,l.jsx)("p",{className:"text-sm text-brand-red mt-1.5",children:n}):d?(0,l.jsx)("p",{className:"text-sm text-brand-dark-gray mt-1.5",children:d}):null]})}var su=t(42292),sp=t(80891);let sx=r.forwardRef((e,a)=>{let{className:t,...s}=e;return(0,l.jsxs)(sp.bL,{ref:a,className:(0,i.cn)("relative flex w-full touch-none select-none items-center",t),...s,children:[(0,l.jsx)(sp.CC,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:(0,l.jsx)(sp.Q6,{className:"absolute h-full bg-brand-dark-cyan"})}),(0,l.jsx)(sp.zi,{className:"block h-5 w-5 rounded-full border-2 border-brand-dark-cyan bg-background ring-offset-background transition-colors focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50"}),(0,l.jsx)(sp.zi,{className:"block h-5 w-5 rounded-full border-2 border-brand-dark-cyan bg-background ring-offset-background transition-colors focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50"})]})});sx.displayName=sp.bL.displayName;var sh=t(68695),sg=t(94954);function sy(e){let{icon:a,iconBgColor:t,iconColor:s,title:r,value:n,isLoading:i,valueFormatter:o=e=>e.toLocaleString(),borderColor:d="border-brand-stroke",comparisonValue:c,toiletLeakValue:m,waterHeaterLeakValue:u,toiletLeakComparisonValue:p,waterHeaterLeakComparisonValue:x,spoeDpoeUnitsCount:h,toiletUnitsCount:g,waterHeaterUnitsCount:y,targetValue:f,isMainCard:b=!0}=e;return(0,l.jsxs)("div",{className:"relative flex flex-1 ".concat(b?"flex-col xl:flex-row justify-start lg:items-center":"flex-col justify-center items-start"," shrink-0 min-w-full lg:min-w-fit py-4 gap-4 bg-white rounded-xl border ").concat(d," px-5"),children:[(0,l.jsxs)("div",{className:"flex gap-3 flex-1 ".concat("items-center"),children:[(0,l.jsx)("div",{className:"flex items-center justify-center shrink-0 w-10 h-10 rounded-md ".concat(t),children:(0,l.jsx)(a,{className:"w-6 h-6 ".concat(s)})}),(0,l.jsxs)("p",{className:"text-base font-semibold whitespace-nowrap",children:[r,b&&(0,l.jsx)("br",{}),(0,l.jsx)("span",{className:"text-sm font-normal text-brand-dark-gray ".concat(b?"":"pl-2"),children:"(gallons per day)"})]})]}),(0,l.jsxs)("div",{className:"w-full grid grid-cols-1 xl:grid-cols-[1fr_2fr] gap-5",children:[(0,l.jsxs)("div",{className:"border border-gray-300 rounded-xl px-4 py-3 flex gap-2",children:[(0,l.jsxs)("div",{className:"flex flex-col justify-center",children:[(0,l.jsx)("p",{className:"text-sm font-semibold text-nowrap text-brand-black mb-0.5",children:"GBD"}),(0,l.jsx)("div",{className:"min-w-14",children:i?(0,l.jsx)(ee.A,{className:"h-3 w-3 animate-spin text-brand-dark-gray"}):(0,l.jsxs)("p",{className:"text-xs font-medium text-nowrap text-brand-dark-gray",children:["Target: ",f]})})]}),(0,l.jsxs)("div",{className:"border border-gray-300 bg-gray-50 rounded-xl px-4 py-3 grid grid-cols-1 md:grid-cols-[3fr_1fr] gap-2 w-full",children:[(0,l.jsxs)("div",{className:"flex flex-col",children:[(0,l.jsx)("p",{className:"text-sm font-medium text-nowrap text-brand-dark-gray",children:"(SPOE/DPOE)"}),i?(0,l.jsx)(ee.A,{className:"h-7 w-6 animate-spin text-brand-dark-cyan"}):(0,l.jsxs)("div",{className:"flex items-center gap-1",children:[(0,l.jsx)("p",{className:"text-xl font-bold",children:"number"==typeof n?o(n):n}),(0,l.jsx)("p",{className:"text-xl font-bold",children:(0,l.jsx)("span",{className:"text-sm font-medium text-nowrap text-brand-dark-gray",children:"(gallons)"})}),void 0!==c&&0!==c&&(0,l.jsxs)("div",{className:"flex items-center gap-1 ".concat(c>0?"text-red-700":"text-green-700"),children:[c>0?(0,l.jsx)(sh.A,{className:"w-5 h-5"}):(0,l.jsx)(sg.A,{className:"w-5 h-5"}),(0,l.jsxs)("p",{className:"text-base",children:[c>0?"+":"-",Math.abs(c),"%"]})]})]})]}),(0,l.jsxs)("div",{className:"flex flex-col",children:[(0,l.jsx)("p",{className:"text-sm font-medium text-nowrap text-brand-dark-gray",children:"Units"}),i?(0,l.jsx)(ee.A,{className:"h-7 w-6 animate-spin text-brand-dark-cyan"}):(0,l.jsx)("div",{className:"flex items-center flex-wrap gap-1",children:(0,l.jsx)("p",{className:"text-xl font-bold flex-1",children:o(null!=h?h:0)})})]})]})]}),(0,l.jsxs)("div",{className:"border border-gray-300 rounded-xl px-4 py-3 flex gap-2",children:[(0,l.jsxs)("div",{className:"flex flex-col justify-center",children:[(0,l.jsx)("p",{className:"text-sm font-semibold text-nowrap text-brand-black",children:"Fixture Level"}),(0,l.jsx)("p",{className:"text-sm font-semibold text-nowrap text-brand-black",children:"(Point of Use)"})]}),(0,l.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-[1fr_1fr] gap-3 w-full",children:[(0,l.jsxs)("div",{className:"border border-gray-300 bg-gray-50 rounded-xl px-4 py-3 flex flex-row items-center gap-3",children:[(0,l.jsx)("div",{className:"overflow-hidden h-10 w-10 border border-brand-stroke rounded-lg flex items-center justify-center shrink-0 bg-indigo-100",children:(0,l.jsx)(aO,{leakType:"toilet leak",className:"w-10 h-10 flex-1"})}),(0,l.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-[3fr_1fr] gap-2 w-full",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("p",{className:"text-sm font-medium text-nowrap text-brand-dark-gray",children:"Toilet"}),i?(0,l.jsx)(ee.A,{className:"h-7 w-6 animate-spin text-brand-dark-cyan"}):(0,l.jsxs)("div",{className:"flex items-center flex-wrap gap-1",children:[(0,l.jsx)("p",{className:"text-xl font-bold",children:m?o(m):m}),(0,l.jsx)("p",{className:"text-xl font-bold",children:(0,l.jsx)("span",{className:"text-sm font-medium text-nowrap text-brand-dark-gray",children:"(gallons)"})}),void 0!==p&&0!==p&&(0,l.jsxs)("div",{className:"flex items-center gap-1 ".concat(p>0?"text-red-700":"text-green-700"),children:[p>0?(0,l.jsx)(sh.A,{className:"w-5 h-5"}):(0,l.jsx)(sg.A,{className:"w-5 h-5"}),(0,l.jsxs)("p",{className:"text-base",children:[p>0?"+":"-",Math.abs(p),"%"]})]})]})]}),(0,l.jsxs)("div",{className:"flex flex-col",children:[(0,l.jsx)("p",{className:"text-sm font-medium text-nowrap text-brand-dark-gray",children:"Units"}),i?(0,l.jsx)(ee.A,{className:"h-7 w-6 animate-spin text-brand-dark-cyan"}):(0,l.jsx)("div",{className:"flex items-center flex-wrap gap-1",children:(0,l.jsx)("p",{className:"text-xl font-bold flex-1",children:o(null!=g?g:0)})})]})]})]}),(0,l.jsxs)("div",{className:"border border-gray-300 bg-gray-50 rounded-xl px-4 py-3 flex flex-row items-center gap-3",children:[(0,l.jsx)("div",{className:"overflow-hidden h-10 w-10 border border-brand-stroke rounded-lg flex items-center justify-center shrink-0 bg-orange-100",children:(0,l.jsx)(aO,{leakType:"water heater",className:"w-10 h-10 flex-1"})}),(0,l.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-[3fr_1fr] gap-2 w-full",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("p",{className:"text-sm font-medium text-nowrap text-brand-dark-gray",children:"Water Heater"}),i?(0,l.jsx)(ee.A,{className:"h-7 w-6 animate-spin text-brand-dark-cyan"}):(0,l.jsxs)("div",{className:"flex items-center flex-wrap gap-1",children:[(0,l.jsx)("p",{className:"text-xl font-bold",children:u?o(u):u}),(0,l.jsx)("p",{className:"text-xl font-bold",children:(0,l.jsx)("span",{className:"text-sm font-medium text-nowrap text-brand-dark-gray",children:"(gallons)"})}),void 0!==x&&0!==x&&(0,l.jsxs)("div",{className:"flex items-center gap-1 ".concat(x>0?"text-red-700":"text-green-700"),children:[x>0?(0,l.jsx)(sh.A,{className:"w-5 h-5"}):(0,l.jsx)(sg.A,{className:"w-5 h-5"}),(0,l.jsxs)("p",{className:"text-base",children:[x>0?"+":"-",Math.abs(x),"%"]})]})]})]}),(0,l.jsxs)("div",{className:"flex flex-col",children:[(0,l.jsx)("p",{className:"text-sm font-medium text-nowrap text-brand-dark-gray",children:"Units"}),i?(0,l.jsx)(ee.A,{className:"h-7 w-6 animate-spin text-brand-dark-cyan"}):(0,l.jsx)("div",{className:"flex items-center flex-wrap gap-1",children:(0,l.jsx)("p",{className:"text-xl font-bold flex-1",children:o(null!=y?y:0)})})]})]})]})]})]})]})]})}var sf=t(40987),sb=t(27599);let sv=r.forwardRef((e,a)=>{let{className:t,...s}=e;return(0,l.jsx)(sb.bL,{className:(0,i.cn)("peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-xs transition-colors focus-visible:outline-hidden focu
1s-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-brand-dark-cyan data-[state=unchecked]:bg-gray-200",t),...s,ref:a,children:(0,l.jsx)(sb.zi,{className:(0,i.cn)("pointer-events-none block h-4 w-4 rounded-full bg-brand-white shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0")})})});function sN(e){let{variant:a,className:t,...s}=e,r="success"===a?eY.A:t0.A;return(0,l.jsx)("div",{className:(0,i.cn)("flex items-center justify-center",t),...s,children:(0,l.jsx)("div",{className:(0,i.cn)("flex items-center justify-center w-14 h-14 rounded-full","success"===a?"bg-brand-dark-cyan/30":"bg-brand-red/30"),children:(0,l.jsx)("div",{className:(0,i.cn)("flex items-center justify-center w-12 h-12 rounded-full px-1.5 py-2.5","success"===a?"bg-brand-dark-cyan":"bg-brand-red"),children:(0,l.jsx)(r,{className:"w-6 h-6 text-brand-white"})})})})}sv.displayName=sb.bL.displayName;var sj=t(71414);t(38126),t(23042),t(1275);let s_=e=>{let{organizationId:a,propertyId:t,value:s,onChange:n,placeholder:i="All Property | Units",className:o="",error:d=!1}=e,[c,m]=(0,r.useState)(!1),[u,p]=(0,r.useState)([]),[x,h]=(0,r.useState)(!1),[g,y]=(0,r.useState)(new Set),[f,b]=(0,r.useState)(new Set),[v,N]=(0,r.useState)(new Set),j=(0,r.useRef)(null),_=(0,r.useRef)(!1);(0,r.useEffect)(()=>{let e=async()=>{try{h(!0);let e=await e5.FH.inventory.getPropertyUnits({organization_id:a,property_id:t});p(e)}catch(e){console.error("Failed to fetch property units:",e)}finally{h(!1)}};(c&&0===u.length||void 0!==s)&&e()},[c,u.length,s]),(0,r.useEffect)(()=>{let e=e=>{j.current&&!j.current.contains(e.target)&&m(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]);let w=()=>u.flatMap(e=>e.units.map(e=>e.id)),k=e=>{let a=u.find(a=>a.id===e);return(null==a?void 0:a.units.map(e=>e.id))||[]},C=()=>{if(0===g.size)return null;let e=u.filter(e=>e.units.some(e=>g.has(e.id)));if(0===e.length)return null;let a=e[0],t=a.units.filter(e=>g.has(e.id));if(a.units.length===t.length)return{label:"".concat(a.name," | all units"),propertyId:a.id,type:"property"};{let e=t.length;return{label:"".concat(a.name," | ").concat(e," ").concat(1===e?"unit":"units"),propertyId:a.id,type:"property"}}},S=e=>{let a;e.preventDefault(),e.stopPropagation();let t=C();if(!t)return;let l=new Set(g),s=new Set(f);if("property"===t.type&&t.propertyId){let e=u.find(e=>e.id===t.propertyId);e&&(e.units.forEach(e=>{l.delete(e.id)}),s.delete(t.propertyId))}if(y(l),b(s),0===l.size)a=void 0;else if(l.size===w().length)a={type:"all",label:"All"};else{let e=u.filter(e=>e.units.some(e=>l.has(e.id)));if(1===e.length){let t=e[0],s=t.units.filter(e=>l.has(e.id));a=1===s.length?{type:"unit",propertyId:t.id,unitId:s[0].id,label:"".concat(t.name," | ").concat(s[0].name)}:{type:"property",propertyId:t.id,label:t.name}}else{let t=e[0];a={type:"property",propertyId:t.id,label:t.name}}}n(a,Array.from(l))},E=()=>{let e=w();return e.length>0&&e.every(e=>g.has(e))},L=e=>f.has(e.id),A=e=>g.has(e),D=e=>v.has(e);return(0,r.useEffect)(()=>{void 0!==s&&s.unitId&&s.propertyId&&!_.current&&u.length>0&&(y(new Set(Array.isArray(s.unitId)?s.unitId:[s.unitId])),b(new Set([s.propertyId])),N(new Set([s.propertyId])),_.current=!0)},[s,u.length]),(0,l.jsxs)("div",{className:"relative ".concat(o),ref:j,children:[(0,l.jsxs)("button",{type:"button",onClick:()=>m(!c),className:"w-full flex items-center justify-between px-3 py-2 text-left bg-white border border-gray-300 rounded-md shadow-xs focus:outline-hidden focus:ring-1 ".concat(d?"border-red-500 ":"focus:ring-brand-dark-cyan"),children:[(0,l.jsx)("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:(()=>{let e=C();if(!e)return(0,l.jsx)("span",{className:"text-sm text-gray-500 truncate",children:i});if(g.size===w().length)return(0,l.jsx)("span",{className:"text-sm truncate",children:"All"});let a=f.size-1;return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("div",{className:"inline-flex items-center gap-1 bg-gray-100 text-brand-black px-2 py-1 rounded-sm text-xs",children:[(0,l.jsx)("span",{className:"truncate",children:e.label}),(0,l.jsx)(ek.A,{className:"w-4 h-4 cursor-pointer hover:text-red-500 shrink-0 text-brand-dark-gray",onClick:S,strokeWidth:2})]}),a>0&&(0,l.jsxs)("span",{className:"text-sm text-gray-600",children:["+",a," more"]})]})})()}),(0,l.jsx)(eu.A,{className:"w-4 h-4 transition-transform shrink-0 ".concat(c?"rotate-180":"")})]}),c&&(0,l.jsx)("div",{className:"absolute z-50 w-full mt-1 bg-white border border-gray-300 rounded-md shadow-lg max-h-60 overflow-y-auto",children:x?(0,l.jsx)("div",{className:"px-3 py-2 text-gray-500",children:"Loading..."}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("div",{onClick:()=>{let e=w();E()?(y(new Set),b(new Set),n({type:"all",label:"None"},[])):(y(new Set(e)),b(new Set(u.map(e=>e.id))),n({type:"all",label:"All"},e)),m(!1)},className:"flex items-center px-3 py-2 hover:bg-gray-50 cursor-pointer",children:[(0,l.jsx)("div",{className:"flex items-center mr-2",children:(0,l.jsx)("div",{className:"w-4 h-4 border border-gray-300 rounded-sm ".concat(E()?"bg-brand-dark-cyan border-brand-dark-cyan":"bg-white"," flex items-center justify-center"),children:E()&&(0,l.jsx)(eY.A,{className:"w-3 h-3 text-white"})})}),(0,l.jsx)("span",{className:"text-sm text-brand-black select-none",children:"All"})]}),u.map(e=>(0,l.jsxs)("div",{children:[(0,l.jsxs)("div",{className:"flex items-center px-3 py-2 hover:bg-gray-50 bg-gray-25",children:[(0,l.jsxs)("div",{onClick:()=>(e=>{let a=k(e.id),t=new Set(g),l=new Set(f);a.every(e=>
1g.has(e))?(a.forEach(e=>t.delete(e)),l.delete(e.id)):(a.forEach(e=>t.add(e)),l.add(e.id)),y(t),b(l),n({type:"property",propertyId:e.id,label:e.name},Array.from(t))})(e),className:"flex items-center flex-1 cursor-pointer",children:[(0,l.jsx)("div",{className:"flex items-center mr-2",children:(0,l.jsx)("div",{className:"w-4 h-4 border border-gray-300 rounded-sm ".concat(L(e)?"bg-brand-dark-cyan border-brand-dark-cyan":"bg-white"," flex items-center justify-center"),children:L(e)&&(0,l.jsx)(eY.A,{className:"w-3 h-3 text-white"})})}),(0,l.jsx)("span",{className:"text-sm text-brand-black select-none",children:e.name})]}),(0,l.jsx)("button",{type:"button",onClick:a=>{a.stopPropagation(),(e=>{let a=new Set(v);v.has(e)?a.delete(e):a.add(e),N(a)})(e.id)},className:"w-5 h-5 flex items-center justify-center mr-2 hover:bg-gray-200 rounded",children:(0,l.jsx)(eu.A,{className:"text-brand-dark-gray w-4 h-4 transition-transform ".concat(D(e.id)?"rotate-180":"")})})]}),D(e.id)&&e.units.map(a=>(0,l.jsxs)("div",{onClick:()=>((e,a)=>{let t=new Set(g),l=new Set(f);g.has(a.id)?(t.delete(a.id),k(e.id).some(e=>e!==a.id&&t.has(e))||l.delete(e.id)):(t.add(a.id),k(e.id).every(e=>e===a.id||t.has(e))&&l.add(e.id)),y(t),b(l),n({type:"unit",propertyId:e.id,unitId:a.id,label:"".concat(e.name," | ").concat(a.name)},Array.from(t))})(e,a),className:"flex items-center px-8 py-2 hover:bg-gray-50 cursor-pointer",children:[(0,l.jsx)("div",{className:"flex items-center mr-2 ml-4",children:(0,l.jsx)("div",{className:"w-4 h-4 border border-gray-300 rounded-sm ".concat(A(a.id)?"bg-brand-dark-cyan border-brand-dark-cyan":"bg-white"," flex items-center justify-center"),children:A(a.id)&&(0,l.jsx)(eY.A,{className:"w-3 h-3 text-white"})})}),(0,l.jsx)("span",{className:"text-sm text-brand-black select-none",children:a.name})]},a.id))]},e.id)),0===u.length&&!x&&(0,l.jsx)("div",{className:"px-3 py-2 text-gray-500",children:"No properties found"})]})})]})}},32897:(e,a,t)=>{t.d(a,{b:()=>m});var l=t(95155),s=t(12115),r=t(30563),n=t(92273),i=t(87270),o=t(35299),d=t(71414),c=t(64269);
1function m(e){let{columns:a,data:t,columnVisibility:m,onColumnVisibilityChange:u,columnOrder:p,getRowClassName:x,isLoading:h,pageCount:g=1,pageIndex:y=0,onPageChange:f,removeOverflow:b=!1,onRowClick:v,selectedRows:N,onRowSelectionChange:j,headerClassName:_,headerColor:w,cellHeight:k="h-[44px]",showPageSizeSelector:C=!1,pageSize:S=10,onPageSizeChange:E,pageSizeOptions:L,menuPlacement:A="auto",renderExpandedRow:D,isRowExpanded:O}=e,T=(0,s.useMemo)(()=>h?[]:t,[h,t]),I=(0,s.useMemo)(()=>a,[a]),P=(0,r.N4)({data:T,columns:I,state:{columnVisibility:m,columnOrder:p,rowSelection:N,...void 0!==g&&void 0!==y&&void 0!==f&&{pagination:{pageIndex:y,pageSize:S}}},onColumnVisibilityChange:u,getCoreRowModel:(0,n.HT)(),...void 0!==g&&void 0!==y&&void 0!==f&&{getPaginationRowModel:(0,n.kW)(),manualPagination:!0},enableRowSelection:!0,onRowSelectionChange:j,enableColumnResizing:!0}),R=t.length<=10&&10===S&&1===g,M=(0,s.useRef)(5);return(0,s.useEffect)(()=>{!h&&P.getRowCount()>0&&(M.current=P.getRowCount())},[h,P]),(0,l.jsxs)("div",{children:[(0,l.jsx)("div",{className:(0,c.cn)(b?"max-h-96":"overflow-x-auto touch-pan-x [&::-webkit-scrollbar]:h-1 [&::-webkit-scrollbar-track]:bg-gray-100 [&::-webkit-scrollbar-thumb]:bg-gray-400 [&::-webkit-scrollbar-thumb]:rounded-full lg:[&::-webkit-scrollbar]:hidden"),children:(0,l.jsxs)(i.XI,{className:"border-b",children:[(0,l.jsx)(i.A0,{className:(0,c.cn)("sticky top-0 z-10 bg-white shadow-xs",_),children:(0,l.jsx)(i.Hj,{children:P.getHeaderGroups().map(e=>e.headers.map(e=>{var a,t;return(0,l.jsx)(i.nd,{className:(0,c.cn)(w),style:(null==(a=e.column.columnDef.meta)?void 0:a.fixedWidth)?{width:e.getSize(),minWidth:e.getSize(),maxWidth:e.getSize()}:void 0,children:(0,l.jsx)("div",{className:(0,c.cn)("p-2 h-full flex items-center flex-1",null==(t=e.column.columnDef.meta)?void 0:t.className),children:(0,r.Kv)(e.column.columnDef.header,e.getContext())})},e.id)}))})}),(0,l.jsx)(i.BF,{className:"relative",children:h?(0,l.jsxs)(l.Fragment,{children:[[...Array(M.current>10?10:M.current||5)].map((e,t)=>(0,l.jsx)(i.Hj,{children:a.map((e,a)=>(0,l.jsx)(i.nA,{children:(0,l.jsx)("div",{className:"h-5 bg-gray-100 rounded-sm animate-pulse"})},a))},t)),(0,l.jsx)("tr",{className:"absolute inset-0 flex items-center justify-center pointer-events-none",children:(0,l.jsx)("td",{colSpan:a.length,children:(0,l.jsx)(o.A,{className:"h-8 w-8 animate-spin text-brand-dark-cyan"})})})]}):0===P.getRowModel().rows.length?(0,l.jsx)(i.Hj,{children:(0,l.jsx)(i.nA,{colSpan:a.length,className:"text-center py-8",children:"No data"})}):P.getRowModel().rows.map((e,a,t)=>{let n=!!D&&!!(null==O?void 0:O(e));return(0,l.jsxs)(s.Fragment,{children:[(0,l.jsx)(i.Hj,{className:(0,c.cn)(a%2==0?"bg-gray-50":"bg-white",null==x?void 0:x(e),"hover:bg-cyan-100 transition-colors"),onClick:()=>null==v?void 0:v(e),children:e.getVisibleCells().map(e=>{var s,o,d,m,u;return(0,l.jsx)(i.nA,{"data-column-key":null==(s=e.column.columnDef.meta)?void 0:s.columnKey,style:(null==(o=e.column.columnDef.meta)?void 0:o.fixedWidth)?{width:e.column.getSize(),minWidth:e.column.getSize(),maxWidth:e.column.getSize()}:void 0,children:(0,l.jsx)("div",{className:(0,c.cn)("p-2 w-full flex items-center",k,null==(d=e.column.columnDef.meta)?void 0:d.cellClassName,a===t.length-1&&!n&&(null==(m=e.column.columnDef.meta)?void 0:m.borderBottom)&&"border-b border-cyan-300",a===t.length-1&&!n&&(null==(u=e.column.columnDef.meta)?void 0:u.lastCellClassName)),children:(0,r.Kv)(e.column.columnDef.cell,e.getContext())})},e.id)})}),n&&(0,l.jsx)(i.Hj,{className:(0,c.cn)(a%2==0?"bg-gray-50":"bg-white"),children:(0,l.jsx)(i.nA,{colSpan:e.getVisibleCells().length,className:"p-0",children:D(e)})})]},e.id)})})]})}),R?null:(0,l.jsx)(d.x,{pageIndex:y,pageCount:g,onPageChange:null!=f?f:()=>{},isLoading:h,showPageSizeSelector:C,pageSize:S,onPageSizeChange:E,pageSizeOptions:L,menuPlacement:A})]})}},34107:(e,a,t)=>{t.d(a,{n:()=>s});var l=t(12115);function s(e){let{setPage:a}=e,[t,s]=(0,l.useState)(""),[r,n]=(0,l.useState)(""),[i,o]=(0,l.useState)([]),[d,c]=(0,l.useState)([]),[m,u]=(0,l.useState)([]),[p,x]=(0,l.useState)(!1),[h,g]=(0,l.useState)(""),[y,f]=(0,l.useState)([]),[b,v]=(0,l.useState)([]),[N,j]=(0,l.useState)({}),[_,w]=(0,l.useState)({}),[k,C]=(0,l.useState)({}),[S,E]=(0,l.useState)({}),[L,A]=(0,l.useState)(!1),[D,O]=(0,l.useState)([]),[T,I]=(0,l.useState)([]),[P,R]=(0,l.useState)([]);return{inputValue:t,setInputValue:s,debouncedValue:r,setDebouncedValue:n,handleClearSearch:()=>{s(""),n(""),a(0)},roles:i,setRoles:o,selectedRole:d,setSelectedRole:c,tempSelectedRole:m,setTempSelectedRole:u,isRolePopoverOpen:p,setIsRolePopoverOpen:x,handleRoleReset:()=>{u([]),c([]),a(0),x(!1)},handleRoleApply:()=>{c(m),a(0),x(!1)},organizationSearch:h,setOrganizationSearch:g,selectedOrganizations:y,setSelectedOrganizations:f,tempSelectedOrganizations:b,setTempSelectedOrganizations:v,selectedProperties:N,setSelectedProperties:j,tempSelectedProperties:_,setTempSelectedProperties:w,organizationProperties:k,setOrganizationProperties:C,loadingProperties:S,setLoadingProperties:E,isPopoverOpen:L,setIsPopoverOpen:A,handleOrgReset:()=>
1{v([]),w({}),f([]),j({}),a(0),A(!1)},handleOrgApply:()=>{f(b),j(_),A(!1)},orgProperties:D,setOrgProperties:O,selectedOrgProperties:T,setSelectedOrgProperties:I,tempSelectedOrgProperties:P,setTempSelectedOrgProperties:R,handleOrgPropReset:()=>{R([]),I([]),a(0),A(!1)},handleOrgPropApply:()=>{I(P),A(!1)}}}},35072:(e,a,t)=>{t.d(a,{Ss:()=>r,q_:()=>s});let l=["on_track","opportunities","critical","zero_usage"],s=e=>{switch(e){case"on_track":return"On Track";case"opportunities":return"Opportunities";case"critical":return"Critical";case"zero_usage":return"Zero Usage";default:var a;return null==e||null==(a=e.replace(/_/g," "))?void 0:a.replace(/\b\w/g,e=>e.toUpperCase())}},r=e=>n(e).map(e=>({value:e,label:s(e)})),n=e=>[...e].sort((e,a)=>{let t=l.indexOf(e),s=l.indexOf(a);return -1!==t&&-1!==s?t-s:-1!==t?-1:-1!==s?1:e.localeCompare(a)})},37193:(e,a,t)=>{t.d(a,{js:()=>s,DL:()=>n,Iu:()=>i,QU:()=>o.Q,f8:()=>d,Up:()=>c.U,lZ:()=>m.l});var l=t(15056);let s={getDeviceHealthOverview:e=>(0,l.Vg)("/v2/reporting/device-health/overview",e),getDeviceHealthCriticalAlertsOverview:e=>(0,l.Vg)("/v2/reporting/device-health/critical-alerts/overview",e),getDeviceHealthCriticalAlertsGatewaysRouters:e=>(0,l.Vg)("/v1/reporting/device-health/critical-alerts/gateways-routers",e),getDeviceHealthCriticalAlertsMeters:e=>(0,l.Vg)("/v1/reporting/device-health/critical-alerts/meters",e),getDeviceHealthCriticalAlertsNoConsumption:e=>(0,l.Vg)("/v1/reporting/device-health/critical-alerts/no-consumption",e),getDeviceHealthPortfolioDetailProperties:e=>(0,l.Vg)("/v2/reporting/device-health/portfolio-detail/properties",e),getDeviceHealthPortfolioDetailPropertiesMeters:(e,a)=>(0,l.Vg)("/v1/reporting/device-health/portfolio-detail/properties/".concat(e,"/meters"),a),getDeviceHealthPortfolioInsightsOverview:e=>(0,l.Vg)("/v2/reporting/device-health/portfolio-insights/overview",e),getDeviceHealthPortfolioInsightsPropertiesMeters:(e,a)=>(0,l.Vg)("/v1/reporting/device-health/portfolio-insights/properties/".concat(e,"/meters"),a)};function r(e){let a=Number(null==e?void 0:e[0]);return Number.isFinite(a)?a:void 0}let n={getRollup:e=>(0,l.Vg)("/v2/municipal/rollup",e),getPropertyRows(e){let{page:a,page_size:t,ordering:s,...n}=e,i=r(a),o=r(t),d={...n,...void 0!==i?{page:i}:{},...void 0!==o?{page_size:o}:{},...(null==s?void 0:s[0])?{ordering:s[0]}:{}};return(0,l.Vg)("/v2/municipal/properties",d)},getMonthly:(e,a)=>(0,l.Vg)("/v2/municipal/properties/".concat(e,"/monthly"),a),getYearly:(e,a)=>(0,l.Vg)("/v2/municipal/properties/".concat(e,"/yearly"),a),getBills:(e,a)=>(0,l.Vg)("/v2/municipal/properties/".concat(e,"/bills"),a),getDaily:(e,a)=>(0,l.Vg)("/v2/municipal/properties/".concat(e,"/daily"),a),getMeterHealth:(e,a)=>(0,l.Vg)("/v2/municipal/properties/".concat(e,"/meter-health"),a),getReadDates:(e,a)=>(0,l.Vg)("/v2/municipal/properties/".concat(e,"/read-dates"),a),getPrePost(e){let{organization_id:a,property_id:t,...s}=e,r={...s,organization_id:[String(a)],...(null==t?void 0:t.length)?{property_id:t.map(String)}:{}};return(0,l.Vg)("/v2/municipal/pre-post",r)}},i={getStaffOrganizations:e=>(0,l.Vg)("/v1/admin/staff/inventory/organizations",e)};var o=t(7431);let d={getWaterUsageOverview:e=>(0,l.Vg)("/v1/prevention/water-usage/overview",e),getTotalConsumption:e=>(0,l.Vg)("/v1/prevention/total-consumption",e),getWaterSavingOverview:e=>(0,l.Vg)("/v1/prevention/water-saving/overview",e),getCostSavingOverview:e=>(0,l.Vg)("/v1/prevention/cost-saving/overview",e),getSavingRanking:e=>(0,l.Vg)("/v1/prevention/saving/ranking",e)};var c=t(42964),m=t(26493);t(38731)},38126:(e,a,t)=>{t.d(a,{Toaster:()=>n});var l=t(95155),s=t(1275),r=t(91463);function n(){let{toasts:e}=(0,r.dj)();return(0,l.jsxs)(s.tE,{children:[e.map(function(e){let{id:a,title:t,description:r,action:n,...i}=e;return(0,l.jsxs)(s.y8,{...i,children:[(0,l.jsxs)("div",{className:"grid gap-1",children:[t&&(0,l.jsx)(s.Sb,{children:t}),r&&(0,l.jsx)(s.aD,{children:r})]}),n,(0,l.jsx)(s.eC,{})]},a)}),(0,l.jsx)(s.US,{})]})}},38731:(e,a,t)=>{t.d(a,{d:()=>s});var l=t(15056);let s={getStaffUsers:e=>(0,l.Vg)("/v1/admin/staff/organizations/users",e),createStaffUser:e=>(0,l.$P)("/v1/admin/staff/organizations/users/staff",e),updateStaffUser:(e,a)=>(0,l.$Y)("/v1/admin/staff/organizations/users/staff/".concat(e),a),deleteStaffUser:e=>(0,l.Al)("/v1/admin/staff/organizations/users/staff/".concat(e)),createStaffExternalUser:e=>(0,l.$P)("/v1/admin/staff/organizations/users/external",e),updateStaffExternalUser:(e,a)=>(0,l.$Y)("/v1/admin/staff/organizations/users/external/".concat(e),a),deleteStaffExternalUser:e=>(0,l.Al)("/v1/admin/staff/organizations/users/external/".concat(e)),getOrganizationUsers:(e,a)=>(0,l.Vg)("/v1/admin/external/organizations/".concat(e,"/users"),a),createOrganizationUser:(e,a)=>(0,l.$P)("/v1/admin/external/organizations/".concat(e,"/users"),a),updateOrganizationUser:(e,a,t)=>(0,l.$Y)("/v1/admin/external/organizations/".concat(e,"/users/").concat(a),t),deleteOrganizationUser:(e,a)=>(0,l.Al)("/v1/admin/external/organizations/".concat(e,"/users/").concat(a))}},39735:(e,a,t)=>{t.d(a,{k:()=>p,x:()=>u});
1var l=t(95155),s=t(32897),r=t(12108),n=t(24033),i=t(27937),o=t(77888),d=t(3998),c=t(20063),m=t(35072);let u=(e,a,t,s)=>[{id:"property_name",accessorKey:"property_name",header:"Property",cell:e=>{let{row:a}=e;return(0,l.jsx)("div",{onClick:()=>s.push("/properties/".concat(a.original.property_id)),className:"w-44 2xl:w-auto truncate cursor-pointer hover:text-brand-dark-cyan hover:underline",children:a.original.property_name})},meta:{name:"Property"}},{id:"state",accessorKey:"state",header:"State"},{id:"performance",accessorKey:"performance",header:"Performance",cell:e=>{let{row:a}=e;return(0,l.jsx)("span",{children:(0,m.q_)(a.original.performance)})},meta:{name:"Performance"}},{id:"units",accessorKey:"units",header:()=>{let e=t("units","Units");return(0,l.jsxs)("div",{className:e.className,onClick:e.onClick,children:[(0,l.jsx)("span",{className:"text-right",children:e.label}),(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(r.A,{className:e.upIconClassName}),(0,l.jsx)(n.A,{className:e.downIconClassName})]})]})},cell:e=>{let{row:a}=e;return(0,l.jsx)("div",{className:"flex justify-end w-full",children:(0,l.jsx)("span",{className:"text-right pr-6",children:a.original.units.toLocaleString()})})},meta:{name:"Units"}},{id:"units_with_leakage",accessorKey:"units_with_leakage",header:()=>{let e=t("units_with_leakage","Units with leak");return(0,l.jsxs)("div",{className:e.className,onClick:e.onClick,children:[(0,l.jsx)("span",{className:"text-right min-w-22",children:e.label}),(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(r.A,{className:e.upIconClassName}),(0,l.jsx)(n.A,{className:e.downIconClassName})]})]})},cell:e=>{let{row:a}=e;return(0,l.jsx)("div",{className:"flex justify-end w-full",children:(0,l.jsx)("span",{className:"text-right pr-6",children:a.original.units_with_leakage.toLocaleString()})})},meta:{name:"Units with leak"}},{id:"bedrooms",accessorKey:"bedrooms",header:()=>{let e=t("bedrooms","Bedrooms");return(0,l.jsxs)("div",{className:e.className,onClick:e.onClick,children:[(0,l.jsx)("span",{className:"text-right",children:e.label}),(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(r.A,{className:e.upIconClassName}),(0,l.jsx)(n.A,{className:e.downIconClassName})]})]})},cell:e=>{let{row:a}=e;return(0,l.jsx)("div",{className:"flex justify-end w-full",children:(0,l.jsx)("span",{className:"text-right pr-6",children:a.original.bedrooms.toLocaleString()})})},meta:{name:"Bedrooms"}},{id:"days_read",accessorKey:"days_read",header:()=>{let e=t("days_read","Days Read");return(0,l.jsxs)("div",{className:e.className,onClick:e.onClick,children:[(0,l.jsx)("span",{className:"text-right",children:e.label}),(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(r.A,{className:e.upIconClassName}),(0,l.jsx)(n.A,{className:e.downIconClassName})]})]})},cell:e=>{let{row:a}=e;return(0,l.jsx)("div",{className:"flex justify-end w-full",children:(0,l.jsx)("span",{className:"text-right pr-6",children:a.original.days_read.toLocaleString()})})},meta:{name:"Days Read"}},{id:"gallons_consumed",accessorKey:"gallons_consumed",header:()=>{let e=t("gallons_consumed","Gallons");return(0,l.jsxs)("div",{className:e.className,onClick:e.onClick,children:[(0,l.jsx)("span",{className:"text-right",children:e.label}),(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(r.A,{className:e.upIconClassName}),(0,l.jsx)(n.A,{className:e.downIconClassName})]})]})},cell:e=>{let{row:a}=e;return(0,l.jsx)("div",{className:"flex justify-end w-full",children:(0,l.jsx)("span",{className:"text-right pr-6",children:a.original.gallons_consumed.toLocaleString()})})},meta:{name:"Gallons"}},{id:"leak_percentage",accessorKey:"leak_percentage",header:()=>{let e=t("leak_percentage","Leak Volume %");return(0,l.jsxs)("div",{className:e.className,onClick:e.onClick,children:[(0,l.jsx)("span",{className:"text-right min-w-22",children:e.label}),(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(r.A,{className:e.upIconClassName}),(0,l.jsx)(n.A,{className:e.downIconClassName})]})]})},cell:e=>{let{row:a}=e;return(0,l.jsx)("div",{className:"flex justify-end w-full",children:(0,l.jsxs)("span",{className:"text-right pr-6",children:[a.original.leak_percentage.toLocaleStr
1ing(),"%"]})})},meta:{name:"Leak Volume %"}},{id:"gallons_leaked",accessorKey:"gallons_leaked",header:()=>{let e=t("gallons_leaked","Leak Gallons");return(0,l.jsxs)("div",{className:e.className,onClick:e.onClick,children:[(0,l.jsx)("span",{className:"text-right",children:e.label}),(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(r.A,{className:e.upIconClassName}),(0,l.jsx)(n.A,{className:e.downIconClassName})]})]})},cell:e=>{let{row:a}=e;return(0,l.jsx)("div",{className:"flex justify-end w-full",children:(0,l.jsx)("span",{className:"text-right pr-6",children:a.original.gallons_leaked.toLocaleString()})})},meta:{name:"Leak Gallons"}},{id:"actions",cell:e=>{let{row:a}=e;return(0,l.jsx)("div",{className:"flex justify-end w-full",children:(0,l.jsx)(d.$,{variant:"secondary",size:"sm",className:"py-1 px-2 border-gray-400 w-24 h-7 text-brand-dark-gray hover:text-brand-dark-cyan hover:border-brand-dark-cyan",onClick:()=>{s.push("/properties/".concat(a.original.property_id))},children:(0,l.jsxs)("div",{className:"flex items-center gap-0.5",children:["Details",(0,l.jsx)(i.A,{className:"w-4 h-4"})]})})})}}];function p(e){let{data:a,columnVisibility:t,columnOrder:r,onColumnVisibilityChange:n,isLoading:i,totalCount:d=0,onPageChange:m,currentPage:p=0,params:x,onSort:h,pageSize:g,onPageSizeChange:y}=e,f=(0,c.useRouter)(),b=Math.ceil(d/(g||10)),v=b>1,{getSortableHeaderProps:N}=(0,o.M)({params:x,onSort:h,isLoading:i,data:a}),j=u(i||!1,a,N,f);return(0,l.jsx)(s.b,{columns:j,data:a,columnVisibility:t,onColumnVisibilityChange:n,columnOrder:r,getRowClassName:()=>"cursor-pointer",isLoading:i,pageCount:v?b:void 0,pageIndex:v?p:void 0,onPageChange:v?m:void 0,onRowClick:e=>{f.push("/properties/".concat(e.original.property_id,"?organization_id=").concat(e.original.organization_id))},showPageSizeSelector:!0,pageSize:g,onPageSizeChange:y})}},40170:(e,a,t)=>{t.d(a,{aI:()=>c,qt:()=>i,sl:()=>m,yw:()=>o});var l=t(73730),s=t(26467),r=t(58352),n=t(34334);function i(e,a){switch(e){case"custom-date-range":return(null==a?void 0:a.from)&&(null==a?void 0:a.to)?"".concat((0,l.GP)(a.from,"d MMM, y")," - ").concat((0,l.GP)(a.to,"d MMM, y")):"Custom Date Range";case"yesterday":default:return"Yesterday";case"last-7-days":return"Last 7 Days";case"last-30-days":return"Last 30 Days"}}function o(e){switch(e){case"yesterday":return"Previous Day (N-2)";case"last-7-days":return"Previous 7 days (days 8-14)";case"last-30-days":return"Previous 30 days (days 31-60)"}}function d(e){try{let a=(0,s.H)(e);return(0,r.m)(a,{addSuffix:!0})}catch(e){return console.error("Error formatting date:",e),"Unknown"}}function c(e){return{gallonsDailyUpdate:e.last_update_gallons_daily?d(e.last_update_gallons_daily):"Never",deviceHealthUpdate:e.last_update_device_health?d(e.last_update_device_health):"Never"}}function m(e,a){if(/^[A-Za-z]{3}\s\d{2},\s\d{4}$/.test(e)){let a=(0,n.qg)(e,"MMM dd, yyyy",new Date);return(0,l.GP)(a,"yyyy-MM-dd")}if(/^\d{4}-\d{2}-\d{2}$/.test(e))return e;let t=e.split(" - ")[0],s=new Date().getFullYear();a&&(s=(0,n.qg)(a,"yyyy-MM-dd",new Date).getFullYear());let[r,i]=t.split("/"),o=new Date(s,parseInt(r)-1,parseInt(i));return(0,l.GP)(o,"yyyy-MM-dd")}},40987:(e,a,t)=>{t.d(a,{h:()=>c});
1var l=t(95155),s=t(39347),r=t(23327),n=t(35299),i=t(68695),o=t(94954),d=t(27331);function c(e){let{icon:a,iconBgColor:t,iconColor:c,title:m,value:u,isLoading:p,showLeakIndicator:x=!1,leakPercentage:h,valueFormatter:g=e=>e.toLocaleString(),borderColor:y="border-brand-stroke",subTitle:f,comparisonValue:b,canBeFavorited:v=!1,onFavorite:N,isFavorite:j=!1,hasWaterUsageEfficiencyInNonFavorites:_=!1,stackedAtXl:w=!1,titleWrap:k=!1,subValue:C,titleTooltip:S,targetValue:E}=e;return(0,l.jsxs)("div",{className:"relative flex flex-1 bg-white rounded-xl border px-5 ".concat(y," ").concat(j?"flex-col items-center py-6 gap-4":"flex-row py-4 gap-2"," ").concat(_?"!flex-col items-start justify-between":"items-center justify-between"),children:[(v||j)&&(0,l.jsx)("div",{className:"absolute ".concat(j?"top-4 left-3":"top-1 left-1 cursor-pointer"),onClick:N,children:(0,l.jsx)(s.A,{className:"".concat(j?"w-9 h-9 text-orange-300":"w-4 h-4"," text-brand-gray"),fill:j?"#FCCF85":"none",fillOpacity:.5*!!j,strokeWidth:1.5})}),j&&(0,l.jsx)("div",{className:"absolute top-6 left-14",children:(0,l.jsxs)(d.m_,{children:[(0,l.jsx)(d.k$,{children:(0,l.jsx)(r.A,{className:"w-5 h-5 text-brand-dark-gray"})}),(0,l.jsx)(d.ZI,{align:"end",children:(0,l.jsx)("p",{className:"text-xs font-regular text-brand-white",children:"This stat is your favorite."})})]})}),(0,l.jsxs)("div",{className:"flex items-center gap-3 min-w-0",children:[(0,l.jsx)("div",{className:"flex items-center justify-center shrink-0 w-10 h-10 rounded-md ".concat(t),children:(0,l.jsx)(a,{className:"w-6 h-6 ".concat(c)})}),(0,l.jsxs)("div",{className:"flex flex-col min-w-0",children:[(0,l.jsxs)("div",{className:"flex items-center gap-1",children:[(0,l.jsx)("p",{className:"".concat(j?"text-lg":"text-base"," font-semibold ").concat(k?"whitespace-normal":"whitespace-nowrap"," truncate"),children:m}),S&&(0,l.jsxs)(d.m_,{children:[(0,l.jsx)(d.k$,{children:(0,l.jsx)(r.A,{className:"w-4 h-4 text-brand-dark-gray"})}),(0,l.jsx)(d.ZI,{align:"center",side:"bottom",children:S})]})]}),f&&(0,l.jsx)("p",{className:"text-sm text-brand-dark-gray",children:f}),E&&(0,l.jsx)(l.Fragment,{children:p?(0,l.jsx)(n.A,{className:"h-3 w-3 animate-spin text-brand-dark-gray"}):(0,l.jsxs)("p",{className:"text-xs font-medium text-brand-dark-gray",children:["Target: ",E]})}),w&&!j&&!_&&(p?(0,l.jsx)(n.A,{className:"hidden xl:block 2xl:hidden mt-1 h-5 w-5 animate-spin text-brand-dark-cyan"}):(0,l.jsx)("p",{className:"hidden xl:block 2xl:hidden mt-1 text-2xl font-bold whitespace-nowrap",children:"number"==typeof u?g(u):u}))]})]}),p?(0,l.jsx)(n.A,{className:"h-6 w-6 animate-spin text-brand-dark-cyan ".concat(!w||j||_?"":"xl:hidden 2xl:block")}):(0,l.jsxs)("div",{className:"flex ".concat(j||_?"flex-row items-center gap-3 pb-3 justify-center w-full":"flex-col items-end shrink-0"," ").concat(!w||j||_?"":"xl:hidden 2xl:flex"),children:[(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("p",{className:"text-xl font-bold whitespace-nowrap",children:"number"==typeof u?g(u):u}),x&&void 0!==h&&(0,l.jsx)(d.V7,{percentage:h,size:"sm"})]}),C&&(0,l.jsx)("p",{className:"text-xs font-medium text-brand-dark-gray",children:C}),void 0!==b&&0!==b&&(0,l.jsxs)("div",{className:"flex items-center gap-2 ".concat(b>0?"text-red-700":"text-green-700"),children:[b>0?(0,l.jsx)(i.A,{className:"w-4 h-4"}):(0,l.jsx)(o.A,{className:"w-4 h-4"}),(0,l.jsxs)("p",{className:"text-base",children:[b>0?"+":"-",Math.abs(b),x?"pp":"%"]})]})]})]})}},41860:(e,a,t)=>{t.d(a,{Cc:()=>s,PS:()=>r,WU:()=>n});let l={"toilet leak":"Toilet Leak","other leak":"Other Leak","water heater":"Water Heater Leak","other leak-toilet leak":"Hybrid Leak","toilet leak-water heater":"Hybrid Leak","other leak-water heater":"Hybrid Leak","other leak-toilet leak-water heater":"Hybrid Leak"};function s(e){return!!e&&e in l}function r(e){var a;return null!=(a=l[e])?a:""}function n(e){return r(e).replace(" Leak","")}},42058:(e,a,t)=>{t.d(a,{I:()=>r,d:()=>n});var l=t(73730),s=t(92381);function r(e){let a=!(arguments.length>1)||void 0===arguments[1]||arguments[1];if(0===e)return"0";let t=Math.abs(e),l=e<0?"-":"",s=a?"$":"";return t>=1e9?"".concat(l).concat(s).concat(t/1e9,"B"):t>=1e6?"".concat(l).concat(s).concat(t/1e6,"M"):t>=1e3?"".concat(l).concat(s).concat(t/1e3,"K"):a?"".concat(l,"$").concat(t.toLocaleStr
1ing()):"".concat(l).concat(t.toLocaleString())}function n(e,a,t){let r;if(!e)return"";let[n,i,o]=e.split("-").map(Number),d=new Date(n,i-1,o);switch(a){case"day":return t?(0,l.GP)(d,"MM/dd/yyyy"):(0,l.GP)(d,"MM/dd");case"week":return r=(0,s.f)(d,6),t?"".concat((0,l.GP)(d,"MM/dd/yyyy")," - ").concat((0,l.GP)(r,"MM/dd/yyyy")):"".concat((0,l.GP)(d,"MM/dd")," - ").concat((0,l.GP)(r,"MM/dd"));case"month":return(0,l.GP)(d,"MMM yyyy");default:return e}}},42292:(e,a,t)=>{t.d(a,{R:()=>d});var l=t(95155),s=t(588),r=t(45953),n=t(24033),i=t(5917),o=t(64269);function d(e){let{error:a,description:t,height:d="h-9",...c}=e;return(0,l.jsxs)("div",{className:"w-full",children:[(0,l.jsx)(s.Ay,{...c,unstyled:!0,maxMenuHeight:160,menuPlacement:"auto",components:{DropdownIndicator:e=>{let{selectProps:{menuIsOpen:a}}=e;return(0,l.jsx)(n.A,{className:(0,o.cn)("h-4 w-4 text-brand-dark-gray transition-transform duration-200",a&&"rotate-180")})},Option:e=>{let{children:a,isSelected:t,...s}=e;return(0,l.jsx)(r.c.Option,{...s,isSelected:t,children:(0,l.jsxs)("div",{className:"flex items-center justify-between w-full",children:[a,t&&(0,l.jsx)(i.A,{className:"h-4 w-4 text-brand-dark-cyan shrink-0"})]})})},...c.components},classNames:{control:e=>(0,o.cn)("flex w-full items-center justify-between whitespace-nowrap rounded-md border border-brand-stroke bg-transparent px-3 py-2 text-sm shadow-xs ring-offset-background focus:outline-hidden focus:border-brand-dark-cyan disabled:cursor-not-allowed disabled:opacity-50 hover:border-brand-dark-cyan",a&&"border-brand-red focus:border-brand-red",e.isFocused&&"border-brand-dark-cyan",d),placeholder:()=>"text-brand-dark-gray",singleValue:()=>"text-brand-black",menu:()=>"text-sm bg-white border border-[rgba(15,23,42,0.10)] rounded-md shadow-custom-select-dropdown mt-1 p-1",option:e=>(0,o.cn)("text-sm px-2 py-1.5 cursor-pointer",e.isFocused&&"bg-cyan-50"),indicatorsContainer:()=>"shrink-0"}}),a?(0,l.jsx)("p",{className:"text-sm text-brand-red mt-1.5",children:a}):t?(0,l.jsx)("p",{className:"text-sm text-brand-dark-gray mt-1.5",children:t}):null]})}},42964:(e,a,t)=>{t.d(a,{U:()=>s});var l=t(15056);let s={getStaffProperties:e=>(0,l.Vg)("/v1/admin/staff/inventory/organizations/properties",e),getStaffUnassignedProperties:e=>(0,l.Vg)("/v1/admin/staff/inventory/organizations/properties/unassigned",e),bulkAssignProperties:e=>(0,l.$P)("/v1/admin/staff/inventory/organizations/properties/bulk-assign",e),getOrganizationProperties:(e,a)=>(0,l.Vg)("/v1/admin/external/inventory/organizations/".concat(e,"/properties"),a,{headers:{"X-CURRENT-ORGANIZATION-ID":e}})}},43482:(e,a,t)=>{t.d(a,{y:()=>y});var l=t(95155),s=t(12115),r=t(26265),n=t(75271),i=t(33420),o=t(37665),d=t(68425),c=t(47734),m=t(73697),u=t(35120),p=t(64269),x=t(42058);let h=e=>{let{payload:a,activeItem:t,onHover:s}=e;return a?(0,l.jsx)("div",{className:"flex items-center gap-6 overflow-x-auto [&::-webkit-scrollbar]:hidden",children:a.map(e=>{let a=e.dataKey||e.value.toLowerCase().replace(/ /g,"");return(0,l.jsxs)("div",{className:"flex items-center gap-3 cursor-pointer transition-opacity duration-200",style:{opacity:t?t===a?1:.3:1},onMouseEnter:()=>s(a),onMouseLeave:()=>s(null),children:[(0,l.jsx)("span",{className:"inline-block w-3 h-3 rounded-sm",style:{backgroundColor:e.color}}),(0,l.jsx)("span",{className:"text-base font-medium text-brand-black text-nowrap text-ellipsis",children:e.value})]},e.value)})}):null},g=e=>{var a,t;let{active:s,payload:r,label:n,comparisonDisplay:i,granularity:o}=e;if(!s||!r||0===r.length)return null;let d=n?(0,x.d)(n,o,!0):"",c=null==(t=r[0])||null==(a=t.payload)?void 0:a.percentage_difference;return(0,l.jsxs)("div",{className:"bg-white border border-brand-stroke rounded-sm p-3 shadow-sm",children:[(0,l.jsx)("div",{className:"font-semibold mb-2",children:d}),(0,l.jsx)("div",{className:(0,p.cn)("flex flex-col gap-2",i?"border-b border-brand-stroke pb-2 mb-2":""),children:r.map((e,a)=>(0,l.jsxs)("div",{className:(0,p.cn)("flex items-center","percent_of_leaks"===e.dataKey?"gap-2":"gap-4"),children:[(0,l.jsx)("span",{className:"inline-block w-3 h-3 rounded-sm",style:{backgroundColor:e.color}}),(0,l.jsxs)("span",{className:"text-sm font-medium",children:[e.name,": $",e.value.toLocaleStr
1ing()]})]},a))}),i&&(0,l.jsxs)("div",{className:"flex items-center gap-2 text-sm text-brand-dark-gray",children:[(0,l.jsx)("span",{children:"Delta %:"}),(0,l.jsxs)("span",{className:(0,p.cn)("font-medium",c&&c>0?"text-brand-red":"text-green-600"),children:[Math.abs(c||0),"%"," ",c&&c>0?"increase":"decrease"]})]})]})};function y(e){let{data:a,className:t,height:y=250,granularity:f,activeTimePeriod:b,comparisonDisplay:v}=e,[N,j]=(0,s.useState)(null),_=e=>{j(e)},w=e=>N?N===e?1:.3:1;return(0,l.jsx)("div",{style:{height:y},className:(0,p.cn)("w-full",t),children:(0,l.jsx)(r.u,{width:"99%",height:y,debounce:1,children:(0,l.jsxs)(n.X,{data:a,margin:{top:20,right:30,left:20,bottom:5},barCategoryGap:8,children:[(0,l.jsx)(i.m,{contentStyle:{backgroundColor:"white",border:"1px solid #CBD4E3"},content:(0,l.jsx)(g,{comparisonDisplay:v,granularity:f})}),(0,l.jsx)(o.s,{content:(0,l.jsx)(h,{activeItem:N,onHover:_}),wrapperStyle:{position:"absolute",top:0,left:0,display:"flex"},verticalAlign:"top"}),(0,l.jsx)(d.d,{yAxisId:"left",strokeDasharray:"0 0",vertical:!1,stroke:"#CBD4E3"}),(0,l.jsx)(c.W,{dataKey:"date",axisLine:!1,tickLine:!1,tick:{fill:"#666666"},tickFormatter:e=>(0,x.d)(e,f)}),(0,l.jsx)(m.h,{yAxisId:"left",axisLine:!1,tickLine:!1,tick:{fill:"#666666"},tickFormatter:e=>(0,x.I)(e,!0)}),v&&(0,l.jsx)(u.yP,{yAxisId:"left",dataKey:"previous_period_cost",fill:"#A1CEBC",name:v,opacity:w("previous_period_cost"),onMouseEnter:()=>_("previous_period_cost"),onMouseLeave:()=>_(null),radius:[2,2,2,2]}),(0,l.jsx)(u.yP,{yAxisId:"left",dataKey:"leak_related_cost",fill:"#6341DD",name:b,opacity:w("leak_related_cost"),onMouseEnter:()=>_("leak_related_cost"),onMouseLeave:()=>_(null),radius:[2,2,2,2]})]})})})}},46767:(e,a,t)=>{t.d(a,{TooltipProvider:()=>i,ZI:()=>c,k$:()=>d,m_:()=>o});var l=t(95155),s=t(12115),r=t(26852),n=t(64269);let i=r.Kq,o=r.bL,d=r.l9,c=s.forwardRef((e,a)=>{let{className:t,sideOffset:s=4,...i}=e;return(0,l.jsx)(r.ZL,{children:(0,l.jsx)(r.UC,{ref:a,sideOffset:s,className:(0,n.cn)("z-50 overflow-hidden rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...i})})});c.displayName=r.UC.displayName},51834:(e,a,t)=>{t.d(a,{Cf:()=>c,HM:()=>x,L3:()=>u,c7:()=>m,lG:()=>i,rr:()=>p});var l=t(95155),s=t(12115),r=t(93409),n=t(64269);let i=r.bL;r.l9;let o=r.ZL,d=s.forwardRef((e,a)=>{let{className:t,...s}=e;return(0,l.jsx)(r.hJ,{ref:a,className:(0,n.cn)("fixed inset-0 z-50 bg-black/50 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...s})});d.displayName=r.hJ.displayName;let c=s.forwardRef((e,a)=>{let{className:t,children:s,...i}=e;return(0,l.jsxs)(o,{children:[(0,l.jsx)(d,{}),(0,l.jsx)(r.UC,{ref:a,className:(0,n.cn)("fixed left-[50%] top-[50%] z-50 grid w-full translate-x-[-50%] translate-y-[-50%] gap-4 border border-brand-stroke bg-white p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] rounded-xl",t),...i,children:s})]})});c.displayName=r.UC.displayName;let m=e=>{let{className:a,...t}=e;return(0,l.jsx)("div",{className:(0,n.cn)("flex flex-col space-y-1.5 text-center sm:text-left",a),...t})};m.displayName="DialogHeader";let u=s.forwardRef((e,a)=>{let{className:t,...s}=e;return(0,l.jsx)(r.hE,{ref:a,className:(0,n.cn)("text-lg font-semibold leading-none tracking-tight",t),...s})});u.displayName=r.hE.displayName;let p=s.forwardRef((e,a)=>{let{className:t,...s}=e;return(0,l.jsx)(r.VY,{ref:a,className:(0,n.cn)("text-sm text-muted-foreground",t),...s})});p.displayName=r.VY.displayName;let x=r.bm},52956:(e,a,t)=>{t.d(a,{CJ:()=>d,CR:()=>l,Ew:()=>n,MB:()=>i,RO:()=>c,Zx:()=>r,tf:()=>s,uG:()=>o});let l=["leak_type","property_name","gallons_consumed","gallons_leaked","flow_time","events_sum","leak_days","total_gallons_leaked"],s=["property_name","building_name","unit_name","bedroom_count","attached_to","period","gallons_consumed","events","gallons_leaked","toilet_leaks","other_leaks","leak_volume_percentage"],r=["property_name","building_name","unit_name","bedroom_count","attached_to","meter_serial_number","period","gallons_consumed","events","gallons_leaked","toilet_leaks","other_leaks","leak_volume_percentage"],n=["property_name","building_name","unit_name","bedroom_count","attached_to","date","gallons_consumed","events","hour","flow_time","leak_details"],i=["property_name","building_name","unit_name","bedroom_count","attached_to","meter_serial_number","date","gallons_consumed","events","hour","flow_time","leak_details"],o=["property_name","building_count","bedroom_count","meter_serial_number","period","gallons_consumed","gbd"],d=["property_name","building_count","meter_serial_number","period","hour","gallons_consumed"],c=["property_name","building_name","meter_serial_number","period","hour","gallons_consumed"]},55699:(e,a,t)=>{t.d(a,{D:()=>y,G:()=>g});
1var l=t(95155),s=t(32897),r=t(12108),n=t(24033),i=t(35299),o=t(7125),d=t(6191),c=t(77888),m=t(3998),u=t(12115),p=t(26493),x=t(64269),h=t(58873);function g(e,a,t,s,c,u,p,h,g,y,f){return[{id:"property_name",accessorKey:"property_name",header:()=>{let e=a("property_name","Property","start");return(0,l.jsxs)("div",{className:(0,x.cn)(e.className,"min-w-24"),onClick:e.onClick,children:[(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(r.A,{className:e.upIconClassName}),(0,l.jsx)(n.A,{className:e.downIconClassName})]}),(0,l.jsx)("span",{children:e.label})]})},cell:e=>{let{row:a}=e;if("isProperty"in a.original&&a.original.isProperty||"isMeter"in a.original&&a.original.isMeter)return(0,l.jsx)("div",{className:"flex items-center w-full h-full min-w-28",children:a.original.property_name});if("isLoadMoreMeters"in a.original&&a.original.isLoadMoreMeters){var t;let e=a.original.parent_property_id,s=null==u?void 0:u[e],r=null==h?void 0:h[e],n=(null==p||null==(t=p[e])?void 0:t.length)||0;return(0,l.jsx)("div",{className:"flex items-center justify-center py-2 w-full h-full absolute top-0 left-0",style:{width:"".concat(y,"px")},children:(0,l.jsxs)(m.$,{variant:"secondary",size:"sm",className:"flex items-center gap-2",disabled:r,onClick:a=>{a.stopPropagation(),null==g||g(e)},children:[r&&(0,l.jsx)(i.A,{className:"w-4 h-4 animate-spin"}),"Load More (",n," of ",(null==s?void 0:s.total)||0,")"]})})}return"isEmptyMeters"in a.original&&a.original.isEmptyMeters?(0,l.jsx)("div",{className:"flex items-center justify-center py-2 w-full h-full absolute top-0 left-0",style:{width:"".concat(y,"px")},children:(0,l.jsx)("span",{className:"text-brand-dark-gray text-center",children:"No meters found for this property"})}):null},meta:{name:"Property",cellClassName:"relative"}},{id:"building_count",accessorKey:"building_count",header:()=>(0,l.jsx)("span",{className:"min-w-32",children:"Building"}),cell:e=>{let{row:a}=e;return"isProperty"in a.original&&a.original.isProperty||"isMeter"in a.original&&a.original.isMeter?(0,l.jsx)("div",{className:"flex items-center w-full h-full min-w-28",children:a.original.building_count}):null},meta:{name:"Building"}},{id:"meter_serial_number",accessorKey:"meter_serial_number",header:()=>(0,l.jsx)("span",{className:"min-w-44",children:"Device Serial Number"}),cell:e=>{let{row:a}=e;if("isLoadMoreMeters"in a.original&&a.original.isLoadMoreMeters||"isEmptyMeters"in a.original&&a.original.isEmptyMeters)return null;if("isProperty"in a.original&&a.original.isProperty)return(0,l.jsx)("span",{className:"text-gray-400",children:"-"});if("isMeter"in a.original&&a.original.isMeter){let e=a.original;return(0,l.jsx)("span",{className:"flex items-center w-full h-full cursor-pointer hover:underline hover:text-brand-dark-cyan transition-colors",onClick:()=>null==f?void 0:f(e.meter_serial_number),children:e.meter_serial_number})}return null},meta:{name:"Device Serial Number"}},{id:"period",accessorKey:"period",header:()=>{let e=a("period","Period","start");return(0,l.jsxs)("div",{className:(0,x.cn)(e.className,"min-w-24"),onClick:e.onClick,children:[(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(r.A,{className:e.upIconClassName}),(0,l.jsx)(n.A,{className:e.downIconClassName})]}),(0,l.jsx)("span",{children:e.label})]})},cell:e=>{let{row:a}=e;return"isLoadMoreMeters"in a.original&&a.original.isLoadMoreMeters||"isEmptyMeters"in a.original&&a.original.isEmptyMeters?null:"isProperty"in a.original&&a.original.isProperty||"isMeter"in a.original&&a.original.isMeter?(0,l.jsx)("span",{children:a.original.period}):null},meta:{name:"Period"}},{id:"hour",accessorKey:"hour",header:()=>(0,l.jsx)("span",{className:"min-w-24",children:"Hour"}),cell:e=>{let{row:a}=e;return"isLoadMoreMeters"in a.original&&a.original.isLoadMoreMeters||"isEmptyMeters"in a.original&&a.original.isEmptyMeters?null:"isProperty"in a.original&&a.original.isProperty?(0,l.jsx)("span",{className:"text-gray-400",children:"-"}):"isMeter"in a.original&&a.original.isMeter?(0,l.jsx)("span",{children:a.original.hour}):null},meta:{name:"Hour"}},{id:"gallons_consumed",accessorKey:"gallons_consumed",header:()=>{let e=a("gallons_consumed","Gallons");return(0,l.jsxs)("div",{className:e.className,onClick:e.onClick,children:[(0,l.jsx)("span",{className:"text-right",children:e.label}),(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(r.A,{className:e.upIconClassName}),(0,l.jsx)(n.A,{className:e.downIconClassName})]})]})},cell:e=>{let{row:a}=e;if("isLoadMoreMeters"in a.original&&a.original.isLoadMoreMeters||"isEmptyMeters"in a.original&&a.original.isEmptyMeters)return null;let t=0;return"isProperty"in a.original&&a.original.isProperty?t=a.original.gallons_consumed:"isMeter"in a.original&&a.original.isMeter&&(t=a.original.gallons_consumed),(0,l.jsx)("div",{className:"flex justify-end w-full",children:(0,l.jsx)("span",{className:"text-right pr-6",children:t.toLocaleStr
1ing()})})},meta:{name:"Gallons"}},{id:"actions",size:140,enableResizing:!1,cell:e=>{let{row:a}=e;if("isLoadMoreMeters"in a.original&&a.original.isLoadMoreMeters||"isEmptyMeters"in a.original&&a.original.isEmptyMeters)return null;if("isProperty"in a.original&&a.original.isProperty){let e=a.original,r=null==t?void 0:t[e.property_id],n=null==s?void 0:s[e.property_id];return(0,l.jsx)("div",{className:"flex justify-end w-full",children:(0,l.jsx)(m.$,{variant:"secondary",size:"sm",className:"opacity-100 py-1 px-2 w-32 h-7",onClick:a=>{a.stopPropagation(),null==c||c(e.property_id)},children:n?(0,l.jsx)(i.A,{className:"w-5 h-5 animate-spin text-brand-dark-cyan"}):r?(0,l.jsxs)("div",{className:"flex items-center gap-0.5",children:["Hide meters",(0,l.jsx)(o.A,{className:"w-5 h-5",strokeWidth:2})]}):(0,l.jsxs)("div",{className:"flex items-center gap-0.5",children:["Show meters",(0,l.jsx)(d.A,{className:"w-5 h-5",strokeWidth:2})]})})})}return null},meta:{fixedWidth:!0}}]}function y(e){let{data:a,isLoading:t,totalCount:r=0,onPageChange:n,currentPage:i=0,params:o,onSort:d,columnVisibility:m,columnOrder:x,onColumnVisibilityChange:y,pageSize:f,onPageSizeChange:b,menuPlacement:v,onMetersFiltersClick:N}=e,j=Math.ceil(r/(f||10)),_=j>1,[w,k]=(0,u.useState)({}),[C,S]=(0,u.useState)({}),[E,L]=(0,u.useState)({}),[A,D]=(0,u.useState)({}),[O,T]=(0,u.useState)({}),[I,P]=(0,u.useState)({}),[R,M]=(0,u.useState)(0);(0,u.useEffect)(()=>{k({}),L({}),D({}),T({}),P({})},[o.start_date,o.end_date,o.organization_id,o.property_id,o.meter_serial_number]),(0,u.useEffect)(()=>{let e=()=>{let e=window.document.querySelector("[data-hour-property-table]");e&&M(e.getBoundingClientRect().width)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[a]);let G=async e=>{let t=w[e],l=a.find(a=>a.property_id===e);if(k(a=>({...a,[e]:!t})),!t){S(a=>({...a,[e]:!0}));try{let a=await p.l.getLeakReportPropertiesMetersConsumptionHour(e,{...o,page:1,page_size:5,vendor:"waltero"}),t=a.results.map((a,t)=>({...a,isMeter:!0,id:"".concat(e,"-meter-").concat(t,"-").concat(a.meter_serial_number)}));L(a=>({...a,[e]:t})),D(t=>({...t,[e]:{page:1,hasMore:null!==a.next,total:a.count||0}}))}catch(e){console.error("Error fetching meters data:",e),(0,h.N)("Failed to load meters","Unable to fetch meters data for ".concat((null==l?void 0:l.property_name)||"this property"))}finally{S(a=>({...a,[e]:!1}))}}},z=async e=>{let t=A[e];if(!(null==t?void 0:t.hasMore)||O[e])return;T(a=>({...a,[e]:!0}));let l=I[e],s=!l;try{let a=await p.l.getLeakReportPropertiesMetersConsumptionHour(e,{...o,page:l?t.page+1:1,page_size:50,vendor:"waltero"}),r=a.results.map((a,s)=>({...a,isMeter:!0,id:"".concat(e,"-meter-").concat(l?t.page+1:1,"-").concat(s,"-").concat(a.meter_serial_number)}));L(a=>({...a,[e]:s?r:[...a[e]||[],...r]})),D(s=>({...s,[e]:{page:l?t.page+1:1,hasMore:null!==a.next,total:a.count||0}})),s&&P(a=>({...a,[e]:!0}))}catch(t){var r;console.error("Error loading more meters:",t),(0,h.N)("Failed to load more meters","Unable to fetch more meters data for ".concat((null==(r=a.find(a=>a.property_id===e))?void 0:r.property_name)||"this property"))}finally{T(a=>({...a,[e]:!1}))}},{getSortableHeaderProps:F}=(0,c.M)({params:o,onSort:d,isLoading:t,data:a}),H=g(null!=t&&t,F,w,C,G,A,E,O,z,R,N),V=a.reduce((e,a)=>{let t=a.property_id,l={...a,id:"property-".concat(t),isProperty:!0};if(e.push(l),w[t]){let l=E[t];if(l&&l.length>0){l.forEach(a=>{e.push(a)});let s=A[t];if(null==s?void 0:s.hasMore){let l={id:"load-more-meters-".concat(t),isLoadMoreMeters:!0,parent_property_id:t,property_name:a.property_name,building_count:a.building_count};e.push(l)}}else l&&0===l.length&&e.push({id:"empty-meters-".concat(t),isEmptyMeters:!0,parent_property_id:t})}return e},[]);return(0,l.jsx)("div",{"data-hour-property-table":!0,children:(0,l.jsx)(s.b,{columns:H,data:V,columnVisibility:m,onColumnVisibilityChange:y||(()=>{}),columnOrder:x,getRowClassName:e=>{let a=[];return"isProperty"in e.original&&e.original.isProperty?a.push("hover:bg-gray-50"):"isMeter"in e.original&&e.original.isMeter?a.push("bg-cyan-50 hover:bg-cyan-100"):("isLoadMoreMeters"in e.original&&e.original.isLoadMoreMeters||"isLoadMoreDaily"in e.original&&e.original.isLoadMoreDaily||"isEmptyMeters"in e.original&&e.original.isEmptyMeters)&&a.push("bg-cyan-50 border-t-2 relative"),a.join(" ")},isLoading:t,pageCount:_?j:void 0,pageIndex:_?i:void 0,onPageChange:_?n:void 0,headerClassName:"h-14",headerColor:"text-brand-black",showPageSizeSelector:!0,pageSize:f,onPageSizeChange:b,menuPlacement:v})})}},56375:(e,a,t)=>{t.d(a,{W:()=>p,r:()=>x});
1var l=t(95155),s=t(12115),r=t(12108),n=t(24033),i=t(27937),o=t(27331),d=t(20063),c=t(77888),m=t(41860),u=t(73730);let p=(e,a,t,s,d,c,p,x,h)=>[{id:"leak_type",accessorKey:"leak_type",header:"Leak Type",cell:e=>{var a;let{row:t}=e;return(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("div",{className:"h-8 w-8 border border-brand-stroke rounded-lg flex items-center justify-center shrink-0",children:(0,l.jsx)(o.Hq,{leakType:t.original.leak_type})}),(0,l.jsx)("span",{className:"text-sm font-medium capitalize text-nowrap",children:(0,m.WU)(null!=(a=t.original.leak_type)?a:"")})]})}},{id:"property_name",header:"Property | Building | Unit",accessorKey:"property_name",cell:e=>{let{row:a}=e;return(0,l.jsx)("div",{className:"flex flex-col gap-1 w-48 lg:w-auto",children:(0,l.jsxs)("span",{className:"text-sm font-medium truncate cursor-pointer",children:[(0,l.jsx)("span",{onClick:()=>null==c?void 0:c(a.original.property_id),className:"hover:text-brand-dark-cyan hover:underline",children:a.original.property_name}),(0,l.jsx)("span",{className:"mx-1 shrink-0",children:"|"}),(0,l.jsx)("span",{onClick:()=>null==p?void 0:p(a.original.property_id,a.original.building_id),className:"hover:text-brand-dark-cyan hover:underline",children:a.original.building_name}),(0,l.jsx)("span",{className:"mx-1 shrink-0",children:"|"}),(0,l.jsx)("span",{onClick:()=>null==x?void 0:x(a.original.property_id,a.original.building_id,a.original.unit_id),className:"hover:text-brand-dark-cyan hover:underline",children:a.original.unit_name})]})})}},{id:"gallons_consumed",header:()=>{let e=t("gallons_consumed","Gallons");return(0,l.jsxs)("div",{className:e.className,onClick:e.onClick,children:[(0,l.jsx)("span",{className:"text-right",children:e.label}),(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(r.A,{className:e.upIconClassName}),(0,l.jsx)(n.A,{className:e.downIconClassName})]})]})},cell:e=>{var a;let{row:t}=e;return(0,l.jsx)("div",{className:"flex justify-end w-full",children:(0,l.jsx)("span",{className:"text-right pr-6",children:(null!=(a=t.original.gallons_consumed)?a:0).toLocaleString()})})},accessorKey:"gallons_consumed",meta:{name:"Gallons"}},{id:"gallons_leaked",header:()=>{let e=t("gallons_leaked","Leak Gallons over the selected period");return(0,l.jsxs)("div",{className:e.className,onClick:e.onClick,children:[(0,l.jsx)("span",{className:"text-right w-44",children:e.label}),(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(r.A,{className:e.upIconClassName}),(0,l.jsx)(n.A,{className:e.downIconClassName})]})]})},cell:e=>{var a;let{row:t}=e;return(0,l.jsx)("div",{className:"flex justify-end w-full",children:(0,l.jsx)("span",{className:"text-right pr-6",children:(null!=(a=t.original.gallons_leaked)?a:0).toLocaleString()})})},accessorKey:"gallons_leaked",meta:{name:"Leak Gallons",borderBottom:!0,className:h&&"border-l border-t border-cyan-300 rounded-tl-md",cellClassName:h&&"border-l border-cyan-300",lastCellClassName:h&&"rounded-bl-md"}},{id:"flow_time",accessorKey:"flow_time",header:()=>(0,l.jsx)("div",{className:"flex justify-end w-full",children:(0,l.jsx)("span",{className:"text-right w-24",children:"Average Flow Time"})}),cell:e=>{let{row:a}=e;return(0,l.jsx)("div",{className:"flex justify-end w-full",children:(0,l.jsx)("span",{className:"text-right",children:a.original.flow_time})})},meta:{name:"Average Flow Time",borderBottom:!0,className:h&&"border-t border-cyan-300"}},{id:"events_sum",accessorKey:"events_sum",header:()=>(0,l.jsx)("div",{className:"flex justify-end w-full",children:(0,l.jsx)("span",{className:"text-right w-20",children:"Average Events"})}),cell:e=>{var a;let{row:t}=e;return(0,l.jsx)("div",{className:"flex justify-end w-full",children:(0,l.jsx)("span",{className:"text-right",children:(null!=(a=t.original.events_sum)?a:0).toLocaleString()})})},meta:{name:"Average Events",borderBottom:!0,className:h&&"border-t border-r border-cyan-300 rounded-tr-md",cellClassName:h&&"border-r border-cyan-300",lastCellClassName:h&&"rounded-br-md"}},{accessorKey:"before_leak_days_leak_overview",header:()=>(0,l.jsx)("div",{className:"text-right"})},{id:"leak_days",accessorKey:"leak_days",header:()=>(0,l.jsx)("div",{className:"w-full flex justify-end",children:(0,l.jsxs)("span",{className:"text-right w-32",children:["Leaking ",(0,l.jsx)("br",{}),"Period"]}
1)}),cell:e=>{var a,t,s,r;let{row:n}=e;return(0,l.jsx)("div",{className:"flex justify-end w-full",children:(0,l.jsxs)("span",{className:"text-right",children:[(null==n||null==(a=n.original)?void 0:a.leak_start_date)?(0,u.GP)(null==n||null==(t=n.original)?void 0:t.leak_start_date,"MM/dd"):"N/A",(null==n||null==(s=n.original)?void 0:s.leak_end_date)?" - ".concat((0,u.GP)(null==n||null==(r=n.original)?void 0:r.leak_end_date,"MM/dd")):" - N/A"]})})},meta:{name:"Leaking Period",borderBottom:!0,className:h&&"border-l border-t border-cyan-300 rounded-tl-md",cellClassName:h&&"border-l border-cyan-300",lastCellClassName:h&&"rounded-bl-md"}},{id:"total_gallons_leaked",header:()=>{let e=t("total_gallons_leaked","Total Leak Gallons since the leak started");return(0,l.jsxs)("div",{className:e.className,onClick:e.onClick,children:[(0,l.jsx)("span",{className:"text-right w-44",children:e.label}),(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(r.A,{className:e.upIconClassName}),(0,l.jsx)(n.A,{className:e.downIconClassName})]})]})},cell:e=>{var a;let{row:t}=e;return(0,l.jsx)("div",{className:"flex justify-end w-full",children:(0,l.jsx)("span",{className:"text-right pr-6",children:(null!=(a=t.original.total_gallons_leaked)?a:0).toLocaleString()})})},accessorKey:"total_gallons_leaked",meta:{name:"Total Leak Gallons",borderBottom:!0,className:h&&"border-r border-t border-cyan-300 rounded-tr-md",cellClassName:h&&"border-r border-cyan-300",lastCellClassName:h&&"rounded-br-md"}},{id:"actions",cell:e=>{let{row:a}=e;return(0,l.jsx)("div",{className:"flex justify-end w-full",children:(0,l.jsx)(o.$n,{variant:"secondary",size:"sm",className:"py-1 px-2 border-gray-400 w-24 h-7 text-brand-dark-gray hover:text-brand-dark-cyan hover:border-brand-dark-cyan",onClick:()=>s(a),children:(0,l.jsxs)("div",{className:"flex items-center gap-0.5",children:["Details",(0,l.jsx)(i.A,{className:"w-4 h-4"})]})})})}}];function x(e){let{data:a,isLoading:t,onColumnVisibilityChange:r,params:n,onSort:i,pageCount:m,pageIndex:u,onPageChange:x,dateRangeLabel:h,isPropertyPage:g,onFilterClick:y,pageSize:f,onPageSizeChange:b,onPropertyFilterClick:v,onBuildingFilterClick:N,onUnitFilterClick:j}=e,_=(0,d.useRouter)(),[w,k]=(0,s.useState)({yesterday:null,runningLeak:null}),C=(0,s.useRef)(null),{getSortableHeaderProps:S}=(0,c.M)({params:n,onSort:i,isLoading:t,data:a}),E=!t&&a.length>0,L=(0,s.useCallback)(()=>{if(!C.current)return;let e=C.current.getBoundingClientRect(),a=C.current.querySelector('[data-column-key="gallons_leaked"]'),t=C.current.querySelector('[data-column-key="leak_days"]');if(a){let t=a.getBoundingClientRect();k(a=>({...a,yesterday:new DOMRect(t.left-e.left,-34,t.width,20)}))}if(t){let a=t.getBoundingClientRect();k(t=>({...t,runningLeak:new DOMRect(a.left-e.left,-34,a.width,20)}))}},[]);(0,s.useEffect)(()=>{let e=window.setTimeout(L,0),a=new ResizeObserver(L);return C.current&&a.observe(C.current),window.addEventListener("resize",L),()=>{window.clearTimeout(e),a.disconnect(),window.removeEventListener("resize",L)}},[L]),(0,s.useEffect)(()=>{L()},[a,t,L]);let A=p(null!=t&&t,a,S,e=>{let a=new URLSearchParams;Object.entries({meter:e.original.meter_serial_number,...h&&{dateRangeLabel:h},...n.days_ago&&{days_ago:n.days_ago.toString()},...n.start_date&&{start_date:n.start_date},...n.end_date&&{end_date:n.end_date},...n.organization_id&&{organization_id:n.organization_id.toString()},...n.include_active_leak&&{include_active_leak:n.include_active_leak.toString()},...n.property_id&&{property_id:n.property_id.toString()}}).forEach(e=>{let[t,l]=e;l&&a.set(t,l)}),g?_.push("/properties/".concat(n.property_id,"/leak-detail?").concat(a.toString())):_.push("/history/leak-detail?".concat(a.toString()))},y,v,N,j,E);return(0,l.jsxs)("div",{className:"relative overflow-x-auto [&::-webkit-scrollbar]:h-1 [&::-webkit-scrollbar-track]:bg-gray-100 [&::-webkit-scrollbar-thumb]:bg-gray-400 [&::-webkit-scrollbar-thumb]:rounded-full lg:[&::-webkit-scrollbar]:hidden",ref:C,children:[(0,l.jsxs)("div",{className:"hidden lg:flex relative h-7 top-0 z-10",children:[E&&w.yesterday&&(0,l.jsx)("div",{className:"text-cyan-600 text-base text-nowrap",style:{position:"absolute",left:"".concat(w.yesterday.x,"px"),top:"0px"},children:h}),E&&w.runningLeak&&(0,l.jsx)("div",{className:"text-cyan-600 text-base text-nowrap",style:{position:"absolute",left:"".concat(w.runningLeak.x,"px"),top:"0px"},children:"Running Leak"})]}),(0,l.jsx)(o.bQ,{columns:A.map(e=>({...e,meta:{...e.meta,columnKey:"accessorKey"in e?e.accessorKey:e.id}})),data:a,columnVisibility:{},columnOrder:[],onColumnVisibilityChange:r||(()=>{}),isLoading:t,pageCount:m,pageIndex:u,onPageChange:x,showPageSizeSelector:!0,pageSize:f,onPageSizeChange:b})]})}},58518:(e,a,t)=>{t.d(a,{D:()=>c,m:()=>m});
1var l=t(95155),s=t(32897),r=t(12108),n=t(24033),i=t(77888),o=t(73730),d=t(64269);function c(e,a,t,s,i,d){return[{id:"property_name",accessorKey:"property_name",header:()=>(0,l.jsx)("span",{className:"min-w-32",children:"Property"}),cell:e=>{let{row:a}=e;return(0,l.jsx)("span",{children:a.original.property_name})},meta:{name:"Property"}},{id:"building_name",accessorKey:"building_name",header:()=>{let e=t("building_name","Building","start");return(0,l.jsxs)("div",{className:e.className,onClick:e.onClick,children:[(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(r.A,{className:e.upIconClassName}),(0,l.jsx)(n.A,{className:e.downIconClassName})]}),(0,l.jsx)("span",{children:e.label})]})},cell:e=>{let{row:a}=e;return(0,l.jsx)("div",{className:"flex items-center w-full h-full min-w-28 cursor-pointer hover:underline hover:text-brand-dark-cyan transition-colors",onClick:()=>null==s?void 0:s(a.original.property_id,a.original.building_id),children:a.original.building_name})},meta:{name:"Building"}},{id:"unit_name",accessorKey:"unit_name",header:()=>{let e=t("unit_name","Unit","start");return(0,l.jsxs)("div",{className:e.className,onClick:e.onClick,children:[(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(r.A,{className:e.upIconClassName}),(0,l.jsx)(n.A,{className:e.downIconClassName})]}),(0,l.jsx)("span",{children:e.label})]})},cell:e=>{let{row:a}=e;return(0,l.jsx)("div",{className:"flex items-center w-full h-full cursor-pointer hover:underline hover:text-brand-dark-cyan transition-colors",onClick:()=>null==i?void 0:i(a.original.property_id,a.original.building_id,a.original.unit_id),children:a.original.unit_name})},meta:{name:"Unit"}},{id:"bedroom_count",accessorKey:"bedroom_count",header:()=>(0,l.jsx)("span",{className:"min-w-20",children:"Bd - Ba"}),cell:e=>{let{row:a}=e;return(0,l.jsxs)("span",{children:[a.original.bedroom_count," Bd - ",a.original.bathroom_count," Ba"]})},meta:{name:"Bd - Ba"}},{id:"attached_to",accessorKey:"attached_to",header:()=>(0,l.jsx)("span",{className:"min-w-24",children:"Attached To"}),meta:{name:"Attached To"}},{id:"meter_serial_number",accessorKey:"meter_serial_number",header:()=>(0,l.jsx)("span",{className:"min-w-44",children:"Device Serial Number"}),cell:e=>{let{row:a}=e;return(0,l.jsx)("div",{className:"flex items-center w-full h-full cursor-pointer hover:underline hover:text-brand-dark-cyan transition-colors",onClick:()=>null==d?void 0:d(a.original.meter_serial_number),children:a.original.meter_serial_number})},meta:{name:"Device Serial Number"}},{id:"date",accessorKey:"date",header:()=>{let e=t("date","Date","start");return(0,l.jsxs)("div",{className:e.className,onClick:e.onClick,children:[(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(r.A,{className:e.upIconClassName}),(0,l.jsx)(n.A,{className:e.downIconClassName})]}),(0,l.jsx)("span",{children:e.label})]})},cell:e=>{let{row:a}=e;return(0,l.jsx)("div",{children:a.original.date?(0,o.GP)(a.original.date,"MMM dd, yyyy"):"-"})},meta:{name:"Date"}},{id:"gallons_consumed",accessorKey:"gallons_consumed",header:()=>{let e=t("gallons_consumed","Gallons");return(0,l.jsxs)("div",{className:e.className,onClick:e.onClick,children:[(0,l.jsx)("span",{className:"text-right",children:e.label}),(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(r.A,{className:e.upIconClassName}),(0,l.jsx)(n.A,{className:e.downIconClassName})]})]})},cell:e=>{var a;let{row:t}=e;return(0,l.jsx)("div",{className:"flex justify-end w-full",children:(0,l.jsx)("span",{className:"text-right pr-6",children:(null!=(a=t.original.gallons_consumed)?a:0).toLocaleString()})})},meta:{name:"Gallons"}},{id:"events",accessorKey:"events",header:()=>{let e=t("events","Events");return(0,l.jsxs)("div",{className:e.className,onClick:e.onClick,children:[(0,l.jsx)("span",{className:"text-right",children:e.label}),(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(r.A,{className:e.upIconClassName}),(0,l.jsx)(n.A,{className:e.downIconClassName})]})]})},cell:e=>{var a;let{row:t}=e;return(0,l.jsx)("div",{className:"flex justify-end w-full",children:(0,l.jsx)("span",{className:"text-right pr-6",children:(null!=(a=t.original.events)?a:0).toLocaleStr
1ing()})})},meta:{name:"Events"}},{id:"hour",accessorKey:"hour",header:"Hour",meta:{name:"Hour"}},{id:"flow_time",accessorKey:"flow_time",header:()=>(0,l.jsx)("div",{className:"flex justify-end w-full",children:(0,l.jsx)("span",{className:"text-right",children:"Flow Time"})}),cell:e=>{let{row:a}=e;return(0,l.jsx)("div",{className:"flex justify-end w-full",children:(0,l.jsx)("span",{className:"text-right",children:a.original.flow_time})})},meta:{name:"Flow Time"}},{id:"leak_details",accessorKey:"leak_details",header:"Leak Details",meta:{name:"Leak Details"}}]}function m(e){let{data:a,isLoading:t,totalCount:r=0,onPageChange:n,currentPage:o=0,params:m,onSort:u,columnVisibility:p,columnOrder:x,onColumnVisibilityChange:h,pageSize:g,onPageSizeChange:y,onBuildingFilterClick:f,onUnitFilterClick:b,onMetersFiltersClick:v}=e,N=Math.ceil(r/(g||10)),j=N>1,{getSortableHeaderProps:_}=(0,i.M)({params:m,onSort:u,isLoading:t,data:a}),w=c(null!=t&&t,a,_,f,b,v);return(0,l.jsx)(s.b,{columns:w,data:a,columnVisibility:p||{},onColumnVisibilityChange:h||(()=>{}),columnOrder:x||[],getRowClassName:e=>{let a=""!==e.original.leak_details&&"No Leak"!==e.original.leak_details&&null!==e.original.leak_details;return(0,d.cn)({"bg-indigo-50":a})},isLoading:t,pageCount:j?N:void 0,pageIndex:j?o:void 0,onPageChange:j?n:void 0,headerClassName:"h-14",headerColor:"text-brand-black",showPageSizeSelector:!0,pageSize:g,onPageSizeChange:y})}},58873:(e,a,t)=>{t.d(a,{N:()=>r});var l=t(95155),s=t(91463);function r(e,a,t){let r=(0,s.oR)({variant:"destructive",title:e,description:a,action:t?(0,l.jsx)("button",{onClick:()=>{t(),r.dismiss()},className:"inline-flex h-8 shrink-0 items-center justify-center rounded-md border border-brand-black bg-transparent px-3 text-sm font-medium transition-colors text-brand-black hover:bg-gray-100",children:"Retry"}):void 0})}},60163:(e,a,t)=>{t.d(a,{MG:()=>U.M,Zr:()=>B.Z,Qp:()=>V.Qp,vN:()=>H,kR:()=>c,cE:()=>C,bb:()=>r,Px:()=>o,Zu:()=>x,JJ:()=>_,Fw:()=>u,T7:()=>M,l9:()=>g,N_:()=>A,Hn:()=>Q,Q0:()=>I,Vc:()=>P,nt:()=>Y,Gj:()=>q,G$:()=>G.G,Ok:()=>f,wk:()=>T,kv:()=>ei,e5:()=>ea,Jw:()=>v});var l=t(91463),s=t(12115);function r(e){let{columns:a,storageKey:t,defaultColumns:l,defaultColumnOrder:r}=e,[n,i]=P("".concat(t,"SelectedColumns"),l),[o,d]=P("".concat(t,"OrderedColumns"),null!=r?r:l),c=I({columns:a,initialVisibleColumns:n,initialColumnOrder:o}),m=(0,s.useCallback)(e=>{c.setSelectedColumns(e),i(e)},[c.setSelectedColumns,i]),u=(0,s.useCallback)(e=>{c.setOrderedColumns(e),d(e)},[c.setOrderedColumns,d]);return{selectedColumns:c.selectedColumns,setSelectedColumns:m,orderedColumns:c.orderedColumns,setOrderedColumns:u,columnOptions:c.columnOptions,columnVisibility:c.columnVisibility}}let n={overview:null,criticalAlertsOverview:null,gatewaysRouters:null,meters:null,noConsumption:null,portfolioDetailProperties:null,propertiesNeedingAttention:null,otherProperties:null,loading:{overview:!1,criticalAlertsOverview:!1,gatewaysRouters:!1,meters:!1,noConsumption:!1,portfolioDetailProperties:!1,propertiesNeedingAttention:!1,otherProperties:!1},pagination:{gatewaysRouters:0,meters:0,noConsumption:0,portfolioDetailProperties:0,propertiesNeedingAttention:0,otherProperties:0},ordering:{gatewaysRouters:null,meters:null,noConsumption:null},pageSize:{gatewaysRouters:10,meters:10,noConsumption:10,portfolioDetailProperties:10,propertiesNeedingAttention:10,otherProperties:10}};function i(e,a){switch(a.type){case"SET_LOADING":return{...e,loading:{...e.loading,[a.payload.key]:a.payload.value}};case"SET_DATA":return{...e,[a.payload.key]:a.payload.value};case"SET_PAGE":return{...e,pagination:{...e.pagination,[a.payload.key]:a.payload.value}};case"SET_ORDERING":return{...e,ordering:{...e.ordering,[a.payload.key]:a.payload.value},pagination:{...e.pagination,[a.payload.key]:0}};case"SET_PAGE_SIZE":return{...e,pageSize:{...e.pageSize,[a.payload.key]:a.payload.value}};default:return e}}function o(){let[e,a]=(0,s.useReducer)(i,n);return{state:e,actions:{setLoading:(0,s.useCallback)((e,t)=>{a({type:"SET_LOADING",payload:{key:e,value:t}})},[]),setData:(0,s.useCallback)((e,t)=>{a({type:"SET_DATA",payload:{key:e,value:t}})},[]),setPage:(0,s.useCallback)((e,t)=>{a({type:"SET_PAGE",payload:{key:e,value:t}})},[]),setOrdering:(0,s.useCallback)((e,t)=>{a({type:"SET_ORDERING",payload:{key:e,value:t}})},[]),setPageSize:(0,s.useCallback)((e,t)=>{a({type:"SET_PAGE_SIZE",payload:{key:e,value:t}})},[])},dispatch:a}}let d="cockpit_date_filters";function c(e){let{organizations:a}
1=e,[t,l]=(0,s.useState)(!1),[r,n]=(0,s.useState)("yesterday"),[i,o]=(0,s.useState)("false"),[c,m]=(0,s.useState)(!0);return(0,s.useEffect)(()=>{let e=localStorage.getItem(d);if(e){let a=JSON.parse(e);a.onlyActiveLeaks&&l(a.onlyActiveLeaks),a.activeTimePeriod&&n(a.activeTimePeriod),a.comparison&&o(a.comparison)}else l(!1),n("yesterday"),o("false");m(!1)},[a]),(0,s.useEffect)(()=>{c||localStorage.setItem(d,JSON.stringify({onlyActiveLeaks:t,activeTimePeriod:r,comparison:i}))},[r,i,c,t]),{onlyActiveLeaks:t,handleOnlyActiveLeaksChange:e=>{l(e)},activeTimePeriod:r,handleTimePeriodChange:e=>{o("false"),n(e)},comparison:i,handleComparisonChange:e=>{o(e)}}}let m="gateway_date_filters";function u(e){let{organizations:a,onPaginationReset:t}=e,[l,r]=(0,s.useState)(void 0),[n,i]=(0,s.useState)(void 0),[o,d]=(0,s.useState)(!1),[c,u]=(0,s.useState)(!0),p=new Date;return(0,s.useEffect)(()=>{let e=localStorage.getItem(m);if(e){let a=JSON.parse(e);a.date&&(r(a.date),i(a.date))}else r(p),i(p);u(!1)},[a]),(0,s.useEffect)(()=>{c||localStorage.setItem(m,JSON.stringify({date:l}))},[l,c]),{date:l,tempDate:n,isCalendarOpen:o,handleCalendarOpenChange:e=>{d(e)},handleTempDateChange:e=>{i(e)},handleDateReset:()=>{r(p),i(p),d(!1),null==t||t()},handleDateApply:()=>{r(n),d(!1),null==t||t()}}}let p="finance_date_filters";function x(e){let{organizations:a,onPaginationReset:t}=e,[l,r]=(0,s.useState)(!1),[n,i]=(0,s.useState)("yesterday"),[o,d]=(0,s.useState)({from:void 0,to:void 0}),[c,m]=(0,s.useState)({from:void 0,to:void 0}
1),[u,x]=(0,s.useState)(!1),[h,g]=(0,s.useState)(!0);return(0,s.useEffect)(()=>{let e=localStorage.getItem(p);if(e){let a=JSON.parse(e);a.onlyActiveLeaks&&r(a.onlyActiveLeaks),a.activeTimePeriod&&i(a.activeTimePeriod),a.dateRange&&(d({from:a.dateRange.from?new Date(a.dateRange.from):void 0,to:a.dateRange.to?new Date(a.dateRange.to):void 0}),m({from:a.dateRange.from?new Date(a.dateRange.from):void 0,to:a.dateRange.to?new Date(a.dateRange.to):void 0}))}else i("yesterday"),d({from:void 0,to:void 0}),m({from:void 0,to:void 0});g(!1)},[a]),(0,s.useEffect)(()=>{if(h)return;let e={onlyActiveLeaks:l,activeTimePeriod:n,dateRange:{from:o.from?new Date(o.from.toDateString()).toISOString():void 0,to:o.to?new Date(o.to.toDateString()).toISOString():void 0}};localStorage.setItem(p,JSON.stringify(e))},[n,o,h,l]),{onlyActiveLeaks:l,handleOnlyActiveLeaksChange:e=>{r(e),null==t||t()},activeTimePeriod:n,handleTimePeriodChange:e=>{i(e),d({from:void 0,to:void 0}),m({from:void 0,to:void 0}),null==t||t()},dateRange:o,tempDateRange:c,isCalendarOpen:u,handleCalendarOpenChange:e=>{x(e)},handleTempDateRangeChange:e=>{m(e)},handleDateRangeReset:()=>{o.from&&o.to&&(d({from:void 0,to:void 0}),i("yesterday")),m({from:void 0,to:void 0}),x(!1),null==t||t()},handleDateRangeApply:()=>{d({from:c.from,to:c.to}),x(!1),i("custom-date-range"),null==t||t()}}}let h="history_date_filters";function g(e){let{organizations:a,onPaginationReset:t}=e,[l,r]=(0,s.useState)(!1),[n,i]=(0,s.useState)("yesterday"),[o,d]=(0,s.useState)({from:void 0,to:void 0}),[c,m]=(0,s.useState)({from:void 0,to:void 0}),[u,p]=(0,s.useState)(!1),[x,g]=(0,s.useState)(!0),y=new Date,f=new Date;return f.setDate(y.getDate()-6),(0,s.useEffect)(()=>{let e=localStorage.getItem(h);if(e){let a=JSON.parse(e);a.onlyActiveLeaks&&r(a.onlyActiveLeaks),a.activeTimePeriod&&i(a.activeTimePeriod),a.dateRange&&(d({from:a.dateRange.from?new Date(a.dateRange.from):f,to:a.dateRange.to?new Date(a.dateRange.to):y}),m({from:a.dateRange.from?new Date(a.dateRange.from):f,to:a.dateRange.to?new Date(a.dateRange.to):y}))}else r(!1),i("custom-date-range"),d({from:f,to:y}),m({from:f,to:y});g(!1)},[a]),(0,s.useEffect)(()=>{if(x)return;let e={onlyActiveLeaks:l,activeTimePeriod:n,dateRange:{from:o.from?new Date(o.from.toDateString()).toISOString():f,to:o.to?new Date(o.to.toDateString()).toISOString():y}};localStorage.setItem(h,JSON.stringify(e))},[n,o,x,l]),{onlyActiveLeaks:l,activeTimePeriod:n,dateRange:o,tempDateRange:c,isCalendarOpen:u,handleOnlyActiveLeaksChange:e=>{r(e),null==t||t()},handleTimePeriodChange:e=>{i(e),d({from:void 0,to:void 0}),m({from:void 0,to:void 0}),null==t||t()},handleCalendarOpenChange:e=>{p(e)},handleTempDateRangeChange:e=>{m(e)},handleDateRangeReset:()=>{o.from&&o.to&&(d({from:f,to:y}),i("custom-date-range")),m({from:f,to:y}),p(!1),null==t||t()},handleDateRangeApply:()=>{d({from:c.from,to:c.to}),p(!1),i("custom-date-range"),null==t||t()}}}let y="properties_date_filters";function f(e){let{organizations:a,onPaginationReset:t}=e,[l,r]=(0,s.useState)(!1),[n,i]=(0,s.useState)("yesterday"),[o,d]=(0,s.useState)({from:void 0,to:void 0}),[c,m]=(0,s.useState)({from:void 0,to:void 0}
1),[u,p]=(0,s.useState)(!1),[x,h]=(0,s.useState)(!0);return(0,s.useEffect)(()=>{let e=localStorage.getItem(y);if(e){let a=JSON.parse(e);a.onlyActiveLeaks&&r(a.onlyActiveLeaks),a.activeTimePeriod&&i(a.activeTimePeriod),a.dateRange&&(d({from:a.dateRange.from?new Date(a.dateRange.from):void 0,to:a.dateRange.to?new Date(a.dateRange.to):void 0}),m({from:a.dateRange.from?new Date(a.dateRange.from):void 0,to:a.dateRange.to?new Date(a.dateRange.to):void 0}))}else i("yesterday"),d({from:void 0,to:void 0}),m({from:void 0,to:void 0});h(!1)},[a]),(0,s.useEffect)(()=>{if(x)return;let e={onlyActiveLeaks:l,activeTimePeriod:n,dateRange:{from:o.from?new Date(o.from.toDateString()).toISOString():void 0,to:o.to?new Date(o.to.toDateString()).toISOString():void 0}};localStorage.setItem(y,JSON.stringify(e))},[n,o,x,l]),{onlyActiveLeaks:l,handleOnlyActiveLeaksChange:e=>{r(e),null==t||t()},activeTimePeriod:n,handleTimePeriodChange:e=>{i(e),d({from:void 0,to:void 0}),m({from:void 0,to:void 0}),null==t||t()},dateRange:o,tempDateRange:c,isCalendarOpen:u,handleCalendarOpenChange:e=>{p(e)},handleTempDateRangeChange:e=>{m(e)},handleDateRangeReset:()=>{o.from&&o.to&&(d({from:void 0,to:void 0}),i("yesterday")),m({from:void 0,to:void 0}),p(!1),null==t||t()},handleDateRangeApply:()=>{d({from:c.from,to:c.to}),p(!1),i("custom-date-range"),null==t||t()}}}let b="top5_date_filters";function v(e){let{organizations:a,setPropertiesPage:t,setUnitsPage:l}=e,[r,n]=(0,s.useState)("yesterday"),[i,o]=(0,s.useState)(!1),[d,c]=(0,s.useState)(!0);return(0,s.useEffect)(()=>{let e=localStorage.getItem(b);if(e){let a=JSON.parse(e);a.activeTimePeriod&&n(a.activeTimePeriod),a.showTodaysData&&o(a.showTodaysData)}else n("yesterday"),o(!1);c(!1)},[a]),(0,s.useEffect)(()=>{d||localStorage.setItem(b,JSON.stringify({activeTimePeriod:r,showTodaysData:i}))},[r,i,d]),{activeTimePeriod:r,handleTimePeriodChange:e=>{n(e),null==t||t(1),null==l||l(1)},showTodaysData:i,handleShowTodaysDataChange:e=>{o(e),null==t||t(1),null==l||l(1)}}}t(29141);let N={overview:{data:null,loading:!1},waterUsageEfficiency:{data:null,loading:!1},financesCosts:{data:null,loading:!1},financesLeakTypeCosts:{data:null,loading:!1},financesLeakOverview:{data:null,loading:!1,page:0,count:0,ordering:"",pageSize:10},waterBudget:{data:null,loading:!1,deleteLoading:!1,page:0,count:0,ordering:"",tempDeleteItem:null,tempEditItem:null,pageSize:10},granularity:"day",refreshTrigger:0,dialogs:{financeLeakRelatedCosts:!1,customCost:!1,columnsFilter:!1,waterBudgetColumns:!1,deleteCustomCost:!1,editCustomCost:!1}};function j(e,a){switch(a.type){case"SET_OVERVIEW_LOADING":return{...e,overview:{...e.overview,loading:a.payload}};case"SET_OVERVIEW_DATA":return{...e,overview:{...e.overview,data:a.payload}};
1case"SET_WATER_USAGE_EFFICIENCY_LOADING":return{...e,waterUsageEfficiency:{...e.waterUsageEfficiency,loading:a.payload}};case"SET_WATER_USAGE_EFFICIENCY_DATA":return{...e,waterUsageEfficiency:{...e.waterUsageEfficiency,data:a.payload}};case"SET_FINANCES_COSTS_LOADING":return{...e,financesCosts:{...e.financesCosts,loading:a.payload}};case"SET_FINANCES_COSTS_DATA":return{...e,financesCosts:{...e.financesCosts,data:a.payload}};case"SET_FINANCES_LEAK_TYPE_COSTS_LOADING":return{...e,financesLeakTypeCosts:{...e.financesLeakTypeCosts,loading:a.payload}};case"SET_FINANCES_LEAK_TYPE_COSTS_DATA":return{...e,financesLeakTypeCosts:{...e.financesLeakTypeCosts,data:a.payload}};case"SET_FINANCES_LEAK_OVERVIEW_LOADING":return{...e,financesLeakOverview:{...e.financesLeakOverview,loading:a.payload}};case"SET_FINANCES_LEAK_OVERVIEW_DATA":return{...e,financesLeakOverview:{...e.financesLeakOverview,data:a.payload.data,count:a.payload.count}};case"SET_FINANCES_LEAK_OVERVIEW_PAGE":return{...e,financesLeakOverview:{...e.financesLeakOverview,page:a.payload}};case"SET_FINANCES_LEAK_OVERVIEW_ORDERING":return{...e,financesLeakOverview:{...e.financesLeakOverview,ordering:a.payload}};case"SET_FINANCES_LEAK_OVERVIEW_PAGE_SIZE":return{...e,financesLeakOverview:{...e.financesLeakOverview,pageSize:a.payload}};case"SET_WATER_BUDGET_LOADING":return{...e,waterBudget:{...e.waterBudget,loading:a.payload}};case"SET_WATER_BUDGET_DELETE_LOADING":return{...e,waterBudget:{...e.waterBudget,deleteLoading:a.payload}};case"SET_WATER_BUDGET_DATA":return{...e,waterBudget:{...e.waterBudget,data:a.payload.data,count:a.payload.count}};case"SET_WATER_BUDGET_PAGE":return{...e,waterBudget:{...e.waterBudget,page:a.payload}};case"SET_WATER_BUDGET_ORDERING":return{...e,waterBudget:{...e.waterBudget,ordering:a.payload}};case"SET_WATER_BUDGET_TEMP_DELETE_ITEM":return{...e,waterBudget:{...e.waterBudget,tempDeleteItem:a.payload}};case"SET_WATER_BUDGET_TEMP_EDIT_ITEM":return{...e,waterBudget:{...e.waterBudget,tempEditItem:a.payload}};case"SET_WATER_BUDGET_PAGE_SIZE":return{...e,waterBudget:{...e.waterBudget,pageSize:a.payload}};case"SET_GRANULARITY":return{...e,granularity:a.payload};case"TOGGLE_DIALOG":return{...e,dialogs:{...e.dialogs,[a.payload.dialog]:a.payload.open}};case"TRIGGER_REFRESH":return{...e,refreshTrigger:e.refreshTrigger+1};default:return e}}function _(){let[e,a]=(0,s.useReducer)(j,N);return{state:e,actions:{setOverviewLoading:e=>a({type:"SET_OVERVIEW_LOADING",payload:e}),setOverviewData:e=>a({type:"SET_OVERVIEW_DATA",payload:e}),setWaterUsageEfficiencyLoading:e=>
1a({type:"SET_WATER_USAGE_EFFICIENCY_LOADING",payload:e}),setWaterUsageEfficiencyData:e=>a({type:"SET_WATER_USAGE_EFFICIENCY_DATA",payload:e}),setFinancesCostsLoading:e=>a({type:"SET_FINANCES_COSTS_LOADING",payload:e}),setFinancesCostsData:e=>a({type:"SET_FINANCES_COSTS_DATA",payload:e}),setFinancesLeakTypeCostsLoading:e=>a({type:"SET_FINANCES_LEAK_TYPE_COSTS_LOADING",payload:e}),setFinancesLeakTypeCostsData:e=>a({type:"SET_FINANCES_LEAK_TYPE_COSTS_DATA",payload:e}),setFinancesLeakOverviewLoading:e=>a({type:"SET_FINANCES_LEAK_OVERVIEW_LOADING",payload:e}),setFinancesLeakOverviewData:(e,t)=>a({type:"SET_FINANCES_LEAK_OVERVIEW_DATA",payload:{data:e,count:t}}),setFinancesLeakOverviewPage:e=>a({type:"SET_FINANCES_LEAK_OVERVIEW_PAGE",payload:e}),setFinancesLeakOverviewOrdering:e=>a({type:"SET_FINANCES_LEAK_OVERVIEW_ORDERING",payload:e}),setFinancesLeakOverviewPageSize:e=>a({type:"SET_FINANCES_LEAK_OVERVIEW_PAGE_SIZE",payload:e}),setWaterBudgetLoading:e=>a({type:"SET_WATER_BUDGET_LOADING",payload:e}),setWaterBudgetDeleteLoading:e=>a({type:"SET_WATER_BUDGET_DELETE_LOADING",payload:e}),setWaterBudgetData:(e,t)=>a({type:"SET_WATER_BUDGET_DATA",payload:{data:e,count:t}}),setWaterBudgetPage:e=>a({type:"SET_WATER_BUDGET_PAGE",payload:e}),setWaterBudgetOrdering:e=>a({type:"SET_WATER_BUDGET_ORDERING",payload:e}),setWaterBudgetTempDeleteItem:e=>a({type:"SET_WATER_BUDGET_TEMP_DELETE_ITEM",payload:e}),setWaterBudgetTempEditItem:e=>a({type:"SET_WATER_BUDGET_TEMP_EDIT_ITEM",payload:e}),setWaterBudgetPageSize:e=>a({type:"SET_WATER_BUDGET_PAGE_SIZE",payload:e}),setGranularity:e=>a({type:"SET_GRANULARITY",payload:e}),toggleDialog:(e,t)=>
1a({type:"TOGGLE_DIALOG",payload:{dialog:e,open:t}}),triggerRefresh:()=>a({type:"TRIGGER_REFRESH"})}}}let w={overview:{data:null,loading:!1},waterUsageEfficiency:{data:null,loading:!1},costs:{data:null,loading:!1},portfolioPerformance:{data:null,loading:!1},watchlist:{data:null,loading:!1},toplist:{data:null,loading:!1},granularity:"day",activeTab:"watchlist",isLeakRelatedCostsDialogOpen:!1};function k(e,a){switch(a.type){case"SET_OVERVIEW_LOADING":return{...e,overview:{...e.overview,loading:a.payload}};case"SET_OVERVIEW_DATA":return{...e,overview:{...e.overview,data:a.payload}};case"SET_WATER_USAGE_EFFICIENCY_LOADING":return{...e,waterUsageEfficiency:{...e.waterUsageEfficiency,loading:a.payload}};case"SET_WATER_USAGE_EFFICIENCY_DATA":return{...e,waterUsageEfficiency:{...e.waterUsageEfficiency,data:a.payload}};case"SET_COSTS_LOADING":return{...e,costs:{...e.costs,loading:a.payload}};case"SET_COSTS_DATA":return{...e,costs:{...e.costs,data:a.payload}};case"SET_PORTFOLIO_PERFORMANCE_LOADING":return{...e,portfolioPerformance:{...e.portfolioPerformance,loading:a.payload}};case"SET_PORTFOLIO_PERFORMANCE_DATA":return{...e,portfolioPerformance:{...e.portfolioPerformance,data:a.payload}};case"SET_WATCHLIST_LOADING":return{...e,watchlist:{...e.watchlist,loading:a.payload}};case"SET_WATCHLIST_DATA":return{...e,watchlist:{...e.watchlist,data:a.payload}};case"SET_TOPLIST_LOADING":return{...e,toplist:{...e.toplist,loading:a.payload}};case"SET_TOPLIST_DATA":return{...e,toplist:{...e.toplist,data:a.payload}};case"SET_GRANULARITY":return{...e,granularity:a.payload};case"SET_ACTIVE_TAB":return{...e,activeTab:a.payload};case"SET_LEAK_RELATED_COSTS_DIALOG_OPEN":return{...e,isLeakRelatedCostsDialogOpen:a.payload};case"SET_ALL_LOADING":return{...e,overview:{...e.overview,loading:a.payload},waterUsageEfficiency:{...e.waterUsageEfficiency,loading:a.payload},costs:{...e.costs,loading:a.payload},portfolioPerformance:{...e.portfolioPerformance,loading:a.payload},watchlist:{...e.watchlist,loading:a.payload},toplist:{...e.toplist,loading:a.payload}};default:return e}}function C(){let[e,a]=(0,s.useReducer)(k,w);return{state:e,actions:{setOverviewLoading:e=>a({type:"SET_OVERVIEW_LOADING",payload:e}),setOverviewData:e=>a({type:"SET_OVERVIEW_DATA",payload:e}),setWaterUsageEfficiencyLoading:e=>
1a({type:"SET_WATER_USAGE_EFFICIENCY_LOADING",payload:e}),setWaterUsageEfficiencyData:e=>a({type:"SET_WATER_USAGE_EFFICIENCY_DATA",payload:e}),setCostsLoading:e=>a({type:"SET_COSTS_LOADING",payload:e}),setCostsData:e=>a({type:"SET_COSTS_DATA",payload:e}),setPortfolioPerformanceLoading:e=>a({type:"SET_PORTFOLIO_PERFORMANCE_LOADING",payload:e}),setPortfolioPerformanceData:e=>a({type:"SET_PORTFOLIO_PERFORMANCE_DATA",payload:e}),setWatchlistLoading:e=>a({type:"SET_WATCHLIST_LOADING",payload:e}),setWatchlistData:e=>a({type:"SET_WATCHLIST_DATA",payload:e}),setToplistLoading:e=>a({type:"SET_TOPLIST_LOADING",payload:e}),setToplistData:e=>a({type:"SET_TOPLIST_DATA",payload:e}),setGranularity:e=>a({type:"SET_GRANULARITY",payload:e}),setActiveTab:e=>a({type:"SET_ACTIVE_TAB",payload:e}),setLeakRelatedCostsDialogOpen:e=>a({type:"SET_LEAK_RELATED_COSTS_DIALOG_OPEN",payload:e}),setAllLoading:e=>a({type:"SET_ALL_LOADING",payload:e})}}}let S={overview:{data:null,loading:!1},gallonsDynamics:{data:[],loading:!1},leakOverview:{data:[],loading:!1,count:0,page:0,ordering:"",pageSize:10},buildingFilters:{data:[],loading:!1,initial:[]},unitFilters:{data:[],loading:!1,initial:[]},gallonsDynamicsGranularity:"day",isBarChartModalOpen:!1,meterLevelConsumptionDay:{data:[],loading:!1,count:0,page:0,ordering:"",pageSize:10},meterLevelConsumptionHour:{data:[],loading:!1,count:0,page:0,ordering:"",pageSize:10},propertyLevelConsumptionDay:{data:[],loading:!1,count:0,page:0,ordering:"",pageSize:10},propertyLevelConsumptionHour:{data:[],loading:!1,count:0,page:0,ordering:"",pageSize:10},activeMainTab:"leak-overview",activeMeterTab:"day",activePropertyMeterTab:"day",buildingFilterOpen:!1,unitFilterOpen:!1,columnsFilterOpen:!1,columnsFilterDayOpen:!1,columnsFilterHourOpen:!1,columnsFilterDayPropertyOpen:!1,columnsFilterHourPropertyOpen:!1,metersFiltersOpen:!1,metersFilters:{metersOptions:[],initialMeters:[],selectedMeters:[],loading:!1},hourlyDrilldown:null,hourlyDrilldownData:{data:[],loading:!1,count:0,page:0,pageSize:10,ordering:""},propertyHourlyDrilldown:null,propertyHourlyDrilldownData:{data:[],loading:!1,count:0,page:0,pageSize:10,ordering:""}};function E(e,a){switch(a.type){case"SET_OVERVIEW_LOADING":return{...e,overview:{...e.overview,loading:a.payload}};case"SET_OVERVIEW_DATA":return{...e,overview:{...e.overview,data:a.payload}};case"SET_GALLONS_DYNAMICS_LOADING":return{...e,gallonsDynamics:{...e.gallonsDynamics,loading:a.payload}};case"SET_GALLONS_DYNAMICS_DATA":return{...e,gallonsDynamics:{...e.gallonsDynamics,data:a.payload}};case"SET_LEAK_OVERVIEW_LOADING":return{...e,leakOverview:{...e.leakOverview,loading:a.payload}};case"SET_LEAK_OVERVIEW_DATA":return{...e,leakOverview:{...e.leakOverview,data:a.payload.data,count:a.payload.count}};case"SET_LEAK_OVERVIEW_PAGE":return{...e,leakOverview:{...e.leakOverview,page:a.payload}};case"SET_LEAK_OVERVIEW_ORDERING":return{...e,leakOverview:{...e.leakOverview,ordering:a.payload}};case"SET_LEAK_OVERVIEW_PAGE_SIZE":return{...e,leakOverview:{...e.leakOverview,pageSize:a.payload}};case"SET_BUILDING_FILTERS_LOADING":return{...e,buildingFilters:{...e.buildingFilters,loading:a.payload}};case"SET_BUILDING_FILTERS_DATA":return{...e,buildingFilters:{...e.buildingFilters,data:a.payload.data,initial:a.payload.initial}};case"SET_UNIT_FILTERS_LOADING":return{...e,unitFilters:{...e.unitFilters,loading:a.payload}};case"SET_UNIT_FILTERS_DATA":return{...e,unitFilters:{...e.unitFilters,data:a.payload.data,initial:a.payload.initial}};case"SET_GALLONS_DYNAMICS_GRANULARITY":return{...e,gallonsDynamicsGranularity:a.payload};case"SET_BAR_CHART_MODAL_OPEN":return{...e,isBarChartModalOpen:a.payload};case"SET_METER_LEVEL_CONSUMPTION_DAY_LOADING":return{...e,meterLevelConsumptionDay:{...e.meterLevelConsumptionDay,loading:a.payload}};case"SET_METER_LEVEL_CONSUMPTION_DAY_DATA":return{...e,meterLevelConsumptionDay:{...e.meterLevelConsumptionDay,data:a.payload.data,count:a.payload.count}};case"SET_METER_LEVEL_CONSUMPTION_DAY_PAGE":return{...e,meterLevelConsumptionDay:{...e.meterLevelConsumptionDay,page:a.payload}};case"SET_METER_LEVEL_CONSUMPTION_DAY_ORDERING":return{...e,meterLevelConsumptionDay:{...e.meterLevelConsumptionDay,ordering:a.payload}};case"SET_METER_LEVEL_CONSUMPTION_DAY_PAGE_SIZE":return{...e,meterLevelConsumptionDay:{...e.meterLevelConsumptionDay,pageSize:a.payload}};case"SET_METER_LEVEL_CONSUMPTION_HOUR_LOADING":return{...e,meterLevelConsumptionHour:{...e.meterLevelConsumptionHour,loading:a.payload}};case"SET_METER_LEVEL_CONSUMPTION_HOUR_DATA":return{...e,meterLevelConsumptionHour:{...e.meterLevelConsumptionHour,data:a.payload.data,count:a.payload.count}};case"SET_METER_LEVEL_CONSUMPTION_HOUR_PAGE":return{...e,meterLevelConsumptionHour:{...e.meterLevelConsumptionHour,page:a.payload}};case"SET_METER_LEVEL_CONSUMPTION_HOUR_ORDERING":return{...e,meterLevelConsumptionHour:{...e.meterLevelConsumptionHour,ordering:a.payload}};case"SET_METER_LEVEL_CONSUMPTION_HOUR_PAGE_SIZE":return{...e,meterLevelConsumptionHour:{...e.meterLevelConsumptionHour,pageSize:a.payload}};case"SET_PROPERTY_LEVEL_CONSUMPTION_DAY_LOADING":return{...e,propertyLevelConsumptionDay:{...e.propertyLevelConsumptionDay,loading:a.payload}};case"SET_PROPERTY_LEVEL_CONSUMPTION_DAY_DATA":return{...e,propertyLevelConsumptionDay:{...e.propertyLevelConsumptionDay,data:a.payload.data,count:a.payload.count}};case"SET_PROPERTY_LEVEL_CONSUMPTION_DAY_PAGE":return{...e,propertyLevelConsumptionDay:{...e.propertyLevelConsumptionDay,page:a.payload}};case"SET_PROPERTY_LEVEL_CONSUMPTION_DAY_ORDERING":return{...e,propertyLevelConsumptionDay:{...e.propertyLevelConsumptionDay,ordering:a.payload}};case"SET_PROPERTY_LEVEL_CONSUMPTION_DAY_PAGE_SIZE":return{...e,propertyLevelConsumptionDay:{...e.propertyLevelConsumptionDay,pageSize:a.payload}};case"SET_PROPERTY_LEVEL_CONSUMPTION_HOUR_LOADING":return{...e,propertyLevelConsumptionHour:{...e.propertyLevelConsumptionHour,loading:a.payload}};case"SET_PROPERTY_LEVEL_CONSUMPTION_HOUR_DATA":return{...e,propertyLevelConsumptionHour:{...e.propertyLevelConsumptionHour,data:a.payload.data,count:a.payload.count}};case"SET_PROPERTY_LEVEL_CONSUMPTION_HOUR_PAGE":return{...e,propertyLevelConsumptionHour:{...e.propertyLevelConsumptionHour,page:a.payload}};case"SET_PROPERTY_LEVEL_CONSUMPTION_HOUR_ORDERING":return{...e,propertyLevelConsumptionHour:{...e.propertyLevelConsumptionHour,ordering:a.payload}};case"SET_PROPERTY_LEVEL_CONSUMPTION_HOUR_PAGE_SIZE":return{...e,propertyLevelConsumptionHour:{...e.propertyLevelConsumptionHour,pageSize:a.payload}};case"SET_ACTIVE_MAIN_TAB":return{...e,activeMainTab:a.payload};case"SET_ACTIVE_METER_TAB":return{...e,activeMeterTab:a.payload};case"SET_ACTIVE_PROPERTY_METER_TAB":return{...e,activePropertyMeterTab:a.payload};case"SET_BUILDING_FILTER_OPEN":return{...e,buildingFilterOpen:a.payload};case"SET_UNIT_FILTER_OPEN":return{...e,unitFilterOpen:a.payload};case"SET_COLUMNS_FILTER_OPEN":return{...e,columnsFilterOpen:a.payload};case"SET_COLUMNS_FILTER_DAY_OPEN":return{...e,columnsFilterDayOpen:a.payload};case"SET_COLUMNS_FILTER_HOUR_OPEN":return{...e,columnsFilterHourOpen:a.payload};case"SET_COLUMNS_FILTER_DAY_PROPERTY_OPEN":return{...e,columnsFilterDayPropertyOpen:a.payload};case"SET_COLUMNS_FILTER_HOUR_PROPERTY_OPEN":return{...e,columnsFilterHourPropertyOpen:a.payload};case"SET_METERS_FILTERS_OPEN":return{...e,metersFiltersOpen:a.payload};case"SET_METERS_FILTERS_OPTIONS":return{...e,metersFilters:{...e.metersFilters,metersOptions:a.payload}};case"SET_INITIAL_METERS_FILTERS":return{...e,metersFilters:{...e.metersFilters,initialMeters:a.payload}};case"SET_SELECTED_METERS_FILTERS":return{...e,metersFilters:{...e.metersFilters,selectedMeters:a.payload}};case"SET_METERS_FILTERS_LOADING":return{...e,metersFilters:{...e.metersFilters,loading:a.payload}};case"SET_HOURLY_DRILLDOWN":return{...e,hourlyDrilldown:a.payload};case"SET_HOURLY_DRILLDOWN_DATA_LOADING":return{...e,hourlyDrilldownData:{...e.hourlyDrilldownData,loading:a.payload}};case"SET_HOURLY_DRILLDOWN_DATA":return{...e,hourlyDrilldownData:{...e.hourlyDrilldownData,data:a.payload.data,count:a.payload.count}};case"SET_HOURLY_DRILLDOWN_DATA_PAGE":return{...e,hourlyDrilldownData:{...e.hourlyDrilldownData,page:a.payload}};case"SET_HOURLY_DRILLDOWN_DATA_PAGE_SIZE":return{...e,hourlyDrilldownData:{...e.hourlyDrilldownData,pageSize:a.payload}};case"SET_HOURLY_DRILLDOWN_DATA_ORDERING":return{...e,hourlyDrilldownData:{...e.hourlyDrilldownData,ordering:a.payload}};case"RESET_HOURLY_DRILLDOWN_DATA":return{...e,hourlyDrilldownData:{data:[],loading:!1,count:0,page:0,pageSize:10,ordering:""}};case"SET_PROPERTY_HOURLY_DRILLDOWN":return{...e,propertyHourlyDrilldown:a.payload};case"SET_PROPERTY_HOURLY_DRILLDOWN_DATA_LOADING":return{...e,propertyHourlyDrilldownData:{...e.propertyHourlyDrilldownData,loading:a.payload}};case"SET_PROPERTY_HOURLY_DRILLDOWN_DATA":return{...e,propertyHourlyDrilldownData:{...e.propertyHourlyDrilldownData,data:a.payload.data,count:a.payload.count}};case"SET_PROPERTY_HOURLY_DRILLDOWN_DATA_PAGE":return{...e,propertyHourlyDrilldownData:{...e.propertyHourlyDrilldownData,page:a.payload}};case"SET_PROPERTY_HOURLY_DRILLDOWN_DATA_PAGE_SIZE":return{...e,propertyHourlyDrilldownData:{...e.propertyHourlyDrilldownData,pageSize:a.payload}};case"SET_PROPERTY_HOURLY_DRILLDOWN_DATA_ORDERING":return{...e,propertyHourlyDrilldownData:{...e.propertyHourlyDrilldownData,ordering:a.payload}};case"RESET_PROPERTY_HOURLY_DRILLDOWN_DATA":return{...e,propertyHourlyDrilldownData:{data:[],loading:!1,count:0,page:0,pageSize:10,ordering:""}};default:return e}}let L={setOverviewLoading:e=>({type:"SET_OVERVIEW_LOADING",payload:e}),setOverviewData:e=>({type:"SET_OVERVIEW_DATA",payload:e}),setGallonsDynamicsLoading:e=>({type:"SET_GALLONS_DYNAMICS_LOADING",payload:e}),setGallonsDynamicsData:e=>({type:"SET_GALLONS_DYNAMICS_DATA",payload:e}),setLeakOverviewLoading:e=>({type:"SET_LEAK_OVERVIEW_LOADING",payload:e}),setLeakOverviewData:(e,a)=>({type:"SET_LEAK_OVERVIEW_DATA",payload:{data:e,count:a}}),setLeakOverviewPage:e=>({type:"SET_LEAK_OVERVIEW_PAGE",payload:e}),setLeakOverviewOrdering:e=>({type:"SET_LEAK_OVERVIEW_ORDERING",payload:e}),setLeakOverviewPageSize:e=>({type:"SET_LEAK_OVERVIEW_PAGE_SIZE",payload:e}),setBuildingFiltersLoading:e=>({type:"SET_BUILDING_FILTERS_LOADING",payload:e}),setBuildingFiltersData:(e,a)=>({type:"SET_BUILDING_FILTERS_DATA",payload:{data:e,initial:a}}),setUnitFiltersLoading:e=>({type:"SET_UNIT_FILTERS_LOADING",payload:e}),setUnitFiltersData:(e,a)=>({type:"SET_UNIT_FILTERS_DATA",payload:{data:e,initial:a}}),setGallonsDynamicsGranularity:e=>({type:"SET_GALLONS_DYNAMICS_GRANULARITY",payload:e}),setBarChartModalOpen:e=>({type:"SET_BAR_CHART_MODAL_OPEN",payload:e}),setMeterLevelConsumptionDayLoading:e=>({type:"SET_METER_LEVEL_CONSUMPTION_DAY_LOADING",payload:e}),setMeterLevelConsumptionDayData:(e,a)=>({type:"SET_METER_LEVEL_CONSUMPTION_DAY_DATA",payload:{data:e,count:a}}),setMeterLevelConsumptionDayPage:e=>({type:"SET_METER_LEVEL_CONSUMPTION_DAY_PAGE",payload:e}),setMeterLevelConsumptionDayOrdering:e=>({type:"SET_METER_LEVEL_CONSUMPTION_DAY_ORDERING",payload:e}),setMeterLevelConsumptionDayPageSize:e=>({type:"SET_METER_LEVEL_CONSUMPTION_DAY_PAGE_SIZE",payload:e}),setMeterLevelConsumptionHourLoading:e=>({type:"SET_METER_LEVEL_CONSUMPTION_HOUR_LOADING",payload:e}),setMeterLevelConsumptionHourData:(e,a)=>({type:"SET_METER_LEVEL_CONSUMPTION_HOUR_DATA",payload:{data:e,count:a}}),setMeterLevelConsumptionHourPage:e=>({type:"SET_METER_LEVEL_CONSUMPTION_HOUR_PAGE",payload:e}),setMeterLevelConsumptionHourOrdering:e=>({type:"SET_METER_LEVEL_CONSUMPTION_HOUR_ORDERING",payload:e}),setMeterLevelConsumptionHourPageSize:e=>({type:"SET_METER_LEVEL_CONSUMPTION_HOUR_PAGE_SIZE",payload:e}),setPropertyLevelConsumptionDayLoading:e=>({type:"SET_PROPERTY_LEVEL_CONSUMPTION_DAY_LOADING",payload:e}),setPropertyLevelConsumptionDayData:(e,a)=>({type:"SET_PROPERTY_LEVEL_CONSUMPTION_DAY_DATA",payload:{data:e,count:a}}),setPropertyLevelConsumptionDayPage:e=>({type:"SET_PROPERTY_LEVEL_CONSUMPTION_DAY_PAGE",payload:e}),setPropertyLevelConsumptionDayOrdering:e=>({type:"SET_PROPERTY_LEVEL_CONSUMPTION_DAY_ORDERING",payload:e}),setPropertyLevelConsumptionDayPageSize:e=>({type:"SET_PROPERTY_LEVEL_CONSUMPTION_DAY_PAGE_SIZE",payload:e}),setPropertyLevelConsumptionHourLoading:e=>({type:"SET_PROPERTY_LEVEL_CONSUMPTION_HOUR_LOADING",payload:e}),setPropertyLevelConsumptionHourData:(e,a)=>({type:"SET_PROPERTY_LEVEL_CONSUMPTION_HOUR_DATA",payload:{data:e,count:a}}),setPropertyLevelConsumptionHourPage:e=>({type:"SET_PROPERTY_LEVEL_CONSUMPTION_HOUR_PAGE",payload:e}),setPropertyLevelConsumptionHourOrdering:e=>({type:"SET_PROPERTY_LEVEL_CONSUMPTION_HOUR_ORDERING",payload:e}),setPropertyLevelConsumptionHourPageSize:e=>({type:"SET_PROPERTY_LEVEL_CONSUMPTION_HOUR_PAGE_SIZE",payload:e}
1),setActiveMainTab:e=>({type:"SET_ACTIVE_MAIN_TAB",payload:e}),setActiveMeterTab:e=>({type:"SET_ACTIVE_METER_TAB",payload:e}),setActivePropertyMeterTab:e=>({type:"SET_ACTIVE_PROPERTY_METER_TAB",payload:e}),setBuildingFilterOpen:e=>({type:"SET_BUILDING_FILTER_OPEN",payload:e}),setUnitFilterOpen:e=>({type:"SET_UNIT_FILTER_OPEN",payload:e}),setColumnsFilterOpen:e=>({type:"SET_COLUMNS_FILTER_OPEN",payload:e}),setColumnsFilterDayOpen:e=>({type:"SET_COLUMNS_FILTER_DAY_OPEN",payload:e}),setColumnsFilterHourOpen:e=>({type:"SET_COLUMNS_FILTER_HOUR_OPEN",payload:e}),setColumnsFilterDayPropertyOpen:e=>({type:"SET_COLUMNS_FILTER_DAY_PROPERTY_OPEN",payload:e}),setColumnsFilterHourPropertyOpen:e=>({type:"SET_COLUMNS_FILTER_HOUR_PROPERTY_OPEN",payload:e}),setMetersFiltersOpen:e=>({type:"SET_METERS_FILTERS_OPEN",payload:e}),setMetersFiltersOptions:e=>({type:"SET_METERS_FILTERS_OPTIONS",payload:e}),setInitialMetersFilters:e=>({type:"SET_INITIAL_METERS_FILTERS",payload:e}),setSelectedMetersFilters:e=>({type:"SET_SELECTED_METERS_FILTERS",payload:e}),setMetersFiltersLoading:e=>({type:"SET_METERS_FILTERS_LOADING",payload:e}),setHourlyDrilldown:e=>({type:"SET_HOURLY_DRILLDOWN",payload:e}),setHourlyDrilldownDataLoading:e=>({type:"SET_HOURLY_DRILLDOWN_DATA_LOADING",payload:e}),setHourlyDrilldownData:(e,a)=>({type:"SET_HOURLY_DRILLDOWN_DATA",payload:{data:e,count:a}}),setHourlyDrilldownDataPage:e=>({type:"SET_HOURLY_DRILLDOWN_DATA_PAGE",payload:e}),setHourlyDrilldownDataPageSize:e=>({type:"SET_HOURLY_DRILLDOWN_DATA_PAGE_SIZE",payload:e}),setHourlyDrilldownDataOrdering:e=>({type:"SET_HOURLY_DRILLDOWN_DATA_ORDERING",payload:e}),resetHourlyDrilldownData:()=>({type:"RESET_HOURLY_DRILLDOWN_DATA"}),setPropertyHourlyDrilldown:e=>({type:"SET_PROPERTY_HOURLY_DRILLDOWN",payload:e}),setPropertyHourlyDrilldownDataLoading:e=>({type:"SET_PROPERTY_HOURLY_DRILLDOWN_DATA_LOADING",payload:e}),setPropertyHourlyDrilldownData:(e,a)=>({type:"SET_PROPERTY_HOURLY_DRILLDOWN_DATA",payload:{data:e,count:a}}),setPropertyHourlyDrilldownDataPage:e=>({type:"SET_PROPERTY_HOURLY_DRILLDOWN_DATA_PAGE",payload:e}),setPropertyHourlyDrilldownDataPageSize:e=>({type:"SET_PROPERTY_HOURLY_DRILLDOWN_DATA_PAGE_SIZE",payload:e}),setPropertyHourlyDrilldownDataOrdering:e=>({type:"SET_PROPERTY_HOURLY_DRILLDOWN_DATA_ORDERING",payload:e}),resetPropertyHourlyDrilldownData:()=>({type:"RESET_PROPERTY_HOURLY_DRILLDOWN_DATA"})};function A(){let[e,a]=(0,s.useReducer)(E,S);return{state:e,actions:{setOverviewLoading:e=>a(L.setOverviewLoading(e)),setOverviewData:e=>a(L.setOverviewData(e)),setGallonsDynamicsLoading:e=>a(L.setGallonsDynamicsLoading(e)),setGallonsDynamicsData:e=>a(L.setGallonsDynamicsData(e)),setLeakOverviewLoading:e=>a(L.setLeakOverviewLoading(e)),setLeakOverviewData:(e,t)=>a(L.setLeakOverviewData(e,t)),setLeakOverviewPage:e=>a(L.setLeakOverviewPage(e)),setLeakOverviewOrdering:e=>a(L.setLeakOverviewOrdering(e)),setLeakOverviewPageSize:e=>a(L.setLeakOverviewPageSize(e)),setBuildingFiltersLoading:e=>a(L.setBuildingFiltersLoading(e)),setBuildingFiltersData:(e,t)=>a(L.setBuildingFiltersData(e,t)),setUnitFiltersLoading:e=>a(L.setUnitFiltersLoading(e)),setUnitFiltersData:(e,t)=>a(L.setUnitFiltersData(e,t)),setGallonsDynamicsGranularity:e=>a(L.setGallonsDynamicsGranularity(e)),setBarChartModalOpen:e=>a(L.setBarChartModalOpen(e)),setMeterLevelConsumptionDayLoading:e=>a(L.setMeterLevelConsumptionDayLoading(e)),setMeterLevelConsumptionDayData:(e,t)=>a(L.setMeterLevelConsumptionDayData(e,t)),setMeterLevelConsumptionDayPage:e=>a(L.setMeterLevelConsumptionDayPage(e)),setMeterLevelConsumptionDayOrdering:e=>a(L.setMeterLevelConsumptionDayOrdering(e)),setMeterLevelConsumptionDayPageSize:e=>a(L.setMeterLevelConsumptionDayPageSize(e)),setMeterLevelConsumptionHourLoading:e=>a(L.setMeterLevelConsumptionHourLoading(e)),setMeterLevelConsumptionHourData:(e,t)=>a(L.setMeterLevelConsumptionHourData(e,t)),setMeterLevelConsumptionHourPage:e=>a(L.setMeterLevelConsumptionHourPage(e)),setMeterLevelConsumptionHourOrdering:e=>a(L.setMeterLevelConsumptionHourOrdering(e)),setMeterLevelConsumptionHourPageSize:e=>a(L.setMeterLevelConsumptionHourPageSize(e)),setPropertyLevelConsumptionDayLoading:e=>a(L.setPropertyLevelConsumptionDayLoading(e)),setPropertyLevelConsumptionDayData:(e,t)=>a(L.setPropertyLevelConsumptionDayData(e,t)),setPropertyLevelConsumptionDayPage:e=>a(L.setPropertyLevelConsumptionDayPage(e)),setPropertyLevelConsumptionDayOrdering:e=>a(L.setPropertyLevelConsumptionDayOrdering(e)),setPropertyLevelConsumptionDayPageSize:e=>a(L.setPropertyLevelConsumptionDayPageSize(e)),setPropertyLevelConsumptionHourLoading:e=>a(L.setPropertyLevelConsumptionHourLoading(e)),setPropertyLevelConsumptionHourData:(e,t)=>a(L.setPropertyLevelConsumptionHourData(e,t)),setPropertyLevelConsumptionHourPage:e=>a(L.setPropertyLevelConsumptionHourPage(e)),setPropertyLevelConsumptionHourOrdering:e=>a(L.setPropertyLevelConsumptionHourOrdering(e)),setPropertyLevelConsumptionHourPageSize:e=>a(L.setPropertyLevelConsumptionHourPageSize(e)),setActiveMainTab:e=>a(L.setActiveMainTab(e)),setActiveMeterTab:e=>a(L.setActiveMeterTab(e)),setActivePropertyMeterTab:e=>a(L.setActivePropertyMeterTab(e)),setBuildingFilterOpen:e=>a(L.setBuildingFilterOpen(e)),setUnitFilterOpen:e=>a(L.setUnitFilterOpen(e)),setColumnsFilterOpen:e=>a(L.setColumnsFilterOpen(e)),setColumnsFilterDayOpen:e=>a(L.setColumnsFilterDayOpen(e)),setColumnsFilterHourOpen:e=>a(L.setColumnsFilterHourOpen(e)),setColumnsFilterDayPropertyOpen:e=>a(L.setColumnsFilterDayPropertyOpen(e)),setColumnsFilterHourPropertyOpen:e=>a(L.setColumnsFilterHourPropertyOpen(e)),setMetersFiltersOpen:e=>a(L.setMetersFiltersOpen(e)),setMetersFiltersOptions:e=>a(L.setMetersFiltersOptions(e)),setInitialMetersFilters:e=>a(L.setInitialMetersFilters(e)),setSelectedMetersFilters:e=>a(L.setSelectedMetersFilters(e)),setMetersFiltersLoading:e=>a(L.setMetersFiltersLoading(e)),setHourlyDrilldown:e=>a(L.setHourlyDrilldown(e)),setHourlyDrilldownDataLoading:e=>a(L.setHourlyDrilldownDataLoading(e)),setHourlyDrilldownData:(e,t)=>a(L.setHourlyDrilldownData(e,t)),setHourlyDrilldownDataPage:e=>a(L.setHourlyDrilldownDataPage(e)),setHourlyDrilldownDataPageSize:e=>a(L.setHourlyDrilldownDataPageSize(e)),setHourlyDrilldownDataOrdering:e=>a(L.setHourlyDrilldownDataOrdering(e)),resetHourlyDrilldownData:()=>a(L.resetHourlyDrilldownData()),setPropertyHourlyDrilldown:e=>a(L.setPropertyHourlyDrilldown(e)),setPropertyHourlyDrilldownDataLoading:e=>a(L.setPropertyHourlyDrilldownDataLoading(e)),setPropertyHourlyDrilldownData:(e,t)=>a(L.setPropertyHourlyDrilldownData(e,t)),setPropertyHourlyDrilldownDataPage:e=>a(L.setPropertyHourlyDrilldownDataPage(e)),setPropertyHourlyDrilldownDataPageSize:e=>a(L.setPropertyHourlyDrilldownDataPageSize(e)),setPropertyHourlyDrilldownDataOrdering:e=>a(L.setPropertyHourlyDrilldownDataOrdering(e)),resetPropertyHourlyDrilldownData:()=>a(L.resetPropertyHourlyDrilldownData())}}}let D={propertyInfo:{data:null,loading:!1},overview:{data:null,loading:!1},leakOverview:{data:[],loading:!1,count:0,page:0,pageSize:10,ordering:""},tenantConsumptionDay:{data:[],loading:!1,count:0,page:0,ordering:"",pageSize:10},tenantConsumptionHour:{data:[],loading:!1,count:0,page:0,ordering:"",pageSize:10},propertyLevelConsumptionDay:{data:[],loading:!1,count:0,page:0,ordering:"",pageSize:10},propertyLevelConsumptionHour:{data:[],loading:!1,count:0,page:0,ordering:"",pageSize:10},filters:{buildings:{data:[],initial:[],selected:[]},units:{data:[],initial:[],selected:[]},loading:!1},activeMainTab:"leak-overview",activeMeterTab:"day",activePropertyMeterTab:"day",buildingFilterOpen:!1,unitFilterOpen:!1,columnsFilterOpen:!1,columnsFilterDayOpen:!1,columnsFilterHourOpen:!1,columnsFilterDayPropertyOpen:!1,columnsFilterHourPropertyOpen:!1,metersFiltersOpen:!1,metersFilters:{metersOptions:[],initialMeters:[],selectedMeters:[],loading:!1},hourlyDrilldown:null,hourlyDrilldownData:{data:[],loading:!1,count:0,page:0,pageSize:10,ordering:""},propertyHourlyDrilldown:null,propertyHourlyDrilldownData:{data:[],loading:!1,count:0,page:0,pageSize:10,ordering:""}};function O(e,a){switch(a.type){case"SET_PROPERTY_INFO_LOADING":return{...e,propertyInfo:{...e.propertyInfo,loading:a.payload}};case"SET_PROPERTY_INFO_DATA":return{...e,propertyInfo:{...e.propertyInfo,data:a.payload}};case"SET_OVERVIEW_LOADING":return{...e,overview:{...e.overview,loading:a.payload}};case"SET_OVERVIEW_DATA":return{...e,overview:{...e.overview,data:a.payload}};case"SET_LEAK_OVERVIEW_LOADING":return{...e,leakOverview:{...e.leakOverview,loading:a.payload}};case"SET_LEAK_OVERVIEW_DATA":return{...e,leakOverview:{...e.leakOverview,data:a.payload.data,count:a.payload.count}};case"SET_LEAK_OVERVIEW_PAGE":return{...e,leakOverview:{...e.leakOverview,page:a.payload}};case"SET_LEAK_OVERVIEW_ORDERING":return{...e,leakOverview:{...e.leakOverview,ordering:a.payload}};case"SET_LEAK_OVERVIEW_PAGE_SIZE":return{...e,leakOverview:{...e.leakOverview,pageSize:a.payload}};case"SET_METER_CONSUMPTION_DAY_LOADING":return{...e,tenantConsumptionDay:{...e.tenantConsumptionDay,loading:a.payload}};case"SET_METER_CONSUMPTION_DAY_DATA":return{...e,tenantConsumptionDay:{...e.tenantConsumptionDay,data:a.payload.data,count:a.payload.count}};case"SET_METER_CONSUMPTION_DAY_PAGE":return{...e,tenantConsumptionDay:{...e.tenantConsumptionDay,page:a.payload}};case"SET_METER_CONSUMPTION_DAY_ORDERING":return{...e,tenantConsumptionDay:{...e.tenantConsumptionDay,ordering:a.payload}};case"SET_METER_CONSUMPTION_DAY_PAGE_SIZE":return{...e,tenantConsumptionDay:{...e.tenantConsumptionDay,pageSize:a.payload}};case"SET_METER_CONSUMPTION_HOUR_LOADING":return{...e,tenantConsumptionHour:{...e.tenantConsumptionHour,loading:a.payload}};case"SET_METER_CONSUMPTION_HOUR_DATA":return{...e,tenantConsumptionHour:{...e.tenantConsumptionHour,data:a.payload.data,count:a.payload.count}};case"SET_METER_CONSUMPTION_HOUR_PAGE":return{...e,tenantConsumptionHour:{...e.tenantConsumptionHour,page:a.payload}};case"SET_METER_CONSUMPTION_HOUR_ORDERING":return{...e,tenantConsumptionHour:{...e.tenantConsumptionHour,ordering:a.payload}};case"SET_METER_CONSUMPTION_HOUR_PAGE_SIZE":return{...e,tenantConsumptionHour:{...e.tenantConsumptionHour,pageSize:a.payload}};case"SET_PROPERTY_LEVEL_CONSUMPTION_DAY_LOADING":return{...e,propertyLevelConsumptionDay:{...e.propertyLevelConsumptionDay,loading:a.payload}};case"SET_PROPERTY_LEVEL_CONSUMPTION_DAY_DATA":return{...e,propertyLevelConsumptionDay:{...e.propertyLevelConsumptionDay,data:a.payload.data,count:a.payload.count}};case"SET_PROPERTY_LEVEL_CONSUMPTION_DAY_PAGE":return{...e,propertyLevelConsumptionDay:{...e.propertyLevelConsumptionDay,page:a.payload}};case"SET_PROPERTY_LEVEL_CONSUMPTION_DAY_ORDERING":return{...e,propertyLevelConsumptionDay:{...e.propertyLevelConsumptionDay,ordering:a.payload}};case"SET_PROPERTY_LEVEL_CONSUMPTION_DAY_PAGE_SIZE":return{...e,propertyLevelConsumptionDay:{...e.propertyLevelConsumptionDay,pageSize:a.payload}};case"SET_PROPERTY_LEVEL_CONSUMPTION_HOUR_LOADING":return{...e,propertyLevelConsumptionHour:{...e.propertyLevelConsumptionHour,loading:a.payload}};case"SET_PROPERTY_LEVEL_CONSUMPTION_HOUR_DATA":return{...e,propertyLevelConsumptionHour:{...e.propertyLevelConsumptionHour,data:a.payload.data,count:a.payload.count}};case"SET_PROPERTY_LEVEL_CONSUMPTION_HOUR_PAGE":return{...e,propertyLevelConsumptionHour:{...e.propertyLevelConsumptionHour,page:a.payload}};case"SET_PROPERTY_LEVEL_CONSUMPTION_HOUR_ORDERING":return{...e,propertyLevelConsumptionHour:{...e.propertyLevelConsumptionHour,ordering:a.payload}};case"SET_PROPERTY_LEVEL_CONSUMPTION_HOUR_PAGE_SIZE":return{...e,propertyLevelConsumptionHour:{...e.propertyLevelConsumptionHour,pageSize:a.payload}};case"SET_ACTIVE_MAIN_TAB":return{...e,activeMainTab:a.payload};case"SET_ACTIVE_METER_TAB":return{...e,activeMeterTab:a.payload};case"SET_ACTIVE_PROPERTY_METER_TAB":return{...e,activePropertyMeterTab:a.payload};case"SET_BUILDING_FILTER_OPEN":return{...e,buildingFilterOpen:a.payload};case"SET_UNIT_FILTER_OPEN":return{...e,unitFilterOpen:a.payload};case"SET_COLUMNS_FILTER_OPEN":return{...e,columnsFilterOpen:a.payload};case"SET_COLUMNS_FILTER_DAY_OPEN":return{...e,columnsFilterDayOpen:a.payload};case"SET_COLUMNS_FILTER_HOUR_OPEN":return{...e,columnsFilterHourOpen:a.payload};case"SET_COLUMNS_FILTER_DAY_PROPERTY_OPEN":return{...e,columnsFilterDayPropertyOpen:a.payload};case"SET_COLUMNS_FILTER_HOUR_PROPERTY_OPEN":return{...e,columnsFilterHourPropertyOpen:a.payload};case"SET_FILTERS_LOADING":return{...e,filters:{...e.filters,loading:a.payload}};case"SET_BUILDINGS_DATA":return{...e,filters:{...e.filters,buildings:{...e.filters.buildings,data:a.payload.data,initial:a.payload.initial}}};case"SET_UNITS_DATA":return{...e,filters:{...e.filters,units:{...e.filters.units,data:a.payload.data,initial:a.payload.initial}}};case"SET_SELECTED_BUILDINGS":return{...e,filters:{...e.filters,buildings:{...e.filters.buildings,selected:a.payload}}};case"SET_SELECTED_UNITS":return{...e,filters:{...e.filters,units:{...e.filters.units,selected:a.payload}}};case"SET_METERS_FILTERS_OPEN":return{...e,metersFiltersOpen:a.payload};case"SET_METERS_FILTERS_OPTIONS":return{...e,metersFilters:{...e.metersFilters,metersOptions:a.payload}};case"SET_INITIAL_METERS_FILTERS":return{...e,metersFilters:{...e.metersFilters,initialMeters:a.payload}};case"SET_SELECTED_METERS_FILTERS":return{...e,metersFilters:{...e.metersFilters,selectedMeters:a.payload}};case"SET_METERS_FILTERS_LOADING":return{...e,metersFilters:{...e.metersFilters,loading:a.payload}};case"RESET_ALL_PAGINATION":return{...e,leakOverview:{...e.leakOverview,page:0},tenantConsumptionDay:{...e.tenantConsumptionDay,page:0},tenantConsumptionHour:{...e.tenantConsumptionHour,page:0}};case"SET_HOURLY_DRILLDOWN":return{...e,hourlyDrilldown:a.payload};case"SET_HOURLY_DRILLDOWN_DATA_LOADING":return{...e,hourlyDrilldownData:{...e.hourlyDrilldownData,loading:a.payload}};case"SET_HOURLY_DRILLDOWN_DATA":return{...e,hourlyDrilldownData:{...e.hourlyDrilldownData,data:a.payload.data,count:a.payload.count}};case"SET_HOURLY_DRILLDOWN_DATA_PAGE":return{...e,hourlyDrilldownData:{...e.hourlyDrilldownData,page:a.payload}};case"SET_HOURLY_DRILLDOWN_DATA_PAGE_SIZE":return{...e,hourlyDrilldownData:{...e.hourlyDrilldownData,pageSize:a.payload}};case"SET_HOURLY_DRILLDOWN_DATA_ORDERING":return{...e,hourlyDrilldownData:{...e.hourlyDrilldownData,ordering:a.payload}};case"RESET_HOURLY_DRILLDOWN_DATA":return{...e,hourlyDrilldownData:{data:[],loading:!1,count:0,page:0,pageSize:10,ordering:""}};case"SET_PROPERTY_HOURLY_DRILLDOWN":return{...e,propertyHourlyDrilldown:a.payload};case"SET_PROPERTY_HOURLY_DRILLDOWN_DATA_LOADING":return{...e,propertyHourlyDrilldownData:{...e.propertyHourlyDrilldownData,loading:a.payload}};case"SET_PROPERTY_HOURLY_DRILLDOWN_DATA":return{...e,propertyHourlyDrilldownData:{...e.propertyHourlyDrilldownData,data:a.payload.data,count:a.payload.count}};case"SET_PROPERTY_HOURLY_DRILLDOWN_DATA_PAGE":return{...e,propertyHourlyDrilldownData:{...e.propertyHourlyDrilldownData,page:a.payload}};case"SET_PROPERTY_HOURLY_DRILLDOWN_DATA_PAGE_SIZE":return{...e,propertyHourlyDrilldownData:{...e.propertyHourlyDrilldownData,pageSize:a.payload}};case"SET_PROPERTY_HOURLY_DRILLDOWN_DATA_ORDERING":return{...e,propertyHourlyDrilldownData:{...e.propertyHourlyDrilldownData,ordering:a.payload}};case"RESET_PROPERTY_HOURLY_DRILLDOWN_DATA":return{...e,propertyHourlyDrilldownData:{data:[],loading:!1,count:0,page:0,pageSize:10,ordering:""}};default:return e}}function T(){let[e,a]=(0,s.useReducer)(O,D);return{state:e,actions:{setPropertyInfoLoading:e=>a({type:"SET_PROPERTY_INFO_LOADING",payload:e}),setPropertyInfoData:e=>a({type:"SET_PROPERTY_INFO_DATA",payload:e}),setOverviewLoading:e=>a({type:"SET_OVERVIEW_LOADING",payload:e}),setOverviewData:e=>a({type:"SET_OVERVIEW_DATA",payload:e}),setLeakOverviewLoading:e=>a({type:"SET_LEAK_OVERVIEW_LOADING",payload:e}),setLeakOverviewData:(e,t)=>a({type:"SET_LEAK_OVERVIEW_DATA",payload:{data:e,count:t}}),setLeakOverviewPage:e=>a({type:"SET_LEAK_OVERVIEW_PAGE",payload:e}),setLeakOverviewOrdering:e=>a({type:"SET_LEAK_OVERVIEW_ORDERING",payload:e}),setLeakOverviewPageSize:e=>a({type:"SET_LEAK_OVERVIEW_PAGE_SIZE",payload:e}),setMeterLevelConsumptionDayLoading:e=>a({type:"SET_METER_CONSUMPTION_DAY_LOADING",payload:e}),setMeterLevelConsumptionDayData:(e,t)=>a({type:"SET_METER_CONSUMPTION_DAY_DATA",payload
1:{data:e,count:t}}),setMeterLevelConsumptionDayPage:e=>a({type:"SET_METER_CONSUMPTION_DAY_PAGE",payload:e}),setMeterLevelConsumptionDayOrdering:e=>a({type:"SET_METER_CONSUMPTION_DAY_ORDERING",payload:e}),setMeterLevelConsumptionDayPageSize:e=>a({type:"SET_METER_CONSUMPTION_DAY_PAGE_SIZE",payload:e}),setMeterLevelConsumptionHourLoading:e=>a({type:"SET_METER_CONSUMPTION_HOUR_LOADING",payload:e}),setMeterLevelConsumptionHourData:(e,t)=>a({type:"SET_METER_CONSUMPTION_HOUR_DATA",payload:{data:e,count:t}}),setMeterLevelConsumptionHourPage:e=>a({type:"SET_METER_CONSUMPTION_HOUR_PAGE",payload:e}),setMeterLevelConsumptionHourOrdering:e=>a({type:"SET_METER_CONSUMPTION_HOUR_ORDERING",payload:e}),setMeterLevelConsumptionHourPageSize:e=>a({type:"SET_METER_CONSUMPTION_HOUR_PAGE_SIZE",payload:e}),setPropertyLevelConsumptionDayLoading:e=>a({type:"SET_PROPERTY_LEVEL_CONSUMPTION_DAY_LOADING",payload:e}),setPropertyLevelConsumptionDayData:(e,t)=>a({type:"SET_PROPERTY_LEVEL_CONSUMPTION_DAY_DATA",payload:{data:e,count:t}}),setPropertyLevelConsumptionDayPage:e=>a({type:"SET_PROPERTY_LEVEL_CONSUMPTION_DAY_PAGE",payload:e}),setPropertyLevelConsumptionDayOrdering:e=>a({type:"SET_PROPERTY_LEVEL_CONSUMPTION_DAY_ORDERING",payload:e}),setPropertyLevelConsumptionDayPageSize:e=>a({type:"SET_PROPERTY_LEVEL_CONSUMPTION_DAY_PAGE_SIZE",payload:e}),setPropertyLevelConsumptionHourLoading:e=>a({type:"SET_PROPERTY_LEVEL_CONSUMPTION_HOUR_LOADING",payload:e}),setPropertyLevelConsumptionHourData:(e,t)=>a({type:"SET_PROPERTY_LEVEL_CONSUMPTION_HOUR_DATA",payload:{data:e,count:t}}),setPropertyLevelConsumptionHourPage:e=>a({type:"SET_PROPERTY_LEVEL_CONSUMPTION_HOUR_PAGE",payload:e}),setPropertyLevelConsumptionHourOrdering:e=>a({type:"SET_PROPERTY_LEVEL_CONSUMPTION_HOUR_ORDERING",payload:e}),setPropertyLevelConsumptionHourPageSize:e=>a({type:"SET_PROPERTY_LEVEL_CONSUMPTION_HOUR_PAGE_SIZE",payload:e}),setActiveMainTab:e=>a({type:"SET_ACTIVE_MAIN_TAB",payload:e}),setActiveMeterTab:e=>a({type:"SET_ACTIVE_METER_TAB",payload:e}),setActivePropertyMeterTab:e=>a({type:"SET_ACTIVE_PROPERTY_METER_TAB",payload:e}),setBuildingFilterOpen:e=>a({type:"SET_BUILDING_FILTER_OPEN",payload:e}),setUnitFilterOpen:e=>a({type:"SET_UNIT_FILTER_OPEN",payload:e}),setColumnsFilterOpen:e=>a({type:"SET_COLUMNS_FILTER_OPEN",payload:e}),setColumnsFilterDayOpen:e=>a({type:"SET_COLUMNS_FILTER_DAY_OPEN",payload:e}),setColumnsFilterHourOpen:e=>a({type:"SET_COLUMNS_FILTER_HOUR_OPEN",payload:e}),setColumnsFilterDayPropertyOpen:e=>a({type:"SET_COLUMNS_FILTER_DAY_PROPERTY_OPEN",payload:e}),setColumnsFilterHourPropertyOpen:e=>a({type:"SET_COLUMNS_FILTER_HOUR_PROPERTY_OPEN",payload:e}),setFiltersLoading:e=>a({type:"SET_FILTERS_LOADING",payload:e}),setBuildingsData:(e,t)=>a({type:"SET_BUILDINGS_DATA",payload:{data:e,initial:t}}),setUnitsData:(e,t)=>a({type:"SET_UNITS_DATA",payload:{data:e,initial:t}}),setSelectedBuildings:e=>a({type:"SET_SELECTED_BUILDINGS",payload:e}),setSelectedUnits:e=>a({type:"SET_SELECTED_UNITS",payload:e}),setMetersFiltersOpen:e=>a({type:"SET_METERS_FILTERS_OPEN",payload:e}),setMetersFiltersOptions:e=>a({type:"SET_METERS_FILTERS_OPTIONS",payload:e}),setInitialMetersFilters:e=>a({type:"SET_INITIAL_METERS_FILTERS",payload:e}),setSelectedMetersFilters:e=>a({type:"SET_SELECTED_METERS_FILTERS",payload:e}),setMetersFiltersLoading:e=>a({type:"SET_METERS_FILTERS_LOADING",payload:e}),resetAllPagination:()=>a({type:"RESET_ALL_PAGINATION"}),setHourlyDrilldown:e=>a({type:"SET_HOURLY_DRILLDOWN",payload:e}),setHourlyDrilldownDataLoading:e=>a({type:"SET_HOURLY_DRILLDOWN_DATA_LOADING",payload:e}),setHourlyDrilldownData:(e,t)=>a({type:"SET_HOURLY_DRILLDOWN_DATA",payload:{data:e,count:t}}),setHourlyDrilldownDataPage:e=>a({type:"SET_HOURLY_DRILLDOWN_DATA_PAGE",payload:e}),setHourlyDrilldownDataPageSize:e=>a({type:"SET_HOURLY_DRILLDOWN_DATA_PAGE_SIZE",payload:e}),setHourlyDrilldownDataOrdering:e=>a({type:"SET_HOURLY_DRILLDOWN_DATA_ORDERING",payload:e}),resetHourlyDrilldownData:()=>a({type:"RESET_HOURLY_DRILLDOWN_DATA"}),setPropertyHourlyDrilldown:e=>a({type:"SET_PROPERTY_HOURLY_DRILLDOWN",payload:e}),setPropertyHourlyDrilldownDataLoading:e=>a({type:"SET_PROPERTY_HOURLY_DRILLDOWN_DATA_LOADING",payload:e}),setPropertyHourlyDrilldownData:(e,t)=>a({type:"SET_PROPERTY_HOURLY_DRILLDOWN_DATA",payload:{data:e,count:t}}),setPropertyHourlyDrilldownDataPage:e=>a({type:"SET_PROPERTY_HOURLY_DRILLDOWN_DATA_PAGE",payload:e}),setPropertyHourlyDrilldownDataPageSize:e=>a({type:"SET_PROPERTY_HOURLY_DRILLDOWN_DATA_PAGE_SIZE",payload:e}),setPropertyHourlyDrilldownDataOrdering:e=>a({type:"SET_PROPERTY_HOURLY_DRILLDOWN_DATA_ORDERING",payload:e}),resetPropertyHourlyDrilldownData:()=>a({type:"RESET_PROPERTY_HOURLY_DRILLDOWN_DATA"})}}}
1function I(e){let{columns:a,initialVisibleColumns:t,initialColumnOrder:l}=e,[r,n]=(0,s.useState)(t),[i,o]=(0,s.useState)(l),d=a.filter(e=>"string"==typeof e.id&&"actions"!==e.id).sort((e,a)=>i.indexOf(e.id)-i.indexOf(a.id)).map(e=>{var a;return{value:e.id,label:"string"==typeof e.header&&""!==e.header?e.header:(null==(a=e.meta)?void 0:a.name)||""}}),c=Object.fromEntries(i.map(e=>[e,r.includes(e)]));return{selectedColumns:r,setSelectedColumns:n,orderedColumns:i,setOrderedColumns:o,columnOptions:d,columnVisibility:c}}function P(e,a){let[t,l]=(0,s.useState)(()=>{try{let t=localStorage.getItem(e);return t?JSON.parse(t):a}catch(e){return a}});return(0,s.useEffect)(()=>{localStorage.setItem(e,JSON.stringify(t))},[e,t]),[t,l]}let R="gateway_filters";function M(e){var a;let{organizations:t,onPaginationReset:l,initialOverride:r}=e,n=null!=(a=null==r?void 0:r.deviceType)?a:[],[i,o]=(0,s.useState)(!1),[d,c]=(0,s.useState)(!1),[m,u]=(0,s.useState)(!1),[p,x]=(0,s.useState)(!0),[h,g]=(0,s.useState)([]),[y,f]=(0,s.useState)([]),[b,v]=(0,s.useState)([]),[N,j]=(0,s.useState)([]),[_,w]=(0,s.useState)(n),[k,C]=(0,s.useState)(n),[S,E]=(0,s.useState)("");return(0,s.useEffect)(()=>{let e=localStorage.getItem(R);e&&JSON.parse(e).date,x(!1)},[t]),(0,s.useEffect)(()=>{p||localStorage.setItem(R,JSON.stringify({selectedBuilding:h,selectedStatus:b,selectedDeviceType:_}))},[h,b,_,p]),{isBuildingOpen:i,isStatusOpen:d,isDeviceTypeOpen:m,handleBuildingOpenChange:e=>{o(e)},handleStatusOpenChange:e=>{c(e)},handleDeviceTypeOpenChange:e=>{u(e)},selectedBuilding:h,tempSelectedBuilding:y,selectedStatus:b,tempSelectedStatus:N,selectedDeviceType:_,tempSelectedDeviceType:k,buildingSearch:S,handleBuildingChange:e=>{f(e)},handleStatusChange:e=>{j(e)},handleDeviceTypeChange:e=>{C(e)},handleBuildingSearchChange:e=>{E(e)},handleApplyBuilding:()=>{g(y),E(""),o(!1),null==l||l()},handleApplyStatus:()=>{v(N),c(!1),null==l||l()},handleApplyDeviceType:()=>{w(k),u(!1),null==l||l()},handleResetBuilding:()=>{f([]),g([]),E(""),o(!1),null==l||l()},handleResetStatus:()=>{j([]),v([]),c(!1),null==l||l()},handleResetDeviceType:()=>{C([]),w([]),u(!1),null==l||l()},handleResetAll:()=>{g([]),f([]),v([]),j([]),w([]),C([]),E(""),null==l||l()}}}var G=t(41794),z=t(8505),F=t(58873);function H(e){let{storageKey:a,selectedOrganizations:t,selectedProperties:l,buildingId:r,unitId:n,onPaginationReset:i}=e,[o,d]=(0,s.useState)(r?[r]:[]),[c,m]=(0,s.useState)(n?[n]:[]),[u,p]=(0,s.useState)(!1),x=(0,s.useRef)(""),h=(0,s.useRef)(""),g=(0,s.useRef)(!1),y=(0,s.useRef)(!1),f=(0,s.useRef)(null),b=(0,s.useRef)(!1),v=(0,s.useRef)(null),[N,j]=(0,s.useState)({data:[],loading:!1,initial:[]}),[_,w]=(0,s.useState)({data:[],loading:!1,initial:[]}),k="".concat(a,"_building_unit_filters"),C=(0,s.useCallback)(()=>{try{let e=localStorage.getItem(k);return e?JSON.parse(e):null}catch(e){return console.warn("Failed to read building/unit filters from localStorage:",e),null}},[k]),S=(0,s.useCallback)(e=>{try{localStorage.setItem(k,JSON.stringify(e))}catch(e){console.warn("Failed to save building/unit filters to localStorage:",e)}},[k]),E=(0,s.useCallback)(e=>{let a={organizations:[...t].sort(),properties:[...l].sort()},s={organizations:[...e.context.organizations].sort(),properties:[...e.context.properties].sort()};return JSON.stringify(a.organizations)===JSON.stringify(s.organizations)&&JSON.stringify(a.properties)===JSON.stringify(s.properties)},[t,l]),L=(0,s.useCallback)(async()=>{if(0===t.length||1!==l.length)return void j({data:[],loading:!1,initial:[]});try{j(e=>({...e,loading:!0}));let e=await z.FH.inventory.filters.getBuildings({organization_id:t.map(e=>parseInt(e,10)),property_id:l.map(e=>parseInt(e,10))}),a=e.map(e=>({value:e.id.toString(),label:e.name})),s=e.map(e=>e.id.toString());j({data:a,loading:!1,initial:s})}catch(e){console.error("Error fetching building filters:",e),(0,F.N)("Failed to load building filters","Unable to fetch building filters data. Please try again."),j({data:[],loading:!1,initial:[]})}},[t,l]),A=(0,s.useCallback)(async()=>{if(0===t.length||1!==l.length||0===o.length)return void w({data:[],loading:!1,initial:[]});try{w(e=>({...e,loading:!0}));let e=await z.FH.inventory.filters.getUnits({organization_id:t.map(e=>parseInt(e,10)),property_id:l.map(e=>parseInt(e,10)),building_id:o.map(e=>parseInt(e,10))}),a=e.map(e=>({value:e.id.toString(),label:e.name})),s=e.map(e=>e.id.toString());w({data:a,loading:!1,initial:s})}catch(e){console.error("Error fetching unit filters:",e),(0,F.N)("Failed to load unit filters","Unable to fetch unit filters data. Please try again."),w({data:[],loading:!1,initial:[]})}},[t,l,o]);return(0,s.useEffect)(()=>{let e=JSON.stringify({organization_id:t,property_id:l});e!==x.current&&(x.current=e,L())},[L,t,l]),(0,s.useEffect)(()=>{let e=JSON.stringify({organization_id:t,property_id:l,...o.length>0&&{building_id:o}});e!==h.current&&(h.current=e,A())},[A,t,l,o]),(0,s.useEffect)(()=>{b.current||(b.current=!0,f.current=C())},[C]),(0,s.useEffect)(()=>
1{if(u||N.loading||_.loading)return;let e=N.data.length>0,a=_.data.length>0;if(e&&a){let e=C();e&&E(e)?(d(e.selections.buildings),m(e.selections.units)):(d([]),m([])),r&&N.data.some(e=>e.value===r)&&(d([r]),m([])),n&&_.data.some(e=>e.value===n)&&(m([n]),r||d([]))}p(!0)},[C,E,N.data,N.loading,_.data,_.loading,r,n]),(0,s.useEffect)(()=>{if(g.current||N.loading||0===N.data.length)return;if(g.current=!0,r&&N.data.some(e=>e.value===r))return void d([r]);let e=f.current;if(e&&E(e)){let a=e.selections.buildings.filter(e=>N.data.some(a=>a.value===e));a.length>0&&d(a)}},[N.data,N.loading,r,E]),(0,s.useEffect)(()=>{if(y.current||_.loading||0===_.data.length)return;if(y.current=!0,n&&_.data.some(e=>e.value===n))return void m([n]);let e=f.current;if(e&&E(e)){let a=e.selections.units.filter(e=>_.data.some(a=>a.value===e));a.length>0&&m(a)}},[_.data,_.loading,n,E]),(0,s.useEffect)(()=>{u&&0!==N.data.length&&0!==_.data.length&&S({context:{organizations:t,properties:l},selections:{buildings:o,units:c}})},[o,c,t,l,u,S,N.data,_.data]),(0,s.useEffect)(()=>{if(!u)return;let e=JSON.stringify({organizations:[...t].sort(),properties:[...l].sort()});if(null===v.current){v.current=e;return}e!==v.current&&(v.current=e,d([]),m([]),p(!1))},[t,l,u]),(0,s.useEffect)(()=>{let e=N.data.map(e=>e.value);d(a=>{let t=a.filter(a=>e.includes(a));return t.length!==a.length?t:a})},[N.data]),(0,s.useEffect)(()=>{let e=_.data.map(e=>e.value);m(a=>{let t=a.filter(a=>e.includes(a));return t.length!==a.length?t:a})},[_.data]),{selectedBuildings:o,setSelectedBuildings:(0,s.useCallback)(e=>{d(e),null==i||i()},[i]),selectedUnits:c,setSelectedUnits:(0,s.useCallback)(e=>{m(e),null==i||i()},[i]),buildingFilters:N,unitFilters:_,isInitialized:u}}var V=t(13016),U=t(77888),B=t(12516);t(13553);let K={selectedOrganizationId:null,selectedPropertyIds:[],grain:"monthly",phase:"both",utility:"water",coverage:"installed",constructionType:null,rollup:{data:null,loading:!1},prePost:{data:null,loading:!1},rows:{data:null,loading:!1},page:0,pageSize:25,expandedPropertyId:null,chartOpen:!1,periodsOpen:!1,openPeriodKey:null,openPeriodDetailKind:null,panels:{},periodDetails:{},meterHealth:{}};function W(e,a){var t,l,s,r,n,i;switch(a.type){case"SET_GRAIN":return{...e,grain:a.payload,expandedPropertyId:null,chartOpen:!1,periodsOpen:!1,openPeriodKey:null,openPeriodDetailKind:null,panels:{},periodDetails:{},meterHealth:{}};case"SET_FILTERS":return{...e,...void 0!==a.payload.organizationId&&{selectedOrganizationId:a.payload.organizationId,selectedPropertyIds:[],rollup:{...e.rollup,data:null},prePost:{...e.prePost,data:null},rows:{...e.rows,data:null}},...void 0!==a.payload.propertyIds&&{selectedPropertyIds:a.payload.propertyIds},...void 0!==a.payload.phase&&{phase:a.payload.phase},...void 0!==a.payload.utility&&{utility:a.payload.utility},...void 0!==a.payload.coverage&&{coverage:a.payload.coverage},...void 0!==a.payload.constructionType&&{constructionType:a.payload.constructionType},page:0,expandedPropertyId:null,chartOpen:!1,periodsOpen:!1,openPeriodKey:null,openPeriodDetailKind:null,panels:{},periodDetails:{},meterHealth:{}};case"SET_ROLLUP_LOADING":return{...e,rollup:{...e.rollup,loading:a.payload}};case"SET_ROLLUP_DATA":return{...e,rollup:{...e.rollup,data:a.payload}};case"SET_PRE_POST_LOADING":return{...e,prePost:{...e.prePost,loading:a.payload}};case"SET_PRE_POST_DATA":return{...e,prePost:{...e.prePost,data:a.payload}};case"SET_ROWS_LOADING":return{...e,rows:{...e.rows,loading:a.payload}};case"SET_ROWS_DATA":return{...e,rows:{...e.rows,data:a.payload}};case"SET_PAGE":return{...e,page:a.payload,expandedPropertyId:null,chartOpen:!1,periodsOpen:!1,openPeriodKey:null,openPeriodDetailKind:null,panels:{},periodDetails:{},meterHealth:{}};case"SET_PAGE_SIZE":return{...e,pageSize:a.payload,page:0,expandedPropertyId:null,chartOpen:!1,periodsOpen:!1,openPeriodKey:null,openPeriodDetailKind:null,panels:{},periodDetails:{},meterHealth:{}};case"TOGGLE_PROPERTY_DISCLOSURE":{let{propertyId:t,disclosure:l}=a.payload;if(t!==e.expandedPropertyId)return{...e,expandedPropertyId:t,chartOpen:"chart"===l,periodsOpen:"periods"===l,openPeriodKey:null,openPeriodDetailKind:null,periodDetails:{},meterHealth:{}};let s="chart"===l?!e.chartOpen:e.chartOpen,r="periods"===l?!e.periodsOpen:e.periodsOpen;if(!s&&!r)return{...e,expandedPropertyId:null,chartOpen:!1,periodsOpen:!1,openPeriodKey:null,openPeriodDetailKind:null,periodDetails:{},meterHealth:{}};return{...e,chartOpen:s,periodsOpen:r}}case"SET_OPEN_PERIOD":return{...e,openPeriodKey:a.payload.key,openPeriodDetailKind:a.payload.kind};case"SET_PANEL_LOADING":{let{key:l,grain:s,loading:r}
1=a.payload,n=null!=(t=e.panels[l])?t:{...function(e){switch(e){case"yearly":case"monthly":case"bills":return{grain:e,data:null}}}(s),loading:!1};return{...e,panels:{...e.panels,[l]:{...n,loading:r}}}}case"SET_PANEL_DATA":{let{key:t,...r}=a.payload;return{...e,panels:{...e.panels,[t]:{...r,loading:null!=(s=null==(l=e.panels[t])?void 0:l.loading)&&s}}}}case"SET_PERIOD_DETAIL_LOADING":{let{key:t,grain:l,kind:s,loading:n}=a.payload,i=null!=(r=e.periodDetails[t])?r:{...function(e,a){switch(e){case"yearly":return{grain:e,kind:"months",data:null};case"monthly":return{grain:e,kind:"daily",data:null};case"bills":return"read-dates"===a?{grain:e,kind:a,data:null}:{grain:e,kind:"daily",data:null}}}(l,s),loading:!1};return{...e,periodDetails:{...e.periodDetails,[t]:{...i,loading:n}}}}case"SET_PERIOD_DETAIL_DATA":{let{key:t,...l}=a.payload;return{...e,periodDetails:{...e.periodDetails,[t]:{...l,loading:null!=(i=null==(n=e.periodDetails[t])?void 0:n.loading)&&i}}}}case"SET_METER_HEALTH_LOADING":return{...e,meterHealth:{...e.meterHealth,[a.payload.key]:{data:null,loading:!0,failed:!1}}};case"SET_METER_HEALTH_RESULT":{let{key:t,data:l}=a.payload;if(!(t in e.meterHealth))return e;return{...e,meterHealth:{...e.meterHealth,[t]:{data:l,loading:!1,failed:null===l}}}}default:return e}}function Y(){let[e,a]=(0,s.useReducer)(W,K);return{state:e,actions:(0,s.useMemo)(()=>({setGrain:e=>a({type:"SET_GRAIN",payload:e}),setFilters:e=>a({type:"SET_FILTERS",payload:e}),setRollupLoading:e=>a({type:"SET_ROLLUP_LOADING",payload:e}),setRollupData:e=>a({type:"SET_ROLLUP_DATA",payload:e}),setPrePostLoading:e=>a({type:"SET_PRE_POST_LOADING",payload:e}),setPrePostData:e=>a({type:"SET_PRE_POST_DATA",payload:e}),setRowsLoading:e=>a({type:"SET_ROWS_LOADING",payload:e}),setRowsData:e=>a({type:"SET_ROWS_DATA",payload:e}),setPage:e=>a({type:"SET_PAGE",payload:e}),setPageSize:e=>a({type:"SET_PAGE_SIZE",payload:e}),togglePropertyDisclosure:(e,t)=>a({type:"TOGGLE_PROPERTY_DISCLOSURE",payload:{propertyId:e,disclosure:t}}),setOpenPeriod:function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return a({type:"SET_OPEN_PERIOD",payload:{key:e,kind:t}})},setPanelLoading:(e,t,l)=>a({type:"SET_PANEL_LOADING",payload:{key:e,grain:t,loading:l}}),setPanelData:(e,t)=>a({type:"SET_PANEL_DATA",payload:{key:e,...t}}),setPeriodDetailLoading:(e,t,l,s)=>a({type:"SET_PERIOD_DETAIL_LOADING",payload:{key:e,grain:t,kind:l,loading:s}}),setPeriodDetailData:(e,t)=>a({type:"SET_PERIOD_DETAIL_DATA",payload:{key:e,...t}}),setMeterHealthLoading:e=>a({type:"SET_METER_HEALTH_LOADING",payload:{key:e}}),setMeterHealthResult:(e,t)=>a({type:"SET_METER_HEALTH_RESULT",payload:{key:e,data:t}})}),[])}}var $=t(20063);let Z=["organization_id","property_id","phase","utility","coverage","construction_type"];function q(e,a){let t=(0,$.useRouter)(),l=(0,$.useSearchParams)(),r=(0,s.useRef)(!1);(0,s.useEffect)(()=>{if(r.current)return;r.current=!0;let e={},t=l.getAll("property_id");t.length>0&&(e.propertyIds=t);let s=l.get("phase");("pre"===s||"post"===s||"both"===s)&&(e.phase=s);let n=l.get("utility");("water"===n||"sewer"===n||"storm_water"===n||"irrigation"===n)&&(e.utility=n);let i=l.get("coverage");("installed"===i||"not_installed"===i||"all"===i)&&(e.coverage=i);let o=l.get("construction_type");("new_construction"===o||"operating"===o||"unknown"===o)&&(e.constructionType=o),Object.keys(e).length>0&&a(e)},[l,a]),(0,s.useEffect)(()=>{if(!r.current||!e.organizationId)return;let a=new URLSearchParams;a.set("organization_id",e.organizationId),e.propertyIds.forEach(e=>a.append("property_id",e)),"both"!==e.phase&&a.set("phase",e.phase),a.set("utility",e.utility),a.set("coverage",e.coverage),e.constructionType&&a.set("construction_type",e.constructionType);let s=new URLSearchParams;Z.forEach(e=>l.getAll(e).forEach(a=>s.append(e,a))),s.toString()!==a.toString()&&t.replace("?".concat(a.toString()),{scroll:!1})},[e,t,l])}var J=t(37193),X=t(40170);function Q(){let e=(0,$.usePathname)(),[a,t]=(0,s.useState)({gallonsDailyUpdate:"",deviceHealthUpdate:"",isLoading:!0,error:null}),l=async()=>{try{let e=await J.lZ.getJobsOverview(),a=(0,X.aI)(e);t({...a,isLoading:!1,error:null})}catch(e){t({gallonsDailyUpdate:"Unknown",deviceHealthUpdate:"Unknown",isLoading:!1,error:e})}};return(0,s.useEffect)(()=>
1{l()},[e]),a}t(34107);var ee=t(1800);function ea(e){let{hasStaffAccess:a}=e,[t,l]=(0,s.useState)([]),[r,n]=(0,s.useState)(0),[i,o]=(0,s.useState)(0),[d,c]=(0,s.useState)(""),[m,u]=(0,s.useState)(10),[p,x]=(0,s.useState)(0),[h,g]=(0,s.useState)(!1),[y,f]=(0,s.useState)([]),[b,v]=(0,s.useState)(!1),[N,j]=(0,s.useState)([]),[_,w]=(0,s.useState)(!1),k=(0,s.useCallback)(()=>({page:i+1,page_size:m,...d&&{ordering:d},...N.length>0&&{status:N}}),[i,m,d,N]),C=(0,s.useCallback)(async()=>{try{g(!0);let e=k(),a=await ee.d.getReportsHistory(e);l(a.results),n(a.count)}catch(e){console.error("Failed to fetch reports:",e),(0,F.N)("Failed to fetch reports",void 0,C)}finally{g(!1)}},[k]),S=(0,s.useCallback)(()=>{x(e=>e+1)},[]);(0,s.useEffect)(()=>{a&&C()},[C,p,a]);let E=(0,s.useRef)(h);return(0,s.useEffect)(()=>{E.current=h},[h]),(0,s.useEffect)(()=>{if(!a)return;let e=window.document,t=null,l=()=>{null===t&&(t=window.setInterval(()=>{E.current||S()},6e4))},s=()=>{null!==t&&(window.clearInterval(t),t=null)},r=()=>{if(e.hidden)return void s();E.current||S(),l()};return e.hidden||l(),e.addEventListener("visibilitychange",r),()=>{s(),e.removeEventListener("visibilitychange",r)}},[a,S]),(0,s.useEffect)(()=>{let e=async()=>{try{v(!0);let e=await z.FH.common.getEnums();f(e.results.export_report_statuses)}catch(e){console.error("Failed to fetch export report statuses:",e)}finally{v(!1)}};a&&e()},[a]),{reports:t,totalCount:r,page:i,pageSize:m,ordering:d,isLoadingReports:h,exportReportStatuses:y,isLoadingStatuses:b,selectedStatuses:N,isStatusFilterOpen:_,setSelectedStatuses:j,setIsStatusFilterOpen:w,handleSort:e=>{c(e),o(0)},handlePageChange:e=>{o(e)},handlePageSizeChange:e=>{u(e)},handleStatusFilterApply:()=>{o(0)},handleStatusFilterReset:()=>{o(0)},refresh:S,buildReportsParams:k}}var et=t(22544),el=t(73730);let es="report_excel_yesterday",er="report_excel_historical",en=[es,er];function ei(e){let{hasStaffAccess:a,organizations:t,isOrgAdminOrMember:r,activeOrganization:n,onSuccess:i}=e,[o,d]=(0,s.useState)([]),c=(0,s.useRef)([]),[m,u]=(0,s.useState)([]),p=(0,s.useCallback)(e=>{c.current=e,u(e)}
1,[]),[x,h]=(0,s.useState)([]),g=(0,s.useRef)([]),[y,f]=(0,s.useState)([]),b=(0,s.useCallback)(e=>{g.current=e,f(e)},[]),[v,N]=(0,s.useState)([]),j=(0,s.useRef)([]),[_,w]=(0,s.useState)([]),k=(0,s.useCallback)(e=>{j.current=e,w(e)},[]),[C,S]=(0,s.useState)([]),E=(0,s.useRef)([]),[L,A]=(0,s.useState)([]),D=(0,s.useCallback)(e=>{E.current=e,A(e)},[]),[O,T]=(0,s.useState)([]),[I,P]=(0,s.useState)(!1),[R,M]=(0,s.useState)(es),[G,H]=(0,s.useState)([]),V=(0,s.useRef)([]),[U,B]=(0,s.useState)([]),K=(0,s.useCallback)(e=>{V.current=e,B(e)},[]),[W,Y]=(0,s.useState)({from:void 0,to:void 0}),[$,Z]=(0,s.useState)({from:void 0,to:void 0}),[q,J]=(0,s.useState)(!1),[X,Q]=(0,s.useState)(!1),{control:ea,setValue:ei}=(0,et.mN)({defaultValues:{organizations:[],properties:[],buildings:[],units:[],reportsTypes:[]}}),{propertyOptions:eo,allPropertyOptions:ed,owningOrganizationIds:ec,isLoadingProperties:em,buildingOptions:eu,isLoadingBuildings:ep,unitOptions:ex,isLoadingUnits:eh}=function(e){let{selectedOrganizations:a,selectedProperties:t,selectedBuildings:l}=e,[r,n]=(0,s.useState)([]),[i,o]=(0,s.useState)(!1),[d,c]=(0,s.useState)([]),[m,u]=(0,s.useState)(!1),[p,x]=(0,s.useState)([]),[h,g]=(0,s.useState)(!1);(0,s.useEffect)(()=>{let e=!1;return(async()=>{try{o(!0);let a=await z.FH.inventory.filters.getProperties();e||n(a)}catch(a){console.error("Failed to fetch properties for filters:",a),e||((0,F.N)("Failed to load properties","Unable to fetch property filter options."),n([]))}finally{e||o(!1)}})(),()=>{e=!0}},[]);let y=e=>({label:e.name,value:e.id.toString()}),f=(e,a)=>e.label.localeCompare(a.label),b=(0,s.useMemo)(()=>{let e=new Set(a);return r.filter(a=>e.has(String(a.organization_id)))},[r,a]),v=(0,s.useMemo)(()=>b.map(y).sort(f),[b]),N=(0,s.useMemo)(()=>r.map(y).sort(f),[r]),j=(0,s.useCallback)(e=>{let a=new Set(e),t=new Set;return r.forEach(e=>{a.has(e.id.toString())&&t.add(String(e.organization_id))}),[...t]},[r]);(0,s.useEffect)(()=>{let e=!1;return(async()=>{if(0===a.length||1!==t.length)return c([]);try{u(!0);let l=await z.FH.inventory.filters.getBuildings({organization_id:a.map(e=>parseInt(e)),property_id:t.map(e=>parseInt(e))});e||c(l)}catch(a){console.error("Failed to fetch buildings for filters:",a),e||((0,F.N)("Failed to load buildings","Unable to fetch building filter options."),c([]))}finally{e||u(!1)}})(),()=>{e=!0}},[a,t]);let _=(0,s.useMemo)(()=>d.map(e=>({label:"".concat(e.property_name," - ").concat(e.name),value:e.id.toString()})).sort((e,a)=>e.label.localeCompare(a.label)),[d]);return(0,s.useEffect)(()=>{let e=!1;return(async()=>{if(0===a.length||1!==t.length||0===l.length)return x([]);try{g(!0);let s=await z.FH.inventory.filters.getUnits({organization_id:a.map(e=>parseInt(e)),property_id:t.map(e=>parseInt(e)),building_id:l.map(e=>parseInt(e))});e||x(s)}catch(a){console.error("Failed to fetch units for filters:",a),e||((0,F.N)("Failed to load units","Unable to fetch unit filter options."),x([]))}finally{e||g(!1)}})(),()=>{e=!0}},[a,t,l]),{propertyOptions:v,allPropertyOptions:N,owningOrganizationIds:j,isLoadingProperties:i,buildingOptions:_,isLoadingBuildings:m,unitOptions:(0,s.useMemo)(()=>p.map(e=>({label:"".concat(e.property_name," - ").concat(e.building_name," - ").concat(e.name),value:e.id.toString()})).sort((e,a)=>e.label.localeCompare(a.label)),[p]),isLoadingUnits:h}}({selectedOrganizations:o,selectedProperties:x,selectedBuildings:v}),eg=(0,s.useRef)(!1),ey=(0,s.useRef)(!1),ef=(0,s.useRef)(!1),eb=(0,s.useRef)(!1);(0,s.useEffect)(()=>{eg.current=!1,ey.current=!1},[x]),(0,s.useEffect)(()=>{ef.current=!1},[t]),(0,s.useEffect)(()=>{if(1===t.length&&0===o.length&&!ef.current){let e=t[0].id.toString();d([e]),p([e]),ei("organizations",[e]),ef.current=!0}},[t,o.length,p,ei]),(0,s.useEffect)(()=>{eb.current=!1},[eo]),(0,s.useEffect)(()=>{if(1===eo.length&&0===x.length&&!eb.current){let e=eo[0].value;h([e]),b([e]),ei("properties",[e]),eb.current=!0}},[eo,x.length,b,ei]),(0,s.useEffect)(()=>{if(1===x.length&&eu.length>0&&!eg.current){let e=eu.map(e=>e.value);N(e),k(e),ei("buildings",e),eg.current=!0}},[x.length,eu,k,ei]),(0,s.useEffect)(()=>
1{if(1===x.length&&ex.length>0&&!ey.current){let e=ex.map(e=>e.value);S(e),D(e),ei("units",e),ey.current=!0}},[x.length,ex,D,ei]);let ev=(0,s.useMemo)(()=>{let e=e=>{let a=en.indexOf(e);return -1===a?en.length:a};return[...O].sort((a,t)=>e(a.type)-e(t.type))},[O]),eN=(0,s.useMemo)(()=>{let e=O.find(e=>e.type===R);return e?e.content.map(e=>({label:e.name,value:e.type})).sort((e,a)=>e.label.localeCompare(a.label)):[]},[O,R]),ej=R===er,e_=!o.length||!x.length||!G.length||ej&&(!W.from||!W.to)||I||em||X,ew=(0,s.useCallback)(e=>{JSON.stringify([...e].sort())!==JSON.stringify([...o].sort())&&(d(e),ei("organizations",e),h([]),b([]),ei("properties",[]),N([]),k([]),ei("buildings",[]),S([]),D([]),ei("units",[]))},[o,ei]),ek=(0,s.useCallback)(e=>{if(JSON.stringify([...e].sort())!==JSON.stringify([...x].sort())){h(e),ei("properties",e),N([]),k([]),ei("buildings",[]),S([]),D([]),ei("units",[]);let a=ec(e),t=a.length!==o.length||a.some(e=>!o.includes(e));a.length>0&&t&&(d(a),p(a),ei("organizations",a))}},[ec,o,x,k,p,D,ei]),eC=(0,s.useCallback)(e=>{H(e)},[]),eS=(0,s.useCallback)(e=>{JSON.stringify([...e].sort())!==JSON.stringify([...v].sort())&&(N(e),ei("buildings",e),S([]),D([]),ei("units",[]))},[v,D,ei]),eE=(0,s.useCallback)(e=>{JSON.stringify([...e].sort())!==JSON.stringify([...C].sort())&&(S(e),ei("units",e))},[C,S,ei]),eL=(0,s.useCallback)(()=>{ew(c.current)},[ew]),eA=(0,s.useCallback)(()=>{ek(g.current)},[ek]),eD=(0,s.useCallback)(()=>{eS(j.current)},[eS]),eO=(0,s.useCallback)(()=>{eE(E.current)},[eE]),eT=(0,s.useCallback)(()=>{eC(V.current)},[eC]),eI=(0,s.useCallback)(e=>{e!==R&&(M(e),H([]),K([]),ei("reportsTypes",[]),e===es&&(Y({from:void 0,to:void 0}),Z({from:void 0,to:void 0}),J(!1)))},[R,ei]),eP=async()=>{try{Q(!0);let e=eo.length>0&&x.length===eo.length,a=eu.length>0&&v.length===eu.length,t=ex.length>0&&C.length===ex.length,s={report_type:R,report_content:G,organization_ids:o.map(e=>parseInt(e)),property_ids:e?[]:x.map(e=>parseInt(e)),building_ids:a?[]:v.map(e=>parseInt(e)),unit_ids:t?[]:C.map(e=>parseInt(e))};ej&&W.from&&W.to&&(s.from_date=(0,el.GP)(W.from,"yyyy-MM-dd"),s.to_date=(0,el.GP)(W.to,"yyyy-MM-dd")),await ee.d.createExportReport(s),(0,l.oR)({title:"Report requested!",description:"Your report is being generated. Check the history below for status.",className:"bg-green-200 border-green-200 text-brand-black"}),null==i||i()}catch(e){console.error("Failed to generate report:",e),(0,F.N)("Failed to generate report",void 0,eP)}finally{Q(!1)}},eR=(0,s.useCallback)(()=>{r||(d([]),p([]),ei("organizations",[])),h([]),b([]),ei("properties",[]),N([]),k([]),ei("buildings",[]),S([]),D([]),ei("units",[]),H([]),K([]),ei("reportsTypes",[]),Y({from:void 0,to:void 0}),Z({from:void 0,to:void 0}),J(!1),M(es)},[r,N,S,ei]);return(0,s.useEffect)(()=>{let e=async()=>{try{P(!0);let e=await ee.d.getReportsTypes();T(e.results)}catch(e){console.error("Failed to fetch reports types:",e)}finally{P(!1)}};a&&e()},[a]),(0,s.useEffect)(()=>{0!==O.length&&(O.some(e=>e.type===R)||M(ev[0].type))},[O,R,ev]),(0,s.useEffect)(()=>{if(r&&n){let e=n.id.toString();d([e]),p([e]),ei("organizations",[e])}},[r,n,p,ei]),{organizations:t,selectedOrganizations:o,tempSelectedOrganizations:m,setTempSelectedOrganizations:p,handleOrganizationsChange:ew,commitTempOrganizations:eL,propertyOptions:eo,allPropertyOptions:ed,selectedProperties:x,tempSelectedProperties:y,setTempSelectedProperties:b,handlePropertiesChange:ek,commitTempProperties:eA,isLoadingProperties:em,buildingOptions:eu,isLoadingBuildings:ep,selectedBuildings:v,tempSelectedBuildings:_,setTempSelectedBuildings:k,handleBuildingsChange:eS,commitTempBuildings:eD,unitOptions:ex,isLoadingUnits:eh,selectedUnits:C,tempSelectedUnits:L,setTempSelectedUnits:D,handleUnitsChange:eE,commitTempUnits:eO,control:ea,reportsTypes:O,orderedReportsTypes:ev,activeReportType:R,handleActiveReportTypeChange:eI,requiresDateRange:ej,isLoadingReportsTypes:I,contentOptions:eN,selectedContents:G,tempSelectedContents:U,setTempSelectedContents:K,handleContentsChange:eC,commitTempContents:eT,dateRange:W,tempDateRange:$,isCalendarOpen:q,handleCalendarOpenChange:e=>{J(e),e&&Z(W)},handleTempDateRangeChange:e=>{Z(e)},handleDateRangeReset:()=>{Y({from:void 0,to:void 0}),Z({from:void 0,to:void 0}),J(!1)},handleDateRangeApply:()=>{Y($),J(!1)},isGenerating:X,isDisabled:e_,handleGenerate:eP,handleReset:eR,isOrgAdminOrMember:r}}},64269:(e,a,t)=>{t.d(a,{cn:()=>r});
1var l=t(2821),s=t(75889);function r(){for(var e=arguments.length,a=Array(e),t=0;t<e;t++)a[t]=arguments[t];return(0,s.QP)((0,l.$)(a))}},64789:(e,a,t)=>{t.d(a,{v:()=>l});function l(e){return"$".concat((null!=e?e:0).toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2}))}},71414:(e,a,t)=>{t.d(a,{x:()=>f});var l=t(95155),s=t(12115),r=t(90368),n=t(27937),i=t(37772),o=t(64269),d=t(3998);let c=e=>{let{className:a,...t}=e;return(0,l.jsx)("nav",{role:"navigation","aria-label":"pagination",className:(0,o.cn)("mx-auto flex w-full justify-center",a),...t})};c.displayName="Pagination";let m=s.forwardRef((e,a)=>{let{className:t,...s}=e;return(0,l.jsx)("ul",{ref:a,className:(0,o.cn)("flex flex-row items-center gap-1",t),...s})});m.displayName="PaginationContent";let u=s.forwardRef((e,a)=>{let{className:t,...s}=e;return(0,l.jsx)("li",{ref:a,className:(0,o.cn)("",t),...s})});u.displayName="PaginationItem";let p=e=>{let{className:a,isActive:t,size:s="icon",...r}=e;return(0,l.jsx)("a",{"aria-current":t?"page":void 0,className:(0,o.cn)((0,d.r)({variant:t?"quaternary1":"ghost",size:s}),a),...r})};p.displayName="PaginationLink";let x=e=>{let{className:a,...t}=e;return(0,l.jsxs)(p,{"aria-label":"Go to previous page",size:"default",className:(0,o.cn)("gap-1 pl-2.5",a),...t,children:[(0,l.jsx)(r.A,{className:"h-4 w-4"}),(0,l.jsx)("span",{children:"Previous"})]})};x.displayName="PaginationPrevious";let h=e=>{let{className:a,...t}=e;return(0,l.jsxs)(p,{"aria-label":"Go to next page",size:"default",className:(0,o.cn)("gap-1 pr-2.5",a),...t,children:[(0,l.jsx)("span",{children:"Next"}),(0,l.jsx)(n.A,{className:"h-4 w-4"})]})};h.displayName="PaginationNext";let g=e=>{let{className:a,...t}=e;return(0,l.jsxs)("span",{"aria-hidden":!0,className:(0,o.cn)("flex h-9 w-9 items-center justify-center",a),...t,children:[(0,l.jsx)(i.A,{className:"h-4 w-4"}),(0,l.jsx)("span",{className:"sr-only",children:"More pages"})]})};g.displayName="PaginationEllipsis";var y=t(27331);function f(e){let{pageIndex:a,pageCount:t,onPageChange:s,isLoading:r=!1,className:n,showPageSizeSelector:i=!1,pageSize:d=10,onPageSizeChange:f,pageSizeOptions:b=[10,25,50],menuPlacement:v="auto"}=e;if(t<=1&&!i)return null;let N=b.map(e=>({value:e.toString(),label:e.toString()}));return(0,l.jsx)("div",{className:(0,o.cn)("flex items-center justify-between mt-4",n),children:t>=1&&(0,l.jsxs)(c,{className:(0,o.cn)(r&&"pointer-events-none opacity-50",i&&"flex-col md:flex-row items-center"),children:[(0,l.jsxs)(m,{children:[(0,l.jsx)(u,{children:(0,l.jsx)(x,{href:"#",onClick:e=>{e.preventDefault(),s(a-1)},"aria-disabled":0===a,className:0===a?"pointer-events-none opacity-50":""})}),(()=>{let e=[];
1if(t<=5)for(let r=0;r<t;r++)e.push((0,l.jsx)(u,{children:(0,l.jsx)(p,{href:"#",onClick:e=>{e.preventDefault(),s(r)},isActive:a===r,children:r+1})},r));else{let r=Math.max(a-1,0),n=Math.min(a+1,t-1),i=r>1;for(let r=0;r<1;r++)r<t&&e.push((0,l.jsx)(u,{children:(0,l.jsx)(p,{href:"#",onClick:e=>{e.preventDefault(),s(r)},isActive:a===r,children:r+1})},r));i&&e.push((0,l.jsx)(u,{children:(0,l.jsx)(g,{})},"left-ellipsis"));for(let i=r;i<=n;i++)i>=1&&i<t-1&&e.push((0,l.jsx)(u,{children:(0,l.jsx)(p,{href:"#",onClick:e=>{e.preventDefault(),s(i)},isActive:a===i,children:i+1})},i));n<t-1-1&&e.push((0,l.jsx)(u,{children:(0,l.jsx)(g,{})},"right-ellipsis"));for(let r=t-1;r<t;r++)r>=0&&e.push((0,l.jsx)(u,{children:(0,l.jsx)(p,{href:"#",onClick:e=>{e.preventDefault(),s(r)},isActive:a===r,children:r+1})},r))}return e})(),(0,l.jsx)(u,{children:(0,l.jsx)(h,{href:"#",onClick:e=>{e.preventDefault(),s(a+1)},"aria-disabled":a+1>=t,className:a+1>=t?"pointer-events-none opacity-50":""})})]}),i&&(0,l.jsxs)("div",{className:"flex items-center gap-2 ml-4 lg:ml-10",children:[(0,l.jsx)("span",{className:"text-sm text-gray-700 text-nowrap",children:"Show per page"}),(0,l.jsx)(y.R9,{value:N.find(e=>e.value===d.toString()),onChange:e=>{e&&f&&f(parseInt(e.value))},options:N,isDisabled:r,className:"w-20",menuPlacement:v,isSearchable:!1,isClearable:!1})]})]})})}},75134:(e,a,t)=>{t.d(a,{F:()=>m,k:()=>c});
1var l=t(95155);t(12115);var s=t(12108),r=t(24033),n=t(27331),i=t(77888),o=t(64789),d=t(41860);let c=(e,a,t)=>[{id:"leak_type",accessorKey:"leak_type",header:()=>"Leak Type",cell:e=>{var a,t;let{row:s}=e;return(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("div",{className:"h-8 w-8 border border-brand-stroke rounded-lg flex items-center justify-center shrink-0",children:(0,l.jsx)(n.Hq,{leakType:null!=(a=s.original.leak_type)?a:""})}),(0,l.jsx)("span",{className:"text-sm font-medium capitalize text-nowrap",children:(0,d.WU)(null!=(t=s.original.leak_type)?t:"")})]})},meta:{name:"Leak Type"}},{id:"property_name",header:"Property | Building | Unit",accessorKey:"property_name",cell:e=>{let{row:a}=e;return(0,l.jsx)("div",{className:"flex flex-col gap-1 w-48 lg:w-auto",children:(0,l.jsxs)("span",{className:"text-sm font-medium truncate",children:[a.original.property_name," | ",a.original.building_name," |"," ",a.original.unit_name]})})},meta:{name:"Property | Building | Unit"}},{id:"gallons_consumed",accessorKey:"gallons_consumed",header:()=>{let e=t("gallons_consumed","Gallons");return(0,l.jsxs)("div",{className:e.className,onClick:e.onClick,children:[(0,l.jsx)("span",{className:"text-right w-auto lg:w-44",children:e.label}),(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(s.A,{className:e.upIconClassName}),(0,l.jsx)(r.A,{className:e.downIconClassName})]})]})},cell:e=>{var a;let{row:t}=e;return(0,l.jsx)("div",{className:"flex justify-end w-full",children:(0,l.jsx)("span",{className:"text-right pr-6",children:(null!=(a=t.original.gallons_consumed)?a:0).toLocaleString()})})},meta:{name:"Gallons"}},{id:"gallons_leaked",accessorKey:"gallons_leaked",header:()=>{let e=t("gallons_leaked","Leak Gallons over the selected period");return(0,l.jsxs)("div",{className:e.className,onClick:e.onClick,children:[(0,l.jsx)("span",{className:"text-right w-44",children:e.label}),(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(s.A,{className:e.upIconClassName}),(0,l.jsx)(r.A,{className:e.downIconClassName})]})]})},cell:e=>{var a;let{row:t}=e;return(0,l.jsx)("div",{className:"flex justify-end w-full",children:(0,l.jsx)("span",{className:"text-right pr-6",children:(null!=(a=t.original.gallons_leaked)?a:0).toLocaleString()})})},meta:{name:"Leak Gallons"}},{id:"total_gallons_leaked",accessorKey:"total_gallons_leaked",header:()=>{let e=t("total_gallons_leaked","Total Leak Gallons since the leak started");return(0,l.jsxs)("div",{className:e.className,onClick:e.onClick,children:[(0,l.jsx)("span",{className:"text-right w-44",children:e.label}),(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(s.A,{className:e.upIconClassName}),(0,l.jsx)(r.A,{className:e.downIconClassName})]})]})},cell:e=>{var a;let{row:t}=e;return(0,l.jsx)("div",{className:"flex justify-end w-full",children:(0,l.jsx)("span",{className:"text-right pr-6",children:(null!=(a=t.original.total_gallons_leaked)?a:0).toLocaleString()})})},meta:{name:"Total Leak Gallons"}},{id:"total_expense",accessorKey:"total_expense",header:()=>{let e=t("total_expense","Leak Variable Expense");return(0,l.jsxs)("div",{className:e.className,onClick:e.onClick,children:[(0,l.jsx)("span",{className:"text-right w-44",children:e.label}),(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(s.A,{className:e.upIconClassName}),(0,l.jsx)(r.A,{className:e.downIconClassName})]})]})},cell:e=>{let{row:a}=e;return(0,l.jsx)("div",{className:"flex justify-end w-full",children:(0,l.jsx)("span",{className:"text-right pr-6",children:(0,o.v)(a.original.total_expense)})})},meta:{name:"Leak Variable Expense"}}];function m(e){let{data:a,isLoading:t,columnVisibility:s,columnOrder:r,onColumnVisibilityChange:o,totalCount:d,currentPage:m,onPageChange:u,params:p,onSort:x,pageSize:h,onPageSizeChange:g}=e,y=Math.ceil(d/(h||10)),f=y>1,{getSortableHeaderProps:b}=(0,i.M)({params:p,onSort:x,isLoading:t,data:a}),v=c(t,a,b);return(0,l.jsx)(n.bQ,{columns:v,data:a,columnVisibility:s,columnOrder:r,onColumnVisibilityChange:o,isLoading:t,pageCount:f?y:void 0,pageIndex:f?m:void 0,onPageChange:f?u:void 0,showPageSizeSelector:!0,pageSize:h,onPageSizeChange:g})}},77888:(e,a,t)=>{t.d(a,{M:()=>l});function l(e){let{params:a,onSort:t,isLoading:l=!1,data:s=[]}=e,r=()=>{let e=a.ordering||"";return e?{field:e.startsWith("-")?e.slice(1):e,direction:e.startsWith("-")?"desc":"asc"}:null},n=(e,a)=>{let l="".concat("desc"===a?"-":"").concat(e);null==t||t(l)};return{getCurrentSortState:r,handleSort:n,getSortableHeaderProps:function(e,a){let t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"end",i=r(),o=(null==i?void 0:i.field)===e,d=o&&(null==i?void 0:i.direction)==="asc";return{className:"w-full flex justify-".concat(t," gap-1 ").concat(!l&&s.length>0?"cursor-pointer":"cursor-default"),onClick:()=>{l||0===s.length||n(e,d?"desc":"asc")},upIconClassName:"shrink-0 w-4 h-4 ".concat(o&&(null==i?void 0:i.direction)==="asc"?"text-brand-dark-cyan":"text-brand-gray"," ").concat(!l&&s.length>0?"opacity-100":"opacity-50"),downIconClassName:"shrink-0 w-4 h-4 mt-[-6px] ".concat(o&&(null==i?void 0:i.direction)==="desc"?"text-brand-dark-cyan":"text-brand-gray"," ").concat(!l&&s.length>0?"opacity-100":"opacity-50"),label:a}}}}},82983:(e,a,t)=>{t.d(a,{r:()=>l});function l(e,a){if(e.length!==a.length)return!1;let t=[...e].sort(),l=[...a].sort();return t.every((e,a)=>e===l[a])}},87270:(e,a,t)=>{t.d(a,{A0:()=>i,BF:()=>o,Hj:()=>d,XI:()=>n,nA:()=>m,nd:()=>c});
1var l=t(95155),s=t(12115),r=t(64269);let n=s.forwardRef((e,a)=>{let{className:t,...s}=e;return(0,l.jsx)("table",{ref:a,className:(0,r.cn)("w-full caption-bottom text-sm",t),...s})});n.displayName="Table";let i=s.forwardRef((e,a)=>{let{className:t,...s}=e;return(0,l.jsx)("thead",{ref:a,className:(0,r.cn)("[&_tr]:border-b",t),...s})});i.displayName="TableHeader";let o=s.forwardRef((e,a)=>{let{className:t,...s}=e;return(0,l.jsx)("tbody",{ref:a,className:(0,r.cn)("[&_tr:last-child]:border-0",t),...s})});o.displayName="TableBody",s.forwardRef((e,a)=>{let{className:t,...s}=e;return(0,l.jsx)("tfoot",{ref:a,className:(0,r.cn)("border-t bg-muted/50 font-medium last:[&>tr]:border-b-0",t),...s})}).displayName="TableFooter";let d=s.forwardRef((e,a)=>{let{className:t,...s}=e;return(0,l.jsx)("tr",{ref:a,className:(0,r.cn)("border-b transition-colors",t),...s})});d.displayName="TableRow";let c=s.forwardRef((e,a)=>{let{className:t,...s}=e;return(0,l.jsx)("th",{ref:a,className:(0,r.cn)("h-10 p-0 text-left align-middle text-base font-normal text-brand-dark-gray [&:has([role=checkbox])]:pr-0",t),...s})});c.displayName="TableHead";let m=s.forwardRef((e,a)=>{let{className:t,...s}=e;return(0,l.jsx)("td",{ref:a,className:(0,r.cn)("h-[44px] p-0 align-middle [&:has([role=checkbox])]:pr-0 text-sm text-brand-black font-medium",t),...s})});m.displayName="TableCell",s.forwardRef((e,a)=>{let{className:t,...s}=e;return(0,l.jsx)("caption",{ref:a,className:(0,r.cn)("mt-4 text-sm text-muted-foreground",t),...s})}).displayName="TableCaption"},89837:(e,a,t)=>{t.d(a,{O:()=>y,h:()=>f});var l=t(95155),s=t(32897),r=t(35299),n=t(12108),i=t(24033),o=t(27937),d=t(7125),c=t(6191),m=t(77888),u=t(3998),p=t(12115),x=t(26493),h=t(64269),g=t(40170);
1function y(e,a,t,s,m,p,x,y,f,b,v,N,j,_,w,k,C,S){return[{id:"property_name",accessorKey:"property_name",header:()=>(0,l.jsx)("span",{className:"min-w-32",children:"Property"}),cell:e=>{let{row:a}=e;if("isLoadMore"in a.original&&a.original.isLoadMore){var t;let e=null==b?void 0:b[a.original.parent_id],s=null==N?void 0:N[a.original.parent_id],n=(null==v||null==(t=v[a.original.parent_id])?void 0:t.length)||0;return(0,l.jsx)("div",{className:"flex items-center justify-center py-2 w-full h-full absolute top-0 left-0",style:{width:"".concat(_,"px")},children:(0,l.jsxs)(u.$,{variant:"secondary",size:"sm",className:"flex items-center gap-2",disabled:s,onClick:e=>{e.stopPropagation(),null==j||j(a.original.parent_id)},children:[s&&(0,l.jsx)(r.A,{className:"w-4 h-4 animate-spin"}),"Load More (",n," of ",(null==e?void 0:e.total)||0,")"]})})}return(0,l.jsx)("span",{children:a.original.property_name})},meta:{name:"Property",cellClassName:"relative"}},{id:"building_name",accessorKey:"building_name",header:()=>{let e=t("building_name","Building","start");return(0,l.jsxs)("div",{className:e.className,onClick:e.onClick,children:[(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(n.A,{className:e.upIconClassName}),(0,l.jsx)(i.A,{className:e.downIconClassName})]}),(0,l.jsx)("span",{children:e.label})]})},cell:e=>{let{row:a}=e;return"isLoadMore"in a.original&&a.original.isLoadMore?null:(0,l.jsx)("div",{className:"flex items-center w-full h-full min-w-28 cursor-pointer hover:underline hover:text-brand-dark-cyan transition-colors",onClick:()=>null==s?void 0:s(a.original.property_id,a.original.building_id),children:a.original.building_name})},meta:{name:"Building"}},{id:"unit_name",accessorKey:"unit_name",header:()=>{let e=t("unit_name","Unit","start");return(0,l.jsxs)("div",{className:e.className,onClick:e.onClick,children:[(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(n.A,{className:e.upIconClassName}),(0,l.jsx)(i.A,{className:e.downIconClassName})]}),(0,l.jsx)("span",{children:e.label})]})},cell:e=>{let{row:a}=e;return"isLoadMore"in a.original&&a.original.isLoadMore?null:(0,l.jsx)("div",{className:"flex items-center w-full h-full cursor-pointer hover:underline hover:text-brand-dark-cyan transition-colors",onClick:()=>null==m?void 0:m(a.original.property_id,a.original.building_id,a.original.unit_id),children:a.original.unit_name})},meta:{name:"Unit"}},{id:"bedroom_count",accessorKey:"bedroom_count",header:()=>(0,l.jsx)("span",{className:"min-w-20",children:"Bd - Ba"}),cell:e=>{let{row:a}=e;if("isLoadMore"in a.original&&a.original.isLoadMore)return null;let t=a.original;return(0,l.jsxs)("span",{children:[t.bedroom_count," Bd - ",t.bathroom_count," Ba"]})},meta:{name:"Bd - Ba"}},{id:"attached_to",accessorKey:"attached_to",header:()=>(0,l.jsx)("span",{className:"min-w-32",children:"Attached To"}),cell:e=>{let{row:a}=e;return"isLoadMore"in a.original&&a.original.isLoadMore?null:(0,l.jsx)("span",{children:a.original.attached_to})},meta:{name:"Attached To"}},{id:"meter_serial_number",accessorKey:"meter_serial_number",header:()=>(0,l.jsx)("span",{className:"min-w-44",children:"Device Serial Number"}),cell:e=>{let{row:a}=e;return"isLoadMore"in a.original&&a.original.isLoadMore?null:(0,l.jsx)("span",{className:"flex items-center w-full h-full cursor-pointer hover:underline hover:text-brand-dark-cyan transition-colors",onClick:()=>null==p?void 0:p(a.original.meter_serial_number),children:a.original.meter_serial_number})},meta:{name:"Device Serial Number"}},{id:"period",accessorKey:"period",header:()=>{let e=t("period","Period","start");return(0,l.jsxs)("div",{className:(0,h.cn)(e.className,"min-w-24"),onClick:e.onClick,children:[(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(n.A,{className:e.upIconClassName}),(0,l.jsx)(i.A,{className:e.downIconClassName})]}),(0,l.jsx)("span",{children:e.label})]})},cell:e=>{let{row:a}=e;return"isLoadMore"in a.original&&a.original.isLoadMore?null:(0,l.jsx)("span",{children:a.original.period})},meta:{name:"Period"}},{id:"gallons_consumed",accessorKey:"gallons_consumed",header:()=>{let e=t("gallons_consumed","Gallons");return(0,l.jsxs)("div",{className:e.className,onClick:e.onClick,children:[(0,l.jsx)("span",{className:"text-right",children:e.label}),(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(n.A,{className:e.upIconClassName}),(0,l.jsx)(i.A,{className:e.downIconClassName})]})]})},cell:e=>{var a;let{row:t}=e;return"isLoadMore"in t.original&&t.original.isLoadMore?null:(0,l.jsx)("div",{className:"flex justify-end w-full",children:(0,l.jsx)("span",{className:"text-right pr-6",children:(null!=(a=t.original.gallons_consumed)?a:0).toLocaleStr
1ing()})})},meta:{name:"Gallons"}},{id:"events",accessorKey:"events",header:()=>{let e=t("events","Events");return(0,l.jsxs)("div",{className:e.className,onClick:e.onClick,children:[(0,l.jsx)("span",{className:"text-right",children:e.label}),(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(n.A,{className:e.upIconClassName}),(0,l.jsx)(i.A,{className:e.downIconClassName})]})]})},cell:e=>{let{row:a}=e;return"isLoadMore"in a.original&&a.original.isLoadMore?null:(0,l.jsx)("div",{className:"flex justify-end w-full",children:(0,l.jsx)("span",{className:"text-right pr-6",children:Math.round(a.original.events).toLocaleString()})})},meta:{name:"Events"}},{id:"gallons_leaked",accessorKey:"gallons_leaked",header:()=>{let e=t("gallons_leaked","Leak Gallons");return(0,l.jsxs)("div",{className:e.className,onClick:e.onClick,children:[(0,l.jsx)("span",{className:"text-right",children:e.label}),(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(n.A,{className:e.upIconClassName}),(0,l.jsx)(i.A,{className:e.downIconClassName})]})]})},cell:e=>{var a;let{row:t}=e;return"isLoadMore"in t.original&&t.original.isLoadMore?null:(0,l.jsx)("div",{className:"flex justify-end w-full",children:(0,l.jsx)("span",{className:"text-right pr-6",children:(null!=(a=t.original.gallons_leaked)?a:0).toLocaleString()})})},meta:{name:"Leak Gallons"}},{id:"toilet_leaks",accessorKey:"toilet_leaks",header:()=>{let e=t("toilet_leaks","Toilet Leaks");return(0,l.jsxs)("div",{className:e.className,onClick:e.onClick,children:[(0,l.jsx)("span",{className:"text-right",children:e.label}),(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(n.A,{className:e.upIconClassName}),(0,l.jsx)(i.A,{className:e.downIconClassName})]})]})},cell:e=>{var a;let{row:t}=e;return"isLoadMore"in t.original&&t.original.isLoadMore?null:(0,l.jsx)("div",{className:"flex justify-end w-full",children:(0,l.jsx)("span",{className:"text-right pr-6",children:(null!=(a=t.original.toilet_leaks)?a:0).toLocaleString()})})},meta:{name:"Toilet Leaks"}},{id:"other_leaks",accessorKey:"other_leaks",header:()=>{let e=t("other_leaks","Other Leaks");return(0,l.jsxs)("div",{className:e.className,onClick:e.onClick,children:[(0,l.jsx)("span",{className:"text-right",children:e.label}),(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(n.A,{className:e.upIconClassName}),(0,l.jsx)(i.A,{className:e.downIconClassName})]})]})},cell:e=>{var a;let{row:t}=e;return"isLoadMore"in t.original&&t.original.isLoadMore?null:(0,l.jsx)("div",{className:"flex justify-end w-full",children:(0,l.jsx)("span",{className:"text-right pr-6",children:(null!=(a=t.original.other_leaks)?a:0).toLocaleString()})})},meta:{name:"Other Leaks"}},{id:"leak_volume_percentage",accessorKey:"leak_volume_percentage",header:()=>{let e=t("leak_volume_percentage","Leak Volume %");return(0,l.jsxs)("div",{className:e.className,onClick:e.onClick,children:[(0,l.jsx)("span",{className:"text-right min-w-22",children:e.label}),(0,l.jsxs)("div",{className:"flex flex-col items-center w-5",children:[(0,l.jsx)(n.A,{className:e.upIconClassName}),(0,l.jsx)(i.A,{className:e.downIconClassName})]})]})},cell:e=>{var a;let{row:t}=e;return"isLoadMore"in t.original&&t.original.isLoadMore?null:(0,l.jsx)("div",{className:"flex justify-end w-full",children:(0,l.jsxs)("span",{className:"text-right pr-6",children:[(null!=(a=t.original.leak_volume_percentage)?a:0).toLocaleString(),"%"]})})},meta:{name:"Leak Volume %"}},{id:"actions",size:130,enableResizing:!1,cell:e=>{let{row:a}=e;if("isLoadMore"in a.original&&a.original.isLoadMore)return null;if("isDaily"in a.original&&a.original.isDaily){let e=a.original;return(0,l.jsx)("div",{className:"flex justify-end w-full",children:(0,l.jsx)(u.$,{variant:"secondary",size:"sm",className:"py-1 px-2 border-gray-400 w-28 h-7 text-brand-dark-gray hover:text-brand-dark-cyan hover:border-brand-dark-cyan",onClick:a=>{a.stopPropagation(),null==k||k(e.parent_id,e.period)},children:(0,l.jsxs)("div",{className:"flex items-center gap-0.5",children:["Show hourly",(0,l.jsx)(o.A,{className:"w-4 h-4"})]})})})}let t=a.original;if(C){let e=(0,g.sl)(t.period,null==S?void 0:S.start_date);return(0,l.jsx)("div",{className:"flex justify-end w-full",children:(0,l.jsx)(u.$,{variant:"secondary",size:"sm",className:"py-1 px-2 border-gray-400 w-28 h-7 text-brand-dark-gray hover:text-brand-dark-cyan hover:border-brand-dark-cyan",onClick:a=>{a.stopPropagation(),null==k||k(t.meter_serial_number,e)},children:(0,l.jsxs)("div",{className:"flex items-center gap-0.5",children:["Show hourly",(0,l.jsx)(o.A,{className:"w-4 h-4"})]})})})}{let e=null==x?void 0:x[t.id],a=null==y?void 0:y[t.id];return(0,l.jsx)("div",{className:"flex justify-end w-full",children:(0,l.jsx)(u.$,{variant:"secondary",size:"sm",className:"opacity-100 py-1 px-2 w-28 h-7",onClick:e=>{e.stopPropagation(),null==f||f(t.meter_serial_number)},children:a?(0,l.jsx)(r.A,{className:"w-5 h-5 animate-spin text-brand-dark-cyan"}):e?(0,l.jsxs)("div",{className:"flex items-center gap-0.5",children:["Hide daily",(0,l.jsx)(d.A,{className:"w-5 h-5",strokeWidth:2})]}):(0,l.jsxs)("div",{className:"flex items-center gap-0.5",children:["Show daily",(0,l.jsx)(c.A,{className:"w-5 h-5",strokeWidth:2})]})})})}},meta:{fixedWidth:!0}}]}function f(e){let{data:a,isLoading:t,totalCount:r=0,onPageChange:n,currentPage:i=0,params:o,onSort:d,columnVisibility:c,columnOrder:u,onColumnVisibilityChange:h,pageSize:g,onPageSizeChange:f,menuPlacement:b,onBuildingFilterClick:v,onUnitFilterClick:N,onMetersFiltersClick:j,onShowHourly:_}=e,w=Math.ceil(r/(g||10)),k=w>1,[C,S]=(0,p.useState)({}),[E,L]=(0,p.useState)({}),[A,D]=(0,p.useState)({}),[O,T]=(0,p.useState)({}),[I,P]=(0,p.useState)({}),[R,M]=(0,p.useState)({}),[G,z]=(0,p.useState)(0);(0,p.useEffect)(()=>{S({}),D({}),T({}),P({}),M({})},[o.start_date,o.end_date,o.organization_id,o.property_id,o.ordering]),(0,p.useEffect)(()=>{let e=()=>{let e=window.document.querySelector("[data-day-meter-table]");e&&z(e.getBoundingClientRect().width)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[a]);let F=async e=>{let a=C[e];if(S(t=>({...t,[e]:!a})),!a){L(a=>({...a,[e]:!0}));let a=Object.fromEntries(Object.entries(o).filter(e=>{let[a]=e;return!["organization_id","property_id"].includes(a)}));
1try{let t=await x.l.getLeakDetailsMetersDay(e,{...a,page:1,page_size:5}),l=t.results.map((a,t)=>({...a,organization_id:0,isDaily:!0,id:"".concat(e,"-daily-").concat(t,"-").concat(a.period),parent_id:e}));D(a=>({...a,[e]:l})),T(a=>({...a,[e]:{page:1,hasMore:null!==t.next,total:t.count||0}}))}catch(e){console.error("Error fetching daily data:",e)}finally{L(a=>({...a,[e]:!1}))}}},H=async e=>{let a=O[e];if(!(null==a?void 0:a.hasMore)||I[e])return;P(a=>({...a,[e]:!0}));let t=Object.fromEntries(Object.entries(o).filter(e=>{let[a]=e;return!["organization_id","property_id"].includes(a)})),l=R[e],s=!l;try{let r=await x.l.getLeakDetailsMetersDay(e,{...t,page:l?a.page+1:1,page_size:50}),n=r.results.map((t,s)=>({...t,organization_id:0,isDaily:!0,id:"".concat(e,"-daily-").concat(l?a.page+1:1,"-").concat(s,"-").concat(t.period),parent_id:e}));D(a=>({...a,[e]:s?n:[...a[e]||[],...n]})),T(t=>({...t,[e]:{page:l?a.page+1:1,hasMore:null!==r.next,total:r.count||0}})),s&&M(a=>({...a,[e]:!0}))}catch(e){console.error("Error loading more daily data:",e)}finally{P(a=>({...a,[e]:!1}))}},{getSortableHeaderProps:V}=(0,m.M)({params:o,onSort:d,isLoading:t,data:a}),U=y(null!=t&&t,a,V,v,N,j,C,E,F,O,A,I,H,G,!0,_,!!(1===o.days_ago||o.start_date&&o.end_date&&o.start_date===o.end_date),o),B=a.reduce((e,a)=>{let t=a.meter_serial_number;if(e.push({...a,id:t}),C[t]&&A[t]){e.push(...A[t]);let a=O[t];(null==a?void 0:a.hasMore)&&e.push({id:"load-more-".concat(t),isLoadMore:!0,parent_id:t,meter_serial_number:t,property_name:"",building_name:"",unit_name:"",attached_to:"",gallons_consumed:0,gallons_leaked:0,toilet_leaks:0,other_leaks:0,leak_volume_percentage:0,events:0,period:"",organization_id:0,property_id:0,building_id:0,unit_id:0,isDaily:!1})}return e},[]);return(0,l.jsx)("div",{"data-day-meter-table":!0,children:(0,l.jsx)(s.b,{columns:U,data:B,columnVisibility:c||{},onColumnVisibilityChange:h||(()=>{}),columnOrder:u||[],getRowClassName:e=>{let a=[];return"isDaily"in e.original&&e.original.isDaily&&a.push("bg-cyan-50"),"isLoadMore"in e.original&&e.original.isLoadMore?a.push("bg-cyan-50 border-t-2 relative"):a.push("hover:bg-gray-50"),a.join(" ")},isLoading:t,pageCount:k?w:void 0,pageIndex:k?i:void 0,onPageChange:k?n:void 0,headerClassName:"h-14",headerColor:"text-brand-black",showPageSizeSelector:!0,pageSize:g,onPageSizeChange:f,menuPlacement:b})})}},93893:(e,a,t)=>{t.d(a,{Header:()=>M});var l=t(95155),s=t(12115),r=t(52619),n=t.n(r),i=t(15239),o=t(20063),d=t(27331),c=t(64269),m=t(6259),u=t(29141),p=t(15101),x=t(23042),h=t(60163),g=t(65993),y=t(91456),f=t(89077),b=t(85710),v=t(54485),N=t(77676),j=t(91761),_=t(70968),w=t(71871),k=t(35597),C=t(68985),S=t(91169),E=t(1505),L=t(16854),A=t(37264),D=t(24033),O=t(99265),T=t(84926),I=t(35299),P=t(65229),R=t(9540);function M(){var e,a;let t=(0,o.usePathname)(),r=(0,o.useRouter)(),M=(0,o.useSearchParams)(),{user:G,isStaff:z,isIONAdmin:F,isOrgAdmin:H,isOrgMember:V,isLoading:U}=(0,u.J)(),{organizations:B,activeOrganization:K,setActiveOrganization:W,hasPropertyInsightsAccess:Y,hasPortfolioInsightsAccess:$,isLoading:Z}=(0,p.Z)(),[q,J]=(0,s.useState)(!1),X=(0,s.useMemo)(()=>{if(!G||U)return[];let e=[];
1if(Y&&e.push({name:"Property Insights",key:"property-insights",icon:(0,l.jsx)(g.A,{className:"w-4 h-4"}),requiresAccess:"property",items:[{name:"Top 5 Leaks Home",href:"/top5-leaks-home",icon:(0,l.jsx)(y.A,{className:"w-4 h-4"})},{name:"Top 5 Leaks Details",href:"/top5-leaks-details",icon:(0,l.jsx)(f.A,{className:"w-4 h-4"})},{name:"Gateway & Device Health",href:"/gateway-device-health",icon:(0,l.jsx)(b.A,{className:"w-4 h-4"})},{name:"History",href:"/history",icon:(0,l.jsx)(v.A,{className:"w-4 h-4"})},{name:"Report Center",href:"/report-center",icon:(0,l.jsx)(N.A,{className:"w-4 h-4"})}]}),$){var a,t;let s=[];z&&(null==G||null==(a=G.permissions)?void 0:a.some(e=>"reporting.view_ion_prevention_report"===e.name))&&s.push({name:"Performance-Prevention",href:"/prevention",icon:(0,l.jsx)(j.A,{className:"w-4 h-4"})}),s.push({name:"Performance-Detection",href:"/detection",icon:(0,l.jsx)(y.A,{className:"w-4 h-4"})}),z&&(null==G||null==(t=G.permissions)?void 0:t.some(e=>"municipal.view_municipal_report"===e.name))&&s.push({name:"Municipal",href:"/municipal",icon:(0,l.jsx)(_.A,{className:"w-4 h-4"})}),s.push({name:"Properties",href:"/properties",icon:(0,l.jsx)(w.A,{className:"w-4 h-4"})},{name:"Device Health",href:"/portfolio-gateway-device-health",icon:(0,l.jsx)(b.A,{className:"w-4 h-4"})},{name:"Leak Costs",href:"/finance",icon:(0,l.jsx)(k.A,{className:"w-4 h-4"})}),e.push({name:"Portfolio Insights",key:"portfolio-insights",icon:(0,l.jsx)(C.A,{className:"w-4 h-4"}),requiresAccess:"portfolio",items:s})}if(F||H){let a=[{name:"User Management",href:"/admin/users",icon:(0,l.jsx)(S.A,{className:"w-4 h-4"})}];F&&a.push({name:"Properties",href:"/admin/properties",icon:(0,l.jsx)(E.A,{className:"w-4 h-4"})},{name:"Organizations",href:"/admin/organizations",icon:(0,l.jsx)(L.A,{className:"w-4 h-4"})}),e.push({name:"Admin",key:"admin",icon:(0,l.jsx)(A.A,{className:"w-4 h-4"}),requiresAccess:"admin",items:a})}return e},[null==G?void 0:G.id,null==K?void 0:K.id,Y,$,z,F,H,U]),Q=(H||V)&&B.length>1,ee=B.map(e=>({label:e.name,value:e.id})),ea=(0,s.useMemo)(()=>!G||U||0===X.length?null:X.find(e=>e.items.some(e=>"/history"===e.href?t.startsWith("/history"):"/properties"===e.href?t.startsWith("/properties"):"/top5-leaks-home"===e.href?"/top5-leaks-home"===t||"/top5-leaks-details"===t&&""!==M.toString():"/top5-leaks-details"===e.href?"/top5-leaks-details"===t&&""===M.toString():t===e.href||t.startsWith(e.href)))||X[0],[t,M,X,G,U]);if(!G||U||Z||"/"===t)return(0,l.jsx)("header",{className:"h-16 flex w-full justify-center items-center border-b border-brand-stroke bg-brand-white",children:(0,l.jsx)(i.default,{src:"/images/logo.png",alt:"ION Water Logo",width:88,height:32})});let et=e=>"/history"===e?t.startsWith("/history"):"/properties"===e?t.startsWith("/properties"):"/top5-leaks-home"===e?"/top5-leaks-home"===t||"/top5-leaks-details"===t&&""!==M.toString():"/top5-leaks-details"===e?"/top5-leaks-details"===t&&""===M.toString():t===e,el=async()=>{await x.y.logout(),J(!1),r.push("/login")};return(0,l.jsxs)("header",{className:"sticky top-0 z-100 bg-white border-b border-gray-200",children:[(0,l.jsx)("div",{className:"w-full",children:(0,l.jsx)("div",{className:"container mx-auto px-8",children:(0,l.jsxs)("div",{className:"flex h-16 items-center justify-between",children:[(0,l.jsxs)("div",{className:"flex items-center gap-4",children:[(0,l.jsx)(i.default,{src:"/images/logo.png",alt:"ION Water Logo",width:88,height:32}),(0,l.jsx)("div",{className:"hidden md:block",children:(0,l.jsx)(()=>
1{let[e,a]=(0,s.useState)(!1),t=(0,s.useRef)(null),r=(0,s.useRef)(null);return(0,l.jsxs)(m.rI,{open:e,onOpenChange:e=>{a(e),e&&setTimeout(()=>{if(r.current&&t.current){let e=r.current,a=t.current;try{let t=a.getBoundingClientRect(),l=e.getBoundingClientRect(),s=l.top-t.top,r=l.bottom-t.top,n=a.clientHeight;if(s<0||r>n){let e=s-n/2+l.height/2;a.scrollTo({top:e,behavior:"smooth"})}}catch(e){console.warn("Failed to scroll to active item:",e)}}},100)},children:[(0,l.jsxs)(m.ty,{className:"flex items-center gap-2 px-3 py-2 rounded-lg text-sm font-medium text-brand-dark-gray hover:text-brand-dark-cyan hover:bg-cyan-50 focus:outline-hidden transition-colors [&[data-state=open]>.chevron-down]:rotate-180",children:[null==ea?void 0:ea.icon,(0,l.jsx)("span",{className:"hidden sm:inline select-none",children:null==ea?void 0:ea.name}),(0,l.jsx)(D.A,{className:"chevron-down w-4 h-4 transition-transform duration-200"})]}),(0,l.jsx)(m.SQ,{ref:t,align:"start",className:"w-64 p-1 max-h-96 overflow-y-auto",children:X.map(e=>(0,l.jsxs)("div",{className:"mb-2 last:mb-0",children:[(0,l.jsx)("div",{className:"px-3 py-1 text-xs font-semibold text-gray-500 uppercase tracking-wide",children:e.name}),e.items.map(e=>(0,l.jsx)(m._2,{asChild:!0,children:(0,l.jsxs)(n(),{ref:et(e.href)?r:null,href:e.href,className:(0,c.cn)("flex items-center gap-3 px-3 py-2 rounded-md text-sm font-medium transition-colors cursor-pointer",et(e.href)?"bg-cyan-50 text-brand-dark-cyan":"text-brand-dark-gray hover:text-brand-dark-cyan hover:bg-gray-50"),children:[e.icon,e.name,e.badge&&(0,l.jsx)("span",{className:"ml-auto px-1.5 py-0.5 text-xs bg-red-100 text-red-600 rounded-full",children:e.badge})]})},e.href))]},e.key))})]})},{})}),ea&&(0,l.jsx)("div",{className:"hidden lg:flex items-center pl-4 border-l border-gray-200",children:ea.items.map(e=>(0,l.jsxs)(n(),{href:e.href,className:(0,c.cn)("flex items-center gap-2 px-3 py-1.5 rounded-md text-sm font-medium transition-colors",et(e.href)?"bg-cyan-50 text-brand-dark-cyan":"text-brand-dark-gray hover:text-brand-dark-cyan hover:bg-gray-50"),children:[e.icon,(0,l.jsx)("span",{className:(0,c.cn)("hidden",Q?"2xl:inline":"xl:inline"),children:e.name}),e.badge&&(0,l.jsx)("span",{className:"px-1.5 py-0.5 text-xs bg-red-100 text-red-600 rounded-full",children:e.badge})]},e.href))})]}),(0,l.jsxs)("div",{className:"flex items-center gap-4",children:[Q&&(0,l.jsx)("div",{className:"hidden md:block",children:(0,l.jsx)(d.R9,{options:ee,value:ee.find(e=>{var a;return e.value===((null==K?void 0:K.id)||(null==(a=ee[0])?void 0:a.value))}),onChange:e=>{let a=B.find(a=>a.id===(null==e?void 0:e.value));a&&W(a)},placeholder:"Select Organization",className:"w-48"})}),(0,l.jsxs)("div",{className:"hidden md:flex items-center gap-3",children:[(0,l.jsx)(()=>{var e,a;return(0,l.jsxs)(m.rI,{children:[(0,l.jsx)(m.ty,{className:"focus:outline-hidden [&[data-state=open]>svg]:rotate-180",children:(0,l.jsx)("div",{className:"w-10 h-10 rounded-full bg-brand-dark-cyan flex items-center justify-center shrink-0",children:(0,l.jsxs)("span",{className:"text-white text-xs font-medium",children:[null==G||null==(e=G.first_name)?void 0:e[0],null==G||null==(a=G.last_name)?void 0:a[0]]})})}),(0,l.jsxs)(m.SQ,{align:"end",className:"p-1",children:[(0,l.jsxs)("div",{className:"px-3 py-2 border-b border-gray-100",children:[(0,l.jsxs)("p",{className:"text-sm font-medium text-brand-dark-gray",children:[null==G?void 0:G.first_name," ",null==G?void 0:G.last_name]}),(0,l.jsx)("p",{className:"text-xs text-gray-500",children:null==G?void 0:G.username})]}),(0,l.jsxs)(m._2,{onClick:()=>r.push("/profile"),className:"flex items-center gap-2 py-2 px-3 cursor-pointer text-sm font-medium text-brand-dark-gray hover:text-brand-dark-cyan hover:bg-cyan-50",children:[(0,l.jsx)(O.A,{className:"w-4 h-4"}),"Profile"]}),(0,l.jsxs)(m._2,{onClick:el,className:"flex items-center gap-2 py-2 px-3 cursor-pointer text-sm font-medium text-brand-dark-gray hover:text-red-600 hover:bg-red-50",children:[(0,l.jsx)(T.A,{className:"w-4 h-4"}),"Logout"]})]})]})},{}),(0,l.jsx)(()=>{let{gallonsDailyUpdate:e,deviceHealthUpdate:a,isLoading:t}=(0,h.Hn)(),s=(0,o.usePathname)();return(0,l.jsxs)("div",{children:[(0,l.jsx)("p",{className:"text-xs text-brand-dark-gray",children:"Last Update:"}),(0,l.jsx)("p",{className:"text-xs text-brand-dark-gray font-medium",children:t?(0,l.jsx)(I.A,{className:"w-4 h-4 animate-spin"}):"/gateway-device-health"===s||"/portfolio-gateway-device-health"===s?a:e})]})},{})]}),(0,l.jsx)("button",{className:"md:hidden p-2 rounded-md text-brand-dark-gray hover:bg-gray-100",onClick:()=>J(!q),children:q?(0,l.jsx)(P.A,{className:"w-6 h-6"}):(0,l.jsx)(R.A,{className:"w-6 h-6"})})]})]})})}),q&&(0,l.jsx)("div",{className:"lg:hidden fixed inset-0 z-50 bg-white",children:(0,l.jsxs)("div",{className:"flex flex-col h-full",children:[(0,l.jsxs)("div",{className:"h-16 flex items-center justify-between px-8 border-b border-brand-stroke",children:[(0,l.jsx)(i.default,{src:"/images/logo.png",alt:"ION Water Logo",width:88,height:32}),(0,l.jsx)("button",{onClick:()=>J(!1),className:"p-2 rounded-md text-brand-dark-gray hover:bg-gray-100","aria-label":"Close menu",children:(0,l.jsx)(P.A,{className:"w-6 h-6"})})]}),(0,l.jsxs)("div",{className:"flex-1 overflow-y-auto p-8",children:[Q&&(0,l.jsxs)("div",{className:"mb-6",children:[(0,l.jsx)("label",{className:"block text-sm font-medium text-brand-dark-gray mb-2",children:"Organization"}),(0,l.jsx)(d.R9,{options:ee,value:ee.find(e=>{var a;return e.value===((null==K?void 0:K.id)||(null==(a=ee[0])?void 0:a.value))}),onChange:e=>{let a=B.find(a=>a.id===(null==e?void 0:e.value));a&&W(a)},className:"w-full"})]}),(0,l.jsx)("div",{className:"space-y-6",children:X.map(e=>(0,l.jsxs)("div",{children:[(0,l.jsxs)("h3",{className:"flex items-center gap-2 text-base font-semibold text-brand-dark-gray mb-3",children:[e.icon,e.name]}),(0,l.jsx)("div",{className:"space-y-1 ml-6",children:e.items.map(e=>(0,l.jsxs)(n(),{href:e.href,onClick:()=>
1J(!1),className:(0,c.cn)("flex items-center gap-3 px-3 py-2 rounded-md text-sm font-medium transition-colors",et(e.href)?"bg-cyan-50 text-brand-dark-cyan":"text-brand-dark-gray hover:text-brand-dark-cyan hover:bg-gray-50"),children:[e.icon,e.name,e.badge&&(0,l.jsx)("span",{className:"ml-auto px-2 py-0.5 text-xs bg-red-100 text-red-600 rounded-full",children:e.badge})]},e.href))})]},e.key))})]}),(0,l.jsxs)("div",{className:"border-t border-brand-stroke p-8",children:[(0,l.jsxs)("div",{className:"flex items-center gap-3 mb-4",children:[(0,l.jsx)("div",{className:"w-10 h-10 rounded-full bg-brand-dark-cyan flex items-center justify-center",children:(0,l.jsxs)("span",{className:"text-white text-sm font-medium",children:[null==G||null==(e=G.first_name)?void 0:e[0],null==G||null==(a=G.last_name)?void 0:a[0]]})}),(0,l.jsxs)("div",{children:[(0,l.jsxs)("p",{className:"font-medium text-brand-dark-gray text-sm",children:[null==G?void 0:G.first_name," ",null==G?void 0:G.last_name]}),(0,l.jsx)("p",{className:"text-xs text-gray-500",children:null==G?void 0:G.username})]})]}),(0,l.jsxs)("div",{className:"space-y-1",children:[(0,l.jsxs)(n(),{href:"/profile",onClick:()=>J(!1),className:"flex items-center gap-2 px-3 py-2 rounded-md text-sm font-medium text-brand-dark-gray hover:text-brand-dark-cyan hover:bg-gray-50",children:[(0,l.jsx)(O.A,{className:"w-4 h-4"}),"Profile"]}),(0,l.jsxs)("button",{onClick:el,className:"flex items-center gap-2 px-3 py-2 rounded-md text-sm font-medium text-brand-dark-gray hover:text-red-600 hover:bg-red-50 w-full text-left",children:[(0,l.jsx)(T.A,{className:"w-4 h-4"}),"Logout"]})]})]})]})})]})}}}]);

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.