1import{r as E,j as e}from"./vendor-react-DKbe1Umz.js";import{u as W,a as Y}from"./vendor-data-CjSe2wkl.js";import{u as fe,o as G,q as M,C as k,v as O,s as z,t as U,w as B,I as w,B as N,l as q,D as Le,c as Ie,d as $e,e as qe,f as Pe,aO as Fe,aP as D,aQ as L,aR as I,aS as $,aT as P,S as ce,g as he,h as ue,i as xe,j as ge,b5 as He,T as ze,n as Ue}from"./index-DZ74KeH3.js";import{a as Qe,t as _e,o as Be,s as J,b as Ke,c as me,e as ve}from"./vendor-forms-C2vWC2ab.js";import{T as re,a as ie,b as Q,c as T,d as le,e as S}from"./table-CAeITjOT.js";import{A as We,a as Ve,b as Je,c as Ye,d as Ge,e as Ze,f as Xe,g as et}from"./alert-dialog-CA9oB9-z.js";import{bz as ae,U as tt,az as at,b7 as st,b0 as nt,Y as Ne,J as be,dn as se,b3 as rt,i as it,c$ as lt,cZ as dt}from"./vendor-ui-DMaW9-Ov.js";import"./vendor-charts-DWX9qznF.js";import"./vendor-dates-5UNeOyFW.js";const de=[{value:"SALARIES",label:"Salaries & Payroll"},{value:"INSURANCE",label:"Insurance"},{value:"RENT_LEASE",label:"Rent / Lease"},{value:"LOANS_FINANCING",label:"Loans & Financing"},{value:"SUBSCRIPTIONS",label:"Subscriptions & Software"},{value:"UTILITIES",label:"Utilities"},{value:"VEHICLES",label:"Vehicles & Fleet"},{value:"MARKETING",label:"Marketing & Advertising"},{value:"PROFESSIONAL_FEES",label:"Professional Fees"},{value:"EQUIPMENT",label:"Equipment"},{value:"OTHER",label:"Other"}],ye=[{value:"MONTHLY",label:"Monthly"},{value:"QUARTERLY",label:"Quarterly"},{value:"ANNUAL",label:"Annual"},{value:"ONE_TIME",label:"One-Time"}],Z={SALARIES:"bg-blue-100 text-blue-800 dark:bg-blue-900/30 dark:text-blue-300",INSURANCE:"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-300",RENT_LEASE:"bg-purple-100 text-purple-800 dark:bg-purple-900/30 dark:text-purple-300",LOANS_FINANCING:"bg-red-100 text-red-800 dark:bg-red-900/30 dark:text-red-300",SUBSCRIPTIONS:"bg-cyan-100 text-cyan-800 dark:bg-cyan-900/30 dark:text-cyan-300",UTILITIES:"bg-yellow-100 text-yellow-800 dark:bg-yellow-900/30 dark:text-yellow-300",VEHICLES:"bg-orange-100 text-orange-800 dark:bg-orange-900/30 dark:text-orange-300",MARKETING:"bg-pink-100 text-pink-800 dark:bg-pink-900/30 dark:text-pink-300",PROFESSIONAL_FEES:"bg-indigo-100 text-indigo-800 dark:bg-indigo-900/30 dark:text-indigo-300",EQUIPMENT:"bg-slate-100 text-slate-800 dark:bg-slate-900/30 dark:text-slate-300",OTHER:"bg-gray-100 text-gray-800 dark:bg-gray-900/30 dark:text-gray-300"};function X(t){var o;return((o=de.find(i=>i.value===t))==null?void 0:o.label)??t}function ot(t){var o;return((o=ye.find(i=>i.value===t))==null?void 0:o.label)??t}const Te=12;function K(t,o,i){if(o==="ONE_TIME"){const d=i&&i>0?i:Te;return t/d}const n={MONTHLY:1,QUARTERLY:1/3,ANNUAL:1/12};return t*(n[o]??1)}function p(t){return t.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})}function ct(t){return new Date(t).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}const ne=["SALARIES","INSURANCE","RENT_LEASE","LOANS_FINANCING","SUBSCRIPTIONS","UTILITIES","VEHICLES","MARKETING","PROFESSIONAL_FEES","EQUIPMENT","OTHER"],ht=Be({name:J().min(1,"Name is required").max(200),category:ve(ne),amount:me.number({invalid_type_error:"Enter a valid amount"}).nonnegative("Amount must be 0 or more"),frequency:ve(["MONTHLY","QUARTERLY","ANNUAL","ONE_TIME"]),amortizationMonths:me.number().int().min(1).max(120).nullable().optional(),effectiveDate:J().optional(),endDate:J().optional(),isActive:Ke(),notes:J().optional()});function ut({open:t,onClose:o,editItem:i}){const{toast:n}=fe(),d=Qe({resolver:_e(ht),defaultValues:i?{name:i.name,category:i.category,amount:Number(i.amount),frequency:i.frequency,amortizationMonths:i.amortizationMonths??null,effectiveDate:i.effectiveDate??"",endDate:i.endDate??"",isActive:i.isActive,notes:i.notes??""}:{name:"",category:"OTHER",amount:0,frequency:"MONTHLY",amortizationMonths:null,effectiveDate:"",endDate:"",isActive:!0,notes:""}}),u=d.watch("frequency"),r=Y({mutationFn:l=>G("POST","/api/overhead/items",l),onSuccess:()=>{M.invalidateQueries({queryKey:["/api/overhead/items"]}),M.invalidateQueries({queryKey:["/api/overhead/summary"]}),M.invalidateQueries({queryKey:["/api/overhead/history"]}),n({title:"Cost item added"}),o()},onError:l=>n({title:"Error",description:l.message,variant:"destructive"})}),c=Y({mutationFn:l=>G("PATCH",`/api/overhead/items/${i.id}`,l),onSuccess:()=>{M.invalidateQueries({queryKey:["/api/overhead/items"]}),M.invalidateQueries({queryKey:["/api/overhead/summary"]}),M.invalidateQueries({queryKey:["/api/overhead/history"]}),n({title:"Cost item updated"}),o()},onError:l=>n({title:"Error",description:l.message,variant:"destructive"})}),g=r.isPending||c.isPending;function b(l){const v={...l,amortizationMonths:l.frequency==="ONE_TIME"&&l.amortizationMonths||void 0,effectiveDate:l.effectiveDate||void 0,endDate:l.endDate||void 0,notes:l.notes||void 0};i?c.mutate(v):r.mutate(v)}return e.jsx(Le,{open:t,onOpenChange:l=>!l&&o(),children:e.jsxs(Ie,{className:"sm:max-w-lg","data-testid":"dialog-overhead-item",children:[e.jsxs($e,{children:[e.jsx(qe,{children:i?"Edit Cost Item":"Add Cost Item"}),e.jsx(Pe,{children:"Enter the details of this overhead or fixed cost."})]}),e.jsx(Fe,{...d,children:e.jsxs("form",{onSubmit:d.handleSubmit(b),className:"space-y-4",children:[e.jsx(D,{control:d.control,name:"name",render:({field:l})=>e.jsxs(L,{children:[e.jsx(I,{children:"Name"}),e.jsx($,{children:e.jsx(w,{placeholder:"e.g. Office Rent","data-testid":"input-overhead-name",...l})}),e.jsx(P,{})]})}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(D,{control:d.control,name:"category",render:({field:l})=>e.jsxs(L,{children:[e.jsx(I,{children:"Category"}),e.jsxs(ce,{onValueChange:l.onChange,defaultValue:l.value,children:[e.jsx($,{children:e.jsx(he,{"data-testid":"select-overhead-category",children:e.jsx(ue,{placeholder:"Select"})})}),e.jsx(xe,{children:de.map(v=>e.jsx(ge,{value:v.value,children:v.label},v.value))})]}),e.jsx(P,{})]})}),e.jsx(D,{control:d.control,name:"frequency",render:({field:l})=>e.jsxs(L,{children:[e.jsx(I,{children:"Frequency"}),e.jsxs(ce,{onValueChange:l.onChange,defaultValue:l.value,children:[e.jsx($,{children:e.jsx(he,{"data-testid":"select-overhead-frequency",children:e.jsx(ue,{placeholder:"Select"})})}),e.jsx(xe,{children:ye.map(v=>e.jsx(ge,{value:v.value,children:v.label},v.value))})]}),e.jsx(P,{})]})})]}),e.jsx(D,{control:d.control,name:"amount",render:({field:l})=>e.jsxs(L,{children:[e.jsx(I,{children:"Amount ($)"}),e.jsx($,{children:e.jsx(w,{type:"number",min:"0",step:"0.01",placeholder:"0.00","data-testid":"input-overhead-amount",...l})}),e.jsx(P,{})]})}),u==="ONE_TIME"&&e.jsx(D,{control:d.control,name:"amortizationMonths",render:({field:l})=>e.jsxs(L,{children:[e.jsx(I,{children:"Amortization Period (months)"}),e.jsx($,{children:e.jsx(w,{type:"number",min:"1",max:"120",step:"1",placeholder:"Default: 12 months","data-testid":"input-amortization-months",value:l.value??"",onChange:v=>{const R=v.target.value;l.onChange(R===""?null:Number(R))}})}),e.jsx(P,{}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Spread this one-time cost over this many months for the monthly overhead calculation."})]})}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(D,{control:d.control,name:"effectiveDate",render:({field:l})=>e.jsxs(L,{children:[e.jsx(I,{children:"Effective Date"}),e.jsx($,{children:e.jsx(w,{type:"date","data-testid":"input-overhead-effective-date",...l})}),e.jsx(P,{})]})}),e.jsx(D,{control:d.control,name:"endDate",render:({field:l})=>e.jsxs(L,{children:[e.jsx(I,{children:"End Date"}),e.jsx($,{children:e.jsx(w,{type:"date","data-testid":"input-overhead-end-date",...l})}),e.jsx(P,{})]})})]}),e.jsx(D,{control:d.control,name:"isActive",render:({field:l})=>e.jsxs(L,{className:"flex items-center gap-3",children:[e.jsx($,{children:e.jsx(He,{checked:l.value,onCheckedChange:l.onChange,"data-testid":"switch-overhead-active"})}),e.jsx(I,{className:"!mt-0",children:"Active (included in calculations)"})]})}),e.jsx(D,{control:d.control,name:"notes",render:({field:l})=>e.jsxs(L,{children:[e.jsx(I,{children:"Notes"}),e.jsx($,{children:e.jsx(ze,{placeholder:"Optional notes...",rows:2,"data-testid":"textarea-overhead-notes",...l})}),e.jsx(P,{})]})}),e.jsxs(Ue,{children:[e.jsx(N,{type:"button",variant:"outline",onClick:o,"data-testid":"button-overhead-cancel",children:"Cancel"}),e.jsx(N,{type:"submit",disabled:g,"data-testid":"button-overhead-save",children:g?"Saving...":i?"Update":"Add Cost"})]})]})})]})})}function xt({category:t,items:o,onEdit:i,onDelete:n}){const d=o.reduce((r,c)=>
1r+K(Number(c.amount),c.frequency,c.amortizationMonths),0),u=o.filter(r=>r.isActive).reduce((r,c)=>r+K(Number(c.amount),c.frequency,c.amortizationMonths),0);return e.jsxs("div",{className:"mb-6","data-testid":`group-category-${t}`,children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-muted/50 border rounded-t-md",children:[e.jsx("span",{className:`inline-flex px-2 py-0.5 rounded text-xs font-semibold ${Z[t]??Z.OTHER}`,children:X(t)}),e.jsxs("div",{className:"flex items-center gap-4 text-xs text-muted-foreground",children:[e.jsxs("span",{children:["Active: ",e.jsxs("span",{className:"font-semibold text-foreground",children:["$",p(u),"/mo"]})]}),e.jsxs("span",{children:["Total: ",e.jsxs("span",{className:"font-semibold text-foreground",children:["$",p(d),"/mo"]})]})]})]}),e.jsxs(re,{children:[e.jsx(ie,{children:e.jsxs(Q,{children:[e.jsx(T,{children:"Name"}),e.jsx(T,{children:"Frequency"}),e.jsx(T,{className:"text-right",children:"Amount"}),e.jsx(T,{className:"text-right",children:"Monthly Equiv."}),e.jsx(T,{children:"Status"}),e.jsx(T,{children:"Notes"}),e.jsx(T,{className:"text-right",children:"Actions"})]})}),e.jsx(le,{children:o.map(r=>{const c=K(Number(r.amount),r.frequency,r.amortizationMonths);return e.jsxs(Q,{"data-testid":`row-overhead-${r.id}`,children:[e.jsx(S,{className:"font-medium",children:r.name}),e.jsxs(S,{className:"text-sm text-muted-foreground",children:[ot(r.frequency),r.frequency==="ONE_TIME"&&r.amortizationMonths&&e.jsxs("span",{className:"block text-xs text-muted-foreground",children:["÷ ",r.amortizationMonths," mo"]})]}),e.jsxs(S,{className:"text-right font-mono text-sm",children:["$",p(Number(r.amount))]}),e.jsxs(S,{className:"text-right font-mono text-sm text-muted-foreground",children:["$",p(c),"/mo",r.frequency==="ONE_TIME"&&!r.amortizationMonths&&e.jsxs("span",{className:"text-muted-foreground text-xs ml-1",children:["(÷ ",Te," mo default)"]})]}),e.jsx(S,{children:e.jsx(q,{variant:r.isActive?"default":"secondary",children:r.isActive?"Active":"Inactive"})}),e.jsx(S,{className:"text-sm text-muted-foreground max-w-[180px] truncate",children:r.notes??"â"}),e.jsx(S,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[e.jsx(N,{type:"button",variant:"ghost",size:"sm",onClick:()=>i(r),"data-testid":`button-edit-overhead-${r.id}`,children:e.jsx(lt,{className:"h-3.5 w-3.5"})}),e.jsx(N,{type:"button",variant:"ghost",size:"sm",className:"text-destructive hover:text-destructive",onClick:()=>n(r),"data-testid":`button-delete-overhead-${r.id}`,children:e.jsx(dt,{className:"h-3.5 w-3.5"})})]})})]},r.id)})})]})]})}function gt({history:t}){const o=new Date,i=new Date(o.getFullYear(),o.getMonth(),1),n=new Date(o.getFullYear(),o.getMonth()-1,1),d=t.filter(x=>new Date(x.createdAt)>=i),u=t.filter(x=>{const j=new Date(x.createdAt);return j>=n&&j<i});function r(x){let j=0,h=0,C=0;for(const y of x)y.action==="CREATE"?j++:y.action==="UPDATE"?h++:y.action==="DELETE"&&C++;return{creates:j,updates:h,deletes:C,total:x.length}}function c(x){let j=0;for(const h of x)try{if(h.action==="CREATE"&&h.newData)j+=Number(JSON.parse(h.newData).amount??0);else if(h.action==="DELETE"&&h.previousData)j-=Number(JSON.parse(h.previousData).amount??0);else if(h.action==="UPDATE"&&h.previousData&&h.newData){const C=Number(JSON.parse(h.previousData).amount??0),y=Number(JSON.parse(h.newData).amount??0);j+=y-C}}catch{}return j}const g=r(d),b=r(u),l=c(d),v=c(u),R=i.toLocaleDateString(void 0,{month:"long",year:"numeric"}),m=n.toLocaleDateString(void 0,{month:"long",year:"numeric"});return e.jsxs("div",{className:"grid grid-cols-2 gap-4 mb-6","data-testid":"period-comparison",children:[e.jsxs("div",{className:"p-4 border rounded-md bg-muted/30",children:[e.jsx("p",{className:"text-sm font-medium mb-2",children:R}),e.jsxs("div",{className:"space-y-1 text-xs text-muted-foreground",children:[e.jsxs("p",{children:[g.total," changes (",g.creates," added, ",g.updates," updated, ",g.deletes," removed)"]}),e.jsxs("p",{className:`font-mono ${l>=0?"text-red-600 dark:text-red-400":"text-green-600 dark:text-green-400"}`,children:["Net cost change: ",l>=0?"+":"","$",p(l)]})]})]}),e.jsxs("div",{className:"p-4 border rounded-md bg-muted/30",children:[e.jsx("p",{className:"text-sm font-medium mb-2",children:m}),e.jsxs("div",{className:"space-y-1 text-xs text-muted-foreground",children:[e.jsxs("p",{children:[b.total," changes (",b.creates," added, ",b.updates," updated, ",b.deletes," removed)"]}),e.jsxs("p",{className:`font-mono ${v>=0?"text-red-600 dark:text-red-400":"text-green-600 dark:text-green-400"}`,children:["Net cost change: ",v>=0?"+":"","$",p(v)]})]})]})]})}function mt(){const{data:t=[],isLoading:o}=W({queryKey:["/api/overhead/history"]}),i=d=>{switch(d){case"CREATE":return e.jsx(q,{className:"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-300",children:"Created"});case"UPDATE":return e.jsx(q,{className:"bg-blue-100 text-blue-800 dark:bg-blue-900/30 dark:text-blue-300",children:"Updated"});case"DELETE":return e.jsx(q,{className:"bg-red-100 text-red-800 dark:bg-red-900/30 dark:text-red-300",children:"Deleted"});default:return e.jsx(q,{variant:"secondary",children:d})}};function n(d){if(d.action==="CREATE")return"Item created";if(d.action==="DELETE")return"Item removed";if(!d.previousData||!d.newData)return"Item updated";try{const u=JSON.parse(d.previousData),r=JSON.parse(d.newData),c=[];return u.amount!==r.amount&&c.push(`amount: $${u.amount} â $${r.amount}`),u.frequency!==r.frequency&&c.push(`frequency: ${u.frequency} â ${r.frequency}`),u.isActive!==r.isActive&&c.push(r.isActive?"re-activated":"deactivated"),u.name!==r.name&&c.push(`name: "${u.name}" â "${r.name}"`),u.category!==r.category&&c.push("category changed"),u.amortizationMonths!==r.amortizationMonths&&c.push(`amortization: ${u.amortizationMonths??"none"} â ${r.amortizationMonths??"none"} mo`),c.length>0?c.join(", "):"No visible changes"}catch{return"Item updated"}}return o?e.jsx("div",{className:"p-8 text-center text-muted-foreground",children:"Loading history..."}):t.length===0?e.jsxs("div",{className:"p-8 text-center text-muted-foreground",children:[e.jsx(se,{className:"h-10 w-10 mx-auto mb-3 opacity-30"}),e.jsx("p",{className:"font-medium",children:"No history yet"}),e.jsx("p",{className:"text-sm mt-1",children:"Changes to overhead cost items will appear here"})]}):e.jsxs("div",{children:[e.jsx(gt,{history:t}),e.jsx("div",{className:"space-y-2","data-testid":"overhead-history-list",children:t.map(d=>e.jsxs("div",{className:"flex items-start gap-3 p-3 border rounded-md bg-background","data-testid":`history-entry-${d.id}`,children:[e.jsx("div",{className:"pt-0.5",children:i(d.action)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium",children:d.itemName}),e.jsx("p",{className:"text-xs text-muted-foreground",children:n(d)})]}),e.jsx("p",{className:"text-xs text-muted-foreground whitespace-nowrap",children:ct(d.createdAt)})]},d.id))})]})}function vt({summary:t}){const o=Object.entries(t.categoryBreakdown).filter(([,n])=>n>0).sort(([,n],[,d])=>d-n);if(o.length===0)return null;const i=Object.keys(t.weightedCategoryBreakdown??{}).length>0;return e.jsx("div",{className:"space-y-3","data-testid":"category-breakdown-section",children:o.map(([n,d])=>{var c;const u=t.totalMonthly>0?d/t.totalMonthly*100:0,r=(c=t.weightedCategoryBreakdown)==null?void 0:c[n];return e.jsxs("div",{className:"flex items-center gap-3","data-testid":`category-bar-${n}`,children:[e.jsx("span",{className:`inline-flex px-2 py-0.5 rounded text-xs font-semibold min-w-[120px] ${Z[n]??Z.OTHER}`,children:X(n)}),e.jsx("div",{className:"flex-1 bg-muted rounded-full h-3 overflow-hidden",children:e.jsx("div",{className:"h-full bg-primary/60 rounded-full transition-all",style:{width:`${Math.min(u,100)}%`}})}),e.jsxs("span",{className:"text-xs font-mono text-muted-foreground min-w-[80px] text-right",children:["$",p(d),"/mo"]}),e.jsxs("span",{className:"text-xs text-muted-foreground min-w-[40px] text-right",children:[u.toFixed(0),"%"]}),i&&r&&e.jsxs("span",{className:"text-xs font-mono text-muted-foreground min-w-[60px] text-right","data-testid":`weight-${n}`,children:["@",r.weight,"%"]})]},n)})})}function je({summary:t}){if(!t.suggestedPercent)return null;const o=t.suggestedPercent,i=t.overheadCriticalThreshold,n=t.overheadWarningThreshold;return i!=null&&o>=i?e.jsxs(q,{className:"bg-red-100 text-red-800 dark:bg-red-900/30 dark:text-red-300 gap-1","data-testid":"badge-overhead-critical",children:[e.jsx(it,{className:"h-3 w-3"}),"Critical"]}):n!=null&&o>
1=n?e.jsxs(q,{className:"bg-yellow-100 text-yellow-800 dark:bg-yellow-900/30 dark:text-yellow-300 gap-1","data-testid":"badge-overhead-warning",children:[e.jsx(be,{className:"h-3 w-3"}),"Warning"]}):e.jsxs(q,{className:"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-300 gap-1","data-testid":"badge-overhead-healthy",children:[e.jsx(Ne,{className:"h-3 w-3"}),"Healthy"]})}const ee=["jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec"],jt=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function pt({summary:t,onSave:o,isPending:i}){const n=(t==null?void 0:t.categoryWeights)??{},d=Object.keys((t==null?void 0:t.categoryBreakdown)??{}).filter(g=>((t==null?void 0:t.categoryBreakdown[g])??0)>0),[u,r]=E.useState(()=>{const g={};for(const b of d)g[b]=n[b]!=null?String(n[b]):"";return g});function c(){const g={};for(const[b,l]of Object.entries(u))if(l.trim()!==""){const v=Number(l);!isNaN(v)&&v>=0&&v<=100&&(g[b]=v)}o(g)}return d.length===0?null:e.jsxs("div",{className:"mt-6 pt-6 border-t","data-testid":"category-weights-section",children:[e.jsx("h3",{className:"text-sm font-medium mb-3",children:"Category Overhead Weights (%)"}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:"Assign different overhead percentages per cost category. Leave blank to use the default overhead %."}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-3",children:d.sort().map(g=>e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:X(g)}),e.jsx(w,{type:"number",min:"0",max:"100",step:"0.5",placeholder:String((t==null?void 0:t.defaultOverheadPercent)??15),value:u[g]??"",onChange:b=>r(l=>({...l,[g]:b.target.value})),className:"h-8 text-sm","data-testid":`input-weight-${g}`})]},g))}),e.jsx(N,{variant:"outline",size:"sm",className:"mt-3",onClick:c,disabled:i,"data-testid":"button-save-category-weights",children:"Save Category Weights"})]})}const te=["q1","q2","q3","q4"],ft=["Q1 (Jan-Mar)","Q2 (Apr-Jun)","Q3 (Jul-Sep)","Q4 (Oct-Dec)"],pe={q1:["jan","feb","mar"],q2:["apr","may","jun"],q3:["jul","aug","sep"],q4:["oct","nov","dec"]};function Nt({summary:t,onSave:o,isPending:i}){const n=(t==null?void 0:t.monthlyRevenueTargets)??{},d=t!=null&&t.annualRevenueTarget?Math.round(t.annualRevenueTarget/12*100)/100:null,[u,r]=E.useState("monthly"),[c,g]=E.useState(()=>{const m={};for(const x of ee)m[x]=n[x]!=null?String(n[x]):"";return m}),[b,l]=E.useState(()=>{const m={};for(const x of te){const h=pe[x][0];m[x]=n[h]!=null?String(Number(n[h])*3):""}return m});function v(){const m={};if(u==="monthly"){for(const[x,j]of Object.entries(c))if(j.trim()!==""){const h=Number(j);!isNaN(h)&&h>=0&&(m[x]=h)}}else for(const[x,j]of Object.entries(b))if(j.trim()!==""){const h=Number(j);if(!isNaN(h)&&h>=0){const C=Math.round(h/3*100)/100;for(const y of pe[x])m[y]=C}}o(Object.keys(m).length>0?m:null)}function R(){if(!(t!=null&&t.annualRevenueTarget))return;const m=Math.round(t.annualRevenueTarget/12*100)/100,x={};for(const C of ee)x[C]=String(m);g(x);const j=Math.round(t.annualRevenueTarget/4*100)/100,h={};for(const C of te)h[C]=String(j);l(h)}return e.jsxs("div",{className:"mt-6 pt-6 border-t","data-testid":"monthly-revenue-targets-section",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium",children:"Revenue Target Breakdown ($)"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Set per-month or per-quarter revenue targets for seasonal adjustments. Leave blank to use annual target ÷ 12."})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[(t==null?void 0:t.annualRevenueTarget)&&e.jsx(N,{variant:"ghost",size:"sm",onClick:R,className:"text-xs","data-testid":"button-distribute-evenly",children:"Distribute Evenly"}),e.jsxs("div",{className:"flex border rounded-md overflow-hidden",children:[e.jsx(N,{variant:u==="monthly"?"default":"ghost",size:"sm",className:"rounded-none h-7 text-xs",onClick:()=>r("monthly"),"data-testid":"button-mode-monthly",children:"Monthly"}),e.jsx(N,{variant:u==="quarterly"?"default":"ghost",size:"sm",className:"rounded-none h-7 text-xs",onClick:()=>r("quarterly"),"data-testid":"button-mode-quarterly",children:"Quarterly"})]})]})]}),u==="monthly"?e.jsx("div",{className:"grid grid-cols-3 md:grid-cols-4 lg:grid-cols-6 gap-3",children:ee.map((m,x)=>e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:jt[x]}),e.jsx(w,{type:"number",min:"0",step:"1000",placeholder:d!=null?String(d):"â",value:c[m]??"",onChange:j=>g(h=>({...h,[m]:j.target.value})),className:"h-8 text-sm","data-testid":`input-revenue-${m}`})]},m))}):e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:te.map((m,x)=>e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:ft[x]}),e.jsx(w,{type:"number",min:"0",step:"1000",placeholder:t!=null&&t.annualRevenueTarget?Str
1ing(Math.round(t.annualRevenueTarget/4)):"â",value:b[m]??"",onChange:j=>l(h=>({...h,[m]:j.target.value})),className:"h-8 text-sm","data-testid":`input-revenue-${m}`})]},m))}),e.jsxs(N,{variant:"outline",size:"sm",className:"mt-3",onClick:v,disabled:i,"data-testid":"button-save-monthly-targets",children:["Save ",u==="monthly"?"Monthly":"Quarterly"," Targets"]})]})}function bt(){const{data:t,isLoading:o}=W({queryKey:["/api/overhead/project-allocation"]});return o?e.jsx("div",{className:"p-8 text-center text-muted-foreground",children:"Loading project allocations..."}):!t||t.allocations.length===0?e.jsxs("div",{className:"p-8 text-center text-muted-foreground",children:[e.jsx(ae,{className:"h-10 w-10 mx-auto mb-3 opacity-30"}),e.jsx("p",{className:"font-medium",children:"No active projects found"}),e.jsx("p",{className:"text-sm mt-1",children:"Overhead allocation requires active projects with budgets"})]}):e.jsxs("div",{className:"space-y-4","data-testid":"project-allocation-section",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-4 mb-4",children:[e.jsxs("div",{className:"p-3 bg-muted/50 rounded-md",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Monthly Overhead"}),e.jsxs("p",{className:"text-lg font-bold",children:["$",p(t.totalMonthlyOverhead)]})]}),e.jsxs("div",{className:"p-3 bg-muted/50 rounded-md",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Direct Costs"}),e.jsxs("p",{className:"text-lg font-bold",children:["$",p(t.totalDirectCosts)]})]}),e.jsxs("div",{className:"p-3 bg-muted/50 rounded-md",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Active Projects"}),e.jsx("p",{className:"text-lg font-bold",children:t.allocations.length})]})]}),e.jsxs(re,{children:[e.jsx(ie,{children:e.jsxs(Q,{children:[e.jsx(T,{children:"Project"}),e.jsx(T,{children:"Status"}),e.jsx(T,{className:"text-right",children:"Direct Cost"}),e.jsx(T,{className:"text-right",children:"Share %"}),e.jsx(T,{className:"text-right",children:"Monthly Allocation"}),e.jsx(T,{className:"text-right",children:"Annual Allocation"})]})}),e.jsx(le,{children:t.allocations.map(i=>e.jsxs(Q,{"data-testid":`row-allocation-${i.projectId}`,children:[e.jsx(S,{children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:i.projectName}),e.jsx("p",{className:"text-xs text-muted-foreground",children:i.projectCode})]})}),e.jsx(S,{children:e.jsx(q,{variant:"secondary",children:i.status})}),e.jsxs(S,{className:"text-right font-mono text-sm",children:["$",p(i.directCost)]}),e.jsxs(S,{className:"text-right font-mono text-sm",children:[i.sharePercent,"%"]}),e.jsxs(S,{className:"text-right font-mono text-sm",children:["$",p(i.monthlyOverheadAllocation)]}),e.jsxs(S,{className:"text-right font-mono text-sm",children:["$",p(i.annualOverheadAllocation)]})]},i.projectId))})]})]})}function yt(){const{data:t,isLoading:o}=W({queryKey:["/api/overhead/monthly-breakdown"]});if(o)return e.jsx("div",{className:"p-8 text-center text-muted-foreground",children:"Loading monthly breakdown..."});if(!t||t.months.length===0)return e.jsx("div",{className:"p-8 text-center text-muted-foreground",children:"No data available"});const i=Math.max(...t.months.map(n=>Math.max(n.overhead,n.revenueTarget??0)));return e.jsxs("div",{className:"space-y-4","data-testid":"monthly-breakdown-section",children:[e.jsx("div",{className:"flex items-end gap-1 h-48","data-testid":"monthly-bar-chart",children:t.months.map(n=>{const d=i>0?n.overhead/i*100:0,u=n.revenueTarget&&i>0?n.revenueTarget/i*100:0;return e.jsxs("div",{className:"flex-1 flex flex-col items-center gap-0.5","data-testid":`bar-month-${n.month}`,children:[e.jsxs("div",{className:"w-full flex items-end gap-0.5 h-40",children:[e.jsx("div",{className:"flex-1 bg-orange-400/70 rounded-t transition-all",style:{height:`${d}%`},title:`Overhead: $${p(n.overhead)}`}),n.revenueTarget!=null&&e.jsx("div",{className:"flex-1 bg-blue-400/50 rounded-t transition-all",style:{height:`${u}%`},title:`Revenue Target: $${p(n.revenueTarget)}`})]}),e.jsx("span",{className:"text-[9px] text-muted-foreground text-center leading-tight",children:n.month.split(" ")[0]})]},n.month)})}),e.jsxs("div",{className:"flex items-center gap-4 justify-center text-xs text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"w-3 h-3 rounded bg-orange-400/70"}),"Monthly Overhead"]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"w-3 h-3 rounded bg-blue-400/50"}),"Revenue Target (÷12)"]})]}),e.jsxs(re,{children:[e.jsx(ie,{children:e.jsxs(Q,{children:[e.jsx(T,{children:"Month"}),e.jsx(T,{className:"text-right",children:"Overhead"}),e.jsx(T,{className:"text-right",children:"Revenue Target"}),e.jsx(T,{className:"text-right",children:"Overhead %"})]})}),e.jsx(le,{children:t.months.map(n=>e.jsxs(Q,{children:[e.jsx(S,{className:"font-medium",children:n.month}),e.jsxs(S,{className:"text-right font-mono text-sm",children:["$",p(n.overhead)]}),e.jsx(S,{className:"text-right font-mono text-sm",children:n.revenueTarget!=null?`$${p(n.revenueTarget)}`:"â"}),e.jsx(S,{className:"text-right font-mono text-sm",children:n.overheadPercent!=null?`${n.overheadPercent}%`:"â"})]},n.month))})]})]})}function Mt({embedded:t}={}){const{toast:o}=fe(),[i,n]=E.useState(!1),[d,u]=E.useState(null),[r,c]=E.useState(null),[g,b]=E.useState(""),[l,v]=E.useState(""),[R,m]=E.useState(""),[x,j]=E.useState(""),[h,C]=E.useState("ALL"),[y,_]=E.useState("costs"),{data:oe=[],isLoading:Se}=W({queryKey:["/api/overhead/items"]}),{data:a,isLoading:V}=W({queryKey:["/api/overhead/summary"]}),Ee=Y({mutationFn:s=>G("DELETE",`/api/overhead/items/${s}`),onSuccess:()=>{M.invalidateQueries({queryKey:["/api/overhead/items"]}),M.invalidateQueries({queryKey:["/api/overhead/summary"]}),M.invalidateQueries({queryKey:["/api/overhead/history"]}),o({title:"Cost item deleted"}),c(null)},onError:s=>o({title:"Error",description:s.message,variant:"destructive"})}),A=Y({mutationFn:s=>G("PATCH","/api/overhead/revenue-target",s),onSuccess:()=>{M.invalidateQueries({queryKey:["/api/overhead/summary"]}),o({title:"Settings saved"})},onError:s=>o({title:"Error",description:s.message,variant:"destructive"})});function Ce(){u(null),n(!0)}function Ae(s){u(s),n(!0)}function we(){const s=g.trim()===""?null:Number(g);if(s!==null&&isNaN(s)){o({title:"Invalid amount",variant:"destructive"});return}A.mutate({annualRevenueTarget:s})}function ke(){const s=Number(l);if(isNaN(s)||s<0||s>100){o({title:"Enter a valid percentage (0â100)",variant:"destructive"});return}A.mutate({annualRevenueTarget:(a==null?void 0:a.annualRevenueTarget)??null,defaultOverheadPercent:s})}function Oe(){(a==null?void 0:a.suggestedPercent)!=null&&(A.mutate({annualRevenueTarget:a.annualRevenueTarget,defaultOverheadPercent:a.suggestedPercent}),o({title:`Default overhead set to ${a.suggestedPercent}%`}))}function Re(){const s=R.trim()===""?null:Number(R),f=x.trim()===""?null:Number(x);if(s!==null&&(isNaN(s)||s<0||s>100)||f!==null&&(isNaN(f)||f<0||f>100)){o({title:"Enter valid percentages (0â100)",variant:"destructive"});return}A.mutate({annualRevenueTarget:(a==null?void 0:a.annualRevenueTarget)??null,overheadWarningThreshold:s,overheadCriticalThreshold:f})}const F=h==="ALL"?oe:oe.filter(s=>s.category===h),H={};for(const s of ne){const f=F.filter(De=>De.category===s);f.length>0&&(H[s]=f)}for(const s of F)ne.includes(s.category)||(H.OTHER||(H.OTHER=[]),H.OTHER.find(f=>f.id===s.id)||H.OTHER.push(s));const Me=["ALL",...de.map(s=>s.value)];return e.jsxs("div",{className:t?"space-y-6":"p-6 space-y-6 max-w-6xl mx-auto",children:[!t&&e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ae,{className:"h-7 w-7 text-primary"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h1",{className:"text-2xl font-bold","data-testid":"heading-overhead-costs",children:"Overhead & Fixed Costs"}),a&&e.jsx(je,{summary:a})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Track recurring company costs to calculate accurate bid overhead percentages"})]})]})}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:[e.jsx(k,{"data-testid":"card-monthly-overhead",children:e.jsx(O,{className:"pt-5",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(tt,{className:"h-8 w-8 text-orange-500 shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground uppercase tracking-wide",children:"Monthly Overhead"}),e.jsx("p",{className:"text-2xl font-bold",children:V?"â":`$${p((a==null?void 0:a.totalMonthly)??0)}`})]})]})})}),e.jsx(k,{"data-testid":"card-annual-overhead",children:e.jsx(O,{className:"pt-5",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(at,{className:"h-8 w-8 text-blue-500 shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground uppercase tracking-wide",children:"Annual Overhead"}),e.jsx("p",{className:"text-2xl font-bold",children:V?"â":`$${p((a==null?void 0:a.totalAnnual)??0)}`})]})]})})}),e.jsx(k,{"data-testid":"card-suggested-percent",children:e.jsx(O,{className:"pt-5",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(st,{className:"h-8 w-8 text-green-500 shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground uppercase tracking-wide",children:"Suggested Overhead %"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"text-2xl font-bold",children:V?"â":(a==null?void 0:a.suggestedPercent)!=null?`${a.suggestedPercent}%`:"â"}),a&&a.suggestedPercent!=null&&e.jsx(je,{summary:a})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"of revenue target"})]})]})})}),e.jsx(k,{"data-testid":"card-default-overhead",children:e.jsx(O,{className:"pt-5",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(nt,{className:"h-8 w-8 text-purple-500 shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground uppercase tracking-wide",children:"Default Bid Overhead"}),e.jsx("p",{className:"text-2xl font-bold",children:V?"â":`${(a==null?void 0:a.defaultOverheadPercent)??15}%`}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"applied to new bids"})]})]})})})]}),e.jsxs(k,{children:[e.jsxs(z,{children:[e.jsx(U,{children:"Overhead Settings"}),e.jsx(B,{children:"Set your annual revenue target to get a calculated overhead percentage recommendation, then apply it to new bids."})]}),e.jsxs(O,{children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium",children:"Annual Revenue Target ($)"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(w,{type:"number",min:"0",step:"1000",placeholder:(a==null?void 0:a.annualRevenueTarget)!=null?String(a.annualRevenueTarget):"e.g. 2000000",value:g,onChange:s=>b(s.target.value),"data-testid":"input-revenue-target"}),e.jsx(N,{variant:"outline",onClick:we,disabled:A.isPending,"data-testid":"button-save-revenue-target",children:"Save"})]}),(a==null?void 0:a.annualRevenueTarget)!=null&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Current: $",p(a.annualRevenueTarget)]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium",children:"Default Overhead % for New Bids"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(w,{type:"number",min:"0",max:"100",step:"0.5",placeholder:String((a==null?void 0:a.defaultOverheadPercent)??15),value:l,onCh
1ange:s=>v(s.target.value),"data-testid":"input-default-overhead-percent"}),e.jsx(N,{variant:"outline",onClick:ke,disabled:A.isPending,"data-testid":"button-set-default-overhead",children:"Set"})]}),(a==null?void 0:a.suggestedPercent)!=null&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Suggested: ",a.suggestedPercent,"% based on your cost data"]}),e.jsxs(N,{type:"button",variant:"link",size:"sm",className:"h-auto p-0 text-xs",onClick:Oe,disabled:A.isPending,"data-testid":"button-apply-suggested",children:[e.jsx(Ne,{className:"h-3 w-3 mr-1"}),"Apply"]})]})]})]}),e.jsxs("div",{className:"mt-6 pt-6 border-t",children:[e.jsxs("h3",{className:"text-sm font-medium mb-3 flex items-center gap-2",children:[e.jsx(be,{className:"h-4 w-4"}),"Overhead Health Alerts"]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:"Warning Threshold (%)"}),e.jsx(w,{type:"number",min:"0",max:"100",step:"0.5",placeholder:(a==null?void 0:a.overheadWarningThreshold)!=null?String(a.overheadWarningThreshold):"e.g. 20",value:R,onChange:s=>m(s.target.value),"data-testid":"input-warning-threshold"}),(a==null?void 0:a.overheadWarningThreshold)!=null&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Current: ",a.overheadWarningThreshold,"%"]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:"Critical Threshold (%)"}),e.jsx(w,{type:"number",min:"0",max:"100",step:"0.5",placeholder:(a==null?void 0:a.overheadCriticalThreshold)!=null?String(a.overheadCriticalThreshold):"e.g. 30",value:x,onChange:s=>j(s.target.value),"data-testid":"input-critical-threshold"}),(a==null?void 0:a.overheadCriticalThreshold)!=null&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Current: ",a.overheadCriticalThreshold,"%"]})]})]}),e.jsx(N,{variant:"outline",size:"sm",className:"mt-3",onClick:Re,disabled:A.isPending,"data-testid":"button-save-thresholds",children:"Save Thresholds"})]}),e.jsx(pt,{summary:a??null,onSave:s=>{A.mutate({annualRevenueTarget:(a==null?void 0:a.annualRevenueTarget)??null,overheadCategoryWeights:s})},isPending:A.isPending}),e.jsx(Nt,{summary:a??null,onSave:s=>{A.mutate({annualRevenueTarget:(a==null?void 0:a.annualRevenueTarget)??null,monthlyRevenueTargets:s})},isPending:A.isPending})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(N,{variant:y==="costs"?"default":"outline",size:"sm",onClick:()=>_("costs"),"data-testid":"tab-costs",children:"Cost Items"}),e.jsx(N,{variant:y==="breakdown"?"default":"outline",size:"sm",onClick:()=>_("breakdown"),"data-testid":"tab-breakdown",children:"Category Breakdown"}),e.jsx(N,{variant:y==="allocation"?"default":"outline",size:"sm",onClick:()=>_("allocation"),"data-testid":"tab-allocation",children:"Project Allocation"}),e.jsx(N,{variant:y==="monthly"?"default":"outline",size:"sm",onClick:()=>_("monthly"),"data-testid":"tab-monthly",children:"Monthly View"}),e.jsxs(N,{variant:y==="history"?"default":"outline",size:"sm",onClick:()=>_("history"),"data-testid":"tab-history",children:[e.jsx(se,{className:"h-4 w-4 mr-1"}),"History"]})]}),y==="costs"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:Me.map(s=>e.jsx(N,{type:"button",variant:h===s?"default":"outline",size:"sm",onClick:()=>C(s),"data-testid":`filter-category-${s}`,children:s==="ALL"?"All Categories":X(s)},s))}),e.jsxs(k,{children:[e.jsx(z,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(U,{children:["Cost Items (",F.length,")"]}),e.jsxs(N,{onClick:Ce,"data-testid":"button-add-overhead-item",children:[e.jsx(rt,{className:"h-4 w-4 mr-2"}),"Add Cost"]})]})}),e.jsx(O,{children:Se?e.jsx("div",{className:"p-8 text-center text-muted-foreground",children:"Loading..."}):F.length===0?e.jsxs("div",{className:"p-8 text-center text-muted-foreground",children:[e.jsx(ae,{className:"h-10 w-10 mx-auto mb-3 opacity-30"}),e.jsx("p",{className:"font-medium",children:"No overhead costs added yet"}),e.jsx("p",{className:"text-sm mt-1",children:'Click "Add Cost" to get started'})]}):e.jsx("div",{"data-testid":"grouped-overhead-items",children:Object.entries(H).map(([s,f])=>e.jsx(xt,{category:s,items:f,onEdit:Ae,onDelete:c},s))})})]}),F.length>0&&e.jsx(k,{className:"bg-muted/40",children:e.jsx(O,{className:"pt-4 pb-4",children:e.jsxs("div",{className:"flex flex-wrap gap-6 text-sm",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Shown items monthly total: "}),e.jsxs("span",{className:"font-semibold",children:["$",p(F.reduce((s,f)=>
1s+K(Number(f.amount),f.frequency,f.amortizationMonths),0)),"/mo"]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Active items only: "}),e.jsxs("span",{className:"font-semibold",children:["$",p(F.filter(s=>s.isActive).reduce((s,f)=>s+K(Number(f.amount),f.frequency,f.amortizationMonths),0)),"/mo"]})]})]})})})]}),y==="breakdown"&&e.jsxs(k,{children:[e.jsxs(z,{children:[e.jsx(U,{children:"Category Breakdown"}),e.jsx(B,{children:"How your overhead costs are distributed across categories"})]}),e.jsx(O,{children:a?e.jsx(vt,{summary:a}):e.jsx("div",{className:"p-8 text-center text-muted-foreground",children:"Loading..."})})]}),y==="allocation"&&e.jsxs(k,{children:[e.jsxs(z,{children:[e.jsx(U,{children:"Per-Project Overhead Allocation"}),e.jsx(B,{children:"How overhead is distributed across active projects based on their share of direct costs (budget or contract amount)"})]}),e.jsx(O,{children:e.jsx(bt,{})})]}),y==="monthly"&&e.jsxs(k,{children:[e.jsxs(z,{children:[e.jsx(U,{children:"Monthly Overhead vs Revenue"}),e.jsx(B,{children:"12-month view comparing monthly overhead costs to revenue target breakdown"})]}),e.jsx(O,{children:e.jsx(yt,{})})]}),y==="history"&&e.jsxs(k,{children:[e.jsxs(z,{children:[e.jsxs(U,{className:"flex items-center gap-2",children:[e.jsx(se,{className:"h-5 w-5"}),"Change History"]}),e.jsx(B,{children:"Audit log of all overhead cost changes"})]}),e.jsx(O,{children:e.jsx(mt,{})})]}),i&&e.jsx(ut,{open:i,onClose:()=>n(!1),editItem:d}),e.jsx(We,{open:!!r,onOpenChange:s=>!s&&c(null),children:e.jsxs(Ve,{"data-testid":"dialog-delete-overhead",children:[e.jsxs(Je,{children:[e.jsx(Ye,{children:"Delete Cost Item?"}),e.jsxs(Ge,{children:["This will permanently remove ",e.jsx("strong",{children:r==null?void 0:r.name})," from your overhead costs. This action cannot be undone."]})]}),e.jsxs(Ze,{children:[e.jsx(Xe,{"data-testid":"button-delete-cancel",children:"Cancel"}),e.jsx(et,{className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",onClick:()=>r&&Ee.mutate(r.id),"data-testid":"button-delete-confirm",children:"Delete"})]})]})})]})}export{Mt as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.