1import{d3 as I,E as D,j as e,ax as M,d4 as V,r as l,b4 as A,t as E,d as L,b as F,b3 as R,bN as $,bO as q,ao as U,bP as z,bT as H,M as B,bf as K,b9 as W,X as _,b5 as J,aI as c}from"./index-CpeGhXo5.js";import{NewRealEstatePage as G}from"./finance.real-estate.new-D0ken_wS.js";import{F as Q}from"./FilterBar-B_jdgGzl.js";import{u as X}from"./useCurrencyHelpers-D5hUvgaW.js";import{C as Y}from"./EntityPill-btGCy98_.js";import{S as Z}from"./scale-Bjl0IPKl.js";import"./Panel-Cf_wAUzv.js";import"./filters-DQMtevU2.js";import"./mock-Ci00pIzy.js";import"./currency-CACMzR5Q.js";function xe(){const f=I();if(f)return f;const{pathname:w}=D();if(w.includes("/real-estate/new"))return e.jsx(G,{});const p=M(),x=V(),{fmtConv:k,fmtConvCompact:y,sym:u}=X(),[N,v]=l.useState([]),[P,h]=l.useState(!1),[m,ee]=l.useState(null),[o,i]=l.useState([{id:"re-001",name:"Tekki Web Solutions Corporate HQ Office",type:"Office Premises",location:"Industrial Area Phase 8A, Sector 75, Mohali, Punjab",purchaseDate:"2022-04-15",purchasePrice:28e5,currentValuation:35e5,ownershipType:"Owned",attachmentUrl:"#",notes:"4,500 sq ft office space with modern IT workstations and conference rooms"},{id:"re-002",name:"IT Park Commercial Development Plot",type:"Commercial Plot",location:"JLPL Industrial Park, Sector 82, Mohali, Punjab",purchaseDate:"2024-01-10",purchasePrice:18e5,currentValuation:22e5,ownershipType:"Owned",attachmentUrl:"#",notes:"500 sq yard commercial plot earmarked for 5-year software campus expansion"}]);l.useEffect(()=>{const t=localStorage.getItem("finance_real_estate_items");if(t)try{const s=JSON.parse(t);Array.isArray(s)&&s.length>0&&i(r=>{const O=new Set(r.map(b=>b.id));return[...s.filter(b=>!O.has(b.id)),...r]})}catch{}},[]);const[a,n]=l.useState({name:"",type:"Office Premises",location:"",purchaseDate:new Date().toISOString().split("T")[0],purchasePrice:0,currentValuation:0,ownershipType:"Owned",notes:""}),g=l.useMemo(()=>o.reduce((t,s)=>t+s.currentValuation,0),[o]),d=l.useMemo(()=>o.reduce((t,s)=>t+s.purchasePrice,0),[o]),j=g-d,C=d>0?j/d*100:0,S=t=>{if(t.preventDefault(),!a.name?.trim())return c.error("Enter property name");if(m)i(s=>s.map(r=>r.id===m.id?{...r,...a}:r)),c.success("Updated property details");else{const s={id:`re-${Date.now()}`,name:a.name.trim(),type:a.type||"Office Premises",location:a.location||"Mohali, Punjab",purchaseDate:a.purchaseDate||new Date().toISOString().split("T")[0],purchasePrice:Number(a.purchasePrice)||0,currentValuation:Number(a.currentValuation)||Number(a.purchasePrice)||0,ownershipType:a.ownershipType||"Owned",notes:a.notes||""};i(r=>[s,...r]),c.success("Added new real estate asset")}h(!1)},T=t=>{confirm("Delete property record?")&&(i(s=>s.filter(r=>r.id!==t)),c.success("Deleted property"))};return e.jsxs("div",{className:"flex flex-col flex-1 h-full min-h-0 overflow-hidden bg-slate-50/50 dark:bg-slate-950/50",children:[e.jsx(A,{title:"Real Estate & Land Assets",subtitle:"Commercial office premises, plot land acquisitions, property valuations, and registry documents",accentVar:"--mod-finance",showMonthYearFilter:!1}),e.jsxs("div",{className:"px-3 pt-2 pb-1.5 shrink-0 grid grid-cols-2 lg:grid-cols-4 gap-2 text-xs",children:[e.jsxs("div",{className:"p-2.5 bg-white dark:bg-slate-900 rounded-lg border border-slate-200 dark:border-slate-800 shadow-2xs flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] uppercase font-bold text-blue-600 dark:text-blue-400 tracking-wide block",children:"Current Valuation"}),e.jsxs("span",{className:"text-sm font-bold text-slate-800 dark:text-slate-200 font-data block",children:[u," ",g.toLocaleString("en-IN")]})]}),e.jsx(E,{className:"w-4 h-4 text-blue-600 shrink-0"})]}),e.jsxs("div",{className:"p-2.5 bg-white dark:bg-slate-900 rounded-lg border border-slate-200 dark:border-slate-800 shadow-2xs flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] uppercase font-bold text-slate-500 tracking-wide block",children:"Acquisition Cost"}),e.jsxs("span",{className:"text-sm font-bold text-slate-800 dark:text-slate-200 font-data block",children:[u," ",d.toLocaleStr
1ing("en-IN")]})]}),e.jsx(Z,{className:"w-4 h-4 text-slate-400 shrink-0"})]}),e.jsxs("div",{className:"p-2.5 bg-white dark:bg-slate-900 rounded-lg border border-slate-200 dark:border-slate-800 shadow-2xs flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] uppercase font-bold text-emerald-600 dark:text-emerald-400 tracking-wide block",children:"Unrealized Gain"}),e.jsxs("span",{className:"text-sm font-bold text-emerald-600 dark:text-emerald-400 font-data block",children:["+",u," ",j.toLocaleString("en-IN")," (",C.toFixed(1),"%)"]})]}),e.jsx(L,{className:"w-4 h-4 text-emerald-500 shrink-0"})]}),e.jsxs("div",{className:"p-2.5 bg-white dark:bg-slate-900 rounded-lg border border-slate-200 dark:border-slate-800 shadow-2xs flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] uppercase font-bold text-purple-600 dark:text-purple-400 tracking-wide block",children:"Properties Owned"}),e.jsxs("span",{className:"text-sm font-bold text-purple-600 dark:text-purple-400 font-data block",children:[o.length," Properties"]})]}),e.jsx(F,{className:"w-4 h-4 text-purple-500 shrink-0"})]})]}),e.jsx("div",{className:"shrink-0 bg-surface/50 border-y border-slate-200 dark:border-slate-800 px-3 py-1.5 flex items-center justify-between",children:e.jsx(Q,{showMonths:!0,actions:e.jsx(R,{delayDuration:150,children:e.jsxs($,{children:[e.jsx(q,{asChild:!0,children:e.jsx("button",{type:"button",onClick:()=>p(`${x}/real-estate/new`),className:"h-8 w-8 p-0 rounded-lg bg-blue-600 hover:bg-blue-700 text-white inline-flex items-center justify-center shadow-2xs transition-colors shrink-0 cursor-pointer",children:e.jsx(U,{className:"w-4 h-4"})})}),e.jsx(z,{side:"bottom",align:"end",children:e.jsx("p",{children:"Add Property"})})]})})})}),e.jsx("div",{className:"p-3 pb-3 flex-1 min-h-0 flex flex-col overflow-hidden",children:e.jsx(H,{fillHeight:!0,selectable:!0,selectedIds:N,onSelectionChange:v,rows:o,rowKey:t=>t.id,searchKeys:["name","type","location"],searchPlaceholder:"Search real estate & land assets...",storageKey:"finance-real-estate",initialPageSize:10,columns:[{key:"name",label:"Property Name & Description",sortable:!0,render:t=>e.jsxs("div",{children:[e.jsx("span",{className:"font-bold text-slate-800 dark:text-slate-200 font-data",children:t.name}),t.notes&&e.jsx("p",{className:"text-[10px] text-slate-400 truncate max-w-md",children:t.notes})]})},{key:"type",label:"Property Type",width:"150px",sortable:!0,render:t=>e.jsx(Y,{name:t.type})},{key:"location",label:"Location",width:"220px",sortable:!0,render:t=>e.jsxs("span",{className:"text-slate-600 dark:text-slate-300 text-[11px] flex items-center gap-1 truncate",children:[e.jsx(B,{className:"w-3 h-3 text-slate-400 shrink-0"})," ",t.location]})},{key:"purchasePrice",label:"Purchase Price",align:"right",width:"130px",sortable:!0,render:t=>e.jsx("span",{className:"font-data font-semibold text-slate-700 dark:text-slate-300",children:y(t.purchasePrice)})},{key:"currentValuation",label:"Market Valuation",align:"right",width:"140px",sortable:!0,render:t=>e.jsx("span",{className:"font-data font-bold text-emerald-600 dark:text-emerald-400",children:k(t.currentValuation)})},{key:"actions",label:"ACTIONS",width:"80px",align:"center",fixed:"right",render:t=>e.jsxs("div",{className:"flex items-center gap-1 justify-center",onClick:s=>s.stopPropagation(),children:[e.jsx("button",{onClick:()=>p(`${x}/real-estate/new?editId=${t.id}`),className:"p-1 rounded hover:bg-slate-100 dark:hover:bg-slate-800 text-slate-600 dark:text-slate-300",title:"Edit Property",children:e.jsx(K,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>T(t.id),className:"p-1 rounded hover:bg-rose-50 text-rose-600",title:"Delete Property",children:e.jsx(W,{className:"w-3.5 h-3.5"})})]})}],onRowClick:t=>p(`${x}/real-estate/new?editId=${t.id}`)})}),P&&e.jsx("div",{className:"fixed inset-0 bg-background/80 backdrop-blur-sm z-50 flex items-center justify-center p-4",children:e.jsxs("div",{className:"bg-white dark:bg-slate-900 border border-slate-200 dark:border-slate-800 rounded-xl shadow-xl max-w-md w-full overflow-hidden animate-in fade-in zoom-in-95 duration-200",children:[e.jsxs("div",{className:"px-4 py-3 border-b border-slate-200 dark:border-slate-800 flex items-center justify-between bg-slate-50 dark:bg-slate-800/40",children:[e.jsx("h3",{className:"text-xs font-bold text-slate-900 dark:text-slate-100",children:m?"Edit Real Estate Property":"Add Real Estate Property"}),e.jsx("button",{onClick:()=>h(!1),className:"p-1 hover:bg-slate-200 rounded",children:e.jsx(_,{className:"w-3.5 h-3.5 text-slate-500"})})]}),e.jsxs("form",{onSubmit:S,className:"p-4 space-y-3 text-xs",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("label",{className:"text-[10px] font-semibold text-slate-600 uppercase",children:["Property Title / Name ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"text",placeholder:"e.g. Tekki Corporate Office Premises",value:a.name,onChange:t=>n({...a,name:t.target.value}),className:"w-full h-8 px-2.5 rounded border border-slate-200 dark:border-slate-800 bg-white dark:bg-slate-900 text-xs",required:!0})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-[10px] font-semibold text-slate-600 uppercase",children:"Property Type"}
1),e.jsxs("select",{value:a.type,onChange:t=>n({...a,type:t.target.value}),className:"w-full h-8 px-2 rounded border border-slate-200 dark:border-slate-800 bg-white dark:bg-slate-900 text-xs",children:[e.jsx("option",{value:"Office Premises",children:"Office Premises"}),e.jsx("option",{value:"Commercial Plot",children:"Commercial Plot"}),e.jsx("option",{value:"Industrial Land",children:"Industrial Land"}),e.jsx("option",{value:"Warehouse",children:"Warehouse"})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-[10px] font-semibold text-slate-600 uppercase",children:"Location / Address"}),e.jsx("input",{type:"text",placeholder:"Mohali, Punjab",value:a.location,onChange:t=>n({...a,location:t.target.value}),className:"w-full h-8 px-2.5 rounded border border-slate-200 dark:border-slate-800 bg-white dark:bg-slate-900 text-xs"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-[10px] font-semibold text-slate-600 uppercase",children:"Purchase Price (â¹)"}),e.jsx("input",{type:"number",placeholder:"0.00",value:a.purchasePrice,onChange:t=>n({...a,purchasePrice:parseFloat(t.target.value)||0}),className:"w-full h-8 px-2.5 rounded border border-slate-200 dark:border-slate-800 bg-white dark:bg-slate-900 font-data font-bold text-xs"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-[10px] font-semibold text-slate-600 uppercase",children:"Market Valuation (â¹)"}),e.jsx("input",{type:"number",placeholder:"0.00",value:a.currentValuation,onChange:t=>n({...a,currentValuation:parseFloat(t.target.value)||0}),className:"w-full h-8 px-2.5 rounded border border-slate-200 dark:border-slate-800 bg-white dark:bg-slate-900 font-data font-bold text-xs"})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-[10px] font-semibold text-slate-600 uppercase",children:"Notes & Description"}),e.jsx("textarea",{rows:2,placeholder:"Additional property details...",value:a.notes,onChange:t=>n({...a,notes:t.target.value}),className:"w-full p-2 rounded border border-slate-200 dark:border-slate-800 bg-white dark:bg-slate-900 text-xs"})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2 border-t border-slate-100 dark:border-slate-800",children:[e.jsx("button",{type:"button",onClick:()=>h(!1),className:"h-7 px-3 rounded border text-xs",children:"Cancel"}),e.jsxs("button",{type:"submit",className:"h-7 px-3 rounded bg-blue-600 hover:bg-blue-700 text-white text-xs font-semibold flex items-center gap-1",children:[e.jsx(J,{className:"w-3.5 h-3.5"})," Save Property"]})]})]})]})})]})}export{xe as RealEstatePage,xe 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.