import{r as d,c as k,o as la,s as oa,v as sa,i as P,w as r,l as na,g as i,b as l,d as s,e as t,F as b,n as B,k as C,h as Y,a as p,j as V,af as ra,aQ as ia,aR as ua,t as m,ae as pe,aU as ge}from"./index-BUdRbiwj.js";import{u as da,a as ma,M as X,b as fe,U as va,c as Z,d as ca,e as ee,f as D}from"./useMeterManagement-CqU4p7ia.js";import{u as pa}from"./assets-eZiqmOvX.js";import{u as ga}from"./locations-IQR_pcEX.js";import{u as fa}from"./useFormAutoSave-Jaawgo91.js";import{F as ya,a as ba}from"./FPPageHeader-CTG2L28r.js";import{F as M}from"./FPInput-CzR_dWoe.js";import{F as L}from"./FPCheckbox-Bu8jNAEW.js";import{F as R}from"./FPSelect-C7p47Ma2.js";import{F as ha}from"./FPStats-BGfZcDZc.js";import{F as xa}from"./FPTable-CU8C_NYc.js";import{F as ae}from"./FPModal-DWGF1LV8.js";import{F as ye}from"./FPBadge-BKY5dPnL.js";import{F as be}from"./FPTabs-R71V25QN.js";import{_ as ka}from"./FormRestoreNotification-DYBlXhOP.js";import"./FPCard-qHzcEQAE.js";const Va={class:"p-6"},Ca={class:"mb-6 grid grid-cols-1 md:grid-cols-5 gap-4"},Ma={class:"flex items-center space-x-2"},_a={class:"flex items-center space-x-3"},Fa={key:0,class:"flex-shrink-0 w-10 h-10"},Ra=["src","alt"],wa={key:1,class:"flex-shrink-0 w-10 h-10 bg-gray-100 rounded-lg flex items-center justify-center"},Ta={class:"text-sm font-medium text-gray-900"},Ua={class:"text-xs text-gray-500"},Da={class:"text-sm"},Ia={class:"font-medium text-gray-900"},Sa={class:"text-xs text-gray-500"},Aa={class:"text-sm"},Ea={key:0,class:"text-xs text-red-500 mt-1"},za={class:"flex items-center space-x-1"},Pa={key:0,class:"text-xs text-gray-500 ml-1"},Ba={key:1,class:"text-sm text-gray-400"},La={class:"flex items-center space-x-2"},Na={class:"space-y-6"},Oa={key:0,class:"space-y-4"},ja={class:"grid grid-cols-1 md:grid-cols-2 gap-4"},qa={key:0,class:"mt-1 text-sm text-red-600"},Ha={key:1,class:"space-y-4"},$a={class:"grid grid-cols-1 md:grid-cols-2 gap-4"},Ya={class:"grid grid-cols-1 md:grid-cols-2 gap-4"},Qa={class:"space-y-3"},Wa={class:"flex justify-between pt-4 border-t"},Ka={key:1},Ga={class:"flex items-center justify-between"},Ja={class:"flex items-center space-x-4"},Xa={key:0,class:"flex items-center text-sm text-gray-500"},Za={key:0,class:"w-4 h-4 mr-2 text-amber-500 animate-pulse",fill:"currentColor",viewBox:"0 0 20 20"},et={key:1,class:"w-4 h-4 mr-2 text-green-500",fill:"currentColor",viewBox:"0 0 20 20"},at={key:2},tt={key:3},lt={class:"flex space-x-3"},ot={class:"space-y-4"},st={key:0},nt={class:"bg-gray-50 rounded-lg p-3 mb-4"},rt={class:"font-medium text-gray-900"},it={class:"text-sm text-gray-600"},ut={class:"text-xs text-gray-500 mt-1"},dt={class:"block text-sm font-medium text-gray-700 mb-2"},mt=["required"],vt={key:0,class:"mt-1 text-sm text-red-600"},ct={class:"space-y-2"},It={__name:"MetersListView",setup(pt){const te=oa(),Q=sa(),v=da(),le=pa(),oe=ga(),{success:I,error:w}=na(),{createMeter:he,updateMeter:xe,deleteMeter:ke,recordMeterReading:Ve,formatMeterForDisplay:se,error:N}=ma(),W=d(!1),T=d("all"),U=d(!1),S=d(!1),A=d(!1),E=d(null),g=d(null),K=d(!1),z=d("create"),h=d("basic"),n=d({...Z}),y=d({...ee}),u=d({}),_=d({}),O=d(!1),G=d(!1),f=d({search:"",type:"",asset:"",location:"",showDue:!1}),j=d({page:1,size:20,total:0,sortBy:"name",sortDirection:"asc"}),{hasUnsavedChanges:J,lastSaveTime:q,clearSavedData:ne,hasSavedData:Ce,getSavedDataInfo:Me,markUserInteraction:c,finishInitialization:_e,restoreFormData:Fe}=fa(n,{storageKey:"atlas_meter_form_data",saveInterval:3e3,excludeFields:[]}),H=d(!1),re=d(null),Re=[{key:"all",label:"All Meters",badge:k(()=>v.totalCount||0)},{key:"active",label:"Active",badge:k(()=>(v.activeMeters||[]).length)},{key:"due",label:"Due for Reading",badge:k(()=>(v.dueForReading||[]).length)},{key:"overdue",label:"Overdue",badge:k(()=>(v.overdueReadings||[]).length)}],we=[{key:"basic",label:"Basic Information",icon:"info"},{key:"config",label:"Configuration",icon:"cog"}],Te=[{key:"name",label:"Name",sortable:!0},{key:"type",label:"Type",sortable:!0},{key:"status",label:"Status",sortable:!0},{key:"currentReading",label:"Current Reading",sortable:!1},{key:"asset",label:"Asset",sortable:!1},{key:"nextReading",label:"Next Reading",sortable:!0,key:"nextReadingDate"},{key:"assignedUsers",label:"Assigned Users",sortable:!1},{key:"actions",label:"Actions",sortable:!1,width:"150px"}],Ue=k(()=>{let o=v.filteredMeters||[];return T.value==="active"?o=v.activeMeters||[]:T.value==="due"?o=v.dueForReading||[]:T.value==="overdue"&&(o=v.overdueReadings||[]),f.value.showDue&&(o=o.filter(a=>a&&a.isReadingDue)),o.filter(a=>a!=null).map(a=>{try{return se?se(a):a}catch(e){return console.warn("Error in formatMeterForDisplay:",e),a}}).filter(a=>a!=null)}),De=k(()=>[{label:"Total Meters",value:v.totalCount||0,color:"blue"},{label:"Active",value:(v.activeMeters||[]).length,color:"green"},{label:"Due for Reading",value:(v.dueForReading||[]).length,color:"orange"},{label:"Overdue",value:(v.overdueReadings||[]).length,color:"red"}]),Ie=k(()=>[{value:"",label:"All Types"},...Object.entries(X).map(([o,a])=>({value:fe[o],label:a}))]),ie=k(()=>{var a,e;const o=((e=(a=le.assets)==null?void 0:a.value)==null?void 0:e.content)||[];return[{value:"",label:"All Assets"},...o.map(x=>({value:x.id,label:x.name}))]}),ue=k(()=>{var a,e;const o=((e=(a=oe.locations)==null?void 0:a.value)==null?void 0:e.content)||[];return[{value:"",label:"All Locations"},...o.map(x=>({value:x.id,label:x.name}))]}),Se=k(()=>Object.entries(X).map(([o,a])=>({value:fe[o],label:a}))),Ae=k(()=>va.map(o=>({value:o.value,label:o.label}))),F=async()=>{try{W.value=!0,await Promise.all([v.fetchMeters(),le.fetchAssets({page:0,size:100}),oe.searchLocations({page:0,size:100})])}catch(o){w(o.message||"Failed to load data")}finally{W.value=!1}},Ee=()=>{F()},$=()=>{v.updateFilters(f.value)},ze=o=>{T.value=o},Pe=({key:o,direction:a})=>{j.value.sortBy=o,j.value.sortDirection=a,F()},Be=o=>{j.value.page=o,F()},Le=()=>{f.value.showDue=!f.value.showDue},Ne=()=>{f.value={search:"",type:"",asset:"",location:"",showDue:!1},v.updateFilters({})},Oe=async()=>{Fe()&&(H.value=!1,I("Your previously saved form data has been restored.","Form Data Restored"))},je=()=>{ne(),H.value=!1},qe=k(()=>{if(!q.value)return"";const o=new Date,a=new Date(q.value),e=Math.floor((o-a)/1e3);return e<60?`${e}s ago`:e<3600?`${Math.floor(e/60)}m ago`:`${Math.floor(e/3600)}h ago`}),de=()=>{z.value="create",n.value={...Z},h.value="basic",u.value={},U.value=!0},me=async o=>{try{z.value="edit",h.value="basic",u.value={};const a=await v.fetchMeterById(o);n.value={...a},U.value=!0}catch{w("Failed to load meter details")}},ve=o=>{Q.push(`/meters/${o.id}`)},He=async()=>{try{O.value=!0,u.value={},z.value==="create"?(await he(n.value),I("Meter created successfully")):(await xe(n.value.id,n.value),I("Meter updated successfully")),ne(),U.value=!1,await F()}catch(o){N.value&&(u.value={general:N.value}),w(o.message||"Failed to save meter")}finally{O.value=!1}},ce=()=>{U.value=!1,n.value={...Z},u.value={}},$e=()=>{h.value==="basic"&&(h.value="config")},Ye=()=>{h.value==="config"&&(h.value="basic")},Qe=o=>{g.value=o,y.value={...ee,meterId:o.id,readingDate:new Date().toISOString().split("T")[0]},_.value={},S.value=!0},We=async()=>{try{G.value=!0,_.value={},await Ve(g.value.id,y.value,g.value),I("Reading recorded successfully"),S.value=!1,g.value=null,await F()}catch(o){N.value&&(_.value={general:N.value}),w(o.message||"Failed to record reading")}finally{G.value=!1}},Ke=()=>{S.value=!1,g.value=null,y.value={...ee},_.value={}},Ge=o=>{E.value=o,A.value=!0},Je=async()=>{try{K.value=!0,await ke(E.value.id),I("Meter deleted successfully"),A.value=!1,E.value=null,await F()}catch{w("Failed to delete meter")}finally{K.value=!1}},Xe=()=>{A.value=!1,E.value=null},Ze=async()=>{try{const o=await v.exportMeters({format:"csv",fields:["name","type","status","unit","currentReading","assetName"]}),a=window.URL.createObjectURL(o),e=document.createElement("a");e.href=a,e.download="meters.csv",document.body.appendChild(e),e.click(),window.URL.revokeObjectURL(a),document.body.removeChild(e)}catch{w("Failed to export meters")}},ea=o=>X[o]||o,aa=o=>ca[o]||o,ta=o=>({[D.ACTIVE]:"success",[D.INACTIVE]:"secondary",[D.OUT_OF_SERVICE]:"error",[D.MAINTENANCE]:"warning",[D.CALIBRATION_DUE]:"warning",[D.FAULTY]:"error"})[o]||"secondary";return la(async()=>{if(await F(),_e(),Ce()){const e=Me();re.value=e,H.value=!0}const o=te.query.edit;o&&setTimeout(()=>{me(parseInt(o)),Q.replace({path:"/meters"})},500),te.query.create==="true"&&setTimeout(()=>{de(),Q.replace({path:"/meters"})},500)}),(o,a)=>(i(),P(ya,null,{header:r(()=>[s(ba,{title:"Meters",description:"Manage meters and track readings for assets and locations",breadcrumbs:[{text:"Meters",to:null}]},{actions:r(()=>[s(t(b),{variant:"outline",size:"sm",onClick:Ze},{default:r(()=>a[31]||(a[31]=[l("svg",{class:"w-4 h-4 mr-2",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[l("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),C(" Export ",-1)])),_:1,__:[31]}),s(t(b),{variant:"outline",size:"sm",onClick:Ee},{default:r(()=>a[32]||(a[32]=[l("svg",{class:"w-4 h-4 mr-2",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[l("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),C(" Refresh ",-1)])),_:1,__:[32]}),s(t(b),{variant:"primary",size:"sm",onClick:de},{default:r(()=>a[33]||(a[33]=[l("svg",{class:"w-4 h-4 mr-2",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[l("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 4v16m8-8H4"})],-1),C(" Add Meter ",-1)])),_:1,__:[33]})]),stats:r(()=>[s(t(ha),{stats:De.value},null,8,["stats"])]),tabs:r(()=>[s(t(be),{modelValue:T.value,"onUpdate:modelValue":a[0]||(a[0]=e=>T.value=e),tabs:Re,onTabChange:ze},null,8,["modelValue"])]),_:1})]),default:r(()=>[l("div",Va,[l("div",Ca,[s(t(M),{modelValue:f.value.search,"onUpdate:modelValue":a[1]||(a[1]=e=>f.value.search=e),placeholder:"Search meters...",onInput:$},{prepend:r(()=>a[34]||(a[34]=[l("svg",{class:"w-4 h-4 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[l("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})],-1)])),_:1},8,["modelValue"]),s(t(R),{modelValue:f.value.type,"onUpdate:modelValue":[a[2]||(a[2]=e=>f.value.type=e),$],placeholder:"Filter by Type",options:Ie.value},null,8,["modelValue","options"]),s(t(R),{modelValue:f.value.asset,"onUpdate:modelValue":[a[3]||(a[3]=e=>f.value.asset=e),$],placeholder:"Filter by Asset",options:ie.value},null,8,["modelValue","options"]),s(t(R),{modelValue:f.value.location,"onUpdate:modelValue":[a[4]||(a[4]=e=>f.value.location=e),$],placeholder:"Filter by Location",options:ue.value},null,8,["modelValue","options"]),l("div",Ma,[s(t(b),{variant:"outline",size:"sm",class:B(f.value.showDue?"bg-orange-50 border-orange-200 text-orange-700":""),onClick:Le},{default:r(()=>a[35]||(a[35]=[l("svg",{class:"w-4 h-4 mr-1",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[l("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})],-1),C(" Due ",-1)])),_:1,__:[35]},8,["class"]),s(t(b),{variant:"ghost",size:"sm",onClick:Ne},{default:r(()=>a[36]||(a[36]=[C(" Clear All ",-1)])),_:1,__:[36]})])]),s(t(xa),{columns:Te,data:Ue.value,loading:W.value,pagination:j.value,"empty-message":"No meters found",onSortChange:Pe,onPageChange:Be,onRowClick:ve},{name:r(({row:e})=>[l("div",_a,[e.image?(i(),p("div",Fa,[l("img",{src:e.image.url,alt:e.name,class:"w-10 h-10 rounded-lg object-cover"},null,8,Ra)])):(i(),p("div",wa,a[37]||(a[37]=[l("svg",{class:"w-5 h-5 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[l("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"})],-1)]))),l("div",null,[l("div",Ta,m(e.name),1),l("div",Ua,m(e.unit),1)])])]),type:r(({row:e})=>[s(t(ye),{variant:"secondary"},{default:r(()=>[C(m(ea(e.type)),1)]),_:2},1024)]),status:r(({row:e})=>[s(t(ye),{variant:ta(e.status)},{default:r(()=>[C(m(aa(e.status)),1)]),_:2},1032,["variant"])]),currentReading:r(({row:e})=>[l("div",Da,[l("span",Ia,m(e.formattedCurrentReading),1),l("div",Sa,m(e.unit),1)])]),asset:r(({row:e})=>[l("span",{class:B(["text-sm",e.assetName?"text-gray-900":"text-gray-400"])},m(e.assetName||"No asset"),3)]),nextReading:r(({row:e})=>[l("div",Aa,[l("span",{class:B([e.readingStatusColor,"px-2 py-1 rounded-full text-xs font-medium"])},m(e.formattedNextReadingDate),3),e.isReadingOverdue?(i(),p("div",Ea," Overdue ")):V("",!0)])]),assignedUsers:r(({row:e})=>[l("div",za,[(i(!0),p(ra,null,ia(((e==null?void 0:e.users)||[]).slice(0,3),(x,gt)=>(i(),P(t(ua),{key:x.id,user:x,size:"sm"},null,8,["user"]))),128)),((e==null?void 0:e.users)||[]).length>3?(i(),p("span",Pa," +"+m(((e==null?void 0:e.users)||[]).length-3),1)):V("",!0),((e==null?void 0:e.users)||[]).length?V("",!0):(i(),p("span",Ba," Unassigned "))])]),actions:r(({row:e})=>[l("div",La,[s(t(b),{variant:"ghost",size:"sm",onClick:Y(x=>Qe(e),["stop"]),disabled:!e||e.status!=="active",title:"Record Reading"},{default:r(()=>a[38]||(a[38]=[l("svg",{class:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[l("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15.232 5.232l3.536 3.536m-2.036-5.036a2.5 2.5 0 113.536 3.536L6.5 21.036H3v-3.572L16.732 3.732z"})],-1)])),_:2,__:[38]},1032,["onClick","disabled"]),s(t(b),{variant:"ghost",size:"sm",onClick:Y(x=>ve(e),["stop"]),disabled:!e},{default:r(()=>a[39]||(a[39]=[l("svg",{class:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[l("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"}),l("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"})],-1)])),_:2,__:[39]},1032,["onClick","disabled"]),s(t(b),{variant:"ghost",size:"sm",onClick:Y(x=>me(e==null?void 0:e.id),["stop"]),disabled:!(e!=null&&e.id)},{default:r(()=>a[40]||(a[40]=[l("svg",{class:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[l("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})],-1)])),_:2,__:[40]},1032,["onClick","disabled"]),s(t(b),{variant:"ghost",size:"sm",class:"text-red-600 hover:text-red-700",onClick:Y(x=>Ge(e),["stop"]),disabled:!e},{default:r(()=>a[41]||(a[41]=[l("svg",{class:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[l("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})],-1)])),_:2,__:[41]},1032,["onClick","disabled"])])]),_:1},8,["data","loading","pagination"])]),s(t(ae),{modelValue:U.value,"onUpdate:modelValue":a[23]||(a[23]=e=>U.value=e),title:z.value==="create"?"Create Meter":"Edit Meter",size:"xl",onCancel:ce},{footer:r(()=>[l("div",Ga,[l("div",Ja,[t(J)||t(q)?(i(),p("div",Xa,[t(J)?(i(),p("svg",Za,a[45]||(a[45]=[l("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)]))):(i(),p("svg",et,a[46]||(a[46]=[l("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)]))),t(J)?(i(),p("span",at,"Auto-saving...")):t(q)?(i(),p("span",tt,"Last saved "+m(qe.value),1)):V("",!0)])):V("",!0)]),l("div",lt,[s(t(b),{variant:"outline",onClick:ce,disabled:O.value},{default:r(()=>a[47]||(a[47]=[C(" Cancel ",-1)])),_:1,__:[47]},8,["disabled"]),s(t(b),{variant:"primary",onClick:He,loading:O.value},{default:r(()=>[C(m(z.value==="create"?"Create Meter":"Update Meter"),1)]),_:1},8,["loading"])])])]),default:r(()=>[s(t(ka),{visible:H.value,"saved-data-info":re.value,onRestore:Oe,onDismiss:je},null,8,["visible","saved-data-info"]),l("div",Na,[s(t(be),{modelValue:h.value,"onUpdate:modelValue":a[5]||(a[5]=e=>h.value=e),tabs:we},null,8,["modelValue"]),h.value==="basic"?(i(),p("div",Oa,[l("div",ja,[s(t(M),{modelValue:n.value.name,"onUpdate:modelValue":a[6]||(a[6]=e=>n.value.name=e),label:"Meter Name",placeholder:"Enter meter name",required:"",error:u.value.name,onInput:t(c)},null,8,["modelValue","error","onInput"]),s(t(R),{modelValue:n.value.type,"onUpdate:modelValue":a[7]||(a[7]=e=>n.value.type=e),label:"Meter Type",placeholder:"Select type",options:Se.value,required:"",error:u.value.type,onChange:t(c)},null,8,["modelValue","options","error","onChange"]),s(t(M),{modelValue:n.value.unit,"onUpdate:modelValue":a[8]||(a[8]=e=>n.value.unit=e),label:"Unit",placeholder:"e.g. kWh, hours, gallons",required:"",error:u.value.unit,onInput:t(c)},null,8,["modelValue","error","onInput"]),s(t(R),{modelValue:n.value.updateFrequency,"onUpdate:modelValue":a[9]||(a[9]=e=>n.value.updateFrequency=e),label:"Reading Frequency",placeholder:"Select frequency",options:Ae.value,required:"",error:u.value.updateFrequency,onChange:t(c)},null,8,["modelValue","options","error","onChange"])]),l("div",null,[a[42]||(a[42]=l("label",{class:"block text-sm font-medium text-gray-700 mb-2"},"Description",-1)),pe(l("textarea",{"onUpdate:modelValue":a[10]||(a[10]=e=>n.value.description=e),class:B(["w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-primary-500 focus:border-primary-500",{"border-red-300":u.value.description}]),placeholder:"Describe the meter and its purpose",rows:"3",onInput:a[11]||(a[11]=(...e)=>t(c)&&t(c)(...e))},null,34),[[ge,n.value.description]]),u.value.description?(i(),p("p",qa,m(u.value.description),1)):V("",!0)])])):V("",!0),h.value==="config"?(i(),p("div",Ha,[l("div",$a,[s(t(R),{modelValue:n.value.assetId,"onUpdate:modelValue":a[12]||(a[12]=e=>n.value.assetId=e),label:"Asset",placeholder:"Select asset (optional)",options:ie.value,error:u.value.assetId,onChange:t(c)},null,8,["modelValue","options","error","onChange"]),s(t(R),{modelValue:n.value.locationId,"onUpdate:modelValue":a[13]||(a[13]=e=>n.value.locationId=e),label:"Location",placeholder:"Select location (optional)",options:ue.value,error:u.value.locationId,onChange:t(c)},null,8,["modelValue","options","error","onChange"]),s(t(M),{modelValue:n.value.decimalPlaces,"onUpdate:modelValue":a[14]||(a[14]=e=>n.value.decimalPlaces=e),label:"Decimal Places",type:"number",min:"0",max:"6",placeholder:"2",error:u.value.decimalPlaces,onInput:t(c)},null,8,["modelValue","error","onInput"]),s(t(M),{modelValue:n.value.calibrationInterval,"onUpdate:modelValue":a[15]||(a[15]=e=>n.value.calibrationInterval=e),label:"Calibration Interval (days)",type:"number",min:"1",placeholder:"365",error:u.value.calibrationInterval,onInput:t(c)},null,8,["modelValue","error","onInput"])]),l("div",Ya,[s(t(M),{modelValue:n.value.minValue,"onUpdate:modelValue":a[16]||(a[16]=e=>n.value.minValue=e),label:"Minimum Value",type:"number",step:"0.01",placeholder:"Optional",error:u.value.minValue,onInput:t(c)},null,8,["modelValue","error","onInput"]),s(t(M),{modelValue:n.value.maxValue,"onUpdate:modelValue":a[17]||(a[17]=e=>n.value.maxValue=e),label:"Maximum Value",type:"number",step:"0.01",placeholder:"Optional",error:u.value.maxValue,onInput:t(c)},null,8,["modelValue","error","onInput"]),s(t(M),{modelValue:n.value.warningThreshold,"onUpdate:modelValue":a[18]||(a[18]=e=>n.value.warningThreshold=e),label:"Warning Threshold",type:"number",step:"0.01",placeholder:"Optional",error:u.value.warningThreshold,onInput:t(c)},null,8,["modelValue","error","onInput"]),s(t(M),{modelValue:n.value.criticalThreshold,"onUpdate:modelValue":a[19]||(a[19]=e=>n.value.criticalThreshold=e),label:"Critical Threshold",type:"number",step:"0.01",placeholder:"Optional",error:u.value.criticalThreshold,onInput:t(c)},null,8,["modelValue","error","onInput"])]),l("div",Qa,[s(t(L),{modelValue:n.value.isMonotonic,"onUpdate:modelValue":a[20]||(a[20]=e=>n.value.isMonotonic=e),label:"Monotonic (values can only increase)",onChange:t(c)},null,8,["modelValue","onChange"]),s(t(L),{modelValue:n.value.allowNegativeReadings,"onUpdate:modelValue":a[21]||(a[21]=e=>n.value.allowNegativeReadings=e),label:"Allow negative readings",onChange:t(c)},null,8,["modelValue","onChange"]),s(t(L),{modelValue:n.value.requiresComment,"onUpdate:modelValue":a[22]||(a[22]=e=>n.value.requiresComment=e),label:"Require comment with readings",onChange:t(c)},null,8,["modelValue","onChange"])])])):V("",!0),l("div",Wa,[h.value!=="basic"?(i(),P(t(b),{key:0,variant:"outline",onClick:Ye},{default:r(()=>a[43]||(a[43]=[C(" Previous ",-1)])),_:1,__:[43]})):(i(),p("div",Ka)),h.value!=="config"?(i(),P(t(b),{key:2,variant:"outline",onClick:$e},{default:r(()=>a[44]||(a[44]=[C(" Next ",-1)])),_:1,__:[44]})):V("",!0)])])]),_:1},8,["modelValue","title"]),s(t(ae),{modelValue:S.value,"onUpdate:modelValue":a[29]||(a[29]=e=>S.value=e),title:"Record Meter Reading",onConfirm:We,onCancel:Ke,"confirm-text":"Record Reading",loading:G.value},{default:r(()=>[l("div",ot,[g.value?(i(),p("div",st,[l("div",nt,[l("h4",rt,m(g.value.name),1),l("p",it,m(g.value.description),1),l("div",ut," Current: "+m(g.value.formattedCurrentReading)+" "+m(g.value.unit),1)]),s(t(M),{modelValue:y.value.value,"onUpdate:modelValue":a[24]||(a[24]=e=>y.value.value=e),label:"Reading Value",type:"number",step:Math.pow(10,-(g.value.decimalPlaces||2)),placeholder:"Enter reading value",required:"",error:_.value.value},null,8,["modelValue","step","error"]),s(t(M),{modelValue:y.value.readingDate,"onUpdate:modelValue":a[25]||(a[25]=e=>y.value.readingDate=e),type:"date",label:"Reading Date",placeholder:"Select reading date",error:_.value.readingDate},null,8,["modelValue","error"]),l("div",null,[l("label",dt,m(g.value.requiresComment?"Comment (Required)":"Comment (Optional)"),1),pe(l("textarea",{"onUpdate:modelValue":a[26]||(a[26]=e=>y.value.comment=e),class:B(["w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-primary-500 focus:border-primary-500",{"border-red-300":_.value.comment}]),placeholder:"Add any notes about this reading",rows:"3",required:g.value.requiresComment},null,10,mt),[[ge,y.value.comment]]),_.value.comment?(i(),p("p",vt,m(_.value.comment),1)):V("",!0)]),l("div",ct,[s(t(L),{modelValue:y.value.isEstimated,"onUpdate:modelValue":a[27]||(a[27]=e=>y.value.isEstimated=e),label:"This is an estimated reading"},null,8,["modelValue"]),g.value.isMonotonic?(i(),P(t(L),{key:0,modelValue:y.value.isRollover,"onUpdate:modelValue":a[28]||(a[28]=e=>y.value.isRollover=e),label:"This is a rollover reading (meter reset to zero)"},null,8,["modelValue"])):V("",!0)])])):V("",!0)])]),_:1},8,["modelValue","loading"]),s(t(ae),{modelValue:A.value,"onUpdate:modelValue":a[30]||(a[30]=e=>A.value=e),title:"Delete Meter",onConfirm:Je,onCancel:Xe,"confirm-text":"Delete","cancel-text":"Cancel","confirm-variant":"error",loading:K.value},{default:r(()=>{var e;return[l("p",null,'Are you sure you want to delete the meter "'+m((e=E.value)==null?void 0:e.name)+'"? This action cannot be undone and will remove all associated readings.',1)]}),_:1},8,["modelValue","loading"])]),_:1}))}};export{It as default};