cmms/frontend/dist/assets/ReportsView-CBYhF-qa.js

2 lines
47 KiB
JavaScript

import{bc as ze,aO as He,r as F,c as U,l as qe,_ as We,m as Me,o as Ne,b4 as Je,i as me,w as I,bl as Ge,g as x,b as e,d as R,a as P,j as te,e as y,t as f,af as oe,aQ as ne,n as Z,k as N,Q as Ve,F as ae}from"./index-BUdRbiwj.js";import{u as Ye}from"./useFormAutoSave-Jaawgo91.js";import{F as Qe,a as Ze}from"./FPPageHeader-CTG2L28r.js";import{F as se}from"./FPInput-CzR_dWoe.js";import{F as H}from"./FPCard-qHzcEQAE.js";import{F as Ee}from"./FPSelect-C7p47Ma2.js";import{F as Xe}from"./FPModal-DWGF1LV8.js";import{F as ue}from"./FPBadge-BKY5dPnL.js";import{F as et}from"./FPTabs-R71V25QN.js";import{_ as tt}from"./FormRestoreNotification-DYBlXhOP.js";class at extends ze{constructor(){super(),this.baseURL="/reports"}async getReports(t={}){const n=new URLSearchParams;t.page!==void 0&&n.set("page",t.page),t.size!==void 0&&n.set("size",t.size),t.search&&n.set("search",t.search),t.type&&n.set("type",t.type),t.status&&n.set("status",t.status),t.createdBy&&n.set("createdBy",t.createdBy),t.tags&&n.set("tags",t.tags.join(",")),t.sortBy&&n.set("sortBy",t.sortBy),t.sortDirection&&n.set("sortDirection",t.sortDirection);const b=n.toString()?`${this.baseURL}?${n}`:this.baseURL;return this.get(b)}async getReportById(t){return this.get(`${this.baseURL}/${t}`)}async createReport(t){return this.post(this.baseURL,t)}async updateReport(t,n){return this.put(`${this.baseURL}/${t}`,n)}async deleteReport(t){return this.delete(`${this.baseURL}/${t}`)}async duplicateReport(t,n={}){return this.post(`${this.baseURL}/${t}/duplicate`,n)}async executeReport(t,n={}){return this.post(`${this.baseURL}/${t}/execute`,n)}async previewReport(t,n={}){return this.post(`${this.baseURL}/preview`,{...t,...n})}async exportReport(t,n={}){return await this.request({url:`${this.baseURL}/${t}/export`,method:"POST",data:n,responseType:"blob"})}async getReportTemplates(t={}){const n=new URLSearchParams;t.type&&n.set("type",t.type),t.category&&n.set("category",t.category);const b=n.toString()?`${this.baseURL}/templates?${n}`:`${this.baseURL}/templates`;return this.get(b)}async createReportFromTemplate(t,n={}){return this.post(`${this.baseURL}/templates/${t}/create`,n)}async getDataSources(){return this.get(`${this.baseURL}/data-sources`)}async getDataSourceFields(t){return this.get(`${this.baseURL}/data-sources/${t}/fields`)}async getDataSourceSample(t,n={}){const b=new URLSearchParams;n.limit&&b.set("limit",n.limit);const E=b.toString()?`${this.baseURL}/data-sources/${t}/sample?${b}`:`${this.baseURL}/data-sources/${t}/sample`;return this.get(E)}async getReportSchedules(t={}){const n=new URLSearchParams;t.reportId&&n.set("reportId",t.reportId),t.isActive!==void 0&&n.set("isActive",t.isActive);const b=n.toString()?`${this.baseURL}/schedules?${n}`:`${this.baseURL}/schedules`;return this.get(b)}async createReportSchedule(t){return this.post(`${this.baseURL}/schedules`,t)}async updateReportSchedule(t,n){return this.put(`${this.baseURL}/schedules/${t}`,n)}async deleteReportSchedule(t){return this.delete(`${this.baseURL}/schedules/${t}`)}async testReportSchedule(t){return this.post(`${this.baseURL}/schedules/${t}/test`)}async getKPIs(t={}){const n=new URLSearchParams;t.category&&n.set("category",t.category),t.isActive!==void 0&&n.set("isActive",t.isActive),t.dashboardId&&n.set("dashboardId",t.dashboardId);const b=n.toString()?`/kpis?${n}`:"/kpis";return this.get(b)}async getKPIById(t){return this.get(`/kpis/${t}`)}async createKPI(t){return this.post("/kpis",t)}async updateKPI(t,n){return this.put(`/kpis/${t}`,n)}async deleteKPI(t){return this.delete(`/kpis/${t}`)}async calculateKPI(t,n={}){return this.post(`/kpis/${t}/calculate`,n)}async getKPIHistory(t,n={}){const b=new URLSearchParams;n.startDate&&b.set("startDate",n.startDate),n.endDate&&b.set("endDate",n.endDate),n.interval&&b.set("interval",n.interval);const E=b.toString()?`/kpis/${t}/history?${b}`:`/kpis/${t}/history`;return this.get(E)}async getDashboards(t={}){const n=new URLSearchParams;t.isPublic!==void 0&&n.set("isPublic",t.isPublic),t.createdBy&&n.set("createdBy",t.createdBy);const b=n.toString()?"/dashboards?${queryParams}":"/dashboards";return this.get(b)}async getDashboardById(t){return this.get(`/dashboards/${t}`)}async createDashboard(t){return this.post("/dashboards",t)}async updateDashboard(t,n){return this.put(`/dashboards/${t}`,n)}async deleteDashboard(t){return this.delete(`/dashboards/${t}`)}async duplicateDashboard(t,n={}){return this.post(`/dashboards/${t}/duplicate`,n)}async getDashboardData(t,n={}){return this.post(`/dashboards/${t}/data`,n)}async bulkDeleteReports(t){return this.post(`${this.baseURL}/bulk-delete`,{ids:t})}async bulkUpdateReportStatus(t,n){return this.post(`${this.baseURL}/bulk-update-status`,{ids:t,status:n})}async bulkExportReports(t,n={}){return await this.request({url:`${this.baseURL}/bulk-export`,method:"POST",data:{ids:t,...n},responseType:"blob"})}async getReportAnalytics(t={}){const n=new URLSearchParams;t.startDate&&n.set("startDate",t.startDate),t.endDate&&n.set("endDate",t.endDate),t.reportId&&n.set("reportId",t.reportId);const b=n.toString()?`${this.baseURL}/analytics?${n}`:`${this.baseURL}/analytics`;return this.get(b)}async getSystemMetrics(t={}){return this.get("/system/metrics",t)}}const k=new at,ye={DRAFT:"draft",PUBLISHED:"published",ARCHIVED:"archived"},Be=He("reports",()=>{const u=F(null),t=F(null),n=F([]),b=F([]),E=F({}),T=F([]),L=F(null),G=F({}),$=F([]),O=F(null),Y=F({}),J=F({}),M=F(null),l=F(!1),i=F(null),q=F({search:"",type:"",status:"",createdBy:"",tags:[]}),B=F(null),V=F(null),d=U(()=>{var a;return((a=u.value)==null?void 0:a.totalElements)||0}),h=U(()=>{var a,r;return((r=(a=u.value)==null?void 0:a.content)==null?void 0:r.filter(o=>o.status===ye.PUBLISHED))||[]}),_=U(()=>{var a,r;return((r=(a=u.value)==null?void 0:a.content)==null?void 0:r.filter(o=>o.status===ye.DRAFT))||[]}),w=U(()=>{var a,r;return((r=(a=u.value)==null?void 0:a.content)==null?void 0:r.filter(o=>o.status===ye.ARCHIVED))||[]}),S=U(()=>{var r,o;const a={};return(o=(r=u.value)==null?void 0:r.content)==null||o.forEach(m=>{a[m.type]||(a[m.type]=[]),a[m.type].push(m)}),a}),p=U(()=>{var a;return((a=T.value)==null?void 0:a.filter(r=>r.isActive))||[]}),g=U(()=>{var r;const a={};return(r=T.value)==null||r.forEach(o=>{a[o.category]||(a[o.category]=[]),a[o.category].push(o)}),a}),A=U(()=>{var a;return((a=$.value)==null?void 0:a.filter(r=>r.isPublic))||[]});return{reports:u,currentReport:t,reportTemplates:n,dataSources:b,dataSourceFields:E,kpis:T,currentKPI:L,kpiCalculations:G,dashboards:$,currentDashboard:O,dashboardData:Y,reportExecutions:J,previewData:M,loading:l,error:i,filters:q,reportAnalytics:B,systemMetrics:V,totalCount:d,publishedReports:h,draftReports:_,archivedReports:w,reportsByType:S,activeKPIs:p,kpisByCategory:g,publicDashboards:A,fetchReports:async(a={})=>{try{l.value=!0,i.value=null;const r={...a,...q.value};return u.value=await k.getReports(r),u.value}catch(r){throw i.value=r.message||"Failed to fetch reports",r}finally{l.value=!1}},fetchReportById:async a=>{try{return l.value=!0,i.value=null,t.value=await k.getReportById(a),t.value}catch(r){throw i.value=r.message||"Failed to fetch report",r}finally{l.value=!1}},createReport:async a=>{var r;try{l.value=!0,i.value=null;const o=await k.createReport(a);return(r=u.value)!=null&&r.content&&(u.value.content.unshift(o),u.value.totalElements++),t.value=o,o}catch(o){throw i.value=o.message||"Failed to create report",o}finally{l.value=!1}},updateReport:async(a,r)=>{var o,m;try{l.value=!0,i.value=null;const C=await k.updateReport(a,r);if((o=u.value)!=null&&o.content){const v=u.value.content.findIndex(s=>s.id===a);v!==-1&&(u.value.content[v]=C)}return((m=t.value)==null?void 0:m.id)===a&&(t.value=C),C}catch(C){throw i.value=C.message||"Failed to update report",C}finally{l.value=!1}},deleteReport:async a=>{var r,o;try{l.value=!0,i.value=null,await k.deleteReport(a),(r=u.value)!=null&&r.content&&(u.value.content=u.value.content.filter(m=>m.id!==a),u.value.totalElements--),((o=t.value)==null?void 0:o.id)===a&&(t.value=null),delete J.value[a]}catch(m){throw i.value=m.message||"Failed to delete report",m}finally{l.value=!1}},executeReport:async(a,r={})=>{try{l.value=!0,i.value=null;const o=await k.executeReport(a,r);return J.value[a]={...o,executedAt:new Date().toISOString(),params:r},o}catch(o){throw i.value=o.message||"Failed to execute report",o}finally{l.value=!1}},previewReport:async(a,r={})=>{try{return l.value=!0,i.value=null,M.value=await k.previewReport(a,r),M.value}catch(o){throw i.value=o.message||"Failed to preview report",o}finally{l.value=!1}},exportReport:async(a,r={})=>{var o,m;try{l.value=!0,i.value=null;const C=await k.exportReport(a,r),v=window.URL.createObjectURL(C),s=document.createElement("a");s.href=v;const c=new Date().toISOString().slice(0,10),Q=(m=(o=u.value)==null?void 0:o.content)==null?void 0:m.find(je=>je.id===a),Ke=`${(Q==null?void 0:Q.name)||"report"}_${c}.${r.format||"pdf"}`;return s.download=Ke,document.body.appendChild(s),s.click(),window.URL.revokeObjectURL(v),document.body.removeChild(s),C}catch(C){throw i.value=C.message||"Failed to export report",C}finally{l.value=!1}},fetchKPIs:async(a={})=>{try{return l.value=!0,i.value=null,T.value=await k.getKPIs(a),T.value}catch(r){throw i.value=r.message||"Failed to fetch KPIs",r}finally{l.value=!1}},fetchKPIById:async a=>{try{return l.value=!0,i.value=null,L.value=await k.getKPIById(a),L.value}catch(r){throw i.value=r.message||"Failed to fetch KPI",r}finally{l.value=!1}},createKPI:async a=>{try{l.value=!0,i.value=null;const r=await k.createKPI(a);return Array.isArray(T.value)&&T.value.unshift(r),L.value=r,r}catch(r){throw i.value=r.message||"Failed to create KPI",r}finally{l.value=!1}},updateKPI:async(a,r)=>{var o;try{l.value=!0,i.value=null;const m=await k.updateKPI(a,r);if(Array.isArray(T.value)){const C=T.value.findIndex(v=>v.id===a);C!==-1&&(T.value[C]=m)}return((o=L.value)==null?void 0:o.id)===a&&(L.value=m),m}catch(m){throw i.value=m.message||"Failed to update KPI",m}finally{l.value=!1}},deleteKPI:async a=>{var r;try{l.value=!0,i.value=null,await k.deleteKPI(a),Array.isArray(T.value)&&(T.value=T.value.filter(o=>o.id!==a)),((r=L.value)==null?void 0:r.id)===a&&(L.value=null),delete G.value[a]}catch(o){throw i.value=o.message||"Failed to delete KPI",o}finally{l.value=!1}},calculateKPI:async(a,r={})=>{try{l.value=!0,i.value=null;const o=await k.calculateKPI(a,r);return G.value[a]={...o,calculatedAt:new Date().toISOString(),params:r},o}catch(o){throw i.value=o.message||"Failed to calculate KPI",o}finally{l.value=!1}},getKPIHistory:async(a,r={})=>{try{return l.value=!0,i.value=null,await k.getKPIHistory(a,r)}catch(o){throw i.value=o.message||"Failed to fetch KPI history",o}finally{l.value=!1}},fetchDashboards:async(a={})=>{try{return l.value=!0,i.value=null,$.value=await k.getDashboards(a),$.value}catch(r){throw i.value=r.message||"Failed to fetch dashboards",r}finally{l.value=!1}},fetchDashboardById:async a=>{try{return l.value=!0,i.value=null,O.value=await k.getDashboardById(a),O.value}catch(r){throw i.value=r.message||"Failed to fetch dashboard",r}finally{l.value=!1}},createDashboard:async a=>{try{l.value=!0,i.value=null;const r=await k.createDashboard(a);return Array.isArray($.value)&&$.value.unshift(r),O.value=r,r}catch(r){throw i.value=r.message||"Failed to create dashboard",r}finally{l.value=!1}},updateDashboard:async(a,r)=>{var o;try{l.value=!0,i.value=null;const m=await k.updateDashboard(a,r);if(Array.isArray($.value)){const C=$.value.findIndex(v=>v.id===a);C!==-1&&($.value[C]=m)}return((o=O.value)==null?void 0:o.id)===a&&(O.value=m),m}catch(m){throw i.value=m.message||"Failed to update dashboard",m}finally{l.value=!1}},deleteDashboard:async a=>{var r;try{l.value=!0,i.value=null,await k.deleteDashboard(a),Array.isArray($.value)&&($.value=$.value.filter(o=>o.id!==a)),((r=O.value)==null?void 0:r.id)===a&&(O.value=null),delete Y.value[a]}catch(o){throw i.value=o.message||"Failed to delete dashboard",o}finally{l.value=!1}},duplicateDashboard:async(a,r={})=>{try{l.value=!0,i.value=null;const o=await k.duplicateDashboard(a,r);return Array.isArray($.value)&&$.value.unshift(o),o}catch(o){throw i.value=o.message||"Failed to duplicate dashboard",o}finally{l.value=!1}},getDashboardData:async(a,r={})=>{try{l.value=!0,i.value=null;const o=await k.getDashboardData(a,r);return Y.value[a]={...o,loadedAt:new Date().toISOString(),params:r},o}catch(o){throw i.value=o.message||"Failed to fetch dashboard data",o}finally{l.value=!1}},fetchDataSources:async()=>{try{return l.value=!0,i.value=null,b.value=await k.getDataSources(),b.value}catch(a){throw i.value=a.message||"Failed to fetch data sources",a}finally{l.value=!1}},fetchDataSourceFields:async a=>{try{l.value=!0,i.value=null;const r=await k.getDataSourceFields(a);return E.value[a]=r,r}catch(r){throw i.value=r.message||"Failed to fetch data source fields",r}finally{l.value=!1}},fetchDataSourceSample:async(a,r={})=>{try{return l.value=!0,i.value=null,await k.getDataSourceSample(a,r)}catch(o){throw i.value=o.message||"Failed to fetch data source sample",o}finally{l.value=!1}},fetchReportTemplates:async(a={})=>{try{return l.value=!0,i.value=null,n.value=await k.getReportTemplates(a),n.value}catch(r){throw i.value=r.message||"Failed to fetch report templates",r}finally{l.value=!1}},createReportFromTemplate:async(a,r={})=>{var o;try{l.value=!0,i.value=null;const m=await k.createReportFromTemplate(a,r);return(o=u.value)!=null&&o.content&&(u.value.content.unshift(m),u.value.totalElements++),t.value=m,m}catch(m){throw i.value=m.message||"Failed to create report from template",m}finally{l.value=!1}},fetchReportAnalytics:async(a={})=>{try{return l.value=!0,i.value=null,B.value=await k.getReportAnalytics(a),B.value}catch(r){throw i.value=r.message||"Failed to fetch report analytics",r}finally{l.value=!1}},fetchSystemMetrics:async(a={})=>{try{return l.value=!0,i.value=null,V.value=await k.getSystemMetrics(a),V.value}catch(r){throw i.value=r.message||"Failed to fetch system metrics",r}finally{l.value=!1}},bulkDeleteReports:async a=>{var r;try{l.value=!0,i.value=null;const o=await k.bulkDeleteReports(a);return(r=u.value)!=null&&r.content&&(u.value.content=u.value.content.filter(m=>!a.includes(m.id)),u.value.totalElements-=o.deleted||a.length),a.forEach(m=>{delete J.value[m]}),o}catch(o){throw i.value=o.message||"Failed to bulk delete reports",o}finally{l.value=!1}},bulkUpdateReportStatus:async(a,r)=>{var o;try{l.value=!0,i.value=null;const m=await k.bulkUpdateReportStatus(a,r);return(o=u.value)!=null&&o.content&&(u.value.content=u.value.content.map(C=>a.includes(C.id)?{...C,status:r}:C)),m}catch(m){throw i.value=m.message||"Failed to bulk update report status",m}finally{l.value=!1}},bulkExportReports:async(a,r={})=>{try{l.value=!0,i.value=null;const o=await k.bulkExportReports(a,r),m=window.URL.createObjectURL(o),C=document.createElement("a");C.href=m;const s=`reports_bulk_${new Date().toISOString().slice(0,10)}.zip`;return C.download=s,document.body.appendChild(C),C.click(),window.URL.revokeObjectURL(m),document.body.removeChild(C),o}catch(o){throw i.value=o.message||"Failed to bulk export reports",o}finally{l.value=!1}},updateFilters:a=>{q.value={...q.value,...a}},clearFilters:()=>{q.value={search:"",type:"",status:"",createdBy:"",tags:[]}},clearCurrentSelections:()=>{t.value=null,L.value=null,O.value=null,M.value=null}}});function st(){const u=Be(),t=U(()=>u.loading),n=U(()=>u.error),b=async()=>{try{const d=new Date,h=new Date(d.getFullYear(),d.getMonth(),1),_=new Date(d.getFullYear(),d.getMonth()+1,0);u.setDateRange(h.toISOString().split("T")[0],_.toISOString().split("T")[0]),await u.calculateKPIs(),await u.generateWorkOrderTrends(),await u.generateAssetPerformance()}catch(d){console.error("Failed to initialize analytics:",d)}},E=async()=>{await u.calculateKPIs(),await u.generateWorkOrderTrends(),await u.generateAssetPerformance()},T=async(d,h)=>{u.setDateRange(d,h),await E()},L=U(()=>{const d=u.kpis||{};return!d.workOrders||!d.maintenance||!d.costs?[]:[{id:"work-orders-total",title:"Total Work Orders",value:d.workOrders.total||0,subtitle:"This period",change:M(d.workOrders.total||0,145),icon:"clipboard-list",color:"blue",trend:(d.workOrders.total||0)>145?"up":"down"},{id:"work-orders-completion",title:"Completion Rate",value:`${u.workOrderCompletionRate||0}%`,subtitle:"Work orders completed",change:M(u.workOrderCompletionRate||0,87),icon:"check-circle",color:"green",trend:(u.workOrderCompletionRate||0)>87?"up":"down"},{id:"assets-operational",title:"Asset Uptime",value:`${u.assetOperationalRate||0}%`,subtitle:"Assets operational",change:M(u.assetOperationalRate||0,92),icon:"cpu",color:"purple",trend:(u.assetOperationalRate||0)>92?"up":"down"},{id:"maintenance-compliance",title:"PM Compliance",value:`${d.maintenance.preventiveCompliance||0}%`,subtitle:"On-time maintenance",change:M(d.maintenance.preventiveCompliance||0,89),icon:"shield-check",color:"indigo",trend:(d.maintenance.preventiveCompliance||0)>89?"up":"down"},{id:"avg-response-time",title:"Avg Response Time",value:`${d.maintenance.avgResponseTime||0}h`,subtitle:"Time to start work",change:M(d.maintenance.avgResponseTime||0,2.8,!0),icon:"clock",color:"orange",trend:(d.maintenance.avgResponseTime||0)<2.8?"up":"down"},{id:"total-costs",title:"Total Costs",value:V(d.costs.totalCosts||0),subtitle:"This period",change:M(d.costs.totalCosts||0,32450),icon:"currency-dollar",color:"yellow",trend:(d.costs.totalCosts||0)<32450?"up":"down"}]}),G=U(()=>{const d=u.workOrderTrends||[];return{labels:d.map(h=>h.period||""),datasets:[{label:"Work Orders Created",data:d.map(h=>h.count||0),borderColor:"rgb(59, 130, 246)",backgroundColor:"rgba(59, 130, 246, 0.1)",tension:.4}]}}),$=U(()=>(u.assetPerformance||[]).map(h=>({...h,healthColor:l(h.healthScore||0),uptimeColor:l(h.uptime||0),status:B(h.healthScore||0,h.uptime||0)}))),O=U(()=>{var S;const d=((S=u.kpis)==null?void 0:S.maintenance)||{},h=u.preventiveMaintenanceRatio||{preventive:0,reactive:0},_=d.preventiveCompliance||0,w=d.avgResponseTime||0;return{compliance:{rate:_,color:i(_),status:_>=95?"excellent":_>=85?"good":"needs-improvement"},responseTime:{hours:w,color:w<=2?"green":w<=4?"yellow":"red",status:w<=2?"excellent":w<=4?"good":"needs-improvement"},preventiveRatio:{preventive:h.preventive,reactive:h.reactive,color:h.preventive>=70?"green":h.preventive>=50?"yellow":"red",status:h.preventive>=70?"excellent":h.preventive>=50?"good":"needs-improvement"}}}),Y=U(()=>{var S;const d=((S=u.kpis)==null?void 0:S.costs)||{},h=u.costBreakdown||[],_=d.totalCosts||0,w=d.avgCostPerWorkOrder||0;return{total:V(_),avgPerWorkOrder:V(w),breakdown:h.map(p=>({...p,formattedAmount:V(p.amount||0),color:q(p.category)})),trends:{labels:["Jan","Feb","Mar","Apr","May","Jun"],data:[28e3,32e3,29e3,35e3,_,0]}}}),J=U(()=>{var _,w;const d=u.systemHealthScore||0,h=u.kpis||{};return{score:d,status:d>=90?"excellent":d>=75?"good":d>=60?"fair":"poor",color:l(d),components:{assets:{score:((_=h.assets)==null?void 0:_.avgHealth)||0,status:"Assets"},workOrders:{score:u.workOrderCompletionRate||0,status:"Work Orders"},maintenance:{score:((w=h.maintenance)==null?void 0:w.preventiveCompliance)||0,status:"Maintenance"}}}}),M=(d,h,_=!1)=>{if(h===0)return 0;const w=(d-h)/h*100;return _?-w:w},l=d=>d>=90?"green":d>=75?"yellow":d>=60?"orange":"red",i=d=>d>=95?"green":d>=85?"yellow":"red",q=d=>({Labor:"blue",Parts:"green",Contractors:"purple",Utilities:"orange"})[d]||"gray",B=(d,h)=>d>=90&&h>=95?"excellent":d>=75&&h>=85?"good":d>=60&&h>=70?"fair":"poor",V=d=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:0,maximumFractionDigits:0}).format(d);return{loading:t,error:n,initializeAnalytics:b,refreshAnalytics:E,updateDateRange:T,getKPIWidgets:L,getWorkOrderTrends:G,getAssetPerformanceData:$,getMaintenanceMetrics:O,getCostAnalysis:Y,getSystemHealth:J}}function rt(){const u=Be(),{addNotification:t}=qe(),n=F(!1),b=F(!1),E=[{value:"work-orders-summary",label:"Work Orders Summary",description:"Comprehensive overview of work order performance and trends",requiredData:["workOrders","assets"],defaultFields:["id","title","status","priority","assignee","createdAt","completedAt"]},{value:"asset-performance",label:"Asset Performance Report",description:"Asset health, uptime, and maintenance history analysis",requiredData:["assets","workOrders","maintenance"],defaultFields:["name","category","status","healthScore","uptime","lastMaintenance"]},{value:"maintenance-compliance",label:"Maintenance Compliance Report",description:"Preventive maintenance schedule adherence and compliance metrics",requiredData:["preventiveMaintenance","workOrders"],defaultFields:["schedule","asset","frequency","lastCompleted","nextDue","status"]},{value:"cost-analysis",label:"Cost Analysis Report",description:"Detailed breakdown of maintenance costs and budget analysis",requiredData:["workOrders","parts","labor"],defaultFields:["workOrder","category","laborCost","partsCost","totalCost","date"]},{value:"technician-performance",label:"Technician Performance Report",description:"Individual technician productivity and performance metrics",requiredData:["workOrders","users"],defaultFields:["technician","completedTasks","avgCompletionTime","qualityScore"]},{value:"inventory-usage",label:"Inventory Usage Report",description:"Parts consumption, stock levels, and procurement analysis",requiredData:["parts","workOrders","inventory"],defaultFields:["partName","category","quantityUsed","currentStock","reorderPoint"]}],T=[{value:"csv",label:"CSV",description:"Comma-separated values for spreadsheet analysis"},{value:"xlsx",label:"Excel",description:"Microsoft Excel workbook with formatting"},{value:"pdf",label:"PDF",description:"Formatted PDF document for sharing"},{value:"json",label:"JSON",description:"Structured data for API integration"}],L=async p=>{n.value=!0;try{M(p);const g={...p,generatedAt:new Date().toISOString(),generatedBy:l(),version:"1.0"},A=await u.createCustomReport(g);return t({type:"success",title:"Report Generated",message:`${p.name} has been generated successfully`}),A}catch(g){throw console.error("Failed to generate report:",g),t({type:"error",title:"Report Generation Failed",message:g.message}),g}finally{n.value=!1}},G=async(p,g="csv",A={})=>{b.value=!0;try{const D=await u.exportReport(p,g);switch(g){case"csv":await i(p,D,A);break;case"xlsx":await q(p,D,A);break;case"pdf":await B(p,D,A);break;case"json":await V(p,D,A);break;default:throw new Error(`Unsupported export format: ${g}`)}return t({type:"success",title:"Export Successful",message:`Report exported as ${D}`}),D}catch(D){throw console.error("Failed to export report:",D),t({type:"error",title:"Export Failed",message:D.message}),D}finally{b.value=!1}},$=U(()=>Object.values(u.customReports).map(p=>({...p,formattedDate:w(p.createdAt),canExport:!0,canDelete:!0}))),O=U(()=>u.exportHistory.map(p=>({...p,formattedDate:S(p.timestamp)}))),Y=async p=>{try{const g=`schedule_${Date.now()}`;return t({type:"success",title:"Report Scheduled",message:`${p.name} will run ${p.schedule.frequency}`}),g}catch(g){throw console.error("Failed to schedule report:",g),t({type:"error",title:"Schedule Failed",message:g.message}),g}},J=async p=>{try{delete u.customReports[p],t({type:"success",title:"Report Deleted",message:"Custom report has been removed"})}catch(g){throw console.error("Failed to delete report:",g),t({type:"error",title:"Delete Failed",message:g.message}),g}},M=p=>{if(!p.name||p.name.trim().length===0)throw new Error("Report name is required");if(!p.type||!E.find(g=>g.value===p.type))throw new Error("Valid report type is required");if(!p.dateRange||!p.dateRange.start||!p.dateRange.end)throw new Error("Date range is required");if(new Date(p.dateRange.start)>=new Date(p.dateRange.end))throw new Error("End date must be after start date")},l=()=>({id:1,name:"Current User",email:"user@example.com"}),i=async(p,g,A)=>{const D=u.customReports[p];if(!D)throw new Error("Report not found");const j=d(D.data,A);_(j,g,"text/csv")},q=async(p,g,A)=>{if(!u.customReports[p])throw new Error("Report not found");console.log("Excel export would be implemented with SheetJS or similar"),await i(p,g.replace(".xlsx",".csv"),A)},B=async(p,g,A)=>{const D=u.customReports[p];if(!D)throw new Error("Report not found");console.log("PDF export would be implemented with jsPDF or Puppeteer");const j=h(D);_(j,g,"application/pdf")},V=async(p,g,A)=>{const D=u.customReports[p];if(!D)throw new Error("Report not found");const j=JSON.stringify(D,null,2);_(j,g,"application/json")},d=(p,g={})=>{if(!p||!p.details||p.details.length===0)return"No data available";const A=p.details,D=Object.keys(A[0]);return[D.join(","),...A.map(W=>D.map(le=>{const z=W[le];return typeof z=="string"&&(z.includes(",")||z.includes('"'))?`"${z.replace(/"/g,'""')}"`:z}).join(","))].join("\\n")},h=(p,g)=>`PDF Report: ${p.name}\\nGenerated: ${p.createdAt}\\n\\nContent would be formatted here...`,_=(p,g,A)=>{const D=new Blob([p],{type:A}),j=URL.createObjectURL(D),W=document.createElement("a");W.href=j,W.download=g,W.style.display="none",document.body.appendChild(W),W.click(),document.body.removeChild(W),URL.revokeObjectURL(j)},w=p=>new Date(p).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}),S=p=>new Date(p).toLocaleString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"});return{generatingReport:n,exportingReport:b,reportTypes:E,exportFormats:T,generateReport:L,exportReport:G,scheduleReport:Y,deleteReport:J,getCustomReports:$,getExportHistory:O}}const ot={class:"flex items-center space-x-3"},nt={class:"border-l border-gray-300 pl-3 ml-3"},lt={class:"flex items-center space-x-2 -mt-5"},it={class:"mt-5"},ct={class:"p-6"},ut={key:0,class:"flex items-center justify-center py-12"},dt={key:1,class:"rounded-lg bg-red-50 border border-red-200 p-4 mb-6"},pt={class:"flex"},vt={class:"ml-3"},mt={class:"mt-1 text-sm text-red-700"},yt={key:2,class:"space-y-8"},ht={class:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6"},gt={class:"flex items-center"},ft={class:"flex-shrink-0"},bt={key:0,"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 5H7a2 2 0 00-2 2v10a2 2 0 002 2h8a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-3 7h3m-3 4h3m-6-4h.01M9 16h.01"},wt={key:1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"},xt={key:2,"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 3v2m6-2v2M9 19v2m6-2v2M5 9H3m2 6H3m18-6h-2m2 6h-2M7 19h10a2 2 0 002-2V7a2 2 0 00-2-2H7a2 2 0 00-2 2v10a2 2 0 002 2zM9 9h6v6H9V9z"},Rt={key:3,"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z"},kt={key:4,"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"},_t={key:5,"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 8c-1.657 0-3 .895-3 2s1.343 2 3 2 3 .895 3 2-1.343 2-3 2m0-8c1.11 0 2.08.402 2.599 1M12 8V7m0 1v8m0 0v1m0-1c-1.11 0-2.08-.402-2.599-1"},Dt={class:"ml-4 flex-1"},Ct={class:"text-sm font-medium text-gray-600"},St={class:"flex items-baseline"},Pt={class:"text-2xl font-semibold text-gray-900"},Ft={key:0,class:"self-center flex-shrink-0 h-4 w-4",fill:"currentColor",viewBox:"0 0 20 20"},It={key:1,class:"self-center flex-shrink-0 h-4 w-4",fill:"currentColor",viewBox:"0 0 20 20"},Ut={class:"sr-only"},At={key:0,class:"text-xs text-gray-500 mt-1"},$t={class:"grid grid-cols-1 lg:grid-cols-2 gap-8"},Tt={class:"flex items-center justify-between mb-6"},Lt={class:"h-64"},Ot={class:"flex items-center justify-between mb-6"},Mt={class:"flex items-center"},Vt={class:"text-sm font-medium"},Et={class:"text-center mb-6"},Bt={class:"text-4xl font-bold text-gray-900 mb-2"},Kt={class:"space-y-3"},jt={class:"text-sm text-gray-600"},zt={class:"flex items-center"},Ht={class:"w-16 bg-gray-200 rounded-full h-2 mr-3"},qt={class:"text-sm font-medium text-gray-900 w-8"},Wt={class:"overflow-x-auto"},Nt={class:"min-w-full divide-y divide-gray-200"},Jt={class:"bg-white divide-y divide-gray-200"},Gt={class:"px-6 py-4 whitespace-nowrap"},Yt={class:"text-sm font-medium text-gray-900"},Qt={class:"text-sm text-gray-500"},Zt={class:"px-6 py-4 whitespace-nowrap"},Xt={class:"flex items-center"},ea={class:"w-16 bg-gray-200 rounded-full h-2 mr-3"},ta={class:"text-sm text-gray-900"},aa={class:"px-6 py-4 whitespace-nowrap text-sm text-gray-900"},sa={class:"px-6 py-4 whitespace-nowrap text-sm text-gray-900"},ra={class:"px-6 py-4 whitespace-nowrap"},oa={key:3,class:"space-y-8"},na={class:"grid grid-cols-1 md:grid-cols-3 gap-6"},la={class:"flex items-center"},ia={class:"text-3xl font-bold text-gray-900"},ca={class:"ml-3"},ua={class:"flex items-center"},da={class:"text-3xl font-bold text-gray-900"},pa={class:"ml-3"},va={class:"flex items-center"},ma={class:"text-3xl font-bold text-gray-900"},ya={class:"ml-3"},ha={class:"grid grid-cols-1 lg:grid-cols-2 gap-8"},ga={class:"space-y-3"},fa={class:"flex items-center justify-between"},ba={class:"text-sm font-medium text-gray-900"},wa={class:"flex items-center justify-between"},xa={class:"text-sm font-medium text-gray-900"},Ra={class:"space-y-3"},ka={class:"flex justify-between"},_a={class:"text-sm font-medium text-gray-900"},Da={class:"flex justify-between"},Ca={class:"text-sm font-medium text-gray-900"},Sa={class:"flex justify-between"},Pa={class:"text-sm font-medium text-gray-900"},Fa={key:4,class:"space-y-8"},Ia={class:"grid grid-cols-1 md:grid-cols-4 gap-6"},Ua={class:"text-3xl font-bold text-gray-900"},Aa={class:"text-3xl font-bold text-gray-900"},$a={class:"text-sm font-medium text-gray-600 mb-2"},Ta={class:"text-3xl font-bold text-gray-900"},La={class:"text-sm text-gray-500 mt-1"},Oa={class:"space-y-4"},Ma={class:"flex items-center"},Va={class:"font-medium text-gray-900"},Ea={class:"text-sm text-gray-600"},Ba={class:"text-right"},Ka={class:"text-lg font-bold text-gray-900"},ja={class:"space-y-4"},za={class:"grid grid-cols-2 gap-4"},Ha={class:"flex items-center justify-between"},qa={class:"flex items-center space-x-4"},Wa={key:0,class:"flex items-center text-sm text-gray-500"},Na={key:0,class:"w-4 h-4 mr-2 text-amber-500 animate-pulse",fill:"currentColor",viewBox:"0 0 20 20"},Ja={key:1,class:"w-4 h-4 mr-2 text-green-500",fill:"currentColor",viewBox:"0 0 20 20"},Ga={key:2},Ya={key:3},Qa={class:"flex space-x-3"},Za={__name:"ReportsView",setup(u){const{loading:t,error:n,initializeAnalytics:b,refreshAnalytics:E,updateDateRange:T,getKPIWidgets:L,getWorkOrderTrends:G,getAssetPerformanceData:$,getMaintenanceMetrics:O,getCostAnalysis:Y,getSystemHealth:J}=st(),{generatingReport:M,exportingReport:l,reportTypes:i,generateReport:q}=rt(),B=F("overview"),V=F(!1),d=F("30d"),h=F(null),_=F(null),w=F({start:"",end:""}),S=F({name:"",type:"",startDate:"",endDate:"",description:""}),{hasUnsavedChanges:p,lastSaveTime:g,restoreFormData:A,clearSavedData:D,hasSavedData:j,getSavedDataInfo:W,markUserInteraction:le}=Ye(S,{storageKey:"atlas_custom_report_form_data",saveInterval:3e3,excludeFields:[]}),z=F(!1),de=F(null),pe=U(()=>L.value),ie=U(()=>G.value),he=U(()=>$.value),K=U(()=>O.value),re=U(()=>Y.value),X=U(()=>J.value),ge=[{key:"overview",label:"Overview"},{key:"maintenance",label:"Maintenance"},{key:"costs",label:"Cost Analysis"}],fe=[{label:"Last 7 days",value:"7d"},{label:"Last 30 days",value:"30d"},{label:"Last 90 days",value:"90d"},{label:"Last year",value:"1y"}],be=U(()=>i.map(v=>({label:v.label,value:v.value}))),we=U(()=>g.value?new Date(g.value).toLocaleTimeString():""),xe=async()=>{await E()},Re=async()=>{console.log("Exporting all reports...")},ke=()=>{_e(),j()||(S.value={name:"",type:"",startDate:w.value.start,endDate:w.value.end,description:""}),V.value=!0},_e=()=>{j()&&(de.value=W(),z.value=!0,console.log("✅ Found saved report data, showing restore notification"))},ce=()=>{D(),V.value=!1,z.value=!1,S.value={name:"",type:"",startDate:"",endDate:"",description:""}},ve=async()=>{try{await q({name:S.value.name,type:S.value.type,dateRange:{start:S.value.startDate,end:S.value.endDate},description:S.value.description}),D(),ce()}catch(v){console.error("Failed to create custom report:",v)}},De=()=>{A(),z.value=!1,console.log("Report form data restored successfully")},Ce=()=>{D(),z.value=!1,S.value={name:"",type:"",startDate:w.value.start,endDate:w.value.end,description:""},console.log("Report auto-saved data dismissed")},ee=()=>{console.log("🔥 Report user interaction detected!"),le()},Se=async()=>{w.value.start&&w.value.end&&(await T(w.value.start,w.value.end),m())},Pe=v=>{B.value=v},Fe=v=>({blue:"bg-blue-100",green:"bg-green-100",purple:"bg-purple-100",indigo:"bg-indigo-100",orange:"bg-orange-100",yellow:"bg-yellow-100"})[v]||"bg-gray-100",Ie=v=>({blue:"text-blue-600",green:"text-green-600",purple:"text-purple-600",indigo:"text-indigo-600",orange:"text-orange-600",yellow:"text-yellow-600"})[v]||"text-gray-600",Ue=(v,s)=>s==="up"?"text-green-600":s==="down"?"text-red-600":"text-gray-500",Ae=v=>v>=90?"bg-green-500":v>=75?"bg-yellow-500":v>=60?"bg-orange-500":"bg-red-500",$e=v=>v>=90?"bg-green-500":v>=75?"bg-yellow-500":v>=60?"bg-orange-500":"bg-red-500",Te=v=>({excellent:"success",good:"info",fair:"warning",poor:"error"})[v]||"secondary",Le=v=>v>=95?"success":v>=85?"warning":"error",Oe=v=>v<=2?"success":v<=4?"warning":"error",a=v=>v>=70?"success":v>=50?"warning":"error",r=v=>({blue:"bg-blue-500",green:"bg-green-500",purple:"bg-purple-500",orange:"bg-orange-500"})[v]||"bg-gray-500",o=async()=>{if(!(!h.value||!window.Chart))try{const v=h.value.getContext("2d");_.value&&_.value.destroy(),_.value=new window.Chart(v,{type:"line",data:ie.value,options:{responsive:!0,maintainAspectRatio:!1,scales:{y:{beginAtZero:!0,grid:{color:"rgba(0, 0, 0, 0.1)"}},x:{grid:{display:!1}}},plugins:{legend:{display:!1}},elements:{point:{radius:4,hoverRadius:6}}}})}catch(v){console.error("Failed to initialize chart:",v)}},m=()=>{_.value&&(_.value.data=ie.value,_.value.update())},C=async()=>{if(!window.Chart)try{const{Chart:v,registerables:s}=await Ge(async()=>{const{Chart:c,registerables:Q}=await import("./chart-C0bvbYRK.js");return{Chart:c,registerables:Q}},[]);v.register(...s),window.Chart=v}catch(v){console.error("Failed to load Chart.js:",v)}};return Me(()=>ie.value,()=>{_.value&&m()},{deep:!0}),Me(()=>d.value,()=>{console.log("Chart period changed:",d.value)}),Ne(async()=>{const v=new Date,s=new Date(v.getFullYear(),v.getMonth(),1);w.value.start=s.toISOString().split("T")[0],w.value.end=v.toISOString().split("T")[0],await b(),await C(),setTimeout(()=>{o()},100)}),Je(()=>{_.value&&_.value.destroy()}),(v,s)=>(x(),me(Qe,null,{header:I(()=>[R(Ze,{title:"Reports & Analytics",description:"Real-time analytics and insights for facility management operations",breadcrumbs:[{text:"Reports",to:null}]},{actions:I(()=>[e("div",ot,[R(y(ae),{variant:"outline",size:"sm",onClick:Re,loading:y(l)},{default:I(()=>s[10]||(s[10]=[e("svg",{class:"w-4 h-4 mr-2",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 10v6m0 0l-3-3m3 3l3-3m2 8H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})],-1),N(" Export All ",-1)])),_:1,__:[10]},8,["loading"]),R(y(ae),{variant:"outline",size:"sm",onClick:xe,loading:y(t)},{default:I(()=>s[11]||(s[11]=[e("svg",{class:"w-4 h-4 mr-2",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})],-1),N(" Refresh ",-1)])),_:1,__:[11]},8,["loading"]),R(y(ae),{variant:"primary",size:"sm",onClick:ke},{default:I(()=>s[12]||(s[12]=[e("svg",{class:"w-4 h-4 mr-2",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 4v16m8-8H4"})],-1),N(" Custom Report ",-1)])),_:1,__:[12]}),e("div",nt,[e("div",lt,[e("div",null,[s[13]||(s[13]=e("label",{class:"block text-xs font-medium text-gray-700 mb-1"},"From",-1)),R(y(se),{modelValue:w.value.start,"onUpdate:modelValue":s[0]||(s[0]=c=>w.value.start=c),type:"date",size:"sm"},null,8,["modelValue"])]),e("div",null,[s[14]||(s[14]=e("label",{class:"block text-xs font-medium text-gray-700 mb-1"},"To",-1)),R(y(se),{modelValue:w.value.end,"onUpdate:modelValue":s[1]||(s[1]=c=>w.value.end=c),type:"date",size:"sm"},null,8,["modelValue"])]),e("div",it,[R(y(ae),{variant:"outline",size:"sm",onClick:Se},{default:I(()=>s[15]||(s[15]=[N(" Apply ",-1)])),_:1,__:[15]})])])])])]),tabs:I(()=>[R(y(et),{modelValue:B.value,"onUpdate:modelValue":s[2]||(s[2]=c=>B.value=c),tabs:ge,onTabChange:Pe},null,8,["modelValue"])]),_:1})]),default:I(()=>[e("div",ct,[y(t)&&!pe.value.length?(x(),P("div",ut,s[16]||(s[16]=[e("div",{class:"text-center"},[e("div",{class:"animate-spin rounded-full h-12 w-12 border-b-2 border-primary-600 mx-auto"}),e("p",{class:"mt-4 text-gray-600"},"Loading analytics...")],-1)]))):y(n)?(x(),P("div",dt,[e("div",pt,[s[18]||(s[18]=e("div",{class:"flex-shrink-0"},[e("svg",{class:"h-5 w-5 text-red-400",viewBox:"0 0 20 20",fill:"currentColor"},[e("path",{"fill-rule":"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z","clip-rule":"evenodd"})])],-1)),e("div",vt,[s[17]||(s[17]=e("h3",{class:"text-sm font-medium text-red-800"},"Analytics Error",-1)),e("p",mt,f(y(n)),1)])])])):B.value==="overview"?(x(),P("div",yt,[e("div",ht,[(x(!0),P(oe,null,ne(pe.value,c=>(x(),me(y(H),{padding:"lg",key:c.id},{default:I(()=>[e("div",gt,[e("div",ft,[e("div",{class:Z(["w-10 h-10 rounded-lg flex items-center justify-center",Fe(c.color)])},[(x(),P("svg",{class:Z(["w-5 h-5",Ie(c.color)]),fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[c.icon==="clipboard-list"?(x(),P("path",bt)):c.icon==="check-circle"?(x(),P("path",wt)):c.icon==="cpu"?(x(),P("path",xt)):c.icon==="shield-check"?(x(),P("path",Rt)):c.icon==="clock"?(x(),P("path",kt)):c.icon==="currency-dollar"?(x(),P("path",_t)):te("",!0)],2))],2)]),e("div",Dt,[e("p",Ct,f(c.title),1),e("div",St,[e("p",Pt,f(c.value),1),c.change!==void 0?(x(),P("p",{key:0,class:Z(["ml-2 flex items-baseline text-sm font-semibold",Ue(c.change,c.trend)])},[c.trend==="up"?(x(),P("svg",Ft,s[19]||(s[19]=[e("path",{"fill-rule":"evenodd",d:"M3.293 9.707a1 1 0 010-1.414l6-6a1 1 0 011.414 0l6 6a1 1 0 01-1.414 1.414L11 5.414V17a1 1 0 11-2 0V5.414L4.707 9.707a1 1 0 01-1.414 0z","clip-rule":"evenodd"},null,-1)]))):(x(),P("svg",It,s[20]||(s[20]=[e("path",{"fill-rule":"evenodd",d:"M16.707 10.293a1 1 0 010 1.414l-6 6a1 1 0 01-1.414 0l-6-6a1 1 0 111.414-1.414L9 14.586V3a1 1 0 012 0v11.586l4.293-4.293a1 1 0 011.414 0z","clip-rule":"evenodd"},null,-1)]))),e("span",Ut,f(c.trend==="up"?"Increased":"Decreased")+" by",1),N(" "+f(Math.abs(c.change).toFixed(1))+"% ",1)],2)):te("",!0)]),c.subtitle?(x(),P("p",At,f(c.subtitle),1)):te("",!0)])])]),_:2},1024))),128))]),e("div",$t,[R(y(H),{padding:"lg"},{default:I(()=>[e("div",Tt,[s[21]||(s[21]=e("h3",{class:"text-lg font-semibold text-gray-900"},"Work Orders Over Time",-1)),R(y(Ee),{modelValue:d.value,"onUpdate:modelValue":s[3]||(s[3]=c=>d.value=c),options:fe,size:"sm"},null,8,["modelValue"])]),e("div",Lt,[e("canvas",{ref_key:"workOrdersChart",ref:h},null,512)])]),_:1}),R(y(H),{padding:"lg"},{default:I(()=>[e("div",Ot,[s[22]||(s[22]=e("h3",{class:"text-lg font-semibold text-gray-900"},"System Health",-1)),e("div",Mt,[e("div",{class:Z(["w-3 h-3 rounded-full mr-2",Ae(X.value.score)])},null,2),e("span",Vt,f(X.value.status.toUpperCase()),1)])]),e("div",Et,[e("div",Bt,f(X.value.score)+"%",1),s[23]||(s[23]=e("p",{class:"text-gray-600"},"Overall System Health",-1))]),e("div",Kt,[(x(!0),P(oe,null,ne(X.value.components,(c,Q)=>(x(),P("div",{key:Q,class:"flex items-center justify-between"},[e("span",jt,f(c.status),1),e("div",zt,[e("div",Ht,[e("div",{class:Z(["h-2 rounded-full",$e(c.score)]),style:Ve({width:`${c.score}%`})},null,6)]),e("span",qt,f(c.score)+"%",1)])]))),128))])]),_:1})]),R(y(H),{padding:"lg"},{default:I(()=>[s[25]||(s[25]=e("h3",{class:"text-lg font-semibold text-gray-900 mb-6"},"Asset Performance Overview",-1)),e("div",Wt,[e("table",Nt,[s[24]||(s[24]=e("thead",{class:"bg-gray-50"},[e("tr",null,[e("th",{class:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider"},"Asset"),e("th",{class:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider"},"Health Score"),e("th",{class:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider"},"Uptime"),e("th",{class:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider"},"MTTR"),e("th",{class:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider"},"Status")])],-1)),e("tbody",Jt,[(x(!0),P(oe,null,ne(he.value.slice(0,5),c=>(x(),P("tr",{key:c.id},[e("td",Gt,[e("div",Yt,f(c.name),1),e("div",Qt,f(c.category),1)]),e("td",Zt,[e("div",Xt,[e("div",ea,[e("div",{class:Z(["h-2 rounded-full",c.healthColor]),style:Ve({width:`${c.healthScore}%`})},null,6)]),e("span",ta,f(c.healthScore)+"%",1)])]),e("td",aa,f(c.uptime)+"%",1),e("td",sa,f(c.mttr)+"h",1),e("td",ra,[R(y(ue),{variant:Te(c.status)},{default:I(()=>[N(f(c.status),1)]),_:2},1032,["variant"])])]))),128))])])])]),_:1,__:[25]})])):B.value==="maintenance"?(x(),P("div",oa,[e("div",na,[R(y(H),{padding:"lg"},{default:I(()=>[s[26]||(s[26]=e("h4",{class:"text-sm font-medium text-gray-600 mb-2"},"Preventive Maintenance Compliance",-1)),e("div",la,[e("div",ia,f(K.value.compliance.rate)+"%",1),e("div",ca,[R(y(ue),{variant:Le(K.value.compliance.rate)},{default:I(()=>[N(f(K.value.compliance.status),1)]),_:1},8,["variant"])])]),s[27]||(s[27]=e("p",{class:"text-sm text-gray-500 mt-1"},"On-time maintenance tasks",-1))]),_:1,__:[26,27]}),R(y(H),{padding:"lg"},{default:I(()=>[s[28]||(s[28]=e("h4",{class:"text-sm font-medium text-gray-600 mb-2"},"Average Response Time",-1)),e("div",ua,[e("div",da,f(K.value.responseTime.hours)+"h",1),e("div",pa,[R(y(ue),{variant:Oe(K.value.responseTime.hours)},{default:I(()=>[N(f(K.value.responseTime.status),1)]),_:1},8,["variant"])])]),s[29]||(s[29]=e("p",{class:"text-sm text-gray-500 mt-1"},"Time to start work",-1))]),_:1,__:[28,29]}),R(y(H),{padding:"lg"},{default:I(()=>[s[30]||(s[30]=e("h4",{class:"text-sm font-medium text-gray-600 mb-2"},"Preventive vs Reactive",-1)),e("div",va,[e("div",ma,f(K.value.preventiveRatio.preventive)+"%",1),e("div",ya,[R(y(ue),{variant:a(K.value.preventiveRatio.preventive)},{default:I(()=>[N(f(K.value.preventiveRatio.status),1)]),_:1},8,["variant"])])]),s[31]||(s[31]=e("p",{class:"text-sm text-gray-500 mt-1"},"Preventive maintenance ratio",-1))]),_:1,__:[30,31]})]),R(y(H),{padding:"lg"},{default:I(()=>[s[39]||(s[39]=e("h3",{class:"text-lg font-semibold text-gray-900 mb-6"},"Maintenance Performance Details",-1)),e("div",ha,[e("div",null,[s[34]||(s[34]=e("h4",{class:"text-md font-medium text-gray-900 mb-4"},"Preventive vs Reactive Breakdown",-1)),e("div",ga,[e("div",fa,[s[32]||(s[32]=e("div",{class:"flex items-center"},[e("div",{class:"w-3 h-3 bg-green-500 rounded-full mr-3"}),e("span",{class:"text-sm text-gray-700"},"Preventive Maintenance")],-1)),e("span",ba,f(K.value.preventiveRatio.preventive)+"%",1)]),e("div",wa,[s[33]||(s[33]=e("div",{class:"flex items-center"},[e("div",{class:"w-3 h-3 bg-red-500 rounded-full mr-3"}),e("span",{class:"text-sm text-gray-700"},"Reactive Maintenance")],-1)),e("span",xa,f(K.value.preventiveRatio.reactive)+"%",1)])])]),e("div",null,[s[38]||(s[38]=e("h4",{class:"text-md font-medium text-gray-900 mb-4"},"Performance Indicators",-1)),e("div",Ra,[e("div",ka,[s[35]||(s[35]=e("span",{class:"text-sm text-gray-600"},"Compliance Rate",-1)),e("span",_a,f(K.value.compliance.rate)+"%",1)]),e("div",Da,[s[36]||(s[36]=e("span",{class:"text-sm text-gray-600"},"Avg Response Time",-1)),e("span",Ca,f(K.value.responseTime.hours)+"h",1)]),e("div",Sa,[s[37]||(s[37]=e("span",{class:"text-sm text-gray-600"},"System Health",-1)),e("span",Pa,f(X.value.score)+"%",1)])])])])]),_:1,__:[39]})])):B.value==="costs"?(x(),P("div",Fa,[e("div",Ia,[R(y(H),{padding:"lg"},{default:I(()=>[s[40]||(s[40]=e("h4",{class:"text-sm font-medium text-gray-600 mb-2"},"Total Costs",-1)),e("p",Ua,f(re.value.total),1),s[41]||(s[41]=e("p",{class:"text-sm text-gray-500 mt-1"},"This period",-1))]),_:1,__:[40,41]}),R(y(H),{padding:"lg"},{default:I(()=>[s[42]||(s[42]=e("h4",{class:"text-sm font-medium text-gray-600 mb-2"},"Avg per Work Order",-1)),e("p",Aa,f(re.value.avgPerWorkOrder),1),s[43]||(s[43]=e("p",{class:"text-sm text-gray-500 mt-1"},"Average cost",-1))]),_:1,__:[42,43]}),(x(!0),P(oe,null,ne(re.value.breakdown.slice(0,2),c=>(x(),me(y(H),{padding:"lg",key:c.category},{default:I(()=>[e("h4",$a,f(c.category),1),e("p",Ta,f(c.formattedAmount),1),e("p",La,f(c.percentage)+"% of total",1)]),_:2},1024))),128))]),R(y(H),{padding:"lg"},{default:I(()=>[s[44]||(s[44]=e("h3",{class:"text-lg font-semibold text-gray-900 mb-6"},"Cost Breakdown by Category",-1)),e("div",Oa,[(x(!0),P(oe,null,ne(re.value.breakdown,c=>(x(),P("div",{key:c.category,class:"flex items-center justify-between p-4 bg-gray-50 rounded-lg"},[e("div",Ma,[e("div",{class:Z(["w-4 h-4 rounded-full mr-4",r(c.color)])},null,2),e("div",null,[e("h4",Va,f(c.category),1),e("p",Ea,f(c.percentage)+"% of total costs",1)])]),e("div",Ba,[e("p",Ka,f(c.formattedAmount),1)])]))),128))])]),_:1,__:[44]})])):te("",!0)]),R(y(Xe),{modelValue:V.value,"onUpdate:modelValue":s[9]||(s[9]=c=>V.value=c),title:"Create Custom Report",size:"lg",onConfirm:ve,onCancel:ce},{footer:I(()=>[e("div",Ha,[e("div",qa,[y(p)||y(g)?(x(),P("div",Wa,[y(p)?(x(),P("svg",Na,s[45]||(s[45]=[e("path",{"fill-rule":"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm1-12a1 1 0 10-2 0v4a1 1 0 00.293.707l2.828 2.829a1 1 0 101.415-1.415L11 9.586V6z","clip-rule":"evenodd"},null,-1)]))):(x(),P("svg",Ja,s[46]||(s[46]=[e("path",{"fill-rule":"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z","clip-rule":"evenodd"},null,-1)]))),y(p)?(x(),P("span",Ga,"Auto-saving...")):y(g)?(x(),P("span",Ya,"Last saved "+f(we.value),1)):te("",!0)])):te("",!0)]),e("div",Qa,[R(y(ae),{variant:"secondary",onClick:ce},{default:I(()=>s[47]||(s[47]=[N(" Cancel ",-1)])),_:1,__:[47]}),R(y(ae),{variant:"primary",loading:y(M),onClick:ve},{default:I(()=>s[48]||(s[48]=[N(" Create Report ",-1)])),_:1,__:[48]},8,["loading"])])])]),default:I(()=>[R(y(tt),{visible:z.value,"saved-data-info":de.value,onRestore:De,onDismiss:Ce},null,8,["visible","saved-data-info"]),e("div",ja,[R(y(se),{modelValue:S.value.name,"onUpdate:modelValue":s[4]||(s[4]=c=>S.value.name=c),label:"Report Name",placeholder:"Enter report name",required:"",onInput:ee},null,8,["modelValue"]),R(y(Ee),{modelValue:S.value.type,"onUpdate:modelValue":s[5]||(s[5]=c=>S.value.type=c),label:"Report Type",options:be.value,required:"",onChange:ee},null,8,["modelValue","options"]),e("div",za,[R(y(se),{modelValue:S.value.startDate,"onUpdate:modelValue":s[6]||(s[6]=c=>S.value.startDate=c),label:"Start Date",type:"date",required:"",onInput:ee},null,8,["modelValue"]),R(y(se),{modelValue:S.value.endDate,"onUpdate:modelValue":s[7]||(s[7]=c=>S.value.endDate=c),label:"End Date",type:"date",required:"",onInput:ee},null,8,["modelValue"])]),R(y(se),{modelValue:S.value.description,"onUpdate:modelValue":s[8]||(s[8]=c=>S.value.description=c),label:"Description",placeholder:"Describe what this report should include",type:"textarea",onInput:ee},null,8,["modelValue"])])]),_:1},8,["modelValue"])]),_:1}))}},cs=We(Za,[["__scopeId","data-v-0db11884"]]);export{cs as default};