import{_ as se,r as I,c,m as oe,a as n,g as l,b as e,j as m,d as b,w as _,k as h,e as v,F as C,t as d,n as q,Q as le,af as L,aQ as U,i as A,aR as ae}from"./index-BUdRbiwj.js";import{F as z}from"./FPInput-CzR_dWoe.js";import{F as te}from"./FPSelect-C7p47Ma2.js";import{F as ne}from"./FPBadge-BKY5dPnL.js";import{S as K}from"./workOrder-jNxj_kjQ.js";const re={class:"cost-tracker"},ie={class:"flex items-center justify-between mb-4"},de={class:"flex items-center space-x-2"},ue={class:"flex items-center space-x-2"},me={class:"grid grid-cols-1 md:grid-cols-5 gap-4 mb-6"},ce={class:"bg-blue-50 border border-blue-200 rounded-lg p-4"},ve={class:"flex items-center"},ge={class:"text-lg font-bold text-blue-900"},xe={class:"bg-green-50 border border-green-200 rounded-lg p-4"},pe={class:"flex items-center"},he={class:"text-lg font-bold text-green-900"},fe={class:"bg-orange-50 border border-orange-200 rounded-lg p-4"},ke={class:"flex items-center"},be={class:"text-lg font-bold text-orange-900"},ye={class:"bg-indigo-50 border border-indigo-200 rounded-lg p-4"},we={class:"flex items-center"},_e={class:"text-lg font-bold text-indigo-900"},Ce={class:"bg-purple-50 border border-purple-200 rounded-lg p-4"},Me={class:"flex items-center"},$e={class:"text-lg font-bold text-purple-900"},Ve={class:"mb-6"},Se={class:"bg-gray-50 border border-gray-200 rounded-lg p-4"},je={class:"flex items-center justify-center"},Be={class:"text-center"},ze={class:"text-2xl font-bold text-gray-900"},Ie={class:"flex items-center justify-between mb-2"},Ae={class:"text-sm"},Le={class:"w-full bg-gray-200 rounded-full h-2"},Ue={class:"bg-white border border-gray-200 rounded-lg overflow-hidden"},He={class:"divide-y divide-gray-200"},Fe={key:0,class:"p-4"},Ne={class:"space-y-2"},De={class:"flex-1"},Te={class:"text-gray-900"},Oe={class:"text-gray-500 ml-2"},Ee={class:"font-medium text-gray-900"},Pe={key:1,class:"p-4"},Re={class:"space-y-2"},qe={class:"flex-1"},Ge={class:"text-gray-900"},Qe={class:"text-gray-500 ml-2"},Je={class:"font-medium text-gray-900"},Ke={key:2,class:"p-4"},We={class:"space-y-2"},Xe={class:"flex-1"},Ye={key:0,class:"text-gray-900"},Ze={class:"flex items-center space-x-2"},et={key:0,class:"font-medium text-gray-900"},tt={class:"flex items-center space-x-1"},st=["onClick"],ot=["onClick"],lt=["onClick"],at={key:3,class:"p-4"},nt={class:"space-y-2"},rt={class:"flex-1"},it={key:0,class:"text-gray-900"},dt={class:"flex items-center space-x-2"},ut={key:0,class:"font-medium text-gray-900"},mt={class:"flex items-center space-x-1"},ct=["onClick"],vt=["onClick"],gt=["onClick"],xt={key:4,class:"p-4"},pt={class:"space-y-2"},ht={class:"flex-1"},ft={key:0,class:"text-gray-900"},kt={class:"flex items-center space-x-2"},bt={key:0,class:"font-medium text-gray-900"},yt={class:"flex items-center space-x-1"},wt=["onClick"],_t=["onClick"],Ct=["onClick"],Mt={key:5,class:"p-8 text-center text-gray-500"},$t={key:1,class:"mt-4 p-3 bg-yellow-50 border border-yellow-200 rounded-lg"},Vt={class:"flex items-center justify-between"},St={key:0,class:"mt-3 flex items-center space-x-2"},jt={__name:"CostTracker",props:{modelValue:{type:Object,default:()=>({costs:[],budget:0})},parts:{type:Array,default:()=>[]},timeEntries:{type:Array,default:()=>[]},disabled:{type:Boolean,default:!1}},emits:["update:modelValue"],setup(f,{emit:W}){const k=f,G=W,r=I([...k.modelValue.costs]),y=I(k.modelValue.budget||0),M=I(!1),g=I(0),H=c(()=>k.timeEntries.map(a=>({id:a.id,description:a.description||"Labor time",duration:a.duration,hourlyRate:a.hourlyRate||0,cost:a.duration*(a.hourlyRate||0)}))),$=c(()=>k.parts.map(a=>({id:a.id,partNumber:a.partNumber,name:a.name,quantity:a.quantity,unitCost:a.unitCost||0,cost:a.quantity*(a.unitCost||0)}))),F=c(()=>H.value.reduce((a,t)=>a+t.cost,0)),N=c(()=>$.value.reduce((a,t)=>a+t.cost,0)),D=c(()=>r.value.map((a,t)=>({...a,originalIndex:t})).filter(a=>a.category==="Material")),T=c(()=>r.value.map((a,t)=>({...a,originalIndex:t})).filter(a=>a.category==="Labor")),O=c(()=>r.value.map((a,t)=>({...a,originalIndex:t})).filter(a=>a.category==="Other")),Q=c(()=>D.value.reduce((a,t)=>a+(t.amount||0),0)),E=c(()=>T.value.reduce((a,t)=>a+(t.amount||0),0)),J=c(()=>O.value.reduce((a,t)=>a+(t.amount||0),0)),P=c(()=>Q.value+E.value+J.value),j=c(()=>F.value+N.value+P.value),w=c(()=>y.value>0?Math.round(j.value/y.value*100):0),X=c(()=>w.value>100?"bg-red-50 border border-red-200":w.value>80?"bg-yellow-50 border border-yellow-200":"bg-green-50 border border-green-200"),Y=c(()=>w.value>100?"bg-red-500":w.value>80?"bg-yellow-500":"bg-green-500"),Z=c(()=>w.value>100?"text-red-600":w.value>80?"text-yellow-600":"text-green-600"),ee=c(()=>H.value.length>0||$.value.length>0||r.value.length>0),u=a=>{const t={material:"Material",labor:"Labor",other:"Other"},o={id:Date.now()+Math.random(),description:"",amount:0,category:t[a]||"Other",editing:!0};r.value.push(o),S()},s=a=>{r.value[a].editing=!0},x=a=>{r.value[a].editing=!1,r.value[a].description||(r.value[a].description=`${r.value[a].category} Cost`),(isNaN(r.value[a].amount)||r.value[a].amount<0)&&(r.value[a].amount=0),S()},i=a=>{r.value.splice(a,1),S()},B=()=>{y.value=g.value,M.value=!1,g.value=0,S()},V=a=>{if(!a)return"0:00";const t=Math.floor(a),o=Math.round((a-t)*60);return`${t}:${o.toString().padStart(2,"0")}`},S=()=>{G("update:modelValue",{costs:r.value,budget:y.value})};return oe(()=>k.modelValue,a=>{r.value=[...a.costs],y.value=a.budget||0},{deep:!0}),(a,t)=>(l(),n("div",re,[e("div",ie,[t[9]||(t[9]=e("h3",{class:"text-lg font-medium text-gray-900"},"Cost Tracking",-1)),e("div",de,[e("div",ue,[b(v(C),{variant:"outline",size:"sm",onClick:t[0]||(t[0]=o=>u("material")),disabled:f.disabled},{default:_(()=>t[6]||(t[6]=[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:"M20 7l-8-4-8 4m16 0l-8 4m8-4v10l-8 4m0-10L4 7m8 4v10M4 7v10l8 4"})],-1),h(" Add Material ",-1)])),_:1,__:[6]},8,["disabled"]),b(v(C),{variant:"outline",size:"sm",onClick:t[1]||(t[1]=o=>u("labor")),disabled:f.disabled},{default:_(()=>t[7]||(t[7]=[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:"M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"})],-1),h(" Add Labor ",-1)])),_:1,__:[7]},8,["disabled"]),b(v(C),{variant:"outline",size:"sm",onClick:t[2]||(t[2]=o=>u("other")),disabled:f.disabled},{default:_(()=>t[8]||(t[8]=[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),h(" Add Other ",-1)])),_:1,__:[8]},8,["disabled"])])])]),e("div",me,[e("div",ce,[e("div",ve,[t[11]||(t[11]=e("svg",{class:"w-8 h-8 text-blue-500 mr-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("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)),e("div",null,[t[10]||(t[10]=e("p",{class:"text-sm font-medium text-blue-900"},"Auto Labor",-1)),e("p",ge,"$"+d(F.value.toFixed(2)),1)])])]),e("div",xe,[e("div",pe,[t[13]||(t[13]=e("svg",{class:"w-8 h-8 text-green-500 mr-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M20 7l-8-4-8 4m16 0l-8 4m8-4v10l-8 4m0-10L4 7m8 4v10M4 7v10l8 4"})],-1)),e("div",null,[t[12]||(t[12]=e("p",{class:"text-sm font-medium text-green-900"},"Auto Parts",-1)),e("p",he,"$"+d(N.value.toFixed(2)),1)])])]),e("div",fe,[e("div",ke,[t[15]||(t[15]=e("svg",{class:"w-8 h-8 text-orange-500 mr-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M19.428 15.428a2 2 0 00-1.022-.547l-2.387-.477a6 6 0 00-3.86.517l-.318.158a6 6 0 01-3.86.517L6.05 15.21a2 2 0 00-1.806.547M8 4h8l-1 1v5.172a2 2 0 00.586 1.414l5 5c1.26 1.26.367 3.414-1.415 3.414H4.828c-1.782 0-2.674-2.154-1.414-3.414l5-5A2 2 0 009 10.172V5L8 4z"})],-1)),e("div",null,[t[14]||(t[14]=e("p",{class:"text-sm font-medium text-orange-900"},"Materials",-1)),e("p",be,"$"+d(Q.value.toFixed(2)),1)])])]),e("div",ye,[e("div",we,[t[17]||(t[17]=e("svg",{class:"w-8 h-8 text-indigo-500 mr-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"})],-1)),e("div",null,[t[16]||(t[16]=e("p",{class:"text-sm font-medium text-indigo-900"},"Add'l Labor",-1)),e("p",_e,"$"+d(E.value.toFixed(2)),1)])])]),e("div",Ce,[e("div",Me,[t[19]||(t[19]=e("svg",{class:"w-8 h-8 text-purple-500 mr-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 7h6m0 10v-3m-3 3h.01M9 17h.01M9 14h.01M12 14h.01M15 11h.01M12 11h.01M9 11h.01M7 21h10a2 2 0 002-2V5a2 2 0 00-2-2H7a2 2 0 00-2 2v14a2 2 0 002 2z"})],-1)),e("div",null,[t[18]||(t[18]=e("p",{class:"text-sm font-medium text-purple-900"},"Other",-1)),e("p",$e,"$"+d(J.value.toFixed(2)),1)])])])]),e("div",Ve,[e("div",Se,[e("div",je,[t[21]||(t[21]=e("svg",{class:"w-8 h-8 text-gray-500 mr-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("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)),e("div",Be,[t[20]||(t[20]=e("p",{class:"text-sm font-medium text-gray-900"},"Total Project Cost",-1)),e("p",ze,"$"+d(j.value.toFixed(2)),1)])])])]),y.value>0?(l(),n("div",{key:0,class:q(["mb-6 p-4 rounded-lg",X.value])},[e("div",Ie,[t[22]||(t[22]=e("span",{class:"text-sm font-medium"},"Budget Progress",-1)),e("span",Ae," $"+d(j.value.toFixed(2))+" / $"+d(y.value.toFixed(2)),1)]),e("div",Le,[e("div",{class:q(["h-2 rounded-full transition-all duration-300",Y.value]),style:le({width:`${Math.min(w.value,100)}%`})},null,6)]),e("p",{class:q(["text-xs mt-1",Z.value])},d(w.value>100?"Over budget by":"Remaining")+": $"+d(Math.abs(y.value-j.value).toFixed(2)),3)],2)):m("",!0),e("div",Ue,[t[38]||(t[38]=e("div",{class:"px-4 py-3 border-b border-gray-200 bg-gray-50"},[e("h4",{class:"text-sm font-medium text-gray-900"},"Cost Breakdown")],-1)),e("div",He,[H.value.length>0?(l(),n("div",Fe,[t[23]||(t[23]=e("h5",{class:"text-sm font-medium text-gray-900 mb-3 flex items-center"},[e("svg",{class:"w-4 h-4 text-blue-500 mr-2",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("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"})]),h(" Labor Costs ")],-1)),e("div",Ne,[(l(!0),n(L,null,U(H.value,o=>(l(),n("div",{key:o.id,class:"flex items-center justify-between text-sm"},[e("div",De,[e("span",Te,d(o.description),1),e("span",Oe,"("+d(V(o.duration))+" @ $"+d(o.hourlyRate)+"/hr)",1)]),e("span",Ee,"$"+d(o.cost.toFixed(2)),1)]))),128))])])):m("",!0),$.value.length>0?(l(),n("div",Pe,[t[24]||(t[24]=e("h5",{class:"text-sm font-medium text-gray-900 mb-3 flex items-center"},[e("svg",{class:"w-4 h-4 text-green-500 mr-2",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M20 7l-8-4-8 4m16 0l-8 4m8-4v10l-8 4m0-10L4 7m8 4v10M4 7v10l8 4"})]),h(" Parts & Materials ")],-1)),e("div",Re,[(l(!0),n(L,null,U($.value,o=>(l(),n("div",{key:o.id,class:"flex items-center justify-between text-sm"},[e("div",qe,[e("span",Ge,d(o.partNumber)+" - "+d(o.name),1),e("span",Qe,"("+d(o.quantity)+" × $"+d(o.unitCost)+")",1)]),e("span",Je,"$"+d(o.cost.toFixed(2)),1)]))),128))])])):m("",!0),D.value.length>0?(l(),n("div",Ke,[t[28]||(t[28]=e("h5",{class:"text-sm font-medium text-gray-900 mb-3 flex items-center"},[e("svg",{class:"w-4 h-4 text-orange-500 mr-2",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M19.428 15.428a2 2 0 00-1.022-.547l-2.387-.477a6 6 0 00-3.86.517l-.318.158a6 6 0 01-3.86.517L6.05 15.21a2 2 0 00-1.806.547M8 4h8l-1 1v5.172a2 2 0 00.586 1.414l5 5c1.26 1.26.367 3.414-1.415 3.414H4.828c-1.782 0-2.674-2.154-1.414-3.414l5-5A2 2 0 009 10.172V5L8 4z"})]),h(" Materials ")],-1)),e("div",We,[(l(!0),n(L,null,U(D.value,(o,R)=>(l(),n("div",{key:o.id||R,class:"flex items-center justify-between text-sm"},[e("div",Xe,[o.editing?(l(),A(v(z),{key:1,modelValue:r.value[o.originalIndex].description,"onUpdate:modelValue":p=>r.value[o.originalIndex].description=p,placeholder:"Material description",size:"sm",class:"mr-2"},null,8,["modelValue","onUpdate:modelValue"])):(l(),n("span",Ye,d(o.description),1))]),e("div",Ze,[o.editing?(l(),A(v(z),{key:1,modelValue:r.value[o.originalIndex].amount,"onUpdate:modelValue":p=>r.value[o.originalIndex].amount=p,modelModifiers:{number:!0},type:"number",step:"0.01",min:"0",placeholder:"0.00",size:"sm",class:"w-20"},null,8,["modelValue","onUpdate:modelValue"])):(l(),n("span",et,"$"+d(o.amount.toFixed(2)),1)),e("div",tt,[!o.editing&&!f.disabled?(l(),n("button",{key:0,onClick:p=>s(o.originalIndex),class:"p-1 text-gray-400 hover:text-gray-600 rounded"},t[25]||(t[25]=[e("svg",{class:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("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)]),8,st)):m("",!0),o.editing?(l(),n("button",{key:1,onClick:p=>x(o.originalIndex),class:"p-1 text-green-500 hover:text-green-600 rounded"},t[26]||(t[26]=[e("svg",{class:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M5 13l4 4L19 7"})],-1)]),8,ot)):m("",!0),f.disabled?m("",!0):(l(),n("button",{key:2,onClick:p=>i(o.originalIndex),class:"p-1 text-red-400 hover:text-red-600 rounded"},t[27]||(t[27]=[e("svg",{class:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("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)]),8,lt))])])]))),128))])])):m("",!0),T.value.length>0?(l(),n("div",at,[t[32]||(t[32]=e("h5",{class:"text-sm font-medium text-gray-900 mb-3 flex items-center"},[e("svg",{class:"w-4 h-4 text-indigo-500 mr-2",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"})]),h(" Additional Labor ")],-1)),e("div",nt,[(l(!0),n(L,null,U(T.value,(o,R)=>(l(),n("div",{key:o.id||R,class:"flex items-center justify-between text-sm"},[e("div",rt,[o.editing?(l(),A(v(z),{key:1,modelValue:r.value[o.originalIndex].description,"onUpdate:modelValue":p=>r.value[o.originalIndex].description=p,placeholder:"Labor description",size:"sm",class:"mr-2"},null,8,["modelValue","onUpdate:modelValue"])):(l(),n("span",it,d(o.description),1))]),e("div",dt,[o.editing?(l(),A(v(z),{key:1,modelValue:r.value[o.originalIndex].amount,"onUpdate:modelValue":p=>r.value[o.originalIndex].amount=p,modelModifiers:{number:!0},type:"number",step:"0.01",min:"0",placeholder:"0.00",size:"sm",class:"w-20"},null,8,["modelValue","onUpdate:modelValue"])):(l(),n("span",ut,"$"+d(o.amount.toFixed(2)),1)),e("div",mt,[!o.editing&&!f.disabled?(l(),n("button",{key:0,onClick:p=>s(o.originalIndex),class:"p-1 text-gray-400 hover:text-gray-600 rounded"},t[29]||(t[29]=[e("svg",{class:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("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)]),8,ct)):m("",!0),o.editing?(l(),n("button",{key:1,onClick:p=>x(o.originalIndex),class:"p-1 text-green-500 hover:text-green-600 rounded"},t[30]||(t[30]=[e("svg",{class:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M5 13l4 4L19 7"})],-1)]),8,vt)):m("",!0),f.disabled?m("",!0):(l(),n("button",{key:2,onClick:p=>i(o.originalIndex),class:"p-1 text-red-400 hover:text-red-600 rounded"},t[31]||(t[31]=[e("svg",{class:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("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)]),8,gt))])])]))),128))])])):m("",!0),O.value.length>0?(l(),n("div",xt,[t[36]||(t[36]=e("h5",{class:"text-sm font-medium text-gray-900 mb-3 flex items-center"},[e("svg",{class:"w-4 h-4 text-purple-500 mr-2",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 7h6m0 10v-3m-3 3h.01M9 17h.01M9 14h.01M12 14h.01M15 11h.01M12 11h.01M9 11h.01M7 21h10a2 2 0 002-2V5a2 2 0 00-2-2H7a2 2 0 00-2 2v14a2 2 0 002 2z"})]),h(" Other Costs ")],-1)),e("div",pt,[(l(!0),n(L,null,U(O.value,(o,R)=>(l(),n("div",{key:o.id||R,class:"flex items-center justify-between text-sm"},[e("div",ht,[o.editing?(l(),A(v(z),{key:1,modelValue:r.value[o.originalIndex].description,"onUpdate:modelValue":p=>r.value[o.originalIndex].description=p,placeholder:"Cost description",size:"sm",class:"mr-2"},null,8,["modelValue","onUpdate:modelValue"])):(l(),n("span",ft,d(o.description),1))]),e("div",kt,[o.editing?(l(),A(v(z),{key:1,modelValue:r.value[o.originalIndex].amount,"onUpdate:modelValue":p=>r.value[o.originalIndex].amount=p,modelModifiers:{number:!0},type:"number",step:"0.01",min:"0",placeholder:"0.00",size:"sm",class:"w-20"},null,8,["modelValue","onUpdate:modelValue"])):(l(),n("span",bt,"$"+d(o.amount.toFixed(2)),1)),e("div",yt,[!o.editing&&!f.disabled?(l(),n("button",{key:0,onClick:p=>s(o.originalIndex),class:"p-1 text-gray-400 hover:text-gray-600 rounded"},t[33]||(t[33]=[e("svg",{class:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("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)]),8,wt)):m("",!0),o.editing?(l(),n("button",{key:1,onClick:p=>x(o.originalIndex),class:"p-1 text-green-500 hover:text-green-600 rounded"},t[34]||(t[34]=[e("svg",{class:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M5 13l4 4L19 7"})],-1)]),8,_t)):m("",!0),f.disabled?m("",!0):(l(),n("button",{key:2,onClick:p=>i(o.originalIndex),class:"p-1 text-red-400 hover:text-red-600 rounded"},t[35]||(t[35]=[e("svg",{class:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("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)]),8,Ct))])])]))),128))])])):m("",!0),ee.value?m("",!0):(l(),n("div",Mt,t[37]||(t[37]=[e("svg",{class:"w-12 h-12 mx-auto mb-4 text-gray-300",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("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),e("p",{class:"text-sm"},"No costs recorded yet",-1),e("p",{class:"text-xs text-gray-400 mt-1"},"Costs will appear automatically from labor and parts",-1)])))])]),!y.value||y.value===0?(l(),n("div",$t,[e("div",Vt,[t[40]||(t[40]=e("div",{class:"flex items-center"},[e("svg",{class:"w-4 h-4 text-yellow-500 mr-2",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})]),e("span",{class:"text-sm text-yellow-800"},"Set a budget to track spending")],-1)),b(v(C),{variant:"outline",size:"sm",onClick:t[3]||(t[3]=o=>M.value=!0)},{default:_(()=>t[39]||(t[39]=[h(" Set Budget ",-1)])),_:1,__:[39]})]),M.value?(l(),n("div",St,[b(v(z),{modelValue:g.value,"onUpdate:modelValue":t[4]||(t[4]=o=>g.value=o),modelModifiers:{number:!0},type:"number",step:"0.01",min:"0",placeholder:"Enter budget amount",size:"sm",class:"flex-1"},null,8,["modelValue"]),b(v(C),{size:"sm",onClick:B},{default:_(()=>t[41]||(t[41]=[h("Set",-1)])),_:1,__:[41]}),b(v(C),{variant:"secondary",size:"sm",onClick:t[5]||(t[5]=o=>M.value=!1)},{default:_(()=>t[42]||(t[42]=[h("Cancel",-1)])),_:1,__:[42]})])):m("",!0)])):m("",!0)]))}},Bs=se(jt,[["__scopeId","data-v-6b62bf5a"]]),Bt={class:"status-history"},zt={class:"flex items-center justify-between mb-4"},It={class:"flex items-center space-x-2"},At={class:"mb-6 p-4 bg-blue-50 border border-blue-200 rounded-lg"},Lt={class:"flex items-center justify-between"},Ut={class:"flex items-center"},Ht={class:"text-lg font-semibold text-blue-900"},Ft={class:"text-right"},Nt={class:"text-sm font-medium text-blue-900"},Dt={key:0,class:"mb-6 p-4 bg-gray-50 border border-gray-200 rounded-lg"},Tt={class:"grid grid-cols-1 md:grid-cols-2 gap-4 mb-3"},Ot={class:"flex items-center space-x-2"},Et={class:"space-y-4"},Pt={key:0,class:"relative"},Rt={class:"w-6 h-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},qt={key:0,"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"},Gt={key:1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"},Qt={key:2,"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M10 9v6m4-6v6m7-3a9 9 0 11-18 0 9 9 0 0118 0z"},Jt={key:3,"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 2"},Kt={class:"flex-1 min-w-0"},Wt={class:"bg-white border border-gray-200 rounded-lg p-4 shadow-sm"},Xt={class:"flex items-center justify-between mb-2"},Yt={class:"flex items-center space-x-2"},Zt={key:0,class:"text-xs text-gray-500"},es={class:"text-xs text-gray-500"},ts={class:"flex items-center space-x-3 mb-2"},ss={class:"text-sm font-medium text-gray-900"},os={class:"text-xs text-gray-500"},ls={key:0,class:"text-sm text-gray-700 mt-2"},as={key:1,class:"mt-3 pt-3 border-t border-gray-100"},ns={class:"grid grid-cols-2 gap-4 text-xs text-gray-500"},rs={key:0},is={key:1},ds={key:1,class:"text-center py-8 text-gray-500"},us={key:1,class:"mt-8 border-t pt-6"},ms={key:0,class:"space-y-2"},cs={class:"flex items-center space-x-3"},vs={class:"font-medium text-gray-900"},gs={class:"text-gray-600"},xs={key:0,class:"text-gray-500"},ps={class:"flex items-center space-x-2 text-xs text-gray-500"},hs={key:1,class:"text-center py-4 text-gray-500 text-sm"},fs={key:2,class:"mt-6 p-4 bg-gray-50 rounded-lg"},ks={class:"grid grid-cols-2 md:grid-cols-4 gap-4 text-sm"},bs={class:"ml-2 font-medium text-gray-900"},ys={class:"ml-2 font-medium text-gray-900"},ws={class:"ml-2 font-medium text-gray-900"},_s={class:"ml-2 font-medium text-gray-900"},Cs={__name:"StatusHistory",props:{modelValue:{type:Array,default:()=>[]},currentStatus:{type:String,default:"OPEN"},disabled:{type:Boolean,default:!1},userOptions:{type:Array,default:()=>[]},currentUser:{type:Object,default:null},auditEntries:{type:Array,default:()=>[]}},emits:["update:modelValue","status-change"],setup(f,{emit:W}){const k=f,G=W,r=I([...k.modelValue]),y=I(!1),M=I(!1),g=I({newStatus:"",userId:null,comment:""}),H=c(()=>Object.entries(K).map(([u,s])=>({value:u,title:s.label,badge:s.badge}))),$=c(()=>r.value.length>0?r.value[0]:null),F=c(()=>g.value.newStatus&&g.value.userId&&g.value.newStatus!==k.currentStatus),N=c(()=>{if(!$.value)return"N/A";const u=new Date,s=new Date($.value.timestamp),x=u-s;return w(x/(1e3*60*60))}),D=c(()=>{if(r.value.length<2)return"N/A";const u=new Date(r.value[r.value.length-1].timestamp),x=new Date(r.value[0].timestamp)-u;return w(x/(1e3*60*60))}),T=c(()=>{if(r.value.length<2)return"N/A";const s=r.value.reduce((x,i,B)=>{if(B===r.value.length-1)return x;const V=new Date(i.timestamp),S=new Date(r.value[B+1].timestamp);return x+(V-S)},0)/(1e3*60*60)/(r.value.length-1);return w(s)}),O=()=>{var u;k.disabled||(g.value={newStatus:"",userId:((u=k.currentUser)==null?void 0:u.id)||null,comment:""},y.value=!0)},Q=()=>{if(!F.value)return;const u=k.userOptions.find(x=>x.value===g.value.userId),s={id:Date.now()+Math.random(),status:g.value.newStatus,previousStatus:k.currentStatus,user:(u==null?void 0:u.data)||k.currentUser,timestamp:new Date().toISOString(),comment:g.value.comment,metadata:{reason:"Manual status change",duration:N.value}};r.value.unshift(s),ee(),G("status-change",{newStatus:g.value.newStatus,previousStatus:k.currentStatus,comment:g.value.comment,user:(u==null?void 0:u.data)||k.currentUser}),E()},E=()=>{y.value=!1,g.value={newStatus:"",userId:null,comment:""}},J=()=>{M.value=!M.value},P=u=>{var s;return((s=K[u])==null?void 0:s.label)||u},j=u=>u?new Date(u).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"}):"",w=u=>{if(!u||isNaN(u))return"0h";if(u<1)return`${Math.round(u*60)}m`;if(u<24)return`${Math.round(u*10)/10}h`;{const s=Math.floor(u/24),x=Math.round(u%24*10)/10;return`${s}d ${x}h`}},X=u=>{var s;return((s=K[u])==null?void 0:s.badge)||"secondary"},Y=u=>{const s=K[u];if(!s)return"bg-gray-100 text-gray-600";const x={primary:"bg-blue-100 text-blue-600",success:"bg-green-100 text-green-600",warning:"bg-yellow-100 text-yellow-600",danger:"bg-red-100 text-red-600",secondary:"bg-gray-100 text-gray-600"};return x[s.badge]||x.secondary},Z=u=>u.includes("CREATE")?"bg-green-500":u.includes("UPDATE")?"bg-blue-500":u.includes("DELETE")?"bg-red-500":"bg-gray-500",ee=()=>{G("update:modelValue",r.value)};return oe(()=>k.modelValue,u=>{r.value=[...u]},{deep:!0}),(u,s)=>{var x;return l(),n("div",Bt,[e("div",zt,[s[5]||(s[5]=e("h3",{class:"text-lg font-medium text-gray-900"},"Status History & Audit Trail",-1)),e("div",It,[b(v(C),{variant:"outline",size:"sm",onClick:O,disabled:f.disabled},{default:_(()=>s[3]||(s[3]=[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),h(" Add Status Update ",-1)])),_:1,__:[3]},8,["disabled"]),b(v(C),{variant:"ghost",size:"sm",onClick:J},{default:_(()=>[s[4]||(s[4]=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:"M9 12h6m-6 4h6m2 5H7a2 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)),h(" "+d(M.value?"Hide":"Show")+" Audit Trail ",1)]),_:1,__:[4]})])]),e("div",At,[e("div",Lt,[e("div",Ut,[s[7]||(s[7]=e("div",{class:"flex-shrink-0 w-10 h-10 bg-blue-100 rounded-full flex items-center justify-center mr-3"},[e("svg",{class:"w-5 h-5 text-blue-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("path",{"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"})])],-1)),e("div",null,[s[6]||(s[6]=e("h4",{class:"text-sm font-medium text-blue-900"},"Current Status",-1)),e("p",Ht,d(P(f.currentStatus)),1)])]),e("div",Ft,[s[8]||(s[8]=e("p",{class:"text-sm text-blue-700"},"Last Updated",-1)),e("p",Nt,d($.value?j($.value.timestamp):"Never"),1)])])]),y.value?(l(),n("div",Dt,[s[11]||(s[11]=e("h4",{class:"text-sm font-medium text-gray-900 mb-3"},"Add Status Update",-1)),e("div",Tt,[b(v(te),{modelValue:g.value.newStatus,"onUpdate:modelValue":s[0]||(s[0]=i=>g.value.newStatus=i),label:"New Status",options:H.value,required:""},null,8,["modelValue","options"]),b(v(te),{modelValue:g.value.userId,"onUpdate:modelValue":s[1]||(s[1]=i=>g.value.userId=i),label:"Changed By",options:f.userOptions,value:(x=f.currentUser)==null?void 0:x.id,required:""},null,8,["modelValue","options","value"])]),b(v(z),{modelValue:g.value.comment,"onUpdate:modelValue":s[2]||(s[2]=i=>g.value.comment=i),label:"Comment",placeholder:"Add a comment about this status change...",type:"textarea",rows:"3",class:"mb-3"},null,8,["modelValue"]),e("div",Ot,[b(v(C),{onClick:Q,disabled:!F.value},{default:_(()=>s[9]||(s[9]=[h(" Save Status Change ",-1)])),_:1,__:[9]},8,["disabled"]),b(v(C),{variant:"secondary",onClick:E},{default:_(()=>s[10]||(s[10]=[h(" Cancel ",-1)])),_:1,__:[10]})])])):m("",!0),e("div",Et,[s[16]||(s[16]=e("h4",{class:"text-sm font-medium text-gray-900"},"Status Timeline",-1)),r.value.length>0?(l(),n("div",Pt,[s[14]||(s[14]=e("div",{class:"absolute left-6 top-8 bottom-0 w-0.5 bg-gray-200"},null,-1)),(l(!0),n(L,null,U(r.value,(i,B)=>{var V;return l(),n("div",{key:i.id||B,class:"relative flex items-start space-x-4 pb-6"},[e("div",{class:q(["flex-shrink-0 w-12 h-12 rounded-full flex items-center justify-center relative z-10",Y(i.status)])},[(l(),n("svg",Rt,[i.status==="COMPLETE"?(l(),n("path",qt)):i.status==="IN_PROGRESS"?(l(),n("path",Gt)):i.status==="ON_HOLD"?(l(),n("path",Qt)):(l(),n("path",Jt))]))],2),e("div",Kt,[e("div",Wt,[e("div",Xt,[e("div",Yt,[b(v(ne),{variant:X(i.status)},{default:_(()=>[h(d(P(i.status)),1)]),_:2},1032,["variant"]),i.previousStatus?(l(),n("span",Zt," from "+d(P(i.previousStatus)),1)):m("",!0)]),e("time",es,d(j(i.timestamp)),1)]),e("div",ts,[i.user?(l(),A(v(ae),{key:0,user:i.user,size:"sm"},null,8,["user"])):m("",!0),e("div",null,[e("p",ss,d(i.user?`${i.user.firstName} ${i.user.lastName}`:"System"),1),e("p",os,d(((V=i.user)==null?void 0:V.jobTitle)||"Automated change"),1)])]),i.comment?(l(),n("p",ls,d(i.comment),1)):m("",!0),i.metadata?(l(),n("div",as,[e("div",ns,[i.metadata.duration?(l(),n("div",rs,[s[12]||(s[12]=e("span",{class:"font-medium"},"Duration in status:",-1)),h(" "+d(w(i.metadata.duration)),1)])):m("",!0),i.metadata.reason?(l(),n("div",is,[s[13]||(s[13]=e("span",{class:"font-medium"},"Reason:",-1)),h(" "+d(i.metadata.reason),1)])):m("",!0)])])):m("",!0)])])])}),128))])):(l(),n("div",ds,s[15]||(s[15]=[e("svg",{class:"w-12 h-12 mx-auto mb-4 text-gray-300",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("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),e("p",{class:"text-sm"},"No status history available",-1),e("p",{class:"text-xs text-gray-400 mt-1"},"Status changes will appear here",-1)])))]),M.value?(l(),n("div",us,[s[17]||(s[17]=e("h4",{class:"text-sm font-medium text-gray-900 mb-4 flex items-center"},[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:"M9 12h6m-6 4h6m2 5H7a2 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"})]),h(" Complete Audit Trail ")],-1)),f.auditEntries.length>0?(l(),n("div",ms,[(l(!0),n(L,null,U(f.auditEntries,(i,B)=>{var V,S;return l(),n("div",{key:i.id||B,class:"flex items-center justify-between p-3 bg-gray-50 rounded text-sm"},[e("div",cs,[e("span",{class:q(["w-2 h-2 rounded-full",Z(i.action)])},null,2),e("span",vs,d(i.action),1),e("span",gs,d(i.field||i.description),1),i.oldValue?(l(),n("span",xs,d(i.oldValue)+" → "+d(i.newValue),1)):m("",!0)]),e("div",ps,[e("span",null,d((V=i.user)==null?void 0:V.firstName)+" "+d((S=i.user)==null?void 0:S.lastName),1),e("span",null,d(j(i.timestamp)),1)])])}),128))])):(l(),n("div",hs," No audit entries available "))])):m("",!0),r.value.length>0?(l(),n("div",fs,[s[22]||(s[22]=e("h4",{class:"text-sm font-medium text-gray-900 mb-3"},"Statistics",-1)),e("div",ks,[e("div",null,[s[18]||(s[18]=e("span",{class:"text-gray-600"},"Total Changes:",-1)),e("span",bs,d(r.value.length),1)]),e("div",null,[s[19]||(s[19]=e("span",{class:"text-gray-600"},"Time in Current:",-1)),e("span",ys,d(N.value),1)]),e("div",null,[s[20]||(s[20]=e("span",{class:"text-gray-600"},"Total Duration:",-1)),e("span",ws,d(D.value),1)]),e("div",null,[s[21]||(s[21]=e("span",{class:"text-gray-600"},"Avg per Status:",-1)),e("span",_s,d(T.value),1)])])])):m("",!0)])}}},zs=se(Cs,[["__scopeId","data-v-3389e2f3"]]);export{Bs as C,zs as S};