1import{h as j,c as w,r as v,t as C,j as e,B as h,A as N,l as q}from"./index-_aijvlUq.js";import{P as V}from"./PageHeader-DCofr6qo.js";import{E as O}from"./EmptyState-CPGKooqj.js";import{e as k}from"./equipment-BFd-7mSR.js";import{b as A,r as p,f as l}from"./equipmentValueReport-BI2xc4oS.js";import"./downscaleImage-qyGK-a3D.js";function u(a){let t=String(a??"");return/^[=+\-@]/.test(t)&&(t=`'${t}`),/[",\r\n]/.test(t)?`"${t.replace(/"/g,'""')}"`:t}function m(a){return`Values are ${a||"the organization"}âs own estimates as of the dates shown â not an appraisal, not verified by Backstage Baton, and not a valuation of any donated item for tax purposes.`}function b({totals:a,print:t}){const r=[{label:"Current value (owned)",value:l(a.valueCents),sub:a.borrowedValueCents>0?`+ ${l(a.borrowedValueCents)} property of others`:`${a.valuedCount} of ${a.itemCount} items valued`},{label:"Original price (owned)",value:l(a.originalCents),sub:"where recorded"},{label:"Items / units",value:`${a.itemCount} / ${a.unitCount}`,sub:`serials on ${a.serialCount} of ${a.itemCount}${a.borrowedCount>0?` · ${a.borrowedCount} borrowed`:""}`},{label:"Valuations dated",value:`${a.oldestValueAsOf||"â"}${a.newestValueAsOf&&a.newestValueAsOf!==a.oldestValueAsOf?` â ${a.newestValueAsOf}`:""}`,sub:"oldest first"}];return e.jsx("div",{className:t?"evr-totals":"grid grid-cols-2 sm:grid-cols-4 gap-3 mb-2",children:r.map(d=>e.jsxs("div",{className:t?"evr-stat":"bg-white rounded-xl border border-gray-200 p-4 text-center",children:[e.jsx("p",{className:t?"evr-stat-label":"text-xs text-gray-500 uppercase tracking-wide",children:d.label}),e.jsx("p",{className:t?"evr-stat-value":"text-2xl font-bold text-gray-900 mt-1",children:d.value}),e.jsx("p",{className:t?"evr-stat-sub":"text-xs text-gray-400 mt-0.5",children:d.sub})]},d.label))})}function g({cat:a,print:t}){return e.jsxs("table",{className:t?void 0:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:t?void 0:"text-left text-xs text-gray-500 uppercase tracking-wide border-b border-gray-200",children:[e.jsx("th",{className:t?void 0:"py-2 pr-3",children:"Item"}),e.jsx("th",{className:t?void 0:"py-2 pr-3",children:"Qty"}),e.jsx("th",{className:t?void 0:"py-2 pr-3",children:"Make / Model"}),e.jsx("th",{className:t?void 0:"py-2 pr-3",children:"Serial"}),e.jsx("th",{className:t?void 0:"py-2 pr-3",children:"Location"}),t&&e.jsx("th",{children:"Source"}),t&&e.jsx("th",{children:"Acquired"}),t&&e.jsx("th",{children:"Cond."}),e.jsx("th",{className:t?void 0:"py-2 pr-3",children:"Ownership"}),e.jsx("th",{className:t?void 0:"py-2 pr-3 text-right",children:"Original"}),e.jsx("th",{className:t?void 0:"py-2 pr-3 text-right",children:"Value"}),e.jsx("th",{className:t?void 0:"py-2",children:"As of"})]})}),e.jsxs("tbody",{children:[a.rows.map(r=>e.jsxs("tr",{className:t?void 0:"border-b border-gray-100",children:[e.jsx("td",{className:t?void 0:"py-1.5 pr-3 font-medium text-gray-900",children:r.name}),e.jsx("td",{className:t?void 0:"py-1.5 pr-3 text-gray-600",children:r.quantity||1}),e.jsx("td",{className:t?void 0:"py-1.5 pr-3 text-gray-600",children:r.makeModel||"â"}),e.jsx("td",{className:t?"evr-mono":"py-1.5 pr-3 font-mono text-xs text-gray-600",children:r.serialNumber||"â"}),e.jsx("td",{className:t?void 0:"py-1.5 pr-3 text-gray-600",children:r.storageVenueName||r.storageLocation||"â"}),t&&e.jsx("td",{children:r.source||"â"}),t&&e.jsx("td",{children:r.acquiredAt?String(r.acquiredAt).slice(0,10):"â"}),t&&e.jsx("td",{children:r.condition?String(r.condition).replace(/_/g," "):"â"}),e.jsx("td",{className:t?void 0:"py-1.5 pr-3 text-gray-600",children:r.ownership==="borrowed"?`Borrowed${r.borrowedFrom?" â "+r.borrowedFrom:""}`:"Own"}),e.jsx("td",{className:t?"evr-num":"py-1.5 pr-3 text-right text-gray-600 tabular-nums",children:l(r.originalPriceCents)}),e.jsxs("td",{className:t?"evr-num":"py-1.5 pr-3 text-right text-gray-900 tabular-nums font-medium",children:[l(p(r)),r.kind==="stock"&&r.estimatedValueCents!=null?e.jsxs("span",{className:t?"evr-unit":"block text-xs font-normal text-gray-500",children:[r.quantity||0," à ",l(r.estimatedValueCents)]}):null]}),e.jsx("td",{className:t?void 0:"py-1.5 text-gray-500 text-xs",children:r.estimatedValueCents!=null?r.valueAsOf||"undated":"â"})]},r.id)),e.jsxs("tr",{className:t?"evr-subtotal":"font-semibold text-gray-900",children:[e.jsxs("td",{className:t?void 0:"py-2 pr-3",colSpan:t?9:6,children:[a.name," subtotal (owned)",a.borrowedValueCents>0&&e.jsxs("span",{className:t?"evr-muted":"font-normal text-gray-400",children:[" · + ",l(a.borrowedValueCents)," property of others"]}),a.unvaluedCount>0&&e.jsxs("span",{className:t?"evr-muted":"font-normal text-gray-400",children:[" · ",a.unvaluedCount," item",a.unvaluedCount===1?"":"s"," unvalued, not included"]})]}),e.jsx("td",{className:t?"evr-num":"py-2 pr-3 text-right tabular-nums",children:l(a.subtotalOriginalCents)}),e.jsx("td",{className:t?"evr-num":"py-2 pr-3 text-right tabular-nums",children:l(a.subtotalValueCents)}),e.jsx("td",{})]})]})]})}function P(){const a=j(n=>n.currentOrg),{showError:t}
1=w(),[r,d]=v.useState(null);v.useEffect(()=>{let n=!0;return k.list().then(i=>{n&&d(Array.isArray(i)?i:[])}).catch(()=>t(C("equipment"))),()=>{n=!1}},[]);const s=r?A(r):null;function f(){const i=[["Category","Item","Qty","Make/Model","Serial","Inventory Tag","Location","Source","Acquired","Ownership","Condition","Original Price","Current Value","Value As Of"].map(u).join(",")];for(const x of s.categories)for(const o of x.rows)i.push([x.name,o.name,o.quantity||1,o.makeModel||"",o.serialNumber||"",o.inventoryTag||"",o.storageVenueName||o.storageLocation||"",o.source||"",o.acquiredAt?String(o.acquiredAt).slice(0,10):"",o.ownership==="borrowed"?`Borrowed${o.borrowedFrom?" - "+o.borrowedFrom:""}`:"Own",o.condition||"",o.originalPriceCents!=null?(o.originalPriceCents/100).toFixed(2):"",p(o)!=null?(p(o)/100).toFixed(2):"",o.estimatedValueCents!=null&&o.valueAsOf||""].map(u).join(","));i.push(""),i.push([`TOTAL OWNED (${s.totals.valuedCount} of ${s.totals.itemCount} items valued; ${s.totals.unvaluedCount} unvalued excluded)`,"","","","","","","","","","",(s.totals.originalCents/100).toFixed(2),(s.totals.valueCents/100).toFixed(2),""].map(u).join(",")),s.totals.borrowedValueCents>0&&i.push([`PROPERTY OF OTHERS (${s.totals.borrowedCount} borrowed item${s.totals.borrowedCount===1?"":"s"})`,"","","","","","","","","","","",(s.totals.borrowedValueCents/100).toFixed(2),""].map(u).join(",")),i.push(""),i.push(u(m(a?.name)));const y=new Blob([i.join(` 2`)],{type:"text/csv;charset=utf-8"}),c=document.createElement("a");c.href=URL.createObjectURL(y),c.download=`equipment-value-report_${q()}.csv`,c.click(),URL.revokeObjectURL(c.href)}return e.jsxs("div",{className:"px-4 md:px-0 print:px-0",children:[e.jsx(V,{title:"Equipment Value Report",breadcrumbs:[{label:"Reports",to:"/reports"},{label:"Equipment Value"}],subtitle:"Inventory of equipment with the values your organization has recorded â for insurance conversations and grant asset lists.",actions:s&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(h,{variant:"secondary",size:"md",onClick:f,children:"Export CSV"}),e.jsx(h,{variant:"secondary",size:"md",onClick:()=>window.print(),children:"Print"})]})}),r?r.length===0?e.jsx(O,{card:!0,title:"No equipment yet.",description:"Add items with their values and the report builds itself."}):e.jsxs(e.Fragment,{children:[e.jsx(b,{totals:s.totals}),e.jsx("p",{className:"text-xs text-gray-400 mb-4",children:m(a?.name)}),s.totals.unvaluedCount>0&&e.jsxs("div",{className:"bg-amber-50 border border-amber-200 rounded-xl p-3 mb-4 text-sm text-amber-800",children:[e.jsxs("strong",{children:[s.totals.unvaluedCount," item",s.totals.unvaluedCount===1?" has":"s have"," no recorded value"]})," â unknown, not zero, and excluded from every total. An insurer or grant reviewer should know this inventory is incomplete until theyâre valued."]}),s.categories.map(n=>e.jsxs("section",{className:"bg-white rounded-xl border border-gray-200 p-4 sm:p-6 mb-4 overflow-x-auto",children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-500 uppercase tracking-wide mb-3",children:n.name}),e.jsx(g,{cat:n})]},n.name))]}):e.jsx("p",{className:"text-sm text-gray-400 py-8 text-center",children:"Loading equipmentâ¦"}),s&&N.createPortal(e.jsxs("div",{id:"equipment-value-print","aria-hidden":"true",children:[e.jsxs("div",{className:"evr-masthead",children:[e.jsx("p",{className:"evr-org",children:a?.name||""}),e.jsx("h1",{children:"Equipment Value Report"}),e.jsxs("p",{className:"evr-sub",children:["Equipment inventory for insurance and grant use · generated ",new Date().toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"})]})]}),e.jsx(b,{totals:s.totals,print:!0}),e.jsxs("p",{className:"evr-footnote",children:[m(a?.name),s.totals.borrowedCount>0&&" Borrowed items are the property of the named lender and are listed for care-custody-control purposes only."]}),s.totals.unvaluedCount>0&&e.jsxs("p",{className:"evr-warn",children:[e.jsxs("strong",{children:[s.totals.unvaluedCount," item",s.totals.unvaluedCount===1?" has":"s have"," no recorded value"]})," â unknown, not zero; excluded from every total above and below."]}),s.categories.map(n=>e.jsxs("section",{className:"evr-section",children:[e.jsx("h2",{children:n.name}),e.jsx(g,{cat:n,print:!0})]},n.name)),e.jsxs("p",{className:"evr-footer",children:["Generated ",new Date().toLocaleDateString("en-US")," · Values are the organizationâs own estimates; not an appraisal · Powered by Backstage Baton"]})]}),document.body),e.jsx("style",{children:` 3 #equipment-value-print { display: none; } 4 @media print { 5 @page { size: letter landscape; margin: 12mm; } 6 body > *:not(#equipment-value-print) { display: none !important; } 7 #equipment-value-print { display: block; font: 10px/1.45 -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; color: #111827; -webkit-print-color-adjust: exact; print-color-adjust: exact; } 8 #equipment-value-print .evr-masthead { border-bottom: 2px solid #2e6b8a; padding-bottom: 6px; margin-bottom: 10px; } 9 #equipment-value-print .evr-org { margin: 0; font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: #6b7280; } 10 #equipment-value-print h1 { font-size: 19px; margin: 2px 0; color: #163d55; } 11 #equipment-value-print .evr-sub { margin: 0; font-size: 10px; color: #6b7280; } 12 #equipment-value-print .evr-totals { display: flex; gap: 20px; margin: 0 0 6px; } 13 #equipment-value-print .evr-stat-label { margin: 0; font-size: 8.5px; text-transform: uppercase; letter-spacing: 0.05em; color: #6b7280; } 14 #equipment-value-print .evr-stat-value { margin: 1px 0 0; font-size: 14px; font-weight: 700; color: #111827; } 15 #equipment-value-print .evr-stat-sub { margin: 0; font-size: 8.5px; color: #9ca3af; } 16 #equipment-value-print .evr-footnote { margin: 0 0 8px; font-size: 8.5px; color: #6b7280; } 17 #equipment-value-print .evr-warn { background: #fef3c7; border-left: 4px solid #d97706; border-radius: 4px; padding: 5px 9px; font-size: 9px; color: #92400e; margin: 0 0 8px; } 18 #equipment-value-print .evr-section { margin: 0 0 10px; break-inside: avoid; } 19 #equipment-value-print h2 { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em; color: #2e6b8a; border-bottom: 1px solid #e5e7eb; padding-bottom: 2px; margin: 0 0 3px; } 20 #equipment-value-print table { width: 100%; border-collapse: collapse; } 21 #equipment-value-print th, #equipment-value-print td { border: 1px solid #e5e7eb; padding: 2px 5px; text-align: left; font-size: 9px; } 22 #equipment-value-print th { background: #f3f4f6; font-weight: 600; color: #374151; text-transform: uppercase; font-size: 8px; letter-spacing: 0.04em; } 23 #equipment-value-print .evr-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; } 24 #equipment-value-print .evr-mono { font-family: ui-monospace, Consolas, monospace; font-size: 8px; } 25 #equipment-value-print .evr-subtotal td { border-top: 2px solid #9ca3af; font-weight: 700; background: #f9fafb; } 26 #equipment-value-print .evr-muted { font-weight: 400; color: #6b7280; } 27 #equipment-value-print .evr-footer { margin-top: 10px; padding-top: 5px; border-top: 1px solid #e5e7eb; font-size: 8.5px; color: #9ca3af; text-align: center; } 28 } 29 `})]})}
29export{P as EquipmentValueReportPage};
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.