@wealthx/shadcn 1.2.1 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (247) hide show
  1. package/.turbo/turbo-build.log +203 -150
  2. package/CHANGELOG.md +29 -0
  3. package/dist/{chunk-4Y6R4WEC.mjs → chunk-2A5RRQGG.mjs} +9 -22
  4. package/dist/{chunk-TS2ZX2VS.mjs → chunk-2UM72RJ7.mjs} +11 -15
  5. package/dist/{chunk-A56YQQHG.mjs → chunk-3NCUZIFP.mjs} +2 -2
  6. package/dist/chunk-3OYFOX3X.mjs +79 -0
  7. package/dist/{chunk-RP3SQYA3.mjs → chunk-3TTACBDP.mjs} +9 -4
  8. package/dist/chunk-4GAWMKMI.mjs +710 -0
  9. package/dist/{chunk-SYOD63OZ.mjs → chunk-5FQIKDKP.mjs} +6 -6
  10. package/dist/{chunk-K3JYD4IU.mjs → chunk-5IS7G74I.mjs} +11 -4
  11. package/dist/chunk-6AW4KJHE.mjs +235 -0
  12. package/dist/chunk-6CR5N2JW.mjs +302 -0
  13. package/dist/{chunk-XIRTEFKH.mjs → chunk-6DZEXFNB.mjs} +36 -8
  14. package/dist/chunk-6O6KD7CE.mjs +271 -0
  15. package/dist/chunk-7PV3IWCN.mjs +33 -0
  16. package/dist/{chunk-SPJ5KXW7.mjs → chunk-7S5AESZO.mjs} +5 -5
  17. package/dist/{chunk-RYCLWMZ7.mjs → chunk-ABFDMHOR.mjs} +9 -7
  18. package/dist/{chunk-SWGT756Z.mjs → chunk-AMQZRHEZ.mjs} +10 -4
  19. package/dist/{chunk-WOEHFRGB.mjs → chunk-BDYZCBRT.mjs} +4 -4
  20. package/dist/{chunk-WAZD7NFU.mjs → chunk-BKNFWEH2.mjs} +6 -6
  21. package/dist/{chunk-CLIN5525.mjs → chunk-C7CQJNMR.mjs} +1 -1
  22. package/dist/{chunk-D4ILTPOG.mjs → chunk-CFMQP5QS.mjs} +5 -4
  23. package/dist/{chunk-VPBN3WOO.mjs → chunk-DGHAXJBN.mjs} +9 -7
  24. package/dist/chunk-DOEO3CDL.mjs +27 -0
  25. package/dist/{chunk-KUDCQ4FI.mjs → chunk-DUJTAXMH.mjs} +9 -4
  26. package/dist/{chunk-GGM2UYGG.mjs → chunk-EBXQWIYG.mjs} +10 -4
  27. package/dist/{chunk-PMB3A7V3.mjs → chunk-EI5F6FMT.mjs} +1 -1
  28. package/dist/chunk-EWRB4PAD.mjs +468 -0
  29. package/dist/chunk-FAKPBKLT.mjs +253 -0
  30. package/dist/chunk-FNQXOAYJ.mjs +169 -0
  31. package/dist/{chunk-4CX4SBRO.mjs → chunk-GHC7LLUX.mjs} +14 -5
  32. package/dist/chunk-HBZLGDIN.mjs +507 -0
  33. package/dist/{chunk-SIZMLSRU.mjs → chunk-HISNT2MG.mjs} +8 -6
  34. package/dist/{chunk-PR6V5XKM.mjs → chunk-HVY6KCCF.mjs} +7 -4
  35. package/dist/chunk-I3RZS7V2.mjs +136 -0
  36. package/dist/chunk-IAE3F7DR.mjs +1962 -0
  37. package/dist/{chunk-ZRO5JO3H.mjs → chunk-IHMFS7NZ.mjs} +81 -84
  38. package/dist/{chunk-PCPLO5HT.mjs → chunk-IOJRDS6V.mjs} +96 -14
  39. package/dist/{chunk-LHYCMLVA.mjs → chunk-JKGDCQTZ.mjs} +11 -4
  40. package/dist/{chunk-H45TKD34.mjs → chunk-JMHR3YGZ.mjs} +1 -1
  41. package/dist/{chunk-4MN6UQHG.mjs → chunk-K5A5L6T2.mjs} +17 -39
  42. package/dist/{chunk-CSDO6VBW.mjs → chunk-LBMRIB3G.mjs} +10 -10
  43. package/dist/chunk-LV35NGVG.mjs +272 -0
  44. package/dist/{chunk-FZIXGLMV.mjs → chunk-M3FV7LOK.mjs} +5 -12
  45. package/dist/{chunk-FMAXJ2SI.mjs → chunk-MBON7YRJ.mjs} +1 -1
  46. package/dist/chunk-MIZQHHUO.mjs +441 -0
  47. package/dist/chunk-MN5NYQCL.mjs +29 -0
  48. package/dist/chunk-NL3ZO62D.mjs +31 -0
  49. package/dist/{chunk-Q76O3RIQ.mjs → chunk-NMOI6CQD.mjs} +1 -1
  50. package/dist/{chunk-P6AM5V7O.mjs → chunk-OODBHKG7.mjs} +1 -1
  51. package/dist/chunk-PBL4OQV2.mjs +283 -0
  52. package/dist/{chunk-3WMX6KWS.mjs → chunk-PU4YZQXV.mjs} +11 -12
  53. package/dist/chunk-QMY3AZJH.mjs +80 -0
  54. package/dist/{chunk-BL3DXM2X.mjs → chunk-QZ4RE6NA.mjs} +11 -4
  55. package/dist/{chunk-VACKZOMY.mjs → chunk-R3VSPKNP.mjs} +3 -3
  56. package/dist/{chunk-OPNQAVVH.mjs → chunk-RJI6GKVF.mjs} +8 -6
  57. package/dist/{chunk-WG6JGJXB.mjs → chunk-T4BJLT57.mjs} +1 -1
  58. package/dist/chunk-U4NDAF2P.mjs +207 -0
  59. package/dist/{chunk-DOH3EHX7.mjs → chunk-U5X52X37.mjs} +1 -1
  60. package/dist/chunk-UMTOX62O.mjs +415 -0
  61. package/dist/{chunk-7MMXNK3C.mjs → chunk-VLARHE5V.mjs} +8 -6
  62. package/dist/{chunk-2I5S2AMY.mjs → chunk-XREGSKX3.mjs} +2 -2
  63. package/dist/{chunk-JNQORUPP.mjs → chunk-YJG55G2H.mjs} +14 -11
  64. package/dist/chunk-ZC45IGZO.mjs +388 -0
  65. package/dist/components/ui/add-column-modal.js +42 -14
  66. package/dist/components/ui/add-column-modal.mjs +4 -4
  67. package/dist/components/ui/add-lead-modal.js +42 -11
  68. package/dist/components/ui/add-lead-modal.mjs +3 -3
  69. package/dist/components/ui/advisor-card.js +497 -0
  70. package/dist/components/ui/advisor-card.mjs +13 -0
  71. package/dist/components/ui/ai-assistant-drawer.js +11 -10
  72. package/dist/components/ui/ai-assistant-drawer.mjs +3 -3
  73. package/dist/components/ui/alert-dialog.js +2 -2
  74. package/dist/components/ui/alert-dialog.mjs +2 -2
  75. package/dist/components/ui/appointment-action-dialogs.js +1160 -0
  76. package/dist/components/ui/appointment-action-dialogs.mjs +23 -0
  77. package/dist/components/ui/appointment-availability-settings.js +1590 -0
  78. package/dist/components/ui/appointment-availability-settings.mjs +23 -0
  79. package/dist/components/ui/appointment-book-dialog.js +1744 -0
  80. package/dist/components/ui/appointment-book-dialog.mjs +27 -0
  81. package/dist/components/ui/appointment-calendar-view.js +833 -0
  82. package/dist/components/ui/appointment-calendar-view.mjs +14 -0
  83. package/dist/components/ui/appointment-detail-sheet.js +1517 -0
  84. package/dist/components/ui/appointment-detail-sheet.mjs +24 -0
  85. package/dist/components/ui/appointment-gmail-connect.js +467 -0
  86. package/dist/components/ui/appointment-gmail-connect.mjs +14 -0
  87. package/dist/components/ui/appointment-mini-card.js +345 -0
  88. package/dist/components/ui/appointment-mini-card.mjs +11 -0
  89. package/dist/components/ui/appointment-time-slot-picker.js +311 -0
  90. package/dist/components/ui/appointment-time-slot-picker.mjs +13 -0
  91. package/dist/components/ui/appointment-upcoming-card.js +1268 -0
  92. package/dist/components/ui/appointment-upcoming-card.mjs +21 -0
  93. package/dist/components/ui/backoffice-alert-history-chart.js +11 -5
  94. package/dist/components/ui/backoffice-alert-history-chart.mjs +5 -4
  95. package/dist/components/ui/backoffice-alerts-chart.js +786 -0
  96. package/dist/components/ui/backoffice-alerts-chart.mjs +19 -0
  97. package/dist/components/ui/backoffice-connections-chart.js +817 -0
  98. package/dist/components/ui/backoffice-connections-chart.mjs +19 -0
  99. package/dist/components/ui/backoffice-contact-history-chart.js +11 -5
  100. package/dist/components/ui/backoffice-contact-history-chart.mjs +5 -4
  101. package/dist/components/ui/badge.js +6 -6
  102. package/dist/components/ui/badge.mjs +1 -1
  103. package/dist/components/ui/borrowing-capacity-line-chart.js +30 -21
  104. package/dist/components/ui/borrowing-capacity-line-chart.mjs +5 -4
  105. package/dist/components/ui/button.js +2 -2
  106. package/dist/components/ui/button.mjs +1 -1
  107. package/dist/components/ui/calendar.js +2 -2
  108. package/dist/components/ui/calendar.mjs +2 -2
  109. package/dist/components/ui/card.js +1 -1
  110. package/dist/components/ui/card.mjs +1 -1
  111. package/dist/components/ui/cash-balance-line-chart.js +31 -23
  112. package/dist/components/ui/cash-balance-line-chart.mjs +5 -4
  113. package/dist/components/ui/cashflow-bar-chart.js +12 -5
  114. package/dist/components/ui/cashflow-bar-chart.mjs +5 -4
  115. package/dist/components/ui/chip.js +97 -18
  116. package/dist/components/ui/chip.mjs +3 -2
  117. package/dist/components/ui/color-picker.js +547 -0
  118. package/dist/components/ui/color-picker.mjs +24 -0
  119. package/dist/components/ui/data-table.js +182 -129
  120. package/dist/components/ui/data-table.mjs +3 -2
  121. package/dist/components/ui/date-picker.js +48 -27
  122. package/dist/components/ui/date-picker.mjs +4 -3
  123. package/dist/components/ui/dialog.js +37 -9
  124. package/dist/components/ui/dialog.mjs +2 -2
  125. package/dist/components/ui/expense-bar-chart.js +12 -5
  126. package/dist/components/ui/expense-bar-chart.mjs +5 -4
  127. package/dist/components/ui/field.mjs +2 -2
  128. package/dist/components/ui/financial-cards.js +322 -155
  129. package/dist/components/ui/financial-cards.mjs +5 -3
  130. package/dist/components/ui/financial-drawers.js +2 -2
  131. package/dist/components/ui/financial-drawers.mjs +3 -3
  132. package/dist/components/ui/financial-sections.js +14 -10
  133. package/dist/components/ui/financial-sections.mjs +6 -5
  134. package/dist/components/ui/form-primitives.js +4 -4
  135. package/dist/components/ui/form-primitives.mjs +3 -3
  136. package/dist/components/ui/income-bar-chart.js +12 -5
  137. package/dist/components/ui/income-bar-chart.mjs +5 -4
  138. package/dist/components/ui/input-group.js +2 -2
  139. package/dist/components/ui/input-group.mjs +2 -2
  140. package/dist/components/ui/kanban-column.js +52 -44
  141. package/dist/components/ui/kanban-column.mjs +7 -5
  142. package/dist/components/ui/opportunity-card.js +52 -44
  143. package/dist/components/ui/opportunity-card.mjs +6 -4
  144. package/dist/components/ui/opportunity-edit-modals.js +1371 -1267
  145. package/dist/components/ui/opportunity-edit-modals.mjs +10 -10
  146. package/dist/components/ui/opportunity-summary-tab.js +2748 -2161
  147. package/dist/components/ui/opportunity-summary-tab.mjs +16 -16
  148. package/dist/components/ui/page-header.js +92 -0
  149. package/dist/components/ui/page-header.mjs +8 -0
  150. package/dist/components/ui/page-top-bar.js +88 -0
  151. package/dist/components/ui/page-top-bar.mjs +8 -0
  152. package/dist/components/ui/pagination.js +303 -19
  153. package/dist/components/ui/pagination.mjs +11 -4
  154. package/dist/components/ui/pipeline-board.js +209 -195
  155. package/dist/components/ui/pipeline-board.mjs +10 -8
  156. package/dist/components/ui/pipeline-dialogs.js +118 -69
  157. package/dist/components/ui/pipeline-dialogs.mjs +8 -7
  158. package/dist/components/ui/pipeline-primitives.js +6 -6
  159. package/dist/components/ui/pipeline-primitives.mjs +2 -2
  160. package/dist/components/ui/property-cashflow-doughnut-chart.js +14 -12
  161. package/dist/components/ui/property-cashflow-doughnut-chart.mjs +5 -4
  162. package/dist/components/ui/property-debt-equity-doughnut-chart.js +14 -12
  163. package/dist/components/ui/property-debt-equity-doughnut-chart.mjs +5 -4
  164. package/dist/components/ui/property-mobile-estimate-line-chart.js +16 -14
  165. package/dist/components/ui/property-mobile-estimate-line-chart.mjs +5 -4
  166. package/dist/components/ui/sidebar-nav.js +679 -0
  167. package/dist/components/ui/sidebar-nav.mjs +14 -0
  168. package/dist/components/ui/stage-timeline.js +6 -6
  169. package/dist/components/ui/stage-timeline.mjs +3 -3
  170. package/dist/components/ui/stepper.js +283 -0
  171. package/dist/components/ui/stepper.mjs +18 -0
  172. package/dist/components/ui/toggle-group.js +4 -4
  173. package/dist/components/ui/toggle-group.mjs +2 -2
  174. package/dist/components/ui/toggle.js +4 -4
  175. package/dist/components/ui/toggle.mjs +1 -1
  176. package/dist/components/ui/transactions-expense-categories-doughnut-chart.js +18 -16
  177. package/dist/components/ui/transactions-expense-categories-doughnut-chart.mjs +5 -4
  178. package/dist/components/ui/transactions-income-expense-bar-chart.js +28 -12
  179. package/dist/components/ui/transactions-income-expense-bar-chart.mjs +5 -4
  180. package/dist/components/ui/transactions-liabilities-breakdown-doughnut-chart.js +18 -16
  181. package/dist/components/ui/transactions-liabilities-breakdown-doughnut-chart.mjs +5 -4
  182. package/dist/index.js +12927 -8522
  183. package/dist/index.mjs +288 -190
  184. package/dist/lib/typography.js +10 -10
  185. package/dist/lib/typography.mjs +1 -1
  186. package/dist/styles.css +1 -1
  187. package/package.json +86 -1
  188. package/src/components/index.tsx +146 -0
  189. package/src/components/ui/add-column-modal.tsx +7 -7
  190. package/src/components/ui/add-lead-modal.tsx +6 -3
  191. package/src/components/ui/advisor-card.tsx +227 -0
  192. package/src/components/ui/ai-assistant-drawer.tsx +4 -3
  193. package/src/components/ui/appointment-action-dialogs.tsx +297 -0
  194. package/src/components/ui/appointment-availability-settings.tsx +645 -0
  195. package/src/components/ui/appointment-book-dialog.tsx +618 -0
  196. package/src/components/ui/appointment-calendar-view.tsx +510 -0
  197. package/src/components/ui/appointment-detail-sheet.tsx +415 -0
  198. package/src/components/ui/appointment-gmail-connect.tsx +188 -0
  199. package/src/components/ui/appointment-mini-card.tsx +104 -0
  200. package/src/components/ui/appointment-time-slot-picker.tsx +123 -0
  201. package/src/components/ui/appointment-upcoming-card.tsx +635 -0
  202. package/src/components/ui/backoffice-alert-history-chart.tsx +10 -2
  203. package/src/components/ui/backoffice-alerts-chart.tsx +312 -0
  204. package/src/components/ui/backoffice-connections-chart.tsx +339 -0
  205. package/src/components/ui/backoffice-contact-history-chart.tsx +10 -2
  206. package/src/components/ui/badge.tsx +12 -6
  207. package/src/components/ui/borrowing-capacity-line-chart.tsx +4 -11
  208. package/src/components/ui/button.tsx +2 -2
  209. package/src/components/ui/card.tsx +1 -1
  210. package/src/components/ui/cash-balance-line-chart.tsx +4 -23
  211. package/src/components/ui/cashflow-bar-chart.tsx +9 -2
  212. package/src/components/ui/chart-shared.tsx +4 -11
  213. package/src/components/ui/chip.tsx +23 -19
  214. package/src/components/ui/color-picker.tsx +309 -0
  215. package/src/components/ui/data-table.tsx +117 -83
  216. package/src/components/ui/date-picker.tsx +42 -37
  217. package/src/components/ui/dialog.tsx +72 -6
  218. package/src/components/ui/expense-bar-chart.tsx +11 -2
  219. package/src/components/ui/financial-cards.tsx +99 -10
  220. package/src/components/ui/income-bar-chart.tsx +11 -2
  221. package/src/components/ui/opportunity-card.tsx +10 -39
  222. package/src/components/ui/opportunity-edit-modals.tsx +98 -36
  223. package/src/components/ui/opportunity-summary-tab.tsx +548 -232
  224. package/src/components/ui/page-header.tsx +57 -0
  225. package/src/components/ui/page-top-bar.tsx +48 -0
  226. package/src/components/ui/pagination.tsx +171 -22
  227. package/src/components/ui/pipeline-board.tsx +12 -5
  228. package/src/components/ui/property-cashflow-doughnut-chart.tsx +3 -1
  229. package/src/components/ui/property-debt-equity-doughnut-chart.tsx +3 -1
  230. package/src/components/ui/property-mobile-estimate-line-chart.tsx +3 -1
  231. package/src/components/ui/sidebar-nav.tsx +516 -0
  232. package/src/components/ui/stepper.tsx +347 -0
  233. package/src/components/ui/toggle.tsx +4 -4
  234. package/src/components/ui/transactions-expense-categories-doughnut-chart.tsx +3 -1
  235. package/src/components/ui/transactions-income-expense-bar-chart.tsx +12 -9
  236. package/src/components/ui/transactions-liabilities-breakdown-doughnut-chart.tsx +3 -1
  237. package/src/lib/format-currency.ts +44 -0
  238. package/src/lib/format-date.ts +50 -0
  239. package/src/lib/opportunity-constants.ts +12 -0
  240. package/src/lib/typography.ts +11 -11
  241. package/src/styles/globals.css +36 -34
  242. package/src/styles/styles-css.ts +1 -1
  243. package/tsup.config.ts +17 -0
  244. package/dist/chunk-PG6K5XEC.mjs +0 -475
  245. package/dist/chunk-WA6O6EUR.mjs +0 -1885
  246. package/dist/chunk-WNGWBVLV.mjs +0 -148
  247. package/dist/{chunk-LLVQKSU3.mjs → chunk-GD4BJDJR.mjs} +3 -3
@@ -0,0 +1,1962 @@
1
+ import {
2
+ DatePicker
3
+ } from "./chunk-DUJTAXMH.mjs";
4
+ import {
5
+ AddressAutocomplete,
6
+ CurrencyInputWithSlider,
7
+ OwnershipSplit
8
+ } from "./chunk-U5X52X37.mjs";
9
+ import {
10
+ Slider
11
+ } from "./chunk-Y6DWJSKZ.mjs";
12
+ import {
13
+ RadioGroup,
14
+ RadioGroupItem
15
+ } from "./chunk-7XJHLGUV.mjs";
16
+ import {
17
+ ToggleGroup,
18
+ ToggleGroupItem
19
+ } from "./chunk-EI5F6FMT.mjs";
20
+ import {
21
+ Textarea
22
+ } from "./chunk-34NWQURD.mjs";
23
+ import {
24
+ Accordion,
25
+ AccordionContent,
26
+ AccordionItem
27
+ } from "./chunk-MARPPFOJ.mjs";
28
+ import {
29
+ Select,
30
+ SelectContent,
31
+ SelectItem,
32
+ SelectTrigger,
33
+ SelectValue
34
+ } from "./chunk-7PYJD5JI.mjs";
35
+ import {
36
+ Label
37
+ } from "./chunk-NSLMILBT.mjs";
38
+ import {
39
+ Checkbox
40
+ } from "./chunk-RGVKLTLH.mjs";
41
+ import {
42
+ Input
43
+ } from "./chunk-GYMYRIZP.mjs";
44
+ import {
45
+ Dialog,
46
+ DialogContent,
47
+ DialogFooter,
48
+ DialogHeader,
49
+ DialogTitle
50
+ } from "./chunk-6DZEXFNB.mjs";
51
+ import {
52
+ Button
53
+ } from "./chunk-XREGSKX3.mjs";
54
+ import {
55
+ cn
56
+ } from "./chunk-VLQZANBF.mjs";
57
+ import {
58
+ __spreadProps,
59
+ __spreadValues
60
+ } from "./chunk-FWCSY2DS.mjs";
61
+
62
+ // src/components/ui/opportunity-edit-modals.tsx
63
+ import * as React from "react";
64
+ import { ChevronDownIcon, Plus, Trash2 } from "lucide-react";
65
+
66
+ // src/lib/opportunity-constants.ts
67
+ var PROPERTY_ASSET_TYPES = /* @__PURE__ */ new Set([
68
+ "Primary Residence",
69
+ "Investment Property",
70
+ "Holiday Home",
71
+ "Commercial Property",
72
+ "Rural Property"
73
+ ]);
74
+
75
+ // src/components/ui/opportunity-edit-modals.tsx
76
+ import { Accordion as AccordionPrimitive } from "@base-ui/react/accordion";
77
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
78
+ var LOAN_PURPOSES = [
79
+ "Purchase a home",
80
+ "Refinance my home loan",
81
+ "Buy an investment property",
82
+ "Refinance investment loan",
83
+ "Renovate/build",
84
+ "Equity release"
85
+ ];
86
+ var ASSET_TYPES = [
87
+ "Primary Residence",
88
+ "Investment Property",
89
+ "Holiday Home",
90
+ "Commercial Property",
91
+ "Rural Property",
92
+ "Cash & Savings",
93
+ "Term Deposit",
94
+ "Shares / ETFs",
95
+ "Managed Funds",
96
+ "Superannuation",
97
+ "Motor Vehicle",
98
+ "Business Equity",
99
+ "Cryptocurrency",
100
+ "Personal Belongings",
101
+ "Life Insurance",
102
+ "Trust Assets",
103
+ "SMSF",
104
+ "Bonds / Fixed Income",
105
+ "Other"
106
+ ];
107
+ var PROPERTY_SUBTYPES = [
108
+ "House",
109
+ "Unit / Apartment",
110
+ "Townhouse",
111
+ "Land",
112
+ "Rural / Farm",
113
+ "Commercial"
114
+ ];
115
+ var PROPERTY_USED_AS = ["Owner Occupied", "Investment", "Vacant Land"];
116
+ var FINANCIAL_ACCOUNT_ASSET_TYPES = /* @__PURE__ */ new Set([
117
+ "Cash & Savings",
118
+ "Term Deposit"
119
+ ]);
120
+ var INVESTMENT_ASSET_TYPES = /* @__PURE__ */ new Set([
121
+ "Shares / ETFs",
122
+ "Managed Funds",
123
+ "Bonds / Fixed Income",
124
+ "Cryptocurrency"
125
+ ]);
126
+ var SUPER_ASSET_TYPES = /* @__PURE__ */ new Set(["Superannuation", "SMSF"]);
127
+ function assetFields(type) {
128
+ return {
129
+ isProperty: PROPERTY_ASSET_TYPES.has(type),
130
+ isVehicle: type === "Motor Vehicle",
131
+ isFinancialAccount: FINANCIAL_ACCOUNT_ASSET_TYPES.has(type),
132
+ isInvestment: INVESTMENT_ASSET_TYPES.has(type),
133
+ isSuper: SUPER_ASSET_TYPES.has(type),
134
+ isBusiness: type === "Business Equity",
135
+ isInsurance: type === "Life Insurance"
136
+ };
137
+ }
138
+ var PROPERTY_LOAN_DEBT_TYPES = /* @__PURE__ */ new Set([
139
+ "Home Loan (Owner Occupied)",
140
+ "Home Loan (Investment)",
141
+ "Construction Loan"
142
+ ]);
143
+ var GENERAL_LOAN_DEBT_TYPES = /* @__PURE__ */ new Set([
144
+ "Personal Loan",
145
+ "Business Loan",
146
+ "Overdraft",
147
+ "Line of Credit",
148
+ "Guarantor Liability"
149
+ ]);
150
+ var CARD_DEBT_TYPES = /* @__PURE__ */ new Set([
151
+ "Credit Card",
152
+ "Store Card",
153
+ "Buy Now Pay Later"
154
+ ]);
155
+ var VEHICLE_DEBT_TYPES = /* @__PURE__ */ new Set(["Car Loan", "Vehicle Lease"]);
156
+ function debtFields(type) {
157
+ return {
158
+ isPropertyLoan: PROPERTY_LOAN_DEBT_TYPES.has(type),
159
+ isGeneralLoan: GENERAL_LOAN_DEBT_TYPES.has(type),
160
+ isCard: CARD_DEBT_TYPES.has(type),
161
+ isVehicle: VEHICLE_DEBT_TYPES.has(type),
162
+ isHecs: type === "HECS / Student Debt",
163
+ isTax: type === "Tax Debt",
164
+ isGuarantor: type === "Guarantor Liability"
165
+ };
166
+ }
167
+ var DEBT_TYPES = [
168
+ "Home Loan (Owner Occupied)",
169
+ "Home Loan (Investment)",
170
+ "Construction Loan",
171
+ "Personal Loan",
172
+ "Car Loan",
173
+ "Credit Card",
174
+ "Store Card",
175
+ "HECS / Student Debt",
176
+ "Business Loan",
177
+ "Overdraft",
178
+ "Tax Debt",
179
+ "Buy Now Pay Later",
180
+ "Vehicle Lease",
181
+ "Guarantor Liability",
182
+ "Line of Credit",
183
+ "Other"
184
+ ];
185
+ var TITLE_OPTIONS = ["Mr", "Mrs", "Ms", "Dr", "Prof"];
186
+ var GENDER_OPTIONS = ["Male", "Female", "Non-binary", "Prefer not to say"];
187
+ var MARITAL_OPTIONS = [
188
+ "Single",
189
+ "Married",
190
+ "De facto",
191
+ "Divorced",
192
+ "Widowed"
193
+ ];
194
+ var CITIZEN_OPTIONS = [
195
+ "Australian Citizen",
196
+ "Permanent Resident",
197
+ "Temporary Resident",
198
+ "Foreign National"
199
+ ];
200
+ var RESIDENTIAL_STATUS_OPTIONS = [
201
+ "Own",
202
+ "Renting",
203
+ "Boarding",
204
+ "With Parents",
205
+ "Other"
206
+ ];
207
+ var PROPERTY_IN_TRUST_OPTIONS = ["None", "Yes - Discretionary", "Yes - Unit"];
208
+ var COMPANY_OWNERSHIP_OPTIONS = [
209
+ "None",
210
+ "Yes - Director",
211
+ "Yes - Shareholder"
212
+ ];
213
+ var INCOME_TYPES = [
214
+ "PAYG",
215
+ "Self-employed",
216
+ "Contractor",
217
+ "Casual",
218
+ "Commission",
219
+ "Government Benefits",
220
+ "Rental",
221
+ "Other"
222
+ ];
223
+ var EXPENSE_TYPES = [
224
+ "Groceries",
225
+ "Dining Out",
226
+ "Transport",
227
+ "Fuel",
228
+ "Utilities",
229
+ "Phone Plan",
230
+ "Internet",
231
+ "Medical",
232
+ "Entertainment",
233
+ "Clothing",
234
+ "Gym & Fitness",
235
+ "Subscriptions",
236
+ "Childcare",
237
+ "Education",
238
+ "Pet Care",
239
+ "Insurance",
240
+ "Council Rates",
241
+ "Body Corp / Strata",
242
+ "Home Maintenance",
243
+ "Travel & Holidays",
244
+ "Donations",
245
+ "Other"
246
+ ];
247
+ var PRIORITIES = [
248
+ "Maximize Borrow Amount",
249
+ "Cheapest Interest Rate",
250
+ "The Best Features",
251
+ "Major Lender",
252
+ "Small Lender",
253
+ "Regional Lender",
254
+ "Non-Bank Lender",
255
+ "Branch Network",
256
+ "Good Customer Service",
257
+ "Environmentally Friendly Lender"
258
+ ];
259
+ function FormField({
260
+ label,
261
+ children,
262
+ className
263
+ }) {
264
+ return /* @__PURE__ */ jsxs("div", { className: cn("flex flex-col gap-1.5", className), children: [
265
+ /* @__PURE__ */ jsx(Label, { className: "text-sm font-medium text-muted-foreground", children: label }),
266
+ children
267
+ ] });
268
+ }
269
+ function ModalScroll({ children }) {
270
+ return /* @__PURE__ */ jsx("div", { className: "max-h-[65vh] overflow-y-auto flex flex-col gap-4 py-1 pr-1", children });
271
+ }
272
+ function FrequencyToggle({
273
+ value,
274
+ onValueChange
275
+ }) {
276
+ return /* @__PURE__ */ jsxs(
277
+ ToggleGroup,
278
+ {
279
+ variant: "outline",
280
+ value,
281
+ onValueChange: (val) => {
282
+ if (val === "Monthly" || val === "Weekly") {
283
+ onValueChange(val);
284
+ }
285
+ },
286
+ children: [
287
+ /* @__PURE__ */ jsx(ToggleGroupItem, { value: "Monthly", size: "sm", children: "Monthly" }),
288
+ /* @__PURE__ */ jsx(ToggleGroupItem, { value: "Weekly", size: "sm", children: "Weekly" })
289
+ ]
290
+ }
291
+ );
292
+ }
293
+ function AccordionItemHeader({
294
+ label,
295
+ onRemove,
296
+ removeLabel = "Remove item"
297
+ }) {
298
+ return /* @__PURE__ */ jsxs(AccordionPrimitive.Header, { className: "flex items-center", children: [
299
+ /* @__PURE__ */ jsxs(
300
+ AccordionPrimitive.Trigger,
301
+ {
302
+ className: cn(
303
+ "flex flex-1 items-center justify-between gap-4 py-4 text-left",
304
+ "text-label-medium rounded-none outline-none transition-[color,opacity]",
305
+ "hover:underline focus-visible:ring-2 focus-visible:ring-foreground/30",
306
+ "[&[data-panel-open]>svg]:rotate-180"
307
+ ),
308
+ children: [
309
+ label,
310
+ /* @__PURE__ */ jsx(ChevronDownIcon, { className: "pointer-events-none size-4 shrink-0 text-muted-foreground transition-transform duration-200" })
311
+ ]
312
+ }
313
+ ),
314
+ /* @__PURE__ */ jsx(
315
+ Button,
316
+ {
317
+ type: "button",
318
+ variant: "ghost",
319
+ size: "icon",
320
+ onClick: onRemove,
321
+ className: "size-8 shrink-0",
322
+ "aria-label": removeLabel,
323
+ children: /* @__PURE__ */ jsx(Trash2, { className: "size-3.5 text-destructive" })
324
+ }
325
+ )
326
+ ] });
327
+ }
328
+ var LOAN_SCENARIO_DEFAULTS = {
329
+ loanPurpose: "",
330
+ propertyEstimate: 0,
331
+ cashEquity: 0,
332
+ loanAmount: 0,
333
+ loanDuration: 30,
334
+ knowsFeatures: "",
335
+ featureFixedRate: false,
336
+ featureVariableRate: false,
337
+ featureSplitLoan: false,
338
+ featureInterestOnly: false,
339
+ featureRedrawFacility: false,
340
+ feature100Offset: false,
341
+ priorities: [],
342
+ borrowOtherThanProperty: "",
343
+ concernedAboutRates: "",
344
+ considerFixedRate: "",
345
+ retirementAge: "",
346
+ anticipatedChanges: ""
347
+ };
348
+ var ABOUT_APPLICANT_DEFAULTS = {
349
+ title: "",
350
+ firstName: "",
351
+ lastName: "",
352
+ phone: "",
353
+ email: "",
354
+ dob: "",
355
+ gender: "",
356
+ maritalStatus: "",
357
+ numDependants: "",
358
+ dependants: [],
359
+ citizenStatus: "",
360
+ residentialAddress: "",
361
+ residentialStatus: "",
362
+ timeAtAddressYears: "",
363
+ timeAtAddressMonths: "",
364
+ previousAddress: "",
365
+ driversLicence: "",
366
+ passport: "",
367
+ propertyInTrust: "",
368
+ companyOwnership: ""
369
+ };
370
+ function makeDefaultIncomeItem() {
371
+ return {
372
+ id: `income-${Date.now()}-${Math.random()}`,
373
+ incomeType: "",
374
+ jobTitle: "",
375
+ startDate: "",
376
+ stillInPosition: true,
377
+ endDate: "",
378
+ companyName: "",
379
+ companyAddress: "",
380
+ incomeAmount: 0,
381
+ frequency: "Monthly",
382
+ companyType: ""
383
+ };
384
+ }
385
+ function makeDefaultAssetItem() {
386
+ return {
387
+ id: `asset-${Date.now()}-${Math.random()}`,
388
+ assetType: "",
389
+ value: 0,
390
+ mainShare: 100,
391
+ coShare: 0
392
+ };
393
+ }
394
+ function makeDefaultDebtItem() {
395
+ return {
396
+ id: `debt-${Date.now()}-${Math.random()}`,
397
+ debtType: "",
398
+ amountOwing: 0,
399
+ originalLoanAmount: 0,
400
+ repaymentAmount: 0,
401
+ repaymentFrequency: "Monthly",
402
+ interestRate: "",
403
+ details: "",
404
+ mainShare: 100,
405
+ coShare: 0
406
+ };
407
+ }
408
+ function makeDefaultExpenseItem() {
409
+ return {
410
+ id: `expense-${Date.now()}-${Math.random()}`,
411
+ expenseType: "",
412
+ amount: 0,
413
+ frequency: "Monthly",
414
+ mainShare: 100,
415
+ coShare: 0
416
+ };
417
+ }
418
+ function EditLoanScenarioModal({
419
+ open,
420
+ onOpenChange,
421
+ initialData,
422
+ onSave,
423
+ container,
424
+ className
425
+ }) {
426
+ const [form, setForm] = React.useState(__spreadValues(__spreadValues({}, LOAN_SCENARIO_DEFAULTS), initialData));
427
+ const initialSnapshot = React.useRef("");
428
+ React.useEffect(() => {
429
+ if (open) {
430
+ const data = __spreadValues(__spreadValues({}, LOAN_SCENARIO_DEFAULTS), initialData);
431
+ setForm(data);
432
+ initialSnapshot.current = JSON.stringify(data);
433
+ }
434
+ }, [open]);
435
+ const isDirty = JSON.stringify(form) !== initialSnapshot.current;
436
+ const set = (key, val) => setForm((prev) => __spreadProps(__spreadValues({}, prev), { [key]: val }));
437
+ const togglePriority = (priority) => {
438
+ setForm((prev) => {
439
+ const exists = prev.priorities.includes(priority);
440
+ if (exists) {
441
+ return __spreadProps(__spreadValues({}, prev), {
442
+ priorities: prev.priorities.filter((p) => p !== priority)
443
+ });
444
+ }
445
+ if (prev.priorities.length >= 3) return prev;
446
+ return __spreadProps(__spreadValues({}, prev), { priorities: [...prev.priorities, priority] });
447
+ });
448
+ };
449
+ const prioritiesAtMax = form.priorities.length >= 3;
450
+ const LOAN_FEATURES = [
451
+ { key: "featureFixedRate", label: "Fixed Rate" },
452
+ { key: "featureVariableRate", label: "Variable Rate" },
453
+ { key: "featureSplitLoan", label: "Split Loan" },
454
+ { key: "featureInterestOnly", label: "Interest Only" },
455
+ { key: "featureRedrawFacility", label: "Redraw Facility" },
456
+ { key: "feature100Offset", label: "100% Offset" }
457
+ ];
458
+ const YES_NO_FIELDS = [
459
+ {
460
+ key: "borrowOtherThanProperty",
461
+ label: "Do you intend to borrow money other than your property?"
462
+ },
463
+ {
464
+ key: "concernedAboutRates",
465
+ label: "Are you concerned about rising interest rates?"
466
+ },
467
+ {
468
+ key: "considerFixedRate",
469
+ label: "Would you consider taking a fixed rate?"
470
+ },
471
+ {
472
+ key: "anticipatedChanges",
473
+ label: "Anticipated changes impacting repayment?"
474
+ }
475
+ ];
476
+ return /* @__PURE__ */ jsx(Dialog, { open, onOpenChange, children: /* @__PURE__ */ jsxs(
477
+ DialogContent,
478
+ {
479
+ className: cn("max-w-lg", className),
480
+ container,
481
+ children: [
482
+ /* @__PURE__ */ jsx(DialogHeader, { children: /* @__PURE__ */ jsx(DialogTitle, { children: "Edit Loan Scenario" }) }),
483
+ /* @__PURE__ */ jsxs(ModalScroll, { children: [
484
+ /* @__PURE__ */ jsx(FormField, { label: "What would you like to do?", children: /* @__PURE__ */ jsxs(
485
+ Select,
486
+ {
487
+ value: form.loanPurpose,
488
+ onValueChange: (val) => set("loanPurpose", val),
489
+ children: [
490
+ /* @__PURE__ */ jsx(SelectTrigger, { className: "w-full", children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Select purpose" }) }),
491
+ /* @__PURE__ */ jsx(SelectContent, { children: LOAN_PURPOSES.map((p) => /* @__PURE__ */ jsx(SelectItem, { value: p, children: p }, p)) })
492
+ ]
493
+ }
494
+ ) }),
495
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
496
+ /* @__PURE__ */ jsx(FormField, { label: "Property Estimate", children: /* @__PURE__ */ jsx(
497
+ CurrencyInputWithSlider,
498
+ {
499
+ value: form.propertyEstimate,
500
+ min: 0,
501
+ max: 1e7,
502
+ step: 5e4,
503
+ onValueChange: (val) => set("propertyEstimate", val)
504
+ }
505
+ ) }),
506
+ /* @__PURE__ */ jsx(FormField, { label: "Cash/equity towards property", children: /* @__PURE__ */ jsx(
507
+ CurrencyInputWithSlider,
508
+ {
509
+ value: form.cashEquity,
510
+ min: 0,
511
+ max: 2e6,
512
+ step: 5e3,
513
+ onValueChange: (val) => set("cashEquity", val)
514
+ }
515
+ ) })
516
+ ] }),
517
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
518
+ /* @__PURE__ */ jsx(FormField, { label: "Loan Amount", children: /* @__PURE__ */ jsx(
519
+ CurrencyInputWithSlider,
520
+ {
521
+ value: form.loanAmount,
522
+ min: 0,
523
+ max: 5e6,
524
+ step: 1e4,
525
+ onValueChange: (val) => set("loanAmount", val)
526
+ }
527
+ ) }),
528
+ /* @__PURE__ */ jsx(FormField, { label: "Loan Duration", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
529
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
530
+ /* @__PURE__ */ jsx(
531
+ Input,
532
+ {
533
+ type: "number",
534
+ min: 1,
535
+ max: 40,
536
+ value: form.loanDuration,
537
+ onChange: (e) => {
538
+ const parsed = parseInt(e.target.value, 10);
539
+ if (!isNaN(parsed)) {
540
+ set("loanDuration", Math.min(40, Math.max(1, parsed)));
541
+ }
542
+ },
543
+ className: "flex-1"
544
+ }
545
+ ),
546
+ /* @__PURE__ */ jsx("span", { className: "text-sm text-muted-foreground", children: "years" })
547
+ ] }),
548
+ /* @__PURE__ */ jsx(
549
+ Slider,
550
+ {
551
+ min: 1,
552
+ max: 40,
553
+ step: 1,
554
+ value: form.loanDuration,
555
+ onValueChange: (val) => set("loanDuration", val)
556
+ }
557
+ )
558
+ ] }) })
559
+ ] }),
560
+ /* @__PURE__ */ jsx(FormField, { label: "Do you know what loan features you want?", children: /* @__PURE__ */ jsxs(
561
+ Select,
562
+ {
563
+ value: form.knowsFeatures,
564
+ onValueChange: (val) => set("knowsFeatures", val),
565
+ children: [
566
+ /* @__PURE__ */ jsx(SelectTrigger, { className: "w-full", children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Select" }) }),
567
+ /* @__PURE__ */ jsxs(SelectContent, { children: [
568
+ /* @__PURE__ */ jsx(SelectItem, { value: "Yes", children: "Yes" }),
569
+ /* @__PURE__ */ jsx(SelectItem, { value: "No", children: "No" })
570
+ ] })
571
+ ]
572
+ }
573
+ ) }),
574
+ form.knowsFeatures === "Yes" && /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
575
+ /* @__PURE__ */ jsx(Label, { className: "text-sm font-medium text-muted-foreground", children: "What features are important to you?" }),
576
+ /* @__PURE__ */ jsx("div", { className: "grid grid-cols-2 gap-2", children: LOAN_FEATURES.map(({ key, label }) => /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
577
+ /* @__PURE__ */ jsx(
578
+ Checkbox,
579
+ {
580
+ id: `feature-${key}`,
581
+ checked: form[key],
582
+ onCheckedChange: (checked) => set(key, checked === true)
583
+ }
584
+ ),
585
+ /* @__PURE__ */ jsx(
586
+ "label",
587
+ {
588
+ htmlFor: `feature-${key}`,
589
+ className: "text-sm cursor-pointer select-none",
590
+ children: label
591
+ }
592
+ )
593
+ ] }, key)) })
594
+ ] }),
595
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
596
+ /* @__PURE__ */ jsx(Label, { className: "text-sm font-medium text-muted-foreground", children: "Top 3 Priorities (Select up to 3)" }),
597
+ /* @__PURE__ */ jsx("div", { className: "grid grid-cols-2 gap-2", children: PRIORITIES.map((priority) => {
598
+ const checked = form.priorities.includes(priority);
599
+ const disabled = prioritiesAtMax && !checked;
600
+ return /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
601
+ /* @__PURE__ */ jsx(
602
+ Checkbox,
603
+ {
604
+ id: `priority-${priority}`,
605
+ checked,
606
+ disabled,
607
+ onCheckedChange: () => togglePriority(priority)
608
+ }
609
+ ),
610
+ /* @__PURE__ */ jsx(
611
+ "label",
612
+ {
613
+ htmlFor: `priority-${priority}`,
614
+ className: cn(
615
+ "text-sm cursor-pointer select-none",
616
+ disabled && "opacity-40 cursor-not-allowed"
617
+ ),
618
+ children: priority
619
+ }
620
+ )
621
+ ] }, priority);
622
+ }) })
623
+ ] }),
624
+ YES_NO_FIELDS.map(({ key, label }) => /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
625
+ /* @__PURE__ */ jsx(Label, { className: "text-sm font-medium text-muted-foreground", children: label }),
626
+ /* @__PURE__ */ jsx(
627
+ RadioGroup,
628
+ {
629
+ value: form[key],
630
+ onValueChange: (val) => {
631
+ if (val === "Yes" || val === "No") set(key, val);
632
+ },
633
+ className: "flex gap-4",
634
+ children: ["Yes", "No"].map((opt) => /* @__PURE__ */ jsxs(
635
+ "label",
636
+ {
637
+ className: "flex items-center gap-2 cursor-pointer select-none",
638
+ children: [
639
+ /* @__PURE__ */ jsx(RadioGroupItem, { value: opt }),
640
+ /* @__PURE__ */ jsx("span", { className: "text-sm", children: opt })
641
+ ]
642
+ },
643
+ opt
644
+ ))
645
+ }
646
+ )
647
+ ] }, key)),
648
+ /* @__PURE__ */ jsx(FormField, { label: "What age are you planning to retire?", children: /* @__PURE__ */ jsx(
649
+ Input,
650
+ {
651
+ type: "number",
652
+ min: 0,
653
+ max: 100,
654
+ value: form.retirementAge,
655
+ onChange: (e) => set("retirementAge", e.target.value),
656
+ placeholder: "e.g. 65"
657
+ }
658
+ ) })
659
+ ] }),
660
+ /* @__PURE__ */ jsxs(DialogFooter, { children: [
661
+ /* @__PURE__ */ jsx(Button, { variant: "outline", onClick: () => onOpenChange(false), children: "Cancel" }),
662
+ /* @__PURE__ */ jsx(
663
+ Button,
664
+ {
665
+ disabled: !isDirty,
666
+ onClick: () => {
667
+ onSave(form);
668
+ onOpenChange(false);
669
+ },
670
+ children: "Save"
671
+ }
672
+ )
673
+ ] })
674
+ ]
675
+ }
676
+ ) });
677
+ }
678
+ function EditAssetsModal({
679
+ open,
680
+ onOpenChange,
681
+ initialItems = [],
682
+ onSave,
683
+ mainApplicantName = "Main Applicant",
684
+ coApplicantName = "Co-Applicant",
685
+ container,
686
+ className
687
+ }) {
688
+ const [items, setItems] = React.useState(
689
+ initialItems.length > 0 ? initialItems : [makeDefaultAssetItem()]
690
+ );
691
+ const initialSnapshot = React.useRef("");
692
+ React.useEffect(() => {
693
+ if (open) {
694
+ const data = initialItems.length > 0 ? initialItems : [makeDefaultAssetItem()];
695
+ setItems(data);
696
+ initialSnapshot.current = JSON.stringify(data);
697
+ }
698
+ }, [open]);
699
+ const isDirty = JSON.stringify(items) !== initialSnapshot.current;
700
+ const updateItem = (id, key, val) => setItems(
701
+ (prev) => prev.map((item) => item.id === id ? __spreadProps(__spreadValues({}, item), { [key]: val }) : item)
702
+ );
703
+ const removeItem = (id) => setItems((prev) => prev.filter((item) => item.id !== id));
704
+ const addItem = () => setItems((prev) => [...prev, makeDefaultAssetItem()]);
705
+ const defaultOpenItems = items.length > 0 ? [items[0].id] : [];
706
+ return /* @__PURE__ */ jsx(Dialog, { open, onOpenChange, children: /* @__PURE__ */ jsxs(
707
+ DialogContent,
708
+ {
709
+ className: cn("max-w-lg", className),
710
+ container,
711
+ children: [
712
+ /* @__PURE__ */ jsx(DialogHeader, { children: /* @__PURE__ */ jsx(DialogTitle, { children: "Edit Assets" }) }),
713
+ /* @__PURE__ */ jsxs(ModalScroll, { children: [
714
+ /* @__PURE__ */ jsx(
715
+ Accordion,
716
+ {
717
+ multiple: true,
718
+ defaultValue: defaultOpenItems,
719
+ className: "w-full",
720
+ children: items.map((item, index) => /* @__PURE__ */ jsxs(AccordionItem, { value: item.id, children: [
721
+ /* @__PURE__ */ jsx(
722
+ AccordionItemHeader,
723
+ {
724
+ label: `Asset ${index + 1} \u2014 ${item.assetType || "New Asset"}`,
725
+ onRemove: () => removeItem(item.id),
726
+ removeLabel: "Remove asset"
727
+ }
728
+ ),
729
+ /* @__PURE__ */ jsx(AccordionContent, { children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-4 pt-1", children: [
730
+ /* @__PURE__ */ jsx(FormField, { label: "Asset Type", children: /* @__PURE__ */ jsxs(
731
+ Select,
732
+ {
733
+ value: item.assetType,
734
+ onValueChange: (val) => updateItem(item.id, "assetType", val),
735
+ children: [
736
+ /* @__PURE__ */ jsx(SelectTrigger, { className: "w-full", children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Select type" }) }),
737
+ /* @__PURE__ */ jsx(SelectContent, { children: ASSET_TYPES.map((t) => /* @__PURE__ */ jsx(SelectItem, { value: t, children: t }, t)) })
738
+ ]
739
+ }
740
+ ) }),
741
+ /* @__PURE__ */ jsx(FormField, { label: "Value", children: /* @__PURE__ */ jsx(
742
+ CurrencyInputWithSlider,
743
+ {
744
+ value: item.value,
745
+ min: 0,
746
+ max: 1e7,
747
+ step: 1e4,
748
+ onValueChange: (val) => updateItem(item.id, "value", val)
749
+ }
750
+ ) }),
751
+ (() => {
752
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
753
+ const f = assetFields(item.assetType);
754
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
755
+ f.isProperty && /* @__PURE__ */ jsxs(Fragment, { children: [
756
+ /* @__PURE__ */ jsx(FormField, { label: "Property Address", children: /* @__PURE__ */ jsx(
757
+ AddressAutocomplete,
758
+ {
759
+ value: (_a = item.address) != null ? _a : "",
760
+ onValueChange: (val) => updateItem(item.id, "address", val),
761
+ onSelect: (opt) => updateItem(item.id, "address", opt.label)
762
+ }
763
+ ) }),
764
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
765
+ /* @__PURE__ */ jsx(FormField, { label: "Property Type", children: /* @__PURE__ */ jsxs(
766
+ Select,
767
+ {
768
+ value: (_b = item.propertySubtype) != null ? _b : "",
769
+ onValueChange: (val) => updateItem(
770
+ item.id,
771
+ "propertySubtype",
772
+ val
773
+ ),
774
+ children: [
775
+ /* @__PURE__ */ jsx(SelectTrigger, { className: "w-full", children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Select" }) }),
776
+ /* @__PURE__ */ jsx(SelectContent, { children: PROPERTY_SUBTYPES.map((t) => /* @__PURE__ */ jsx(SelectItem, { value: t, children: t }, t)) })
777
+ ]
778
+ }
779
+ ) }),
780
+ /* @__PURE__ */ jsx(FormField, { label: "Used As", children: /* @__PURE__ */ jsxs(
781
+ Select,
782
+ {
783
+ value: (_c = item.usedAs) != null ? _c : "",
784
+ onValueChange: (val) => updateItem(item.id, "usedAs", val),
785
+ children: [
786
+ /* @__PURE__ */ jsx(SelectTrigger, { className: "w-full", children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Select" }) }),
787
+ /* @__PURE__ */ jsx(SelectContent, { children: PROPERTY_USED_AS.map((t) => /* @__PURE__ */ jsx(SelectItem, { value: t, children: t }, t)) })
788
+ ]
789
+ }
790
+ ) })
791
+ ] })
792
+ ] }),
793
+ f.isVehicle && /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-3 gap-4", children: [
794
+ /* @__PURE__ */ jsx(FormField, { label: "Make", children: /* @__PURE__ */ jsx(
795
+ Input,
796
+ {
797
+ value: (_d = item.make) != null ? _d : "",
798
+ onChange: (e) => updateItem(item.id, "make", e.target.value),
799
+ placeholder: "e.g. Toyota"
800
+ }
801
+ ) }),
802
+ /* @__PURE__ */ jsx(FormField, { label: "Model", children: /* @__PURE__ */ jsx(
803
+ Input,
804
+ {
805
+ value: (_e = item.model) != null ? _e : "",
806
+ onChange: (e) => updateItem(item.id, "model", e.target.value),
807
+ placeholder: "e.g. Camry"
808
+ }
809
+ ) }),
810
+ /* @__PURE__ */ jsx(FormField, { label: "Year", children: /* @__PURE__ */ jsx(
811
+ Input,
812
+ {
813
+ type: "number",
814
+ min: 1900,
815
+ max: (/* @__PURE__ */ new Date()).getFullYear() + 1,
816
+ value: (_f = item.year) != null ? _f : "",
817
+ onChange: (e) => updateItem(item.id, "year", e.target.value),
818
+ placeholder: "e.g. 2022"
819
+ }
820
+ ) })
821
+ ] }),
822
+ (f.isFinancialAccount || f.isInvestment) && /* @__PURE__ */ jsx(FormField, { label: "Institution / Platform", children: /* @__PURE__ */ jsx(
823
+ Input,
824
+ {
825
+ value: (_g = item.institution) != null ? _g : "",
826
+ onChange: (e) => updateItem(
827
+ item.id,
828
+ "institution",
829
+ e.target.value
830
+ ),
831
+ placeholder: "e.g. CommBank, Vanguard"
832
+ }
833
+ ) }),
834
+ f.isSuper && /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
835
+ /* @__PURE__ */ jsx(FormField, { label: "Fund Name", children: /* @__PURE__ */ jsx(
836
+ Input,
837
+ {
838
+ value: (_h = item.fundName) != null ? _h : "",
839
+ onChange: (e) => updateItem(
840
+ item.id,
841
+ "fundName",
842
+ e.target.value
843
+ ),
844
+ placeholder: "e.g. Australian Super"
845
+ }
846
+ ) }),
847
+ /* @__PURE__ */ jsx(FormField, { label: "Member Number", children: /* @__PURE__ */ jsx(
848
+ Input,
849
+ {
850
+ value: (_i = item.memberNumber) != null ? _i : "",
851
+ onChange: (e) => updateItem(
852
+ item.id,
853
+ "memberNumber",
854
+ e.target.value
855
+ ),
856
+ placeholder: "e.g. 1234567"
857
+ }
858
+ ) })
859
+ ] }),
860
+ f.isBusiness && /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
861
+ /* @__PURE__ */ jsx(FormField, { label: "Business Name", children: /* @__PURE__ */ jsx(
862
+ Input,
863
+ {
864
+ value: (_j = item.businessName) != null ? _j : "",
865
+ onChange: (e) => updateItem(
866
+ item.id,
867
+ "businessName",
868
+ e.target.value
869
+ ),
870
+ placeholder: "e.g. Acme Pty Ltd"
871
+ }
872
+ ) }),
873
+ /* @__PURE__ */ jsx(FormField, { label: "ABN", children: /* @__PURE__ */ jsx(
874
+ Input,
875
+ {
876
+ value: (_k = item.abn) != null ? _k : "",
877
+ onChange: (e) => updateItem(item.id, "abn", e.target.value),
878
+ placeholder: "e.g. 12 345 678 901"
879
+ }
880
+ ) })
881
+ ] }),
882
+ f.isInsurance && /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
883
+ /* @__PURE__ */ jsx(FormField, { label: "Insurer", children: /* @__PURE__ */ jsx(
884
+ Input,
885
+ {
886
+ value: (_l = item.insurer) != null ? _l : "",
887
+ onChange: (e) => updateItem(
888
+ item.id,
889
+ "insurer",
890
+ e.target.value
891
+ ),
892
+ placeholder: "e.g. TAL, AIA"
893
+ }
894
+ ) }),
895
+ /* @__PURE__ */ jsx(FormField, { label: "Policy Number", children: /* @__PURE__ */ jsx(
896
+ Input,
897
+ {
898
+ value: (_m = item.policyNumber) != null ? _m : "",
899
+ onChange: (e) => updateItem(
900
+ item.id,
901
+ "policyNumber",
902
+ e.target.value
903
+ ),
904
+ placeholder: "e.g. POL-123456"
905
+ }
906
+ ) })
907
+ ] })
908
+ ] });
909
+ })(),
910
+ /* @__PURE__ */ jsx(FormField, { label: "Ownership (%)", children: /* @__PURE__ */ jsx(
911
+ OwnershipSplit,
912
+ {
913
+ owners: [
914
+ {
915
+ id: "main",
916
+ name: mainApplicantName != null ? mainApplicantName : "Main Applicant",
917
+ share: item.mainShare
918
+ },
919
+ {
920
+ id: "co",
921
+ name: coApplicantName != null ? coApplicantName : "Co-Applicant",
922
+ share: item.coShare
923
+ }
924
+ ],
925
+ onOwnersChange: (owners) => {
926
+ var _a, _b, _c, _d;
927
+ updateItem(
928
+ item.id,
929
+ "mainShare",
930
+ (_b = (_a = owners.find((o) => o.id === "main")) == null ? void 0 : _a.share) != null ? _b : 50
931
+ );
932
+ updateItem(
933
+ item.id,
934
+ "coShare",
935
+ (_d = (_c = owners.find((o) => o.id === "co")) == null ? void 0 : _c.share) != null ? _d : 50
936
+ );
937
+ }
938
+ }
939
+ ) })
940
+ ] }) })
941
+ ] }, item.id))
942
+ }
943
+ ),
944
+ /* @__PURE__ */ jsxs(
945
+ Button,
946
+ {
947
+ variant: "outline",
948
+ onClick: addItem,
949
+ className: "w-full gap-1.5",
950
+ children: [
951
+ /* @__PURE__ */ jsx(Plus, { className: "h-4 w-4" }),
952
+ "Add More"
953
+ ]
954
+ }
955
+ )
956
+ ] }),
957
+ /* @__PURE__ */ jsxs(DialogFooter, { children: [
958
+ /* @__PURE__ */ jsx(Button, { variant: "outline", onClick: () => onOpenChange(false), children: "Cancel" }),
959
+ /* @__PURE__ */ jsx(
960
+ Button,
961
+ {
962
+ disabled: !isDirty,
963
+ onClick: () => {
964
+ onSave(items);
965
+ onOpenChange(false);
966
+ },
967
+ children: "Save"
968
+ }
969
+ )
970
+ ] })
971
+ ]
972
+ }
973
+ ) });
974
+ }
975
+ function EditDebtsModal({
976
+ open,
977
+ onOpenChange,
978
+ initialItems = [],
979
+ onSave,
980
+ mainApplicantName = "Main Applicant",
981
+ coApplicantName = "Co-Applicant",
982
+ container,
983
+ className
984
+ }) {
985
+ const [items, setItems] = React.useState(
986
+ initialItems.length > 0 ? initialItems : [makeDefaultDebtItem()]
987
+ );
988
+ const initialSnapshot = React.useRef("");
989
+ React.useEffect(() => {
990
+ if (open) {
991
+ const data = initialItems.length > 0 ? initialItems : [makeDefaultDebtItem()];
992
+ setItems(data);
993
+ initialSnapshot.current = JSON.stringify(data);
994
+ }
995
+ }, [open]);
996
+ const isDirty = JSON.stringify(items) !== initialSnapshot.current;
997
+ const updateItem = (id, key, val) => setItems(
998
+ (prev) => prev.map((item) => item.id === id ? __spreadProps(__spreadValues({}, item), { [key]: val }) : item)
999
+ );
1000
+ const removeItem = (id) => setItems((prev) => prev.filter((item) => item.id !== id));
1001
+ const addItem = () => setItems((prev) => [...prev, makeDefaultDebtItem()]);
1002
+ const defaultOpenItems = items.length > 0 ? [items[0].id] : [];
1003
+ return /* @__PURE__ */ jsx(Dialog, { open, onOpenChange, children: /* @__PURE__ */ jsxs(
1004
+ DialogContent,
1005
+ {
1006
+ className: cn("max-w-xl", className),
1007
+ container,
1008
+ children: [
1009
+ /* @__PURE__ */ jsx(DialogHeader, { children: /* @__PURE__ */ jsx(DialogTitle, { children: "Edit Debts" }) }),
1010
+ /* @__PURE__ */ jsxs(ModalScroll, { children: [
1011
+ /* @__PURE__ */ jsx(
1012
+ Accordion,
1013
+ {
1014
+ multiple: true,
1015
+ defaultValue: defaultOpenItems,
1016
+ className: "w-full",
1017
+ children: items.map((item) => {
1018
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
1019
+ const df = debtFields(item.debtType);
1020
+ return /* @__PURE__ */ jsxs(AccordionItem, { value: item.id, children: [
1021
+ /* @__PURE__ */ jsx(
1022
+ AccordionItemHeader,
1023
+ {
1024
+ label: item.debtType || "New Debt",
1025
+ onRemove: () => removeItem(item.id),
1026
+ removeLabel: "Remove debt"
1027
+ }
1028
+ ),
1029
+ /* @__PURE__ */ jsx(AccordionContent, { children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-4 pt-1", children: [
1030
+ /* @__PURE__ */ jsx(FormField, { label: "Debt Type", children: /* @__PURE__ */ jsxs(
1031
+ Select,
1032
+ {
1033
+ value: item.debtType,
1034
+ onValueChange: (val) => updateItem(item.id, "debtType", val),
1035
+ children: [
1036
+ /* @__PURE__ */ jsx(SelectTrigger, { className: "w-full", children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Select type" }) }),
1037
+ /* @__PURE__ */ jsx(SelectContent, { children: DEBT_TYPES.map((t) => /* @__PURE__ */ jsx(SelectItem, { value: t, children: t }, t)) })
1038
+ ]
1039
+ }
1040
+ ) }),
1041
+ (df.isPropertyLoan || df.isGeneralLoan || df.isVehicle) && /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
1042
+ /* @__PURE__ */ jsx(FormField, { label: "Lender", children: /* @__PURE__ */ jsx(
1043
+ Input,
1044
+ {
1045
+ value: (_a = item.lender) != null ? _a : "",
1046
+ onChange: (e) => updateItem(item.id, "lender", e.target.value),
1047
+ placeholder: "e.g. CommBank"
1048
+ }
1049
+ ) }),
1050
+ /* @__PURE__ */ jsx(FormField, { label: "Account Number", children: /* @__PURE__ */ jsx(
1051
+ Input,
1052
+ {
1053
+ value: (_b = item.accountNumber) != null ? _b : "",
1054
+ onChange: (e) => updateItem(
1055
+ item.id,
1056
+ "accountNumber",
1057
+ e.target.value
1058
+ ),
1059
+ placeholder: "e.g. 123-456"
1060
+ }
1061
+ ) })
1062
+ ] }),
1063
+ df.isPropertyLoan && /* @__PURE__ */ jsx(FormField, { label: "Property Address", children: /* @__PURE__ */ jsx(
1064
+ AddressAutocomplete,
1065
+ {
1066
+ value: (_c = item.propertyAddress) != null ? _c : "",
1067
+ onValueChange: (val) => updateItem(item.id, "propertyAddress", val),
1068
+ onSelect: (opt) => updateItem(item.id, "propertyAddress", opt.label)
1069
+ }
1070
+ ) }),
1071
+ df.isVehicle && /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-3 gap-4", children: [
1072
+ /* @__PURE__ */ jsx(FormField, { label: "Make", children: /* @__PURE__ */ jsx(
1073
+ Input,
1074
+ {
1075
+ value: (_d = item.vehicleMake) != null ? _d : "",
1076
+ onChange: (e) => updateItem(
1077
+ item.id,
1078
+ "vehicleMake",
1079
+ e.target.value
1080
+ ),
1081
+ placeholder: "e.g. Toyota"
1082
+ }
1083
+ ) }),
1084
+ /* @__PURE__ */ jsx(FormField, { label: "Model", children: /* @__PURE__ */ jsx(
1085
+ Input,
1086
+ {
1087
+ value: (_e = item.vehicleModel) != null ? _e : "",
1088
+ onChange: (e) => updateItem(
1089
+ item.id,
1090
+ "vehicleModel",
1091
+ e.target.value
1092
+ ),
1093
+ placeholder: "e.g. Camry"
1094
+ }
1095
+ ) }),
1096
+ /* @__PURE__ */ jsx(FormField, { label: "Year", children: /* @__PURE__ */ jsx(
1097
+ Input,
1098
+ {
1099
+ type: "number",
1100
+ min: 1900,
1101
+ max: (/* @__PURE__ */ new Date()).getFullYear() + 1,
1102
+ value: (_f = item.vehicleYear) != null ? _f : "",
1103
+ onChange: (e) => updateItem(
1104
+ item.id,
1105
+ "vehicleYear",
1106
+ e.target.value
1107
+ ),
1108
+ placeholder: "e.g. 2022"
1109
+ }
1110
+ ) })
1111
+ ] }),
1112
+ df.isCard && /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
1113
+ /* @__PURE__ */ jsx(FormField, { label: "Provider", children: /* @__PURE__ */ jsx(
1114
+ Input,
1115
+ {
1116
+ value: (_g = item.lender) != null ? _g : "",
1117
+ onChange: (e) => updateItem(item.id, "lender", e.target.value),
1118
+ placeholder: "e.g. ANZ, Afterpay"
1119
+ }
1120
+ ) }),
1121
+ /* @__PURE__ */ jsx(FormField, { label: "Credit Limit", children: /* @__PURE__ */ jsx(
1122
+ CurrencyInputWithSlider,
1123
+ {
1124
+ value: (_h = item.creditLimit) != null ? _h : 0,
1125
+ min: 0,
1126
+ max: 1e5,
1127
+ step: 500,
1128
+ onValueChange: (val) => updateItem(item.id, "creditLimit", val)
1129
+ }
1130
+ ) })
1131
+ ] }),
1132
+ df.isHecs && /* @__PURE__ */ jsx(FormField, { label: "Institution", children: /* @__PURE__ */ jsx(
1133
+ Input,
1134
+ {
1135
+ value: (_i = item.institution) != null ? _i : "",
1136
+ onChange: (e) => updateItem(item.id, "institution", e.target.value),
1137
+ placeholder: "e.g. University of Sydney"
1138
+ }
1139
+ ) }),
1140
+ df.isTax && /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
1141
+ /* @__PURE__ */ jsx(FormField, { label: "Tax Year", children: /* @__PURE__ */ jsx(
1142
+ Input,
1143
+ {
1144
+ value: (_j = item.taxYear) != null ? _j : "",
1145
+ onChange: (e) => updateItem(item.id, "taxYear", e.target.value),
1146
+ placeholder: "e.g. 2023\u201324"
1147
+ }
1148
+ ) }),
1149
+ /* @__PURE__ */ jsx(FormField, { label: "ATO Reference", children: /* @__PURE__ */ jsx(
1150
+ Input,
1151
+ {
1152
+ value: (_k = item.referenceNumber) != null ? _k : "",
1153
+ onChange: (e) => updateItem(
1154
+ item.id,
1155
+ "referenceNumber",
1156
+ e.target.value
1157
+ ),
1158
+ placeholder: "e.g. 1234567890"
1159
+ }
1160
+ ) })
1161
+ ] }),
1162
+ df.isGuarantor && /* @__PURE__ */ jsx(FormField, { label: "Beneficiary (borrower's name)", children: /* @__PURE__ */ jsx(
1163
+ Input,
1164
+ {
1165
+ value: (_l = item.beneficiary) != null ? _l : "",
1166
+ onChange: (e) => updateItem(item.id, "beneficiary", e.target.value),
1167
+ placeholder: "e.g. Jane Smith"
1168
+ }
1169
+ ) }),
1170
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
1171
+ /* @__PURE__ */ jsx(FormField, { label: "Amount Owing", children: /* @__PURE__ */ jsx(
1172
+ CurrencyInputWithSlider,
1173
+ {
1174
+ value: item.amountOwing,
1175
+ min: 0,
1176
+ max: 1e6,
1177
+ step: 1e3,
1178
+ onValueChange: (val) => updateItem(item.id, "amountOwing", val)
1179
+ }
1180
+ ) }),
1181
+ /* @__PURE__ */ jsx(FormField, { label: "Original Loan Amount", children: /* @__PURE__ */ jsx(
1182
+ CurrencyInputWithSlider,
1183
+ {
1184
+ value: item.originalLoanAmount,
1185
+ min: 0,
1186
+ max: 1e6,
1187
+ step: 1e3,
1188
+ onValueChange: (val) => updateItem(item.id, "originalLoanAmount", val)
1189
+ }
1190
+ ) })
1191
+ ] }),
1192
+ /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-3", children: [
1193
+ /* @__PURE__ */ jsx("div", { className: "flex-1", children: /* @__PURE__ */ jsx(FormField, { label: "Repayments", children: /* @__PURE__ */ jsx(
1194
+ CurrencyInputWithSlider,
1195
+ {
1196
+ value: item.repaymentAmount,
1197
+ min: 0,
1198
+ max: 1e6,
1199
+ step: 100,
1200
+ onValueChange: (val) => updateItem(item.id, "repaymentAmount", val)
1201
+ }
1202
+ ) }) }),
1203
+ /* @__PURE__ */ jsx("div", { className: "shrink-0 mt-[1.625rem]", children: /* @__PURE__ */ jsx(
1204
+ FrequencyToggle,
1205
+ {
1206
+ value: item.repaymentFrequency,
1207
+ onValueChange: (val) => updateItem(item.id, "repaymentFrequency", val)
1208
+ }
1209
+ ) })
1210
+ ] }),
1211
+ /* @__PURE__ */ jsx(FormField, { label: "Interest Rate", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
1212
+ /* @__PURE__ */ jsx(
1213
+ Input,
1214
+ {
1215
+ value: item.interestRate,
1216
+ onChange: (e) => updateItem(
1217
+ item.id,
1218
+ "interestRate",
1219
+ e.target.value
1220
+ ),
1221
+ placeholder: "e.g. 6.5",
1222
+ className: "flex-1"
1223
+ }
1224
+ ),
1225
+ /* @__PURE__ */ jsx("span", { className: "text-sm text-muted-foreground shrink-0", children: "%" })
1226
+ ] }) }),
1227
+ /* @__PURE__ */ jsx(FormField, { label: "Notes", children: /* @__PURE__ */ jsx(
1228
+ Textarea,
1229
+ {
1230
+ value: item.details,
1231
+ onChange: (e) => updateItem(item.id, "details", e.target.value),
1232
+ placeholder: "Short comment",
1233
+ rows: 2
1234
+ }
1235
+ ) }),
1236
+ /* @__PURE__ */ jsx(FormField, { label: "Ownership (%)", children: /* @__PURE__ */ jsx(
1237
+ OwnershipSplit,
1238
+ {
1239
+ owners: [
1240
+ {
1241
+ id: "main",
1242
+ name: mainApplicantName != null ? mainApplicantName : "Main Applicant",
1243
+ share: item.mainShare
1244
+ },
1245
+ {
1246
+ id: "co",
1247
+ name: coApplicantName != null ? coApplicantName : "Co-Applicant",
1248
+ share: item.coShare
1249
+ }
1250
+ ],
1251
+ onOwnersChange: (owners) => {
1252
+ var _a2, _b2, _c2, _d2;
1253
+ updateItem(
1254
+ item.id,
1255
+ "mainShare",
1256
+ (_b2 = (_a2 = owners.find((o) => o.id === "main")) == null ? void 0 : _a2.share) != null ? _b2 : 50
1257
+ );
1258
+ updateItem(
1259
+ item.id,
1260
+ "coShare",
1261
+ (_d2 = (_c2 = owners.find((o) => o.id === "co")) == null ? void 0 : _c2.share) != null ? _d2 : 50
1262
+ );
1263
+ }
1264
+ }
1265
+ ) })
1266
+ ] }) })
1267
+ ] }, item.id);
1268
+ })
1269
+ }
1270
+ ),
1271
+ /* @__PURE__ */ jsxs(
1272
+ Button,
1273
+ {
1274
+ variant: "outline",
1275
+ onClick: addItem,
1276
+ className: "w-full gap-1.5",
1277
+ children: [
1278
+ /* @__PURE__ */ jsx(Plus, { className: "h-4 w-4" }),
1279
+ "Add More"
1280
+ ]
1281
+ }
1282
+ )
1283
+ ] }),
1284
+ /* @__PURE__ */ jsxs(DialogFooter, { children: [
1285
+ /* @__PURE__ */ jsx(Button, { variant: "outline", onClick: () => onOpenChange(false), children: "Cancel" }),
1286
+ /* @__PURE__ */ jsx(
1287
+ Button,
1288
+ {
1289
+ disabled: !isDirty,
1290
+ onClick: () => {
1291
+ onSave(items);
1292
+ onOpenChange(false);
1293
+ },
1294
+ children: "Save"
1295
+ }
1296
+ )
1297
+ ] })
1298
+ ]
1299
+ }
1300
+ ) });
1301
+ }
1302
+ function EditAboutApplicantModal({
1303
+ open,
1304
+ onOpenChange,
1305
+ applicantLabel = "Applicant",
1306
+ initialData,
1307
+ onSave,
1308
+ container,
1309
+ className
1310
+ }) {
1311
+ const [form, setForm] = React.useState(__spreadValues(__spreadValues({}, ABOUT_APPLICANT_DEFAULTS), initialData));
1312
+ const initialSnapshot = React.useRef("");
1313
+ React.useEffect(() => {
1314
+ if (open) {
1315
+ const data = __spreadValues(__spreadValues({}, ABOUT_APPLICANT_DEFAULTS), initialData);
1316
+ setForm(data);
1317
+ initialSnapshot.current = JSON.stringify(data);
1318
+ }
1319
+ }, [open]);
1320
+ const isDirty = JSON.stringify(form) !== initialSnapshot.current;
1321
+ const setStr = (key) => (val) => setForm((prev) => __spreadProps(__spreadValues({}, prev), { [key]: val }));
1322
+ const handleNumDependantsChange = (val) => {
1323
+ const n = Math.max(0, Math.min(20, parseInt(val, 10) || 0));
1324
+ setForm((prev) => {
1325
+ var _a;
1326
+ const current = (_a = prev.dependants) != null ? _a : [];
1327
+ const next = n > current.length ? [...current, ...Array(n - current.length).fill({ dob: "" })] : current.slice(0, n);
1328
+ return __spreadProps(__spreadValues({}, prev), { numDependants: val, dependants: next });
1329
+ });
1330
+ };
1331
+ const setDependantDob = (index, dob) => setForm((prev) => {
1332
+ const next = prev.dependants.map((d, i) => i === index ? { dob } : d);
1333
+ return __spreadProps(__spreadValues({}, prev), { dependants: next });
1334
+ });
1335
+ return /* @__PURE__ */ jsx(Dialog, { open, onOpenChange, children: /* @__PURE__ */ jsxs(
1336
+ DialogContent,
1337
+ {
1338
+ className: cn("max-w-md", className),
1339
+ container,
1340
+ children: [
1341
+ /* @__PURE__ */ jsx(DialogHeader, { children: /* @__PURE__ */ jsxs(DialogTitle, { children: [
1342
+ "Edit About ",
1343
+ applicantLabel
1344
+ ] }) }),
1345
+ /* @__PURE__ */ jsxs(ModalScroll, { children: [
1346
+ /* @__PURE__ */ jsxs("div", { className: "flex gap-3 items-start", children: [
1347
+ /* @__PURE__ */ jsx("div", { className: "w-24 shrink-0", children: /* @__PURE__ */ jsx(FormField, { label: "Title", children: /* @__PURE__ */ jsxs(Select, { value: form.title, onValueChange: setStr("title"), children: [
1348
+ /* @__PURE__ */ jsx(SelectTrigger, { className: "w-full", children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Title" }) }),
1349
+ /* @__PURE__ */ jsx(SelectContent, { children: TITLE_OPTIONS.map((t) => /* @__PURE__ */ jsx(SelectItem, { value: t, children: t }, t)) })
1350
+ ] }) }) }),
1351
+ /* @__PURE__ */ jsx(FormField, { label: "First Name", className: "flex-1", children: /* @__PURE__ */ jsx(
1352
+ Input,
1353
+ {
1354
+ value: form.firstName,
1355
+ onChange: (e) => setStr("firstName")(e.target.value),
1356
+ placeholder: "First name"
1357
+ }
1358
+ ) }),
1359
+ /* @__PURE__ */ jsx(FormField, { label: "Last Name", className: "flex-1", children: /* @__PURE__ */ jsx(
1360
+ Input,
1361
+ {
1362
+ value: form.lastName,
1363
+ onChange: (e) => setStr("lastName")(e.target.value),
1364
+ placeholder: "Last name"
1365
+ }
1366
+ ) })
1367
+ ] }),
1368
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
1369
+ /* @__PURE__ */ jsx(FormField, { label: "Phone Number", children: /* @__PURE__ */ jsx(
1370
+ Input,
1371
+ {
1372
+ value: form.phone,
1373
+ onChange: (e) => setStr("phone")(e.target.value),
1374
+ placeholder: "+61 4xx xxx xxx",
1375
+ type: "tel"
1376
+ }
1377
+ ) }),
1378
+ /* @__PURE__ */ jsx(FormField, { label: "Email", children: /* @__PURE__ */ jsx(
1379
+ Input,
1380
+ {
1381
+ value: form.email,
1382
+ onChange: (e) => setStr("email")(e.target.value),
1383
+ placeholder: "email@example.com",
1384
+ type: "email"
1385
+ }
1386
+ ) })
1387
+ ] }),
1388
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
1389
+ /* @__PURE__ */ jsx(FormField, { label: "Date of Birth", children: /* @__PURE__ */ jsx(
1390
+ DatePicker,
1391
+ {
1392
+ value: form.dob ? new Date(form.dob) : void 0,
1393
+ onChange: (d) => setStr("dob")(d ? d.toISOString().slice(0, 10) : ""),
1394
+ calendarProps: {
1395
+ fromYear: 1900,
1396
+ toYear: (/* @__PURE__ */ new Date()).getFullYear() - 16
1397
+ }
1398
+ }
1399
+ ) }),
1400
+ /* @__PURE__ */ jsx(FormField, { label: "Gender", children: /* @__PURE__ */ jsxs(Select, { value: form.gender, onValueChange: setStr("gender"), children: [
1401
+ /* @__PURE__ */ jsx(SelectTrigger, { className: "w-full", children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Select" }) }),
1402
+ /* @__PURE__ */ jsx(SelectContent, { children: GENDER_OPTIONS.map((g) => /* @__PURE__ */ jsx(SelectItem, { value: g, children: g }, g)) })
1403
+ ] }) })
1404
+ ] }),
1405
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
1406
+ /* @__PURE__ */ jsx(FormField, { label: "Marital Status", children: /* @__PURE__ */ jsxs(
1407
+ Select,
1408
+ {
1409
+ value: form.maritalStatus,
1410
+ onValueChange: setStr("maritalStatus"),
1411
+ children: [
1412
+ /* @__PURE__ */ jsx(SelectTrigger, { className: "w-full", children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Select" }) }),
1413
+ /* @__PURE__ */ jsx(SelectContent, { children: MARITAL_OPTIONS.map((m) => /* @__PURE__ */ jsx(SelectItem, { value: m, children: m }, m)) })
1414
+ ]
1415
+ }
1416
+ ) }),
1417
+ /* @__PURE__ */ jsx(FormField, { label: "No. of Dependants", children: /* @__PURE__ */ jsx(
1418
+ Input,
1419
+ {
1420
+ type: "number",
1421
+ min: 0,
1422
+ max: 20,
1423
+ value: form.numDependants,
1424
+ onChange: (e) => handleNumDependantsChange(e.target.value),
1425
+ placeholder: "0"
1426
+ }
1427
+ ) })
1428
+ ] }),
1429
+ form.dependants.length > 0 && /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3", children: [
1430
+ /* @__PURE__ */ jsx(Label, { className: "text-sm font-medium", children: "Dependant Date of Birth" }),
1431
+ /* @__PURE__ */ jsx("div", { className: "grid grid-cols-2 gap-3", children: form.dependants.map((dep, i) => /* @__PURE__ */ jsx(FormField, { label: `Dependant ${i + 1}`, children: /* @__PURE__ */ jsx(
1432
+ DatePicker,
1433
+ {
1434
+ value: dep.dob ? new Date(dep.dob) : void 0,
1435
+ onChange: (d) => setDependantDob(
1436
+ i,
1437
+ d ? d.toISOString().slice(0, 10) : ""
1438
+ ),
1439
+ calendarProps: {
1440
+ fromYear: 1900,
1441
+ toYear: (/* @__PURE__ */ new Date()).getFullYear()
1442
+ }
1443
+ }
1444
+ ) }, i)) })
1445
+ ] }),
1446
+ /* @__PURE__ */ jsx(FormField, { label: "Citizen Status", children: /* @__PURE__ */ jsxs(
1447
+ Select,
1448
+ {
1449
+ value: form.citizenStatus,
1450
+ onValueChange: setStr("citizenStatus"),
1451
+ children: [
1452
+ /* @__PURE__ */ jsx(SelectTrigger, { className: "w-full", children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Select status" }) }),
1453
+ /* @__PURE__ */ jsx(SelectContent, { children: CITIZEN_OPTIONS.map((c) => /* @__PURE__ */ jsx(SelectItem, { value: c, children: c }, c)) })
1454
+ ]
1455
+ }
1456
+ ) }),
1457
+ /* @__PURE__ */ jsx(FormField, { label: "Current Residential Address", children: /* @__PURE__ */ jsx(
1458
+ AddressAutocomplete,
1459
+ {
1460
+ value: form.residentialAddress,
1461
+ onValueChange: setStr("residentialAddress"),
1462
+ onSelect: (opt) => setStr("residentialAddress")(opt.label)
1463
+ }
1464
+ ) }),
1465
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
1466
+ /* @__PURE__ */ jsx(FormField, { label: "Residential Status", children: /* @__PURE__ */ jsxs(
1467
+ Select,
1468
+ {
1469
+ value: form.residentialStatus,
1470
+ onValueChange: setStr("residentialStatus"),
1471
+ children: [
1472
+ /* @__PURE__ */ jsx(SelectTrigger, { className: "w-full", children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Select" }) }),
1473
+ /* @__PURE__ */ jsx(SelectContent, { children: RESIDENTIAL_STATUS_OPTIONS.map((o) => /* @__PURE__ */ jsx(SelectItem, { value: o, children: o }, o)) })
1474
+ ]
1475
+ }
1476
+ ) }),
1477
+ /* @__PURE__ */ jsx(FormField, { label: "Time at Address", children: /* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
1478
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1 flex-1", children: [
1479
+ /* @__PURE__ */ jsx(
1480
+ Input,
1481
+ {
1482
+ type: "number",
1483
+ min: 0,
1484
+ value: form.timeAtAddressYears,
1485
+ onChange: (e) => setStr("timeAtAddressYears")(e.target.value),
1486
+ placeholder: "0"
1487
+ }
1488
+ ),
1489
+ /* @__PURE__ */ jsx("span", { className: "text-sm text-muted-foreground shrink-0", children: "yr" })
1490
+ ] }),
1491
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1 flex-1", children: [
1492
+ /* @__PURE__ */ jsx(
1493
+ Input,
1494
+ {
1495
+ type: "number",
1496
+ min: 0,
1497
+ max: 11,
1498
+ value: form.timeAtAddressMonths,
1499
+ onChange: (e) => setStr("timeAtAddressMonths")(e.target.value),
1500
+ placeholder: "0"
1501
+ }
1502
+ ),
1503
+ /* @__PURE__ */ jsx("span", { className: "text-sm text-muted-foreground shrink-0", children: "mo" })
1504
+ ] })
1505
+ ] }) })
1506
+ ] }),
1507
+ parseInt(form.timeAtAddressYears || "99") < 2 && /* @__PURE__ */ jsx(FormField, { label: "Previous Address", children: /* @__PURE__ */ jsx(
1508
+ AddressAutocomplete,
1509
+ {
1510
+ value: form.previousAddress,
1511
+ onValueChange: setStr("previousAddress"),
1512
+ onSelect: (opt) => setStr("previousAddress")(opt.label)
1513
+ }
1514
+ ) }),
1515
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
1516
+ /* @__PURE__ */ jsx(FormField, { label: "Driver's Licence", children: /* @__PURE__ */ jsx(
1517
+ Input,
1518
+ {
1519
+ value: form.driversLicence,
1520
+ onChange: (e) => setStr("driversLicence")(e.target.value),
1521
+ placeholder: "e.g. 12345678"
1522
+ }
1523
+ ) }),
1524
+ /* @__PURE__ */ jsx(FormField, { label: "Passport Number", children: /* @__PURE__ */ jsx(
1525
+ Input,
1526
+ {
1527
+ value: form.passport,
1528
+ onChange: (e) => setStr("passport")(e.target.value),
1529
+ placeholder: "e.g. PA1234567"
1530
+ }
1531
+ ) })
1532
+ ] }),
1533
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
1534
+ /* @__PURE__ */ jsx(FormField, { label: "Property in Trust", children: /* @__PURE__ */ jsxs(
1535
+ Select,
1536
+ {
1537
+ value: form.propertyInTrust,
1538
+ onValueChange: setStr("propertyInTrust"),
1539
+ children: [
1540
+ /* @__PURE__ */ jsx(SelectTrigger, { className: "w-full", children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Select" }) }),
1541
+ /* @__PURE__ */ jsx(SelectContent, { children: PROPERTY_IN_TRUST_OPTIONS.map((o) => /* @__PURE__ */ jsx(SelectItem, { value: o, children: o }, o)) })
1542
+ ]
1543
+ }
1544
+ ) }),
1545
+ /* @__PURE__ */ jsx(FormField, { label: "Company Ownership", children: /* @__PURE__ */ jsxs(
1546
+ Select,
1547
+ {
1548
+ value: form.companyOwnership,
1549
+ onValueChange: setStr("companyOwnership"),
1550
+ children: [
1551
+ /* @__PURE__ */ jsx(SelectTrigger, { className: "w-full", children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Select" }) }),
1552
+ /* @__PURE__ */ jsx(SelectContent, { children: COMPANY_OWNERSHIP_OPTIONS.map((o) => /* @__PURE__ */ jsx(SelectItem, { value: o, children: o }, o)) })
1553
+ ]
1554
+ }
1555
+ ) })
1556
+ ] })
1557
+ ] }),
1558
+ /* @__PURE__ */ jsxs(DialogFooter, { children: [
1559
+ /* @__PURE__ */ jsx(Button, { variant: "outline", onClick: () => onOpenChange(false), children: "Cancel" }),
1560
+ /* @__PURE__ */ jsx(
1561
+ Button,
1562
+ {
1563
+ disabled: !isDirty,
1564
+ onClick: () => {
1565
+ onSave(form);
1566
+ onOpenChange(false);
1567
+ },
1568
+ children: "Save"
1569
+ }
1570
+ )
1571
+ ] })
1572
+ ]
1573
+ }
1574
+ ) });
1575
+ }
1576
+ function EditIncomeModal({
1577
+ open,
1578
+ onOpenChange,
1579
+ applicantLabel = "Applicant",
1580
+ initialData,
1581
+ onSave,
1582
+ container,
1583
+ className
1584
+ }) {
1585
+ const defaultItems = React.useMemo(
1586
+ () => {
1587
+ var _a;
1588
+ return ((_a = initialData == null ? void 0 : initialData.items) == null ? void 0 : _a.length) ? initialData.items : [makeDefaultIncomeItem()];
1589
+ },
1590
+ []
1591
+ // eslint-disable-line react-hooks/exhaustive-deps
1592
+ );
1593
+ const [items, setItems] = React.useState(defaultItems);
1594
+ const initialSnapshot = React.useRef("");
1595
+ React.useEffect(() => {
1596
+ var _a;
1597
+ if (open) {
1598
+ const data = ((_a = initialData == null ? void 0 : initialData.items) == null ? void 0 : _a.length) ? initialData.items : [makeDefaultIncomeItem()];
1599
+ setItems(data);
1600
+ initialSnapshot.current = JSON.stringify(data);
1601
+ }
1602
+ }, [open]);
1603
+ const isDirty = JSON.stringify(items) !== initialSnapshot.current;
1604
+ const updateItem = (id, key, val) => setItems(
1605
+ (prev) => prev.map((item) => item.id === id ? __spreadProps(__spreadValues({}, item), { [key]: val }) : item)
1606
+ );
1607
+ const removeItem = (id) => setItems((prev) => prev.filter((item) => item.id !== id));
1608
+ const addItem = () => setItems((prev) => [...prev, makeDefaultIncomeItem()]);
1609
+ const defaultOpenItems = items.length > 0 ? [items[0].id] : [];
1610
+ return /* @__PURE__ */ jsx(Dialog, { open, onOpenChange, children: /* @__PURE__ */ jsxs(
1611
+ DialogContent,
1612
+ {
1613
+ className: cn("max-w-lg", className),
1614
+ container,
1615
+ children: [
1616
+ /* @__PURE__ */ jsx(DialogHeader, { children: /* @__PURE__ */ jsxs(DialogTitle, { children: [
1617
+ "Edit Income ",
1618
+ applicantLabel
1619
+ ] }) }),
1620
+ /* @__PURE__ */ jsxs(ModalScroll, { children: [
1621
+ /* @__PURE__ */ jsx(
1622
+ Accordion,
1623
+ {
1624
+ multiple: true,
1625
+ defaultValue: defaultOpenItems,
1626
+ className: "w-full",
1627
+ children: items.map((item, index) => /* @__PURE__ */ jsxs(AccordionItem, { value: item.id, children: [
1628
+ /* @__PURE__ */ jsx(
1629
+ AccordionItemHeader,
1630
+ {
1631
+ label: `Income ${index + 1} \u2014 ${item.incomeType || "New Income"}`,
1632
+ onRemove: () => removeItem(item.id),
1633
+ removeLabel: "Remove income item"
1634
+ }
1635
+ ),
1636
+ /* @__PURE__ */ jsx(AccordionContent, { children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-4 pt-1", children: [
1637
+ /* @__PURE__ */ jsx(FormField, { label: "Income Type", children: /* @__PURE__ */ jsxs(
1638
+ Select,
1639
+ {
1640
+ value: item.incomeType,
1641
+ onValueChange: (val) => updateItem(item.id, "incomeType", val),
1642
+ children: [
1643
+ /* @__PURE__ */ jsx(SelectTrigger, { className: "w-full", children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Select type" }) }),
1644
+ /* @__PURE__ */ jsx(SelectContent, { children: INCOME_TYPES.map((t) => /* @__PURE__ */ jsx(SelectItem, { value: t, children: t }, t)) })
1645
+ ]
1646
+ }
1647
+ ) }),
1648
+ /* @__PURE__ */ jsx(FormField, { label: "Job Title", children: /* @__PURE__ */ jsx(
1649
+ Input,
1650
+ {
1651
+ value: item.jobTitle,
1652
+ onChange: (e) => updateItem(item.id, "jobTitle", e.target.value),
1653
+ placeholder: "Job title"
1654
+ }
1655
+ ) }),
1656
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
1657
+ /* @__PURE__ */ jsx(FormField, { label: "Start Date", children: /* @__PURE__ */ jsx(
1658
+ DatePicker,
1659
+ {
1660
+ value: item.startDate ? new Date(item.startDate) : void 0,
1661
+ onChange: (d) => updateItem(
1662
+ item.id,
1663
+ "startDate",
1664
+ d ? d.toISOString().slice(0, 10) : ""
1665
+ ),
1666
+ calendarProps: {
1667
+ fromYear: 1950,
1668
+ toYear: (/* @__PURE__ */ new Date()).getFullYear()
1669
+ }
1670
+ }
1671
+ ) }),
1672
+ !item.stillInPosition && /* @__PURE__ */ jsx(FormField, { label: "End Date", children: /* @__PURE__ */ jsx(
1673
+ DatePicker,
1674
+ {
1675
+ value: item.endDate ? new Date(item.endDate) : void 0,
1676
+ onChange: (d) => updateItem(
1677
+ item.id,
1678
+ "endDate",
1679
+ d ? d.toISOString().slice(0, 10) : ""
1680
+ ),
1681
+ calendarProps: {
1682
+ fromYear: 1950,
1683
+ toYear: (/* @__PURE__ */ new Date()).getFullYear()
1684
+ }
1685
+ }
1686
+ ) })
1687
+ ] }),
1688
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
1689
+ /* @__PURE__ */ jsx(
1690
+ Checkbox,
1691
+ {
1692
+ id: `still-in-position-${item.id}`,
1693
+ checked: item.stillInPosition,
1694
+ onCheckedChange: (checked) => updateItem(
1695
+ item.id,
1696
+ "stillInPosition",
1697
+ checked === true
1698
+ )
1699
+ }
1700
+ ),
1701
+ /* @__PURE__ */ jsx(
1702
+ "label",
1703
+ {
1704
+ htmlFor: `still-in-position-${item.id}`,
1705
+ className: "text-sm cursor-pointer select-none",
1706
+ children: "Still in position"
1707
+ }
1708
+ )
1709
+ ] }),
1710
+ /* @__PURE__ */ jsx(FormField, { label: "Company Name", children: /* @__PURE__ */ jsx(
1711
+ Input,
1712
+ {
1713
+ value: item.companyName,
1714
+ onChange: (e) => updateItem(item.id, "companyName", e.target.value),
1715
+ placeholder: "Company name"
1716
+ }
1717
+ ) }),
1718
+ /* @__PURE__ */ jsx(FormField, { label: "Company Address", children: /* @__PURE__ */ jsx(
1719
+ AddressAutocomplete,
1720
+ {
1721
+ value: item.companyAddress,
1722
+ onValueChange: (val) => updateItem(item.id, "companyAddress", val),
1723
+ placeholder: "Search company address"
1724
+ }
1725
+ ) }),
1726
+ /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-3", children: [
1727
+ /* @__PURE__ */ jsx("div", { className: "flex-1", children: /* @__PURE__ */ jsx(FormField, { label: "Income Amount", children: /* @__PURE__ */ jsx(
1728
+ CurrencyInputWithSlider,
1729
+ {
1730
+ value: item.incomeAmount,
1731
+ min: 0,
1732
+ max: 1e6,
1733
+ step: 1e3,
1734
+ onValueChange: (val) => updateItem(item.id, "incomeAmount", val)
1735
+ }
1736
+ ) }) }),
1737
+ /* @__PURE__ */ jsx("div", { className: "shrink-0 mt-[1.625rem]", children: /* @__PURE__ */ jsx(
1738
+ FrequencyToggle,
1739
+ {
1740
+ value: item.frequency,
1741
+ onValueChange: (val) => updateItem(item.id, "frequency", val)
1742
+ }
1743
+ ) })
1744
+ ] }),
1745
+ /* @__PURE__ */ jsx(FormField, { label: "Type of Company", children: /* @__PURE__ */ jsx(
1746
+ RadioGroup,
1747
+ {
1748
+ value: item.companyType,
1749
+ onValueChange: (val) => updateItem(
1750
+ item.id,
1751
+ "companyType",
1752
+ val
1753
+ ),
1754
+ className: "flex gap-4",
1755
+ children: ["Public", "Private"].map((opt) => /* @__PURE__ */ jsxs(
1756
+ "label",
1757
+ {
1758
+ className: "flex items-center gap-2 cursor-pointer text-sm",
1759
+ children: [
1760
+ /* @__PURE__ */ jsx(RadioGroupItem, { value: opt }),
1761
+ opt
1762
+ ]
1763
+ },
1764
+ opt
1765
+ ))
1766
+ }
1767
+ ) })
1768
+ ] }) })
1769
+ ] }, item.id))
1770
+ }
1771
+ ),
1772
+ /* @__PURE__ */ jsxs(
1773
+ Button,
1774
+ {
1775
+ variant: "outline",
1776
+ onClick: addItem,
1777
+ className: "w-full gap-1.5",
1778
+ children: [
1779
+ /* @__PURE__ */ jsx(Plus, { className: "h-4 w-4" }),
1780
+ "Add More"
1781
+ ]
1782
+ }
1783
+ )
1784
+ ] }),
1785
+ /* @__PURE__ */ jsxs(DialogFooter, { children: [
1786
+ /* @__PURE__ */ jsx(Button, { variant: "outline", onClick: () => onOpenChange(false), children: "Cancel" }),
1787
+ /* @__PURE__ */ jsx(
1788
+ Button,
1789
+ {
1790
+ disabled: !isDirty,
1791
+ onClick: () => {
1792
+ onSave({ items });
1793
+ onOpenChange(false);
1794
+ },
1795
+ children: "Save"
1796
+ }
1797
+ )
1798
+ ] })
1799
+ ]
1800
+ }
1801
+ ) });
1802
+ }
1803
+ function EditExpensesModal({
1804
+ open,
1805
+ onOpenChange,
1806
+ applicantLabel = "Applicant",
1807
+ initialData,
1808
+ onSave,
1809
+ container,
1810
+ className
1811
+ }) {
1812
+ const defaultItems = React.useMemo(
1813
+ () => {
1814
+ var _a;
1815
+ return ((_a = initialData == null ? void 0 : initialData.items) == null ? void 0 : _a.length) ? initialData.items : [makeDefaultExpenseItem()];
1816
+ },
1817
+ []
1818
+ // eslint-disable-line react-hooks/exhaustive-deps
1819
+ );
1820
+ const [items, setItems] = React.useState(defaultItems);
1821
+ const initialSnapshot = React.useRef("");
1822
+ React.useEffect(() => {
1823
+ var _a;
1824
+ if (open) {
1825
+ const data = ((_a = initialData == null ? void 0 : initialData.items) == null ? void 0 : _a.length) ? initialData.items : [makeDefaultExpenseItem()];
1826
+ setItems(data);
1827
+ initialSnapshot.current = JSON.stringify(data);
1828
+ }
1829
+ }, [open]);
1830
+ const isDirty = JSON.stringify(items) !== initialSnapshot.current;
1831
+ const updateItem = (id, key, val) => setItems(
1832
+ (prev) => prev.map((item) => item.id === id ? __spreadProps(__spreadValues({}, item), { [key]: val }) : item)
1833
+ );
1834
+ const removeItem = (id) => setItems((prev) => prev.filter((item) => item.id !== id));
1835
+ const addItem = () => setItems((prev) => [...prev, makeDefaultExpenseItem()]);
1836
+ const defaultOpenItems = items.length > 0 ? [items[0].id] : [];
1837
+ return /* @__PURE__ */ jsx(Dialog, { open, onOpenChange, children: /* @__PURE__ */ jsxs(
1838
+ DialogContent,
1839
+ {
1840
+ className: cn("max-w-lg", className),
1841
+ container,
1842
+ children: [
1843
+ /* @__PURE__ */ jsx(DialogHeader, { children: /* @__PURE__ */ jsxs(DialogTitle, { children: [
1844
+ "Edit Expenses ",
1845
+ applicantLabel
1846
+ ] }) }),
1847
+ /* @__PURE__ */ jsxs(ModalScroll, { children: [
1848
+ /* @__PURE__ */ jsx(
1849
+ Accordion,
1850
+ {
1851
+ multiple: true,
1852
+ defaultValue: defaultOpenItems,
1853
+ className: "w-full",
1854
+ children: items.map((item, index) => /* @__PURE__ */ jsxs(AccordionItem, { value: item.id, children: [
1855
+ /* @__PURE__ */ jsx(
1856
+ AccordionItemHeader,
1857
+ {
1858
+ label: `Expense ${index + 1} \u2014 ${item.expenseType || "New Expense"}`,
1859
+ onRemove: () => removeItem(item.id),
1860
+ removeLabel: "Remove expense item"
1861
+ }
1862
+ ),
1863
+ /* @__PURE__ */ jsx(AccordionContent, { children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-4 pt-1", children: [
1864
+ /* @__PURE__ */ jsx(FormField, { label: "Expense Type", children: /* @__PURE__ */ jsxs(
1865
+ Select,
1866
+ {
1867
+ value: item.expenseType,
1868
+ onValueChange: (val) => updateItem(item.id, "expenseType", val),
1869
+ children: [
1870
+ /* @__PURE__ */ jsx(SelectTrigger, { className: "w-full", children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Select type" }) }),
1871
+ /* @__PURE__ */ jsx(SelectContent, { children: EXPENSE_TYPES.map((t) => /* @__PURE__ */ jsx(SelectItem, { value: t, children: t }, t)) })
1872
+ ]
1873
+ }
1874
+ ) }),
1875
+ /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-3", children: [
1876
+ /* @__PURE__ */ jsx("div", { className: "flex-1", children: /* @__PURE__ */ jsx(FormField, { label: "Amount", children: /* @__PURE__ */ jsx(
1877
+ CurrencyInputWithSlider,
1878
+ {
1879
+ value: item.amount,
1880
+ min: 0,
1881
+ max: 1e5,
1882
+ step: 100,
1883
+ onValueChange: (val) => updateItem(item.id, "amount", val)
1884
+ }
1885
+ ) }) }),
1886
+ /* @__PURE__ */ jsx("div", { className: "shrink-0 mt-[1.625rem]", children: /* @__PURE__ */ jsx(
1887
+ FrequencyToggle,
1888
+ {
1889
+ value: item.frequency,
1890
+ onValueChange: (val) => updateItem(item.id, "frequency", val)
1891
+ }
1892
+ ) })
1893
+ ] }),
1894
+ /* @__PURE__ */ jsx(FormField, { label: "Ownership (%)", children: /* @__PURE__ */ jsx(
1895
+ OwnershipSplit,
1896
+ {
1897
+ owners: [
1898
+ {
1899
+ id: "main",
1900
+ name: "Main Applicant",
1901
+ share: item.mainShare
1902
+ },
1903
+ {
1904
+ id: "co",
1905
+ name: "Co-Applicant",
1906
+ share: item.coShare
1907
+ }
1908
+ ],
1909
+ onOwnersChange: (owners) => {
1910
+ var _a, _b, _c, _d;
1911
+ const main = (_b = (_a = owners.find((o) => o.id === "main")) == null ? void 0 : _a.share) != null ? _b : item.mainShare;
1912
+ const co = (_d = (_c = owners.find((o) => o.id === "co")) == null ? void 0 : _c.share) != null ? _d : item.coShare;
1913
+ updateItem(item.id, "mainShare", main);
1914
+ updateItem(item.id, "coShare", co);
1915
+ }
1916
+ }
1917
+ ) })
1918
+ ] }) })
1919
+ ] }, item.id))
1920
+ }
1921
+ ),
1922
+ /* @__PURE__ */ jsxs(
1923
+ Button,
1924
+ {
1925
+ variant: "outline",
1926
+ onClick: addItem,
1927
+ className: "w-full gap-1.5",
1928
+ children: [
1929
+ /* @__PURE__ */ jsx(Plus, { className: "h-4 w-4" }),
1930
+ "Add More"
1931
+ ]
1932
+ }
1933
+ )
1934
+ ] }),
1935
+ /* @__PURE__ */ jsxs(DialogFooter, { children: [
1936
+ /* @__PURE__ */ jsx(Button, { variant: "outline", onClick: () => onOpenChange(false), children: "Cancel" }),
1937
+ /* @__PURE__ */ jsx(
1938
+ Button,
1939
+ {
1940
+ disabled: !isDirty,
1941
+ onClick: () => {
1942
+ onSave({ items });
1943
+ onOpenChange(false);
1944
+ },
1945
+ children: "Save"
1946
+ }
1947
+ )
1948
+ ] })
1949
+ ]
1950
+ }
1951
+ ) });
1952
+ }
1953
+
1954
+ export {
1955
+ PROPERTY_ASSET_TYPES,
1956
+ EditLoanScenarioModal,
1957
+ EditAssetsModal,
1958
+ EditDebtsModal,
1959
+ EditAboutApplicantModal,
1960
+ EditIncomeModal,
1961
+ EditExpensesModal
1962
+ };