@burdenoff/microfe-subscriberbot 2026.1102.3 → 2026.1102.4

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 (28) hide show
  1. package/dist/stories/pages/BankConnectionsPage.stories.d.ts +12 -0
  2. package/dist/stories/pages/BankConnectionsPage.stories.d.ts.map +1 -0
  3. package/dist/stories/support/bankingFixtures.d.ts +8 -0
  4. package/dist/stories/support/bankingFixtures.d.ts.map +1 -0
  5. package/dist/subscriberbot/SubscriberBotRoot.d.ts.map +1 -1
  6. package/dist/subscriberbot/SubscriberBotRoot.js +58 -50
  7. package/dist/subscriberbot/SubscriberBotRoot.js.map +1 -1
  8. package/dist/subscriberbot/SubscriberBotRoutes.d.ts.map +1 -1
  9. package/dist/subscriberbot/SubscriberBotRoutes.js +10 -6
  10. package/dist/subscriberbot/SubscriberBotRoutes.js.map +1 -1
  11. package/dist/subscriberbot/components/StatusBadge.d.ts.map +1 -1
  12. package/dist/subscriberbot/components/StatusBadge.js +3 -0
  13. package/dist/subscriberbot/components/StatusBadge.js.map +1 -1
  14. package/dist/subscriberbot/hooks/useBankingApi.d.ts +31 -0
  15. package/dist/subscriberbot/hooks/useBankingApi.d.ts.map +1 -0
  16. package/dist/subscriberbot/hooks/useBankingApi.js +105 -0
  17. package/dist/subscriberbot/hooks/useBankingApi.js.map +1 -0
  18. package/dist/subscriberbot/pages/banking/BankConnectionsPage.d.ts +11 -0
  19. package/dist/subscriberbot/pages/banking/BankConnectionsPage.d.ts.map +1 -0
  20. package/dist/subscriberbot/pages/banking/BankConnectionsPage.js +564 -0
  21. package/dist/subscriberbot/pages/banking/BankConnectionsPage.js.map +1 -0
  22. package/dist/subscriberbot/types/banking.d.ts +86 -0
  23. package/dist/subscriberbot/types/banking.d.ts.map +1 -0
  24. package/dist/subscriberbot/utils/plaidLink.d.ts +47 -0
  25. package/dist/subscriberbot/utils/plaidLink.d.ts.map +1 -0
  26. package/dist/subscriberbot/utils/plaidLink.js +35 -0
  27. package/dist/subscriberbot/utils/plaidLink.js.map +1 -0
  28. package/package.json +1 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BankConnectionsPage.d.ts","sourceRoot":"","sources":["../../../../src/subscriberbot/pages/banking/BankConnectionsPage.tsx"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AA4EH,wBAAgB,mBAAmB,gCA0clC"}
@@ -0,0 +1,564 @@
1
+ import { useSubscriberBot as e } from "../../context/SubscriberBotContext.js";
2
+ import { cn as t } from "../../utils/cn.js";
3
+ import { PageLayout as n } from "../../components/PageLayout.js";
4
+ import { MetricsCard as r } from "../../components/MetricsCard.js";
5
+ import { formatCurrency as i, formatDate as a, formatIntervalSuffix as o } from "../../utils/formatters.js";
6
+ import { StatusBadge as s } from "../../components/StatusBadge.js";
7
+ import { EmptyState as c } from "../../components/EmptyState.js";
8
+ import { Modal as l } from "../../components/Modal.js";
9
+ import { useTr as ee } from "../../hooks/useTr.js";
10
+ import { ErrorView as u, LoadingView as d, Section as f } from "../../components/StateViews.js";
11
+ import "../../components/index.js";
12
+ import { useBankAggregators as p, useBankConnections as m, useCompleteBankLink as h, useCreateBankLinkSession as te, useDismissRecurringCharge as g, useImportBankStatement as ne, useRecurringCharges as _, useRemoveBankConnection as v, useRestoreRecurringCharge as y, useSyncBankConnection as b, useTrackRecurringCharge as x } from "../../hooks/useBankingApi.js";
13
+ import { openPlaidLink as S } from "../../utils/plaidLink.js";
14
+ import { useMemo as C, useState as w } from "react";
15
+ import { CalendarClock as T, FileUp as E, Landmark as re, Link2 as ie, RefreshCw as ae, Repeat as oe, ShieldCheck as se, Trash2 as ce } from "lucide-react";
16
+ import { Fragment as le, jsx as D, jsxs as O } from "react/jsx-runtime";
17
+ import { PagePurpose as ue } from "@burdenoff/fe-libs/ui";
18
+ //#region src/subscriberbot/pages/banking/BankConnectionsPage.tsx
19
+ var k = "w-full rounded-lg border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary placeholder:text-text-secondary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]", A = "inline-flex items-center gap-2 rounded-lg bg-action-primary-bg px-3 py-2 text-sm font-medium text-action-primary-text hover:opacity-90 disabled:opacity-50", j = "inline-flex items-center gap-2 rounded-lg border border-border-subtle px-3 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken disabled:opacity-50", M = "inline-flex items-center gap-1.5 rounded-lg border border-border-subtle px-2.5 py-1.5 text-xs font-medium text-text-primary hover:bg-bg-sunken disabled:opacity-50", de = [
20
+ "DETECTED",
21
+ "TRACKED",
22
+ "DISMISSED"
23
+ ], N = {
24
+ DETECTED: {
25
+ key: "banking.charges.detected",
26
+ fallback: "To review"
27
+ },
28
+ TRACKED: {
29
+ key: "banking.charges.tracked",
30
+ fallback: "Tracked"
31
+ },
32
+ DISMISSED: {
33
+ key: "banking.charges.dismissed",
34
+ fallback: "Dismissed"
35
+ }
36
+ }, P = 2e6, F = (e) => e instanceof Error ? e.message : "Something went wrong";
37
+ function I() {
38
+ let l = ee(), { navigateTo: ne } = e(), [k, P] = w("DETECTED"), [I, L] = w(!1), [R, z] = w(null), [B, V] = w(!1), pe = p(), H = m(), U = _(k), W = _("DETECTED"), G = _("TRACKED"), me = te(), he = h(), K = b(), q = v(), J = x(), Y = g(), ge = y(), X = pe.data?.find((e) => e.aggregator === "PLAID"), Z = H.data?.items ?? [], _e = U.data?.items ?? [], ve = C(() => {
39
+ let e = /* @__PURE__ */ new Map();
40
+ for (let t of W.data?.items ?? []) e.set(t.currency, (e.get(t.currency) ?? 0) + t.annualCost);
41
+ return [...e.entries()].map(([e, t]) => i(t, e)).join(" + ");
42
+ }, [W.data]), Q = (e) => l("banking.notice.synced", "{{added}} new transaction(s) from {{institution}}; {{recurring}} recurring charge(s) found.", {
43
+ added: e.added,
44
+ institution: e.connection.institutionName,
45
+ recurring: e.recurringDetected
46
+ }), ye = async () => {
47
+ z(null), V(!0);
48
+ try {
49
+ let e = await S((await me.mutateAsync({ aggregator: "PLAID" })).linkToken);
50
+ if (!e) return;
51
+ z({
52
+ tone: "success",
53
+ text: Q(await he.mutateAsync({ input: {
54
+ aggregator: "PLAID",
55
+ publicToken: e.publicToken,
56
+ institutionId: e.institutionId,
57
+ institutionName: e.institutionName
58
+ } }))
59
+ });
60
+ } catch (e) {
61
+ z({
62
+ tone: "error",
63
+ text: F(e)
64
+ });
65
+ } finally {
66
+ V(!1);
67
+ }
68
+ }, be = async (e) => {
69
+ z(null);
70
+ try {
71
+ z({
72
+ tone: "success",
73
+ text: Q(await K.mutateAsync({ id: e.id }))
74
+ });
75
+ } catch (e) {
76
+ z({
77
+ tone: "error",
78
+ text: F(e)
79
+ });
80
+ }
81
+ }, xe = async (e) => {
82
+ if (window.confirm(l("banking.disconnect.confirm", "Disconnect {{institution}}? Its accounts and transactions are deleted from Subscriber Bot. Subscriptions you already track stay.", { institution: e.institutionName }))) {
83
+ z(null);
84
+ try {
85
+ await q.mutateAsync({ id: e.id }), z({
86
+ tone: "success",
87
+ text: l("banking.notice.disconnected", "{{institution}} was disconnected.", { institution: e.institutionName })
88
+ });
89
+ } catch (e) {
90
+ z({
91
+ tone: "error",
92
+ text: F(e)
93
+ });
94
+ }
95
+ }
96
+ }, $ = async (e, t) => {
97
+ z(null);
98
+ try {
99
+ let n = await {
100
+ track: J,
101
+ dismiss: Y,
102
+ restore: ge
103
+ }[e].mutateAsync({ id: t.id });
104
+ e === "track" && z({
105
+ tone: "success",
106
+ text: l("banking.notice.tracked", "{{name}} is now tracked as a subscription.", { name: n.displayName })
107
+ });
108
+ } catch (e) {
109
+ z({
110
+ tone: "error",
111
+ text: F(e)
112
+ });
113
+ }
114
+ }, Se = /* @__PURE__ */ O("div", {
115
+ className: "flex flex-wrap gap-2",
116
+ children: [/* @__PURE__ */ O("button", {
117
+ type: "button",
118
+ className: j,
119
+ onClick: () => L(!0),
120
+ children: [
121
+ /* @__PURE__ */ D(E, {
122
+ className: "h-4 w-4",
123
+ "aria-hidden": !0
124
+ }),
125
+ " ",
126
+ l("banking.import.open", "Import a statement")
127
+ ]
128
+ }), /* @__PURE__ */ O("button", {
129
+ type: "button",
130
+ className: A,
131
+ onClick: () => void ye(),
132
+ disabled: !X?.available || B,
133
+ title: X?.available ? void 0 : l("banking.plaid.unavailable", "Bank linking is not switched on yet. Import a statement instead."),
134
+ children: [/* @__PURE__ */ D(ie, {
135
+ className: "h-4 w-4",
136
+ "aria-hidden": !0
137
+ }), B ? l("banking.plaid.linking", "Connecting…") : l("banking.plaid.connect", "Connect a bank")]
138
+ })]
139
+ });
140
+ return /* @__PURE__ */ O(n, {
141
+ title: l("banking.title", "Bank & card connections"),
142
+ description: l("banking.description", "Find every subscription in your bank and card transactions."),
143
+ actions: Se,
144
+ children: [
145
+ /* @__PURE__ */ D(ue, {
146
+ className: "mb-6",
147
+ children: l("banking.purpose", "Connect a US bank or card through Plaid, or import the CSV export any bank lets you download. Subscriber Bot spots the charges that repeat every week, month, quarter or year so you can track them or wave them off. Your bank password is never shared with Subscriber Bot, and only you can see these accounts.")
148
+ }),
149
+ X && !X.available && /* @__PURE__ */ O("p", {
150
+ className: "mb-4 flex items-start gap-2 rounded-lg border border-border-subtle bg-bg-sunken px-3 py-2 text-sm text-text-secondary",
151
+ "data-testid": "plaid-unavailable",
152
+ children: [/* @__PURE__ */ D(se, {
153
+ className: "mt-0.5 h-4 w-4 shrink-0",
154
+ "aria-hidden": !0
155
+ }), l("banking.plaid.unavailableLong", "Direct bank linking is being switched on. Until then, import a statement export: it finds the same recurring charges.")]
156
+ }),
157
+ R && /* @__PURE__ */ D("p", {
158
+ role: R.tone === "error" ? "alert" : "status",
159
+ className: t("mb-4 rounded-lg px-3 py-2 text-sm", R.tone === "error" ? "bg-status-error-bg-subtle text-status-error-text" : "bg-status-success-bg-subtle text-status-success-text"),
160
+ "data-testid": "banking-notice",
161
+ children: R.text
162
+ }),
163
+ /* @__PURE__ */ O("div", {
164
+ className: "grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4",
165
+ children: [
166
+ /* @__PURE__ */ D(r, {
167
+ icon: /* @__PURE__ */ D(re, { className: "h-5 w-5" }),
168
+ value: H.isLoading ? "—" : Z.length,
169
+ label: l("banking.metrics.connections", "Connected accounts")
170
+ }),
171
+ /* @__PURE__ */ D(r, {
172
+ icon: /* @__PURE__ */ D(oe, { className: "h-5 w-5" }),
173
+ value: W.isLoading ? "—" : W.data?.items.length ?? 0,
174
+ label: l("banking.metrics.detected", "Charges to review")
175
+ }),
176
+ /* @__PURE__ */ D(r, {
177
+ icon: /* @__PURE__ */ D(T, { className: "h-5 w-5" }),
178
+ value: W.isLoading ? "—" : ve || i(0, "USD"),
179
+ label: l("banking.metrics.yearly", "Yearly cost to review")
180
+ }),
181
+ /* @__PURE__ */ D(r, {
182
+ icon: /* @__PURE__ */ D(se, { className: "h-5 w-5" }),
183
+ value: G.isLoading ? "—" : G.data?.items.length ?? 0,
184
+ label: l("banking.metrics.tracked", "Tracked from your bank")
185
+ })
186
+ ]
187
+ }),
188
+ /* @__PURE__ */ O(f, {
189
+ title: l("banking.charges.title", "Recurring charges found"),
190
+ description: l("banking.charges.description", "Charges from the same merchant at a steady amount and rhythm."),
191
+ children: [/* @__PURE__ */ D("div", {
192
+ role: "tablist",
193
+ "aria-label": l("banking.charges.filter", "Charge status"),
194
+ className: "mb-3 flex gap-1.5",
195
+ children: de.map((e) => /* @__PURE__ */ D("button", {
196
+ type: "button",
197
+ role: "tab",
198
+ "aria-selected": k === e,
199
+ onClick: () => P(e),
200
+ className: t("rounded-lg px-3 py-1.5 text-xs font-medium", k === e ? "bg-action-primary-bg text-action-primary-text" : "border border-border-subtle text-text-primary hover:bg-bg-sunken"),
201
+ children: l(N[e].key, N[e].fallback)
202
+ }, e))
203
+ }), U.isLoading ? /* @__PURE__ */ D(d, { label: l("banking.charges.loading", "Loading recurring charges…") }) : U.isError ? /* @__PURE__ */ D(u, {
204
+ message: F(U.error),
205
+ onRetry: () => void U.refetch()
206
+ }) : _e.length === 0 ? /* @__PURE__ */ D(c, {
207
+ illustration: "empty-data",
208
+ title: l("banking.charges.empty.title", "Nothing here yet"),
209
+ description: l("banking.charges.empty.description", "Import a statement with at least two months of transactions, or connect a bank, and repeating charges show up here.")
210
+ }) : /* @__PURE__ */ D("ul", {
211
+ className: "grid grid-cols-1 gap-3 lg:grid-cols-2",
212
+ "data-testid": "recurring-charge-list",
213
+ children: _e.map((e) => /* @__PURE__ */ O("li", {
214
+ className: "rounded-xl border border-border-subtle bg-bg-surface p-4",
215
+ "data-testid": "recurring-charge",
216
+ children: [
217
+ /* @__PURE__ */ O("div", {
218
+ className: "flex items-start justify-between gap-3",
219
+ children: [/* @__PURE__ */ O("div", {
220
+ className: "min-w-0",
221
+ children: [/* @__PURE__ */ D("p", {
222
+ className: "truncate text-sm font-semibold text-text-primary",
223
+ children: e.displayName
224
+ }), /* @__PURE__ */ D("p", {
225
+ className: "mt-0.5 text-xs text-text-secondary",
226
+ children: l("banking.charges.meta", "{{count}} charges since {{first}} · {{confidence}}% sure", {
227
+ count: e.occurrences,
228
+ first: a(e.firstChargedOn),
229
+ confidence: e.confidence
230
+ })
231
+ })]
232
+ }), /* @__PURE__ */ O("span", {
233
+ className: "shrink-0 text-sm font-semibold text-text-primary",
234
+ children: [i(e.lastAmount, e.currency), o(e.interval)]
235
+ })]
236
+ }),
237
+ /* @__PURE__ */ O("p", {
238
+ className: "mt-2 text-xs text-text-secondary",
239
+ children: [
240
+ l("banking.charges.dates", "Last charged {{last}}", { last: a(e.lastChargedOn) }),
241
+ e.nextExpectedOn && ` · ${l("banking.charges.next", "next expected {{next}}", { next: a(e.nextExpectedOn) })}`,
242
+ ` · ${l("banking.charges.yearly", "{{amount}} a year", { amount: i(e.annualCost, e.currency) })}`
243
+ ]
244
+ }),
245
+ /* @__PURE__ */ O("div", {
246
+ className: "mt-3 flex flex-wrap gap-2",
247
+ children: [
248
+ e.status === "DETECTED" && /* @__PURE__ */ O(le, { children: [/* @__PURE__ */ D("button", {
249
+ type: "button",
250
+ className: A,
251
+ onClick: () => void $("track", e),
252
+ disabled: J.isPending,
253
+ children: l("banking.charges.track", "Track as subscription")
254
+ }), /* @__PURE__ */ D("button", {
255
+ type: "button",
256
+ className: j,
257
+ onClick: () => void $("dismiss", e),
258
+ disabled: Y.isPending,
259
+ children: l("banking.charges.dismiss", "Not a subscription")
260
+ })] }),
261
+ e.status === "TRACKED" && e.relationshipId && /* @__PURE__ */ D("button", {
262
+ type: "button",
263
+ className: j,
264
+ onClick: () => ne(`/relationships/${e.relationshipId}`),
265
+ children: l("banking.charges.view", "View subscription")
266
+ }),
267
+ e.status === "DISMISSED" && /* @__PURE__ */ D("button", {
268
+ type: "button",
269
+ className: j,
270
+ onClick: () => void $("restore", e),
271
+ disabled: ge.isPending,
272
+ children: l("banking.charges.restore", "Review again")
273
+ })
274
+ ]
275
+ })
276
+ ]
277
+ }, e.id))
278
+ })]
279
+ }),
280
+ /* @__PURE__ */ D(f, {
281
+ title: l("banking.connections.title", "Your connections"),
282
+ description: l("banking.connections.description", "Disconnecting deletes the accounts and transactions from Subscriber Bot."),
283
+ children: H.isLoading ? /* @__PURE__ */ D(d, { label: l("banking.connections.loading", "Loading connections…") }) : H.isError ? /* @__PURE__ */ D(u, {
284
+ message: F(H.error),
285
+ onRetry: () => void H.refetch()
286
+ }) : Z.length === 0 ? /* @__PURE__ */ D(c, {
287
+ illustration: "empty-data",
288
+ title: l("banking.connections.empty.title", "No bank or card connected"),
289
+ description: l("banking.connections.empty.description", "Download a CSV of your transactions from your bank or card website and import it, or connect a bank."),
290
+ action: /* @__PURE__ */ O("button", {
291
+ type: "button",
292
+ className: A,
293
+ onClick: () => L(!0),
294
+ children: [
295
+ /* @__PURE__ */ D(E, {
296
+ className: "h-4 w-4",
297
+ "aria-hidden": !0
298
+ }),
299
+ " ",
300
+ l("banking.import.open", "Import a statement")
301
+ ]
302
+ })
303
+ }) : /* @__PURE__ */ D("ul", {
304
+ className: "space-y-3",
305
+ "data-testid": "bank-connection-list",
306
+ children: Z.map((e) => /* @__PURE__ */ O("li", {
307
+ className: "flex flex-col gap-3 rounded-xl border border-border-subtle bg-bg-surface p-4 sm:flex-row sm:items-center sm:justify-between",
308
+ "data-testid": "bank-connection",
309
+ children: [/* @__PURE__ */ O("div", {
310
+ className: "min-w-0",
311
+ children: [
312
+ /* @__PURE__ */ O("div", {
313
+ className: "flex items-center gap-2",
314
+ children: [/* @__PURE__ */ D("p", {
315
+ className: "truncate text-sm font-semibold text-text-primary",
316
+ children: e.institutionName
317
+ }), /* @__PURE__ */ D(s, { status: e.status })]
318
+ }),
319
+ /* @__PURE__ */ O("p", {
320
+ className: "mt-0.5 text-xs text-text-secondary",
321
+ children: [
322
+ e.aggregator === "PLAID" ? l("banking.connections.viaPlaid", "Linked with Plaid") : l("banking.connections.viaImport", "Statement import"),
323
+ " · ",
324
+ e.accounts.map((e) => e.mask ? `${e.name} ••${e.mask}` : e.name).join(", ") || l("banking.connections.noAccounts", "no accounts yet"),
325
+ " · ",
326
+ l("banking.connections.count", "{{count}} transactions", { count: e.transactionCount }),
327
+ e.lastSyncedAt && ` · ${l("banking.connections.synced", "updated {{date}}", { date: a(e.lastSyncedAt) })}`
328
+ ]
329
+ }),
330
+ e.lastSyncError && /* @__PURE__ */ D("p", {
331
+ className: "mt-1 text-xs text-status-error-text",
332
+ children: e.lastSyncError
333
+ })
334
+ ]
335
+ }), /* @__PURE__ */ O("div", {
336
+ className: "flex shrink-0 gap-2",
337
+ children: [e.aggregator === "PLAID" && /* @__PURE__ */ O("button", {
338
+ type: "button",
339
+ className: M,
340
+ onClick: () => void be(e),
341
+ disabled: K.isPending || !X?.available,
342
+ children: [
343
+ /* @__PURE__ */ D(ae, {
344
+ className: "h-3.5 w-3.5",
345
+ "aria-hidden": !0
346
+ }),
347
+ " ",
348
+ l("banking.connections.sync", "Sync")
349
+ ]
350
+ }), /* @__PURE__ */ O("button", {
351
+ type: "button",
352
+ className: M,
353
+ onClick: () => void xe(e),
354
+ disabled: q.isPending,
355
+ children: [
356
+ /* @__PURE__ */ D(ce, {
357
+ className: "h-3.5 w-3.5",
358
+ "aria-hidden": !0
359
+ }),
360
+ " ",
361
+ l("banking.connections.disconnect", "Disconnect")
362
+ ]
363
+ })]
364
+ })]
365
+ }, e.id))
366
+ })
367
+ }),
368
+ I && /* @__PURE__ */ D(fe, {
369
+ connections: Z.filter((e) => e.aggregator === "STATEMENT_IMPORT"),
370
+ onClose: () => L(!1),
371
+ onImported: (e) => {
372
+ L(!1), P("DETECTED"), z({
373
+ tone: "success",
374
+ text: Q(e)
375
+ });
376
+ }
377
+ })
378
+ ]
379
+ });
380
+ }
381
+ function fe({ connections: e, onClose: n, onImported: r }) {
382
+ let i = ee(), a = ne(), [o, s] = w(""), [c, u] = w(""), [d, f] = w(""), [p, m] = w(""), [h, te] = w("USD"), [g, _] = w("OUTFLOW_NEGATIVE"), [v, y] = w("MDY"), [b, x] = w(""), [S, C] = w(null), T = async (e) => {
383
+ if (C(null), x(""), e) {
384
+ if (e.size > P) {
385
+ C(i("banking.import.tooLarge", "That file is larger than 2 MB. Export a shorter date range."));
386
+ return;
387
+ }
388
+ x(await e.text());
389
+ }
390
+ }, E = async (e) => {
391
+ if (e.preventDefault(), C(null), !b.trim()) {
392
+ C(i("banking.import.required", "Choose a CSV file or paste the statement."));
393
+ return;
394
+ }
395
+ try {
396
+ r(await a.mutateAsync({ input: {
397
+ connectionId: o || null,
398
+ institutionName: o ? null : c || null,
399
+ accountName: d || null,
400
+ accountMask: p || null,
401
+ currency: h || "USD",
402
+ csv: b,
403
+ amountConvention: g,
404
+ dateFormat: v
405
+ } }));
406
+ } catch (e) {
407
+ C(F(e));
408
+ }
409
+ };
410
+ return /* @__PURE__ */ D(l, {
411
+ title: i("banking.import.title", "Import a bank or card statement"),
412
+ description: i("banking.import.description", "Download your transactions as CSV from your bank or card website (two months or more works best)."),
413
+ onClose: n,
414
+ maxWidthClassName: "max-w-xl",
415
+ children: /* @__PURE__ */ O("form", {
416
+ onSubmit: (e) => void E(e),
417
+ className: "space-y-3",
418
+ "data-testid": "import-statement-form",
419
+ children: [
420
+ e.length > 0 && /* @__PURE__ */ O("label", {
421
+ className: "block text-sm text-text-primary",
422
+ children: [i("banking.import.target", "Add to"), /* @__PURE__ */ O("select", {
423
+ className: t(k, "mt-1"),
424
+ value: o,
425
+ onChange: (e) => s(e.target.value),
426
+ children: [/* @__PURE__ */ D("option", {
427
+ value: "",
428
+ children: i("banking.import.newConnection", "A new connection")
429
+ }), e.map((e) => /* @__PURE__ */ D("option", {
430
+ value: e.id,
431
+ children: e.institutionName
432
+ }, e.id))]
433
+ })]
434
+ }),
435
+ !o && /* @__PURE__ */ O("label", {
436
+ className: "block text-sm text-text-primary",
437
+ children: [i("banking.import.institution", "Bank or card issuer"), /* @__PURE__ */ D("input", {
438
+ className: t(k, "mt-1"),
439
+ value: c,
440
+ onChange: (e) => u(e.target.value),
441
+ placeholder: i("banking.import.institutionPlaceholder", "e.g. Chase"),
442
+ maxLength: 255
443
+ })]
444
+ }),
445
+ /* @__PURE__ */ O("div", {
446
+ className: "grid grid-cols-1 gap-3 sm:grid-cols-3",
447
+ children: [/* @__PURE__ */ O("label", {
448
+ className: "block text-sm text-text-primary sm:col-span-2",
449
+ children: [i("banking.import.account", "Account name"), /* @__PURE__ */ D("input", {
450
+ className: t(k, "mt-1"),
451
+ value: d,
452
+ onChange: (e) => f(e.target.value),
453
+ placeholder: i("banking.import.accountPlaceholder", "e.g. Sapphire card"),
454
+ maxLength: 255
455
+ })]
456
+ }), /* @__PURE__ */ O("label", {
457
+ className: "block text-sm text-text-primary",
458
+ children: [i("banking.import.mask", "Last 4 digits"), /* @__PURE__ */ D("input", {
459
+ className: t(k, "mt-1"),
460
+ value: p,
461
+ onChange: (e) => m(e.target.value.replace(/\D/g, "").slice(-4)),
462
+ inputMode: "numeric",
463
+ maxLength: 4
464
+ })]
465
+ })]
466
+ }),
467
+ /* @__PURE__ */ O("div", {
468
+ className: "grid grid-cols-1 gap-3 sm:grid-cols-3",
469
+ children: [
470
+ /* @__PURE__ */ O("label", {
471
+ className: "block text-sm text-text-primary",
472
+ children: [i("banking.import.currency", "Currency"), /* @__PURE__ */ D("input", {
473
+ className: t(k, "mt-1 uppercase"),
474
+ value: h,
475
+ onChange: (e) => te(e.target.value.toUpperCase().slice(0, 3)),
476
+ maxLength: 3
477
+ })]
478
+ }),
479
+ /* @__PURE__ */ O("label", {
480
+ className: "block text-sm text-text-primary",
481
+ children: [i("banking.import.convention", "Money out is"), /* @__PURE__ */ O("select", {
482
+ className: t(k, "mt-1"),
483
+ value: g,
484
+ onChange: (e) => _(e.target.value),
485
+ children: [/* @__PURE__ */ D("option", {
486
+ value: "OUTFLOW_NEGATIVE",
487
+ children: i("banking.import.negative", "Negative (bank)")
488
+ }), /* @__PURE__ */ D("option", {
489
+ value: "OUTFLOW_POSITIVE",
490
+ children: i("banking.import.positive", "Positive (card)")
491
+ })]
492
+ })]
493
+ }),
494
+ /* @__PURE__ */ O("label", {
495
+ className: "block text-sm text-text-primary",
496
+ children: [i("banking.import.dateFormat", "Date format"), /* @__PURE__ */ O("select", {
497
+ className: t(k, "mt-1"),
498
+ value: v,
499
+ onChange: (e) => y(e.target.value),
500
+ children: [
501
+ /* @__PURE__ */ D("option", {
502
+ value: "MDY",
503
+ children: "MM/DD/YYYY"
504
+ }),
505
+ /* @__PURE__ */ D("option", {
506
+ value: "DMY",
507
+ children: "DD/MM/YYYY"
508
+ }),
509
+ /* @__PURE__ */ D("option", {
510
+ value: "YMD",
511
+ children: "YYYY-MM-DD"
512
+ })
513
+ ]
514
+ })]
515
+ })
516
+ ]
517
+ }),
518
+ /* @__PURE__ */ O("label", {
519
+ className: "block text-sm text-text-primary",
520
+ children: [i("banking.import.file", "CSV file"), /* @__PURE__ */ D("input", {
521
+ type: "file",
522
+ accept: ".csv,text/csv,text/plain",
523
+ className: t(k, "mt-1"),
524
+ onChange: (e) => void T(e.target.files?.[0]),
525
+ "data-testid": "import-statement-file"
526
+ })]
527
+ }),
528
+ /* @__PURE__ */ O("label", {
529
+ className: "block text-sm text-text-primary",
530
+ children: [i("banking.import.paste", "Or paste the statement"), /* @__PURE__ */ D("textarea", {
531
+ className: t(k, "mt-1 h-32 font-mono text-xs"),
532
+ value: b,
533
+ onChange: (e) => x(e.target.value),
534
+ placeholder: "Date,Description,Amount\n10/05/2026,NETFLIX.COM,-15.49",
535
+ "data-testid": "import-statement-csv"
536
+ })]
537
+ }),
538
+ S && /* @__PURE__ */ D("p", {
539
+ role: "alert",
540
+ className: "text-sm text-status-error-text",
541
+ children: S
542
+ }),
543
+ /* @__PURE__ */ O("div", {
544
+ className: "flex justify-end gap-2 pt-1",
545
+ children: [/* @__PURE__ */ D("button", {
546
+ type: "button",
547
+ className: j,
548
+ onClick: n,
549
+ children: i("common.cancel", "Cancel")
550
+ }), /* @__PURE__ */ D("button", {
551
+ type: "submit",
552
+ className: A,
553
+ disabled: a.isPending,
554
+ children: a.isPending ? i("banking.import.submitting", "Importing…") : i("banking.import.submit", "Import and find subscriptions")
555
+ })]
556
+ })
557
+ ]
558
+ })
559
+ });
560
+ }
561
+ //#endregion
562
+ export { I as BankConnectionsPage };
563
+
564
+ //# sourceMappingURL=BankConnectionsPage.js.map