PageSourceSearch

https://www.jaaga.ai/assets/CommunityConsole-1b09a190.js

js jaaga.ai collected 2026-09-24 10:56:59 UTC 246,249 bytes, 127 lines download raw bytes

1import{I as Y,r as a,j as e,T as te,bs as ae,J as de,X as kt,U as Ct,gJ as os,C as et,F as Zs,g0 as ds,cl as ea,f as wt,e as ta,ck as Lt,L as it}from"./index-a9db3765.js";import{m as B,f as xs,a as St,k as ms,b as se,c as zt,p as tt,d as Pt,P as sa,s as aa,e as na,r as us,g as la,v as ia,h as ps,i as ra,u as ca,M as oa,j as hs,l as At,n as Rt,o as $t,q as da,t as xa,w as ma,x as ua,y as fs,z as pa,A as ha,B as fa,C as ba,D as ga,E as ja,F as va,G as ya,H as Na,I as ka,J as Ca,K as wa,L as Sa,N as za,O as Pa,Q as Aa,R as Ft,S as Ot,T as Ra,U as Ta,V as Ea,W as Ma,X as bs,Y as Ba,Z as Ut,_ as _a,$ as Da,a0 as La,a1 as $a,a2 as Fa,a3 as Oa,a4 as gs,a5 as Ua,a6 as Ia,a7 as Ga,a8 as Ha,a9 as Va,aa as Ka,ab as Wa,ac as Ya,ad as qa,ae as Ja,af as Fe,ag as Qa,ah as Xa,ai as Za,aj as rt,ak as It,al as en,am as tn,an as sn,ao as an,ap as nn,aq as ln,ar as rn,as as cn,at as on,au as dn,av as xn,aw as mn}from"./communityApi-9d4029e8.js";import{C as T,E as Q,S as ze,B as y,P as F,M as q,F as C,i as k,K as G,W as me,D as st,L as he,A as un,a as De,b as X,R as pn,c as Oe,d as we,e as hn,f as fn,g as bn,h as ct,j as ft}from"./Receipt-33cc1b3b.js";import{R as gn,P as js}from"./PropertyPicker-5f5319c8.js";import{A as jn}from"./AddPropertyModal-ce5e3101.js";import{T as Ne,K as fe,L as vn,s as yn}from"./listingsApi-99d6e358.js";import{L as Nn}from"./LoginGate-169ba191.js";import{S as kn}from"./search-96295409.js";import{L as ne}from"./loader-circle-525ce89e.js";import{C as vs}from"./copy-5185e60e.js";import{P as Tt}from"./phone-0fddfe69.js";import{C as Et}from"./chevron-left-53dfaa9a.js";import{H as Pe}from"./house-e6e2e314.js";import{R as xe,B as Gt}from"./receipt-20f8a2c0.js";import{S as ce}from"./shield-check-e5caee76.js";import{T as be}from"./trash-2-ac3a09e0.js";import{E as ys}from"./external-link-a06ae40b.js";import{I as Ae}from"./indian-rupee-7a8ce2d0.js";import{U as Ue}from"./users-946abc1b.js";import{T as Ve}from"./trending-up-d7642243.js";import{B as Cn}from"./bell-e7d3e52d.js";import{P as Ht}from"./play-c5e4f892.js";import{Q as Le}from"./qr-code-603f8d11.js";import{C as ue}from"./circle-check-fc7df41c.js";import{I as Ns}from"./info-ee29f7f1.js";import{I as He}from"./inbox-0fc29f37.js";import{S as ks}from"./send-0387825e.js";import{C as bt,T as wn}from"./trees-2786f5b2.js";import{C as Sn}from"./clock-95458a3d.js";import{W as zn}from"./waves-37798369.js";import{T as Pn}from"./trophy-6ea9564f.js";import{L as An}from"./LocationPickerMap-1750a8e7.js";import{r as Rn}from"./geocoding-f5ac55df.js";import{M as Ke}
1from"./map-pin-8192f3ac.js";import{C as Me}from"./check-db1f7ca9.js";import{R as Tn}from"./refresh-cw-faea1f1e.js";import{U as gt}from"./upload-07f9b9c5.js";import{L as $e}from"./landmark-faad4c98.js";import{B as Cs}from"./badge-check-904b82e5.js";import{D as En}from"./droplets-1d5d311f.js";import{F as Mn}from"./flame-19891641.js";import{S as ws}from"./sparkles-c7f98271.js";import{Z as Bn}from"./zap-2296fa16.js";import{T as _n}from"./trending-down-7b136bcf.js";import{S as Dn}from"./scale-a83c394d.js";import{P as Ln}from"./piggy-bank-23a5a371.js";import{K as We}from"./key-round-a831da3b.js";import{L as $n}from"./layout-dashboard-5601ae5a.js";import{C as Fn}from"./chevron-down-5c01a0da.js";import"./download-7aef6341.js";import"./masterpropertyIcon-a40be650.js";import"./TextField-51e349f7.js";import"./Menu-af088ead.js";import"./IconButton-b0e4283b.js";import"./ButtonBase-b67bf523.js";import"./MenuItem-d15af84d.js";import"./dividerClasses-07928e34.js";import"./lock-eb8095b1.js";import"./hooks-064e4e28.js";import"./MapLayers-fec5ccad.js";import"./circle-51f8e0b0.js";import"./layers-057c2cda.js";import"./satellite-4938c08e.js";import"./mapHelpers-8611d173.js";import"./ScaleControl-5918e522.js";/**
2 * @license lucide-react v0.462.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const On=Y("Bug",[["path",{d:"m8 2 1.88 1.88",key:"fmnt4t"}],["path",{d:"M14.12 3.88 16 2",key:"qol33r"}],["path",{d:"M9 7.13v-1a3.003 3.003 0 1 1 6 0v1",key:"d7y7pr"}],["path",{d:"M12 20c-3.3 0-6-2.7-6-6v-3a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v3c0 3.3-2.7 6-6 6",key:"xs1cw7"}],["path",{d:"M12 20v-9",key:"1qisl0"}],["path",{d:"M6.53 9C4.6 8.8 3 7.1 3 5",key:"32zzws"}],["path",{d:"M6 13H2",key:"82j7cp"}],["path",{d:"M3 21c0-2.1 1.7-3.9 3.8-4",key:"4p0ekp"}],["path",{d:"M20.97 5c0 2.1-1.6 3.8-3.5 4",key:"18gb23"}],["path",{d:"M22 13h-4",key:"1jl80f"}],["path",{d:"M17.2 17c2.1.1 3.8 1.9 3.8 4",key:"k3fwyw"}]]);/**
7 * @license lucide-react v0.462.0 - ISC
8 *
9 * This source code is licensed under the ISC license.
10 * See the LICENSE file in the root directory of this source tree.
11 */const Un=Y("Calculator",[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["line",{x1:"8",x2:"16",y1:"6",y2:"6",key:"x4nwl0"}],["line",{x1:"16",x2:"16",y1:"14",y2:"18",key:"wjye3r"}],["path",{d:"M16 10h.01",key:"1m94wz"}],["path",{d:"M12 10h.01",key:"1nrarc"}],["path",{d:"M8 10h.01",key:"19clt8"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M8 14h.01",key:"6423bh"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M8 18h.01",key:"lrp35t"}]]);/**
12 * @license lucide-react v0.462.0 - ISC
13 *
14 * This source code is licensed under the ISC license.
15 * See the LICENSE file in the root directory of this source tree.
16 */const Ye=Y("CalendarCheck",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"m9 16 2 2 4-4",key:"19s6y9"}]]);/**
17 * @license lucide-react v0.462.0 - ISC
18 *
19 * This source code is licensed under the ISC license.
20 * See the LICENSE file in the root directory of this source tree.
21 */const In=Y("CirclePlay",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polygon",{points:"10 8 16 12 10 16 10 8",key:"1cimsy"}]]);/**
22 * @license lucide-react v0.462.0 - ISC
23 *
24 * This source code is licensed under the ISC license.
25 * See the LICENSE file in the root directory of this source tree.
26 */const Gn=Y("CircleX",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);/**
27 * @license lucide-react v0.462.0 - ISC
28 *
29 * This source code is licensed under the ISC license.
30 * See the LICENSE file in the root directory of this source tree.
31 */const at=Y("DoorOpen",[["path",{d:"M13 4h3a2 2 0 0 1 2 2v14",key:"hrm0s9"}],["path",{d:"M2 20h3",key:"1gaodv"}],["path",{d:"M13 20h9",key:"s90cdi"}],["path",{d:"M10 12v.01",key:"vx6srw"}],["path",{d:"M13 4.562v16.157a1 1 0 0 1-1.242.97L5 20V5.562a2 2 0 0 1 1.515-1.94l4-1A2 2 0 0 1 13 4.561Z",key:"199qr4"}]]);/**
32 * @license lucide-react v0.462.0 - ISC
33 *
34 * This source code is licensed under the ISC license.
35 * See the LICENSE file in the root directory of this source tree.
36 */const Hn=Y("Layers3",[["path",{d:"m12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83Z",key:"8b97xw"}],["path",{d:"m6.08 9.5-3.5 1.6a1 1 0 0 0 0 1.81l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9a1 1 0 0 0 0-1.83l-3.5-1.59",key:"1e5n1m"}],["path",{d:"m6.08 14.5-3.5 1.6a1 1 0 0 0 0 1.81l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9a1 1 0 0 0 0-1.83l-3.5-1.59",key:"1iwflc"}]]);/**
37 * @license lucide-react v0.462.0 - ISC
38 *
39 * This source code is licensed under the ISC license.
40 * See the LICENSE file in the root directory of this source tree.
41 */const Ss=Y("LayoutGrid",[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]]);/**
42 * @license lucide-react v0.462.0 - ISC
43 *
44 * This source code is licensed under the ISC license.
45 * See the LICENSE file in the root directory of this source tree.
46 */const Vn=Y("ListChecks",[["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"m3 7 2 2 4-4",key:"1obspn"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}]]);/**
47 * @license lucide-react v0.462.0 - ISC
48 *
49 * This source code is licensed under the ISC license.
50 * See the LICENSE file in the root directory of this source tree.
51 */const zs=Y("Package",[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["path",{d:"m3.3 7 7.703 4.734a2 2 0 0 0 1.994 0L20.7 7",key:"yx3hmr"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]]);/**
52 * @license lucide-react v0.462.0 - ISC
53 *
54 * This source code is licensed under the ISC license.
55 * See the LICENSE file in the root directory of this source tree.
56 */const Vt=Y("PenLine",[["path",{d:"M12 20h9",key:"t2du7b"}],["path",{d:"M16.376 3.622a1 1 0 0 1 3.002 3.002L7.368 18.635a2 2 0 0 1-.855.506l-2.872.838a.5.5 0 0 1-.62-.62l.838-2.872a2 2 0 0 1 .506-.854z",key:"1ykcvy"}]]);/**
57 * @license lucide-react v0.462.0 - ISC
58 *
59 * This source code is licensed under the ISC license.
60 * See the LICENSE file in the root directory of this source tree.
61 */const Kn=Y("PinOff",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89",key:"znwnzq"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11",key:"c9qhm2"}]]);/**
62 * @license lucide-react v0.462.0 - ISC
63 *
64 * This source code is licensed under the ISC license.
65 * See the LICENSE file in the root directory of this source tree.
66 */const jt=Y("Pin",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7
66a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]]);/**
67 * @license lucide-react v0.462.0 - ISC
68 *
69 * This source code is licensed under the ISC license.
70 * See the LICENSE file in the root directory of this source tree.
71 */const Wn=Y("Power",[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]]);/**
72 * @license lucide-react v0.462.0 - ISC
73 *
74 * This source code is licensed under the ISC license.
75 * See the LICENSE file in the root directory of this source tree.
76 */const Yn=Y("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/**
77 * @license lucide-react v0.462.0 - ISC
78 *
79 * This source code is licensed under the ISC license.
80 * See the LICENSE file in the root directory of this source tree.
81 */const qn=Y("Shirt",[["path",{d:"M20.38 3.46 16 2a4 4 0 0 1-8 0L3.62 3.46a2 2 0 0 0-1.34 2.23l.58 3.47a1 1 0 0 0 .99.84H6v10c0 1.1.9 2 2 2h8a2 2 0 0 0 2-2V10h2.15a1 1 0 0 0 .99-.84l.58-3.47a2 2 0 0 0-1.34-2.23z",key:"1wgbhj"}]]);/**
82 * @license lucide-react v0.462.0 - ISC
83 *
84 * This source code is licensed under the ISC license.
85 * See the LICENSE file in the root directory of this source tree.
86 */const Jn=Y("Siren",[["path",{d:"M7 18v-6a5 5 0 1 1 10 0v6",key:"pcx96s"}],["path",{d:"M5 21a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-1a2 2 0 0 0-2-2H7a2 2 0 0 0-2 2z",key:"1b4s83"}],["path",{d:"M21 12h1",key:"jtio3y"}],["path",{d:"M18.5 4.5 18 5",key:"g5sp9y"}],["path",{d:"M2 12h1",key:"1uaihz"}],["path",{d:"M12 2v1",key:"11qlp1"}],["path",{d:"m4.929 4.929.707.707",key:"1i51kw"}],["path",{d:"M12 12v6",key:"3ahymv"}]]);/**
87 * @license lucide-react v0.462.0 - ISC
88 *
89 * This source code is licensed under the ISC license.
90 * See the LICENSE file in the root directory of this source tree.
91 */const Kt=Y("Smartphone",[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]]);/**
92 * @license lucide-react v0.462.0 - ISC
93 *
94 * This source code is licensed under the ISC license.
95 * See the LICENSE file in the root directory of this source tree.
96 */const Qn=Y("Snowflake",[["line",{x1:"2",x2:"22",y1:"12",y2:"12",key:"1dnqot"}],["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"m20 16-4-4 4-4",key:"rquw4f"}],["path",{d:"m4 8 4 4-4 4",key:"12s3z9"}],["path",{d:"m16 4-4 4-4-4",key:"1tumq1"}],["path",{d:"m8 20 4-4 4 4",key:"9p200w"}]]);/**
97 * @license lucide-react v0.462.0 - ISC
98 *
99 * This source code is licensed under the ISC license.
100 * See the LICENSE file in the root directory of this source tree.
101 */const Xn=Y("Type",[["polyline",{points:"4 7 4 4 20 4 20 7",key:"1nosan"}],["line",{x1:"9",x2:"15",y1:"20",y2:"20",key:"swin9y"}],["line",{x1:"12",x2:"12",y1:"4",y2:"20",key:"1tx1rr"}]]);/**
102 * @license lucide-react v0.462.0 - ISC
103 *
104 * This source code is licensed under the ISC license.
105 * See the LICENSE file in the root directory of this source tree.
106 */const Zn=Y("UserCog",[["circle",{cx:"18",cy:"15",r:"3",key:"gjjjvw"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M10 15H6a4 4 0 0 0-4 4v2",key:"1nfge6"}],["path",{d:"m21.7 16.4-.9-.3",key:"12j9ji"}],["path",{d:"m15.2 13.9-.9-.3",key:"1fdjdi"}],["path",{d:"m16.6 18.7.3-.9",key:"heedtr"}],["path",{d:"m19.1 12.2.3-.9",key:"1af3ki"}],["path",{d:"m19.6 18.7-.4-1",key:"1x9vze"}],["path",{d:"m16.8 12.3-.4-1",key:"vqeiwj"}],["path",{d:"m14.3 16.6 1-.4",key:"1qlj63"}],["path",{d:"m20.7 13.8 1-.4",key:"1v5t8k"}]]);/**
107 * @license lucide-react v0.462.0 - ISC
108 *
109 * This source code is licensed under the ISC license.
110 * See the LICENSE file in the root directory of this source tree.
111 */const qe=Y("UserPlus",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]]);/**
112 * @license lucide-react v0.462.0 - ISC
113 *
114 * This source code is licensed under the ISC license.
115 * See the LICENSE file in the root directory of this source tree.
116 */const vt=Y("UsersRound",[["path",{d:"M18 21a8 8 0 0 0-16 0",key:"3ypg7q"}],["circle",{cx:"10",cy:"8",r:"5",key:"o932ke"}],["path",{d:"M22 20c0-3.37-2-6.5-4-8a5 5 0 0 0-.45-8.3",key:"10s06x"}]]);/**
117 * @license lucide-react v0.462.0 - ISC
118 *
119 * This source code is licensed under the ISC license.
120 * See the LICENSE file in the root directory of this source tree.
121 */const el=Y("Utensils",[["path",{d:"M3 2v7c0 1.1.9 2 2 2h4a2 2 0 0 0 2-2V2",key:"cjf0a3"}],["path",{d:"M7 2v20",key:"1473qp"}
121],["path",{d:"M21 15V2a5 5 0 0 0-5 5v6c0 1.1.9 2 2 2h3Zm0 0v7",key:"j28e5"}]]);/**
122 * @license lucide-react v0.462.0 - ISC
123 *
124 * This source code is licensed under the ISC license.
125 * See the LICENSE file in the root directory of this source tree.
126 */const tl=Y("Wind",[["path",{d:"M12.8 19.6A2 2 0 1 0 14 16H2",key:"148xed"}],["path",{d:"M17.5 8a2.5 2.5 0 1 1 2 4H2",key:"1u4tom"}],["path",{d:"M9.8 4.4A2 2 0 1 1 11 8H2",key:"75valh"}]]),Je={"occupied-owner":{tone:"navy",label:"Owner"},"occupied-tenant":{tone:"gold",label:"Tenant"},vacant:{tone:"slate",label:"Vacant"}},Ps={paid:"green",due:"amber",overdue:"red"};function As({societyId:t}){const[s,n]=a.useState(""),[i,r]=a.useState(null),[l,c]=a.useState(!1),[x,o]=a.useState(""),[m,d]=a.useState(null),u=a.useRef(null),b=f=>{if(n(f),u.current&&clearTimeout(u.current),!f.trim()){r(null),c(!1);return}c(!0),u.current=setTimeout(async()=>{try{r(await aa(t,f.trim())||[])}catch{r([])}finally{c(!1)}},320)},g=f=>{var h;(h=navigator.clipboard)==null||h.writeText(f).then(()=>{o(f),setTimeout(()=>o(""),1500)})},v=f=>f==="owner"?"navy":f==="tenant"?"gold":f==="guest"?"green":"slate";return e.jsxs("div",{className:T+" mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 px-3.5 py-2.5",children:[e.jsx(kn,{size:16,className:"shrink-0 text-[#8493b4]"}),e.jsx("input",{className:"w-full bg-transparent text-[13.5px] text-[#0f2547] outline-none placeholder:text-[#8493b4]",placeholder:"Find a resident — name, phone, or room…",value:s,onChange:f=>b(f.target.value)}),l?e.jsx(ne,{size:15,className:"shrink-0 animate-spin text-[#1c4b93]"}):s?e.jsx("button",{type:"button",onClick:()=>b(""),className:"shrink-0 text-[#8493b4] hover:text-[#153568]",children:e.jsx(kt,{size:15})}):null]}),i!==null&&e.jsxs("div",{className:"border-t border-[#eef1f7]",children:[i.length===0?e.jsxs("p",{className:"px-4 py-4 text-[12.5px] text-[#8493b4]",children:["No residents match “",s,"”. Try a different name, phone, or room."]}):i.map(f=>{const h=[f.towerName,f.bedLabel?`Room ${f.unitCode} · Bed ${f.bedLabel}`:f.unitCode].filter(Boolean).join(" · ");return e.jsxs("div",{className:"flex items-center gap-3 border-t border-[#f3f5fa] px-4 py-2.5 first:border-t-0",children:[e.jsx("span",{className:"grid h-9 w-9 shrink-0 place-items-center rounded-full bg-[#153568] text-[12px] font-extrabold text-white",children:(f.name||"?").trim().charAt(0).toUpperCase()}),e.jsxs("button",{type:"button",onClick:()=>f.unitId&&d({_id:f.unitId,code:f.unitCode}),className:"min-w-0 flex-1 rounded-lg px-1 py-0.5 text-left transition hover:bg-[#f4f7fc]",title:"Open in directory",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate text-[13px] font-bold text-[#0f2547]",children:f.name||"Resident"}),f.role&&e.jsx(F,{tone:v(f.role),children:f.role})]}),e.jsxs("div",{className:"mt-0.5 truncate text-[11.5px] text-[#8493b4]",children:[h||"—",f.phone?` · ${f.phone}`:""]})]}),f.phone&&e.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[e.jsx("button",{type:"button",onClick:()=>g(f.phone),title:"Copy number",className:"grid h-8 w-8 place-items-center rounded-lg bg-[#eef3fb] text-[#1c4b93] hover:bg-[#e2ebf9]",children:e.jsx(vs,{size:14})}),e.jsx("a",{href:`tel:${f.phone}`,title:"Call",className:"grid h-8 w-8 place-items-center rounded-lg bg-[#153568] text-white hover:bg-[#1c4b93]",children:e.jsx(Tt,{size:14})})]})]},f.membershipId)}),x&&e.jsxs("p",{className:"px-4 pb-2 text-[11px] font-semibold text-[#15964f]",children:["Copied ",x]})]}),e.jsx(Ts,{unit:m,societyId:t,onClose:()=>d(null),onChanged:()=>{}})]})}function sl({societyId:t}){var b;const[s,n]=a.useState(null),[i,r]=a.useState(!1),[l,c]=a.useState(null),[x,o]=a.useState(!1),m=()=>{r(!1),xs(t).then(n).catch(()=>r(!0))};if(a.useEffect(m,[t]),i)return e.jsx("div",{className:T,children:e.jsx(Q,{icon:e.jsx(te,{size:26}),title:"Couldn't load the directory",sub:"Try again in a moment."})});if(!s)return e.jsx(kl,{});if(((b=s.society)==null?void 0:b.type)==="pg")return e.jsx(fl,{societyId:t,society:s.society,rooms:s.rooms||[],reload:m});if(l)return e.jsx(nl,{societyId:t,tower:l,onBack:()=>{c(null),m()}});const{society:d,towers:u}=s;return e.jsxs(e.Fragment,{children:[e.jsx(Rs,{societyId:t,onResolved:m}),e.jsx(ze,{title:d.name,sub:d.address,right:e.jsx(y,{variant:"gold",icon:e.jsx(ae,{size:15}),onClick:()=>o(!0),children:"Add tower"})}),e.jsx(As,{societyId:t}),u.length===0?e.jsx("div",{className:T,children:e.jsx(Q,{icon:e.jsx(de,{size:26}),title:"No towers yet",sub:"Add your first tower or block, then add its units and residents.",cta:"Add tower",onCta:()=>o(!0)})}):e.jsx("div",{className:"grid grid-cols-1 gap-3.5 min-[620px]:grid-cols-2 xl:grid-cols-3",children:u.map(g=>e.jsxs("button",{onClick:()=>
126c(g),className:T+" group flex flex-col overflow-hidden text-left transition hover:-translate-y-0.5 hover:shadow-[0_18px_40px_-20px_rgba(15,37,71,0.45)]",children:[e.jsxs("div",{className:"flex items-center gap-3 border-b border-[#eef1f7] px-4 py-3.5",children:[e.jsx("span",{className:"grid h-10 w-10 place-items-center rounded-xl bg-gradient-to-br from-[#153568] to-[#1c4b93] text-white",children:e.jsx(de,{size:20})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[15px] font-extrabold text-[#0f2547]",children:g.name}),e.jsxs("div",{className:"text-[11.5px] text-[#8493b4]",children:[g.floors," floors"]})]})]}),e.jsxs("div",{className:"flex items-center justify-between px-4 py-3",children:[e.jsx(ot,{n:`${g.occupancy}%`,l:"Occupied"}),e.jsx(ot,{n:`${g.occupied}/${g.unitCount}`,l:"Units"}),e.jsx(ot,{n:B(g.monthlyRoll),l:"Monthly"})]})]},g.id))}),e.jsx(ml,{open:x,societyId:t,onClose:()=>o(!1),onDone:()=>{o(!1),m()}})]})}function Rs({societyId:t,onResolved:s}){const[n,i]=a.useState(null),[r,l]=a.useState(null),[c,x]=a.useState(null),o=()=>{na(t).then(i).catch(()=>i([]))};if(a.useEffect(()=>{o()},[t]),!n||n.length===0)return null;const m=async d=>{l(d);try{await us(t,d,"reject"),o(),s&&s()}finally{l(null)}};return e.jsxs("div",{className:T+" mb-4 overflow-hidden border-[#f0dfb0]",children:[e.jsxs("div",{className:"flex items-center gap-2 border-b border-[#f3e7c6] bg-gradient-to-br from-[#fdf7e8] to-[#fbefd9] px-4 py-3",children:[e.jsx(qe,{size:15,className:"text-[#c98a00]"}),e.jsx("h3",{className:"text-[13.5px] font-extrabold text-[#7a5600]",children:"Join requests"}),e.jsx("span",{className:"ml-auto rounded-full bg-[#c98a00] px-2 py-0.5 text-[10.5px] font-extrabold text-white",children:n.length})]}),e.jsx("div",{className:"flex flex-col",children:n.map(d=>e.jsxs("div",{className:"flex items-center gap-3 border-t border-[#f6efdd] px-4 py-3 first:border-t-0",children:[e.jsx("span",{className:"grid h-9 w-9 shrink-0 place-items-center rounded-full bg-gradient-to-br from-[#153568] to-[#1c4b93] text-[13px] font-extrabold text-white",children:(d.name||"?").slice(0,1).toUpperCase()}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate text-[13.5px] font-bold text-[#0f2547]",children:d.name||"Resident"}),e.jsxs("div",{className:"mt-0.5 text-[11.5px] text-[#8493b4]",children:[d.phone||"—"," · wants to join"]})]}),e.jsx("button",{onClick:()=>x(d),disabled:r===d._id,className:"inline-flex h-8 shrink-0 items-center gap-1 rounded-lg bg-[#15964f] px-3 text-[11.5px] font-extrabold text-white transition hover:bg-[#0f7d40] disabled:opacity-60",children:"Approve & assign"}),e.jsx("button",{onClick:()=>m(d._id),disabled:r===d._id,className:"inline-flex h-8 shrink-0 items-center rounded-lg border border-[#f0c9c9] bg-white px-3 text-[11.5px] font-extrabold text-[#d63a3a] transition hover:bg-[#fdf1f1] disabled:opacity-60",children:"Reject"})]},d._id))}),c&&e.jsx(al,{societyId:t,request:c,onClose:()=>x(null),onDone:()=>{x(null),o(),s&&s()}})]})}function al({societyId:t,request:s,onClose:n,onDone:i}){var S;const[r,l]=a.useState(null),[c,x]=a.useState(null),[o,m]=a.useState(""),[d,u]=a.useState(""),[b,g]=a.useState(""),[v,f]=a.useState(""),[h,w]=a.useState(!1),[z,p]=a.useState("");a.useEffect(()=>{xs(t).then(l).catch(()=>l({}))},[t]);const j=((S=r==null?void 0:r.society)==null?void 0:S.type)==="pg",E=(r==null?void 0:r.rooms)||[];a.useEffect(()=>{if(!j||!b){x(null);return}x(null),f(""),St(b).then(A=>x((A==null?void 0:A.beds)||[])).catch(()=>x([]))},[j,b]);const R=(c||[]).filter(A=>!A.occupied),N=j?[["guest","Guest"],["tenant","Tenant"]]:[["owner","Owner"],["tenant","Tenant"],["family","Family"]],$=async()=>{var M,_,D;p("");const A={role:o||void 0};if(j){if(!b)return p("Pick a room.");if(!v)return p("Pick a free bed.");A.unitId=b,A.bedLabel=v}else{if(!d.trim())return p("Enter the flat / unit number.");A.code=d.trim()}w(!0);try{await us(t,s._id,"approve",A),i()}catch(H){p(((D=(_=(M=H==null?void 0:H.response)==null?void 0:M.data)==null?void 0:_.status)==null?void 0:D.message)||"Couldn't assign. Please try again."),w(!1)}};return e.jsx(q,{open:!0,onClose:n,width:440,title:`Assign ${s.name||"resident"}`,footer:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(y,{variant:"ghost",onClick:n,children:"Cancel"}),e.jsx(y,{variant:"navy",onClick:$,disabled:h||!r,children:h?"Assigning…":"Approve & assign"})]}),children:r?e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs("div",{className:"rounded-xl bg-[#f7f9fd] px-3 py-2 text-[12.5px] text-[#586887]",children:[e.jsx("b",{className:"text-[#0f2547]",children:s.name||"Resident"}),s.phone?` · ${s.phone}`:""]}),j?e.jsxs(e.Fragment,{children:[e.jsx(C,{label:"Room",children:e.jsxs("select",{className:k,value:b,onChange:A=>g(A.target.value),children:[e.jsx("option",{value:"",children:"Select a room…"}),E.map(A=>e.jsx("option",{value:A._id,children:A.code},A._id))]})}),e.jsx(C,{label:"Bed",children:e.jsxs("select",{className:k,value:v,onCh
126ange:A=>f(A.target.value),disabled:!b||c===null,children:[e.jsx("option",{value:"",children:b?c===null?"Loading beds…":R.length?"Select a free bed…":"No free beds in this room":"Pick a room first"}),R.map(A=>e.jsxs("option",{value:A.label,children:["Bed ",A.label]},A.label))]})})]}):e.jsx(C,{label:"Flat / unit number",children:e.jsx("input",{className:k,value:d,onChange:A=>u(A.target.value),placeholder:"e.g. A-402",autoFocus:!0})}),e.jsxs("div",{children:[e.jsx("span",{className:"mb-1 block text-[11px] font-bold uppercase tracking-[0.08em] text-[#8493b4]",children:"Role"}),e.jsx("div",{className:"flex gap-2",children:N.map(([A,M])=>e.jsx("button",{type:"button",onClick:()=>m(A),className:"h-9 flex-1 rounded-lg border text-[12.5px] font-bold transition "+(o===A?"border-[#1c4b93] bg-[#eef3fb] text-[#1c4b93]":"border-[#d6deec] bg-white text-[#586887] hover:bg-[#f2f5fc]"),children:M},A))})]}),z&&e.jsx("p",{className:"text-[12.5px] font-semibold text-[#d63a3a]",children:z})]}):e.jsxs("div",{className:"flex items-center justify-center gap-2 py-8 text-[12.5px] text-[#586887]",children:[e.jsx(ne,{size:15,className:"animate-spin text-[#1c4b93]"})," Loading directory…"]})})}function ot({n:t,l:s}){return e.jsxs("div",{children:[e.jsx("div",{className:"text-[15px] font-extrabold tabular-nums text-[#153568]",children:t}),e.jsx("div",{className:"text-[9.5px] font-bold uppercase tracking-[0.08em] text-[#8493b4]",children:s})]})}function nl({societyId:t,tower:s,onBack:n}){const[i,r]=a.useState(null),[l,c]=a.useState(!1),[x,o]=a.useState(null),m=()=>{la(t,s.id).then(r).catch(()=>r([]))};return a.useEffect(m,[t,s.id]),e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:n,className:"mb-3 inline-flex items-center gap-1.5 rounded-lg border border-[#d6deec] bg-white px-3 py-1.5 text-[12.5px] font-extrabold text-[#153568] shadow-sm transition hover:bg-[#eef1f7]",children:[e.jsx(Et,{size:15})," All towers"]}),e.jsx(ze,{title:s.name,sub:`${s.floors} floors · ${s.unitCount} units`,right:e.jsx(y,{variant:"gold",icon:e.jsx(ae,{size:15}),onClick:()=>c(!0),children:"Add unit"})}),i?i.length===0?e.jsx("div",{className:T,children:e.jsx(Q,{icon:e.jsx(Pe,{size:26}),title:"No units in this tower yet",sub:"Add units, then add owners and tenants to each.",cta:"Add unit",onCta:()=>c(!0)})}):e.jsxs(e.Fragment,{children:[e.jsx(ll,{units:i}),e.jsx("div",{className:T+" overflow-hidden",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full min-w-[640px] border-collapse text-[13px]",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-[#f7f9fd] text-left text-[10px] uppercase tracking-[0.1em] text-[#8493b4]",children:[e.jsx(je,{children:"Unit"}),e.jsx(je,{children:"Floor"}),e.jsx(je,{children:"Area"}),e.jsx(je,{children:"Type"}),e.jsx(je,{children:"Status"}),e.jsx(je,{right:!0,children:"Maintenance"}),e.jsx(je,{})]})}),e.jsx("tbody",{children:i.map(d=>{const u=Je[d.status]||Je.vacant;return e.jsxs("tr",{onClick:()=>o(d),className:"cursor-pointer border-t border-[#eef1f7] transition hover:bg-[#f7f9fd]",children:[e.jsx("td",{className:"px-3.5 py-3 font-bold text-[#0f2547]",children:d.code}),e.jsx("td",{className:"px-3.5 py-3 text-[#586887]",children:d.floor||"—"}),e.jsx("td",{className:"px-3.5 py-3 text-[#586887]",children:d.area?`${d.area} sq ft`:"—"}),e.jsx("td",{className:"px-3.5 py-3 text-[#586887]",children:d.bhk||"—"}),e.jsx("td",{className:"px-3.5 py-3",children:e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsx(F,{tone:u.tone,children:u.label}),d.status!=="vacant"&&e.jsx(F,{tone:Ps[d.duesStatus]||"slate",children:d.duesStatus}),d.listed&&e.jsx(F,{tone:"gold",children:"Listed"}),d.source==="resident-linked"&&!d.verified&&e.jsx(F,{tone:"amber",dot:!0,children:"Pending"})]})}),e.jsx("td",{className:"px-3.5 py-3 text-right font-bold tabular-nums text-[#0f2547]",children:B(d.maintenance)}),e.jsx("td",{className:"px-3.5 py-3 text-right",children:e.jsx("span",{className:"rounded-lg border border-[#d6deec] bg-white px-2.5 py-1.5 text-[11.5px] font-extrabold text-[#1c4b93]",children:"Manage"})})]},d._id)})})]})})})]}):e.jsx("div",{className:T+" h-[220px] animate-pulse"}),e.jsx(ul,{open:l,societyId:t,towerId:s.id,onClose:()=>c(!1),onDone:()=>{c(!1),m()}}),e.jsx(Ts,{unit:x,societyId:t,onClose:()=>o(null),onChanged:()=>{m()}})]})}function je({children:t,right:s}){return e.jsx("th",{className:"border-b border-[#e6eaf3] px-3.5 py-2.5 font-bold "+(s?"text-right":""),children:t})}function ll({units:t}){const s=t.filter(c=>c.status!=="vacant"),n=s.reduce((c,x)=>c+(x.maintenance||0),0),i=s.filter(c=>c.duesStatus!=="paid"),r=s.filter(c=>c.verified).length,l=t.length?Math.round(s.length/t.length*100):0;return e.jsxs("div",{className:"mb-4 grid grid-cols-2 gap-3.5 lg:grid-cols-4",children:[e.jsx(G,{icon:e.jsx(Pe,{size:15}),k:"Occupancy",v:`${l}%`,bar:l,barColor:"#1c4b93",sub:`${s.length} of ${t.length} occupied`}),e.jsx(G,{icon:e.jsx(me,{size:15}),k:"Monthly roll",v:B(n),accent:"#c98a00",sub:`${s.length} billable unit${s.length===1?"":"s"}`}),e.jsx(G,{icon:e.jsx(xe,{size:15}),k:"Dues",v:i.length?`${i.length}`:"0",vColor:i.length?"#c77812":"#15964f",dot:i.length?"#c77812":"#15964f",sub:i.length?"units pending":"all settled",accent:"#c77812"}),e.jsx(G,{icon:e.jsx(ce,{size:15}),k:"Verified",v:`${s.length?Math.round(r/s.length*100):0}%`,bar:s.length?Math.round(r/s.length*100):0,barColor:"#15964f",accent:"#15964f",sub:`${r} of ${s.length} occupied`})]})}const il={open:"amber","in-progress":"navy",resolved:"green",closed:"slate"};function Ts({unit:t,societyId:s,onClose:n,onChanged:i}
126){var H,V,J,L,Z,P,O,K,W;const[r,l]=a.useState(!1),[c,x]=a.useState(null),[o,m]=a.useState(!1),[d,u]=a.useState(!1),[b,g]=a.useState(!1),[v,f]=a.useState(null),[h,w]=a.useState(!1),[z,p]=a.useState(!1),[j,E]=a.useState(!1),R=()=>{t!=null&&t._id&&St(t._id).then(x).catch(()=>x({...t,residents:t.residents||[],invoices:[],tickets:[],finance:{}}))};if(a.useEffect(()=>{x(null),R()},[t==null?void 0:t._id]),!t)return null;const N=c,$=Je[(N||t).status]||Je.vacant,S=(N==null?void 0:N.residents)||[],A=async()=>{m(!0);try{await ia(t._id,!(N!=null&&N.verified)),R(),i&&i()}finally{m(!1)}},M=async()=>{m(!0);try{await ps(t._id),i&&i(),n()}finally{m(!1)}},_=async U=>{const le=s||(N==null?void 0:N.societyId);if(le){u(!0);try{const ee=await ra(le,t._id);ee!=null&&ee.propertyId&&(window.open(`/properties/listings?list=${ee.propertyId}&for=${U}`,"_blank","noopener"),R(),i&&i())}finally{u(!1)}}},D=async()=>{const U=s||(N==null?void 0:N.societyId);if(U){u(!0);try{await ca(U,t._id),R(),i&&i()}finally{u(!1)}}};return e.jsxs(st,{open:!!t,onClose:n,width:520,storageKey:"unit",title:t.code,subtitle:[N!=null&&N.towerName?`Tower ${N.towerName}`:null,t.bhk,t.area?`${t.area} sq ft`:null,t.floor?`Floor ${t.floor}`:null].filter(Boolean).join(" · "),footer:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(y,{variant:"outline",size:"sm",icon:e.jsx(Ct,{size:14}),onClick:()=>g(!0),children:"Edit"}),e.jsx(y,{variant:"danger",size:"sm",icon:e.jsx(be,{size:14}),onClick:()=>E(!0),children:"Delete"}),e.jsx(y,{variant:"outline",size:"sm",icon:e.jsx(ce,{size:14}),onClick:A,disabled:o,children:N!=null&&N.verified?"Unverify":"Verify"}),e.jsx(y,{variant:"gold",size:"sm",icon:e.jsx(qe,{size:14}),onClick:()=>l(!0),style:{flex:1},children:"Add resident"})]}),children:[e.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-1.5",children:[e.jsx(F,{tone:$.tone,children:$.label}),(N||t).status!=="vacant"&&e.jsx(F,{tone:Ps[(N||t).duesStatus]||"slate",children:(N||t).duesStatus}),(N||t).verified?e.jsx(F,{tone:"green",dot:!0,children:"Verified"}):e.jsx(F,{tone:"amber",dot:!0,children:(N||t).source==="resident-linked"?"Pending approval":"Unverified"}),(N||t).source==="resident-linked"&&e.jsx(F,{tone:"navy",children:"Owner-added"}),(N||t).listed&&e.jsxs(F,{tone:"gold",children:["Listed · ",(N||t).listedFor||"sale"]})]}),N?e.jsxs("div",{className:"flex flex-col gap-3",children:[(N.status==="vacant"||S.length===0)&&!N.listed&&e.jsxs("div",{className:"flex items-start gap-2.5 rounded-xl border border-[#f0dfb0] bg-gradient-to-br from-[#fdf7e8] to-[#fbefd9] px-3.5 py-3",children:[e.jsx("span",{className:"mt-0.5 grid h-8 w-8 shrink-0 place-items-center rounded-lg bg-[#c98a00] text-white",children:e.jsx(Ne,{size:15})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-[12.5px] font-extrabold text-[#7a5600]",children:"Vacant — list it on the marketplace"}),e.jsx("p",{className:"mt-0.5 text-[11.5px] leading-relaxed text-[#8a6a1f]",children:"We'll link this flat to a property and open the Listings flow to add the full details."}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[e.jsxs("button",{onClick:()=>_("sell"),disabled:d,className:"inline-flex h-7 items-center gap-1.5 rounded-lg bg-[#c98a00] px-2.5 text-[11px] font-extrabold text-white transition hover:bg-[#b07a00] disabled:opacity-60",children:[e.jsx(Ne,{size:12})," ",d?"Linking…":"List for sale"]}),e.jsxs("button",{onClick:()=>_("rent"),disabled:d,className:"inline-flex h-7 items-center gap-1.5 rounded-lg border border-[#d9be7a] bg-white px-2.5 text-[11px] font-extrabold text-[#8a6a1f] transition hover:bg-[#fdf7e8] disabled:opacity-60",children:[e.jsx(Ne,{size:12})," List for rent"]}),e.jsxs("button",{onClick:()=>l(!0),className:"inline-flex h-7 items-center gap-1.5 rounded-lg px-2 text-[11px] font-bold text-[#8a6a1f] transition hover:bg-[#fdf7e8]",children:[e.jsx(qe,{size:12})," Add owner"]})]})]})]}),N.propertyId&&!N.listed&&N.status!=="vacant"&&S.length>0&&e.jsxs("div",{className:"flex items-center gap-2 rounded-xl border border-[#e6eaf3] bg-[#f7f9fd] px-3.5 py-2.5",children:[e.jsx(Ne,{size:14,className:"shrink-0 text-[#c98a00]"}),e.jsx("span",{className:"flex-1 text-[11.5px] text-[#586887]",children:"This flat has a linked property — put it on the marketplace."}),e.jsx("button",{onClick:()=>_("sell"),disabled:d,className:"inline-flex h-7 shrink-0 items-center gap-1.5 rounded-lg bg-gradient-to-br from-[#e8a100] to-[#c98a00] px-2.5 text-[11px] font-extrabold text-[#231700] disabled:opacity-60",children:d?"…":"List"})]}),N.listed&&e.jsxs("div",{className:"rounded-xl border border-[#cfe6d6] bg-gradient-to-br from-[#f0faf3] to-[#e6f6ec] px-3.5 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"grid h-7 w-7 shrink-0 place-items-center rounded-lg bg-[#15964f] text-white",children:e.jsx(Ne,{size:14})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"text-[12.5px] font-extrabold text-[#0f6b39]",children:["Listed on JaaGa · ",N.listedFor==="rent"?"for rent":"for sale",(H=N.property)!=null&&H.price?` · ${B(N.property.price)}`:""]}),e.jsx("div",{className:"text-[11px] text-[#3f8a5c]",children:"Live on the marketplace"})]})]}),e.jsxs("div",{className:"mt-2.5 flex flex-wrap items-center gap-2",children:[e.jsxs("a",{href:"/properties/listings",target:"_blank",rel:"noopener noreferrer",className:"inline-flex h-7 items-center gap-1.5 rounded-lg border border-[#c1ddc9] bg-white px-2.5 text-[11px] font-extrabold text-[#0f6b39] hover:bg-[#f0faf3]",children:[e.jsx(ys,{size:12})," Manage on Listings"]}),e.jsx("button",{onClick:D,disabled:d,className:"inline-flex h-7 items-center gap-1.5 rounded-lg border border-[#f0c9c9] bg-white px-2.5 text-[11px] font-extrabold text-[#d63a3a] transition hover:bg-[#fdf1f1] disabled:opacity-60",children:d?"…":"Unlist"})]})]}),e.jsxs("div",{className:"rounded-xl border border-[#e6eaf3] bg-[#f7f9fd] px-3.5 py-3",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-[12px] font-extrabold text-[#153568]",children:[e.jsx(Ae,{size:13,className:"text-[#1c4b93]"})," Request payment"]}),e.jsxs("div",{className:"mt-2 flex flex-wrap gap-2",children:[e.jsx(y,{size:"sm",variant:"navy",onClick:()=>f("maintenance"),children:"Maintenance"}),e.jsx(y,{size:"sm",variant:"outline",onClick:()=>f("rent"),children:"Rent"}),e.jsx(y,{size:"sm",variant:"outline",onClick:()=>f("deposit"),children:"Deposit"}),e.jsx(y,{size:"sm",variant:"outline",onClick:()=>
126f("other"),children:"Other charge"})]}),e.jsx("p",{className:"mt-2 text-[11px] text-[#8493b4]",children:"Raises a due invoice on this flat — the resident pays it from their portal."})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2.5",children:[e.jsx(Be,{icon:e.jsx(me,{size:14}),label:"Maintenance",value:B((V=N.finance)==null?void 0:V.maintenance),sub:"/mo"}),e.jsx(Be,{icon:e.jsx(xe,{size:14}),label:"Dues",value:B((J=N.finance)==null?void 0:J.duesOutstanding),tone:(L=N.finance)!=null&&L.duesOutstanding?"#c77812":"#15964f"}),e.jsx(Be,{icon:e.jsx(he,{size:14}),label:"Open tickets",value:((Z=N.finance)==null?void 0:Z.openTickets)??0,tone:(P=N.finance)!=null&&P.openTickets?"#d63a3a":"#15964f"})]}),((O=N.finance)==null?void 0:O.depositHeld)>0&&e.jsxs("div",{className:"flex items-center justify-between rounded-xl border border-[#f0d9a6] bg-[#fdf7e9] px-3.5 py-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] font-bold uppercase tracking-[0.1em] text-[#a06a12]",children:"Deposit held"}),e.jsx("div",{className:"text-[16px] font-extrabold text-[#0f2547] tabular-nums",children:B(N.finance.depositHeld)})]}),e.jsx(y,{size:"sm",variant:"outline",onClick:()=>p(!0),children:"Settle / refund"})]}),e.jsx(_e,{icon:e.jsx(Ue,{size:14}),title:"Residents",children:S.length===0?e.jsx("div",{className:"py-3 text-center text-[12.5px] text-[#586887]",children:"No residents yet — add the owner to activate this unit."}):e.jsx("div",{className:"flex flex-col",children:S.map(U=>e.jsxs("div",{className:"flex items-center gap-3 border-t border-[#eef1f7] py-2.5 first:border-t-0",children:[e.jsx("span",{className:"grid h-9 w-9 shrink-0 place-items-center rounded-full bg-gradient-to-br from-[#153568] to-[#1c4b93] text-[13px] font-extrabold text-white",children:(U.name||"?").slice(0,1).toUpperCase()}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate text-[13.5px] font-bold text-[#0f2547]",children:U.name}),e.jsxs("div",{className:"text-[11.5px] text-[#5b6b8a]",children:[U.phone||"—",U.status==="moved_out"?" · moved out":""]})]}),e.jsx(F,{tone:U.role==="owner"?"navy":U.role==="tenant"?"gold":"slate",children:U.role}),e.jsx(ol,{r:U,onDone:()=>{R(),i&&i()}}),U.verified&&e.jsx(ce,{size:15,className:"text-[#15964f]"})]},U._id||U.name))})}),e.jsxs(_e,{icon:e.jsx(xe,{size:14}),title:"Recent invoices",children:[!N.invoices||N.invoices.length===0?e.jsx("div",{className:"py-3 text-center text-[12.5px] text-[#586887]",children:"No invoices yet — run billing to generate them."}):e.jsx("div",{className:"flex flex-col",children:N.invoices.map(U=>e.jsxs("div",{className:"flex items-center gap-3 border-t border-[#eef1f7] py-2.5 first:border-t-0",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"text-[13px] font-bold text-[#0f2547]",children:[ms(U.kind)," ",e.jsxs("span",{className:"font-semibold text-[#8493b4]",children:["· ",U.period]})]}),U.arrears?e.jsxs("div",{className:"text-[11px] text-[#c77812]",children:["incl. ",B(U.arrears)," arrears"]}):null]}),e.jsx("div",{className:"text-[13px] font-extrabold tabular-nums text-[#0f2547]",children:B(U.total)}),e.jsx(F,{tone:U.status==="paid"?"green":U.status==="partial"?"amber":U.status==="overdue"?"red":"slate",children:U.status})]},U._id))}),e.jsx("button",{onClick:()=>w(!0),className:"mt-2 w-full rounded-lg border border-[#d6deec] bg-white py-2 text-[12.5px] font-extrabold text-[#153568] transition hover:bg-[#f2f5fc]",children:"View full payment history"})]}),e.jsx(_e,{icon:e.jsx(he,{size:14}),title:"Helpdesk tickets",children:!N.tickets||N.tickets.length===0?e.jsx("div",{className:"py-3 text-center text-[12.5px] text-[#586887]",children:"No tickets raised for this unit."}):e.jsx("div",{className:"flex flex-col",children:N.tickets.map(U=>e.jsxs("div",{className:"flex items-center gap-3 border-t border-[#eef1f7] py-2.5 first:border-t-0",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate text-[13px] font-bold text-[#0f2547]",children:U.title}),e.jsxs("div",{className:"text-[11px] text-[#8493b4]",children:[U.category," · ",se(U.createdAt)]})]}),e.jsx(F,{tone:U.priority==="high"?"red":U.priority==="medium"?"amber":"slate",children:U.priority}),e.jsx(F,{tone:il[U.status]||"slate",children:U.status})]},U._id))})}),e.jsx(un,{societyId:N.societyId,unit:{_id:t._id,code:t.code},mode:"committee"})]}):e.jsxs("div",{className:"flex items-center justify-center gap-2 py-16 text-[13px] font-semibold text-[#586887]",children:[e.jsx(ne,{size:16,className:"animate-spin text-[#1c4b93]"})," Loading unit…"]}),e.jsx(pl,{open:r,unitId:t._id,onClose:()=>l(!1),onDone:()=>{l(!1),R(),i&&i()}}),e.jsx(cl,{open:b,unit:N||t,onClose:()=>g(!1),onDone:()=>{g(!1),R(),i&&i()}}),e.jsx(xl,{open:!!v,kind:v,unit:N||t,onClose:()=>f(null),onDone:()=>{f(null),R(),i&&i()}}),e.jsx(Bs,{open:h,unitId:(N||t)._id,title:`${(N||t).code||"Unit"} · payment history`,onClose:()=>w(!1)}),e.jsx(dl,{open:z,unit:N||t,held:((K=N==null?void 0:N.finance)==null?void 0:K.depositHeld)||0,dues:((W=N==null?void 0:N.finance)==null?void 0:W.duesOutstanding)||0,onClose:()=>p(!1),onDone:()=>{p(!1),R(),i&&i()}}),e.jsx(q,{open:j,onClose:()=>E(!1),title:"Delete unit",footer:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(y,{variant:"ghost",onClick:()=>E(!1),children:"Cancel"}),e.jsx(y,{variant:"danger",onClick:M,disabled:o,children:o?"Deleting…":"Delete unit"})]}),children:e.jsxs("p",{className:"text-[13px] leading-relaxed text-[#586887]",children:["Delete ",e.jsx("b",{className:"text-[#0f2547]",children:t.code}),"? This permanently removes the unit and its residents, invoices and bookings. This can't be und
126one."]})})]})}function rl({bed:t,unitId:s,busy:n,onClose:i,onConfirm:r}){const l=Number((t==null?void 0:t.depositHeld)||0),[c,x]=a.useState(""),[o,m]=a.useState(""),[d,u]=a.useState(null),[b,g]=a.useState(null),[v,f]=a.useState("");if(a.useEffect(()=>{t&&(m(""),u(null),g(null),f(""),x(l>0?String(l):""),t.membershipId&&s&&zt(s,t.membershipId).then(z=>{var j;const p=(z==null?void 0:z.summary)||{};if(u(p.notice||null),l>0){const E=Math.max(0,l-(p.outstanding||0)-(((j=p.notice)==null?void 0:j.suggested)||0));x(String(E))}}).catch(()=>{}))},[t]),!t)return null;const h=l>0?Math.max(0,Math.min(Math.round(Number(c)||0),l)):0,w=l>0?Math.max(0,l-h):0;return e.jsxs(q,{open:!!t,onClose:i,title:`Check out ${t.name||"guest"}`,footer:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(y,{variant:"ghost",onClick:i,children:"Cancel"}),e.jsx(y,{variant:"danger",disabled:n,onClick:()=>r({depositRefund:l>0?h:void 0,depositReason:o.trim()||void 0,moveOutReason:b||void 0,moveOutNote:v.trim()||void 0}),children:n?"Checking out…":"Check out"})]}),children:[e.jsxs("p",{className:"text-[13px] leading-relaxed text-[#586887]",children:["Frees bed ",e.jsx("b",{className:"text-[#0f2547]",children:t.label}),"."]}),l>0?e.jsxs("div",{className:"mt-3 flex flex-col gap-3",children:[e.jsxs("div",{className:"flex items-center justify-between rounded-xl bg-[#eef3fb] px-3.5 py-2.5",children:[e.jsx("span",{className:"text-[11px] font-bold uppercase tracking-[0.08em] text-[#8493b4]",children:"Deposit held"}),e.jsx("span",{className:"text-[15px] font-extrabold text-[#0f2547]",children:B(l)})]}),d&&d.suggested>0&&e.jsxs("div",{className:"rounded-lg bg-[#fbefd9] px-3 py-2 text-[11.5px] font-semibold text-[#a06a12]",children:[d.served?`Left ${d.shortfallDays} day(s) short of notice`:"No notice was given"," — suggested"," ",B(d.suggested)," deduction. Adjust the refund as you see fit."]}),e.jsx(C,{label:"Refund to guest (₹)",children:e.jsx("input",{className:k,value:c,onChange:z=>x(z.target.value),inputMode:"numeric"})}),e.jsxs("div",{className:"flex items-center justify-between text-[12.5px] font-bold",children:[e.jsxs("span",{className:"text-[#15964f]",children:["Refunding ",B(h)]}),w>0&&e.jsxs("span",{className:"text-[#c98a00]",children:["Keeping ",B(w)]})]}),w>0&&e.jsx(C,{label:"Reason for deduction",children:e.jsx("input",{className:k,value:o,onChange:z=>m(z.target.value),placeholder:"e.g. damages, unpaid dues"})})]}):e.jsx("p",{className:"mt-2 text-[12.5px] text-[#8493b4]",children:"No deposit on file for this guest."}),e.jsxs("div",{className:"mt-4",children:[e.jsx("div",{className:"mb-1.5 text-[11px] font-bold uppercase tracking-[0.08em] text-[#8493b4]",children:"Why are they leaving?"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:oa.map(z=>e.jsx("button",{type:"button",onClick:()=>g(b===z?null:z),className:"rounded-full border px-3 py-1.5 text-[12px] font-bold transition "+(b===z?"border-[#153568] bg-[#153568] text-white":"border-[#e6eaf3] bg-white text-[#7c8ca8] hover:bg-[#f7f9fd]"),children:Pt(z)},z))}),e.jsx("textarea",{className:k+" mt-2 h-16 resize-none",value:v,onChange:z=>f(z.target.value),placeholder:"Note (optional) — anything worth remembering"})]})]})}function cl({open:t,unit:s,onClose:n,onDone:i}){const[r,l]=a.useState({}),[c,x]=a.useState(!1),[o,m]=a.useState("");a.useEffect(()=>{t&&s&&(l({code:s.code||"",floor:s.floor??"",area:s.area??"",bhk:s.bhk||"2 BHK",maintenance:s.maintenance??"",rentAmount:s.rentAmount??""}),m(""),x(!1))},[t,s]);const d=b=>g=>l(v=>({...v,[b]:g.target.value})),u=async()=>{var b,g,v;if(!String(r.code).trim())return m("Unit number is required.");x(!0);try{await hs(s._id,{code:r.code,floor:Number(r.floor)||0,area:Number(r.area)||0,bhk:r.bhk,maintenance:Number(r.maintenance)||0,rentAmount:Number(r.rentAmount)||0}),i()}catch(f){m(((v=(g=(b=f==null?void 0:f.response)==null?void 0:b.data)==null?void 0:g.status)==null?void 0:v.message)||"Couldn't update the unit. Try again."),x(!1)}};return e.jsxs(q,{open:t,onClose:n,title:"Edit unit",footer:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(y,{variant:"ghost",onClick:n,children:"Cancel"}
126),e.jsx(y,{variant:"navy",onClick:u,disabled:c,children:c?"Saving…":"Save"})]}),children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(C,{label:"Unit number",children:e.jsx("input",{className:k,value:r.code||"",onChange:d("code"),autoFocus:!0})}),e.jsx(C,{label:"Floor",children:e.jsx("input",{className:k,type:"number",value:r.floor??"",onChange:d("floor")})}),e.jsx(C,{label:"Area (sq ft)",children:e.jsx("input",{className:k,type:"number",value:r.area??"",onChange:d("area")})}),e.jsx(C,{label:"Type",children:e.jsx("select",{className:k,value:r.bhk||"2 BHK",onChange:d("bhk"),children:["1 BHK","2 BHK","3 BHK","4 BHK","Studio","Penthouse"].map(b=>e.jsx("option",{children:b},b))})}),e.jsx(C,{label:"Maintenance (₹/mo)",children:e.jsx("input",{className:k,type:"number",value:r.maintenance??"",onChange:d("maintenance")})}),e.jsx(C,{label:"Rent (₹/mo)",children:e.jsx("input",{className:k,type:"number",value:r.rentAmount??"",onChange:d("rentAmount")})})]}),o&&e.jsx("p",{className:"mt-3 text-[12.5px] font-semibold text-[#d63a3a]",children:o})]})}function Es(t,s){const[n,i]=a.useState({payoutActive:!1,upiEnabled:!1,loaded:!1});return a.useEffect(()=>{if(!s||!t)return;let r=!0;return Promise.all([At(t).catch(()=>null),Rt(t).catch(()=>null)]).then(([l,c])=>{r&&i({payoutActive:(l==null?void 0:l.status)==="active",upiEnabled:!!(c!=null&&c.enabled),loaded:!0})}),()=>{r=!1}},[t,s]),n}function Ms({payoutActive:t,upiEnabled:s,value:n,onChange:i}){if(!(t&&s))return null;const r=[{v:"online",label:"Online (Cashfree)"},{v:"upi",label:"UPI / QR"}];return e.jsxs("div",{children:[e.jsx("span",{className:"mb-1 block text-[11px] font-bold uppercase tracking-[0.08em] text-[#8493b4]",children:"Collect via"}),e.jsx("div",{className:"flex gap-2",children:r.map(l=>e.jsx("button",{type:"button",onClick:()=>i(l.v),className:"flex-1 rounded-lg border px-2 py-2 text-[12.5px] font-bold transition "+(n===l.v?"border-[#1c4b93] bg-[#eef3fb] text-[#153568]":"border-[#e6eaf3] bg-white text-[#7c8ca8] hover:bg-[#f7f9fd]"),children:l.label},l.v))})]})}function Bs({open:t,unitId:s,membershipId:n,title:i,onClose:r}){const[l,c]=a.useState(null),[x,o]=a.useState(!1);return a.useEffect(()=>{!t||!s||(c(null),o(!1),zt(s,n).then(c).catch(()=>o(!0)))},[t,s,n]),e.jsx(q,{open:t,onClose:r,title:i||"Payment history",width:540,children:x?e.jsx("p",{className:"py-6 text-center text-[13px] text-[#d63a3a]",children:"Couldn't load history."}):l?e.jsxs("div",{className:"flex flex-col gap-3",children:[l.resident&&e.jsxs("div",{className:"flex flex-wrap items-center gap-x-1.5 gap-y-1 text-[13px] text-[#586887]",children:[e.jsx("span",{className:"font-extrabold text-[#0f2547]",children:l.resident.name||"Resident"}),l.resident.bedLabel?e.jsxs("span",{children:["· Bed ",l.resident.bedLabel]}):null,l.resident.phone?e.jsxs("span",{children:["· ",l.resident.phone]}):null,l.resident.phoneVerified&&e.jsx(ce,{size:13,className:"text-[#15964f]"}),l.resident.profession&&e.jsx("span",{className:"rounded-full bg-[#eef1f6] px-2 py-0.5 text-[10.5px] font-bold text-[#5b6b8a]",children:tt(l.resident.profession)})]}),l.resident&&(l.resident.moveOutReason||l.resident.moveOutNote)&&e.jsxs("div",{className:"rounded-lg bg-[#fbefd9] px-3 py-2 text-[12px] text-[#a06a12]",children:[e.jsx("span",{className:"font-extrabold",children:l.resident.moveOutReason?`Left — ${Pt(l.resident.moveOutReason)}`:"Left"}),l.resident.moveOutNote?e.jsx("div",{className:"mt-0.5",children:l.resident.moveOutNote}):null]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsx(dt,{label:"Deposit held",value:B(l.summary.depositHeld),tone:"#c98a00"}),e.jsx(dt,{label:"Rent/maint paid",value:B(l.summary.rentPaid),tone:"#15964f"}),e.jsx(dt,{label:"Outstanding",value:B(l.summary.outstanding),tone:l.summary.outstanding?"#d63a3a":"#15964f"})]}),l.deposits.length>0&&e.jsxs("div",{children:[e.jsx("div",{className:"mb-1 text-[11px] font-bold uppercase tracking-[0.1em] text-[#8697b8]",children:"Deposit"}),l.deposits.map(m=>e.jsx(Wt,{row:m},m._id))]}),e.jsxs("div",{children:[e.jsx("div",{className:"mb-1 text-[11px] font-bold uppercase tracking-[0.1em] text-[#8697b8]",children:"Rent & maintenance"}),l.bills.length===0?e.jsx("p",{className:"text-[12.5px] text-[#8493b4]",children:"No bills yet."}):l.bills.map(m=>e.jsx(Wt,{row:m},m._id))]})]}):e.jsx("p",{className:"py-6 text-center text-[13px] text-[#8493b4]",children:"Loading…"})})}function ol({r:t,onDone:s}
126){var z;const[n,i]=a.useState(!1),[r,l]=a.useState(!1),[c,x]=a.useState(null),[o,m]=a.useState(""),d=!!(t.idProof&&t.idProof.key),u=((z=t.idProof)==null?void 0:z.status)||"approved",b=!!(t.kycRequested&&t.kycRequested.at),g=async()=>{try{const p=await $t(t._id);p!=null&&p.url&&window.open(p.url,"_blank","noopener")}catch{}},v=async()=>{l(!0),m(""),x(null);try{const p=await $t(t._id);x((p==null?void 0:p.url)||null)}catch{}},f=async p=>{i(!0);try{await va(t._id,p,p==="reject"?o.trim():void 0),l(!1),s()}finally{i(!1)}},h=async()=>{i(!0);try{await da(t._id),s()}finally{i(!1)}};if(!t._id)return null;const w=e.jsx(q,{open:r,onClose:()=>l(!1),title:"Review KYC",width:460,children:e.jsxs("div",{className:"flex flex-col gap-3",children:[c?e.jsx("img",{src:c,alt:"ID document",className:"max-h-[300px] w-full rounded-lg object-contain"}):e.jsx("p",{className:"py-6 text-center text-[12.5px] text-[#8493b4]",children:"Loading document…"}),e.jsx(C,{label:"Reason (if rejecting)",children:e.jsx("input",{className:k,value:o,onChange:p=>m(p.target.value),placeholder:"e.g. blurry, wrong document"})}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(y,{variant:"danger",onClick:()=>f("reject"),disabled:n,children:"Reject"}),e.jsx(y,{variant:"navy",onClick:()=>f("approve"),disabled:n,children:"Approve"})]})]})});return d&&u==="pending"?e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:v,className:"shrink-0 rounded-md border border-[#f0dfb0] bg-[#fdf6e6] px-2 py-1 text-[11px] font-bold text-[#c77812]",children:"Review KYC"}),w]}):d&&u==="rejected"?e.jsx("button",{onClick:g,className:"shrink-0 text-[11px] font-bold text-[#d63a3a] underline",children:"KYC ✗"}):d?e.jsx("button",{onClick:g,className:"shrink-0 text-[11px] font-bold text-[#15964f] underline",children:"KYC ✓"}):b?e.jsx("span",{className:"shrink-0 text-[11px] font-bold text-[#c77812]",children:"KYC asked"}):e.jsx("button",{onClick:h,disabled:n,className:"shrink-0 rounded-md border border-[#d6deec] bg-white px-2 py-1 text-[11px] font-bold text-[#1c4b93] hover:bg-[#f2f5fc] disabled:opacity-60",children:"Request KYC"})}function dt({label:t,value:s,tone:n}){return e.jsxs("div",{className:"rounded-xl bg-[#f7f9fd] px-3 py-2",children:[e.jsx("div",{className:"text-[10px] font-bold uppercase tracking-[0.1em] text-[#8697b8]",children:t}),e.jsx("div",{className:"text-[15px] font-extrabold tabular-nums",style:{color:n},children:s})]})}function Wt({row:t}){const s=t.status==="paid",n=t.status==="refunded",i=s?"green":n?"slate":t.status==="overdue"?"red":"amber",r=s?"Paid":n?"Refunded":t.status==="overdue"?"Overdue":t.proofStatus==="pending"?"Under review":"Due";return e.jsxs("div",{className:"flex items-center justify-between border-t border-[#eef1f7] py-2 first:border-t-0",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"text-[13px] font-bold text-[#0f2547]",children:[ms(t.kind)," ",e.jsxs("span",{className:"font-semibold text-[#8493b4]",children:["· ",t.period]})]}),e.jsxs("div",{className:"text-[11px] text-[#8493b4]",children:[s&&t.paidAt?`Paid ${se(t.paidAt)}${t.channel?` · ${t.channel}`:""}`:t.dueDate?`Due ${se(t.dueDate)}`:"",t.receiptNo?` · ${t.receiptNo}`:""]})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[e.jsx("span",{className:"text-[13px] font-extrabold tabular-nums text-[#0f2547]",children:B(t.total)}),e.jsx(F,{tone:i,children:r})]})]})}function dl({open:t,unit:s,held:n,dues:i,onClose:r,onDone:l}){const[c,x]=a.useState(""),[o,m]=a.useState(""),[d,u]=a.useState(!1),[b,g]=a.useState(""),[v,f]=a.useState(null);a.useEffect(()=>{t&&(m(""),g(""),u(!1),f(null),zt(s._id).then(p=>{var R;const j=((R=p==null?void 0:p.summary)==null?void 0:R.notice)||null;f(j);const E=Math.max(0,n-(i||0)-((j==null?void 0:j.suggested)||0));x(String(E))}).catch(()=>x(String(n||""))))},[t,n,i,s._id]);const h=Math.max(0,Math.min(Number(c)||0,n)),w=n-h,z=async()=>{var p,j,E;u(!0);try{await xa(s._id,{depositRefund:h,depositReason:o.trim()||void 0}),l()}catch(R){g(((E=(j=(p=R==null?void 0:R.response)==null?void 0:p.data)==null?void 0:j.status)==null?void 0:E.message)||"Couldn't settle the deposit. Try again."),u(!1)}};return e.jsx(q,{open:t,onClose:r,title:"Settle security deposit",footer:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(y,{variant:"ghost",onClick:r,children:"Cancel"}),e.jsx(y,{variant:"navy",onClick:z,disabled:d,children:d?"Settling…":`Refund ${B(h)}`})]}),children:e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs("div",{className:"flex items-center justify-between rounded-xl bg-[#f4f7fc] px-4 py-3",children:[e.jsx("span",{className:"text-[11px] font-bold uppercase tracking-[0.1em] text-[#8697b8]",children:"Deposit held"}),e.jsx("span",{className:"text-[18px] font-extrabold text-[#0f2547] tabular-nums",children:B(n)})]}),i>0&&e.jsxs("div",{className:"rounded-lg bg-[#fbefd9] px-3 py-2 text-[11.5px] font-semibold text-[#a06a12]",children:["This resident has ",B(i)," in unpaid dues — you may want to retain that. Any open bills are closed out on settlement."]}),v&&v.suggested>0&&e.jsxs("div",{className:"rounded-lg bg-[#fbefd9] px-3 py-2 text-[11.5px] font-semibold text-[#a06a12]",children:[v.served?`Left ${v.shortfallDays} day(s) short of notice`:"No notice was given"," — suggested"," ",B(v.suggested)," deduction. Your call."]}),e.jsx(C,{label:"Refund to resident",hint:"The rest is retained (dues / damage). Open bills are written off.",children:e.jsx("input",{className:k,type:"number",value:c,onChange:p=>x(p.target.value),autoFocus:!0})}),e.jsx(C,{label:"Reason (optional)",children:e.jsx("input",{className:k,value:o,onChange:p=>m(p.target.value),placeholder:"e.g. ₹2,000 damages · ₹1,000 dues"})}),e.jsxs("div",{className:"flex items-center justify-between text-[13px] text-[#586887]",children:[e.jsx("span",{children:"Retained"}),e.jsx("span",{className:"font-extrabold text-[#0f2547] tabular-nums",children:B(w)})]}),b&&e.jsx("p",{className:"text-[12.5px] font-semibold text-[#d63a3a]",children:b})]})})}
126function xl({open:t,kind:s,unit:n,onClose:i,onDone:r}){const[l,c]=a.useState(""),[x,o]=a.useState(""),[m,d]=a.useState(!1),[u,b]=a.useState(""),g=Es(n==null?void 0:n.societyId,t),[v,f]=a.useState(null);a.useEffect(()=>{t&&(c(s==="maintenance"?(n==null?void 0:n.maintenance)||"":s==="rent"?(n==null?void 0:n.rentAmount)||"":s==="deposit"&&(n==null?void 0:n.deposit)||""),o(""),b(""),d(!1))},[t,s,n]),a.useEffect(()=>{g.loaded&&f(g.payoutActive&&g.upiEnabled?"online":null)},[g.loaded,g.payoutActive,g.upiEnabled]);const h=s==="maintenance"?"Request maintenance":s==="rent"?"Request rent":s==="deposit"?"Collect security deposit":"Other charge",w=async()=>{var z,p,j;if(!Number(l))return b("Please enter a valid amount.");if(s==="other"&&!x.trim())return b("Add a short description for this charge.");d(!0);try{await ma(n._id,{kind:s,amount:Number(l),description:x.trim()||void 0,collectVia:v||void 0}),r()}catch(E){b(((j=(p=(z=E==null?void 0:E.response)==null?void 0:z.data)==null?void 0:p.status)==null?void 0:j.message)||"Couldn't raise the charge. Try again."),d(!1)}};return e.jsx(q,{open:t,onClose:i,title:h,footer:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(y,{variant:"ghost",onClick:i,children:"Cancel"}),e.jsx(y,{variant:"navy",onClick:w,disabled:m,children:m?"Raising…":"Raise charge"})]}),children:e.jsxs("div",{className:"flex flex-col gap-3",children:[s==="other"&&e.jsx(C,{label:"Description",children:e.jsx("input",{className:k,value:x,onChange:z=>o(z.target.value),placeholder:"e.g. Clubhouse damage fine",autoFocus:!0})}),e.jsx(C,{label:"Amount (₹)",children:e.jsx("input",{className:k,type:"number",value:l,onChange:z=>c(z.target.value),autoFocus:s!=="other"})}),e.jsx(Ms,{payoutActive:g.payoutActive,upiEnabled:g.upiEnabled,value:v,onChange:f}),e.jsxs("p",{className:"text-[11.5px] text-[#8493b4]",children:["Creates a due invoice for ",n==null?void 0:n.code," for this month. The resident pays it by the method you choose (online or UPI), or you can record an offline payment in Billing."]}),u&&e.jsx("p",{className:"text-[12.5px] font-semibold text-[#d63a3a]",children:u})]})})}function Be({icon:t,label:s,value:n,sub:i,tone:r="#0f2547"}){return e.jsxs("div",{className:"rounded-xl border border-[#e6eaf3] bg-white p-3",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-[#8697b8]",children:[e.jsx("span",{style:{color:r},children:t}),e.jsx("span",{className:"text-[9.5px] font-bold uppercase tracking-[0.1em]",children:s})]}),e.jsxs("div",{className:"mt-1.5 text-[16px] font-extrabold leading-none tabular-nums",style:{color:r},children:[n,i&&e.jsxs("span",{className:"text-[10px] font-bold text-[#a7b3cd]",children:[" ",i]})]})]})}function _e({icon:t,title:s,children:n}){return e.jsxs("div",{className:"rounded-xl border border-[#e6eaf3] bg-white p-3.5",children:[e.jsxs("div",{className:"mb-1 flex items-center gap-1.5 text-[#1c4b93]",children:[t,e.jsx("span",{className:"text-[10px] font-bold uppercase tracking-[0.12em] text-[#8493b4]",children:s})]}),n]})}function Ie(t,s){const[n,i]=a.useState(t),[r,l]=a.useState(!1),[c,x]=a.useState(""),o=a.useRef(t);return a.useEffect(()=>{s&&(i(o.current),l(!1),x(""))},[s]),{v:n,set:d=>u=>i(b=>({...b,[d]:u.target.value})),busy:r,setBusy:l,error:c,setError:x}}function ml({open:t,societyId:s,onClose:n,onDone:i}){const r=Ie({name:"",floors:""},t),l=async()=>{if(!r.v.name.trim())return r.setError("Tower name is required.");r.setBusy(!0);try{await ua(s,{name:r.v.name.trim(),floors:Number(r.v.floors)||0}),i()}catch{r.setError("Couldn't add the tower. Try again."),r.setBusy(!1)}};return e.jsx(q,{open:t,onClose:n,title:"Add tower",footer:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(y,{variant:"ghost",onClick:n,children:"Cancel"}),e.jsx(y,{variant:"navy",onClick:l,disabled:r.busy,children:r.busy?"Adding…":"Add tower"})]}),children:e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(C,{label:"Tower / block name",children:e.jsx("input",{className:k,placeholder:"e.g. Tower A",value:r.v.name,onChange:r.set("name"),autoFocus:!0})}),e.jsx(C,{label:"Floors",children:e.jsx("input",{className:k,type:"number",min:"0",placeholder:"12",value:r.v.floors,onChange:r.set("floors")})}),r.error&&e.jsx("p",{className:"text-[12.5px] font-semibold text-[#d63a3a]",children:r.error})]})})}function ul({open:t,societyId:s,towerId:n,onClose:i,onDone:r}){const l=Ie({code:"",floor:"",area:"",bhk:"2 BHK",maintenance:"",rentAmount:"",deposit:""},t),c=async()=>{var x,o,m;if(!l.v.code.trim())return l.setError("Unit number is required.");l.setBusy(!0);try{await fs(s,{towerId:n,code:l.v.code.trim(),floor:Number(l.v.floor)||0,area:Number(l.v.area)||0,bhk:l.v.bhk,...l.v.maintenance!==""?{maintenance:Number(l.v.maintenance)||
1260}:{},...l.v.rentAmount!==""?{rentAmount:Number(l.v.rentAmount)||0}:{},...l.v.deposit!==""?{deposit:Number(l.v.deposit)||0}:{}}),r()}catch(d){l.setError(((m=(o=(x=d==null?void 0:d.response)==null?void 0:x.data)==null?void 0:o.status)==null?void 0:m.message)||"Couldn't add the unit. Try again."),l.setBusy(!1)}};return e.jsxs(q,{open:t,onClose:i,title:"Add unit",footer:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(y,{variant:"ghost",onClick:i,children:"Cancel"}),e.jsx(y,{variant:"navy",onClick:c,disabled:l.busy,children:l.busy?"Adding…":"Add unit"})]}),children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(C,{label:"Unit number",children:e.jsx("input",{className:k,placeholder:"A-402",value:l.v.code,onChange:l.set("code"),autoFocus:!0})}),e.jsx(C,{label:"Floor",children:e.jsx("input",{className:k,type:"number",placeholder:"4",value:l.v.floor,onChange:l.set("floor")})}),e.jsx(C,{label:"Area (sq ft)",children:e.jsx("input",{className:k,type:"number",placeholder:"1460",value:l.v.area,onChange:l.set("area")})}),e.jsx(C,{label:"Type",children:e.jsx("select",{className:k,value:l.v.bhk,onChange:l.set("bhk"),children:["1 BHK","2 BHK","3 BHK","4 BHK","Studio","Penthouse"].map(x=>e.jsx("option",{children:x},x))})}),e.jsx(C,{label:"Maintenance (₹/mo)",hint:"Flat monthly amount for this unit",children:e.jsx("input",{className:k,type:"number",placeholder:"e.g. 2000",value:l.v.maintenance,onChange:l.set("maintenance")})}),e.jsx(C,{label:"Rent (₹/mo)",hint:"For a tenant-occupied flat",children:e.jsx("input",{className:k,type:"number",placeholder:"e.g. 18000",value:l.v.rentAmount,onChange:l.set("rentAmount")})}),e.jsx(C,{label:"Deposit (₹)",hint:"Refundable security deposit",children:e.jsx("input",{className:k,type:"number",placeholder:"e.g. 50000",value:l.v.deposit,onChange:l.set("deposit")})})]}),l.error&&e.jsx("p",{className:"mt-3 text-[12.5px] font-semibold text-[#d63a3a]",children:l.error})]})}function pl({open:t,unitId:s,onClose:n,onDone:i}){const r=Ie({role:"owner",name:"",phone:""},t),l=async()=>{if(!r.v.name.trim())return r.setError("Name is required.");r.setBusy(!0);try{const c=await pa(s,{role:r.v.role,name:r.v.name.trim(),phone:r.v.phone.trim()});i(c)}catch{r.setError("Couldn't add the resident. Try again."),r.setBusy(!1)}};return e.jsx(q,{open:t,onClose:n,title:"Add resident",footer:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(y,{variant:"ghost",onClick:n,children:"Cancel"}),e.jsx(y,{variant:"navy",onClick:l,disabled:r.busy,children:r.busy?"Adding…":"Add resident"})]}),children:e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(C,{label:"Role",children:e.jsxs("select",{className:k,value:r.v.role,onChange:r.set("role"),children:[e.jsx("option",{value:"owner",children:"Owner"}),e.jsx("option",{value:"tenant",children:"Tenant"}),e.jsx("option",{value:"family",children:"Family member"})]})}),e.jsx(C,{label:"Full name",children:e.jsx("input",{className:k,placeholder:"e.g. Ramesh Kumar",value:r.v.name,onChange:r.set("name"),autoFocus:!0})}),e.jsx(C,{label:"Phone",hint:"They'll be invited to the resident app by SMS.",children:e.jsx("input",{className:k,placeholder:"+91 90000 00000",value:r.v.phone,onChange:r.set("phone")})}),r.error&&e.jsx("p",{className:"text-[12.5px] font-semibold text-[#d63a3a]",children:r.error})]})})}const Mt=[{v:1,label:"Single"},{v:2,label:"Double"},{v:3,label:"Triple"},{v:4,label:"4-sharing"},{v:5,label:"5-sharing"},{v:6,label:"6-sharing"}],_s=[{v:"furnished",label:"Furnished"},{v:"semi",label:"Semi-furnished"},{v:"unfurnished",label:"Unfurnished"}],Ds=[{v:"window",label:"Window"},{v:"balcony",label:"Balcony"},{v:"none",label:"No window"}];function hl(t){const s=Mt.find(n=>n.v===Number(t.sharing));return[s?s.label:`${t.sharing}-sharing`,t.ac?"AC":"Non-AC",t.attachedBath?"Attached bath":"Common bath"].filter(Boolean).join(" · ")}function fl({societyId:t,society:s,rooms:n,reload:i}){const[r,l]=a.useState(!1),[c,x]=a.useState(null),o=s.pg||{},m={male:"Men's PG",female:"Women's PG",coed:"Co-Living PG"}[o.gender]||"PG / Hostel";return e.jsxs(e.Fragment,{children:[e.jsx(Rs,{societyId:t,onResolved:i}
126),e.jsx(ze,{title:s.name,sub:[m,s.address].filter(Boolean).join(" · "),right:e.jsx(y,{variant:"gold",icon:e.jsx(ae,{size:15}),onClick:()=>l(!0),children:"Add room"})}),n.length===0?e.jsx("div",{className:T,children:e.jsx(Q,{icon:e.jsx(at,{size:26}),title:"No rooms yet",sub:"Add your first room, set its sharing and rent per bed, then move guests in.",cta:"Add room",onCta:()=>l(!0)})}):e.jsxs(e.Fragment,{children:[e.jsx(bl,{rooms:n}),e.jsx(gl,{rooms:n,onOpen:x})]}),e.jsx(Ls,{open:r,societyId:t,onClose:()=>l(!1),onDone:()=>{l(!1),i()}}),e.jsx(vl,{room:c,onClose:()=>x(null),onChanged:i})]})}function bl({rooms:t}){const s=t.reduce((c,x)=>c+(x.total||0),0),n=t.reduce((c,x)=>c+(x.filled||0),0),i=Math.max(0,s-n),r=t.reduce((c,x)=>c+(x.filled||0)*(x.rentPerBed||0),0),l=s?Math.round(n/s*100):0;return e.jsxs("div",{className:"mb-4 grid grid-cols-2 gap-3.5 lg:grid-cols-5",children:[e.jsx(G,{icon:e.jsx(at,{size:15}),k:"Rooms",v:t.length,accent:"#1c4b93"}),e.jsx(G,{icon:e.jsx(fe,{size:15}),k:"Beds",v:s,accent:"#153568",sub:`${l}% occupied`}),e.jsx(G,{icon:e.jsx(Ue,{size:15}),k:"Occupied",v:n,bar:l,barColor:"#15964f",accent:"#15964f",vColor:"#15964f"}),e.jsx(G,{icon:e.jsx(fe,{size:15}),k:"Vacant",v:i,vColor:i?"#c77812":"#15964f",dot:i?"#c77812":"#15964f",sub:i?"beds open":"fully occupied",accent:"#c77812"}),e.jsx(G,{icon:e.jsx(me,{size:15}),k:"Monthly roll",v:B(r),accent:"#c98a00",sub:"occupied beds"})]})}function gl({rooms:t,onOpen:s}){const n=new Map;for(const r of t){const l=r.floor!=null&&r.floor!==""?Number(r.floor):0;n.has(l)||n.set(l,[]),n.get(l).push(r)}const i=[...n.keys()].sort((r,l)=>l-r);return e.jsxs("div",{className:"overflow-hidden rounded-2xl border border-[#0a1730] bg-gradient-to-b from-[#16305a] to-[#0d1f39] shadow-[0_34px_80px_-34px_rgba(11,27,51,0.75)]",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 px-5 pt-3.5 pb-2.5",children:[e.jsx("span",{className:"font-mono text-[10.5px] uppercase tracking-[0.18em] text-[#8ba0c4]",children:"Occupancy at a glance"}),e.jsxs("span",{className:"flex items-center gap-3.5 font-mono text-[10.5px] text-[#9db0ce]",children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"h-2.5 w-2.5 rounded-[3px] bg-[#c7d3e8]"})," occupied"]}),e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"h-2.5 w-2.5 rounded-[3px] border border-[#39568a] bg-[#0c1b33]"})," vacant"]})]})]}),e.jsx("div",{className:"flex flex-col",children:i.map(r=>e.jsxs("div",{className:"flex items-stretch gap-3 border-t px-3.5 py-3",style:{borderColor:"rgba(80,120,180,0.22)"},children:[e.jsx("div",{className:"flex w-8 shrink-0 items-start justify-center pt-1",children:e.jsx("span",{className:"rounded-md border border-[#39568a] bg-[#0f2547] px-1.5 py-1 font-mono text-[10.5px] font-bold text-[#9db0ce]",children:r===0?"G":r})}),e.jsx("div",{className:"flex flex-wrap gap-2.5",children:n.get(r).slice().sort((l,c)=>String(l.code).localeCompare(String(c.code))).map(l=>e.jsx(jl,{room:l,onOpen:()=>s(l)},l._id))})]},r))}),e.jsx("div",{className:"h-3 bg-gradient-to-b from-[#0a1730] to-[#08111f]"})]})}function jl({room:t,onOpen:s}){const n=t.beds&&t.beds.length?t.beds:Array.from({length:t.total||Number(t.sharing)||1},(c,x)=>({label:String.fromCharCode(65+x),occupied:!1})),i=n.filter(c=>c.occupied).length,r=n.length,l=r>0&&i>=r;return e.jsxs("button",{onClick:s,title:`${t.code} · ${i}/${r} beds · ${B(t.rentPerBed)}/bed`,className:"group flex w-[118px] flex-col gap-2 rounded-lg border border-[#2c4a7a] bg-[#0f2547]/70 p-2.5 text-left transition hover:-translate-y-0.5 hover:border-[#5f7fb3] hover:bg-[#173257]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-1",children:[e.jsx("span",{className:"truncate font-mono text-[12.5px] font-bold text-white",children:t.code}),e.jsxs("span",{className:"shrink-0 font-mono text-[10px] font-bold "+(l?"text-white":i===0?"text-[#6b7ea0]":"text-[#c7d3e8]"),children:[i,"/",r]})]}),e.jsx("div",{className:"flex flex-wrap gap-1",children:n.map((c,x)=>e.jsx("span",{className:"h-[18px] w-[18px] rounded-[3px] transition "+(c.occupied?"bg-[#c7d3e8]":"border border-[#39568a] bg-[#0b1a30] group-hover:border-[#4a6ba0]")},c.label||x))}),e.jsxs("div",{className:"font-mono text-[10px] text-[#9db0ce] tabular-nums",children:[B(t.rentPerBed),e.jsx("span",{className:"text-[#5f7290]",children:"/bed"})]})]})}function Te({icon:t,children:s,on:n=!0}){return e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-lg border px-2.5 py-1 text-[11.5px] font-bold "+(n?"border-[#d6e0f0] bg-[#eef3fb] text-[#1c4b93]":"border-[#e6eaf3] bg-[#f7f9fd] text-[#8493b4]"),
126children:[t,s]})}function vl({room:t,onClose:s,onChanged:n}){var H,V,J;const[i,r]=a.useState(null),[l,c]=a.useState(!1),[x,o]=a.useState(!1),[m,d]=a.useState(null),[u,b]=a.useState(null),[g,v]=a.useState(!1),[f,h]=a.useState(null),[w,z]=a.useState(null),[p,j]=a.useState([]),E=()=>{t!=null&&t._id&&(St(t._id).then(r).catch(()=>r(t)),ha(t._id).then(j).catch(()=>j([])))};if(a.useEffect(()=>{r(null),E()},[t==null?void 0:t._id]),!t)return null;const R=i||t,N=R.beds||[],$=N.filter(L=>L.occupied).length,S=N.length||Number(R.sharing)||0,A=async(L,Z={})=>{b(L);try{await fa(t._id,L,Z),E(),n&&n()}finally{b(null)}},M=async()=>{v(!0);try{await ps(t._id),n&&n(),s()}finally{v(!1)}},_=(H=Ds.find(L=>L.v===R.ventilation))==null?void 0:H.label,D=(V=_s.find(L=>L.v===R.furnishing))==null?void 0:V.label;return e.jsxs(st,{open:!!t,onClose:s,width:540,minWidth:500,storageKey:"room",title:t.code,subtitle:[R.floor?`Floor ${R.floor}`:null,hl(R),`${B(R.rentPerBed)}/bed`].filter(Boolean).join(" · "),footer:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(y,{variant:"outline",size:"sm",icon:e.jsx(Ct,{size:14}),onClick:()=>c(!0),children:"Edit room"}),e.jsx(y,{variant:"danger",size:"sm",icon:e.jsx(be,{size:14}),onClick:()=>o(!0),children:"Delete"}),e.jsxs("div",{className:"ml-auto flex items-center gap-1.5 text-[12.5px] font-extrabold text-[#153568]",children:[e.jsx(fe,{size:14,className:"text-[#1c4b93]"})," ",$,"/",S," beds filled"]})]}),children:[e.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-1.5",children:[e.jsx(Te,{icon:e.jsx(Ue,{size:12}),children:((J=Mt.find(L=>L.v===Number(R.sharing)))==null?void 0:J.label)||`${R.sharing}-sharing`}),e.jsx(Te,{icon:e.jsx(Qn,{size:12}),on:!!R.ac,children:R.ac?"AC":"Non-AC"}),e.jsx(Te,{icon:e.jsx(vn,{size:12}),on:!!R.attachedBath,children:R.attachedBath?"Attached bath":"Common bath"}),_&&e.jsx(Te,{icon:e.jsx(tl,{size:12}),children:_}),D&&e.jsx(Te,{icon:e.jsx(Pe,{size:12}),children:D})]}),e.jsxs("div",{className:"mb-3 grid grid-cols-2 gap-2.5",children:[e.jsx(Be,{icon:e.jsx(me,{size:14}),label:"Rent / bed",value:B(R.rentPerBed),sub:"/mo"}),e.jsx(Be,{icon:e.jsx(xe,{size:14}),label:"Deposit",value:B(R.deposit)})]}),e.jsx(_e,{icon:e.jsx(fe,{size:14}),title:`Beds · ${$}/${S} occupied`,children:i?N.length===0?e.jsx("div",{className:"py-3 text-center text-[12.5px] text-[#586887]",children:"No beds configured for this room."}):e.jsx("div",{className:"grid grid-cols-1 gap-2.5 min-[420px]:grid-cols-2",children:N.map(L=>e.jsx(yl,{bed:L,busy:u===L.label,onAdd:()=>d(L.label),onCheckout:()=>h(L),onHistory:()=>z(L)},L.label))}):e.jsxs("div",{className:"flex items-center justify-center gap-2 py-8 text-[12.5px] font-semibold text-[#586887]",children:[e.jsx(ne,{size:15,className:"animate-spin text-[#1c4b93]"})," Loading beds…"]})}),p.length>0&&e.jsx("div",{className:"mt-3",children:e.jsx(_e,{icon:e.jsx(os,{size:14}),title:`Past residents · ${p.length}`,children:e.jsx("div",{className:"flex flex-col gap-2",children:p.map(L=>e.jsxs("button",{onClick:()=>z({label:L.bedLabel,name:L.name,membershipId:L.membershipId}),className:"flex items-center gap-3 rounded-xl border border-[#e6eaf3] bg-white p-2.5 text-left transition hover:bg-[#f6f8fc]",children:[e.jsx("span",{className:"grid h-9 w-9 shrink-0 place-items-center rounded-full bg-[#eef2f9] text-[12px] font-extrabold text-[#1c4b93]",children:(L.name||"?").slice(0,1).toUpperCase()}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5 truncate text-[13px] font-bold text-[#0f2547]",children:[e.jsx("span",{className:"truncate",children:L.name||"Guest"}),L.profession&&e.jsx("span",{className:"shrink-0 rounded-full bg-[#eef1f6] px-2 py-0.5 text-[10px] font-bold text-[#5b6b8a]",children:tt(L.profession)})]}),e.jsx("div",{className:"truncate text-[11.5px] text-[#8493b4]",children:[L.bedLabel?`Bed ${L.bedLabel}`:null,L.leftAt?`Left ${se(L.leftAt)}`:null,L.moveOutReason?Pt(L.moveOutReason):null].filter(Boolean).join(" · ")})]}),L.totalPaid>0&&e.jsxs("span",{className:"shrink-0 text-[11.5px] font-bold text-[#5b6b8a]",children:[B(L.totalPaid)," paid"]}),e.jsx(et,{size:15,className:"shrink-0 text-[#a9b6cf]"})]},L.membershipId))})})}),e.jsx(Nl,{open:!!m,societyId:t.societyId,unitId:t._id,bedLabel:m,defaultRent:R.rentPerBed,defaultDeposit:R.deposit,onClose:()=>d(null),onDone:()=>{d(null),E(),n&&n()}}),e.jsx(Ls,{open:l,room:R,onClose:()=>c(!1),onDone:()=>{c(!1),E(),n&&n()}}),e.jsx(q,{open:x,onClose:()=>o(!1),title:"Delete room",footer:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(y,{variant:"ghost",onClick:()=>o(!1),children:"Cancel"}),e.jsx(y,{variant:"danger",onClick:M,disabled:g,children:g?"Deleting…":"Delete room"})]}),children:e.jsxs("p",{className:"text-[13px] leading-relaxed text-[#586887]",children:["Delete ",e.jsx("b",{className:"text-[#0f2547]",children:t.code}),"? This removes the room, its beds and any guests on them. This can’t be undone."]})}),e.jsx(rl,{bed:f,unitId:t._id,busy:u===(f==null?void 0:f.label),onClose:()=>h(null),onConfirm:L=>A(f.label,L).then(()=>h(null))}),e.jsx(Bs,{open:!!w,unitId:t._id,membershipId:w==null?void 0:w.membershipId,title:w?`Bed ${w.label} · ${w.name||"guest"} · history`:"",onClose:()=>z(null)})]})}function yl({bed:t,busy:s,onAdd:n,onCheckout:i,onHistory:r}){return t.occupied?e.jsxs("div",{className:"rounded-xl border border-[#e6eaf3] bg-white p-3",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("span",{className:"grid h-9 w-9 shrink-0 place-items-center rounded-full bg-gradient-to-br from-[#153568] to-[#1c4b93] text-[12px] font-extrabold text-white",children:(t.name||"?").slice(0,1).toUpperCase()}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("span",{className:"text-[9.5px] font-bold uppercase tracking-[0.1em] text-[#8493b4]",children:["Bed ",t.label]}),t.stayType==="temporary"?e.jsx(F,{tone:"gold",children:"Short stay"}):e.jsx(F,{tone:"green",dot:!0,children:"Occupied"})]}),e.jsxs("div",{className:"flex items-center gap-1 truncate text-[13px] font-extrabold text-[#0f2547]",children:[e.jsx("span",{className:"truncate",children:t.name}),t.phoneVerified&&e.jsx(ce,{size:13,className:"shrink-0 text-[#15964f]"})]}),t.profession&&e.jsx("div",{className:"text-[11px] font-semibold text-[#5b6b8a]",children:tt(t.profession)}),t.stayType==="temporary"&&t.leaveDate&&e.jsxs("div",{className:"text-[11px] font-semibold text-[#c98a00]",children:["Leaves ",se(t.leaveDate)]}),t.phone&&e.jsxs("div",{className:"flex items-center gap-1 text-[11.5px] text-[#5b6b8a]",children:[e.jsx(Tt,{size:11,className:"text-[#8493b4]"})," ",t.phone]}),t.depositHeld?e.jsxs("div",{className:"text-[11px] font-semibold text-[#c98a00]",children:["Deposit held ",B(t.depositHeld)]}):null]})]}),e.jsxs("div",{className:"mt-2.5 flex gap-2",children:[e.jsxs("button",{onClick:r,className:"flex flex-1 items-center justify-center gap-1.5 rounded-lg border border-[#d6deec] bg-white py-2 text-[11.5px] font-extrabold text-[#153568] transition hover:bg-[#f2f5fc]",children:[e.jsx(xe,{size:13})," History"]}),e.jsxs("button",{onClick:i,disabled:s,className:"flex flex-1 items-center justify-center gap-1.5 rounded-lg border border-[#f0c9c9] bg-white py-2 text-[11.5px] font-extrabold text-[#d63a3a] transition hover:bg-[#fdf1f1] disabled:opacity-60",children:[e.jsx(os,{size:13})," ",s?"…":"Checkout"]})]})]}):e.jsxs("button",{onClick:n,className:"group flex flex-col items-center justify-center gap-1.5 rounded-xl border-2 border-dashed border-[#d3ddef] bg-[#f9fbfe] px-3 py-5 text-center transition hover:border-[#1c4b93] hover:bg-[#eef3fb]",children:[e.jsx("span",{className:"grid h-9 w-9 place-items-center rounded-full bg-white text-[#1c4b93] shadow-sm",children:e.jsx(qe,{size:16})}),e.jsxs("span",{className:"text-[9.5px] font-bold uppercase tracking-[0.1em] text-[#8493b4]",children:["Bed ",t.label," · vacant"]}),e.jsx("span",{className:"text-[12.5px] font-extrabold text-[#1c4b93]",children:"Add guest"})]})}function Nl({open:t,societyId:s,unitId:n,bedLabel:i,defaultRent:r,defaultDeposit:l,onClose:c,onDone:x}){const o=Ie({name:"",phone:"",rent:"",deposit:"",occupationDetail:"",emergencyName:"",emergencyPhone:""}
126,t),[m,d]=a.useState("cash"),u=Es(s,t),[b,g]=a.useState(null),[v,f]=a.useState("monthly"),[h,w]=a.useState("flat"),[z,p]=a.useState(""),[j,E]=a.useState(""),[R,N]=a.useState(null),[$,S]=a.useState(!1),[A,M]=a.useState(!1),[_,D]=a.useState(""),[H,V]=a.useState(""),[J,L]=a.useState(!1),[Z,P]=a.useState(""),O=I=>String(I||"").replace(/\D/g,"").slice(-10),K=async()=>{var I,re,pe;L(!0),P("");try{await ba(s,o.v.phone.trim()),S(!0),V("")}catch(oe){P(((pe=(re=(I=oe==null?void 0:oe.response)==null?void 0:I.data)==null?void 0:re.status)==null?void 0:pe.message)||"Couldn't send the OTP.")}finally{L(!1)}},W=async()=>{var I,re,pe;L(!0),P("");try{await ga(s,o.v.phone.trim(),H.trim()),M(!0),D(O(o.v.phone)),S(!1)}catch(oe){P(((pe=(re=(I=oe==null?void 0:oe.response)==null?void 0:I.data)==null?void 0:re.status)==null?void 0:pe.message)||"Incorrect or expired code.")}finally{L(!1)}};a.useEffect(()=>{t&&(o.set("rent")({target:{value:r?String(r):""}}),o.set("deposit")({target:{value:l?String(l):""}}),d("cash"),f("monthly"),w("flat"),p(""),E(""),N(null),S(!1),M(!1),D(""),V(""),P(""))},[t,r,l]);const U=A&&_===O(o.v.phone);a.useEffect(()=>{u.loaded&&g(u.payoutActive&&u.upiEnabled?"online":null)},[u.loaded,u.payoutActive,u.upiEnabled]);const le=Number(o.v.rent)||0,ee=Number(o.v.deposit)||0,ie=v==="temp",nt=Number(z)||0,ge=ie?h==="night"?le*nt:le:0,Re=ie?ge:le,lt=Re+ee,Qs=async()=>{var I,re,pe;if(!o.v.name.trim())return o.setError("Guest name is required.");o.setBusy(!0);try{await ja(n,i,{name:o.v.name.trim(),phone:o.v.phone.trim(),deposit:ee,collect:m!=="bill",...ie?{stayType:"temporary",stayAmount:ge,stayEnd:j||void 0}:{rent:le},...m!=="bill"?{paymentMode:m}:{collectVia:b||void 0},...R?{profession:R}:{},...o.v.occupationDetail.trim()?{occupationDetail:o.v.occupationDetail.trim()}:{},...o.v.emergencyName.trim()?{emergencyName:o.v.emergencyName.trim()}:{},...o.v.emergencyPhone.trim()?{emergencyPhone:o.v.emergencyPhone.trim()}:{}}),x()}catch(oe){o.setError(((pe=(re=(I=oe==null?void 0:oe.response)==null?void 0:I.data)==null?void 0:re.status)==null?void 0:pe.message)||"Couldn't move the guest in. Try again."),o.setBusy(!1)}},Xs=[{v:"cash",label:"Cash"},{v:"upi",label:"UPI"},{v:"bill",label:"Bill to guest"}];return e.jsx(q,{open:t,onClose:c,title:`Add guest · Bed ${i||""}`,footer:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(y,{variant:"ghost",onClick:c,children:"Cancel"}),e.jsx(y,{variant:"navy",onClick:Qs,disabled:o.busy,children:o.busy?"Adding…":m==="bill"?"Add & bill":`Add & collect ${B(lt)}`})]}),children:e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(C,{label:"Full name",children:e.jsx("input",{className:k,placeholder:"e.g. Arjun Nair",value:o.v.name,onChange:o.set("name"),autoFocus:!0})}),e.jsx(C,{label:"Phone",hint:"They'll be invited to the resident app by SMS.",children:e.jsx("input",{className:k,placeholder:"+91 90000 00000",value:o.v.phone,onChange:I=>{o.set("phone")(I),A&&M(!1)}})}),U?e.jsxs("div",{className:"flex items-center gap-1.5 text-[12.5px] font-bold text-[#15964f]",children:[e.jsx(ce,{size:14})," Number verified"]}):e.jsxs("div",{className:"flex flex-col gap-1.5",children:[$?e.jsxs("div",{className:"flex items-end gap-2",children:[e.jsx("div",{className:"flex-1",children:e.jsx("input",{className:k,placeholder:"Enter OTP sent to guest",value:H,onChange:I=>V(I.target.value),inputMode:"numeric"})}),e.jsx(y,{variant:"navy",size:"sm",onClick:W,disabled:J||!H.trim(),children:J?"…":"Confirm"}),e.jsx(y,{variant:"ghost",size:"sm",onClick:K,disabled:J,children:"Resend"})]}):e.jsxs("button",{type:"button",onClick:K,disabled:O(o.v.phone).length<10||J,className:"flex w-fit items-center gap-1.5 text-[12.5px] font-bold text-[#1c4b93] disabled:text-[#a9b6cf]",children:[e.jsx(ce,{size:14})," ",J?"Sending…":"Verify number by OTP"]}),Z&&e.jsx("span",{className:"text-[11.5px] font-semibold text-[#d63a3a]",children:Z})]}),e.jsx(C,{label:"Profession",children:e.jsx("div",{className:"flex flex-wrap gap-1.5",children:sa.map(I=>e.jsx("button",{type:"button",onClick:()=>N(R===I?null:I),className:"rounded-full border px-3 py-1.5 text-[12px] font-bold transition "+(R===I?"border-[#153568] bg-[#153568] text-white":"border-[#e6eaf3] bg-white text-[#7c8ca8] hover:bg-[#f7f9fd]"),children:tt(I)},I))})}),e.jsx(C,{label:"Company / college (optional)",children:e.jsx("input",{className:k,placeholder:"e.g. Infosys / VIT",value:o.v.occupationDetail,onChange:o.set("occupationDetail")})}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(C,{label:"Emergency name (optional)",children:e.jsx("input",{className:k,value:o.v.emergencyName,onChange:o.set("emergencyName")})}),e.jsx(C,{label:"Emergency phone (optional)",children:e.jsx("input",{className:k,value:o.v.emergencyPhone,onChange:o.set("emergencyPhone")})})]}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:[["monthly","Monthly guest"],["temp","Short stay"]].map(([I,re])=>e.jsx("button",{type:"button",onClick:()=>f(I),className:"rounded-lg border px-2 py-2 text-[12.5px] font-bold transition "+(v===I?"border-[#1c4b93] bg-[#eef3fb] text-[#153568]":"border-[#e6eaf3] bg-white text-[#7c8ca8] hover:bg-[#f7f9fd]"),children:re},I))}),ie?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex gap-2",children:[["flat","Flat total"],["night","Per night"]].map(([I,re])=>e.jsx("button",{type:"button",onClick:()=>w(I),className:"flex-1 rounded-lg border px-2 py-1.5 text-[12px] font-bold transition "+(h===I?"border-[#1c4b93] bg-[#eef3fb] text-[#153568]":"border-[#e6eaf3] bg-white text-[#7c8ca8]"),children:re},I))}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(C,{label:h==="night"?"Per night (₹)":"Stay total (₹)",children:e.jsx("input",{className:k,type:"number",value:o.v.rent,onChange:o.set("rent")})}),h==="night"?e.jsx(C,{label:"Nights",children:e.jsx("input",{className:k,type:"number",value:z,onChange:I=>p(I.target.value)})}):e.jsx(C,{label:"Leave date",children:e.jsx("input",{className:k,type:"date",value:j,onChange:I=>E(I.target.value)})})]}),h==="night"&&e.jsx(C,{label:"Leave date",children:e.jsx("input",{className:k,type:"date",value:j,onChange:I=>E(I.target.value)})}),e.jsx(C,{label:"Deposit (₹) — optional",children:e.jsx("input",{className:k,type:"number",value:o.v.deposit,onChange:o.set("deposit")})})]}):e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(C,{label:"Rent (₹/mo)",children:e.jsx("input",{className:k,type:"number",value:o.v.rent,onChange:o.set("rent")})}),e.jsx(C,{label:"Deposit (₹)",children:e.jsx("input",{className:k,type:"number",value:o.v.deposit,onChange:o.set("deposit")})})]}),e.jsxs("div",{children:[e.jsx("span",{className:"mb-1 block text-[11px] font-bold uppercase tracking-[0.08em] text-[#8493b4]",children:ie?"Stay charge + deposit":"First month + deposit"}),e.jsx("div",{className:"flex gap-2",children:Xs.map(I=>e.jsx("button",{type:"button",onClick:()=>d(I.v),className:"flex-1 rounded-lg border px-2 py-2 text-[12.5px] font-bold transition "+(m===I.v?"border-[#1c4b93] bg-[#eef3fb] text-[#153568]":"border-[#e6eaf3] bg-white text-[#7c8ca8] hover:bg-[#f7f9fd]"),children:I.label},I.v))}),e.jsx("div",{className:"mt-2 rounded-lg px-3 py-2 text-[12px] font-semibold "+(m==="bill"?"bg-[#fbf1df] text-[#7a5600]":"bg-[#e4f6ec] text-[#0c6b39]"),children:m==="bill"?`${B(lt)} billed — guest pays from their app (${ie?"stay":"rent"} ${B(Re)} + deposit ${B(ee)}).`:`Collecting ${B(lt)} now — ${ie?"stay":"rent"} ${B(Re)} + deposit ${B(ee)}.`}),m==="bill"&&e.jsx("div",{className:"mt-2",children:e.jsx(Ms,{payoutActive:u.payoutActive,upiEnabled:u.upiEnabled,value:b,onChange:g})})]}),o.error&&e.jsx("p",{className:"text-[12.5px] font-semibold text-[#d63a3a]",children:o.error})]})})}function xt({on:t,onClick:s,children:n}){return e.jsx("button",{type:"button",onClick:s,className:"h-9 rounded-lg border px-3 text-[12.5px] font-bold transition "+(t?"border-[#1c4b93] bg-[#eef3fb] text-[#1c4b93]":"border-[#d6deec] bg-white text-[#586887] hover:bg-[#f2f5fc]"),children:n})}function Ls({open:t,societyId:s,room:n,onClose:i,onDone:r}){const l=!!n,c=Ie({code:"",floor:"",sharing:2,ac:!1,attachedBath:!1,ventilation:"window",furnishing:"semi",rentPerBed:"",deposit:""},t);a.useEffect(()=>{t&&n&&["code","floor","sharing","ac","attachedBath","ventilation","furnishing","rentPerBed","deposit"].forEach(m=>c.set(m)({target:{value:n[m]??c.v[m]}}))},[t,n==null?void 0:n._id]);const x=(m,d)=>c.set(m)({target:{value:d}}),o=async()=>{var d,u,b;if(!String(c.v.code).trim())return c.setError("Room number is required.");
126if(!Number(c.v.rentPerBed))return c.setError("Enter the rent per bed.");c.setBusy(!0);const m={code:String(c.v.code).trim(),floor:Number(c.v.floor)||0,sharing:Number(c.v.sharing)||1,ac:!!c.v.ac,attachedBath:!!c.v.attachedBath,ventilation:c.v.ventilation,furnishing:c.v.furnishing,rentPerBed:Number(c.v.rentPerBed)||0,deposit:Number(c.v.deposit)||0};try{l?await hs(n._id,m):await fs(s,m),r()}catch(g){c.setError(((b=(u=(d=g==null?void 0:g.response)==null?void 0:d.data)==null?void 0:u.status)==null?void 0:b.message)||"Couldn't save the room. Try again."),c.setBusy(!1)}};return e.jsx(q,{open:t,onClose:i,width:480,title:l?"Edit room":"Add room",footer:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(y,{variant:"ghost",onClick:i,children:"Cancel"}),e.jsx(y,{variant:"navy",onClick:o,disabled:c.busy,children:c.busy?"Saving…":l?"Save room":"Add room"})]}),children:e.jsxs("div",{className:"flex flex-col gap-3.5",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(C,{label:"Room number",children:e.jsx("input",{className:k,placeholder:"e.g. 201",value:c.v.code,onChange:c.set("code"),autoFocus:!0})}),e.jsx(C,{label:"Floor",children:e.jsx("input",{className:k,type:"number",placeholder:"2",value:c.v.floor,onChange:c.set("floor")})})]}),e.jsx(C,{label:"Sharing (beds)",children:e.jsx("div",{className:"flex flex-wrap gap-2",children:Mt.map(m=>e.jsx(xt,{on:Number(c.v.sharing)===m.v,onClick:()=>x("sharing",m.v),children:m.v},m.v))})}),e.jsxs("div",{children:[e.jsx("span",{className:"mb-1.5 block text-[11px] font-bold uppercase tracking-[0.08em] text-[#8493b4]",children:"Amenities"}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(xt,{on:c.v.ac,onClick:()=>x("ac",!c.v.ac),children:"❄ AC"}),e.jsx(xt,{on:c.v.attachedBath,onClick:()=>x("attachedBath",!c.v.attachedBath),children:"Attached bath"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(C,{label:"Ventilation",children:e.jsx("select",{className:k,value:c.v.ventilation,onChange:c.set("ventilation"),children:Ds.map(m=>e.jsx("option",{value:m.v,children:m.label},m.v))})}),e.jsx(C,{label:"Furnishing",children:e.jsx("select",{className:k,value:c.v.furnishing,onChange:c.set("furnishing"),children:_s.map(m=>e.jsx("option",{value:m.v,children:m.label},m.v))})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(C,{label:"Rent / bed (₹/mo)",children:e.jsx("input",{className:k,type:"number",placeholder:"8000",value:c.v.rentPerBed,onChange:c.set("rentPerBed")})}),e.jsx(C,{label:"Deposit (₹)",children:e.jsx("input",{className:k,type:"number",placeholder:"16000",value:c.v.deposit,onChange:c.set("deposit")})})]}),c.error&&e.jsx("p",{className:"text-[12.5px] font-semibold text-[#d63a3a]",children:c.error})]})})}function kl(){return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mb-4 h-8 w-56 animate-pulse rounded-lg bg-[#e9ecf2]"}),e.jsx("div",{className:"grid grid-cols-1 gap-3.5 min-[620px]:grid-cols-2 xl:grid-cols-3",children:[0,1,2].map(t=>e.jsx("div",{className:T+" h-[132px] animate-pulse"},t))})]})}const Yt={proof:e.jsx(xe,{size:15}),penalty:e.jsx(te,{size:15}),sla:e.jsx(he,{size:15}),verify:e.jsx(ce,{size:15}),poll:e.jsx(Cn,{size:15})},qt={proof:{bg:"#e4f6ec",fg:"#15964f"},penalty:{bg:"#fbe8e8",fg:"#d63a3a"},sla:{bg:"#fbefd9",fg:"#c77812"},verify:{bg:"#eef4fd",fg:"#1c4b93"},poll:{bg:"#fdf3dd",fg:"#c98a00"}},Cl=t=>{if(!t)return"";const[s,n]=t.split("-").map(Number);return new Date(s,n-1,1).toLocaleDateString("en-IN",{month:"long",year:"numeric"})},$s=t=>{if(!t)return"";const[s,n]=t.split("-").map(Number);return new Date(s,n-1,1).toLocaleDateString("en-IN",{month:"short"})};function wl({societyId:t}){const[s,n]=a.useState(null);return a.useEffect(()=>{let i=!0;return Na(t).then(r=>i&&n(r)).catch(()=>i&&n([])),()=>i=!1},[t]),!s||s.length===0?null:e.jsxs("div",{className:T+" mb-4 overflow-hidden",style:{borderColor:"#f0d9a6"},children:[e.jsx(X,{icon:e.jsx(at,{size:15}),title:"Leaving soon",children:e.jsxs("span",{className:"rounded-md bg-[#fbefd9] px-2 py-0.5 text-[11px] font-bold text-[#c77812]",children:[s.length," on notice"]})}),e.jsx("div",{className:"flex flex-col",children:s.map(i=>e.jsxs("div",{className:"flex items-center gap-3 border-t border-[#eef1f7] px-4 py-2.5 first:border-t-0",children:[e.jsx("span",{className:"grid h-9 w-9 shrink-0 place-items-center rounded-full bg-[#153568] text-[12px] font-extrabold text-white",children:(i.name||"?").charAt(0).toUpperCase()}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate text-[13px] font-bold text-[#0f2547]",children:i.name||"Resident"}),e.jsxs("div",{className:"truncate text-[11.5px] text-[#8493b4]",children:[i.bedLabel?`Room ${i.unitCode} · Bed ${i.bedLabel}`:i.unitCode,i.depositHeld?` · ${B(i.depositHeld)} deposit held`:""]})]}),e.jsxs("div",{className:"shrink-0 text-right",children:[e.jsxs("div",{className:"text-[12.5px] font-extrabold text-[#c98a00] tabular-nums",children:["Leaves ",se(i.leaveDate)]}),i.shortfallDays>0&&e.jsxs("div",{className:"text-[10.5px] font-semibold text-[#d63a3a]",children:[i.shortfallDays,"d short of notice"]})]})]},i.membershipId))})]})}function Sl({societyId:t,onNavigate:s}){var d;const[n,i]=a.useState(null),[r,l]=a.useState(!1);if(a.useEffect(()=>{let u=!0;return i(null),l(!1),ya(t).then(b=>u&&i(b)).catch(()=>u&&l(!0)),()=>u=!1},[t]),r)return e.jsx("div",{className:T,children:e.jsx(Q,{icon:e.jsx(te,{size:26}),title:"Couldn't load the dashboard",sub:"Check your connection and try again."})});if(!n)return e.jsx(Al,{});const c=n.kpis,x=((d=n.society)==null?void 0:d.type)==="pg",o=n.needsAttention||[],m=u=>s&&s(u);return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:T+" relative mb-5 overflow-hidden",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-5 px-5 py-4 sm:px-6 sm:py-5",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-3.5",children:[e.jsx("span",{className:"grid h-12 w-12 shrink-0 place-items-center rounded-2xl bg-gradient-to-br from-[#153568] to-[#1c4b93] text-white shadow-[0_10px_22px_-10px_rgba(21,53,104,0.7)]",children:e.jsx(de,{size:22})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h1",{className:"truncate text-[20px] font-extrabold leading-none tracking-[-0.02em] text-[#0f2547] sm:text-[22px]",children:n.society.name}),e.jsx("span",{className:"hidden rounded-full bg-[#fdf3dd] px-2 py-0.5 text-[10px] font-bold uppercase tracking-[0.1em] text-[#c98a00] sm:inline",children:n.society.plan||"Community"})]}),n.society.address&&e.jsx("p",{className:"mt-1 truncate text-[12.5px] text-[#8493b4]",children:n.society.address}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsx(y,{size:"sm",variant:"gold",icon:e.jsx(xe,{size:14}),onClick:()=>m("billing"),children:"Collect dues"}),e.jsx(y,{size:"sm",variant:"outline",icon:e.jsx(De,{size:14}),onClick:()=>m("communication"),children:"Post a notice"})]})]})]}),e.jsxs("div",{className:"flex items-center gap-3.5 rounded-xl bg-[#f7f9fd] px-4 py-3",children:[e.jsx(zl,{pct:c.collectionPct}),e.jsxs("div",{children:[e.jsxs("div",{className:"text-[10px] font-bold uppercase tracking-[0.12em] text-[#8697b8]",children:["Collected · ",$s(n.period)]}),e.jsx("div",{className:"mt-0.5 text-[16px] font-extrabold tabular-nums text-[#0f2547]",children:B(c.collected)}),e.jsxs("div",{className:"text-[11.5px] text-[#8493b4] tabular-nums",children:["of ",B(c.billed)," billed"]})]})]})]})}),e.jsx(As,{societyId:t}),e.jsx(wl,{societyId:t}),e.jsxs("div",{className:"mb-5 grid grid-cols-2 gap-3.5 lg:grid-cols-4",children:[e.jsx(G,{icon:e.jsx(te,{size:15}),k:"Overdue",v:B(c.overdue),vColor:c.overdue?"#d63a3a":"#15964f",dot:c.overdue?"#d63a3a":"#15964f",sub:c.overdueCount?`${c.overdueCount} unit${c.overdueCount===1?"":"s"} in arrears`:"no arrears",accent:"#d63a3a"}),e.jsx(G,{icon:e.jsx(Pe,{size:15}),k:"Occupancy",v:`${c.occupancy}%`,bar:c.occupancy,barColor:"#1c4b93",sub:x?`${c.filledBeds} of ${c.beds} beds · ${c.vacant} vacant`:`${c.occupied} of ${c.units} · ${c.vacant} vacant`}),x?e.jsx(G,{icon:e.jsx(fe,{size:15}),k:"Vacant beds",v:c.vacant,accent:"#c98a00",sub:`${c.filledBeds} of ${c.beds} filled`}):e.jsx(G,{icon:e.jsx(ce,{size:15}),k:"Verified",v:`${c.verifiedPct}%`,bar:c.verifiedPct,barColor:"#c98a00",accent:"#c98a00",sub:`${c.verifiedUnits} of ${c.occupied} occupied`}),e.jsx(G,{icon:e.jsx(he,{size:15}),k:"Open tickets",v:c.openTickets,vColor:c.openTickets?"#c77812":"#15964f",dot:c.slaBreached?"#d63a3a":c.openTickets?"#c77812":"#15964f",sub:c.slaBreached?`${c.slaBreached} high-priority`:"none urgent",accent:"#c77812"})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-4 lg:grid-cols-[1.5fr_1fr]",children:[e.jsxs("div",{className:T+" h-fit",children:[e.jsx(X,{icon:e.jsx(me,{size:15}
126),title:`Maintenance collection · ${Cl(n.period)}`,children:e.jsxs("span",{className:"rounded-md bg-[#e4f6ec] px-2 py-0.5 text-[11px] font-bold text-[#15964f]",children:[c.collectionPct,"% collected"]})}),e.jsxs("div",{className:"px-4 py-4",children:[e.jsx("div",{className:"flex h-3.5 overflow-hidden rounded-lg shadow-[inset_0_0_0_1px_#e4e8f1]",children:c.billed>0&&[["c",n.collection.collected,"#15964f"],["p",n.collection.pending,"#c77812"]].map(([u,b,g])=>e.jsx("div",{style:{width:`${b/c.billed*100}%`,background:g}},u))}),e.jsxs("div",{className:"mt-3.5 flex flex-wrap gap-5",children:[e.jsx(mt,{dot:"#15964f",amt:B(n.collection.collected),lb:"collected"}),e.jsx(mt,{dot:"#c77812",amt:B(n.collection.pending),lb:"pending this month"}),n.collection.overdue>0&&e.jsx(mt,{dot:"#d63a3a",amt:B(n.collection.overdue),lb:"overdue (arrears)"})]}),n.trend&&n.trend.length>1&&e.jsxs("div",{className:"mt-5 border-t border-[#eef1f7] pt-4",children:[e.jsxs("div",{className:"mb-2.5 flex items-center gap-1.5 text-[10px] font-bold uppercase tracking-[0.12em] text-[#8697b8]",children:[e.jsx(Ve,{size:13,className:"text-[#1c4b93]"})," Collection trend"]}),e.jsx(Pl,{data:n.trend,current:n.period})]}),c.billed===0&&e.jsx("p",{className:"mt-3 text-[12.5px] text-[#8493b4]",children:"No occupied units billed yet — add residents in the Directory to start the roll."})]})]}),e.jsxs("div",{className:T+" h-fit",children:[e.jsx(X,{icon:e.jsx(he,{size:15}),title:"Needs attention",children:e.jsxs("span",{className:"rounded-md px-2 py-0.5 text-[11px] font-bold "+(o.length?"bg-[#fbe8e8] text-[#d63a3a]":"bg-[#e4f6ec] text-[#15964f]"),children:[o.length," open"]})}),o.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center px-4 py-10 text-center",children:[e.jsx("span",{className:"grid h-11 w-11 place-items-center rounded-2xl bg-[#e4f6ec] text-[#15964f]",children:e.jsx(ce,{size:20})}),e.jsx("p",{className:"mt-2.5 text-[13px] font-bold text-[#153568]",children:"All caught up"}),e.jsx("p",{className:"text-[12px] text-[#8493b4]",children:"No pending actions right now."})]}):e.jsx("div",{className:"flex flex-col px-4",children:o.map(u=>{const b=qt[u.kind]||qt.verify,g=u.id==="overdue"||u.id==="proofs"?"billing":u.id==="tickets"?"helpdesk":"directory";return e.jsxs("div",{className:"flex items-start gap-3 border-t border-[#eef1f7] py-3 first:border-t-0",children:[e.jsx("span",{className:"grid h-8 w-8 shrink-0 place-items-center rounded-lg",style:{background:b.bg,color:b.fg},children:Yt[u.kind]||Yt.verify}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-[13px] font-bold text-[#153568]",children:u.title}),e.jsx("div",{className:"mt-0.5 text-[11.5px] text-[#5b6b8a]",children:u.sub})]}),e.jsxs(y,{size:"sm",variant:"outline",onClick:()=>m(g),children:[u.cta," ",e.jsx(et,{size:13})]})]},u.id)})})]})]}),e.jsxs("p",{className:"mt-6 text-center text-[10px] font-bold uppercase tracking-[0.14em] text-[#a7b3cd]",children:["JaaGa Community · ",n.society.name]})]})}function zl({pct:t}){const s=Math.max(0,Math.min(100,t||0)),n=s>=85?"#15964f":s>=60?"#c98a00":"#d63a3a";return e.jsx("div",{className:"relative grid h-[64px] w-[64px] place-items-center rounded-full",style:{background:`conic-gradient(${n} ${s*3.6}deg, #e6ecf5 0deg)`},children:e.jsx("div",{className:"grid h-[50px] w-[50px] place-items-center rounded-full bg-white",children:e.jsxs("span",{className:"text-[15px] font-extrabold tabular-nums",style:{color:"#0f2547"},children:[s,"%"]})})})}function Pl({data:t,current:s}){const n=Math.max(...t.map(i=>i.billed),1);return e.jsx("div",{className:"flex items-end gap-2.5",children:t.map(i=>{const r=Math.max(6,Math.round(i.billed/n*56)),l=Math.round(i.collected/(i.billed||1)*r),c=i.period===s;return e.jsxs("div",{className:"flex flex-1 flex-col items-center gap-1.5",children:[e.jsxs("div",{className:"relative w-full max-w-[34px] overflow-hidden rounded-md bg-[#eaeef6]",style:{height:56},title:`${i.collectionPct}% collected`,children:[e.jsx("div",{className:"absolute bottom-0 w-full rounded-t-md bg-[#dfe6f1]",style:{height:r}}),e.jsx("div",{className:"absolute bottom-0 w-full rounded-t-md",style:{height:l,background:c?"#1c4b93":"#15964f"}})]}),e.jsxs("span",{className:"text-[10px] font-bold tabular-nums "+(c?"text-[#1c4b93]":"text-[#8697b8]"),children:[i.collectionPct,"%"]}),e.jsx("span",{className:"text-[9px] font-semibold uppercase tracking-[0.06em] text-[#a7b3cd]",children:$s(i.period)})]},i.period)})})}function mt({dot:t,amt:s,lb:n}){return e.jsxs("span",{className:"flex items-center gap-2 text-[12px]",children:[e.jsx("span",{className:"h-2 w-2 rounded-full",style:{background:t}}),e.jsx("span",{className:"font-extrabold text-[#153568] tabular-nums",children:s}),e.jsx("span",{className:"text-[#586887]",children:n})]})}function Al(){return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:T+" mb-5 h-[150px] animate-pulse"}),e.jsx("div",{className:"mb-5 grid grid-cols-2 gap-3.5 lg:grid-cols-4",children:[0,1,2,3].map(t=>e.jsx("div",{className:T+" h-[112px] animate-pulse"},t))}),e.jsxs("div",{className:"grid grid-cols-1 gap-4 lg:grid-cols-[1.5fr_1fr]",children:[e.jsx("div",{className:T+" h-[260px] animate-pulse"}),e.jsx("div",{className:T+" h-[260px] animate-pulse"})]})]})}function Rl(){const t=new Date;return`${t.getFullYear()}
126-${String(t.getMonth()+1).padStart(2,"0")}`}function Jt(t,s){const[n,i]=t.split("-").map(Number),r=n*12+(i-1)+s;return`${Math.floor(r/12)}-${String(r%12+1).padStart(2,"0")}`}function ke(t){const[s,n]=t.split("-").map(Number);return new Date(s,n-1,1).toLocaleDateString("en-IN",{month:"long",year:"numeric"})}const Tl={paid:"green",partial:"amber",overdue:"red",due:"slate"},El={paid:"Paid",partial:"Partial",overdue:"Overdue",due:"Due"};function Ml({societyId:t,society:s,onNavigate:n}){var Z;const i=(s==null?void 0:s.type)==="pg",r=a.useMemo(Rl,[]),[l,c]=a.useState(r),[x,o]=a.useState(null),[m,d]=a.useState(null),[u,b]=a.useState(!1),[g,v]=a.useState(!1),[f,h]=a.useState(null),[w,z]=a.useState(null),[p,j]=a.useState(null),[E,R]=a.useState(null),[N,$]=a.useState(!1);a.useEffect(()=>{At(t).then(j).catch(()=>j({status:"none"})),Rt(t).then(R).catch(()=>R({enabled:!1}))},[t]);const S=(p==null?void 0:p.status)==="active",A=E?!!E.enabled:!!((Z=s==null?void 0:s.upiCollect)!=null&&Z.enabled),M=()=>{o(null),d(null),b(!1),Promise.all([ka(t,l),Ca(t,l)]).then(([P,O])=>{o(P),d(O)}).catch(()=>b(!0))};a.useEffect(M,[t,l]);const _=async P=>{$(!1),v(!0);try{await(i?wa:Sa)(t,l,P),M()}catch{b(!0)}finally{v(!1)}},D=()=>{S&&A?$(!0):_(S?"online":"upi")},H=()=>{h(null),M()},V=x==null?void 0:x.summary,J=x==null?void 0:x.generated,L=l>r;return p&&E&&!S&&!A?e.jsxs("div",{className:T+" p-8 text-center",children:[e.jsx("span",{className:"mx-auto grid h-14 w-14 place-items-center rounded-2xl bg-[#fef3d9] text-[#c98a00]",children:e.jsx(te,{size:26})}),e.jsx("h2",{className:"mt-4 text-[17px] font-extrabold text-[#0f2547]",children:"Set up a way to collect first"}),e.jsxs("p",{className:"mx-auto mt-1.5 max-w-[440px] text-[13px] leading-relaxed text-[#586887]",children:["Before running billing, set up how residents pay you — either verify a"," ",e.jsx("b",{children:"payout account"})," (collect online via Cashfree) or enable"," ",e.jsx("b",{children:"UPI / QR collection"})," (residents pay your UPI and upload a screenshot).",p.status==="pending"?" Your payout is verifying; this can take a few minutes.":p.status==="failed"?" Your last payout attempt failed — please resubmit.":""]}),e.jsx("div",{className:"mt-5",children:e.jsx(y,{variant:"navy",onClick:()=>n&&n("settings"),children:"Go to Settings"})})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-5 flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-[19px] font-extrabold tracking-[-0.01em] text-[#0f2547]",children:"Billing & Accounting"}),e.jsx("p",{className:"mt-0.5 text-[13px] text-[#5b6b8a]",children:i?"Generate monthly rent invoices and record collections, bed by bed.":"Generate maintenance invoices and record collections, unit by unit."})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex items-center gap-1 rounded-lg border border-[#d6deec] bg-white p-0.5",children:[e.jsx("button",{onClick:()=>c(P=>Jt(P,-1)),className:"grid h-8 w-8 place-items-center rounded-md text-[#586887] hover:bg-[#f2f5fc]","aria-label":"Previous month",children:e.jsx(Et,{size:16})}),e.jsx("span",{className:"min-w-[132px] text-center text-[13px] font-extrabold text-[#153568] tabular-nums",children:ke(l)}),e.jsx("button",{onClick:()=>c(P=>Jt(P,1)),disabled:l>=r,className:"grid h-8 w-8 place-items-center rounded-md text-[#586887] hover:bg-[#f2f5fc] disabled:opacity-30","aria-label":"Next month",children:e.jsx(et,{size:16})})]}),J&&!L&&e.jsx(y,{variant:"outline",icon:e.jsx(Ht,{size:14}),onClick:D,disabled:g,children:g?"Running…":i?"Top-up rent run":"Top-up run"})]})]}),e.jsx(Bl,{societyId:t,onReviewed:M}),u?e.jsx("div",{className:T,children:e.jsx(Q,{icon:e.jsx(te,{size:26}),title:"Couldn't load billing",sub:"Check your connection and try again.",cta:"Retry",onCta:M})}):!x||!m?e.jsx(Fl,{}):J?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-5 grid grid-cols-2 gap-3.5 lg:grid-cols-4",children:[e.jsx(G,{icon:e.jsx(me,{size:15}),k:"Billed",v:B(V.billed),sub:`${V.count} invoice${V.count===1?"":"s"}`,accent:"#1c4b93"}),e.jsx(G,{icon:e.jsx(Ve,{size:15}),k:"Collected",v:B(V.collected),vColor:"#15964f",bar:V.collectionPct,barColor:"#15964f",sub:`${V.paidCount} settled`}),e.jsx(G,{icon:e.jsx(te,{size:15}),k:"Pending",v:B(V.pending),vColor:V.pending?"#c77812":"#15964f",dot:V.pending?"#c77812":"#15964f",sub:`${V.dueCount} unit${V.dueCount===1?"":"s"} due`,accent:"#c77812"}),e.jsx(G,{icon:e.jsx(xe,{size:15}),k:"Collection",v:`${V.collectionPct}%`,bar:V.collectionPct,barColor:"#c98a00",accent:"#c98a00",sub:ke(l)})]}),e.jsxs("div",{className:T+" overflow-hidden",children:[e.jsx(X,{icon:e.jsx(xe,{size:15}),title:`Invoices · ${ke(l)}`,children:e.jsxs("span",{className:"rounded-md bg-[#eef3fb] px-2 py-0.5 text-[11px] font-bold text-[#1c4b93]",children:[V.count," total"]})}),e.jsxs("div",{className:"hidden grid-cols-[1.3fr_1.6fr_0.9fr_0.9fr_1fr_92px_112px] gap-x-3 border-b border-[#eef1f7] px-4 py-2.5 text-[10px] font-bold uppercase tracking-[0.12em] text-[#8697b8] lg:grid",children:[e.jsx("span",{children:i?"Room · Bed":"Unit"}),e.jsx("span",{children:i?"Guest":"Resident"}),e.jsx("span",{className:"text-right",children:i?"Rent":"Base"}),e.jsx("span",{className:"text-right",children:"Arrears"}),e.jsx("span",{className:"text-right",children:"Total"}),e.jsx("span",{children:"Status"}),e.jsx("span",{className:"text-right",children:"Action"})]}),e.jsx("div",{className:"flex flex-col",children:m.map(P=>e.jsx(_l,{inv:P,isPg:i,onPay:()=>h(P),onReceipt:()=>z(P._id)},P._id))})]})]}):e.jsxs("div",{className:T,children:[e.jsx(Q,{icon:e.jsx(xe,{size:26}),title:`No invoices for ${ke(l)} yet`,sub:L?"You can only generate bills for the current or a past period.":i?"Generate this period's rent for every occupied bed. Arrears from unpaid earlier months are carried forward automatically.":"Generate this period's maintenance bills for every occupied unit. Arrears from unpaid earlier months are carried forward automatically."}),!L&&e.jsx("div",{className:"flex justify-center pb-8",children:e.jsx(y,{variant:"navy",icon:e.jsx(Ht,{size:15}),onClick:D,disabled:g,children:g?"Generating…":i?`Run ${ke(l)} rent`:`Generate ${ke(l)} bills`})})]}),e.jsx($l,{invoice:f,onClose:()=>h(null),onPaid:H}),w&&e.jsx(pn,{invoiceId:w,onClose:()=>z(null)}),e.jsxs(q,{open:N,onClose:()=>$(!1),title:"How should residents pay this?",width:420,children:[e.jsxs("p",{className:"mb-3 text-[13px] text-[#586887]",children:["Pick how you want to collect ",i?"this rent run":"these bills",". Residents will see only the method you choose."]}),e.jsxs("div",{className:"flex flex-col gap-2.5",children:[e.jsxs("button",{onClick:()=>_("online"),className:"flex items-start gap-3 rounded-xl border border-[#d6deec] bg-white p-3.5 text-left transition hover:border-[#1c4b93] hover:bg-[#f2f5fc]",children:[e.jsx("span",{className:"grid h-9 w-9 shrink-0 place-items-center rounded-lg bg-[#eef3fb] text-[#1c4b93]",children:e.jsx(Ae,{size:16})}),e.jsxs("span",{children:[e.jsx("span",{className:"block text-[13.5px] font-extrabold text-[#0f2547]",children:"Online (Cashfree)"}),e.jsx("span",{className:"block text-[12px] text-[#586887]",children:"Residents pay in-app; money settles to your payout account."})]})]}),e.jsxs("button",{onClick:()=>_("upi"),className:"flex items-start gap-3 rounded-xl border border-[#d6deec] bg-white p-3.5 text-left transition hover:border-[#1c4b93] hover:bg-[#f2f5fc]",children:[e.jsx("span",{className:"grid h-9 w-9 shrink-0 place-items-center rounded-lg bg-[#fdf3dd] text-[#c98a00]",children:e.jsx(Le,{size:16})}),e.jsxs("span",{children:[e.jsx("span",{className:"block text-[13.5px] font-extrabold text-[#0f2547]",children:"UPI / QR"}),e.jsx("span",{className:"block text-[12px] text-[#586887]",children:"Residents pay your UPI directly and upload a screenshot for you to approve."})]})]})]})]})]})}function Bl({societyId:t,onReviewed:s}){var d,u,b,g,v,f;
126const[n,i]=a.useState(null),[r,l]=a.useState(null),[c,x]=a.useState(null),o=()=>za(t,"pending").then(i).catch(()=>i([]));if(a.useEffect(()=>{o()},[t]),!n||n.length===0)return null;const m=async(h,w)=>{let z;w==="reject"&&(z=window.prompt("Reason for rejecting this proof (optional):","")||""),x(h.invoiceId);try{await Pa(h.invoiceId,w,z),l(null),await o(),s&&s()}catch{}finally{x(null)}};return e.jsxs("div",{className:T+" mb-5 overflow-hidden",style:{borderColor:"#f0d9a6"},children:[e.jsx(X,{icon:e.jsx(Le,{size:15}),title:"UPI payment proofs to review",children:e.jsxs("span",{className:"rounded-md bg-[#fbefd9] px-2 py-0.5 text-[11px] font-bold text-[#c77812]",children:[n.length," pending"]})}),e.jsx("div",{className:"flex flex-col",children:n.map(h=>{var w,z,p,j;return e.jsxs("div",{className:"flex flex-wrap items-center gap-3 border-t border-[#eef1f7] px-4 py-3 first:border-t-0",children:[e.jsx("button",{onClick:()=>l(h),className:"grid h-12 w-12 shrink-0 place-items-center overflow-hidden rounded-lg border border-[#e6eaf3] bg-[#f4f7fc]",title:"View screenshot",children:(w=h.proof)!=null&&w.url?e.jsx("img",{src:h.proof.url,alt:"proof",className:"h-full w-full object-cover"}):e.jsx(Le,{size:16,className:"text-[#a7b3cd]"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"text-[13.5px] font-extrabold text-[#153568]",children:[h.unit||"—",h.bedLabel?` · ${h.bedLabel}`:""," ",e.jsxs("span",{className:"font-semibold text-[#8493b4]",children:["· ",((z=h.resident)==null?void 0:z.name)||"Resident"]})]}),e.jsxs("div",{className:"text-[11.5px] text-[#8493b4]",children:[h.kind==="rent"?"Rent":"Maintenance"," · ",h.period," · claims"," ",B((p=h.proof)==null?void 0:p.amount),(j=h.proof)!=null&&j.ref?` · ref ${h.proof.ref}`:""]})]}),e.jsx("div",{className:"text-right text-[14px] font-extrabold text-[#0f2547] tabular-nums",children:B(h.total)}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(y,{size:"sm",variant:"danger",onClick:()=>m(h,"reject"),disabled:c===h.invoiceId,children:"Reject"}),e.jsx(y,{size:"sm",variant:"navy",icon:e.jsx(ue,{size:13}),onClick:()=>m(h,"approve"),disabled:c===h.invoiceId,children:"Approve"})]})]},h.invoiceId)})}),e.jsx(q,{open:!!r,onClose:()=>l(null),title:r?`Payment proof · ${r.unit||""}`:"",width:520,children:r&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between rounded-xl bg-[#f4f7fc] px-4 py-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[12.5px] font-extrabold text-[#0f2547]",children:((d=r.resident)==null?void 0:d.name)||"Resident"}),e.jsx("div",{className:"text-[11.5px] text-[#8493b4]",children:((u=r.resident)==null?void 0:u.phone)||""})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("div",{className:"text-[11px] font-bold uppercase tracking-[0.1em] text-[#8697b8]",children:"Bill"}),e.jsx("div",{className:"text-[16px] font-extrabold text-[#0f2547] tabular-nums",children:B(r.total)})]})]}),e.jsxs("div",{className:"text-[12px] text-[#586887]",children:["Resident claims to have paid ",e.jsx("b",{children:B((b=r.proof)==null?void 0:b.amount)}),(g=r.proof)!=null&&g.ref?e.jsxs(e.Fragment,{children:[" ","· ref ",e.jsx("b",{children:r.proof.ref})]}):null,(v=r.proof)!=null&&v.upiId?e.jsxs(e.Fragment,{children:[" · to ",r.proof.upiId]}):null]}),(f=r.proof)!=null&&f.url?e.jsx("img",{src:r.proof.url,alt:"Payment screenshot",className:"max-h-[60vh] w-full rounded-xl border border-[#e6eaf3] object-contain"}):e.jsx("div",{className:"rounded-xl border border-dashed border-[#e6eaf3] p-6 text-center text-[12.5px] text-[#8493b4]",children:"Screenshot unavailable."}),e.jsxs("div",{className:"flex justify-end gap-2 pt-1",children:[e.jsx(y,{variant:"danger",onClick:()=>m(r,"reject"),disabled:c===r.invoiceId,children:"Reject"}),e.jsx(y,{variant:"navy",icon:e.jsx(ue,{size:14}),onClick:()=>m(r,"approve"),disabled:c===r.invoiceId,children:"Approve into Collected"})]})]})})]})}function _l({inv:t,isPg:s,onPay:n,onReceipt:i}){var x;const r=Tl[t.status]||"slate",l=t.status==="paid",c=t.room||((x=t.unit)==null?void 0:x.code)||"—";return e.jsxs("div",{className:"grid grid-cols-2 items-center gap-x-3 gap-y-1 border-t border-[#eef1f7] px-4 py-3 first:border-t-0 lg:grid-cols-[1.3fr_1.6fr_0.9fr_0.9fr_1fr_92px_112px]",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"grid h-8 w-8 shrink-0 place-items-center rounded-lg bg-[#eef3fb] text-[12px] font-extrabold text-[#1c4b93]",children:String(c).slice(0,3)}),e.jsxs("span",{className:"text-[13.5px] font-extrabold text-[#153568]",children:[c,s&&t.bedLabel?e.jsxs("span",{className:"text-[#8493b4]",children:[" · ",t.bedLabel]}):null]})]}),e.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 text-[13px] text-[#586887] lg:justify-start",children:[e.jsx("span",{className:"truncate",children:t.resident||t.guest||e.jsx("span",{className:"text-[#a7b3cd]",children:s?"Vacant bed":"Vacant / unassigned"})}),t.kind==="deposit"&&e.jsx(F,{tone:"gold",children:"Deposit"}),t.kind==="rent"&&e.jsx(F,{tone:"navy",children:"Rent"}),t.kind==="other"&&e.jsx(F,{tone:"slate",children:"Charge"})]}),e.jsx("div",{className:"hidden text-right text-[13px] tabular-nums text-[#586887] lg:block",children:B(t.base)}),e.jsx("div",{className:"hidden text-right text-[13px] tabular-nums lg:block",children:t.arrears?e.jsx("span",{className:"font-bold text-[#c77812]",children:B(t.arrears)}):e.jsx("span",{className:"text-[#c4cddd]",children:"—"})}),e.jsx("div",{className:"col-start-2 row-start-1 text-right text-[14px] font-extrabold text-[#0f2547] tabular-nums lg:col-auto lg:row-auto",children:B(t.total)}),e.jsx("div",{className:"lg:justify-self-start",children:e.jsx(F,{tone:r,dot:!0,children:El[t.status]||t.status})}),e.jsx("div",{className:"col-span-2 mt-1 flex items-center justify-end gap-2 lg:col-auto lg:mt-0",children:l?e.jsxs("button",{onClick:i,className:"inline-flex items-center gap-1 rounded-md px-1.5 py-1 text-[11.5px] font-bold text-[#15964f] transition hover:bg-[#e4f6ec]",title:t.receiptNo?`Receipt ${t.receiptNo} · ${t.channel||"paid"}`:"View receipt",children:[e.jsx(Zs,{size:13})," Receipt"]}):e.jsx(y,{size:"sm",variant:"outline",icon:e.jsx(Ae,{size:13}),onClick:n,children:"Offline"})})]})}const Dl=["cash","upi","cheque","netbanking"],Ll={cash:"Cash",upi:"UPI",cheque:"Cheque",netbanking:"Net banking"};function $l({invoice:t,onClose:s,onPaid:n}){var v,f;
126const[i,r]=a.useState(""),[l,c]=a.useState("cash"),[x,o]=a.useState(!1),[m,d]=a.useState("");if(a.useEffect(()=>{t&&(r(String(t.total||"")),c("cash"),d(""),o(!1))},[t]),!t)return null;const u=t.room||t.bedLabel?[t.room||((v=t.unit)==null?void 0:v.code),t.bedLabel].filter(Boolean).join(" · "):((f=t.unit)==null?void 0:f.code)||"",b=t.resident||t.guest||"Unassigned",g=async()=>{const h=Number(i);if(!h||h<=0)return d("Enter a valid amount.");o(!0);try{await Aa(t._id,{amount:h,mode:l}),n(t)}catch{d("Couldn't record the payment. Please try again."),o(!1)}};return e.jsxs(q,{open:!!t,onClose:s,title:`Record offline payment · ${u}`,footer:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(y,{variant:"ghost",onClick:s,children:"Cancel"}),e.jsx(y,{variant:"navy",onClick:g,disabled:x,children:x?"Recording…":"Record offline payment"})]}),children:[e.jsxs("div",{className:"mb-3 flex items-start gap-2 rounded-lg bg-[#fbefd9] px-3 py-2 text-[11.5px] font-semibold text-[#a06a12]",children:[e.jsx(Ns,{size:14,className:"mt-px shrink-0"}),"For money received ",e.jsx("b",{children:"outside JaaGa"})," (cash / cheque / direct bank transfer). Online & wallet payments are collected via the resident app."]}),e.jsxs("div",{className:"mb-4 flex items-center justify-between rounded-xl bg-[#f4f7fc] px-4 py-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] font-bold uppercase tracking-[0.1em] text-[#8697b8]",children:"Amount due"}),e.jsxs("div",{className:"text-[12.5px] text-[#586887]",children:[b,t.arrears?` · incl. ${B(t.arrears)} arrears`:""]})]}),e.jsx("div",{className:"text-[20px] font-extrabold text-[#0f2547] tabular-nums",children:B(t.total)})]}),e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(C,{label:"Amount received",hint:"Enter a lower amount to record a part-payment.",children:e.jsx("input",{className:k,type:"number",value:i,onChange:h=>r(h.target.value),autoFocus:!0})}),e.jsxs("div",{children:[e.jsx("span",{className:"mb-1 block text-[11px] font-bold uppercase tracking-[0.08em] text-[#8493b4]",children:"Payment mode"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:Dl.map(h=>e.jsx("button",{onClick:()=>c(h),className:"h-9 rounded-lg border px-3 text-[12.5px] font-bold transition "+(l===h?"border-[#1c4b93] bg-[#eef3fb] text-[#1c4b93]":"border-[#d6deec] bg-white text-[#586887] hover:bg-[#f2f5fc]"),children:Ll[h]},h))})]}),m&&e.jsx("p",{className:"text-[12.5px] font-semibold text-[#d63a3a]",children:m})]})]})}function Fl(){return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mb-5 grid grid-cols-2 gap-3.5 lg:grid-cols-4",children:[0,1,2,3].map(t=>e.jsx("div",{className:T+" h-[112px] animate-pulse"},t))}),e.jsx("div",{className:T+" h-[320px] animate-pulse"})]})}const Ol=["plumbing","electrical","housekeeping","security","lift","common-area","other"],Qe={plumbing:"Plumbing",electrical:"Electrical",housekeeping:"Housekeeping",security:"Security",lift:"Lift","common-area":"Common area",other:"Other"},Fs={plumbing:"#1c4b93",electrical:"#c98a00",housekeeping:"#15964f",security:"#d63a3a",lift:"#c77812","common-area":"#7c8ca8",other:"#8697b8"},Ul=["low","medium","high"],Bt={low:"Low",medium:"Medium",high:"High"},Os={low:"slate",medium:"amber",high:"red"},Us={open:"amber","in-progress":"navy",resolved:"green",closed:"slate"},Is={open:"Open","in-progress":"In progress",resolved:"Resolved",closed:"Closed"},Il=[{key:"",label:"All"},{key:"open",label:"Open"},{key:"in-progress",label:"In-progress"},{key:"resolved",label:"Resolved"},{key:"closed",label:"Closed"}];function Gl({societyId:t}){const[s,n]=a.useState(""),[i,r]=a.useState(null),[l,c]=a.useState(null),[x,o]=a.useState(!1),[m,d]=a.useState(!1),[u,b]=a.useState(null),g=()=>{r(null),c(null),o(!1),Ft(t,{status:s}).then(f=>{r(f.stats),c(f.items)}).catch(()=>o(!0))};a.useEffect(g,[t,s]);const v=()=>Ft(t,{status:s}).then(f=>{if(r(f.stats),c(f.items),u){const h=f.items.find(w=>w._id===u._id);h&&b(h)}});return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-4 flex flex-wrap items-end justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-[19px] font-extrabold tracking-[-0.01em] text-[#0f2547]",children:"Helpdesk"}),e.jsx("p",{className:"mt-0.5 text-[13px] text-[#5b6b8a]",children:"Track and resolve resident complaints, unit by unit."})]}),e.jsx(y,{variant:"navy",icon:e.jsx(ae,{size:15}),onClick:()=>d(!0),children:"New ticket"})]}),x?e.jsx("div",{className:T,children:e.jsx(Q,{icon:e.jsx(te,{size:26}),title:"Couldn't load the helpdesk",sub:"Check your connection and try again.",cta:"Retry",onCta:g})}):!i||!l?e.jsx(Yl,{}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-5 grid grid-cols-2 gap-3.5 lg:grid-cols-4",children:[e.jsx(G,{icon:e.jsx(He,{size:15}),k:"Open",v:i.open,accent:"#c77812",vColor:"#c77812",sub:`${i.total} total`}),e.jsx(G,{icon:e.jsx(ne,{size:15}),k:"In progress",v:i.inProgress,accent:"#1c4b93",sub:"being worked on"}),e.jsx(G,{icon:e.jsx(ue,{size:15}),k:"Resolved",v:i.resolved,accent:"#15964f",vColor:"#15964f",sub:`${i.closed} closed`}),e.jsx(G,{icon:e.jsx(te,{size:15}),k:"High priority",v:i.highPriority,accent:"#d63a3a",vColor:i.highPriority?"#d63a3a":"#15964f",dot:i.highPriority?"#d63a3a":"#15964f",sub:"need attention"})]}),e.jsx("div",{className:"mb-4 flex flex-wrap gap-2",children:Il.map(f=>e.jsx("button",{onClick:()=>n(f.key),className:"h-9 rounded-lg border px-3.5 text-[12.5px] font-bold transition "+(s===f.key?"border-[#1c4b93] bg-[#eef3fb] text-[#1c4b93]":"border-[#d6deec] bg-white text-[#586887] hover:bg-[#f2f5fc]"),children:f.label},f.key||"all"))}),e.jsxs("div",{className:T+" overflow-hidden",children:[e.jsx(X,{icon:e.jsx(he,{size:15}),title:"Tickets",children:e.jsxs("span",{className:"rounded-md bg-[#eef3fb] px-2 py-0.5 text-[11px] font-bold text-[#1c4b93]",children:[l.length," shown"]})}),l.length===0?e.jsx(Q,{icon:e.jsx(he,{size:26}),title:"No tickets here",sub:s?"No tickets match this filter. Try another status.":"When residents raise complaints, they'll show up here to triage and resolve.",cta:s?void 0:"New ticket",onCta:s?void 0:()=>d(!0)}):e.jsx("div",{className:"flex flex-col",children:l.map(f=>e.jsx(Hl,{t:f,onOpen:()=>b(f)},f._id))})]})]}),e.jsx(Wl,{open:m,societyId:t,onClose:()=>d(!1),onCreated:()=>{d(!1),g()}}),e.jsx(Kl,{ticket:u,onClose:()=>b(null),onChange:v})]})}function Hl({t,onOpen:s}){const n=Fs[t.category]||"#8697b8";return e.jsxs("button",{onClick:s,className:"grid grid-cols-[auto_1fr_auto] items-center gap-3 border-t border-[#eef1f7] px-4 py-3 text-left first:border-t-0 hover:bg-[#f7f9fd]",children:[e.jsx("span",{className:"grid h-9 w-9 shrink-0 place-items-center rounded-lg",style:{background:n+"15",color:n},children:e.jsx(Oe,{size:15})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-[13.5px] font-extrabold text-[#153568]",children:t.title}),e.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[11.5px] text-[#5b6b8a]",children:[e.jsx("span",{className:"font-bold text-[#1c4b93]",children:t.unitCode||"—"}),e.jsx("span",{className:"text-[#c4cddd]",children:"·"}),e.jsx("span",{className:"truncate",children:t.raisedByName||"Resident"}),e.jsx("span",{className:"text-[#c4cddd]",children:"·"}),e.jsx("span",{children:Qe[t.category]||t.category}),e.jsx("span",{className:"text-[#c4cddd]",children:"·"}),e.jsx("span",{className:"text-[#8697b8]",children:se(t.createdAt)})]})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[e.jsx(F,{tone:Os[t.priority]||"slate",dot:!0,children:Bt[t.priority]||t.priority}),e.jsx(F,{tone:Us[t.status]||"slate",children:Is[t.status]||t.status})]})]})}function Vl(t){return t==="open"?{to:"in-progress",label:"Start work",icon:e.jsx(In,{size:14})}:t==="in-progress"?{to:"resolved",label:"Mark resolved",icon:e.jsx(ue,{size:14})}:null}function Kl({ticket:t,onClose:s,onChange:n}
126){const[i,r]=a.useState(""),[l,c]=a.useState(!1),[x,o]=a.useState(""),[m,d]=a.useState(!1),[u,b]=a.useState(!1);if(a.useEffect(()=>{r((t==null?void 0:t.assignedTo)||""),o("")},[t==null?void 0:t._id]),!t)return null;const g=async j=>{d(!0);try{await Ot(t._id,{status:j}),await n()}finally{d(!1)}},v=async()=>{if(i.trim()!==(t.assignedTo||"")){c(!0);try{await Ot(t._id,{assignedTo:i.trim()}),await n()}finally{c(!1)}}},f=async()=>{const j=x.trim();if(j){b(!0);try{await Ra(t._id,j),o(""),await n()}finally{b(!1)}}},h=Vl(t.status),w=Fs[t.category]||"#8697b8",z=t.comments||[],p=t.status==="closed";return e.jsxs(st,{open:!!t,onClose:s,width:480,storageKey:"ticket",title:t.title,subtitle:`${t.unitCode||"—"} · ${Qe[t.category]||t.category}`,footer:p?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"flex flex-1 items-center gap-1.5 text-[12.5px] font-bold text-[#15964f]",children:[e.jsx(ue,{size:14})," Resolved & closed"]}),e.jsx(y,{variant:"outline",icon:e.jsx(gn,{size:14}),onClick:()=>g("in-progress"),disabled:m,children:"Reopen"})]}):e.jsxs("div",{className:"flex items-center gap-2",children:[h&&e.jsx(y,{variant:"navy",icon:h.icon,onClick:()=>g(h.to),disabled:m,className:"flex-1",children:h.label}),e.jsx(y,{variant:h?"outline":"navy",icon:e.jsx(ue,{size:14}),onClick:()=>g("closed"),disabled:m,className:h?"":"flex-1",children:"Close ticket"})]}),children:[e.jsxs("div",{className:"mb-4 flex items-center gap-2",children:[e.jsx(F,{tone:Us[t.status]||"slate",dot:!0,children:Is[t.status]||t.status}),e.jsxs(F,{tone:Os[t.priority]||"slate",dot:!0,children:[Bt[t.priority]||t.priority," priority"]})]}),e.jsxs("div",{className:T+" mb-3.5 p-4",children:[e.jsx("div",{className:we+" mb-1.5",children:"Complaint"}),e.jsx("p",{className:"whitespace-pre-wrap text-[13.5px] leading-relaxed text-[#3f4d6b]",children:t.description||"No description provided."})]}),e.jsxs("div",{className:T+" mb-3.5 grid grid-cols-2 gap-3 p-4",children:[e.jsx(Ee,{label:"Raised by",value:t.raisedByName||"Resident"}),e.jsx(Ee,{label:"Unit",value:t.unitCode||"—"}),e.jsx(Ee,{label:"Category",value:e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx("span",{className:"h-2 w-2 rounded-full",style:{background:w}}),Qe[t.category]||t.category]})}),e.jsx(Ee,{label:"Raised on",value:se(t.createdAt)}),t.resolvedAt&&e.jsx(Ee,{label:"Resolved on",value:se(t.resolvedAt)})]}),e.jsxs("div",{className:T+" mb-3.5 p-4",children:[e.jsxs("div",{className:"mb-1.5 flex items-center gap-1.5",children:[e.jsx(Zn,{size:13,className:"text-[#1c4b93]"}),e.jsx("span",{className:we,children:"Assigned to"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{className:k,placeholder:"Name of staff / vendor",value:i,onChange:j=>r(j.target.value)}),e.jsx(y,{variant:"outline",size:"sm",onClick:v,disabled:l||i.trim()===(t.assignedTo||""),children:l?"Saving…":"Save"})]})]}),e.jsxs("div",{className:T+" overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-2 border-b border-[#eef1f7] px-4 py-3",children:[e.jsx(ds,{size:14,className:"text-[#1c4b93]"}),e.jsx("h3",{className:"text-[13px] font-extrabold text-[#153568]",children:"Activity"}),e.jsx("span",{className:"ml-auto rounded-md bg-[#eef3fb] px-2 py-0.5 text-[10.5px] font-bold text-[#1c4b93]",children:z.length})]}),z.length===0?e.jsx("div",{className:"px-4 py-6 text-center text-[12.5px] text-[#8697b8]",children:"No comments yet. Add the first update below."}):e.jsx("div",{className:"flex flex-col gap-3 px-4 py-3.5",children:z.map((j,E)=>e.jsxs("div",{className:"flex gap-2.5",children:[e.jsx("span",{className:"mt-0.5 grid h-7 w-7 shrink-0 place-items-center rounded-full bg-[#eef3fb] text-[11px] font-extrabold text-[#1c4b93]",children:(j.name||"?").slice(0,1).toUpperCase()}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsx("span",{className:"text-[12.5px] font-extrabold text-[#153568]",children:j.name||"Staff"}),e.jsx("span",{className:"text-[10.5px] text-[#a7b3cd]",children:se(j.at)})]}),e.jsx("p",{className:"mt-0.5 whitespace-pre-wrap text-[12.5px] leading-relaxed text-[#586887]",children:j.text})]})]},E))}),e.jsxs("div",{className:"border-t border-[#eef1f7] p-3",children:[e.jsx("textarea",{className:k+" min-h-[64px] py-2",placeholder:"Add an update or note…",value:x,onChange:j=>o(j.target.value)}),e.jsx("div",{className:"mt-2 flex justify-end",children:e.jsx(y,{variant:"navy",size:"sm",icon:e.jsx(ks,{size:13}),onClick:f,disabled:u||!x.trim(),children:u?"Sending…":"Comment"})})]})]})]})}function Ee({label:t,value:s}){return e.jsxs("div",{children:[e.jsx("div",{className:we+" mb-1",children:t}),e.jsx("div",{className:"text-[13px] font-bold text-[#153568]",children:s})]})}function Wl({open:t,societyId:s,onClose:n,onCreated:i}
126){const[r,l]=a.useState(""),[c,x]=a.useState("plumbing"),[o,m]=a.useState("medium"),[d,u]=a.useState(""),[b,g]=a.useState(!1),[v,f]=a.useState("");a.useEffect(()=>{t&&(l(""),x("plumbing"),m("medium"),u(""),f(""),g(!1))},[t]);const h=async()=>{if(!r.trim())return f("Give the ticket a short title.");g(!0);try{await Ta(s,{category:c,title:r.trim(),description:d.trim(),priority:o}),i()}catch{f("Couldn't create the ticket. Please try again."),g(!1)}};return e.jsx(q,{open:t,onClose:n,title:"New ticket",footer:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(y,{variant:"ghost",onClick:n,children:"Cancel"}),e.jsx(y,{variant:"navy",icon:e.jsx(ae,{size:14}),onClick:h,disabled:b,children:b?"Creating…":"Create ticket"})]}),children:e.jsxs("div",{className:"flex flex-col gap-3.5",children:[e.jsx(C,{label:"Title",children:e.jsx("input",{className:k,placeholder:"e.g. Water leak in basement parking",value:r,onChange:w=>l(w.target.value),autoFocus:!0})}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(C,{label:"Category",children:e.jsx("select",{className:k,value:c,onChange:w=>x(w.target.value),children:Ol.map(w=>e.jsx("option",{value:w,children:Qe[w]},w))})}),e.jsxs("div",{children:[e.jsx("span",{className:"mb-1 block text-[11px] font-bold uppercase tracking-[0.08em] text-[#8493b4]",children:"Priority"}),e.jsx("div",{className:"flex gap-2",children:Ul.map(w=>e.jsx("button",{onClick:()=>m(w),className:"h-10 flex-1 rounded-lg border text-[12.5px] font-bold transition "+(o===w?"border-[#1c4b93] bg-[#eef3fb] text-[#1c4b93]":"border-[#d6deec] bg-white text-[#586887] hover:bg-[#f2f5fc]"),children:Bt[w]},w))})]})]}),e.jsx(C,{label:"Description",hint:"Describe the issue so staff can act on it.",children:e.jsx("textarea",{className:k+" min-h-[84px] py-2",placeholder:"What's wrong, where, and since when…",value:d,onChange:w=>u(w.target.value)})}),v&&e.jsx("p",{className:"text-[12.5px] font-semibold text-[#d63a3a]",children:v})]})})}function Yl(){return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mb-5 grid grid-cols-2 gap-3.5 lg:grid-cols-4",children:[0,1,2,3].map(t=>e.jsx("div",{className:T+" h-[112px] animate-pulse"},t))}),e.jsx("div",{className:"mb-4 flex gap-2",children:[0,1,2,3,4].map(t=>e.jsx("div",{className:"h-9 w-20 animate-pulse rounded-lg bg-[#eef1f7]"},t))}),e.jsx("div",{className:T+" h-[320px] animate-pulse"})]})}const Xe={clubhouse:{label:"Clubhouse",icon:de,color:"#1c4b93",tone:"navy"},gym:{label:"Gym",icon:hn,color:"#15964f",tone:"green"},pool:{label:"Pool",icon:zn,color:"#1c4b93",tone:"navy"},hall:{label:"Hall",icon:fn,color:"#c98a00",tone:"gold"},court:{label:"Court",icon:Pn,color:"#c77812",tone:"amber"},park:{label:"Park",icon:wn,color:"#15964f",tone:"green"},other:{label:"Other",icon:Ss,color:"#586887",tone:"slate"}},ql=Object.keys(Xe),_t=t=>Xe[t]||Xe.other;function Se(t){if(!t)return"";const[s,n]=t.split(":").map(Number),i=s>=12?"PM":"AM";return`${s%12||12}:${String(n).padStart(2,"0")} ${i}`}const ut=()=>new Date().toISOString().slice(0,10);function Jl({societyId:t}){const[s,n]=a.useState(null),[i,r]=a.useState(null),[l,c]=a.useState(!1),[x,o]=a.useState(!1),[m,d]=a.useState(null),[u,b]=a.useState(null),g=()=>{n(null),r(null),c(!1),Promise.all([Ea(t),Ma(t)]).then(([h,w])=>{n(h),r(w)}).catch(()=>c(!0))};a.useEffect(g,[t]);const v=async h=>{try{await bs(h._id,{active:!h.active}),g()}catch{c(!0)}},f=async h=>{try{await Ba(h),g()}catch{c(!0)}};return e.jsxs(e.Fragment,{children:[e.jsx(ze,{title:"Amenities",sub:"Manage shared facilities and resident bookings.",right:e.jsx(y,{variant:"navy",icon:e.jsx(ae,{size:15}),onClick:()=>o(!0),children:"Add facility"})}),l?e.jsx("div",{className:T,children:e.jsx(Q,{icon:e.jsx(te,{size:26}),title:"Couldn't load amenities",sub:"Check your connection and try again.",cta:"Retry",onCta:g})}):!s||!i?e.jsx(ti,{}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-5 grid grid-cols-2 gap-3.5 lg:grid-cols-4",children:[e.jsx(G,{icon:e.jsx(Ss,{size:15}),k:"Facilities",v:s.length,sub:"shared spaces",accent:"#1c4b93"}),e.jsx(G,{icon:e.jsx(Ye,{size:15}),k:"Active",v:s.filter(h=>h.active).length,vColor:"#15964f",dot:"#15964f",sub:"open for booking",accent:"#15964f"}),e.jsx(G,{icon:e.jsx(Ae,{size:15}),k:"Chargeable",v:s.filter(h=>h.chargeable).length,vColor:"#c98a00",sub:"paid facilities",accent:"#c98a00"}),e.jsx(G,{icon:e.jsx(bt,{size:15}),k:"Upcoming bookings",v:s.reduce((h,w)=>h+(w.upcomingBookings||0),0),sub:"across all spaces",accent:"#1c4b93"})]}),s.length===0?e.jsx("div",{className:T,children:e.jsx(Q,{icon:e.jsx(Ye,{size:26}),title:"No amenities yet",sub:"Add a clubhouse, gym, pool or hall to let residents book shared spaces.",cta:"Add facility",onCta:()=>o(!0)})}):e.jsx("div",{className:"grid grid-cols-1 gap-3.5 sm:grid-cols-2 lg:grid-cols-3",children:s.map(h=>e.jsx(Ql,{a:h,onBook:()=>b(h),onEdit:()=>d(h),onToggle:()=>v(h)},h._id))}),e.jsxs("div",{className:T+" mt-5 overflow-hidden",children:[e.jsx(X,{icon:e.jsx(bt,{size:15}),title:"Upcoming bookings",children:e.jsxs("span",{className:"rounded-md bg-[#eef3fb] px-2 py-0.5 text-[11px] font-bold text-[#1c4b93]",children:[i.length," total"]})}),i.length===0?e.jsx(Q,{icon:e.jsx(Vn,{size:26}),title:"No upcoming bookings",sub:"Reservations residents make will appear here."}):e.jsx("div",{className:"flex flex-col",children:i.map(h=>e.jsx(Xl,{b:h,onCancel:()=>f(h._id)},h._id))})]})]}),e.jsx(Zl,{open:x||!!m,societyId:t,amenity:m,onClose:()=>{o(!1),d(null)},onSaved:()=>{o(!1),d(null),g()}}),e.jsx(ei,{amenity:u,societyId:t,onClose:()=>b(null),onBooked:()=>{b(null),g()}})]})}function Ql({a:t,onBook:s,onEdit:n,onToggle:i}){const r=_t(t.type),l=r.icon;return e.jsxs("div",{className:T+" flex flex-col p-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"grid h-11 w-11 shrink-0 place-items-center rounded-xl",style:{background:r.color+"15",color:r.color},children:e.jsx(l,{size:20})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate text-[15px] font-extrabold text-[#153568]",children:t.name}),e.jsxs("div",{className:"mt-0.5 flex items-center gap-1.5 text-[12px] text-[#5b6b8a]",children:[e.jsx("span",{children:r.label}),t.capacity?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-[#c4cddd]",children:"·"}),e.jsxs("span",{className:"inline-flex items-center gap-1 tabular-nums",children:[e.jsx(Ue,{size:12})," ",t.capacity]})]}):null]})]}),e.jsx(F,{tone:t.active?"green":"slate",dot:!0,children:t.active?"Active":"Inactive"})]}),t.description&&e.jsx("p",{className:"mt-3 line-clamp-2 text-[12.5px] leading-relaxed text-[#586887]",children:t.description}),e.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[(t.openTime||t.closeTime)&&e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-md bg-[#f4f7fc] px-2 py-1 text-[11.5px] font-semibold text-[#586887] tabular-nums",children:[e.jsx(Sn,{size:12,className:"text-[#8697b8]"}),Se(t.openTime)," – ",Se(t.closeTime)]}),e.jsx(F,{tone:t.chargeable?"gold":"slate",children:t.chargeable?B(t.charge):"Free"})]}),e.jsxs("div",{className:"mt-3 flex items-center gap-1.5 text-[12px] text-[#5b6b8a]",children:[e.jsx(bt,{size:13,className:"text-[#8697b8]"}),e.jsx("span",{className:"tabular-nums font-bold text-[#153568]",children:t.upcomingBookings||0}),e.jsxs("span",{children:["upcoming booking",(t.upcomingBookings||0)===1?"":"s"]})]}),e.jsxs("div",{className:"mt-auto flex items-center justify-between gap-2 border-t border-[#eef1f7] pt-3",children:[e.jsx(y,{size:"sm",variant:"navy",icon:e.jsx(Ye,{size:13}),onClick:s,disabled:!t.active,children:"Book"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(y,{size:"sm",variant:"outline",icon:e.jsx(Ct,{size:13}),onClick:n,children:"Edit"}),e.jsx(y,{size:"sm",variant:t.active?"ghost":"outline",onClick:i,children:t.active?"Deactivate":"Activate"})]})]})]})}function Xl({b:t,onCancel:s}){var l,c,x,o;const n=_t((l=t.amenity)==null?void 0:l.type),i=n.icon,r=(c=t.amenity)==null?void 0:c.chargeable;return e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2 border-t border-[#eef1f7] px-4 py-3 first:border-t-0",children:[e.jsx("span",{className:"grid h-9 w-9 shrink-0 place-items-center rounded-lg",style:{background:n.color+"15",color:n.color},children:e.jsx(i,{size:16})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate text-[13.5px] font-extrabold text-[#153568]",children:((x=t.amenity)==null?void 0:x.name)||n.label}),e.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-1.5 text-[12px] text-[#5b6b8a]",children:[e.jsx("span",{children:se(t.date)}),e.jsx("span",{className:"text-[#c4cddd]",children:"·"}),e.jsxs("span",{className:"tabular-nums",children:[Se(t.start)," – ",Se(t.end)]})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 text-[12.5px] text-[#586887]",children:[e.jsx(Ue,{size:13,className:"text-[#8697b8]"}),e.jsx("span",{className:"truncate max-w-[120px]",children:t.name})]}),r&&e.jsx(F,{tone:"gold",children:B((o=t.amenity)==null?void 0:o.charge)}),e.jsx(y,{size:"sm",variant:"danger",onClick:s,children:"Cancel"})]})}function Zl({open:t,societyId:s,amenity:n,onClose:i,onSaved:r}
126){const l=!!n,[c,x]=a.useState(""),[o,m]=a.useState("clubhouse"),[d,u]=a.useState(""),[b,g]=a.useState("06:00"),[v,f]=a.useState("22:00"),[h,w]=a.useState(!1),[z,p]=a.useState(""),[j,E]=a.useState(""),[R,N]=a.useState(!1),[$,S]=a.useState("");a.useEffect(()=>{t&&(x((n==null?void 0:n.name)||""),m((n==null?void 0:n.type)||"clubhouse"),u((n==null?void 0:n.capacity)!=null?String(n.capacity):""),g((n==null?void 0:n.openTime)||"06:00"),f((n==null?void 0:n.closeTime)||"22:00"),w(!!(n!=null&&n.chargeable)),p((n==null?void 0:n.charge)!=null?String(n.charge):""),E((n==null?void 0:n.description)||""),N(!1),S(""))},[t,n]);const A=async()=>{if(!c.trim())return S("Give the facility a name.");N(!0);const M={name:c.trim(),type:o,capacity:d?Number(d):void 0,openTime:b,closeTime:v,chargeable:h,charge:h&&z?Number(z):void 0,description:j.trim()||void 0};try{l?await bs(n._id,M):await _a(s,M),r()}catch{S(`Couldn't ${l?"save":"add"} the facility. Please try again.`),N(!1)}};return e.jsx(q,{open:t,onClose:i,title:l?"Edit facility":"Add facility",footer:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(y,{variant:"ghost",onClick:i,children:"Cancel"}),e.jsx(y,{variant:"navy",onClick:A,disabled:R,children:R?l?"Saving…":"Adding…":l?"Save facility":"Add facility"})]}),children:e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(C,{label:"Name",children:e.jsx("input",{className:k,value:c,onChange:M=>x(M.target.value),placeholder:"e.g. Grand Clubhouse",autoFocus:!0})}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(C,{label:"Type",children:e.jsx("select",{className:k,value:o,onChange:M=>m(M.target.value),children:ql.map(M=>e.jsx("option",{value:M,children:Xe[M].label},M))})}),e.jsx(C,{label:"Capacity",children:e.jsx("input",{className:k,type:"number",min:"0",value:d,onChange:M=>u(M.target.value),placeholder:"e.g. 50"})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(C,{label:"Opens",children:e.jsx("input",{className:k+" tabular-nums",type:"time",value:b,onChange:M=>g(M.target.value)})}),e.jsx(C,{label:"Closes",children:e.jsx("input",{className:k+" tabular-nums",type:"time",value:v,onChange:M=>f(M.target.value)})})]}),e.jsxs("div",{children:[e.jsx("span",{className:"mb-1 block text-[11px] font-bold uppercase tracking-[0.08em] text-[#8493b4]",children:"Charges"}),e.jsxs("button",{onClick:()=>w(M=>!M),className:"inline-flex h-9 items-center gap-2 rounded-lg border px-3 text-[12.5px] font-bold transition "+(h?"border-[#c98a00] bg-[#fdf3dd] text-[#c98a00]":"border-[#d6deec] bg-white text-[#586887] hover:bg-[#f2f5fc]"),children:[e.jsx("span",{className:"grid h-4 w-4 place-items-center rounded-[4px] border "+(h?"border-[#c98a00] bg-[#c98a00] text-white":"border-[#c4cddd] bg-white"),children:h&&e.jsx(Ae,{size:11})}),"Chargeable facility"]})]}),h&&e.jsx(C,{label:"Charge per booking",hint:"Amount residents pay for each slot.",children:e.jsx("input",{className:k+" tabular-nums",type:"number",min:"0",value:z,onChange:M=>p(M.target.value),placeholder:"e.g. 500"})}),e.jsx(C,{label:"Description",children:e.jsx("textarea",{className:k+" h-auto py-2 leading-relaxed",rows:3,value:j,onChange:M=>E(M.target.value),placeholder:"Rules, notes or a short description…"})}),$&&e.jsx("p",{className:"text-[12.5px] font-semibold text-[#d63a3a]",children:$})]})})}function ei({amenity:t,societyId:s,onClose:n,onBooked:i}){var A,M;const[r,l]=a.useState(""),[c,x]=a.useState(ut()),[o,m]=a.useState(null),[d,u]=a.useState(null),[b,g]=a.useState(""),[v,f]=a.useState(!1),[h,w]=a.useState("");if(a.useEffect(()=>{t&&(l(""),x(ut()),g(""),f(!1),w(""),u(null))},[t]),a.useEffect(()=>{t&&(m(null),u(null),Ut(s,t._id,c).then(_=>m((_==null?void 0:_.slots)||[])).catch(()=>m([])))},[t,s,c]),!t)return null;const z=_t(t.type),p=z.icon,j=o||[],E=_=>{var D;(D=j[_])!=null&&D.available&&(w(""),u(H=>{var V;if(!H)return{a:_,b:_};if(H.a===H.b){const J=Math.min(H.a,_),L=Math.max(H.a,_);for(let Z=J;Z<=L;Z++)if(!((V=j[Z])!=null&&V.available))return{a:_,b:_};return{a:J,b:L}}return{a:_,b:_}}))},R=d?(A=j[d.a])==null?void 0:A.start:null,N=d?(M=j[d.b])==null?void 0:M.end:null,$=d?d.b-d.a+1:0,S=async()=>{var _;if(!r.trim())return w("Enter the resident's name.");if(!d||!R||!N)return w("Pick an available slot.");f(!0),w("");try{await Da(s,{amenityId:t._id,name:r.trim(),date:c,start:R,end:N,notes:b.trim()||void 0}),i()}catch(D){((_=D==null?void 0:D.response)==null?void 0:_.status)===409?(w("That slot was just taken. Pick another."),Ut(s,t._id,c).then(H=>m((H==null?void 0:H.slots)||[])),u(null)):w("Couldn't create the booking. Please try again."),f(!1)}};return e.jsxs(q,{open:!!t,onClose:n,title:"New booking",footer:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(y,{variant:"ghost",onClick:n,children:"Cancel"}),e.jsx(y,{variant:"navy",onClick:S,disabled:v,children:v?"Booking…":"Confirm booking"})]}),children:[e.jsxs("div",{className:"mb-4 flex items-center gap-3 rounded-xl bg-[#f4f7fc] px-4 py-3",children:[e.jsx("span",{className:"grid h-10 w-10 shrink-0 place-items-center rounded-lg",style:{background:z.color+"15",color:z.color},children:e.jsx(p,{size:18})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate text-[14px] font-extrabold text-[#0f2547]",children:t.name}),e.jsxs("div",{className:"text-[12px] text-[#586887]",children:[z.label,t.openTime||t.closeTime?` · ${Se(t.openTime)} – ${Se(t.closeTime)}`:""]})]}),e.jsx(F,{tone:t.chargeable?"gold":"slate",children:t.chargeable?B(t.charge):"Free"})]}),e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(C,{label:"Resident name",children:e.jsx("input",{className:k,value:r,onChange:_=>l(_.target.value),placeholder:"Who's booking this?",autoFocus:!0})}),e.jsx(C,{label:"Date",children:e.jsx("input",{className:k+" tabular-nums",type:"date",min:ut(),value:c,onChange:_=>x(_.target.value)})}),e.jsxs("div",{children:[e.jsxs("div",{className:"mb-1.5 flex items-center justify-between",children:[e.jsx("span",{className:"text-[11px] font-bold uppercase tracking-[0.08em] text-[#8493b4]",children:"Available slots"}),e.jsx("span",{className:"text-[10.5px] text-[#a7b3cd]",children:d?`${R}–${N} · ${$} hr${$>1?"s":""}`:"tap start, then end"})]}),o===null?e.jsxs("div",{className:"flex items-center justify-center gap-2 py-8 text-[12.5px] font-semibold text-[#586887]",children:[e.jsx(ne,{size:15,className:"animate-spin text-[#1c4b93]"})," Checking availability…"]}):j.length===0?e.jsx("div",{className:"rounded-xl bg-[#f7f9fd] px-4 py-6 text-center text-[12.5px] text-[#8697b8]",children:"No slots for this day."}):e.jsx("div",{className:"grid grid-cols-4 gap-1.5 min-[520px]:grid-cols-6",children:j.map((_,D)=>{const H=d&&D>=d.a&&D<=d.b,V=!_.available;return e.jsx("button",{type:"button",onClick:()=>E(D),disabled:V,title:_.booked?"Already booked":_.past?"Past":"Available",className:"h-9 rounded-lg border text-[11.5px] font-bold tabular-nums transition "+(H?"border-[#1c4b93] bg-gradient-to-br from-[#153568] to-[#1c4b93] text-white":V?"cursor-not-allowed border-[#eef1f7] bg-[#f4f6fb] text-[#c4cddd] line-through":"border-[#d6deec] bg-white text-[#153568] hover:bg-[#eef3fb]"),children:_.start},_.start)})})]}),e.jsx(C,{label:"Notes",children:e.jsx("textarea",{className:k+" h-auto py-2 leading-relaxed",rows:2,value:b,onChange:_=>g(_.target.value),placeholder:"Anything the manager should know…"})}),h&&e.jsx("p",{className:"text-[12.5px] font-semibold text-[#d63a3a]",children:h})]})]})}function ti(){return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mb-5 grid grid-cols-2 gap-3.5 lg:grid-cols-4",children:[0,1,2,3].map(t=>e.jsx("div",{className:T+" h-[112px] animate-pulse"},t))}),e.jsx("div",{className:"grid grid-cols-1 gap-3.5 sm:grid-cols-2 lg:grid-cols-3",children:[0,1,2,3,4,5].map(t=>e.jsx("div",{className:T+" h-[220px] animate-pulse"},t))}),e.jsx("div",{className:T+" mt-5 h-[240px] animate-pulse"})]})}
126const yt={notice:{label:"Notice",tone:"navy",icon:ea,hex:"#1c4b93"},event:{label:"Event",tone:"gold",icon:bn,hex:"#c98a00"},maintenance:{label:"Maintenance",tone:"amber",icon:Oe,hex:"#c77812"},emergency:{label:"Emergency",tone:"red",icon:Jn,hex:"#d63a3a"}},si=["notice","event","maintenance","emergency"],Gs={all:"All residents",owners:"Owners",tenants:"Tenants",committee:"Committee"},ai=["all","owners","tenants","committee"],ni=[{key:"all",label:"All"},{key:"notice",label:"Notice"},{key:"event",label:"Event"},{key:"maintenance",label:"Maintenance"},{key:"emergency",label:"Emergency"}];function li({societyId:t}){const[s,n]=a.useState(null),[i,r]=a.useState(!1),[l,c]=a.useState("all"),[x,o]=a.useState(!1),m=()=>{n(null),r(!1),La(t).then(n).catch(()=>r(!0))};a.useEffect(m,[t]);const d=a.useMemo(()=>(s||[]).filter(u=>l==="all"||u.category===l),[s,l]);return e.jsxs(e.Fragment,{children:[e.jsx(ze,{title:"Communication",sub:"Post notices and announcements to residents.",right:e.jsx(y,{variant:"navy",icon:e.jsx(ae,{size:15}),onClick:()=>o(!0),children:"New announcement"})}),i?e.jsx("div",{className:T,children:e.jsx(Q,{icon:e.jsx(te,{size:26}),title:"Couldn't load announcements",sub:"Check your connection and try again.",cta:"Retry",onCta:m})}):s?s.length===0?e.jsx("div",{className:T,children:e.jsx(Q,{icon:e.jsx(De,{size:26}),title:"No announcements yet",sub:"Post your first notice to keep residents informed.",cta:"New announcement",onCta:()=>o(!0)})}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mb-4 flex flex-wrap gap-2",children:ni.map(u=>{const b=l===u.key,g=u.key==="all"?s.length:s.filter(v=>v.category===u.key).length;return e.jsxs("button",{onClick:()=>c(u.key),className:"inline-flex items-center gap-1.5 rounded-lg border px-3 py-1.5 text-[12.5px] font-bold transition "+(b?"border-[#1c4b93] bg-[#eef3fb] text-[#1c4b93]":"border-[#d6deec] bg-white text-[#586887] hover:bg-[#f2f5fc]"),children:[u.label,e.jsx("span",{className:"rounded-md px-1.5 text-[10.5px] tabular-nums "+(b?"bg-[#dbe7fa] text-[#1c4b93]":"bg-[#eef1f7] text-[#8697b8]"),children:g})]},u.key)})}),d.length===0?e.jsx("div",{className:T,children:e.jsx(Q,{icon:e.jsx(De,{size:26}),title:"Nothing in this category",sub:"Try a different filter or post a new announcement."})}):e.jsx("div",{className:"flex flex-col gap-3.5",children:d.map(u=>e.jsx(ii,{a:u,onChanged:m},u._id))})]}):e.jsx(ci,{}),e.jsx(ri,{open:x,societyId:t,onClose:()=>o(!1),onCreated:()=>{o(!1),m()}})]})}function ii({a:t,onChanged:s}){const n=yt[t.category]||yt.notice,i=n.icon,[r,l]=a.useState(!1),[c,x]=a.useState(!1),[o,m]=a.useState(!1),d=async()=>{l(!0);try{await $a(t._id),s()}catch{l(!1)}},u=async()=>{m(!0);try{await Fa(t._id),s()}catch{m(!1),x(!1)}};return e.jsx("div",{className:T+" p-4 sm:p-5"+(t.pinned?" border-l-[3px] border-l-[#c98a00] ring-1 ring-[#f2dfa8]":""),children:e.jsxs("div",{className:"flex gap-3.5",children:[e.jsx("span",{className:"grid h-11 w-11 shrink-0 place-items-center rounded-xl",style:{background:n.hex+"16",color:n.hex},children:e.jsx(i,{size:19})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(F,{tone:n.tone,dot:!0,children:n.label}),e.jsx(F,{tone:"slate",children:Gs[t.audience]||t.audience}),t.pinned&&e.jsxs(F,{tone:"gold",children:[e.jsx(jt,{size:11})," Pinned"]})]}),e.jsx("h3",{className:"mt-2.5 text-[15px] font-extrabold leading-snug text-[#153568]",children:t.title}),t.body&&e.jsx("p",{className:"mt-1.5 whitespace-pre-line text-[13.5px] leading-relaxed text-[#586887]",children:t.body}),e.jsxs("div",{className:"mt-3 text-[11.5px] text-[#8697b8]",children:["Posted by"," ",e.jsx("span",{className:"font-bold text-[#5b6b8a]",children:t.postedByName||"—"})," · ",se(t.createdAt)]}),e.jsx("div",{className:"mt-3.5 flex items-center gap-2",children:c?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[12px] font-bold text-[#d63a3a]",children:"Delete this announcement?"}),e.jsx(y,{size:"sm",variant:"danger",onClick:u,disabled:o,children:o?"Deleting…":"Confirm"}),e.jsx(y,{size:"sm",variant:"ghost",onClick:()=>x(!1),children:"Cancel"})]}):e.jsxs(e.Fragment,{children:[e.jsx(y,{size:"sm",variant:"outline",icon:t.pinned?e.jsx(Kn,{size:13}):e.jsx(jt,{size:13}),onClick:d,disabled:r,children:t.pinned?"Unpin":"Pin"}),e.jsx(y,{size:"sm",variant:"danger",icon:e.jsx(be,{size:13}),onClick:()=>x(!0),children:"Delete"})]})})]})]})})}function ri({open:t,societyId:s,onClose:n,onCreated:i}
126){const[r,l]=a.useState(""),[c,x]=a.useState("notice"),[o,m]=a.useState("all"),[d,u]=a.useState(""),[b,g]=a.useState(!1),[v,f]=a.useState(!1),[h,w]=a.useState("");a.useEffect(()=>{t&&(l(""),x("notice"),m("all"),u(""),g(!1),f(!1),w(""))},[t]);const z=async()=>{if(!r.trim())return w("Enter a title for the announcement.");f(!0);try{await Oa(s,{title:r.trim(),body:d.trim(),category:c,audience:o,pinned:b}),i()}catch{w("Couldn't post the announcement. Please try again."),f(!1)}};return e.jsx(q,{open:t,onClose:n,title:"New announcement",width:480,footer:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(y,{variant:"ghost",onClick:n,children:"Cancel"}),e.jsx(y,{variant:"navy",icon:e.jsx(De,{size:14}),onClick:z,disabled:v,children:v?"Posting…":"Post announcement"})]}),children:e.jsxs("div",{className:"flex flex-col gap-3.5",children:[e.jsx(C,{label:"Title",children:e.jsx("input",{className:k,value:r,onChange:p=>l(p.target.value),placeholder:"e.g. Water supply interrupted on Sunday",autoFocus:!0})}),e.jsxs("div",{children:[e.jsx("span",{className:"mb-1 block text-[11px] font-bold uppercase tracking-[0.08em] text-[#8493b4]",children:"Category"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:si.map(p=>{const j=yt[p],E=j.icon,R=c===p;return e.jsxs("button",{onClick:()=>x(p),className:"inline-flex items-center gap-1.5 rounded-lg border px-3 py-2 text-[12.5px] font-bold transition",style:R?{borderColor:j.hex,background:j.hex+"14",color:j.hex}:{borderColor:"#d6deec",background:"#fff",color:"#586887"},children:[e.jsx(E,{size:14}),j.label]},p)})})]}),e.jsx(C,{label:"Audience",children:e.jsx("select",{className:k,value:o,onChange:p=>m(p.target.value),children:ai.map(p=>e.jsx("option",{value:p,children:Gs[p]},p))})}),e.jsx(C,{label:"Message",children:e.jsx("textarea",{className:k+" min-h-[110px] py-2",value:d,onChange:p=>u(p.target.value),placeholder:"Write the details residents need to know…"})}),e.jsxs("button",{onClick:()=>g(p=>!p),className:"inline-flex w-fit items-center gap-1.5 rounded-lg border px-3 py-2 text-[12.5px] font-bold transition "+(b?"border-[#c98a00] bg-[#fdf3dd] text-[#c98a00]":"border-[#d6deec] bg-white text-[#586887] hover:bg-[#f2f5fc]"),children:[e.jsx(jt,{size:14}),b?"Pinned to top":"Pin to top"]}),h&&e.jsx("p",{className:"text-[12.5px] font-semibold text-[#d63a3a]",children:h})]})})}function ci(){return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mb-4 flex gap-2",children:[0,1,2,3,4].map(t=>e.jsx("div",{className:"h-9 w-20 animate-pulse rounded-lg bg-[#eef1f7]"},t))}),e.jsx("div",{className:"flex flex-col gap-3.5",children:[0,1,2].map(t=>e.jsx("div",{className:T+" h-[150px] animate-pulse"},t))})]})}function oi({societyId:t,linkedProperty:s,reload:n}){const[i,r]=a.useState(null),[l,c]=a.useState(!1),x=s,o=async()=>{c(!0);try{await Ia(t),n()}finally{c(!1)}},m=d=>window.open(`/properties/listings?list=${x._id}&for=${d}`,"_blank","noopener");return e.jsxs("div",{className:T+" mt-4",children:[e.jsx(X,{icon:e.jsx(ct,{size:15}),title:"Property & marketplace"}),e.jsx("div",{className:"px-4 py-4",children:x?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"grid h-10 w-10 shrink-0 place-items-center rounded-xl bg-[#eef3fb] text-[#1c4b93]",children:e.jsx(ct,{size:18})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate text-[13.5px] font-extrabold text-[#0f2547]",children:x.name}),x.hasGeo&&e.jsxs("span",{className:"inline-flex items-center gap-0.5 text-[10px] font-bold text-[#15964f]",children:[e.jsx(Ke,{size:11})," mapped"]})]}),e.jsx("div",{className:"mt-0.5 text-[11.5px] text-[#8493b4]",children:"Linked property record"})]}),x.listed&&e.jsxs(F,{tone:"gold",children:["Listed · ",x.listedFor||"sale"]})]}),x.listed?e.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[e.jsxs("a",{href:"/properties/listings",target:"_blank",rel:"noopener noreferrer",className:"inline-flex h-8 items-center gap-1.5 rounded-lg border border-[#d6deec] bg-white px-3 text-[12.5px] font-extrabold text-[#153568] hover:bg-[#f2f5fc]",children:[e.jsx(ys,{size:13})," Manage on Listings"]}),e.jsx(y,{variant:"danger",size:"sm",onClick:o,disabled:l,children:l?"…":"Remove listing"})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"mt-3 text-[12px] text-[#586887]",children:"Put this property on the JaaGa marketplace. You'll enter the full listing details (photos, price, amenities) in the Listings flow."}),e.jsxs("div",{className:"mt-2 flex flex-wrap gap-2",children:[e.jsx(y,{variant:"gold",size:"sm",icon:e.jsx(Ne,{size:14}),onClick:()=>m("sell"),children:"List for sale"}),e.jsx(y,{variant:"outline",size:"sm",icon:e.jsx(Ne,{size:14}),onClick:()=>m("rent"),children:"List for rent"})]})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-[12.5px] text-[#586887]",children:"Link this society to a property record — the same one that powers My-Properties and Listings. It gives the society a map location and lets you list it on the marketplace."}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsx(y,{variant:"navy",size:"sm",icon:e.jsx(ct,{size:14}),onClick:()=>
126r("link"),children:"Choose an existing property"}),e.jsx(y,{variant:"outline",size:"sm",icon:e.jsx(Ke,{size:14}),onClick:()=>r("create"),children:"Add on the map"})]})]})}),i==="link"&&e.jsx(js,{title:"Link a property",subtitle:"Choose a property to link to this society",fetchPage:gs,onPick:async d=>{await Ua(t,d._id),r(null),n()},onClose:()=>r(null)}),i==="create"&&e.jsx(xi,{societyId:t,onClose:()=>r(null),onDone:()=>{r(null),n()}})]})}function di({title:t,onClose:s,children:n,footer:i,width:r=480}){return wt.createPortal(e.jsx("div",{onClick:s,className:"fixed inset-0 z-[1550] flex items-end justify-center bg-[#0a1932]/50 p-0 backdrop-blur-[2px] sm:items-center sm:p-4",children:e.jsxs("div",{onClick:l=>l.stopPropagation(),className:"flex max-h-[92vh] w-full flex-col overflow-hidden rounded-t-2xl border border-[#e6eaf3] bg-white sm:rounded-2xl",style:{maxWidth:r},children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-[#eef1f7] px-5 py-3.5",children:[e.jsx("h3",{className:"text-[16px] font-extrabold text-[#0f2547]",children:t}),e.jsx("button",{onClick:s,className:"grid h-8 w-8 place-items-center rounded-lg border border-[#e6eaf3] text-[#586887] hover:bg-[#f2f5fc]",children:e.jsx(kt,{size:16})})]}),e.jsx("div",{className:"flex flex-col gap-3 overflow-y-auto px-5 py-4",children:n}),e.jsx("div",{className:"flex justify-end gap-2 border-t border-[#eef1f7] px-5 py-3",children:i})]})}),document.body)}function xi({societyId:t,onClose:s,onDone:n}){const[i,r]=a.useState(null),[l,c]=a.useState({address:"",city:"",state:"",pincode:""}),[x,o]=a.useState(!1),[m,d]=a.useState(""),u=(v,f)=>{r({lat:v,lng:f}),Rn(v,f).then(h=>{h&&c(w=>({...w,address:h.addressLine1||w.address,city:h.city||w.city,state:h.state||w.state,pincode:h.pincode||w.pincode}))}).catch(()=>{})},b=()=>{if(!navigator.geolocation)return d("Location unavailable — drop the pin instead.");navigator.geolocation.getCurrentPosition(v=>u(v.coords.latitude,v.coords.longitude),()=>d("Couldn't get location — drop the pin."))},g=async()=>{var v,f,h;if(!i)return d("Pin the location on the map.");o(!0);try{await Ga(t,{...l,lat:i.lat,lng:i.lng}),n()}catch(w){d(((h=(f=(v=w==null?void 0:w.response)==null?void 0:v.data)==null?void 0:f.status)==null?void 0:h.message)||"Couldn't create the property. Try again."),o(!1)}};return e.jsxs(di,{title:"Add a property on the map",onClose:s,footer:e.jsxs(e.Fragment,{children:[e.jsx(y,{variant:"ghost",onClick:s,children:"Cancel"}),e.jsx(y,{variant:"navy",onClick:g,disabled:x,children:x?"Creating…":"Create & link"})]}),children:[e.jsxs("div",{className:"mb-1 flex items-center justify-between",children:[e.jsx("span",{className:"text-[11px] font-bold uppercase tracking-[0.08em] text-[#8493b4]",children:"Location — drop a pin"}),e.jsxs("button",{type:"button",onClick:b,className:"inline-flex items-center gap-1 text-[11px] font-bold text-[#1c4b93] hover:underline",children:[e.jsx(Ke,{size:11})," Use my location"]})]}),e.jsx("div",{className:"h-[220px] overflow-hidden rounded-xl border border-[#e6eaf3]",children:e.jsx(An,{className:"h-full w-full",position:i,onPick:u,showCoordinates:!1,zoom:13})}),e.jsx("div",{className:"text-[11px] text-[#8493b4]",children:i?e.jsxs("span",{className:"font-bold text-[#15964f]",children:["Pinned · ",i.lat.toFixed(5),", ",i.lng.toFixed(5)]}):"Tap the map — the address fills in automatically."}),e.jsx(C,{label:"Address",children:e.jsx("input",{className:k,value:l.address,onChange:v=>c({...l,address:v.target.value})})}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsx(C,{label:"City",children:e.jsx("input",{className:k,value:l.city,onChange:v=>c({...l,city:v.target.value})})}),e.jsx(C,{label:"State",children:e.jsx("input",{className:k,value:l.state,onChange:v=>c({...l,state:v.target.value})})}),e.jsx(C,{label:"PIN",children:e.jsx("input",{className:k,value:l.pincode,onChange:v=>c({...l,pincode:v.target.value})})})]}),m&&e.jsx("p",{className:"text-[12.5px] font-semibold text-[#d63a3a]",children:m})]})}const ve=[{id:"greatvibes",family:"Great Vibes"},{id:"alexbrush",family:"Alex Brush"},{id:"allura",family:"Allura"},{id:"mrdafoe",family:"Mr Dafoe"},{id:"herrvon",family:"Herr Von Muellerhoff"},{id:"sacramento",family:"Sacramento"}],mi="https://fonts.googleapis.com/css2?family=Great+Vibes&family=Alex+Brush&family=Allura&fam
126ily=Mr+Dafoe&family=Herr+Von+Muellerhoff&family=Sacramento&display=swap";function ui({societyId:t,signatory:s,reload:n}){const i=!!(s!=null&&s.url),[r,l]=a.useState(!i),[c,x]=a.useState("draw"),[o,m]=a.useState((s==null?void 0:s.name)||""),[d,u]=a.useState((s==null?void 0:s.designation)||""),[b,g]=a.useState(null),[v,f]=a.useState((s==null?void 0:s.name)||""),[h,w]=a.useState(ve[0].id),[z,p]=a.useState(!1),[j,E]=a.useState(""),R=a.useRef(null),N=a.useRef(!1),$=a.useRef(!1);a.useEffect(()=>{const P="jg-sign-fonts";if(!document.getElementById(P)){const O=document.createElement("link");O.id=P,O.rel="stylesheet",O.href=mi,document.head.appendChild(O)}document.fonts&&document.fonts.load&&ve.forEach(O=>document.fonts.load(`48px "${O.family}"`).catch(()=>{}))},[]),a.useEffect(()=>{if(!r||c!=="draw")return;const P=R.current;if(!P)return;const O=window.devicePixelRatio||1,K=P.getBoundingClientRect();P.width=K.width*O,P.height=K.height*O;const W=P.getContext("2d");W.scale(O,O),W.lineWidth=2.2,W.lineCap="round",W.lineJoin="round",W.strokeStyle="#0f2547",$.current=!1},[r,c]);const S=P=>{const K=R.current.getBoundingClientRect(),W=P.touches?P.touches[0]:P;return{x:W.clientX-K.left,y:W.clientY-K.top}},A=P=>{P.preventDefault(),N.current=!0;const O=R.current.getContext("2d"),{x:K,y:W}=S(P);O.beginPath(),O.moveTo(K,W)},M=P=>{if(!N.current)return;P.preventDefault();const O=R.current.getContext("2d"),{x:K,y:W}=S(P);O.lineTo(K,W),O.stroke(),$.current=!0},_=()=>{N.current=!1},D=()=>{const P=R.current;P&&(P.getContext("2d").clearRect(0,0,P.width,P.height),$.current=!1)},H=P=>{var K;const O=(K=P.target.files)==null?void 0:K[0];if(O){if(!/^image\//.test(O.type))return E("Please choose an image (PNG/JPG).");E(""),g({blob:O,url:URL.createObjectURL(O)})}},V=()=>new Promise(P=>R.current.toBlob(O=>P(O),"image/png")),J=async()=>{const P=ve.find(ge=>ge.id===h)||ve[0],O=(v||"").trim();if(!O)return null;try{await document.fonts.load(`64px "${P.family}"`)}catch{}const K=window.devicePixelRatio||1,W=500,U=160,le=document.createElement("canvas");le.width=W*K,le.height=U*K;const ee=le.getContext("2d");ee.scale(K,K),ee.fillStyle="#0f2547",ee.textAlign="center",ee.textBaseline="middle";let ie=76;const nt=W-44;for(ee.font=`${ie}px "${P.family}", cursive`;ie>20&&ee.measureText(O).width>nt;)ie-=2,ee.font=`${ie}px "${P.family}", cursive`;return ee.fillText(O,W/2,U/2+4),new Promise(ge=>le.toBlob(Re=>ge(Re),"image/png"))},L=async()=>{var O,K,W;E("");let P=null;if(c==="draw"){if(!$.current)return E("Draw your signature first.");P=await V()}else if(c==="type"){if(!v.trim())return E("Type your name for the signature.");P=await J()}else{if(!(b!=null&&b.blob))return E("Choose a signature image.");P=b.blob}if(!P)return E("Couldn't read the signature. Try again.");p(!0);try{await Ha(t,P,{name:o.trim(),designation:d.trim()}),g(null),l(!1),n()}catch(U){E(((W=(K=(O=U==null?void 0:U.response)==null?void 0:O.data)==null?void 0:K.status)==null?void 0:W.message)||"Couldn't save the signature. Try again.")}finally{p(!1)}},Z=async()=>{p(!0);try{await Va(t),m(""),u(""),l(!0),n()}finally{p(!1)}};return e.jsxs("div",{className:T+" mt-4",children:[e.jsx("style",{children:".jg-sign-ff{font-family:var(--jg-ff),'Snell Roundhand','Apple Chancery',cursive !important}"}),e.jsx(X,{icon:e.jsx(Vt,{size:15}),title:"Authorized signatory",children:i&&!r&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] font-bold text-[#15964f]",children:[e.jsx(Me,{size:12})," On receipts"]})}),e.jsxs("div",{className:"px-4 py-4",children:[e.jsx("p",{className:"text-[12.5px] leading-relaxed text-[#586887]",children:"Add a committee member's signature — it's stamped on rent & maintenance receipts you issue."}),i&&!r?e.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-4",children:[e.jsx("div",{className:"rounded-xl border border-[#e6eaf3] bg-white p-2",children:e.jsx("img",{src:s.url,alt:"Signature",className:"h-16 w-auto max-w-[240px] object-contain"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[13.5px] font-extrabold text-[#0f2547]",children:s.name||"—"}),e.jsx("div",{className:"text-[11.5px] text-[#8493b4]",children:s.designation||"Authorized signatory"}),e.jsxs("div",{className:"mt-2 flex gap-2",children:[e.jsx(y,{variant:"outline",size:"sm",icon:e.jsx(Tn,{size:13}),onClick:()=>l(!0),children:"Replace"}),e.jsx(y,{variant:"danger",size:"sm",icon:e.jsx(be,{size:13}),onClick:Z,disabled:z,children:"Remove"})]})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mt-3 flex gap-2",children:[["draw","Draw",Vt],["type","Type",Xn],["upload","Upload image",gt]].map(([P,O,K])=>e.jsxs("button",{type:"button",onClick:()=>x(P),className:"inline-flex h-8 items-center gap-1.5 rounded-lg border px-3 text-[12px] font-bold transition "+(c===P?"border-[#1c4b93] bg-[#eef3fb] text-[#1c4b93]":"border-[#d6deec] bg-white text-[#586887] hover:bg-[#f2f5fc]"),children:[e.jsx(K,{size:13})," ",O]},P))}),c==="draw"?e.jsx("div",{className:"mt-3",children:e.jsxs("div",{className:"relative overflow-hidden rounded-xl border border-dashed border-[#c9d6ef] bg-[#fbfcfe]",children:[e.jsx("canvas",{ref:R,className:"block h-[150px] w-full touch-none",onMouseDown:A,onMouseMove:M,onMouseUp:_,onMouseLeave:_,onTouchStart:A,onTouchMove:M,onTouchEnd:_}),e.jsx("span",{className:"pointer-events-none absolute bottom-2 left-3 text-[10.5px] text-[#b3c0d8]",children:"Sign inside the box"}),e.jsx("button",{type:"button",onClick:D,className:"absolute right-2 top-2 inline-flex h-7 items-center gap-1 rounded-lg border border-[#d6deec] bg-white px-2 text-[11px] font-bold text-[#586887] hover:bg-[#f2f5fc]",children:"Clear"})]})}):c==="type"?e.jsxs("div",{className:"mt-3",children:[e.jsx("input",{className:k,value:v,onCh
126ange:P=>f(P.target.value),placeholder:"Type your name",maxLength:40}),e.jsx("div",{className:"mt-2.5 flex flex-wrap gap-1.5",children:ve.map(P=>{const O=h===P.id;return e.jsx("button",{type:"button",onClick:()=>w(P.id),className:"jg-sign-ff inline-flex h-9 items-center overflow-hidden rounded-lg border px-3 leading-none transition "+(O?"border-[#1c4b93] bg-[#eef3fb] ring-1 ring-[#1c4b93]":"border-[#d6deec] bg-white hover:bg-[#f7f9fd]"),style:{"--jg-ff":`"${P.family}"`,fontSize:"22px",color:"#0f2547"},title:P.family,children:"Abc"},P.id)})}),e.jsx("div",{className:"mt-2.5 flex h-[110px] items-center justify-center rounded-xl border border-dashed border-[#c9d6ef] bg-[#fbfcfe]",children:e.jsx("span",{className:"jg-sign-ff truncate px-4",style:{"--jg-ff":`"${(ve.find(P=>P.id===h)||ve[0]).family}"`,fontSize:"52px",color:"#0f2547"},children:v.trim()||"Signature"})})]}):e.jsx("div",{className:"mt-3",children:e.jsxs("label",{className:"flex h-[150px] w-full cursor-pointer flex-col items-center justify-center gap-2 rounded-xl border-2 border-dashed border-[#c9d6ef] bg-[#fbfcfe] text-[#1c4b93] transition hover:border-[#1c4b93] hover:bg-[#f4f7fc]",children:[b?e.jsx("img",{src:b.url,alt:"Signature",className:"h-[120px] w-auto max-w-[90%] object-contain"}):e.jsxs(e.Fragment,{children:[e.jsx(gt,{size:20}),e.jsx("span",{className:"text-[12.5px] font-bold",children:"Choose a PNG/JPG of your signature"})]}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:H})]})}),e.jsxs("div",{className:"mt-3 grid grid-cols-1 gap-3 sm:grid-cols-2",children:[e.jsx(C,{label:"Signatory name",children:e.jsx("input",{className:k,value:o,onChange:P=>m(P.target.value),placeholder:"e.g. Ramesh Rao"})}),e.jsx(C,{label:"Designation",children:e.jsx("input",{className:k,value:d,onChange:P=>u(P.target.value),placeholder:"e.g. Secretary, RWA"})})]}),j&&e.jsx("p",{className:"mt-2 text-[12.5px] font-semibold text-[#d63a3a]",children:j}),e.jsxs("div",{className:"mt-3 flex gap-2",children:[e.jsx(y,{variant:"navy",size:"sm",onClick:L,disabled:z,icon:z?e.jsx(ne,{size:13,className:"animate-spin"}):e.jsx(Me,{size:14}),children:z?"Saving…":"Save signature"}),i&&e.jsx(y,{variant:"ghost",size:"sm",onClick:()=>{l(!1),g(null),E("")},children:"Cancel"})]})]})]})]})}function pi({societyId:t}){const[s,n]=a.useState(null),[i,r]=a.useState(""),[l,c]=a.useState(""),[x,o]=a.useState(""),[m,d]=a.useState(null),[u,b]=a.useState(!1),[g,v]=a.useState(""),[f,h]=a.useState(!1),w=()=>{Rt(t).then(N=>{const $=N||{};n($),r($.upiId||""),c($.payeeName||""),o($.note||"")}).catch(()=>n({enabled:!1}))};a.useEffect(w,[t]);const z=async N=>{var S,A,M,_;const $=(S=N.target.files)==null?void 0:S[0];if($){if(!/^image\//.test($.type))return v("Please choose an image (PNG/JPG).");v(""),b(!0);try{const D=await Ka(t,$);n(D),d(null)}catch(D){v(((_=(M=(A=D==null?void 0:D.response)==null?void 0:A.data)==null?void 0:M.status)==null?void 0:_.message)||"Couldn't upload the QR. Try again.")}finally{b(!1)}}},p=async N=>{var $,S,A;v(""),b(!0);try{const M=await Wa(t,{upiId:i.trim(),payeeName:l.trim(),note:x.trim(),...N});n(M),r(M.upiId||""),h(!0),setTimeout(()=>h(!1),1800)}catch(M){v(((A=(S=($=M==null?void 0:M.response)==null?void 0:$.data)==null?void 0:S.status)==null?void 0:A.message)||"Couldn't save. Check the UPI id and try again.")}finally{b(!1)}},j=async()=>{b(!0);try{const N=await Ya(t);n(N)}finally{b(!1)}},E=async()=>{await p({enabled:!(s!=null&&s.enabled)})},R=(m==null?void 0:m.url)||(s==null?void 0:s.qrUrl);return e.jsxs("div",{className:T+" mt-4",children:[e.jsx(X,{icon:e.jsx(Le,{size:15}),title:"UPI / QR collection",children:s!=null&&s.enabled?e.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] font-bold text-[#15964f]",children:[e.jsx(Me,{size:12})," Live for residents"]}):e.jsx("span",{className:"text-[11px] font-bold text-[#8493b4]",children:"Off"})}),e.jsxs("div",{className:"px-4 py-4",children:[e.jsx("p",{className:"text-[12.5px] leading-relaxed text-[#586887]",children:"Let residents pay dues directly to your UPI. They scan the QR (or copy the UPI id), pay from their own app, then upload a screenshot as proof — you review it in Billing and approve it into Collected. Money reaches you directly, so JaaGa takes no commission on this method."}),s===null?e.jsxs("div",{className:"mt-4 flex items-center gap-2 text-[13px] text-[#8493b4]",children:[e.jsx(ne,{size:15,className:"animate-spin"})," Loading…"]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mt-4 grid grid-cols-1 gap-4 sm:grid-cols-[180px_1fr]",children:[e.jsxs("div",{children:[e.jsx("span",{className:"mb-1 block text-[11px] font-bold uppercase tracking-[0.08em] text-[#8493b4]",children:"Payment QR"}),R?e.jsxs("div",{className:"relative overflow-hidden rounded-xl border border-[#e6eaf3] bg-white p-2",children:[e.jsx("img",{src:R,alt:"UPI QR",className:"mx-auto h-[150px] w-[150px] object-contain"}),e.jsxs("div",{className:"mt-2 flex gap-2",children:[e.jsxs("label",{className:"inline-flex h-8 flex-1 cursor-pointer items-center justify-center gap-1.5 rounded-lg border border-[#d6deec] bg-white px-2 text-[12px] font-bold text-[#586887] hover:bg-[#f2f5fc]",children:[e.jsx(gt,{size:13})," Replace",e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:z,disabled:u})]}),e.jsx(y,{variant:"danger",size:"sm",icon:e.jsx(be,{size:13}),onClick:j,disabled:u})]})]}):e.jsxs("label",{className:"flex h-[190px] w-full cursor-pointer flex-col items-center justify-center gap-2 rounded-xl border-2 border-dashed border-[#c9d6ef] bg-[#fbfcfe] text-[#1c4b93] transition hover:border-[#1c4b93] hover:bg-[#f4f7fc]",children:[e.jsx(Le,{size:22}),e.jsx("span",{className:"px-3 text-center text-[12px] font-bold",children:"Upload your UPI QR (PNG/JPG)"}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:z,disabled:u})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(C,{label:"UPI ID",hint:"e.g. society@okhdfcbank — residents can copy this to pay",children:e.jsx("input",{className:k,value:i,onChange:N=>r(N.target.value),placeholder:"name@bank",autoCapitalize:"none"})}),e.jsx(C,{label:"Payee name",hint:"Shown to residents as who they are paying",children:e.jsx("input",{className:k,value:l,onCh
126ange:N=>c(N.target.value),placeholder:"e.g. Green Meadows RWA"})}),e.jsx(C,{label:"Note to residents (optional)",children:e.jsx("input",{className:k,value:x,onChange:N=>o(N.target.value),placeholder:"e.g. Add your flat number in the payment remark"})})]})]}),g&&e.jsx("p",{className:"mt-3 text-[12.5px] font-semibold text-[#d63a3a]",children:g}),e.jsxs("div",{className:"mt-4 flex flex-wrap items-center gap-2",children:[e.jsx(y,{variant:"navy",size:"sm",onClick:()=>p({}),disabled:u,icon:u?e.jsx(ne,{size:13,className:"animate-spin"}):f?e.jsx(Me,{size:14}):e.jsx(Me,{size:14}),children:u?"Saving…":f?"Saved":"Save details"}),e.jsx(y,{variant:s!=null&&s.enabled?"danger":"gold",size:"sm",onClick:E,disabled:u,children:s!=null&&s.enabled?"Turn off for residents":"Enable for residents"}),i.trim()&&e.jsxs("button",{type:"button",onClick:()=>{var N;return(N=navigator.clipboard)==null?void 0:N.writeText(i.trim())},className:"inline-flex h-8 items-center gap-1.5 rounded-lg border border-[#d6deec] bg-white px-3 text-[12px] font-bold text-[#586887] hover:bg-[#f2f5fc]",children:[e.jsx(vs,{size:13})," Copy UPI id"]})]}),!(s!=null&&s.enabled)&&e.jsxs("p",{className:"mt-3 flex items-start gap-1.5 text-[11.5px] text-[#8493b4]",children:[e.jsx(Ns,{size:13,className:"mt-px shrink-0"}),"Add a UPI id or a QR, then enable it — residents will see a “Pay via UPI / QR” option on their dues."]})]})]})]})}const hi=["Starter","Growth","Enterprise"],fi=["monthly","quarterly"],bi=["sqft","fixed","bhk"],gi={monthly:"Monthly",quarterly:"Quarterly"},ji={sqft:"Per sq ft",fixed:"Fixed",bhk:"By BHK"},vi=["president","secretary","treasurer","member"],Hs={president:"President",secretary:"Secretary",treasurer:"Treasurer",member:"Member"};function yi(t){return(t||"?").trim().split(/\s+/).slice(0,2).map(s=>s[0]).join("").toUpperCase()}function Ni({societyId:t}){const[s,n]=a.useState(null),[i,r]=a.useState(!1),[l,c]=a.useState(!1),x=()=>{n(null),r(!1),qa(t).then(n).catch(()=>r(!0))};return a.useEffect(x,[t]),e.jsxs(e.Fragment,{children:[e.jsx(ze,{title:"Settings & Roles",sub:"Society profile, billing configuration, and committee."}),i?e.jsx("div",{className:T,children:e.jsx(Q,{icon:e.jsx(te,{size:26}),title:"Couldn't load settings",sub:"Check your connection and try again.",cta:"Retry",onCta:x})}):s?e.jsx(ki,{data:s,reload:x,add:l,setAdd:c,societyId:t}):e.jsx(Li,{})]})}function ki({data:t,reload:s,add:n,setAdd:i,societyId:r}){const{society:l,counts:c,linkedProperty:x}=t,o=l.committee||[],m=l.type==="pg";return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-5 grid grid-cols-3 gap-3.5",children:[m?e.jsxs(e.Fragment,{children:[e.jsx(G,{icon:e.jsx(at,{size:15}),k:"Rooms",v:c.units,accent:"#1c4b93"}),e.jsx(G,{icon:e.jsx(fe,{size:15}),k:"Guests",v:c.members,accent:"#c98a00"})]}):e.jsxs(e.Fragment,{children:[e.jsx(G,{icon:e.jsx(Hn,{size:15}),k:"Towers",v:c.towers,accent:"#1c4b93"}),e.jsx(G,{icon:e.jsx(Pe,{size:15}),k:"Units",v:c.units,accent:"#c98a00"})]}),e.jsx(G,{icon:e.jsx(vt,{size:15}),k:"Committee",v:o.length,accent:"#15964f",vColor:"#15964f",sub:m?"managers":`${c.members} members`})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-4 lg:grid-cols-2",children:[e.jsx(Ci,{society:l,societyId:r,reload:s}),m?e.jsx(Mi,{society:l,societyId:r,reload:s}):e.jsx(Ri,{society:l,societyId:r,reload:s})]}),e.jsx("div",{className:"mt-4",children:e.jsx(zi,{societyId:r})}),e.jsx(pi,{societyId:r}),e.jsx(Ai,{society:l,societyId:r,reload:s}),e.jsx(Pi,{society:l,societyId:r,reload:s}),e.jsx(oi,{societyId:r,linkedProperty:x,reload:s}),e.jsx(ui,{societyId:r,signatory:l.signatory,reload:s}),e.jsx("div",{className:"mt-4",children:e.jsx(Bi,{society:l,committee:o,societyId:r,reload:s,onAdd:()=>i(!0)})}),e.jsx(Di,{open:n,onClose:()=>i(!1),societyId:r,onAdded:()=>{i(!1),s()}})]})}function Ci({society:t,societyId:s,reload:n}){const[i,r]=a.useState(t.name||""),[l,c]=a.useState(t.address||""),[x,o]=a.useState(t.plan||"Starter"),[m,d]=a.useState(t.timezone||"Asia/Kolkata"),[u,b]=a.useState(!1),[g,v]=a.useState(!1),[f,h]=a.useState(""),w=i!==(t.name||"")||l!==(t.address||"")||x!==(t.plan||"Starter")||m!==(t.t
126imezone||"Asia/Kolkata"),z=async()=>{if(!i.trim())return h("Society name is required.");b(!0),h("");try{await Fe(s,{name:i.trim(),address:l,plan:x,timezone:m}),v(!0),setTimeout(()=>v(!1),1800),n()}catch{h("Couldn't save. Please try again.")}finally{b(!1)}};return e.jsxs("div",{className:T,children:[e.jsx(X,{icon:e.jsx(de,{size:15}),title:"Society profile",children:g&&e.jsx(F,{tone:"green",dot:!0,children:"Saved"})}),e.jsxs("div",{className:"flex flex-col gap-3.5 p-4",children:[e.jsx(C,{label:"Name",children:e.jsx("input",{className:k,value:i,onChange:p=>r(p.target.value)})}),e.jsx(C,{label:"Address",children:e.jsx("input",{className:k,value:l,onChange:p=>c(p.target.value),placeholder:"Street, city, PIN"})}),e.jsxs("div",{className:"grid grid-cols-2 gap-3.5",children:[e.jsx(C,{label:"Plan",children:e.jsx("select",{className:k,value:x,onChange:p=>o(p.target.value),children:hi.map(p=>e.jsx("option",{value:p,children:p},p))})}),e.jsx(C,{label:"Timezone",children:e.jsx("input",{className:k,value:m,onChange:p=>d(p.target.value),placeholder:"Asia/Kolkata"})})]}),f&&e.jsx("p",{className:"text-[12.5px] font-semibold text-[#d63a3a]",children:f}),e.jsx("div",{className:"flex items-center justify-end",children:e.jsx(y,{variant:"navy",onClick:z,disabled:u||!w,children:u?"Saving…":"Save changes"})})]})]})}const wi=["savings","current"],Qt="Society/Trust/Clubs/NGO/Association",Xt="Real Estate, Housing, Rentals";function pt({value:t,onChange:s,options:n,fallback:i}){const r=n.length?n:i?[{id:i,value:i}]:[];return e.jsx("select",{className:k,value:t,onChange:l=>s(l.target.value),children:r.map(l=>e.jsx("option",{value:l.value,children:l.value},l.id))})}function Si({status:t,payout:s}){const n={active:{bg:"#e7f4ed",bd:"#cde9d8",fg:"#0c6b39",Icon:ue,title:"Verified",sub:"Settlements will go to this account."},pending:{bg:"#fbefd9",bd:"#f0dfb0",fg:"#8a6a1f",Icon:ne,spin:!0,title:"Verifying…",sub:"Cashfree is verifying your bank & PAN. Refresh in a bit."},failed:{bg:"#fdeaea",bd:"#f0c9c9",fg:"#d63a3a",Icon:te,title:"Verification failed",sub:(s==null?void 0:s.lastError)||"Please check the details and resubmit."},none:{bg:"#eef3fb",bd:"#e6eaf3",fg:"#153568",Icon:$e,title:"No payout account yet",sub:"Add your society's bank account to receive collections directly."}}[t]||{},{bg:i,bd:r,fg:l,Icon:c,spin:x,title:o,sub:m}=n;return e.jsxs("div",{className:"rounded-xl border p-3.5",style:{backgroundColor:i,borderColor:r},children:[e.jsxs("div",{className:"flex items-center gap-2",style:{color:l},children:[c&&e.jsx(c,{size:16,className:x?"animate-spin":""}),e.jsx("span",{className:"text-[13px] font-extrabold",children:o})]}),e.jsx("p",{className:"mt-1 text-[12px] font-medium",style:{color:l,opacity:.85},children:m}),(s==null?void 0:s.accountLast4)&&e.jsxs("div",{className:"mt-2 flex items-center gap-1.5 rounded-lg bg-white/70 px-2.5 py-1.5 text-[12px] font-bold text-[#0f2547]",children:[e.jsx($e,{size:13,className:"shrink-0 text-[#1c4b93]"}),e.jsxs("span",{className:"truncate",children:[s.accountHolder||""," · A/C ••••",s.accountLast4,s.ifsc?` · ${s.ifsc}`:""]})]})]})}function zi({societyId:t}){const[s,n]=a.useState(null),[i,r]=a.useState(""),[l,c]=a.useState(""),[x,o]=a.useState(""),[m,d]=a.useState(""),[u,b]=a.useState(""),[g,v]=a.useState("savings"),[f,h]=a.useState(Qt),[w,z]=a.useState(Xt),[p,j]=a.useState(""),[E,R]=a.useState({scheduleOptions:[],entityTypes:[],businessTypes:[]}),[N,$]=a.useState(""),[S,A]=a.useState(""),[M,_]=a.useState(!1),[D,H]=a.useState(""),V=()=>At(t).then(P=>n(P||{status:"none"})).catch(()=>n({status:"none"}));a.useEffect(()=>{V()},[t]),a.useEffect(()=>{Ja().then(P=>{R(P),P.scheduleOptions.length&&j(O=>O||P.scheduleOptions[0].value)})},[]);const J=(s==null?void 0:s.status)||"none",L=J==="active",Z=async()=>{var P,O,K;if(H(""),l.trim()!==x.trim())return H("Account numbers don't match.");_(!0);try{const W=await Qa(t,{accountHolder:i.trim(),accountNumber:l.trim(),ifsc:m.trim().toUpperCase(),pan:u.trim().toUpperCase(),accountType:g,entityType:f,businessType:w,...p?{scheduleOption:p}:{},email:N.trim(),phone:S.trim()});n(W)}catch(W){H(((K=(O=(P=W==null?void 0:W.response)==null?void 0:P.data)==null?void 0:O.status)==null?void 0:K.message)||"Couldn't verify these details."),V()}finally{_(!1)}};return e.jsxs("div",{className:T,children:[e.jsx(X,{icon:e.jsx($e,{size:15}),title:"Payout account",children:L&&e.jsx(F,{tone:"green",dot:!0,children:"Verified"})}),e.jsx("div",{className:"flex flex-col gap-3.5 p-4",children:s===null?e.jsxs("p",{className:"flex items-center gap-2 text-[13px] text-[#8493b4]",children:[e.jsx(ne,{size:14,className:"animate-spin"})," Loading…"]}):e.jsxs(e.Fragment,{children:[e.jsx(Si,{status:J,payout:s}),L?e.jsx("p",{className:"text-[12.5px] text-[#5a6b7b]",children:"Your settlement account is verified and locked in. To change it, contact support."}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-[12px] leading-relaxed text-[#8493b4]",children:"Collections settle directly to this account. Only masked details are stored here — Cashfree holds the full bank account and PAN. Adding an account does not change how your current payments work."}),e.jsx("p",{className:"text-[12px] font-semibold leading-relaxed text-[#8a6a1f]",children:"Double-check the account number and IFSC before saving. They are not penny-drop verified, so a typo will send settlements to the wrong account."}),e.jsx(C,{label:"Account holder name",children:e.jsx("input",{className:k,value:i,onChange:P=>r(P.target.value),placeholder:"As printed on the passbook"})}),e.jsxs("div",{className:"grid grid-cols-2 gap-3.5",children:[e.jsx(C,{label:"Account number",children:e.jsx("input",{className:k,value:l,onCh
126ange:P=>c(P.target.value),inputMode:"numeric"})}),e.jsx(C,{label:"Re-enter account number",children:e.jsx("input",{className:k,value:x,onChange:P=>o(P.target.value),inputMode:"numeric"})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3.5",children:[e.jsx(C,{label:"IFSC",children:e.jsx("input",{className:k,value:m,onChange:P=>d(P.target.value),placeholder:"HDFC0001234"})}),e.jsx(C,{label:"PAN",children:e.jsx("input",{className:k,value:u,onChange:P=>b(P.target.value),placeholder:"ABCDE1234F"})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3.5",children:[e.jsx(C,{label:"Account type",children:e.jsx("select",{className:k,value:g,onChange:P=>v(P.target.value),children:wi.map(P=>e.jsx("option",{value:P,children:P[0].toUpperCase()+P.slice(1)},P))})}),e.jsx(C,{label:"Entity type",children:e.jsx(pt,{value:f,onChange:h,options:E.entityTypes,fallback:Qt})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3.5",children:[e.jsx(C,{label:"Business category",children:e.jsx(pt,{value:w,onChange:z,options:E.businessTypes,fallback:Xt})}),e.jsx(C,{label:"Settlement cycle",children:e.jsx(pt,{value:p,onChange:j,options:E.scheduleOptions,fallback:p})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3.5",children:[e.jsx(C,{label:"Contact email",children:e.jsx("input",{className:k,value:N,onChange:P=>$(P.target.value),placeholder:"For settlement notifications"})}),e.jsx(C,{label:"Contact phone",children:e.jsx("input",{className:k,value:S,onChange:P=>A(P.target.value),inputMode:"numeric",placeholder:"10-digit mobile"})})]}),D&&e.jsx("p",{className:"text-[12.5px] font-semibold text-[#d63a3a]",children:D}),e.jsx("div",{className:"flex items-center justify-end",children:e.jsx(y,{variant:"navy",onClick:Z,disabled:M,children:M?"Saving…":J==="failed"?"Fix and resubmit":"Save account"})})]})]})})]})}function Pi({society:t,societyId:s,reload:n}){const[i,r]=a.useState(t.terms||""),[l,c]=a.useState(t.noticePeriodDays??30),[x,o]=a.useState(!1),[m,d]=a.useState(!1),u=async()=>{o(!0);try{await Fe(s,{terms:i.trim(),noticePeriodDays:Number(l)||0}),d(!0),setTimeout(()=>d(!1),1800),n()}finally{o(!1)}};return e.jsxs("div",{className:T+" mt-4",children:[e.jsx(X,{icon:e.jsx(ce,{size:15}),title:"House rules, terms & notice",children:m&&e.jsx(F,{tone:"green",dot:!0,children:"Saved"})}),e.jsxs("div",{className:"flex flex-col gap-3 p-4",children:[e.jsx("p",{className:"text-[12.5px] leading-relaxed text-[#586887]",children:"Residents agree to these terms in their app before they're fully active. Change them and residents are asked to agree again."}),e.jsx(C,{label:"Terms residents agree to",children:e.jsx("textarea",{className:"w-full resize-none rounded-lg border border-[#d6deec] bg-white px-3 py-2 text-[13.5px] leading-relaxed text-[#153568] outline-none transition focus:border-[#1c4b93] focus:shadow-[0_0_0_3px_rgba(28,75,147,0.12)] placeholder:text-[#a7b3cd]",rows:5,value:i,onChange:b=>r(b.target.value),placeholder:"e.g. Maintenance is due by the 5th. No subletting without approval. Give 30 days' notice before leaving. Keep common areas clean."})}),e.jsxs("div",{className:"grid grid-cols-1 items-end gap-3 sm:grid-cols-[200px_auto]",children:[e.jsx(C,{label:"Move-out notice (days)",hint:"Used to suggest a deduction at checkout.",children:e.jsx("input",{className:k,type:"number",value:l,onChange:b=>c(b.target.value)})}),e.jsx(y,{variant:"navy",size:"sm",onClick:u,disabled:x,children:x?"Saving…":"Save"})]})]})]})}function Ai({society:t,societyId:s,reload:n}){const i=t.deposit||{},[r,l]=a.useState(!!i.enabled),[c,x]=a.useState(i.amount||""),[o,m]=a.useState(!1),[d,u]=a.useState(!1),b=async g=>{m(!0);try{await Fe(s,{deposit:{enabled:r,amount:Number(c)||0,...g}}),u(!0),setTimeout(()=>u(!1),1800),n()}finally{m(!1)}};return e.jsxs("div",{className:T+" mt-4",children:[e.jsx(X,{icon:e.jsx($e,{size:15}),title:"Security deposits",children:r?e.jsx(F,{tone:"green",dot:!0,children:"On"}):e.jsx("span",{className:"text-[11px] font-bold text-[#8493b4]",children:"Off"})}),e.jsxs("div",{className:"p-4",children:[e.jsx("p",{className:"text-[12.5px] leading-relaxed text-[#586887]",children:"Collect a refundable deposit from residents. It's held — never counted as income — until you settle it at move-out. Works for flats and PG beds."}),e.jsxs("div",{className:"mt-4 grid grid-cols-1 gap-3 sm:grid-cols-[1fr_auto] sm:items-end",children:[e.jsx(C,{label:"Default deposit amount",hint:"A unit or bed can override this when you collect.",children:e.jsxs("div",{className:"relative",children:[e.jsx("span",{className:"pointer-events-none absolute left-3 top-1/2 -translate-y-1/2 text-[13.5px] font-bold text-[#8697b8]",children:"₹"}),e.jsx("input",{className:k+" pl-7",type:"number",value:c,onChange:g=>x(g.target.value),placeholder:"e.g. 20000"})]})}),e.jsx(y,{variant:"navy",size:"sm",onClick:()=>b(),disabled:o,children:d?"Saved":"Save"})]}),e.jsx("div",{className:"mt-3",children:e.jsx(y,{variant:r?"danger":"gold",size:"sm",onClick:()=>{const g=!r;l(g),b({enabled:g})},disabled:o,children:r?"Turn deposits off":"Turn deposits on"})})]})]})}function Ri({society:t,societyId:s,reload:n}){const i=t.billing||{}
126,[r,l]=a.useState(i.cycle||"monthly"),[c,x]=a.useState(i.basis||"sqft"),[o,m]=a.useState(i.dueDay??5),[d,u]=a.useState(i.ratePerSqft??0),[b,g]=a.useState(!1),[v,f]=a.useState(!1),[h,w]=a.useState(""),z=r!==(i.cycle||"monthly")||c!==(i.basis||"sqft")||Number(o)!==(i.dueDay??5)||Number(d)!==(i.ratePerSqft??0),p=async()=>{const j=Number(o);if(!j||j<1||j>28)return w("Due day must be between 1 and 28.");g(!0),w("");try{await Fe(s,{billing:{cycle:r,basis:c,dueDay:j,ratePerSqft:Number(d)||0}}),f(!0),setTimeout(()=>f(!1),1800),n()}catch{w("Couldn't save. Please try again.")}finally{g(!1)}};return e.jsxs("div",{className:T,children:[e.jsx(X,{icon:e.jsx(me,{size:15}),title:"Billing configuration",children:v&&e.jsx(F,{tone:"green",dot:!0,children:"Saved"})}),e.jsxs("div",{className:"flex flex-col gap-3.5 p-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3.5",children:[e.jsx(C,{label:"Cycle",children:e.jsx("select",{className:k,value:r,onChange:j=>l(j.target.value),children:fi.map(j=>e.jsx("option",{value:j,children:gi[j]},j))})}),e.jsx(C,{label:"Basis",children:e.jsx("select",{className:k,value:c,onChange:j=>x(j.target.value),children:bi.map(j=>e.jsx("option",{value:j,children:ji[j]},j))})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3.5",children:[e.jsx(C,{label:"Due day",children:e.jsx("input",{className:k,type:"number",min:1,max:28,value:o,onChange:j=>m(j.target.value)})}),e.jsx(C,{label:"Rate per sq ft",hint:"Applied to each unit's area to compute monthly maintenance.",children:e.jsxs("div",{className:"relative",children:[e.jsx("span",{className:"pointer-events-none absolute left-3 top-1/2 -translate-y-1/2 text-[13.5px] font-bold text-[#8697b8]",children:"₹"}),e.jsx("input",{className:k+" pl-7",type:"number",step:"0.1",min:0,value:d,onChange:j=>u(j.target.value)})]})})]}),e.jsx("p",{className:"text-[11px] text-[#8493b4]",children:"New/edited units use this rate."}),h&&e.jsx("p",{className:"text-[12.5px] font-semibold text-[#d63a3a]",children:h}),e.jsx("div",{className:"flex items-center justify-end",children:e.jsx(y,{variant:"navy",onClick:p,disabled:b||!z,children:b?"Saving…":"Save changes"})})]})]})}const Ti=[{v:"male",label:"Men only"},{v:"female",label:"Women only"},{v:"coed",label:"Co-Living"}],Ei=[{v:"veg",label:"Veg"},{v:"nonveg",label:"Non-veg"},{v:"both",label:"Both"}];function Mi({society:t,societyId:s,reload:n}){const i=t.pg||{},[r,l]=a.useState(i.gender||"coed"),[c,x]=a.useState(!!i.foodIncluded),[o,m]=a.useState(i.foodType&&i.foodType!=="none"?i.foodType:"veg"),[d,u]=a.useState(i.noticePeriodDays??30),[b,g]=a.useState(i.rules||[]),[v,f]=a.useState(""),[h,w]=a.useState(!1),[z,p]=a.useState(!1),[j,E]=a.useState(""),R=()=>{const S=v.trim();S&&(g(A=>[...A,S]),f(""))},N=S=>g(A=>A.filter((M,_)=>_!==S)),$=async()=>{const S=Number(d);if(S<0||S>180)return E("Notice period must be between 0 and 180 days.");w(!0),E("");try{await Fe(s,{type:"pg",pg:{gender:r,foodIncluded:c,foodType:c?o:"none",noticePeriodDays:S,rules:b}}),p(!0),setTimeout(()=>p(!1),1800),n()}catch{E("Couldn't save. Please try again.")}finally{w(!1)}};return e.jsxs("div",{className:T,children:[e.jsx(X,{icon:e.jsx(fe,{size:15}),title:"PG / hostel configuration",children:z&&e.jsx(F,{tone:"green",dot:!0,children:"Saved"})}),e.jsxs("div",{className:"flex flex-col gap-3.5 p-4",children:[e.jsx(C,{label:"Gender",children:e.jsx("div",{className:"flex flex-wrap gap-2",children:Ti.map(S=>e.jsx(Zt,{on:r===S.v,onClick:()=>l(S.v),children:S.label},S.v))})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[11px] font-bold uppercase tracking-[0.08em] text-[#8493b4]",children:"Food"}),e.jsxs("button",{type:"button",onClick:()=>x(S=>!S),className:"inline-flex h-6 items-center gap-1.5 rounded-full px-2 text-[11px] font-extrabold transition "+(c?"bg-[#e4f6ec] text-[#15964f]":"bg-[#eef1f7] text-[#7c8ca8]"),children:[e.jsx(el,{size:12})," ",c?"Included":"Not included"]})]}),c&&e.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:Ei.map(S=>e.jsx(Zt,{on:o===S.v,onClick:()=>m(S.v),children:S.label},S.v))})]}),e.jsx(C,{label:"Notice period (days)",hint:"How much notice a guest must give before moving out.",children:e.jsx("input",{className:k,type:"number",min:0,max:180,value:d,onChange:S=>u(S.target.value)})}),e.jsxs("div",{children:[e.jsx("span",{className:"mb-1 block text-[11px] font-bold uppercase tracking-[0.08em] text-[#8493b4]",children:"House rules"}),b.length>0&&e.jsx("div",{className:"mb-2 flex flex-col gap-1.5",children:b.map((S,A)=>e.jsxs("div",{className:"flex items-center gap-2 rounded-lg border border-[#e6eaf3] bg-[#f7f9fd] px-3 py-2",children:[e.jsx("span",{className:"flex-1 text-[12.5px] text-[#3b4a68]",children:S}),e.jsx("button",{type:"button",onClick:()=>N(A),className:"grid h-6 w-6 place-items-center rounded-md text-[#a7b3cd] transition hover:bg-[#fdf1f1] hover:text-[#d63a3a]",children:e.jsx(kt,{size:13})})]},A))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{className:k,placeholder:"e.g. No visitors after 10 PM",value:v,onCh
126ange:S=>f(S.target.value),onKeyDown:S=>{S.key==="Enter"&&(S.preventDefault(),R())}}),e.jsx(y,{variant:"outline",icon:e.jsx(ae,{size:14}),onClick:R,children:"Add"})]})]}),j&&e.jsx("p",{className:"text-[12.5px] font-semibold text-[#d63a3a]",children:j}),e.jsx("div",{className:"flex items-center justify-end",children:e.jsx(y,{variant:"navy",onClick:$,disabled:h,children:h?"Saving…":"Save changes"})})]})]})}function Zt({on:t,onClick:s,children:n}){return e.jsx("button",{type:"button",onClick:s,className:"h-9 rounded-lg border px-3 text-[12.5px] font-bold transition "+(t?"border-[#1c4b93] bg-[#eef3fb] text-[#1c4b93]":"border-[#d6deec] bg-white text-[#586887] hover:bg-[#f2f5fc]"),children:n})}function Bi({society:t,committee:s,societyId:n,reload:i,onAdd:r}){return e.jsxs("div",{className:T+" overflow-hidden",children:[e.jsx(X,{icon:e.jsx(vt,{size:15}),title:"Committee & roles",children:e.jsx(y,{variant:"navy",size:"sm",icon:e.jsx(ae,{size:14}),onClick:r,children:"Add member"})}),s.length===0?e.jsx(Q,{icon:e.jsx(vt,{size:26}),title:"No committee members yet",sub:"Add the president, secretary, and other office bearers to define who governs this society.",cta:"Add member",onCta:r}):e.jsx("div",{className:"flex flex-col",children:s.map(l=>e.jsx(_i,{m:l,isOwner:l.userId&&l.userId===t.createdBy,societyId:n,reload:i},l._id))})]})}function _i({m:t,isOwner:s,societyId:n,reload:i}){const[r,l]=a.useState(!1),c=s||t.role==="president"?"gold":"navy",x=async()=>{l(!0);try{await Xa(n,t._id),i()}catch{l(!1)}};return e.jsxs("div",{className:"flex items-center gap-3 border-t border-[#eef1f7] px-4 py-3 first:border-t-0",children:[e.jsx("span",{className:"grid h-9 w-9 shrink-0 place-items-center rounded-full bg-[#eef3fb] text-[12px] font-extrabold text-[#1c4b93]",children:yi(t.name)}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"text-[13.5px] font-extrabold text-[#153568]",children:t.name}),s?e.jsx(F,{tone:"gold",children:"Owner"}):e.jsx(F,{tone:c,children:Hs[t.role]||t.role})]}),t.phone&&e.jsx("div",{className:"mt-0.5 text-[12px] text-[#5b6b8a] tabular-nums",children:t.phone})]}),!s&&e.jsx(y,{variant:"danger",size:"sm",icon:e.jsx(be,{size:13}),onClick:x,disabled:r,children:r?"Removing…":"Remove"})]})}function Di({open:t,onClose:s,societyId:n,onAdded:i}){const[r,l]=a.useState(""),[c,x]=a.useState("member"),[o,m]=a.useState(""),[d,u]=a.useState(!1),[b,g]=a.useState("");a.useEffect(()=>{t&&(l(""),x("member"),m(""),g(""),u(!1))},[t]);const v=async()=>{if(!r.trim())return g("Name is required.");u(!0),g("");try{await Za(n,{name:r.trim(),role:c,phone:o.trim()}),i()}catch{g("Couldn't add member. Please try again."),u(!1)}};return e.jsx(q,{open:t,onClose:s,title:"Add committee member",footer:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(y,{variant:"ghost",onClick:s,children:"Cancel"}),e.jsx(y,{variant:"navy",icon:e.jsx(ce,{size:14}),onClick:v,disabled:d,children:d?"Adding…":"Add member"})]}),children:e.jsxs("div",{className:"flex flex-col gap-3.5",children:[e.jsx(C,{label:"Name",children:e.jsx("input",{className:k,value:r,onChange:f=>l(f.target.value),placeholder:"Full name",autoFocus:!0})}),e.jsxs("div",{className:"grid grid-cols-2 gap-3.5",children:[e.jsx(C,{label:"Role",children:e.jsx("select",{className:k,value:c,onChange:f=>x(f.target.value),children:vi.map(f=>e.jsx("option",{value:f,children:Hs[f]},f))})}),e.jsx(C,{label:"Phone",children:e.jsx("input",{className:k,value:o,onChange:f=>m(f.target.value),placeholder:"+91…"})})]}),b&&e.jsx("p",{className:"text-[12.5px] font-semibold text-[#d63a3a]",children:b})]})})}function Li(){return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mb-5 grid grid-cols-3 gap-3.5",children:[0,1,2].map(t=>e.jsx("div",{className:T+" h-[112px] animate-pulse"},t))}),e.jsxs("div",{className:"grid grid-cols-1 gap-4 lg:grid-cols-2",children:[e.jsx("div",{className:T+" h-[340px] animate-pulse"}),e.jsx("div",{className:T+" h-[340px] animate-pulse"})]}),e.jsx("div",{className:T+" mt-4 h-[220px] animate-pulse"})]})}const $i=["water","gas","cleaning","laundry","pest","appliance","utility","other"],Ze={water:"Water",gas:"Gas",cleaning:"Cleaning",laundry:"Laundry",pest:"Pest control",appliance:"Appliance",utility:"Utility",other:"Other"},Fi={water:En,gas:Mn,cleaning:ws,laundry:qn,pest:On,appliance:Oe,utility:Bn,other:zs}
126,Dt={water:"#1c4b93",gas:"#c77812",cleaning:"#15964f",laundry:"#1c4b93",pest:"#d63a3a",appliance:"#c98a00",utility:"#c98a00",other:"#8697b8"};function Vs({category:t,size:s=15}){const n=Fi[t]||zs;return e.jsx(n,{size:s})}const Ks={requested:"amber",approved:"navy","in-progress":"navy",fulfilled:"green",closed:"slate",rejected:"red",cancelled:"slate"},Nt={requested:"Requested",approved:"Approved","in-progress":"In progress",fulfilled:"Fulfilled",closed:"Closed",rejected:"Rejected",cancelled:"Cancelled"},Oi=["one-time","weekly","monthly"],Ws={"one-time":"One-time",weekly:"Weekly",monthly:"Monthly"},Ui=[{key:"",label:"All"},{key:"requested",label:"Requested"},{key:"approved",label:"Approved"},{key:"in-progress",label:"In progress"},{key:"fulfilled",label:"Fulfilled"}];function Ii({societyId:t}){const[s,n]=a.useState(""),[i,r]=a.useState(null),[l,c]=a.useState(null),[x,o]=a.useState(null),[m,d]=a.useState(!1),[u,b]=a.useState(!1),[g,v]=a.useState(null),f=()=>{r(null),c(null),o(null),d(!1),Promise.all([rt(t),It(t,{status:s})]).then(([z,p])=>{r(z),c(p.stats),o(p.items)}).catch(()=>d(!0))};a.useEffect(f,[t,s]);const h=()=>Promise.all([rt(t),It(t,{status:s})]).then(([z,p])=>{if(r(z),c(p.stats),o(p.items),g){const j=p.items.find(E=>E._id===g._id);j&&v(j)}}),w=()=>rt(t).then(r);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-4 flex flex-wrap items-end justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-[19px] font-extrabold tracking-[-0.01em] text-[#0f2547]",children:"Services"}),e.jsx("p",{className:"mt-0.5 text-[13px] text-[#5b6b8a]",children:"Offer services and manage resident requests."})]}),e.jsx(y,{variant:"navy",icon:e.jsx(ae,{size:15}),onClick:()=>b(!0),children:"Add service"})]}),m?e.jsx("div",{className:T,children:e.jsx(Q,{icon:e.jsx(te,{size:26}),title:"Couldn't load services",sub:"Check your connection and try again.",cta:"Retry",onCta:f})}):!i||!l||!x?e.jsx(qi,{}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-5 grid grid-cols-2 gap-3.5 lg:grid-cols-4",children:[e.jsx(G,{icon:e.jsx(He,{size:15}),k:"Requests",v:l.total,accent:"#1c4b93",sub:"all time"}),e.jsx(G,{icon:e.jsx(ne,{size:15}),k:"Open",v:l.open,accent:"#c77812",vColor:"#c77812",sub:"need action"}),e.jsx(G,{icon:e.jsx(Oe,{size:15}),k:"Needs pricing",v:l.unconfigured,accent:"#1c4b93",sub:"to configure"}),e.jsx(G,{icon:e.jsx(me,{size:15}),k:"Awaiting payment",v:l.awaitingPayment,accent:"#c98a00",vColor:l.awaitingPayment?"#c98a00":"#15964f",dot:l.awaitingPayment?"#c98a00":"#15964f",sub:"billed via JaaGa"})]}),e.jsxs("div",{className:T+" mb-5 overflow-hidden",children:[e.jsx(X,{icon:e.jsx(ft,{size:15}),title:"Service catalog",children:e.jsxs("span",{className:"rounded-md bg-[#eef3fb] px-2 py-0.5 text-[11px] font-bold text-[#1c4b93]",children:[i.length," listed"]})}),i.length===0?e.jsx(Q,{icon:e.jsx(ft,{size:26}),title:"No services yet",sub:"Build a catalog of services your community offers — water delivery, cleaning, laundry and more.",cta:"Add service",onCta:()=>b(!0)}):e.jsx("div",{className:"grid grid-cols-1 gap-3 p-4 md:grid-cols-2",children:i.map(z=>e.jsx(Gi,{s:z,onToggle:w},z._id))})]}),e.jsx("div",{className:"mb-4 flex flex-wrap gap-2",children:Ui.map(z=>e.jsx("button",{onClick:()=>n(z.key),className:"h-9 rounded-lg border px-3.5 text-[12.5px] font-bold transition "+(s===z.key?"border-[#1c4b93] bg-[#eef3fb] text-[#1c4b93]":"border-[#d6deec] bg-white text-[#586887] hover:bg-[#f2f5fc]"),children:z.label},z.key||"all"))}),e.jsxs("div",{className:T+" overflow-hidden",children:[e.jsx(X,{icon:e.jsx(He,{size:15}),title:"Requests",children:e.jsxs("span",{className:"rounded-md bg-[#eef3fb] px-2 py-0.5 text-[11px] font-bold text-[#1c4b93]",children:[x.length," shown"]})}),x.length===0?e.jsx(Q,{icon:e.jsx(He,{size:26}),title:"No requests here",sub:s?"No requests match this filter. Try another status.":"When residents request a service, it'll show up here to price, assign and fulfil."}):e.jsx("div",{className:"flex flex-col",children:x.map(z=>e.jsx(Hi,{r:z,onOpen:()=>v(z)},z._id))})]})]}),e.jsx(Yi,{open:u,societyId:t,onClose:()=>b(!1),onCreated:()=>{b(!1),f()}}),e.jsx(Wi,{request:g,onClose:()=>v(null),onChange:h})]})}function Gi({s:t,onToggle:s}){const[n,i]=a.useState(!1),r=Dt[t.category]||"#8697b8",l=async()=>{i(!0);try{await en(t._id,{active:!t.active}),await s()}finally{i(!1)}};return e.jsxs("div",{className:T+" flex flex-col gap-3 p-3.5",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"grid h-9 w-9 shrink-0 place-items-center rounded-lg",style:{background:r+"15",color:r},children:e.jsx(Vs,{category:t.category})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate text-[13.5px] font-extrabold text-[#153568]",children:t.name}),e.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[11.5px] text-[#5b6b8a]",children:[e.jsx("span",{children:Ze[t.category]||t.category}),e.jsx("span",{className:"text-[#c4cddd]",children:"·"}),e.jsx("span",{children:Ws[t.recurring]||t.recurring})]})]}),e.jsx(F,{tone:t.active?"green":"slate",dot:!0,children:t.active?"Active":"Inactive"})]}),t.description&&e.jsx("p",{className:"line-clamp-2 text-[12px] leading-relaxed text-[#586887]",children:t.description}),e.jsxs("div",{className:"mt-auto flex items-center justify-between gap-2 border-t border-[#eef1f7] pt-3",children:[t.chargeable?e.jsx(F,{tone:"gold",children:e.jsx("span",{className:"tabular-nums",children:B(t.price)})}):e.jsx(F,{tone:"green",children:"Free"}),e.jsx(y,{variant:t.active?"outline":"navy",size:"sm",icon:e.jsx(Wn,{size:13}),onClick:l,disabled:n,children:n?"…":t.active?"Deactivate":"Activate"})]})]})}function Ys(t){return t.settlementMode==="platform"?t.paymentStatus==="paid"?{tone:"green",label:"Paid"}:{tone:"gold",label:`Awaiting ${B(t.price)}`}:t.settlementMode==="direct"?{tone:"slate",label:"Direct"}:{tone:"amber",label:"Needs config"}}
126function Hi({r:t,onOpen:s}){const n=Dt[t.category]||"#8697b8",i=Ys(t);return e.jsxs("button",{onClick:s,className:"grid grid-cols-[auto_1fr_auto] items-center gap-3 border-t border-[#eef1f7] px-4 py-3 text-left first:border-t-0 hover:bg-[#f7f9fd]",children:[e.jsx("span",{className:"grid h-9 w-9 shrink-0 place-items-center rounded-lg",style:{background:n+"15",color:n},children:e.jsx(Vs,{category:t.category})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-[13.5px] font-extrabold text-[#153568]",children:t.title}),e.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[11.5px] text-[#5b6b8a]",children:[e.jsx("span",{className:"font-bold text-[#1c4b93]",children:t.unitCode||"—"}),e.jsx("span",{className:"text-[#c4cddd]",children:"·"}),e.jsx("span",{className:"truncate",children:t.requestedByName||"Resident"}),e.jsx("span",{className:"text-[#c4cddd]",children:"·"}),e.jsx("span",{className:"text-[#8697b8]",children:se(t.createdAt)})]})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[e.jsx(F,{tone:i.tone,children:i.label}),e.jsx(F,{tone:Ks[t.status]||"slate",children:Nt[t.status]||t.status})]})]})}function Vi(t){return t==="requested"?{to:"approved",label:"Approve",icon:e.jsx(ue,{size:14})}:t==="approved"?{to:"in-progress",label:"Start work",icon:e.jsx(ne,{size:14})}:t==="in-progress"?{to:"fulfilled",label:"Mark fulfilled",icon:e.jsx(Cs,{size:14})}:null}const Ki=[{key:"platform",label:"Platform",hint:"Collect via JaaGa"},{key:"direct",label:"Direct",hint:"Resident pays provider offline"}];function Wi({request:t,onClose:s,onChange:n}){const[i,r]=a.useState(""),[l,c]=a.useState(""),[x,o]=a.useState(""),[m,d]=a.useState(""),[u,b]=a.useState("platform"),[g,v]=a.useState(!1),[f,h]=a.useState(""),[w,z]=a.useState(!1),[p,j]=a.useState(!1);if(a.useEffect(()=>{var D,H;r(((D=t==null?void 0:t.provider)==null?void 0:D.name)||""),c(((H=t==null?void 0:t.provider)==null?void 0:H.phone)||""),o((t==null?void 0:t.price)!=null?String(t.price):""),d((t==null?void 0:t.payoutToProvider)!=null?String(t.payoutToProvider):""),b(t!=null&&t.settlementMode&&t.settlementMode!=="none"?t.settlementMode:"platform"),h("")},[t==null?void 0:t._id]),!t)return null;const E=async D=>{z(!0);try{await tn(t._id,{status:D}),await n()}finally{z(!1)}},R=async()=>{v(!0);try{await sn(t._id,{provider:{name:i.trim(),phone:l.trim()},price:Number(x)||0,settlementMode:u,payoutToProvider:Number(m)||0,status:t.status==="requested"?"approved":t.status}),await n()}finally{v(!1)}},N=async()=>{const D=f.trim();if(D){j(!0);try{await an(t._id,D),h(""),await n()}finally{j(!1)}}},$=Vi(t.status),S=Dt[t.category]||"#8697b8",A=t.comments||[],M=Ys(t),_=["fulfilled","closed","rejected","cancelled"].includes(t.status);return e.jsxs(st,{open:!!t,onClose:s,width:480,storageKey:"service",title:t.title,subtitle:`${t.unitCode||"—"} · ${Ze[t.category]||t.category}`,footer:e.jsxs("div",{className:"flex items-center gap-2",children:[$&&e.jsx(y,{variant:"navy",icon:$.icon,onClick:()=>E($.to),disabled:w,className:"flex-1",children:$.label}),!_&&e.jsx(y,{variant:"danger",icon:e.jsx(Gn,{size:14}),onClick:()=>E("rejected"),disabled:w,className:$?"":"flex-1",children:"Reject"}),_&&e.jsxs("span",{className:"flex flex-1 items-center justify-center gap-1.5 text-[12.5px] font-bold text-[#7c8ca8]",children:[e.jsx(ue,{size:14})," ",Nt[t.status]||t.status]})]}),children:[e.jsxs("div",{className:"mb-4 flex flex-wrap items-center gap-2",children:[e.jsx(F,{tone:Ks[t.status]||"slate",dot:!0,children:Nt[t.status]||t.status}),e.jsx(F,{tone:M.tone,children:M.label})]}),t.paymentStatus==="paid"&&e.jsxs("div",{className:"mb-3.5 flex items-center gap-2 rounded-xl border border-[#cdeddb] bg-[#e4f6ec] px-3.5 py-2.5 text-[12.5px] font-bold text-[#15964f]",children:[e.jsx(Cs,{size:15}),"Paid via ",t.channel||t.paidVia||"JaaGa"," · receipt"]}),e.jsxs("div",{className:T+" mb-3.5 p-4",children:[e.jsx("div",{className:we+" mb-1.5",children:"Request"}),e.jsx("p",{className:"whitespace-pre-wrap text-[13.5px] leading-relaxed text-[#3f4d6b]",children:t.description||"No details provided."})]}),e.jsxs("div",{className:T+" mb-3.5 grid grid-cols-2 gap-3 p-4",children:[e.jsx(Ce,{label:"Requested by",value:t.requestedByName||"Resident"}),e.jsx(Ce,{label:"Unit",value:t.unitCode||"—"}),e.jsx(Ce,{label:"Category",value:e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx("span",{className:"h-2 w-2 rounded-full",style:{background:S}}),Ze[t.category]||t.category]})}),e.jsx(Ce,{label:"Quantity",value:t.quantity!=null?String(t.quantity):"—"}),e.jsx(Ce,{label:"Preferred date",value:t.preferredDate?se(t.preferredDate):"—"}),e.jsx(Ce,{label:"Requested on",value:se(t.createdAt)})]}),e.jsxs("div",{className:T+" mb-3.5 p-4",children:[e.jsxs("div",{className:"mb-3 flex items-center gap-1.5",children:[e.jsx(Oe,{size:13,className:"text-[#1c4b93]"}),e.jsx("span",{className:we,children:"Configure request"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(C,{label:"Provider name",children:e.jsx("input",{className:k,placeholder:"Vendor / staff name",value:i,onChange:D=>r(D.target.value)})}),e.jsx(C,{label:"Provider phone",children:e.jsx("input",{className:k,placeholder:"Phone",value:l,onCh
126ange:D=>c(D.target.value)})})]}),e.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-3",children:[e.jsx(C,{label:"Price (₹)",children:e.jsx("input",{type:"number",min:"0",className:k+" tabular-nums",placeholder:"0",value:x,onChange:D=>o(D.target.value)})}),e.jsx(C,{label:"Payout to provider (₹)",children:e.jsx("input",{type:"number",min:"0",className:k+" tabular-nums",placeholder:"0",value:m,onChange:D=>d(D.target.value)})})]}),e.jsxs("div",{className:"mt-3",children:[e.jsx("span",{className:"mb-1 block text-[11px] font-bold uppercase tracking-[0.08em] text-[#8493b4]",children:"Settlement mode"}),e.jsx("div",{className:"flex gap-2",children:Ki.map(D=>e.jsxs("button",{onClick:()=>b(D.key),className:"flex-1 rounded-lg border px-3 py-2 text-left transition "+(u===D.key?"border-[#1c4b93] bg-[#eef3fb]":"border-[#d6deec] bg-white hover:bg-[#f2f5fc]"),children:[e.jsx("span",{className:"block text-[12.5px] font-extrabold "+(u===D.key?"text-[#1c4b93]":"text-[#586887]"),children:D.label}),e.jsx("span",{className:"mt-0.5 block text-[10.5px] text-[#8697b8]",children:D.hint})]},D.key))})]}),e.jsx("p",{className:"mt-2.5 text-[11.5px] leading-relaxed text-[#8493b4]",children:u==="platform"?"Platform ⇒ resident is billed ₹price via the app — JaaGa collects and settles.":"Direct ⇒ share the provider contact; the resident pays them directly, offline."}),e.jsx("div",{className:"mt-3 flex justify-end",children:e.jsx(y,{variant:"gold",size:"sm",icon:e.jsx(Ae,{size:13}),onClick:R,disabled:g,children:g?"Saving…":"Save configuration"})})]}),e.jsxs("div",{className:T+" overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-2 border-b border-[#eef1f7] px-4 py-3",children:[e.jsx(ds,{size:14,className:"text-[#1c4b93]"}),e.jsx("h3",{className:"text-[13px] font-extrabold text-[#153568]",children:"Activity"}),e.jsx("span",{className:"ml-auto rounded-md bg-[#eef3fb] px-2 py-0.5 text-[10.5px] font-bold text-[#1c4b93]",children:A.length})]}),A.length===0?e.jsx("div",{className:"px-4 py-6 text-center text-[12.5px] text-[#8697b8]",children:"No comments yet. Add the first update below."}):e.jsx("div",{className:"flex flex-col gap-3 px-4 py-3.5",children:A.map((D,H)=>e.jsxs("div",{className:"flex gap-2.5",children:[e.jsx("span",{className:"mt-0.5 grid h-7 w-7 shrink-0 place-items-center rounded-full bg-[#eef3fb] text-[11px] font-extrabold text-[#1c4b93]",children:(D.name||"?").slice(0,1).toUpperCase()}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsx("span",{className:"text-[12.5px] font-extrabold text-[#153568]",children:D.name||"Staff"}),e.jsx("span",{className:"text-[10.5px] text-[#a7b3cd]",children:se(D.at)})]}),e.jsx("p",{className:"mt-0.5 whitespace-pre-wrap text-[12.5px] leading-relaxed text-[#586887]",children:D.text})]})]},H))}),e.jsxs("div",{className:"border-t border-[#eef1f7] p-3",children:[e.jsx("textarea",{className:k+" min-h-[64px] py-2",placeholder:"Add an update or note…",value:f,onChange:D=>h(D.target.value)}),e.jsx("div",{className:"mt-2 flex justify-end",children:e.jsx(y,{variant:"navy",size:"sm",icon:e.jsx(ks,{size:13}),onClick:N,disabled:p||!f.trim(),children:p?"Sending…":"Comment"})})]})]})]})}function Ce({label:t,value:s}){return e.jsxs("div",{children:[e.jsx("div",{className:we+" mb-1",children:t}),e.jsx("div",{className:"text-[13px] font-bold text-[#153568]",children:s})]})}function Yi({open:t,societyId:s,onClose:n,onCreated:i}){const[r,l]=a.useState(""),[c,x]=a.useState("water"),[o,m]=a.useState(""),[d,u]=a.useState(!0),[b,g]=a.useState(""),[v,f]=a.useState("one-time"),[h,w]=a.useState(""),[z,p]=a.useState(""),[j,E]=a.useState(!1),[R,N]=a.useState("");a.useEffect(()=>{t&&(l(""),x("water"),m(""),u(!0),g(""),f("one-time"),w(""),p(""),N(""),E(!1))},[t]);const $=async()=>{if(!r.trim())return N("Give the service a name.");E(!0);try{await nn(s,{name:r.trim(),category:c,description:o.trim(),chargeable:d,price:d&&Number(b)||0,recurring:v,provider:{name:h.trim(),phone:z.trim()}}),i()}catch{N("Couldn't add the service. Please try again."),E(!1)}};return e.jsx(q,{open:t,onClose:n,title:"Add service",footer:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(y,{variant:"ghost",onClick:n,children:"Cancel"}),e.jsx(y,{variant:"navy",icon:e.jsx(ae,{size:14}),onClick:$,disabled:j,children:j?"Adding…":"Add service"})]}),children:e.jsxs("div",{className:"flex flex-col gap-3.5",children:[e.jsx(C,{label:"Name",children:e.jsx("input",{className:k,placeholder:"e.g. 20L water can delivery",value:r,onChange:S=>l(S.target.value),autoFocus:!0})}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(C,{label:"Category",children:e.jsx("select",{className:k,value:c,onChange:S=>x(S.target.value),children:$i.map(S=>e.jsx("option",{value:S,children:Ze[S]},S))})}),e.jsx(C,{label:"Recurring",children:e.jsx("select",{className:k,value:v,onCh
126ange:S=>f(S.target.value),children:Oi.map(S=>e.jsx("option",{value:S,children:Ws[S]},S))})})]}),e.jsx(C,{label:"Description",hint:"What the service includes, so residents know what to expect.",children:e.jsx("textarea",{className:k+" min-h-[72px] py-2",placeholder:"Describe the service…",value:o,onChange:S=>m(S.target.value)})}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("span",{className:"mb-1 block text-[11px] font-bold uppercase tracking-[0.08em] text-[#8493b4]",children:"Pricing"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:()=>u(!0),className:"h-10 flex-1 rounded-lg border text-[12.5px] font-bold transition "+(d?"border-[#1c4b93] bg-[#eef3fb] text-[#1c4b93]":"border-[#d6deec] bg-white text-[#586887] hover:bg-[#f2f5fc]"),children:"Chargeable"}),e.jsx("button",{onClick:()=>u(!1),className:"h-10 flex-1 rounded-lg border text-[12.5px] font-bold transition "+(d?"border-[#d6deec] bg-white text-[#586887] hover:bg-[#f2f5fc]":"border-[#1c4b93] bg-[#eef3fb] text-[#1c4b93]"),children:"Free"})]})]}),e.jsx(C,{label:"Price (₹)",children:e.jsx("input",{type:"number",min:"0",className:k+" tabular-nums disabled:bg-[#f2f5fc] disabled:text-[#a7b3cd]",placeholder:"0",value:b,onChange:S=>g(S.target.value),disabled:!d})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(C,{label:"Provider name",children:e.jsx("input",{className:k,placeholder:"Optional",value:h,onChange:S=>w(S.target.value)})}),e.jsx(C,{label:"Provider phone",children:e.jsxs("div",{className:"relative",children:[e.jsx(Tt,{size:13,className:"pointer-events-none absolute left-3 top-1/2 -translate-y-1/2 text-[#a7b3cd]"}),e.jsx("input",{className:k+" pl-8",placeholder:"Optional",value:z,onChange:S=>p(S.target.value)})]})})]}),R&&e.jsx("p",{className:"text-[12.5px] font-semibold text-[#d63a3a]",children:R})]})})}function qi(){return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mb-5 grid grid-cols-2 gap-3.5 lg:grid-cols-4",children:[0,1,2,3].map(t=>e.jsx("div",{className:T+" h-[112px] animate-pulse"},t))}),e.jsx("div",{className:T+" mb-5 h-[180px] animate-pulse"}),e.jsx("div",{className:"mb-4 flex gap-2",children:[0,1,2,3,4].map(t=>e.jsx("div",{className:"h-9 w-20 animate-pulse rounded-lg bg-[#eef1f7]"},t))}),e.jsx("div",{className:T+" h-[320px] animate-pulse"})]})}function Ji(){const t=new Date;return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}`}function es(t,s){const[n,i]=t.split("-").map(Number),r=n*12+(i-1)+s;return`${Math.floor(r/12)}-${String(r%12+1).padStart(2,"0")}`}function Ge(t){const[s,n]=t.split("-").map(Number);return new Date(s,n-1,1).toLocaleDateString("en-IN",{month:"long",year:"numeric"})}const ts=["Staff","Housekeeping","Security","Repairs","Maintenance","Utilities","Vendor","Legal","Insurance","Other"],ss=["Interest","Fine/Penalty","Donation","Deposit","Other"],Qi=["cash","upi","bank","cheque"],qs={cash:"Cash",upi:"UPI",bank:"Bank",cheque:"Cheque"},Xi=new Set(["Maintenance","Rent","Amenities","Services"]),as=t=>Object.entries(t||{}).filter(([,s])=>Number(s)!==0).sort((s,n)=>Number(n[1])-Number(s[1]));function Zi({societyId:t}){const s=a.useMemo(Ji,[]),[n,i]=a.useState(s),[r,l]=a.useState(null),[c,x]=a.useState(null),[o,m]=a.useState(!1),[d,u]=a.useState(!1),b=()=>{l(null),x(null),m(!1),Promise.all([ln(t,n),rn(t,{period:n})]).then(([h,w])=>{l(h),x(Array.isArray(w)?w:[])}).catch(()=>m(!0))};a.useEffect(b,[t,n]);const g=r==null?void 0:r.month,v=g?Number(g.income||0)-Number(g.expense||0):0,f=v>=0;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-5 flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-[19px] font-extrabold tracking-[-0.01em] text-[#0f2547]",children:"Accounts"}),e.jsx("p",{className:"mt-0.5 text-[13px] text-[#5b6b8a]",children:"Society income, expenses and balance."})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex items-center gap-1 rounded-lg border border-[#d6deec] bg-white p-0.5",children:[e.jsx("button",{onClick:()=>i(h=>es(h,-1)),className:"grid h-8 w-8 place-items-center rounded-md text-[#586887] hover:bg-[#f2f5fc]","aria-label":"Previous month",children:e.jsx(Et,{size:16})}),e.jsx("span",{className:"min-w-[132px] text-center text-[13px] font-extrabold text-[#153568] tabular-nums",children:Ge(n)}),e.jsx("button",{onClick:()=>i(h=>es(h,1)),disabled:n>=s,className:"grid h-8 w-8 place-items-center rounded-md text-[#586887] hover:bg-[#f2f5fc] disabled:opacity-30","aria-label":"Next month",children:e.jsx(et,{size:16})})]}),e.jsx(y,{variant:"navy",icon:e.jsx(ae,{size:15}),onClick:()=>u(!0),children:"Add entry"})]})]}),o?e.jsx("div",{className:T,children:e.jsx(Q,{icon:e.jsx(te,{size:26}),title:"Couldn't load accounts",sub:"Check your connection and try again.",cta:"Retry",onCta:b})}):!r||!c?e.jsx(sr,{}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-5 grid grid-cols-2 gap-3.5 lg:grid-cols-4",children:[e.jsx(G,{icon:e.jsx(Ve,{size:15}),k:"Income",v:B(g.income),vColor:"#15964f",accent:"#15964f",sub:Ge(n)}),e.jsx(G,{icon:e.jsx(_n,{size:15}),k:"Expenses",v:B(g.expense),vColor:"#d63a3a",accent:"#d63a3a",sub:Ge(n)}),e.jsx(G,{icon:e.jsx(Dn,{size:15}),k:"Net",v:B(v),vColor:f?"#15964f":"#d63a3a",dot:f?"#15964f":"#d63a3a",accent:f?"#15964f":"#d63a3a",sub:f?"Surplus this month":"Deficit this month"}),e.jsx(G,{icon:e.jsx($e,{size:15}),k:"Balance",v:B(r.balance),accent:"#1c4b93",sub:"Cumulative cash"})]}),r.depositsHeld>0&&e.jsxs("div",{className:"mb-5 flex items-center gap-3 rounded-xl border border-[#e6eaf3] bg-[#f7f9fd] px-4 py-3",children:[e.jsx("span",{className:"grid h-9 w-9 shrink-0 place-items-center rounded-lg bg-[#eef3fb] text-[#1c4b93]",children:e.jsx(Ln,{size:16})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-[13px] font-bold text-[#0f2547]",children:"Deposits held"}),e.jsx("div",{className:"text-[11.5px] text-[#8493b4]",children:"Refundable security deposits — not counted as income."})]}),e.jsx("span",{className:"text-[15px] font-extrabold tabular-nums text-[#1c4b93]",children:B(r.depositsHeld)})]}),e.jsxs("div",{className:"mb-5 grid grid-cols-1 gap-4 lg:grid-cols-2",children:[e.jsx(ns,{icon:e.jsx(Ve,{size:15,className:"text-[#15964f]"}),title:"Income",total:g.income,rows:as(g.incomeHeads),tone:"green",markAuto:!0,empty:"No income recorded this month."}),e.jsx(ns,{icon:e.jsx(me,{size:15,className:"text-[#d63a3a]"}),title:"Expenses",total:g.expense,rows:as(g.expenseHeads),tone:"red",empty:"No expenses recorded this month."})]}),e.jsxs("div",{className:T+" overflow-hidden",children:[e.jsx(X,{icon:e.jsx(Gt,{size:15}),title:`Ledger · ${Ge(n)}`,children:e.jsxs("span",{className:"rounded-md bg-[#eef3fb] px-2 py-0.5 text-[11px] font-bold text-[#1c4b93]",children:[c.length," entr",c.length===1?"y":"ies"]})}),c.length===0?e.jsx(Q,{icon:e.jsx(Gt,{size:26}),title:"No manual entries this month",sub:"Collections show automatically above. Add expenses or off-book income with “Add entry”."}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"hidden grid-cols-[92px_96px_1.2fr_1.3fr_1fr_84px] gap-x-3 border-b border-[#eef1f7] px-4 py-2.5 text-[10px] font-bold uppercase tracking-[0.12em] text-[#8697b8] lg:grid",children:[e.jsx("span",{children:"Date"}),e.jsx("span",{children:"Type"}),e.jsx("span",{children:"Head"}),e.jsx("span",{children:"Party"}),e.jsx("span",{className:"text-right",children:"Amount"}),e.jsx("span",{className:"text-right",children:"Action"})]}),e.jsx("div",{className:"flex flex-col",children:c.map(h=>e.jsx(er,{entry:h,onDeleted:b},h._id))})]})]})]}),e.jsx(tr,{open:d,onClose:()=>u(!1),societyId:t,period:n,onSaved:()=>{u(!1),b()}})]})}function ns({icon:t,title:s,total:n,rows:i,tone:r,markAuto:l,empty:c}){return e.jsxs("div",{className:T+" flex flex-col overflow-hidden",children:[e.jsx(X,{icon:t,title:s}),i.length===0?e.jsx(Q,{icon:e.jsx(ws,{size:24}),title:c}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex flex-col",children:i.map(([x,o])=>e.jsxs("div",{className:"flex items-center gap-2 border-t border-[#eef1f7] px-4 py-2.5 first:border-t-0",children:[e.jsx("span",{className:"text-[13.5px] font-semibold text-[#153568]",children:x}),l&&Xi.has(x)&&e.jsx(F,{tone:"slate",children:"auto"}),e.jsx("span",{className:"ml-auto text-[13.5px] font-extrabold text-[#0f2547] tabular-nums",children:B(o)})]},x))}),e.jsxs("div",{className:"mt-auto flex items-center justify-between border-t border-[#eef1f7] bg-[#f7f9fd] px-4 py-2.5",children:[e.jsx("span",{className:"text-[11px] font-bold uppercase tracking-[0.1em] text-[#8697b8]",children:"Total"}),e.jsx("span",{className:"text-[15px] font-extrabold tabular-nums",style:{color:r==="red"?"#d63a3a":"#15964f"},children:B(n)})]})]})]})}function er({entry:t,onDeleted:s}){const[n,i]=a.useState(!1),[r,l]=a.useState(!1),c=t.type==="income",x=async()=>
126{l(!0);try{await cn(t._id),s()}catch{l(!1),i(!1)}};return e.jsxs("div",{className:"grid grid-cols-2 items-center gap-x-3 gap-y-1 border-t border-[#eef1f7] px-4 py-3 first:border-t-0 lg:grid-cols-[92px_96px_1.2fr_1.3fr_1fr_84px]",children:[e.jsx("div",{className:"text-[12.5px] tabular-nums text-[#586887]",children:t.date}),e.jsx("div",{className:"justify-self-end lg:justify-self-start",children:e.jsx(F,{tone:c?"green":"red",dot:!0,children:c?"Income":"Expense"})}),e.jsxs("div",{className:"text-[13.5px] font-semibold text-[#153568]",children:[t.head,t.description&&e.jsxs("span",{className:"ml-1 hidden font-normal text-[#8697b8] lg:inline",children:["· ",t.description]})]}),e.jsxs("div",{className:"truncate text-[13px] text-[#586887]",children:[t.party||e.jsx("span",{className:"text-[#a7b3cd]",children:"—"}),t.paymentMode&&e.jsx("span",{className:"ml-1 text-[11px] uppercase tracking-[0.06em] text-[#a7b3cd]",children:qs[t.paymentMode]||t.paymentMode})]}),e.jsxs("div",{className:"col-start-2 row-start-1 text-right text-[14px] font-extrabold tabular-nums lg:col-auto lg:row-auto",style:{color:c?"#15964f":"#d63a3a"},children:[c?"+":"−",B(t.amount)]}),e.jsx("div",{className:"col-span-2 mt-1 flex items-center justify-end gap-2 lg:col-auto lg:mt-0",children:n?e.jsxs(e.Fragment,{children:[e.jsx(y,{size:"sm",variant:"danger",onClick:x,disabled:r,children:r?"…":"Delete"}),e.jsx(y,{size:"sm",variant:"ghost",onClick:()=>i(!1),disabled:r,children:"Cancel"})]}):e.jsxs("button",{onClick:()=>i(!0),className:"inline-flex items-center gap-1 rounded-md px-1.5 py-1 text-[11.5px] font-bold text-[#d63a3a] transition hover:bg-[#fdf1f1]",title:"Delete entry",children:[e.jsx(be,{size:13})," Delete"]})})]})}function ls(){const t=new Date;return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`}function tr({open:t,onClose:s,societyId:n,period:i,onSaved:r}){const[l,c]=a.useState("expense"),[x,o]=a.useState("Staff"),[m,d]=a.useState(""),[u,b]=a.useState(ls),[g,v]=a.useState(""),[f,h]=a.useState("cash"),[w,z]=a.useState(""),[p,j]=a.useState(!1),[E,R]=a.useState("");a.useEffect(()=>{t&&(c("expense"),o("Staff"),d(""),b(ls()),v(""),h("cash"),z(""),R(""),j(!1))},[t]);const N=l==="expense"?ts:ss,$=A=>{c(A),o(A==="expense"?ts[0]:ss[0])},S=async()=>{const A=Number(m);if(!A||A<=0)return R("Enter a valid amount greater than zero.");j(!0);try{await on(n,{type:l,head:x,amount:A,date:u,description:w,party:g,paymentMode:f}),r()}catch{R("Couldn't save the entry. Please try again."),j(!1)}};return e.jsx(q,{open:t,onClose:s,title:"Add ledger entry",footer:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(y,{variant:"ghost",onClick:s,children:"Cancel"}),e.jsx(y,{variant:"navy",onClick:S,disabled:p,children:p?"Saving…":`Add ${l==="expense"?"expense":"income"}`})]}),children:e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs("div",{children:[e.jsx("span",{className:"mb-1 block text-[11px] font-bold uppercase tracking-[0.08em] text-[#8493b4]",children:"Type"}),e.jsx("div",{className:"flex gap-2",children:[{key:"income",label:"Income"},{key:"expense",label:"Expense"}].map(A=>{const M=l===A.key,_=A.key==="income"?"border-[#15964f] bg-[#e4f6ec] text-[#15964f]":"border-[#d63a3a] bg-[#fbe8e8] text-[#d63a3a]";return e.jsx("button",{onClick:()=>$(A.key),className:"h-9 flex-1 rounded-lg border px-3 text-[12.5px] font-bold transition "+(M?_:"border-[#d6deec] bg-white text-[#586887] hover:bg-[#f2f5fc]"),children:A.label},A.key)})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(C,{label:"Head",children:e.jsx("select",{className:k,value:x,onChange:A=>o(A.target.value),children:N.map(A=>e.jsx("option",{value:A,children:A},A))})}),e.jsx(C,{label:"Amount",children:e.jsx("input",{className:k,type:"number",min:"0",value:m,onChange:A=>d(A.target.value),placeholder:"0",autoFocus:!0})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(C,{label:"Date",children:e.jsx("input",{className:k,type:"date",value:u,onChange:A=>b(A.target.value)})}),e.jsx(C,{label:"Payment mode",children:e.jsx("select",{className:k,value:f,onChange:A=>h(A.target.value),children:Qi.map(A=>e.jsx("option",{value:A,children:qs[A]},A))})})]}),e.jsx(C,{label:l==="expense"?"Party (vendor / payee)":"Party (payer)",children:e.jsx("input",{className:k,value:g,onChange:A=>v(A.target.value),placeholder:l==="expense"?"e.g. Acme Housekeeping":"e.g. Flat A-204"})}),e.jsx(C,{label:"Description",children:e.jsx("textarea",{className:k+" h-20 resize-none py-2",value:w,onChange:A=>z(A.target.value),placeholder:"Optional note"})}),E&&e.jsx("p",{className:"text-[12.5px] font-semibold text-[#d63a3a]",children:E})]})})}function sr(){return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mb-5 grid grid-cols-2 gap-3.5 lg:grid-cols-4",children:[0,1,2,3].map(t=>e.jsx("div",{className:T+" h-[112px] animate-pulse"},t))}),e.jsxs("div",{className:"mb-5 grid grid-cols-1 gap-4 lg:grid-cols-2",children:[e.jsx("div",{className:T+" h-[240px] animate-pulse"}),e.jsx("div",{className:T+" h-[240px] animate-pulse"})]}),e.jsx("div",{className:T+" h-[280px] animate-pulse"})]})}const is=[{k:"dashboard",label:"Dashboard",Icon:$n},{k:"directory",label:"Directory",Icon:de},{k:"billing",label:"Billing",Icon:me},{k:"accounts",label:"Accounts",Icon:Un},{k:"helpdesk",label:"Helpdesk",Icon:he},{k:"services",label:"Services",Icon:ft},{k:"amenities",label:"Amenities",Icon:Ye},{k:"communication",label:"Notices",Icon:De},{k:"settings",label:"Settings",Icon:Yn}],rs=[],ar=208,nr=340,ye=244,ht="jaaga.community.sidebarWidth",cs=t=>Math.max(ar,Math.min(nr,Math.round(t||ye)));function Nc(){const t=ta(p=>{var j;return(j=p.login)==null?void 0:j.accessToken}),s=Lt(),[n,i]=a.useState(null),[r,l]=a.useState(null),[c,x]=a.use
126State("dashboard"),[o,m]=a.useState(!1),d=a.useRef(null),u=a.useRef(!1),[b,g]=a.useState(()=>{try{const p=Number(localStorage.getItem(ht));return p?cs(p):ye}catch{return ye}}),v=a.useRef(b);a.useEffect(()=>{const p=E=>{if(!u.current||!d.current)return;const R=d.current.getBoundingClientRect().left,N=cs(E.clientX-R);v.current=N,d.current.style.width=N+"px"},j=()=>{if(u.current){u.current=!1,document.body.style.userSelect="",document.body.style.cursor="",g(v.current);try{localStorage.setItem(ht,String(v.current))}catch{}}};return window.addEventListener("mousemove",p),window.addEventListener("mouseup",j),()=>{window.removeEventListener("mousemove",p),window.removeEventListener("mouseup",j)}},[]);const f=p=>{p.preventDefault(),u.current=!0,document.body.style.userSelect="none",document.body.style.cursor="col-resize"},h=()=>{v.current=ye,g(ye),d.current&&(d.current.style.width=ye+"px");try{localStorage.setItem(ht,String(ye))}catch{}},w=()=>{m(!1),dn().then(p=>{i(p),l(j=>j||p[0]&&p[0]._id||null)}).catch(()=>m(!0))};a.useEffect(()=>{Lt()&&w()},[t]);const z=a.useMemo(()=>(n||[]).find(p=>p._id===r)||null,[n,r]);return s?e.jsxs("div",{className:"flex overflow-hidden bg-[#f4f6fb]",style:{height:"calc(100dvh - 64px)"},children:[e.jsxs("aside",{ref:d,style:{width:b},className:"relative hidden shrink-0 flex-col bg-gradient-to-b from-[#153568] to-[#0f2547] lg:flex",children:[e.jsxs("div",{className:"flex items-center gap-2.5 px-5 py-4",children:[e.jsx("span",{className:"grid h-9 w-9 place-items-center rounded-xl bg-white/10 text-[#f0b437]",children:e.jsx(We,{size:18})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[14.5px] font-extrabold leading-none text-white",children:"Community"}),e.jsx("div",{className:"mt-1 text-[10px] font-bold uppercase tracking-[0.14em] text-[#8fa8d4]",children:"JaaGa"})]})]}),e.jsx("div",{className:"mx-3 mb-2 mt-1 h-px bg-white/10"}),e.jsxs("nav",{className:"flex flex-1 flex-col gap-0.5 px-3",children:[e.jsx("div",{className:"px-3 pb-1.5 text-[9px] font-bold uppercase tracking-[0.16em] text-[#6f88b6]",children:"Manage"}),is.map(p=>{const j=c===p.k;return e.jsxs("button",{onClick:()=>x(p.k),disabled:!z,className:"group flex items-center gap-3 rounded-xl px-3 py-2.5 text-[13.5px] font-bold transition disabled:opacity-40 "+(j?"bg-gradient-to-r from-white/[0.16] to-white/[0.04] text-white shadow-[inset_2px_0_0_#f0b437]":"text-[#b9cbea] hover:bg-white/[0.06] hover:text-white"),children:[e.jsx(p.Icon,{size:17,className:j?"text-[#f0b437]":""})," ",p.label]},p.k)}),rs.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mx-3 my-3 h-px bg-white/10"}),e.jsx("div",{className:"px-3 pb-1 text-[9.5px] font-bold uppercase tracking-[0.14em] text-[#6f88b6]",children:"Rolling out"}),rs.map(p=>e.jsxs("div",{className:"flex items-center gap-3 rounded-xl px-3 py-2 text-[13px] font-semibold text-[#5f7aa8]",children:[e.jsx(p.Icon,{size:16})," ",e.jsx("span",{className:"flex-1",children:p.label}),e.jsx("span",{className:"rounded-full bg-white/[0.07] px-1.5 py-0.5 text-[8.5px] font-bold uppercase tracking-[0.08em] text-[#8fa8d4]",children:"soon"})]},p.label))]})]}),z&&e.jsx("div",{className:"border-t border-white/10 p-3",children:e.jsxs("div",{className:"rounded-xl bg-white/[0.06] px-3 py-2.5",children:[e.jsx("div",{className:"text-[9px] font-bold uppercase tracking-[0.14em] text-[#6f88b6]",children:"Managing"}),e.jsx("div",{className:"mt-0.5 truncate text-[12.5px] font-extrabold text-white",children:z.name}),e.jsxs(it,{to:"/properties/community/resident",className:"mt-2 inline-flex items-center gap-1.5 text-[11px] font-bold text-[#f0b437] transition hover:brightness-110",children:[e.jsx(Kt,{size:12})," Open resident view"]})]})}),e.jsx("div",{onMouseDown:f,onDoubleClick:h,title:"Drag to resize · double-click to reset",className:"group absolute right-0 top-0 z-20 hidden h-full w-2 cursor-col-resize lg:block",children:e.jsx("span",{className:"pointer-events-none absolute right-0 top-0 h-full w-px bg-white/10 transition-all group-hover:w-[3px] group-hover:bg-[#f0b437]/70"})})]}),e.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[e.jsxs("header",{className:"flex-none border-b border-[#e4e8f1] bg-white",children:[e.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 sm:px-6",children:[e.jsx(ir,{societies:n,active:z,onPick:l,onCreated:p=>{i(j=>[p,...j||[]]),l(p._id),x("directory")},onDeleted:p=>{const j=(n||[]).filter(E=>E._id!==p);i(j),l(E=>{var R;return E===p?((R=j[0])==null?void 0:R._id)??null:E})}}),e.jsxs(it,{to:"/properties/community?choose=1",className:"ml-auto inline-flex h-9 shrink-0 items-center gap-1.5 rounded-lg px-2.5 text-[12px] font-bold text-[#586887] transition hover:bg-[#f2f5fc]",title:"Change your Community role",children:[e.jsx(We,{size:13})," ",e.jsx("span",{className:"hidden sm:inline",children:"Change role"})]}),e.jsxs(it,{to:"/properties/community/resident",className:"inline-flex h-9 shrink-0 items-center gap-1.5 rounded-lg border border-[#d6deec] bg-white px-3 text-[12.5px] font-extrabold text-[#153568] transition hover:bg-[#f2f5fc]",title:"Switch to the resident's view",children:[e.jsx(Kt,{size:14})," ",e.jsx("span",{className:"hidden sm:inline",children:"Resident view"})]})]}),z&&e.jsx("div",{className:"flex gap-1.5 overflow-x-auto border-t border-[#eef1f7] px-4 py-2 [scrollbar-width:none] sm:px-6 lg:hidden [&::-webkit-scrollbar]:hidden",children:is.map(p=>e.jsxs("button",{onClick:()=>x(p.k),className:"inline-flex h-9 shrink-0 items-center gap-1.5 rounded-lg px-3 text-[12.5px] font-extrabold transition "+(c===p.k?"bg-gradient-to-br from-[#153568] to-[#1c4b93] text-white":"text-[#586887] hover:bg-[#f2f5fc]"),children:[e.jsx(p.Icon,{size:14})," ",p.label]},p.k))})]}),e.jsx("main",{className:"flex-1 overflow-y-auto px-4 py-5 sm:px-6",children:e.jsx("div",{className:"mx-auto max-w-[1180px]",children:o?e.jsx(dr,{onRetry:w}
126):n===null?e.jsx(or,{}):z?e.jsx(lr,{which:c,societyId:z._id,society:z,onNavigate:x}):e.jsx(cr,{onCreated:p=>{i(j=>[p,...j||[]]),l(p._id),x("directory")}})})})]})]}):e.jsx(Nn,{eyebrow:"JaaGa Community",icon:de,title:"Log in to manage your community",description:"Sign in to set up your society, run billing and manage residents.",cta:"Log in",features:["Billing, dues & accounting","Directory, helpdesk & amenities","List flats on the marketplace"]})}function lr({which:t,societyId:s,society:n,onNavigate:i}){switch(t){case"directory":return e.jsx(sl,{societyId:s});case"billing":return e.jsx(Ml,{societyId:s,society:n,onNavigate:i});case"accounts":return e.jsx(Zi,{societyId:s});case"helpdesk":return e.jsx(Gl,{societyId:s});case"amenities":return e.jsx(Jl,{societyId:s});case"communication":return e.jsx(li,{societyId:s});case"services":return e.jsx(Ii,{societyId:s});case"settings":return e.jsx(Ni,{societyId:s});default:return e.jsx(Sl,{societyId:s,onNavigate:i})}}function ir({societies:t,active:s,onPick:n,onCreated:i,onDeleted:r}){const[l,c]=a.useState(!1),[x,o]=a.useState(!1),[m,d]=a.useState(null),u=a.useRef(null);return a.useEffect(()=>{if(!l)return;const b=v=>{u.current&&!u.current.contains(v.target)&&c(!1)},g=v=>{v.key==="Escape"&&c(!1)};return document.addEventListener("mousedown",b),document.addEventListener("keydown",g),()=>{document.removeEventListener("mousedown",b),document.removeEventListener("keydown",g)}},[l]),s?e.jsxs("div",{className:"relative",ref:u,children:[e.jsxs("button",{onClick:()=>c(b=>!b),className:"flex items-center gap-2 rounded-xl border border-[#e4e8f1] bg-white px-3 py-1.5 text-left transition hover:bg-[#f2f5fc]",children:[e.jsx("span",{className:"grid h-8 w-8 place-items-center rounded-lg bg-gradient-to-br from-[#153568] to-[#1c4b93] text-white",children:e.jsx(de,{size:16})}),e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block max-w-[200px] truncate text-[14px] font-extrabold text-[#0f2547]",children:s.name}),e.jsx("span",{className:"block text-[10.5px] text-[#8493b4]",children:"Managing committee"})]}),e.jsx(Fn,{size:15,className:"text-[#8493b4]"})]}),l&&e.jsxs("div",{className:"absolute left-0 top-full z-30 mt-1 w-[280px] overflow-hidden rounded-xl border border-[#e4e8f1] bg-white shadow-[0_18px_44px_rgba(20,42,82,0.18)]",children:[(t||[]).map(b=>e.jsxs("div",{className:"group flex w-full items-center gap-2 px-3 py-2.5 text-left text-[13px] font-semibold hover:bg-[#f4f7fc] "+(b._id===s._id?"text-[#1c4b93]":"text-[#3b4a68]"),children:[e.jsxs("button",{onClick:()=>{n(b._id),c(!1)},className:"flex min-w-0 flex-1 items-center gap-2 text-left",children:[e.jsx(de,{size:15,className:"shrink-0 text-[#8493b4]"}),e.jsx("span",{className:"truncate",children:b.name})]}),e.jsx("button",{onClick:g=>{g.stopPropagation(),d(b)},title:"Delete society",className:"grid h-7 w-7 shrink-0 place-items-center rounded-lg text-[#a7b3cd] transition hover:bg-[#fdf1f1] hover:text-[#d63a3a]",children:e.jsx(be,{size:14})})]},b._id)),e.jsxs("button",{onClick:()=>{c(!1),o(!0)},className:"flex w-full items-center gap-2 border-t border-[#eef1f7] px-3 py-2.5 text-left text-[13px] font-extrabold text-[#1c4b93] hover:bg-[#f4f7fc]",children:[e.jsx(ae,{size:15})," New society"]})]}),e.jsx(Js,{open:x,onClose:()=>o(!1),onCreated:i}),e.jsx(rr,{society:m,onClose:()=>d(null),onDeleted:b=>{d(null),c(!1),r(b)}})]}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"grid h-9 w-9 place-items-center rounded-xl bg-gradient-to-br from-[#153568] to-[#1c4b93] text-[#f0b437] lg:hidden",children:e.jsx(We,{size:17})}),e.jsx("div",{className:"text-[15px] font-extrabold text-[#0f2547]",children:"JaaGa Community"})]})}function rr({society:t,onClose:s,onDeleted:n}){const[i,r]=a.useState(!1),[l,c]=a.useState("");if(a.useEffect(()=>{r(!1),c("")},[t]),!t)return null;const x=async()=>{var o,m,d;r(!0),c("");try{await xn(t._id),n(t._id)}catch(u){c(((d=(m=(o=u==null?void 0:u.response)==null?void 0:o.data)==null?void 0:m.status)==null?void 0:d.message)||"Couldn't delete. Please try again."),r(!1)}};return wt.createPortal(e.jsx("div",{onClick:s,className:"fixed inset-0 z-[1400] flex items-center justify-center bg-[#0a1932]/50 p-4 backdrop-blur-[2px]",children:e.jsxs("div",{onClick:o=>o.stopPropagation(),className:"w-full max-w-[400px] overflow-hidden rounded-2xl border border-[#e6eaf3] bg-white shadow-[0_40px_80px_-30px_rgba(11,30,61,0.6)]",children:[e.jsxs("div",{className:"flex items-center gap-3 border-b border-[#f6e2e2] bg-[#fdf3f3] px-5 py-4",children:[e.jsx("span",{className:"grid h-9 w-9 place-items-center rounded-xl bg-[#f7d9d9] text-[#d63a3a]",children:e.jsx(te,{size:18})}),e.jsx("h3",{className:"text-[15px] font-extrabold text-[#0f2547]",children:"Delete society"})]}),e.jsxs("div",{className:"px-5 py-4",children:[e.jsxs("p",{className:"text-[13px] leading-relaxed text-[#586887]",children:["Delete ",e.jsx("span",{className:"font-extrabold text-[#0f2547]",children:t.name}),"? This permanently removes the society and its towers, units, billing and residents. The linked property is ",e.jsx("span",{className:"font-semibold",children:"not"})," deleted."]}),l&&e.jsx("p",{className:"mt-2 text-[12.5px] font-semibold text-[#d63a3a]",children:l})]}),e.jsxs("div",{className:"flex justify-end gap-2 border-t border-[#eef1f7] px-5 py-3",children:[e.jsx(y,{variant:"ghost",onClick:s,children:"Cancel"}),e.jsx(y,{variant:"danger",onClick:x,disabled:i,children:i?"Deleting…":"Delete society"})]})]})}),document.body)}function cr({onCreated:t}){const[s,n]=a.useState(!1);return e.jsxs("div",{className:T+" mx-auto mt-6 max-w-[520px] p-8 text-center",children:[e.jsx("div",{className:"mx-auto grid h-14 w-14 place-items-center rounded-2xl bg-gradient-to-br from-[#153568] to-[#1c4b93] text-[#f0b437]",children:e.jsx(We,{size:26})}),e.jsx("h2",{className:"mt-4 text-[20px] font-extrabold text-[#0f2547]",children:"Set up your community"}),e.jsx("p",{className:"mx-auto mt-1.5 max-w-[380px] text-[13.5px] text-[#5b6b8a]",children:"Create your society, add your towers and units, and invite residents — live in days."}),e.jsx("div",{className:"mt-5",children:e.jsx(y,{variant:"navy",icon:e.jsx(ae,{size:16}),onClick:()=>n(!0),children:"Create society"})}),e.jsx(Js,{open:s,onClose:()=>n(!1),onCreated:t})]})}function Js({open:t,onClose:s,onCreated:n}){var N,$;
126const[i,r]=a.useState(null),[l,c]=a.useState(!1),[x,o]=a.useState(!1),[m,d]=a.useState(""),[u,b]=a.useState("apartment"),[g,v]=a.useState("coed"),[f,h]=a.useState("none"),[w,z]=a.useState(!1),[p,j]=a.useState("");if(a.useEffect(()=>{t&&(j(""),z(!1),r(null),c(!1),o(!1),d(""),b("apartment"),v("coed"),h("none"))},[t]),!t)return null;const E=async S=>{if(o(!1),!S)return;const A=await yn(S,{owner:!0}).catch(()=>null);r(A||{_id:S,name:"New property"})},R=async()=>{var S,A,M;if(!i)return j("Add or choose a property first.");z(!0),j("");try{const _={propertyId:i._id,name:m.trim()||void 0,type:u};u==="pg"&&(_.pg={gender:g,foodIncluded:f!=="none",foodType:f==="none"?"none":f});const D=await mn(_);n(D),s()}catch(_){j(((M=(A=(S=_==null?void 0:_.response)==null?void 0:S.data)==null?void 0:A.status)==null?void 0:M.message)||"Couldn't create the society. Please try again."),z(!1)}};return e.jsxs("div",{onClick:s,className:"fixed inset-0 z-[1200] flex items-end justify-center bg-[#0a1932]/50 p-0 backdrop-blur-[2px] sm:items-center sm:p-4",children:[e.jsxs("div",{onClick:S=>S.stopPropagation(),className:"flex max-h-[92vh] w-full max-w-[460px] flex-col overflow-hidden rounded-t-2xl border border-[#e6eaf3] bg-white shadow-[0_40px_80px_-30px_rgba(11,30,61,0.6)] sm:rounded-2xl",children:[e.jsx("div",{className:"border-b border-[#eef1f7] px-5 py-3.5",children:e.jsx("h3",{className:"text-[16px] font-extrabold text-[#0f2547]",children:"Create society"})}),e.jsxs("div",{className:"flex flex-col gap-3 overflow-y-auto px-5 py-4",children:[e.jsxs("div",{children:[e.jsx("span",{className:"mb-1.5 block text-[11px] font-bold uppercase tracking-[0.08em] text-[#8493b4]",children:"What are you managing?"}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:[{k:"apartment",Icon:de,label:"Apartment society",sub:"Towers · flats"},{k:"pg",Icon:fe,label:"PG / Hostel",sub:"Rooms · beds"}].map(S=>{const A=u===S.k;return e.jsxs("button",{type:"button",onClick:()=>b(S.k),className:"flex flex-col items-start gap-1 rounded-xl border px-3 py-2.5 text-left transition "+(A?"border-[#1c4b93] bg-[#eef3fb] shadow-[inset_0_0_0_1px_#1c4b93]":"border-[#e6eaf3] bg-white hover:bg-[#f5f7fc]"),children:[e.jsxs("span",{className:"flex items-center gap-1.5 text-[13px] font-extrabold "+(A?"text-[#1c4b93]":"text-[#3b4a68]"),children:[e.jsx(S.Icon,{size:15})," ",S.label]}),e.jsx("span",{className:"text-[11px] font-semibold text-[#8493b4]",children:S.sub})]},S.k)})})]}),u==="pg"&&e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(C,{label:"Gender",children:e.jsxs("select",{className:k,value:g,onChange:S=>v(S.target.value),children:[e.jsx("option",{value:"male",children:"Male"}),e.jsx("option",{value:"female",children:"Female"}),e.jsx("option",{value:"coed",children:"Co-Living"})]})}),e.jsx(C,{label:"Food",children:e.jsxs("select",{className:k,value:f,onChange:S=>h(S.target.value),children:[e.jsx("option",{value:"none",children:"Not included"}),e.jsx("option",{value:"veg",children:"Veg"}),e.jsx("option",{value:"nonveg",children:"Non-veg"}),e.jsx("option",{value:"both",children:"Both"})]})})]}),i?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"rounded-xl border border-[#1c4b93] bg-[#eef3fb] px-3 py-2.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Pe,{size:14,className:"shrink-0 text-[#1c4b93]"}),e.jsx("span",{className:"truncate text-[13px] font-extrabold text-[#0f2547]",children:i.name}),i.hasGeo&&e.jsxs("span",{className:"inline-flex items-center gap-0.5 text-[10px] font-bold text-[#15964f]",children:[e.jsx(Ke,{size:11})," mapped"]}),e.jsx("button",{type:"button",onClick:()=>r(null),className:"ml-auto text-[11px] font-bold text-[#1c4b93] hover:underline",children:"Change"})]}),e.jsx("div",{className:"mt-0.5 truncate text-[11.5px] text-[#8493b4]",children:[((N=i.type)==null?void 0:N.name)||(($=i.type)==null?void 0:$.key),i.addressLine1,i.city].filter(Boolean).join(" · ")})]}),e.jsx(C,{label:"Society name (optional — defaults to the property's name)",children:e.jsx("input",{className:k,placeholder:(i==null?void 0:i.name)||"e.g. Green Meadows RWA",value:m,onChange:S=>d(S.target.value)})})]}):e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",onClick:()=>o(!0),className:"flex w-full items-center justify-center gap-2 rounded-xl border-2 border-dashed border-[#c9d6ef] py-3 text-[13.5px] font-extrabold text-[#1c4b93] transition hover:border-[#1c4b93] hover:bg-[#f4f7fc]",children:[e.jsx(ae,{size:17})," Add a new property"]}),e.jsxs("button",{type:"button",onClick:()=>c(!0),className:"flex w-full items-center justify-center gap-2 rounded-xl border border-[#e6eaf3] bg-white py-2.5 text-[12.5px] font-extrabold text-[#153568] transition hover:bg-[#f5f7fc]",children:[e.jsx(de,{size:15}
126)," Choose from my properties"]})]}),p&&e.jsx("p",{className:"text-[12.5px] font-semibold text-[#d63a3a]",children:p})]}),e.jsxs("div",{className:"flex justify-end gap-2 border-t border-[#eef1f7] px-5 py-3",children:[e.jsx(y,{variant:"ghost",onClick:s,children:"Cancel"}),e.jsx(y,{variant:"navy",onClick:R,disabled:w||!i,children:w?"Creating…":"Create society"})]})]}),l&&e.jsx(js,{title:"Choose a property",subtitle:"Pick a property to set up as a society",fetchPage:gs,onAddProperty:()=>{c(!1),o(!0)},onPick:S=>{r(S),c(!1)},onClose:()=>c(!1)}),x&&wt.createPortal(e.jsx("div",{className:"fixed inset-0 z-[1300] flex items-center justify-center bg-black/45 p-4",onClick:S=>S.stopPropagation(),children:e.jsx("div",{className:"w-full max-w-[780px]",children:e.jsx(jn,{setShowAddproperty:o,propertyFetch:()=>{},setSuccessModal:()=>{},onCreated:E})})}),document.body)]})}function or(){return e.jsxs("div",{className:"flex items-center justify-center gap-2 py-20 text-[13px] font-semibold text-[#586887]",children:[e.jsx(ne,{size:18,className:"animate-spin text-[#1c4b93]"})," Loading your community…"]})}function dr({onRetry:t}){return e.jsxs("div",{className:T+" mx-auto mt-6 max-w-[460px] p-8 text-center",children:[e.jsx("h3",{className:"text-[16px] font-extrabold text-[#153568]",children:"Couldn't load"}),e.jsx("p",{className:"mt-1 text-[13px] text-[#5b6b8a]",children:"Please sign in and try again."}),e.jsx("div",{className:"mt-4",children:e.jsx(y,{variant:"navy",onClick:t,children:"Retry"})})]})}export{Nc as default};
127//# sourceMappingURL=CommunityConsole-1b09a190.js.map

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.