ownledger 2.0.0 → 2.1.1

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 (87) hide show
  1. package/AGENTS.md +45 -0
  2. package/CHANGELOG.md +30 -0
  3. package/README.md +13 -0
  4. package/assets/index.html +11 -11
  5. package/assets/static/{Account-DEBzshne.js → Account-CYrXDU9Z.js} +1 -1
  6. package/assets/static/{Accounts-C1iNsQsy.js → Accounts-BXleOwUO.js} +1 -1
  7. package/assets/static/{Attention-qo4v70P1.js → Attention-Ci3luOdE.js} +1 -1
  8. package/assets/static/{ByCategory-33P2zSs-.js → ByCategory-cLVOyjwd.js} +1 -1
  9. package/assets/static/CardDetail-BxXfAcMp.js +1 -0
  10. package/assets/static/{Cards-C3AdusmT.js → Cards-DNtITMnA.js} +1 -1
  11. package/assets/static/{Cards-DuqZFxkQ.js → Cards-DnIsAWPD.js} +1 -1
  12. package/assets/static/{CardsValue-BM9WUQmy.js → CardsValue-V1-fYMLf.js} +1 -1
  13. package/assets/static/{Cashback-DsWyjgRr.js → Cashback-B8lqwRnb.js} +1 -1
  14. package/assets/static/{CategoryIcon-E6EWIpbr.js → CategoryIcon-D4Cdb_ZP.js} +1 -1
  15. package/assets/static/{CategoryPicker-BPeJNSuM.js → CategoryPicker-54vkuxVh.js} +1 -1
  16. package/assets/static/{ChartWidget-Bk1TAvJM.js → ChartWidget-S5F4Ze91.js} +1 -1
  17. package/assets/static/{Combobox-lRNTmjKR.js → Combobox-BvX68J3o.js} +1 -1
  18. package/assets/static/{Deposits-CgEFypxb.js → Deposits-Ct5HhCEc.js} +1 -1
  19. package/assets/static/{DrillLink-pa6s17Xu.js → DrillLink-CZyI-y0-.js} +1 -1
  20. package/assets/static/{Field-OkPhoYM1.js → Field-DYmqEAlI.js} +1 -1
  21. package/assets/static/{HomeEditor-DdrzEPe2.js → HomeEditor-Dv-h_ql-.js} +1 -1
  22. package/assets/static/{Import-DrhHmL65.js → Import-B2uhVnEm.js} +1 -1
  23. package/assets/static/{IncomeSpending-Cveqr3xt.js → IncomeSpending-DNT2CWH9.js} +1 -1
  24. package/assets/static/{KV-CKGyL0p7.js → KV-CKWaJkRK.js} +1 -1
  25. package/assets/static/{Left-Bs_oKU19.js → Left-BefXZztB.js} +1 -1
  26. package/assets/static/{Money-DCMKf898.js → Money-BwLucm7P.js} +1 -1
  27. package/assets/static/{NetWorth-Cjd13J56.js → NetWorth-DeLSapZ2.js} +1 -1
  28. package/assets/static/{Pace-CBUDNxzH.js → Pace-D6gilOBZ.js} +1 -1
  29. package/assets/static/{Panel-CXjnsEN0.js → Panel-CSe25x0N.js} +1 -1
  30. package/assets/static/{PinDialog-DoGuAyi4.js → PinDialog-CHiLIKEs.js} +1 -1
  31. package/assets/static/{Plans-EWJdPCJ3.js → Plans-D7rJ1yHU.js} +1 -1
  32. package/assets/static/{Recent-BmJjA5dK.js → Recent-Dcqb2yko.js} +1 -1
  33. package/assets/static/{Reports-DSrLn_wC.js → Reports--PDAEnQM.js} +1 -1
  34. package/assets/static/{Settings-DdiEp2Qi.js → Settings-Bd0oglWl.js} +1 -1
  35. package/assets/static/{Transactions-Cy0kgcLE.js → Transactions-CQ1yQ1UU.js} +1 -1
  36. package/assets/static/{TxRow-IqjFXpya.js → TxRow-BGfpKo2m.js} +1 -1
  37. package/assets/static/{Unusual-D5-L9ZOy.js → Unusual-DGB4ZOA2.js} +1 -1
  38. package/assets/static/{Upcoming-CCqPol8c.js → Upcoming-B0HwBqmG.js} +1 -1
  39. package/assets/static/{WhichCard-Butdi7AN.js → WhichCard-BefFKS2q.js} +1 -1
  40. package/assets/static/{arrow-up-C8D_7x_H.js → arrow-up-CRgLRKET.js} +1 -1
  41. package/assets/static/{bits-BoWPOwTB.js → bits-D34d9IBm.js} +1 -1
  42. package/assets/static/{button-Cj0k8AtB.js → button-BKhMn8jX.js} +1 -1
  43. package/assets/static/{cards-AZlSJQ0z.js → cards-Ct0jh73r.js} +1 -1
  44. package/assets/static/{charts-Cj_hTR4h.js → charts-D-1glV8L.js} +1 -1
  45. package/assets/static/chevron-down-BWoQwA6m.js +1 -0
  46. package/assets/static/chevron-right-D7Sgw1v1.js +1 -0
  47. package/assets/static/{createLucideIcon-DUW9Fpzj.js → createLucideIcon-XZ28znwT.js} +1 -1
  48. package/assets/static/{dialog-BIbLA-XP.js → dialog-Bx-cd-2e.js} +1 -1
  49. package/assets/static/{dist-CbNfxqbd.js → dist--HKr0kfV.js} +1 -1
  50. package/assets/static/{dist-DYP_TYPy.js → dist-BFPyD74_.js} +1 -1
  51. package/assets/static/{dist-CetESl7K.js → dist-CmbuesVk.js} +1 -1
  52. package/assets/static/{dist-DaSyQKU7.js → dist-vgyaCpaL.js} +1 -1
  53. package/assets/static/{es2015-BgAh-EkH.js → es2015-DqY4UvQc.js} +1 -1
  54. package/assets/static/{index-DYyIpxqK.js → index-DBHFdsYB.js} +4 -4
  55. package/assets/static/index-iYMxgw-7.css +1 -0
  56. package/assets/static/{queries-C_4ufx4u.js → queries-BcMmmb36.js} +1 -1
  57. package/assets/static/{react-dom-CI34djkT.js → react-dom-5dgiSOdd.js} +1 -1
  58. package/assets/static/{select-2EwEpMf_.js → select-B5P2TaPX.js} +1 -1
  59. package/assets/static/{shared-CR-hvb-r.js → shared-BgU6fc7z.js} +1 -1
  60. package/assets/static/{triangle-exclamation-point-C6padEUM.js → triangle-exclamation-point-CMy18kC0.js} +1 -1
  61. package/assets/static/{useMutation-BWtHiYPX.js → useMutation-aC3Z1p9y.js} +1 -1
  62. package/dist/cli/check.js +7 -1
  63. package/dist/cli/dev.js +22 -2
  64. package/dist/cli/index.js +3 -0
  65. package/dist/cli/statements.d.ts +1 -0
  66. package/dist/cli/statements.js +231 -0
  67. package/dist/modules/api.d.ts +3 -0
  68. package/dist/modules/cards/api.d.ts +1 -1
  69. package/dist/modules/cards/api.js +34 -2
  70. package/dist/modules/cards/files.d.ts +11 -0
  71. package/dist/modules/cards/files.js +17 -0
  72. package/dist/node/statements.d.ts +64 -0
  73. package/dist/node/statements.js +218 -0
  74. package/dist/worker/api.js +14 -5
  75. package/dist/worker/github.d.ts +20 -1
  76. package/dist/worker/github.js +63 -5
  77. package/dist/worker/store.d.ts +2 -0
  78. package/dist/worker/store.js +8 -3
  79. package/dist/worker/version.d.ts +1 -1
  80. package/dist/worker/version.js +1 -1
  81. package/package.json +3 -1
  82. package/assets/static/CardDetail-CvRo7JPt.js +0 -1
  83. package/assets/static/chevron-down-BLodeu9a.js +0 -1
  84. package/assets/static/chevron-right-BetctQ6k.js +0 -1
  85. package/assets/static/index-CBsgYTMJ.css +0 -1
  86. package/dist/worker/tar.d.ts +0 -2
  87. package/dist/worker/tar.js +0 -62
package/AGENTS.md CHANGED
@@ -20,6 +20,9 @@ amounts, and never write without the owner's go. `npx ownledger check` must pass
20
20
  | `data/ledger/yyyy/mm.jsonl` | One transaction per line, in the month file of its date |
21
21
  | `imports/raw/` | Original exports, kept as received |
22
22
  | `imports/<source>.mapping.yaml` | How to read one app's export (see below) |
23
+ | `imports/statements/<account-id>/<YYYY-MM>.pdf` | Optional: the bank's statement PDFs, unlocked (see Bank statements) |
24
+ | `imports/statements/sources.yaml` | Optional: how to find each card's statements in email |
25
+ | `.env.statements` | The statement passwords, on the owner's computer only (git-ignored; never commit, never print) |
23
26
 
24
27
  ## Transactions
25
28
 
@@ -73,6 +76,48 @@ A 0% instalment is a plan `{kind: instalment, account: <card>, principal, count,
73
76
  `exclude: [ids]`, `default_account`). The pool is a view only: accounts stay separate in the data. With the pool on, spending with
74
77
  no account named goes to `default_account`. Change widgets through the connector's `add_widget` / `edit_widget` / `remove_widget`.
75
78
 
79
+ ## Bank statements
80
+
81
+ The bank's own statement PDFs can be kept in the repo, one per card per statement:
82
+ `imports/statements/<account-id>/<YYYY-MM>.pdf`. `YYYY-MM` is the month of the statement's **close date** (the
83
+ period's last day), not the month the bank sent it: a period 01–31/10 sent on 05/11 is `2026-10.pdf`. They are stored
84
+ **unlocked**. Only the owner's computer reads them (this CLI); the Worker only hands a filed PDF to the signed-in
85
+ dashboard ("Statement PDF" on a statement) and never reads it. Optional: a repo without statements works the same.
86
+
87
+ `imports/statements/sources.yaml`, per account id: `from` (the bank's sender address), `subject` (words in the subject),
88
+ `password` (the name of the variable in `.env.statements`, e.g. `PW_WOORI`), `password_hint` (what the password is made
89
+ of, e.g. "date of birth ddmmyy"; never the password itself). The bank's own email facts, nothing else.
90
+
91
+ Passwords live in `.env.statements` at the repo root (`PW_<ACCOUNT_ID>=…` or `PW_<BANK>=…`, the first word of the id;
92
+ or the variable `sources.yaml` names). It is git-ignored. Never commit it, print it, or send it anywhere.
93
+
94
+ ### Collect statements from Gmail
95
+
96
+ Needs an agent that can save files on the owner's computer (Claude Code, Codex…) with a Gmail connector. ownledger
97
+ itself never connects to email.
98
+
99
+ 1. For each card (or the one asked for): search Gmail with `sources.yaml`'s `from`/`subject` if it has the card;
100
+ otherwise find the bank's statement emails and propose a `sources.yaml` entry for the owner's go.
101
+ 2. Download the PDF attachments to a temporary folder **outside** the repo.
102
+ 3. If the password variable is missing from `.env.statements`, ask the owner for the password once and write it
103
+ there (never echo it, never commit it).
104
+ 4. `npx ownledger statements add <account-id> <files…>`: it unlocks each file, reads its statement period from the
105
+ text (or refuses and asks for `--month YYYY-MM`) and shows card, month and period. Already-filed statements are
106
+ skipped; a different file for a month already filed is refused. Show the owner the list, get their go, then run it
107
+ again with `--yes` (files and commits).
108
+ 5. `npx ownledger statements list` shows which months are missing between the first and the last; report them.
109
+
110
+ ### Check a statement against the ledger
111
+
112
+ `npx ownledger statements check <account-id> <YYYY-MM>` (`--json` for structured output) prints the period,
113
+ ownledger's figures for it, its transactions on the card, and the statement's text. Compare them and tell the owner
114
+ what's missing, extra or different (amounts, dates, fees, cashback, the closing balance). Never change anything from
115
+ the PDF on your own: each fix is a normal write (preview → go). The bank's statement amount goes in with
116
+ `add_statement_amount`.
117
+
118
+ `npx ownledger check` warns about statement files that don't fit (a folder that isn't an account, a name that isn't
119
+ `YYYY-MM.pdf`, a PDF still locked).
120
+
76
121
  ## Rules for writes
77
122
 
78
123
  1. Show the owner exactly what will change (the transactions, with amounts and accounts) and wait for their go.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,35 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.1.1 (2026-11-23)
4
+
5
+ - **Fix: the dashboard failed to load ("Could not load data:" with no reason) once statement PDFs were filed.** The
6
+ Worker read each new commit from the repo's whole tarball, PDFs included, and ran past Cloudflare's CPU limit. It now
7
+ lists the repo's files (one call) and reads only `data/` and `imports/*.mapping.yaml` (one GraphQL call per 100
8
+ files); statement PDFs and raw exports are never downloaded. Same GitHub App permissions.
9
+ - **Clear errors:** when the data repo can't be loaded, `/api/*` answers JSON with the reason (502) instead of a bare
10
+ 500, and the dashboard shows the HTTP status when an answer isn't JSON (e.g. Cloudflare's own 503 page).
11
+
12
+ ## 2.1.0 (2026-11-23)
13
+
14
+ Bank statements, optional. Data format stays 1: a repo without statements works as it does now.
15
+
16
+ - **Convention:** the bank's statement PDFs, unlocked, at `imports/statements/<account-id>/<YYYY-MM>.pdf` (`YYYY-MM` =
17
+ the month of the statement's close date); optional `imports/statements/sources.yaml` (how to find each card's
18
+ statements in email: sender, subject, the name of the password variable and what the password is made of). Passwords
19
+ stay in `.env.statements` on your computer (git-ignored).
20
+ - **CLI:** `ownledger statements add <card> <file.pdf>…` unlocks (qpdf compiled to WebAssembly, nothing to install),
21
+ reads the statement period from the PDF's text (or asks for `--month`), skips what's already filed, refuses a
22
+ different file for a filed month, and commits once per run (preview; `--yes`). `ownledger statements list` shows the
23
+ months each card has and the ones missing. `ownledger statements check <card> <YYYY-MM>` prints the statement's text
24
+ next to ownledger's figures and transactions for that period, for your agent to compare. `ownledger check` warns on
25
+ statement files that don't fit (unknown account folder, bad name, still locked).
26
+ - **Dashboard:** a filed statement shows a "Statement PDF" link (`GET /api/m/cards/statement-pdf?account=&close=`,
27
+ same sign-in, built from the ledger's own card and close date). Card statements in `/api/m/cards/<id>` and
28
+ `…/statement` carry `pdf: true` when the file exists.
29
+ - **Statements are read on your computer only.** The Worker lists the PDFs' paths (their bytes are skipped in the
30
+ tarball) and streams one to your signed-in dashboard; it never parses them. No connector tool reads statements.
31
+ - **AGENTS.md:** "Bank statements": collect from Gmail with your own agent, file, check against the ledger.
32
+
3
33
  ## 2.0.0 (2026-11-22)
4
34
 
5
35
  A new dashboard, modules, and credit cards done properly. Data format stays 1: existing data repos work as they are.
package/README.md CHANGED
@@ -58,6 +58,7 @@ Tools: `about`, `rules`, `accounts`, `transactions`, `report`, `net_worth`, `car
58
58
  | Your AI client | your Worker's `/mcp` with a token your Worker issued (1 h, refreshable 30 days, revocable in the dashboard) | your GitHub credentials |
59
59
  | GitHub sign-in | proves who you are; your Worker reads your login, then revokes that GitHub token at once | kept anywhere |
60
60
  | The CLI | GitHub (`gh`), Cloudflare (`wrangler`), npm | sending your data anywhere |
61
+ | Bank statement PDFs (optional) | read only by the CLI on your computer; your Worker only streams a filed PDF to your signed-in dashboard | parsed by the Worker; their passwords leave your computer |
61
62
 
62
63
  Only the GitHub logins in `ALLOWED_LOGINS` (yours, set by `deploy`) can sign in. Writes are refused unless the whole ledger still passes `ownledger check`; your repo's CI runs the same check on every push.
63
64
 
@@ -72,6 +73,7 @@ data/plans.yaml instalments, loans, premiums
72
73
  data/prices.csv date,asset,price
73
74
  data/ledger/yyyy/mm.jsonl one transaction per line; lines sum to 0
74
75
  imports/ raw exports + one mapping per source app
76
+ imports/statements/ optional: your banks' statement PDFs, unlocked, <card>/<YYYY-MM>.pdf
75
77
  AGENTS.md the rules any AI follows in this repo
76
78
  ```
77
79
 
@@ -98,8 +100,19 @@ ownledger check [dir] check the data (CI runs it)
98
100
  ownledger import <file> import an export (--profile, --preset misa, --yes)
99
101
  ownledger deploy deploy or update your Worker (--openwallet / --no-openwallet)
100
102
  ownledger dev [dir] run your Worker locally against the local folder (sign-in skipped; --openwallet[=<url>])
103
+ ownledger statements add <card> <file.pdf>… unlock and file bank statement PDFs (preview; --yes files and commits)
104
+ ownledger statements list [<card>] which months each card has, and which are missing
105
+ ownledger statements check <card> <YYYY-MM> the statement's text next to the ledger's figures for that period
101
106
  ```
102
107
 
108
+ ### Bank statements (optional)
109
+
110
+ Keep your cards' statement PDFs in your data repo and open them from the dashboard. Collecting them from Gmail is done by
111
+ your own AI agent on your computer (Claude Code or similar, with a Gmail connector), following
112
+ [AGENTS.md](AGENTS.md#collect-statements-from-gmail); ownledger never connects to your email. `ownledger statements add`
113
+ removes the bank's password (kept in `.env.statements`, git-ignored, on your computer only) and files each PDF under the
114
+ month of its statement's close date. `ownledger statements check` lets your agent compare a statement with your ledger.
115
+
103
116
  ## Development
104
117
 
105
118
  ```sh
package/assets/index.html CHANGED
@@ -9,17 +9,17 @@
9
9
  <link rel="icon" href="/icon.svg" type="image/svg+xml">
10
10
  <link rel="apple-touch-icon" href="/apple-touch-icon.png">
11
11
  <meta name="apple-mobile-web-app-title" content="ownledger">
12
- <script type="module" crossorigin src="/static/index-DYyIpxqK.js"></script>
13
- <link rel="modulepreload" crossorigin href="/static/queries-C_4ufx4u.js">
14
- <link rel="modulepreload" crossorigin href="/static/react-dom-CI34djkT.js">
15
- <link rel="modulepreload" crossorigin href="/static/button-Cj0k8AtB.js">
16
- <link rel="modulepreload" crossorigin href="/static/dist-CetESl7K.js">
17
- <link rel="modulepreload" crossorigin href="/static/es2015-BgAh-EkH.js">
18
- <link rel="modulepreload" crossorigin href="/static/dist-DYP_TYPy.js">
19
- <link rel="modulepreload" crossorigin href="/static/createLucideIcon-DUW9Fpzj.js">
20
- <link rel="modulepreload" crossorigin href="/static/dist-DaSyQKU7.js">
21
- <link rel="modulepreload" crossorigin href="/static/dist-CbNfxqbd.js">
22
- <link rel="stylesheet" crossorigin href="/static/index-CBsgYTMJ.css">
12
+ <script type="module" crossorigin src="/static/index-DBHFdsYB.js"></script>
13
+ <link rel="modulepreload" crossorigin href="/static/queries-BcMmmb36.js">
14
+ <link rel="modulepreload" crossorigin href="/static/react-dom-5dgiSOdd.js">
15
+ <link rel="modulepreload" crossorigin href="/static/button-BKhMn8jX.js">
16
+ <link rel="modulepreload" crossorigin href="/static/dist-CmbuesVk.js">
17
+ <link rel="modulepreload" crossorigin href="/static/es2015-DqY4UvQc.js">
18
+ <link rel="modulepreload" crossorigin href="/static/dist-BFPyD74_.js">
19
+ <link rel="modulepreload" crossorigin href="/static/createLucideIcon-XZ28znwT.js">
20
+ <link rel="modulepreload" crossorigin href="/static/dist-vgyaCpaL.js">
21
+ <link rel="modulepreload" crossorigin href="/static/dist--HKr0kfV.js">
22
+ <link rel="stylesheet" crossorigin href="/static/index-iYMxgw-7.css">
23
23
  </head>
24
24
  <body>
25
25
  <div id="root"></div>
@@ -1 +1 @@
1
- import{B as e,I as t,L as n,d as r,m as i,u as a,w as o}from"./queries-C_4ufx4u.js";import{a as s,i as c,t as l}from"./charts-Cj_hTR4h.js";import{t as u}from"./DrillLink-pa6s17Xu.js";import{t as d}from"./Money-DCMKf898.js";import{M as f,a as p,l as m}from"./index-DYyIpxqK.js";var h=e(t(),1),g=n();function _({widget:e,menu:t}){let{t:n,lang:_}=o(),v=r().data,y=e.account,b=a().data,x=y===`pool`?b?.pool?.name||n(`pool.name`):v?.accounts.find(e=>e.id===y)?.name,S=e.title?.trim()||x||n(`widget.account`),{data:C,error:w,isLoading:T}=i({metric:`balance`,account:y??``,by:`month`,period:`last-12-months`},!!y),E=(0,h.useMemo)(()=>(C?.points??[]).map(e=>({ym:e.key,v:e.value})),[C]),D=E[E.length-1];return(0,g.jsx)(f,{title:S,titleHref:y?`#/transactions?account=${encodeURIComponent(y)}`:void 0,menu:t,loading:!!y&&T,error:y?w?.message:void 0,empty:y?C&&E.length===0?n(`account.empty`):void 0:n(`account.pick`),children:D&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(u,{filter:{account:y},className:`text-2xl font-semibold tracking-tight`,children:(0,g.jsx)(d,{amount:D.v})}),(0,g.jsx)(l,{table:{head:[n(`chart.month`),n(`account.balance`)],rows:E.map(e=>[p(e.ym),m(e.v,_)])},children:(0,g.jsx)(c,{data:E,xKey:`ym`,formatX:e=>p(String(e)),specs:[{key:`v`,label:n(`account.balance`),kind:`line`,color:s.accent}]})})]})})}export{_ as default};
1
+ import{B as e,I as t,L as n,d as r,m as i,u as a,w as o}from"./queries-BcMmmb36.js";import{a as s,i as c,t as l}from"./charts-D-1glV8L.js";import{t as u}from"./DrillLink-CZyI-y0-.js";import{t as d}from"./Money-BwLucm7P.js";import{M as f,a as p,l as m}from"./index-DBHFdsYB.js";var h=e(t(),1),g=n();function _({widget:e,menu:t}){let{t:n,lang:_}=o(),v=r().data,y=e.account,b=a().data,x=y===`pool`?b?.pool?.name||n(`pool.name`):v?.accounts.find(e=>e.id===y)?.name,S=e.title?.trim()||x||n(`widget.account`),{data:C,error:w,isLoading:T}=i({metric:`balance`,account:y??``,by:`month`,period:`last-12-months`},!!y),E=(0,h.useMemo)(()=>(C?.points??[]).map(e=>({ym:e.key,v:e.value})),[C]),D=E[E.length-1];return(0,g.jsx)(f,{title:S,titleHref:y?`#/transactions?account=${encodeURIComponent(y)}`:void 0,menu:t,loading:!!y&&T,error:y?w?.message:void 0,empty:y?C&&E.length===0?n(`account.empty`):void 0:n(`account.pick`),children:D&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(u,{filter:{account:y},className:`text-2xl font-semibold tracking-tight`,children:(0,g.jsx)(d,{amount:D.v})}),(0,g.jsx)(l,{table:{head:[n(`chart.month`),n(`account.balance`)],rows:E.map(e=>[p(e.ym),m(e.v,_)])},children:(0,g.jsx)(c,{data:E,xKey:`ym`,formatX:e=>p(String(e)),specs:[{key:`v`,label:n(`account.balance`),kind:`line`,color:s.accent}]})})]})})}export{_ as default};
@@ -1 +1 @@
1
- import{t as e}from"./chevron-down-BLodeu9a.js";import{t}from"./chevron-right-BetctQ6k.js";import{B as n,I as r,L as i,T as a,a as o,d as s,o as c,t as l,u,w as d}from"./queries-C_4ufx4u.js";import{A as f,W as p,l as m,n as h,r as g,s as _,u as v}from"./index-DYyIpxqK.js";import{t as y}from"./Money-DCMKf898.js";import{o as b,r as x}from"./bits-BoWPOwTB.js";import{a as S,i as C,n as w,o as T,r as E,s as D}from"./dist-CetESl7K.js";import{n as O,s as k}from"./button-Cj0k8AtB.js";import{t as A}from"./dist-DYP_TYPy.js";import{n as j,r as M,t as N}from"./dist-CbNfxqbd.js";import{t as P}from"./dist-DaSyQKU7.js";import{t as F}from"./cards-AZlSJQ0z.js";import{t as ee}from"./drill-t1zr57xi.js";var I=n(r(),1),L=i(),R=Object.defineProperty,z=(e,t)=>R(e,`name`,{value:t,configurable:!0}),B=`Collapsible`,[te,ne]=T(B),[re,V]=te(B),ie=I.forwardRef(z(function(e,t){let{__scopeCollapsible:n,open:r,defaultOpen:i,disabled:a,onOpenChange:o,...s}=e,[c,l]=E({prop:r,defaultProp:i??!1,onChange:o,caller:B});return(0,L.jsx)(re,{scope:n,disabled:a,contentId:w(),open:c,onOpenToggle:I.useCallback(()=>l(e=>!e),[l]),children:(0,L.jsx)(D.div,{"data-state":U(c),"data-disabled":a?``:void 0,...s,ref:t})})},`Collapsible`)),ae=`CollapsibleTrigger`,oe=I.forwardRef(z(function(e,t){let{__scopeCollapsible:n,...r}=e,i=V(ae,n);return(0,L.jsx)(D.button,{type:`button`,"aria-controls":i.open?i.contentId:void 0,"aria-expanded":i.open||!1,"data-state":U(i.open),"data-disabled":i.disabled?``:void 0,disabled:i.disabled,...r,ref:t,onClick:C(e.onClick,i.onOpenToggle)})},`CollapsibleTrigger`)),H=`CollapsibleContent`,se=I.forwardRef(z(function(e,t){let{forceMount:n,...r}=e,i=V(H,e.__scopeCollapsible);return(0,L.jsx)(A,{present:n||i.open,children:({present:e})=>(0,L.jsx)(ce,{...r,ref:t,present:e})})},`CollapsibleContent`)),ce=I.forwardRef(z(function(e,t){let{__scopeCollapsible:n,present:r,children:i,...a}=e,o=V(H,n),[s,c]=I.useState(r),l=I.useRef(null),u=k(t,l),d=I.useRef(0),f=d.current,p=I.useRef(0),m=p.current,h=o.open||s,g=I.useRef(h),_=I.useRef(void 0);return I.useEffect(()=>{let e=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(e)},[]),S(()=>{let e=l.current;if(e){_.current=_.current||{transitionDuration:e.style.transitionDuration,animationName:e.style.animationName},e.style.transitionDuration=`0s`,e.style.animationName=`none`;let t=e.getBoundingClientRect();d.current=t.height,p.current=t.width,g.current||(e.style.transitionDuration=_.current.transitionDuration,e.style.animationName=_.current.animationName),c(r)}},[o.open,r]),(0,L.jsx)(D.div,{"data-state":U(o.open),"data-disabled":o.disabled?``:void 0,id:o.contentId,hidden:!h,...a,ref:u,style:{"--radix-collapsible-content-height":f?`${f}px`:void 0,"--radix-collapsible-content-width":m?`${m}px`:void 0,...e.style},children:h&&i})},`CollapsibleContentImpl`));function U(e){return e?`open`:`closed`}z(U,`getState`);var le=Object.defineProperty,W=(e,t)=>le(e,`name`,{value:t,configurable:!0}),G={Automatic:`automatic`,Manual:`manual`},K=`Tabs`,[ue,de]=T(K,[M]),fe=M(),[pe,q]=ue(K),me=I.forwardRef(W(function(e,t){let{__scopeTabs:n,value:r,onValueChange:i,defaultValue:a,orientation:o=`horizontal`,dir:s,activationMode:c=G.Automatic,...l}=e,u=P(s),[d,f]=E({prop:r,onChange:i,defaultProp:a??``,caller:K});return(0,L.jsx)(pe,{scope:n,baseId:w(),value:d,onValueChange:f,orientation:o,dir:u,activationMode:c,children:(0,L.jsx)(D.div,{dir:u,"data-orientation":o,...l,ref:t})})},`Tabs`)),he=`TabsList`,ge=I.forwardRef(W(function(e,t){let{__scopeTabs:n,loop:r=!0,...i}=e,a=q(he,n),o=fe(n);return(0,L.jsx)(N,{asChild:!0,...o,orientation:a.orientation,dir:a.dir,loop:r,children:(0,L.jsx)(D.div,{role:`tablist`,"aria-orientation":a.orientation,...i,ref:t})})},`TabsList`)),_e=`TabsTrigger`,ve=I.forwardRef(W(function(e,t){let{__scopeTabs:n,value:r,disabled:i=!1,...a}=e,o=q(_e,n),s=fe(n),c=J(o.baseId,r),l=Y(o.baseId,r),u=r===o.value;return(0,L.jsx)(j,{asChild:!0,...s,focusable:!i,active:u,children:(0,L.jsx)(D.button,{type:`button`,role:`tab`,"aria-selected":u,"aria-controls":l,"data-state":u?`active`:`inactive`,"data-disabled":i?``:void 0,disabled:i,id:c,...a,ref:t,onMouseDown:C(e.onMouseDown,e=>{!i&&e.button===0&&e.ctrlKey===!1?(e.currentTarget.focus(),o.onValueChange(r)):e.preventDefault()}),onKeyDown:C(e.onKeyDown,e=>{i||e.target!==e.currentTarget||[` `,`Enter`].includes(e.key)&&o.onValueChange(r)}),onFocus:C(e.onFocus,()=>{let e=o.activationMode!==G.Manual;!u&&!i&&e&&o.onValueChange(r)})})})},`TabsTrigger`)),ye=`TabsContent`,be=I.forwardRef(W(function(e,t){let{__scopeTabs:n,value:r,forceMount:i,children:a,...o}=e,s=q(ye,n),c=J(s.baseId,r),l=Y(s.baseId,r),u=r===s.value,d=I.useRef(u);return I.useEffect(()=>{let e=requestAnimationFrame(()=>d.current=!1);return()=>cancelAnimationFrame(e)},[]),(0,L.jsx)(A,{present:i||u,children:({present:n})=>(0,L.jsx)(D.div,{"data-state":u?`active`:`inactive`,"data-orientation":s.orientation,role:`tabpanel`,"aria-labelledby":c,hidden:!n,id:l,tabIndex:0,...o,ref:t,style:{...e.style,animationDuration:d.current?`0s`:void 0},children:n&&a})})},`TabsContent`));function J(e,t){return`${e}-trigger-${t}`}W(J,`makeTriggerId`);function Y(e,t){return`${e}-content-${t}`}W(Y,`makeContentId`);function xe({...e}){return(0,L.jsx)(ie,{"data-slot":`collapsible`,...e})}function Se({...e}){return(0,L.jsx)(oe,{"data-slot":`collapsible-trigger`,...e})}function Ce({...e}){return(0,L.jsx)(se,{"data-slot":`collapsible-content`,...e})}function we({className:e,orientation:t=`horizontal`,...n}){return(0,L.jsx)(me,{"data-slot":`tabs`,"data-orientation":t,className:a(`group/tabs flex gap-2 data-horizontal:flex-col`,e),...n})}var Te=O(`group/tabs-list inline-flex w-fit items-center justify-center rounded-lg p-[3px] text-muted-foreground group-data-horizontal/tabs:h-8 group-data-vertical/tabs:h-fit group-data-vertical/tabs:flex-col data-[variant=line]:rounded-none`,{variants:{variant:{default:`bg-muted`,line:`gap-1 bg-transparent`}},defaultVariants:{variant:`default`}});function Ee({className:e,variant:t=`default`,...n}){return(0,L.jsx)(ge,{"data-slot":`tabs-list`,"data-variant":t,className:a(Te({variant:t}),e),...n})}function X({className:e,...t}){return(0,L.jsx)(ve,{"data-slot":`tabs-trigger`,className:a(`relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-1.5 py-0.5 text-sm font-medium whitespace-nowrap text-foreground/60 transition-all group-data-vertical/tabs:w-full group-data-vertical/tabs:justify-start hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 has-data-[icon=inline-end]:pr-1 has-data-[icon=inline-start]:pl-1 dark:text-muted-foreground dark:hover:text-foreground group-data-[variant=default]/tabs-list:data-active:shadow-sm group-data-[variant=line]/tabs-list:data-active:shadow-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,`group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-active:bg-transparent dark:group-data-[variant=line]/tabs-list:data-active:border-transparent dark:group-data-[variant=line]/tabs-list:data-active:bg-transparent`,`data-active:bg-background data-active:text-foreground dark:data-active:border-input dark:data-active:bg-input/30 dark:data-active:text-foreground`,`after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-horizontal/tabs:after:inset-x-0 group-data-horizontal/tabs:after:bottom-[-5px] group-data-horizontal/tabs:after:h-0.5 group-data-vertical/tabs:after:inset-y-0 group-data-vertical/tabs:after:-right-1 group-data-vertical/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-active:after:opacity-100`,e),...t})}function Z({className:e,...t}){return(0,L.jsx)(be,{"data-slot":`tabs-content`,className:a(`flex-1 text-sm outline-none`,e),...t})}var De=90,Oe=[`var(--chart-1)`,`var(--chart-2)`,`var(--chart-3)`,`var(--chart-4)`,`var(--chart-5)`],Q=e=>Math.abs(e.value);function ke({children:e,tone:t}){return(0,L.jsx)(`span`,{className:a(`shrink-0 rounded-full px-2 py-0.5 text-[11px] font-medium`,t===`warn`?`bg-warning/10 text-warning`:`bg-secondary text-secondary-foreground`),children:e})}function Ae({a:e,holdings:t,card:n,deposit:r,nested:i}){let{t:o,lang:s}=d();return(0,L.jsxs)(`li`,{className:a(`relative flex flex-col gap-1 rounded-md py-1.5 hover:bg-muted/40 focus-within:ring-3 focus-within:ring-ring/50`,i?`pl-4`:`px-2`),children:[(0,L.jsxs)(`div`,{className:`flex min-h-11 items-center justify-between gap-3`,children:[(0,L.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,L.jsx)(`a`,{href:ee({account:e.id}),className:`truncate rounded-md text-sm font-medium outline-none after:absolute after:inset-0 focus-visible:underline`,children:e.name}),e.closed&&(0,L.jsx)(ke,{children:o(`accounts.closedOn`,{date:_(e.closed,s)})}),t&&!e.priced&&(0,L.jsx)(ke,{tone:`warn`,children:o(`accounts.noPrice`)})]}),(0,L.jsx)(y,{amount:e.value,mode:`short`,className:`shrink-0 text-sm font-medium`})]}),t&&(0,L.jsxs)(`p`,{className:`text-xs text-muted-foreground tabular-nums`,children:[e.qty!==null&&(0,L.jsx)(L.Fragment,{children:o(`accounts.qty`,{n:m(e.qty,s,4)})}),e.price&&(0,L.jsxs)(L.Fragment,{children:[` · `,o(`accounts.price`,{price:v(e.price.price,s),date:h(e.price.date)})]}),` · `,o(`accounts.cost`),` `,(0,L.jsx)(y,{amount:e.cost,mode:`short`})]}),n&&(0,L.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,L.jsx)(b,{owed:n.owed,limit:n.limit,atLeast:n.limitAtLeast}),(0,L.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-3 text-xs text-muted-foreground`,children:[n.toPay>0?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`span`,{children:[o(`cards.toPay`),` `,(0,L.jsx)(y,{amount:n.toPay,mode:`short`,className:`font-medium text-foreground`})]}),n.due&&(0,L.jsx)(`span`,{children:h(n.due)}),(0,L.jsx)(x,{days:n.daysToDue})]}):(0,L.jsx)(`span`,{children:o(`cards.nothingToPay`)}),(0,L.jsx)(`a`,{href:F(n.account),className:`relative z-10 ml-auto inline-flex min-h-11 items-center rounded-md px-1 underline outline-none focus-visible:ring-3 focus-visible:ring-ring/50`,children:o(`accounts.cardPage`)})]})]}),r&&(0,L.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[r.maturity?`${r.daysToMaturity<0?o(`deposits.matured`):o(`deposits.inDays`,{n:r.daysToMaturity})} · ${h(r.maturity)}`:o(`deposits.noMaturity`),r.rate!==null&&` · ${m(r.rate,s,2)}%`,r.interestAtMaturity?(0,L.jsxs)(L.Fragment,{children:[` · `,o(`deposits.interest`),` `,(0,L.jsx)(y,{amount:r.interestAtMaturity,mode:`short`})]}):null]})]})}function je({open:n,onToggle:r,label:i,count:o,children:s,nested:c}){return(0,L.jsxs)(`div`,{className:a(`flex flex-col`,c&&`pl-4`),children:[(0,L.jsxs)(`button`,{type:`button`,"aria-expanded":n,onClick:r,className:`flex min-h-11 items-center gap-1 rounded-md px-2 text-left text-sm text-muted-foreground outline-none hover:bg-muted/40 focus-visible:ring-3 focus-visible:ring-ring/50`,children:[n?(0,L.jsx)(e,{className:`size-4`,"aria-hidden":!0}):(0,L.jsx)(t,{className:`size-4`,"aria-hidden":!0}),i,` (`,o,`)`]}),n&&s]})}function Me(){let{t:n,lang:r}=d(),i=u().data,a=s().data,{data:h,error:_,isLoading:v}=l(),b=!!i?.features?.cards,x=o(b).data,S=c(!!i?.features?.deposits).data,C=i?.today??new Date().toISOString().slice(0,10),w=i?.pool,T=w?.name??n(`pool.name`),[E,D]=(0,I.useState)(!1),O=e=>a?.types[e]?.[r]??e,k=e=>!!a?.types[e]?.holdings,A=(0,I.useMemo)(()=>new Map((x?.cards??[]).map(e=>[e.account,e])),[x]),j=(0,I.useMemo)(()=>new Map((S??[]).map(e=>[e.account,e])),[S]),M=(0,I.useMemo)(()=>{let e=h??[],t=e=>!!a?.types[e.type]?.liability,n=e=>(t(e)||e.value<0)&&e.value<0,r=0,i=0,o=0;for(let t of e)(t.value!==0||t.qty)&&(n(t)?i+=t.value:r+=t.value,t.priced||o++);let s=e=>e.value===0&&!e.qty&&(e.lastActivity===null||g(e.lastActivity,C)>De),c=e.filter(e=>e.closed),l=e.filter(e=>!e.closed),u=w?.on?l.filter(e=>e.pool):[],d=l.filter(e=>!u.includes(e)),f=d.filter(s),p=d.filter(e=>!s(e)),m=p.filter(e=>t(e)||e.value<0),_=e=>A.get(e.id)?.daysToDue??1/0;m.sort((e,t)=>_(e)-_(t)||e.value-t.value);let v=new Map;for(let e of p.filter(e=>!m.includes(e))){let t=v.get(e.type)??{id:e.type,label:O(e.type),value:0,items:[]};t.items.push(e),t.value+=e.value,v.set(e.type,t)}let y=[...v.values()];for(let e of y)e.items.sort((e,t)=>Q(t)-Q(e));let b=u.filter(e=>!s(e)).sort((e,t)=>Q(t)-Q(e)),x=u.filter(s);u.length&&y.push({id:`pool`,label:T,value:u.reduce((e,t)=>e+t.value,0),items:b,pool:!0}),y.sort((e,t)=>t.value-e.value),y.forEach((e,t)=>e.color=e.value>0&&t<Oe.length?Oe[t]:`var(--chart-muted)`);let S=y.reduce((e,t)=>e+(t.pool?u.length:t.items.length),0);return{assets:r,liabilities:i,net:r+i,groups:y,debt:m,poolIdle:x,poolCount:u.length,assetCount:S,inactiveRest:f.sort((e,t)=>e.name.localeCompare(t.name)),closed:c.sort((e,t)=>(t.closed??``).localeCompare(e.closed??``)),unpriced:o,any:e.length>0}},[h,a,w?.on,T,C,r,A]);if(_)return(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n(`common.error`,{message:_.message})});if(v||!h||!a)return(0,L.jsxs)(`div`,{className:`flex flex-col gap-4`,"aria-busy":`true`,children:[(0,L.jsx)(p,{className:`h-8 w-48`}),(0,L.jsx)(p,{className:`h-24 w-full`}),(0,L.jsx)(p,{className:`h-48 w-full`})]});if(!M.any)return(0,L.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,L.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:n(`accounts.title`)}),(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n(`accounts.empty`)}),(0,L.jsx)(f,{className:`self-start`,prompt:n(`start.s2.prompt`)})]});let N=(e,t)=>(0,L.jsx)(Ae,{a:e,nested:t,holdings:k(e.type),card:A.get(e.id),deposit:j.get(e.id)},e.id),P=M.groups.filter(e=>e.value>0),F=P.reduce((e,t)=>e+t.value,0),R=e=>F>0&&e>0?`${m(e/F*100,r)}%`:``,z=M.inactiveRest.length+M.closed.length;return(0,L.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,L.jsxs)(`header`,{className:`flex flex-col gap-1`,children:[(0,L.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:n(`accounts.title`)}),(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n(`accounts.netWorth`)}),(0,L.jsx)(y,{amount:M.net,className:`text-3xl font-semibold tracking-tight md:text-4xl`}),(0,L.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[n(`accounts.assets`),` `,(0,L.jsx)(y,{amount:M.assets,mode:`short`,className:`font-medium text-foreground`}),` · `,n(`accounts.liabilities`),` `,(0,L.jsx)(y,{amount:M.liabilities,mode:`short`,className:`font-medium text-foreground`})]}),M.unpriced>0&&(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`nw.unpriced`,{n:M.unpriced})})]}),P.length>0&&(0,L.jsx)(`div`,{className:`flex h-2.5 w-full gap-0.5 overflow-hidden rounded-full`,role:`img`,"aria-label":`${n(`accounts.byType`)}: ${P.map(e=>`${e.label} ${R(e.value)}`).join(`, `)}`,children:P.map(e=>(0,L.jsx)(`span`,{className:`h-full first:rounded-l-full last:rounded-r-full`,style:{width:`${e.value/F*100}%`,background:e.color},title:`${e.label} ${R(e.value)}`},e.id))}),(0,L.jsxs)(we,{defaultValue:`assets`,className:`gap-4`,children:[(0,L.jsxs)(Ee,{className:`h-10! w-full sm:w-fit`,children:[(0,L.jsxs)(X,{value:`assets`,className:`px-3`,children:[n(`accounts.assets`),(0,L.jsx)($,{n:M.assetCount})]}),M.debt.length>0&&(0,L.jsxs)(X,{value:`debt`,className:`px-3`,children:[n(`accounts.liabilities`),(0,L.jsx)($,{n:M.debt.length})]}),z>0&&(0,L.jsxs)(X,{value:`idle`,className:`px-3`,children:[n(`accounts.tabIdle`),(0,L.jsx)($,{n:z})]})]}),(0,L.jsx)(Z,{value:`assets`,children:(0,L.jsx)(`div`,{className:`grid items-start gap-3 md:grid-cols-2`,children:M.groups.map(r=>(0,L.jsxs)(xe,{className:`group/acc overflow-hidden rounded-xl bg-card ring-1 ring-foreground/[0.07] shadow-[0_1px_2px_oklch(0_0_0/0.04)]`,children:[(0,L.jsxs)(Se,{className:`flex min-h-14 w-full items-center gap-3 px-4 text-left outline-none hover:bg-muted/40 focus-visible:ring-3 focus-visible:ring-ring/50 focus-visible:ring-inset`,children:[(0,L.jsx)(`span`,{"aria-hidden":!0,className:`size-2.5 shrink-0 rounded-full`,style:{background:r.color}}),(0,L.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium`,children:[r.label,(0,L.jsx)(`span`,{className:`ml-1.5 font-normal text-muted-foreground tabular-nums`,children:r.pool?M.poolCount:r.items.length})]}),(0,L.jsx)(y,{amount:r.value,mode:`short`,className:`shrink-0 text-sm font-semibold`}),(0,L.jsx)(`span`,{className:`w-9 shrink-0 text-right text-xs text-muted-foreground tabular-nums`,children:R(r.value)}),(0,L.jsx)(e,{className:`size-4 shrink-0 text-muted-foreground transition-transform group-data-[state=open]/acc:rotate-180 motion-reduce:transition-none`,"aria-hidden":!0})]}),(0,L.jsxs)(Ce,{className:`border-t px-2 py-1`,children:[r.pool&&(0,L.jsxs)(`a`,{href:ee({account:`pool`}),className:`flex min-h-11 items-center justify-between gap-2 rounded-md px-2 text-sm text-muted-foreground outline-none hover:bg-muted/40 hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50`,children:[n(`accounts.poolTx`,{name:T}),(0,L.jsx)(t,{className:`size-4`,"aria-hidden":!0})]}),(0,L.jsx)(`ul`,{className:`flex flex-col`,children:r.items.map(e=>N(e))}),r.pool&&M.poolIdle.length>0&&(0,L.jsx)(je,{open:E,onToggle:()=>D(e=>!e),label:n(`accounts.inactive`),count:M.poolIdle.length,children:(0,L.jsx)(`ul`,{className:`flex flex-col`,children:M.poolIdle.map(e=>N(e,!0))})})]})]},r.id))})}),M.debt.length>0&&(0,L.jsx)(Z,{value:`debt`,children:(0,L.jsx)(`ul`,{className:`grid items-start gap-3 md:grid-cols-2`,children:M.debt.map(e=>(0,L.jsx)(`li`,{className:`list-none rounded-xl bg-card px-2 py-1 ring-1 ring-foreground/[0.07] shadow-[0_1px_2px_oklch(0_0_0/0.04)]`,children:(0,L.jsx)(`ul`,{children:N(e)})},e.id))})}),z>0&&(0,L.jsxs)(Z,{value:`idle`,className:`flex flex-col gap-5`,children:[M.inactiveRest.length>0&&(0,L.jsxs)(`section`,{className:`flex flex-col gap-1`,children:[(0,L.jsxs)(`h2`,{className:`px-2 text-sm font-medium text-muted-foreground`,children:[n(`accounts.inactive`),` `,(0,L.jsx)(`span`,{className:`tabular-nums`,children:M.inactiveRest.length})]}),(0,L.jsx)(`ul`,{className:`grid gap-x-6 rounded-xl bg-card px-2 py-1 ring-1 ring-foreground/[0.07] md:grid-cols-2`,children:M.inactiveRest.map(e=>N(e))})]}),M.closed.length>0&&(0,L.jsxs)(`section`,{className:`flex flex-col gap-1`,children:[(0,L.jsxs)(`h2`,{className:`px-2 text-sm font-medium text-muted-foreground`,children:[n(`accounts.closed`),` `,(0,L.jsx)(`span`,{className:`tabular-nums`,children:M.closed.length})]}),(0,L.jsx)(`ul`,{className:`grid gap-x-6 rounded-xl bg-card px-2 py-1 ring-1 ring-foreground/[0.07] md:grid-cols-2`,children:M.closed.map(e=>N(e))})]})]})]})]})}function $({n:e}){return(0,L.jsx)(`span`,{className:`rounded-full bg-muted px-1.5 text-xs font-normal text-muted-foreground tabular-nums group-data-active:bg-secondary`,children:e})}export{Me as default};
1
+ import{t as e}from"./chevron-down-BWoQwA6m.js";import{t}from"./chevron-right-D7Sgw1v1.js";import{B as n,I as r,L as i,T as a,a as o,d as s,o as c,t as l,u,w as d}from"./queries-BcMmmb36.js";import{A as f,W as p,l as m,n as h,r as g,s as _,u as v}from"./index-DBHFdsYB.js";import{t as y}from"./Money-BwLucm7P.js";import{o as b,r as x}from"./bits-D34d9IBm.js";import{a as S,i as C,n as w,o as T,r as E,s as D}from"./dist-CmbuesVk.js";import{n as O,s as k}from"./button-BKhMn8jX.js";import{t as A}from"./dist-BFPyD74_.js";import{n as j,r as M,t as N}from"./dist--HKr0kfV.js";import{t as P}from"./dist-vgyaCpaL.js";import{t as F}from"./cards-Ct0jh73r.js";import{t as ee}from"./drill-t1zr57xi.js";var I=n(r(),1),L=i(),R=Object.defineProperty,z=(e,t)=>R(e,`name`,{value:t,configurable:!0}),B=`Collapsible`,[te,ne]=T(B),[re,V]=te(B),ie=I.forwardRef(z(function(e,t){let{__scopeCollapsible:n,open:r,defaultOpen:i,disabled:a,onOpenChange:o,...s}=e,[c,l]=E({prop:r,defaultProp:i??!1,onChange:o,caller:B});return(0,L.jsx)(re,{scope:n,disabled:a,contentId:w(),open:c,onOpenToggle:I.useCallback(()=>l(e=>!e),[l]),children:(0,L.jsx)(D.div,{"data-state":U(c),"data-disabled":a?``:void 0,...s,ref:t})})},`Collapsible`)),ae=`CollapsibleTrigger`,oe=I.forwardRef(z(function(e,t){let{__scopeCollapsible:n,...r}=e,i=V(ae,n);return(0,L.jsx)(D.button,{type:`button`,"aria-controls":i.open?i.contentId:void 0,"aria-expanded":i.open||!1,"data-state":U(i.open),"data-disabled":i.disabled?``:void 0,disabled:i.disabled,...r,ref:t,onClick:C(e.onClick,i.onOpenToggle)})},`CollapsibleTrigger`)),H=`CollapsibleContent`,se=I.forwardRef(z(function(e,t){let{forceMount:n,...r}=e,i=V(H,e.__scopeCollapsible);return(0,L.jsx)(A,{present:n||i.open,children:({present:e})=>(0,L.jsx)(ce,{...r,ref:t,present:e})})},`CollapsibleContent`)),ce=I.forwardRef(z(function(e,t){let{__scopeCollapsible:n,present:r,children:i,...a}=e,o=V(H,n),[s,c]=I.useState(r),l=I.useRef(null),u=k(t,l),d=I.useRef(0),f=d.current,p=I.useRef(0),m=p.current,h=o.open||s,g=I.useRef(h),_=I.useRef(void 0);return I.useEffect(()=>{let e=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(e)},[]),S(()=>{let e=l.current;if(e){_.current=_.current||{transitionDuration:e.style.transitionDuration,animationName:e.style.animationName},e.style.transitionDuration=`0s`,e.style.animationName=`none`;let t=e.getBoundingClientRect();d.current=t.height,p.current=t.width,g.current||(e.style.transitionDuration=_.current.transitionDuration,e.style.animationName=_.current.animationName),c(r)}},[o.open,r]),(0,L.jsx)(D.div,{"data-state":U(o.open),"data-disabled":o.disabled?``:void 0,id:o.contentId,hidden:!h,...a,ref:u,style:{"--radix-collapsible-content-height":f?`${f}px`:void 0,"--radix-collapsible-content-width":m?`${m}px`:void 0,...e.style},children:h&&i})},`CollapsibleContentImpl`));function U(e){return e?`open`:`closed`}z(U,`getState`);var le=Object.defineProperty,W=(e,t)=>le(e,`name`,{value:t,configurable:!0}),G={Automatic:`automatic`,Manual:`manual`},K=`Tabs`,[ue,de]=T(K,[M]),fe=M(),[pe,q]=ue(K),me=I.forwardRef(W(function(e,t){let{__scopeTabs:n,value:r,onValueChange:i,defaultValue:a,orientation:o=`horizontal`,dir:s,activationMode:c=G.Automatic,...l}=e,u=P(s),[d,f]=E({prop:r,onChange:i,defaultProp:a??``,caller:K});return(0,L.jsx)(pe,{scope:n,baseId:w(),value:d,onValueChange:f,orientation:o,dir:u,activationMode:c,children:(0,L.jsx)(D.div,{dir:u,"data-orientation":o,...l,ref:t})})},`Tabs`)),he=`TabsList`,ge=I.forwardRef(W(function(e,t){let{__scopeTabs:n,loop:r=!0,...i}=e,a=q(he,n),o=fe(n);return(0,L.jsx)(N,{asChild:!0,...o,orientation:a.orientation,dir:a.dir,loop:r,children:(0,L.jsx)(D.div,{role:`tablist`,"aria-orientation":a.orientation,...i,ref:t})})},`TabsList`)),_e=`TabsTrigger`,ve=I.forwardRef(W(function(e,t){let{__scopeTabs:n,value:r,disabled:i=!1,...a}=e,o=q(_e,n),s=fe(n),c=J(o.baseId,r),l=Y(o.baseId,r),u=r===o.value;return(0,L.jsx)(j,{asChild:!0,...s,focusable:!i,active:u,children:(0,L.jsx)(D.button,{type:`button`,role:`tab`,"aria-selected":u,"aria-controls":l,"data-state":u?`active`:`inactive`,"data-disabled":i?``:void 0,disabled:i,id:c,...a,ref:t,onMouseDown:C(e.onMouseDown,e=>{!i&&e.button===0&&e.ctrlKey===!1?(e.currentTarget.focus(),o.onValueChange(r)):e.preventDefault()}),onKeyDown:C(e.onKeyDown,e=>{i||e.target!==e.currentTarget||[` `,`Enter`].includes(e.key)&&o.onValueChange(r)}),onFocus:C(e.onFocus,()=>{let e=o.activationMode!==G.Manual;!u&&!i&&e&&o.onValueChange(r)})})})},`TabsTrigger`)),ye=`TabsContent`,be=I.forwardRef(W(function(e,t){let{__scopeTabs:n,value:r,forceMount:i,children:a,...o}=e,s=q(ye,n),c=J(s.baseId,r),l=Y(s.baseId,r),u=r===s.value,d=I.useRef(u);return I.useEffect(()=>{let e=requestAnimationFrame(()=>d.current=!1);return()=>cancelAnimationFrame(e)},[]),(0,L.jsx)(A,{present:i||u,children:({present:n})=>(0,L.jsx)(D.div,{"data-state":u?`active`:`inactive`,"data-orientation":s.orientation,role:`tabpanel`,"aria-labelledby":c,hidden:!n,id:l,tabIndex:0,...o,ref:t,style:{...e.style,animationDuration:d.current?`0s`:void 0},children:n&&a})})},`TabsContent`));function J(e,t){return`${e}-trigger-${t}`}W(J,`makeTriggerId`);function Y(e,t){return`${e}-content-${t}`}W(Y,`makeContentId`);function xe({...e}){return(0,L.jsx)(ie,{"data-slot":`collapsible`,...e})}function Se({...e}){return(0,L.jsx)(oe,{"data-slot":`collapsible-trigger`,...e})}function Ce({...e}){return(0,L.jsx)(se,{"data-slot":`collapsible-content`,...e})}function we({className:e,orientation:t=`horizontal`,...n}){return(0,L.jsx)(me,{"data-slot":`tabs`,"data-orientation":t,className:a(`group/tabs flex gap-2 data-horizontal:flex-col`,e),...n})}var Te=O(`group/tabs-list inline-flex w-fit items-center justify-center rounded-lg p-[3px] text-muted-foreground group-data-horizontal/tabs:h-8 group-data-vertical/tabs:h-fit group-data-vertical/tabs:flex-col data-[variant=line]:rounded-none`,{variants:{variant:{default:`bg-muted`,line:`gap-1 bg-transparent`}},defaultVariants:{variant:`default`}});function Ee({className:e,variant:t=`default`,...n}){return(0,L.jsx)(ge,{"data-slot":`tabs-list`,"data-variant":t,className:a(Te({variant:t}),e),...n})}function X({className:e,...t}){return(0,L.jsx)(ve,{"data-slot":`tabs-trigger`,className:a(`relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-1.5 py-0.5 text-sm font-medium whitespace-nowrap text-foreground/60 transition-all group-data-vertical/tabs:w-full group-data-vertical/tabs:justify-start hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 has-data-[icon=inline-end]:pr-1 has-data-[icon=inline-start]:pl-1 dark:text-muted-foreground dark:hover:text-foreground group-data-[variant=default]/tabs-list:data-active:shadow-sm group-data-[variant=line]/tabs-list:data-active:shadow-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,`group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-active:bg-transparent dark:group-data-[variant=line]/tabs-list:data-active:border-transparent dark:group-data-[variant=line]/tabs-list:data-active:bg-transparent`,`data-active:bg-background data-active:text-foreground dark:data-active:border-input dark:data-active:bg-input/30 dark:data-active:text-foreground`,`after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-horizontal/tabs:after:inset-x-0 group-data-horizontal/tabs:after:bottom-[-5px] group-data-horizontal/tabs:after:h-0.5 group-data-vertical/tabs:after:inset-y-0 group-data-vertical/tabs:after:-right-1 group-data-vertical/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-active:after:opacity-100`,e),...t})}function Z({className:e,...t}){return(0,L.jsx)(be,{"data-slot":`tabs-content`,className:a(`flex-1 text-sm outline-none`,e),...t})}var De=90,Oe=[`var(--chart-1)`,`var(--chart-2)`,`var(--chart-3)`,`var(--chart-4)`,`var(--chart-5)`],Q=e=>Math.abs(e.value);function ke({children:e,tone:t}){return(0,L.jsx)(`span`,{className:a(`shrink-0 rounded-full px-2 py-0.5 text-[11px] font-medium`,t===`warn`?`bg-warning/10 text-warning`:`bg-secondary text-secondary-foreground`),children:e})}function Ae({a:e,holdings:t,card:n,deposit:r,nested:i}){let{t:o,lang:s}=d();return(0,L.jsxs)(`li`,{className:a(`relative flex flex-col gap-1 rounded-md py-1.5 hover:bg-muted/40 focus-within:ring-3 focus-within:ring-ring/50`,i?`pl-4`:`px-2`),children:[(0,L.jsxs)(`div`,{className:`flex min-h-11 items-center justify-between gap-3`,children:[(0,L.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,L.jsx)(`a`,{href:ee({account:e.id}),className:`truncate rounded-md text-sm font-medium outline-none after:absolute after:inset-0 focus-visible:underline`,children:e.name}),e.closed&&(0,L.jsx)(ke,{children:o(`accounts.closedOn`,{date:_(e.closed,s)})}),t&&!e.priced&&(0,L.jsx)(ke,{tone:`warn`,children:o(`accounts.noPrice`)})]}),(0,L.jsx)(y,{amount:e.value,mode:`short`,className:`shrink-0 text-sm font-medium`})]}),t&&(0,L.jsxs)(`p`,{className:`text-xs text-muted-foreground tabular-nums`,children:[e.qty!==null&&(0,L.jsx)(L.Fragment,{children:o(`accounts.qty`,{n:m(e.qty,s,4)})}),e.price&&(0,L.jsxs)(L.Fragment,{children:[` · `,o(`accounts.price`,{price:v(e.price.price,s),date:h(e.price.date)})]}),` · `,o(`accounts.cost`),` `,(0,L.jsx)(y,{amount:e.cost,mode:`short`})]}),n&&(0,L.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,L.jsx)(b,{owed:n.owed,limit:n.limit,atLeast:n.limitAtLeast}),(0,L.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-3 text-xs text-muted-foreground`,children:[n.toPay>0?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`span`,{children:[o(`cards.toPay`),` `,(0,L.jsx)(y,{amount:n.toPay,mode:`short`,className:`font-medium text-foreground`})]}),n.due&&(0,L.jsx)(`span`,{children:h(n.due)}),(0,L.jsx)(x,{days:n.daysToDue})]}):(0,L.jsx)(`span`,{children:o(`cards.nothingToPay`)}),(0,L.jsx)(`a`,{href:F(n.account),className:`relative z-10 ml-auto inline-flex min-h-11 items-center rounded-md px-1 underline outline-none focus-visible:ring-3 focus-visible:ring-ring/50`,children:o(`accounts.cardPage`)})]})]}),r&&(0,L.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[r.maturity?`${r.daysToMaturity<0?o(`deposits.matured`):o(`deposits.inDays`,{n:r.daysToMaturity})} · ${h(r.maturity)}`:o(`deposits.noMaturity`),r.rate!==null&&` · ${m(r.rate,s,2)}%`,r.interestAtMaturity?(0,L.jsxs)(L.Fragment,{children:[` · `,o(`deposits.interest`),` `,(0,L.jsx)(y,{amount:r.interestAtMaturity,mode:`short`})]}):null]})]})}function je({open:n,onToggle:r,label:i,count:o,children:s,nested:c}){return(0,L.jsxs)(`div`,{className:a(`flex flex-col`,c&&`pl-4`),children:[(0,L.jsxs)(`button`,{type:`button`,"aria-expanded":n,onClick:r,className:`flex min-h-11 items-center gap-1 rounded-md px-2 text-left text-sm text-muted-foreground outline-none hover:bg-muted/40 focus-visible:ring-3 focus-visible:ring-ring/50`,children:[n?(0,L.jsx)(e,{className:`size-4`,"aria-hidden":!0}):(0,L.jsx)(t,{className:`size-4`,"aria-hidden":!0}),i,` (`,o,`)`]}),n&&s]})}function Me(){let{t:n,lang:r}=d(),i=u().data,a=s().data,{data:h,error:_,isLoading:v}=l(),b=!!i?.features?.cards,x=o(b).data,S=c(!!i?.features?.deposits).data,C=i?.today??new Date().toISOString().slice(0,10),w=i?.pool,T=w?.name??n(`pool.name`),[E,D]=(0,I.useState)(!1),O=e=>a?.types[e]?.[r]??e,k=e=>!!a?.types[e]?.holdings,A=(0,I.useMemo)(()=>new Map((x?.cards??[]).map(e=>[e.account,e])),[x]),j=(0,I.useMemo)(()=>new Map((S??[]).map(e=>[e.account,e])),[S]),M=(0,I.useMemo)(()=>{let e=h??[],t=e=>!!a?.types[e.type]?.liability,n=e=>(t(e)||e.value<0)&&e.value<0,r=0,i=0,o=0;for(let t of e)(t.value!==0||t.qty)&&(n(t)?i+=t.value:r+=t.value,t.priced||o++);let s=e=>e.value===0&&!e.qty&&(e.lastActivity===null||g(e.lastActivity,C)>De),c=e.filter(e=>e.closed),l=e.filter(e=>!e.closed),u=w?.on?l.filter(e=>e.pool):[],d=l.filter(e=>!u.includes(e)),f=d.filter(s),p=d.filter(e=>!s(e)),m=p.filter(e=>t(e)||e.value<0),_=e=>A.get(e.id)?.daysToDue??1/0;m.sort((e,t)=>_(e)-_(t)||e.value-t.value);let v=new Map;for(let e of p.filter(e=>!m.includes(e))){let t=v.get(e.type)??{id:e.type,label:O(e.type),value:0,items:[]};t.items.push(e),t.value+=e.value,v.set(e.type,t)}let y=[...v.values()];for(let e of y)e.items.sort((e,t)=>Q(t)-Q(e));let b=u.filter(e=>!s(e)).sort((e,t)=>Q(t)-Q(e)),x=u.filter(s);u.length&&y.push({id:`pool`,label:T,value:u.reduce((e,t)=>e+t.value,0),items:b,pool:!0}),y.sort((e,t)=>t.value-e.value),y.forEach((e,t)=>e.color=e.value>0&&t<Oe.length?Oe[t]:`var(--chart-muted)`);let S=y.reduce((e,t)=>e+(t.pool?u.length:t.items.length),0);return{assets:r,liabilities:i,net:r+i,groups:y,debt:m,poolIdle:x,poolCount:u.length,assetCount:S,inactiveRest:f.sort((e,t)=>e.name.localeCompare(t.name)),closed:c.sort((e,t)=>(t.closed??``).localeCompare(e.closed??``)),unpriced:o,any:e.length>0}},[h,a,w?.on,T,C,r,A]);if(_)return(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n(`common.error`,{message:_.message})});if(v||!h||!a)return(0,L.jsxs)(`div`,{className:`flex flex-col gap-4`,"aria-busy":`true`,children:[(0,L.jsx)(p,{className:`h-8 w-48`}),(0,L.jsx)(p,{className:`h-24 w-full`}),(0,L.jsx)(p,{className:`h-48 w-full`})]});if(!M.any)return(0,L.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,L.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:n(`accounts.title`)}),(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n(`accounts.empty`)}),(0,L.jsx)(f,{className:`self-start`,prompt:n(`start.s2.prompt`)})]});let N=(e,t)=>(0,L.jsx)(Ae,{a:e,nested:t,holdings:k(e.type),card:A.get(e.id),deposit:j.get(e.id)},e.id),P=M.groups.filter(e=>e.value>0),F=P.reduce((e,t)=>e+t.value,0),R=e=>F>0&&e>0?`${m(e/F*100,r)}%`:``,z=M.inactiveRest.length+M.closed.length;return(0,L.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,L.jsxs)(`header`,{className:`flex flex-col gap-1`,children:[(0,L.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:n(`accounts.title`)}),(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n(`accounts.netWorth`)}),(0,L.jsx)(y,{amount:M.net,className:`text-3xl font-semibold tracking-tight md:text-4xl`}),(0,L.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[n(`accounts.assets`),` `,(0,L.jsx)(y,{amount:M.assets,mode:`short`,className:`font-medium text-foreground`}),` · `,n(`accounts.liabilities`),` `,(0,L.jsx)(y,{amount:M.liabilities,mode:`short`,className:`font-medium text-foreground`})]}),M.unpriced>0&&(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`nw.unpriced`,{n:M.unpriced})})]}),P.length>0&&(0,L.jsx)(`div`,{className:`flex h-2.5 w-full gap-0.5 overflow-hidden rounded-full`,role:`img`,"aria-label":`${n(`accounts.byType`)}: ${P.map(e=>`${e.label} ${R(e.value)}`).join(`, `)}`,children:P.map(e=>(0,L.jsx)(`span`,{className:`h-full first:rounded-l-full last:rounded-r-full`,style:{width:`${e.value/F*100}%`,background:e.color},title:`${e.label} ${R(e.value)}`},e.id))}),(0,L.jsxs)(we,{defaultValue:`assets`,className:`gap-4`,children:[(0,L.jsxs)(Ee,{className:`h-10! w-full sm:w-fit`,children:[(0,L.jsxs)(X,{value:`assets`,className:`px-3`,children:[n(`accounts.assets`),(0,L.jsx)($,{n:M.assetCount})]}),M.debt.length>0&&(0,L.jsxs)(X,{value:`debt`,className:`px-3`,children:[n(`accounts.liabilities`),(0,L.jsx)($,{n:M.debt.length})]}),z>0&&(0,L.jsxs)(X,{value:`idle`,className:`px-3`,children:[n(`accounts.tabIdle`),(0,L.jsx)($,{n:z})]})]}),(0,L.jsx)(Z,{value:`assets`,children:(0,L.jsx)(`div`,{className:`grid items-start gap-3 md:grid-cols-2`,children:M.groups.map(r=>(0,L.jsxs)(xe,{className:`group/acc overflow-hidden rounded-xl bg-card ring-1 ring-foreground/[0.07] shadow-[0_1px_2px_oklch(0_0_0/0.04)]`,children:[(0,L.jsxs)(Se,{className:`flex min-h-14 w-full items-center gap-3 px-4 text-left outline-none hover:bg-muted/40 focus-visible:ring-3 focus-visible:ring-ring/50 focus-visible:ring-inset`,children:[(0,L.jsx)(`span`,{"aria-hidden":!0,className:`size-2.5 shrink-0 rounded-full`,style:{background:r.color}}),(0,L.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium`,children:[r.label,(0,L.jsx)(`span`,{className:`ml-1.5 font-normal text-muted-foreground tabular-nums`,children:r.pool?M.poolCount:r.items.length})]}),(0,L.jsx)(y,{amount:r.value,mode:`short`,className:`shrink-0 text-sm font-semibold`}),(0,L.jsx)(`span`,{className:`w-9 shrink-0 text-right text-xs text-muted-foreground tabular-nums`,children:R(r.value)}),(0,L.jsx)(e,{className:`size-4 shrink-0 text-muted-foreground transition-transform group-data-[state=open]/acc:rotate-180 motion-reduce:transition-none`,"aria-hidden":!0})]}),(0,L.jsxs)(Ce,{className:`border-t px-2 py-1`,children:[r.pool&&(0,L.jsxs)(`a`,{href:ee({account:`pool`}),className:`flex min-h-11 items-center justify-between gap-2 rounded-md px-2 text-sm text-muted-foreground outline-none hover:bg-muted/40 hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50`,children:[n(`accounts.poolTx`,{name:T}),(0,L.jsx)(t,{className:`size-4`,"aria-hidden":!0})]}),(0,L.jsx)(`ul`,{className:`flex flex-col`,children:r.items.map(e=>N(e))}),r.pool&&M.poolIdle.length>0&&(0,L.jsx)(je,{open:E,onToggle:()=>D(e=>!e),label:n(`accounts.inactive`),count:M.poolIdle.length,children:(0,L.jsx)(`ul`,{className:`flex flex-col`,children:M.poolIdle.map(e=>N(e,!0))})})]})]},r.id))})}),M.debt.length>0&&(0,L.jsx)(Z,{value:`debt`,children:(0,L.jsx)(`ul`,{className:`grid items-start gap-3 md:grid-cols-2`,children:M.debt.map(e=>(0,L.jsx)(`li`,{className:`list-none rounded-xl bg-card px-2 py-1 ring-1 ring-foreground/[0.07] shadow-[0_1px_2px_oklch(0_0_0/0.04)]`,children:(0,L.jsx)(`ul`,{children:N(e)})},e.id))})}),z>0&&(0,L.jsxs)(Z,{value:`idle`,className:`flex flex-col gap-5`,children:[M.inactiveRest.length>0&&(0,L.jsxs)(`section`,{className:`flex flex-col gap-1`,children:[(0,L.jsxs)(`h2`,{className:`px-2 text-sm font-medium text-muted-foreground`,children:[n(`accounts.inactive`),` `,(0,L.jsx)(`span`,{className:`tabular-nums`,children:M.inactiveRest.length})]}),(0,L.jsx)(`ul`,{className:`grid gap-x-6 rounded-xl bg-card px-2 py-1 ring-1 ring-foreground/[0.07] md:grid-cols-2`,children:M.inactiveRest.map(e=>N(e))})]}),M.closed.length>0&&(0,L.jsxs)(`section`,{className:`flex flex-col gap-1`,children:[(0,L.jsxs)(`h2`,{className:`px-2 text-sm font-medium text-muted-foreground`,children:[n(`accounts.closed`),` `,(0,L.jsx)(`span`,{className:`tabular-nums`,children:M.closed.length})]}),(0,L.jsx)(`ul`,{className:`grid gap-x-6 rounded-xl bg-card px-2 py-1 ring-1 ring-foreground/[0.07] md:grid-cols-2`,children:M.closed.map(e=>N(e))})]})]})]})]})}function $({n:e}){return(0,L.jsx)(`span`,{className:`rounded-full bg-muted px-1.5 text-xs font-normal text-muted-foreground tabular-nums group-data-active:bg-secondary`,children:e})}export{Me as default};
@@ -1 +1 @@
1
- import{t as e}from"./createLucideIcon-DUW9Fpzj.js";import{B as t,C as n,I as r,L as i,T as a,c as o,w as s}from"./queries-C_4ufx4u.js";import{A as c,M as l,n as u}from"./index-DYyIpxqK.js";import{t as d}from"./Money-DCMKf898.js";import{t as f}from"./button-Cj0k8AtB.js";import{t as p}from"./drill-t1zr57xi.js";import{n as m}from"./shared-CR-hvb-r.js";var h={name:`circle-exclamation-point`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]],aliases:[`alert-circle`,`circle-alert`]};h.node;var g=e(h),_={name:`clock`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]};_.node;var v=e(_),y={name:`info`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 16v-4`,key:`1dtifu`}],[`path`,{d:`M12 8h.01`,key:`e9boi3`}]]};y.node;var b=e(y),x=t(r(),1),S=i(),C=5,w={red:{icon:g,cls:`text-critical`,row:`bg-critical/5`},amber:{icon:v,cls:`text-warning`},info:{icon:b,cls:`text-muted-foreground`}};function T(e,t){let r={name:e.name??``,count:e.count??0,n:e.count??0,...e.params??{}},i=`attention.${e.kind}`,a=n(t,i,r);return a===i?e.title:a}function E(e,t){return e.days===void 0?null:e.days<0?t(`attention.overdueDays`,{n:-e.days}):e.days===0?t(`attention.today`):t(`attention.inDays`,{n:e.days})}function D(e,t){let n=e.name??``;switch(e.kind){case`uncategorised`:return t(`ask.uncategorised`,{n:e.count??0,from:String(e.params?.from??``)});case`plan_due`:case`plan_overdue`:return t(`ask.plan`,{name:n});case`unmatched`:return t(`ask.unmatched`,{name:n});case`negative`:return t(`ask.negative`,{name:n});default:return t(`ask.generic`,{title:e.title})}}function O({widget:e,menu:t}){let{t:n,lang:r}=s(),i=m(e,`widget.attention`),{data:h,error:g,isLoading:_}=o(),[v,y]=(0,x.useState)(!1),b=h?.attention??[],O=v?b:b.slice(0,C);return(0,S.jsxs)(l,{title:(0,S.jsxs)(`span`,{className:`flex items-center gap-2`,children:[i,b.length>0&&(0,S.jsx)(`span`,{className:a(`rounded-full px-2 py-0.5 text-xs font-medium tabular-nums`,b.some(e=>e.severity===`red`)?`bg-critical/10 text-critical`:`bg-secondary text-secondary-foreground`),children:b.length})]}),menu:t,loading:_,error:g?.message,empty:h&&b.length===0?n(`attention.empty`):void 0,children:[(0,S.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:O.map((e,t)=>{let i=E(e,n),o=T(e,r),s=w[e.severity],l=s.icon,f=(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`span`,{className:`mt-0.5 flex shrink-0 items-center`,children:[(0,S.jsx)(l,{className:a(`size-4`,s.cls),"aria-hidden":!0}),(0,S.jsx)(`span`,{className:`sr-only`,children:n(`attention.sev.${e.severity}`)})]}),(0,S.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,S.jsx)(`span`,{className:`text-sm`,children:o}),(0,S.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:[i,!i||e.days===void 0?null:u(e.date)].filter(Boolean).join(` · `)})]}),e.amount!==void 0&&(0,S.jsx)(d,{amount:Math.abs(e.amount),mode:`short`,className:`shrink-0 text-sm font-medium`})]});return(0,S.jsxs)(`li`,{className:a(`-mx-2 flex flex-wrap items-center gap-x-2 gap-y-1 rounded-lg px-2 py-1.5`,s.row),children:[e.link?(0,S.jsx)(`a`,{href:e.link.startsWith(`#`)?e.link:p(),className:`flex min-h-11 min-w-0 flex-1 items-start gap-2 rounded-md py-1 outline-none hover:bg-muted/50 focus-visible:ring-3 focus-visible:ring-ring/50`,children:f}):(0,S.jsx)(`div`,{className:`flex min-h-11 min-w-0 flex-1 items-start gap-2 py-1`,children:f}),e.ask&&(0,S.jsx)(c,{prompt:D(e,n)})]},`${e.kind}-${t}`)})}),b.length>C&&(0,S.jsx)(f,{type:`button`,variant:`ghost`,size:`sm`,className:`min-h-11 self-start md:min-h-8`,onClick:()=>y(e=>!e),children:v?n(`common.showLess`):n(`attention.seeAll`,{n:b.length})})]})}export{T as attentionLabel,O as default,E as whenText};
1
+ import{t as e}from"./createLucideIcon-XZ28znwT.js";import{B as t,C as n,I as r,L as i,T as a,c as o,w as s}from"./queries-BcMmmb36.js";import{A as c,M as l,n as u}from"./index-DBHFdsYB.js";import{t as d}from"./Money-BwLucm7P.js";import{t as f}from"./button-BKhMn8jX.js";import{t as p}from"./drill-t1zr57xi.js";import{n as m}from"./shared-BgU6fc7z.js";var h={name:`circle-exclamation-point`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]],aliases:[`alert-circle`,`circle-alert`]};h.node;var g=e(h),_={name:`clock`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]};_.node;var v=e(_),y={name:`info`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 16v-4`,key:`1dtifu`}],[`path`,{d:`M12 8h.01`,key:`e9boi3`}]]};y.node;var b=e(y),x=t(r(),1),S=i(),C=5,w={red:{icon:g,cls:`text-critical`,row:`bg-critical/5`},amber:{icon:v,cls:`text-warning`},info:{icon:b,cls:`text-muted-foreground`}};function T(e,t){let r={name:e.name??``,count:e.count??0,n:e.count??0,...e.params??{}},i=`attention.${e.kind}`,a=n(t,i,r);return a===i?e.title:a}function E(e,t){return e.days===void 0?null:e.days<0?t(`attention.overdueDays`,{n:-e.days}):e.days===0?t(`attention.today`):t(`attention.inDays`,{n:e.days})}function D(e,t){let n=e.name??``;switch(e.kind){case`uncategorised`:return t(`ask.uncategorised`,{n:e.count??0,from:String(e.params?.from??``)});case`plan_due`:case`plan_overdue`:return t(`ask.plan`,{name:n});case`unmatched`:return t(`ask.unmatched`,{name:n});case`negative`:return t(`ask.negative`,{name:n});default:return t(`ask.generic`,{title:e.title})}}function O({widget:e,menu:t}){let{t:n,lang:r}=s(),i=m(e,`widget.attention`),{data:h,error:g,isLoading:_}=o(),[v,y]=(0,x.useState)(!1),b=h?.attention??[],O=v?b:b.slice(0,C);return(0,S.jsxs)(l,{title:(0,S.jsxs)(`span`,{className:`flex items-center gap-2`,children:[i,b.length>0&&(0,S.jsx)(`span`,{className:a(`rounded-full px-2 py-0.5 text-xs font-medium tabular-nums`,b.some(e=>e.severity===`red`)?`bg-critical/10 text-critical`:`bg-secondary text-secondary-foreground`),children:b.length})]}),menu:t,loading:_,error:g?.message,empty:h&&b.length===0?n(`attention.empty`):void 0,children:[(0,S.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:O.map((e,t)=>{let i=E(e,n),o=T(e,r),s=w[e.severity],l=s.icon,f=(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`span`,{className:`mt-0.5 flex shrink-0 items-center`,children:[(0,S.jsx)(l,{className:a(`size-4`,s.cls),"aria-hidden":!0}),(0,S.jsx)(`span`,{className:`sr-only`,children:n(`attention.sev.${e.severity}`)})]}),(0,S.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,S.jsx)(`span`,{className:`text-sm`,children:o}),(0,S.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:[i,!i||e.days===void 0?null:u(e.date)].filter(Boolean).join(` · `)})]}),e.amount!==void 0&&(0,S.jsx)(d,{amount:Math.abs(e.amount),mode:`short`,className:`shrink-0 text-sm font-medium`})]});return(0,S.jsxs)(`li`,{className:a(`-mx-2 flex flex-wrap items-center gap-x-2 gap-y-1 rounded-lg px-2 py-1.5`,s.row),children:[e.link?(0,S.jsx)(`a`,{href:e.link.startsWith(`#`)?e.link:p(),className:`flex min-h-11 min-w-0 flex-1 items-start gap-2 rounded-md py-1 outline-none hover:bg-muted/50 focus-visible:ring-3 focus-visible:ring-ring/50`,children:f}):(0,S.jsx)(`div`,{className:`flex min-h-11 min-w-0 flex-1 items-start gap-2 py-1`,children:f}),e.ask&&(0,S.jsx)(c,{prompt:D(e,n)})]},`${e.kind}-${t}`)})}),b.length>C&&(0,S.jsx)(f,{type:`button`,variant:`ghost`,size:`sm`,className:`min-h-11 self-start md:min-h-8`,onClick:()=>y(e=>!e),children:v?n(`common.showLess`):n(`attention.seeAll`,{n:b.length})})]})}export{T as attentionLabel,O as default,E as whenText};
@@ -1 +1 @@
1
- import{r as e}from"./charts-Cj_hTR4h.js";import{t}from"./CategoryIcon-E6EWIpbr.js";import{t as n}from"./Money-DCMKf898.js";import{M as r,l as i,o as a}from"./index-DYyIpxqK.js";import{L as o,_ as s,u as c,w as l}from"./queries-C_4ufx4u.js";import{t as u}from"./drill-t1zr57xi.js";import{n as d,t as f}from"./shared-CR-hvb-r.js";var p=o();function m(e,t){let n=t.slice(0,7);switch(e){case`last-month`:return a(n,-1);case`this-year`:return t.slice(0,4);case`last-year`:return String(Number(t.slice(0,4))-1);default:return e&&/^\d{4}(-\d{2})?$/.test(e)?e:n}}function h({widget:a,menu:o}){let{t:h,lang:g}=l(),_=d(a,`widget.byCategory`),v=c().data,y=m(a.period,v?.today??new Date().toISOString().slice(0,10)),{data:b,error:x,isLoading:S}=s(y,`top`),C=(b?.rows??[]).filter(e=>e.current>0).sort((e,t)=>t.current-e.current).slice(0,8),w=b?.current??0;return(0,p.jsx)(r,{title:_,titleHref:`#/reports`,menu:o,loading:S,error:x?.message,empty:b&&C.length===0?h(`bycat.empty`):void 0,children:b&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[h(`bycat.total`),` `,(0,p.jsx)(n,{amount:w,mode:`short`,className:`font-medium text-foreground`})]}),(0,p.jsx)(e,{rows:C.map(e=>({key:e.key,name:(0,p.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,p.jsx)(t,{category:e.key,name:e.name,className:`size-6 [&_svg]:size-3`}),(0,p.jsx)(`span`,{className:`truncate`,children:e.name})]}),value:e.current,label:(0,p.jsx)(n,{amount:e.current,mode:`short`,className:`font-medium`}),meta:(0,p.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,p.jsxs)(`span`,{children:[i(e.current/(w||1)*100,g),`%`]}),e.changePct!==null&&b.months>=1&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(f,{pct:e.changePct,className:`text-xs`}),(0,p.jsx)(`span`,{children:h(`pace.vsUsual`)})]})]}),href:u({category:e.key,from:b.period.from,to:b.period.to})}))})]})})}export{h as default,m as reportPeriod};
1
+ import{r as e}from"./charts-D-1glV8L.js";import{t}from"./CategoryIcon-D4Cdb_ZP.js";import{t as n}from"./Money-BwLucm7P.js";import{M as r,l as i,o as a}from"./index-DBHFdsYB.js";import{L as o,_ as s,u as c,w as l}from"./queries-BcMmmb36.js";import{t as u}from"./drill-t1zr57xi.js";import{n as d,t as f}from"./shared-BgU6fc7z.js";var p=o();function m(e,t){let n=t.slice(0,7);switch(e){case`last-month`:return a(n,-1);case`this-year`:return t.slice(0,4);case`last-year`:return String(Number(t.slice(0,4))-1);default:return e&&/^\d{4}(-\d{2})?$/.test(e)?e:n}}function h({widget:a,menu:o}){let{t:h,lang:g}=l(),_=d(a,`widget.byCategory`),v=c().data,y=m(a.period,v?.today??new Date().toISOString().slice(0,10)),{data:b,error:x,isLoading:S}=s(y,`top`),C=(b?.rows??[]).filter(e=>e.current>0).sort((e,t)=>t.current-e.current).slice(0,8),w=b?.current??0;return(0,p.jsx)(r,{title:_,titleHref:`#/reports`,menu:o,loading:S,error:x?.message,empty:b&&C.length===0?h(`bycat.empty`):void 0,children:b&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[h(`bycat.total`),` `,(0,p.jsx)(n,{amount:w,mode:`short`,className:`font-medium text-foreground`})]}),(0,p.jsx)(e,{rows:C.map(e=>({key:e.key,name:(0,p.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,p.jsx)(t,{category:e.key,name:e.name,className:`size-6 [&_svg]:size-3`}),(0,p.jsx)(`span`,{className:`truncate`,children:e.name})]}),value:e.current,label:(0,p.jsx)(n,{amount:e.current,mode:`short`,className:`font-medium`}),meta:(0,p.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,p.jsxs)(`span`,{children:[i(e.current/(w||1)*100,g),`%`]}),e.changePct!==null&&b.months>=1&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(f,{pct:e.changePct,className:`text-xs`}),(0,p.jsx)(`span`,{children:h(`pace.vsUsual`)})]})]}),href:u({category:e.key,from:b.period.from,to:b.period.to})}))})]})})}export{h as default,m as reportPeriod};
@@ -0,0 +1 @@
1
+ import{t as e}from"./createLucideIcon-XZ28znwT.js";import{t}from"./chevron-right-D7Sgw1v1.js";import{B as n,I as r,L as i,T as a,d as o,h as s,r as c,w as l,y as u}from"./queries-BcMmmb36.js";import{A as d,G as f,J as p,K as m,W as h,Y as g,a as _,k as v,l as y,q as b,r as x,s as S,t as C}from"./index-DBHFdsYB.js";import{t as w}from"./DrillLink-CZyI-y0-.js";import{t as T}from"./KV-CKWaJkRK.js";import{t as E}from"./Money-BwLucm7P.js";import{t as D}from"./Panel-CSe25x0N.js";import{a as O,i as k,n as A,o as j,r as M}from"./bits-D34d9IBm.js";import{n as N,t as P}from"./TxRow-BGfpKo2m.js";import{a as F,n as I,t as L}from"./charts-D-1glV8L.js";import{n as R,r as z}from"./cards-Ct0jh73r.js";var B={name:`arrow-left`,size:24,node:[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]};B.node;var V=e(B),H=n(r(),1),U=i();function W({account:e,close:t,onClose:n}){let{t:r,lang:i}=l(),a=v(`(max-width: 767px)`),{data:c,error:u,isLoading:d}=s(e,t),_=N(o().data),y=c?.statement;return(0,U.jsx)(f,{open:t!==null,onOpenChange:e=>!e&&n(),children:(0,U.jsxs)(m,{side:a?`bottom`:`right`,className:a?`max-h-[85svh] overflow-auto rounded-t-xl`:`overflow-auto sm:max-w-md`,children:[(0,U.jsxs)(p,{children:[(0,U.jsx)(g,{children:y?.open?r(`cards.currentPeriod`):r(`cards.statementOf`,{date:t?S(t,i):``})}),(0,U.jsxs)(b,{children:[y?`${S(y.from,i)} – ${S(y.close,i)}`:r(`common.loading`),y?.pdf&&(0,U.jsxs)(U.Fragment,{children:[` · `,(0,U.jsx)(`a`,{href:`/api/m/cards/statement-pdf?account=${encodeURIComponent(e)}&close=${y.close}`,target:`_blank`,rel:`noopener noreferrer`,className:`underline underline-offset-2 hover:text-foreground`,children:r(`cards.statementPdf`)})]})]})]}),(0,U.jsx)(`div`,{className:`flex flex-col gap-3 px-4 pb-4`,children:u?(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:r(`common.error`,{message:u.message})}):d||!c||!y?(0,U.jsx)(h,{className:`h-40 w-full`}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`dl`,{className:`divide-y rounded-lg border px-3`,children:[(0,U.jsx)(T,{label:r(`cards.opening`),children:(0,U.jsx)(E,{amount:y.opening})}),(0,U.jsx)(T,{label:r(`cards.k.purchase`),children:(0,U.jsx)(E,{amount:y.purchases})}),y.fees>0&&(0,U.jsx)(T,{label:r(`cards.k.fee`),children:(0,U.jsx)(E,{amount:y.fees})}),y.refunds>0&&(0,U.jsx)(T,{label:r(`cards.k.refund`),children:(0,U.jsx)(E,{amount:-y.refunds})}),y.cashback>0&&(0,U.jsx)(T,{label:r(`cards.k.cashback`),children:(0,U.jsx)(E,{amount:-y.cashback})}),y.payments>0&&(0,U.jsx)(T,{label:r(`cards.k.payment`),children:(0,U.jsx)(E,{amount:-y.payments})}),(0,U.jsx)(T,{label:r(`cards.closing`),className:`font-medium`,children:(0,U.jsx)(E,{amount:y.closing})})]}),(0,U.jsx)(`ul`,{children:c.transactions.map(t=>(0,U.jsxs)(`li`,{className:`flex flex-col`,children:[t.kind&&(0,U.jsx)(`span`,{className:`px-2 pt-1 text-[11px] font-medium tracking-wide text-muted-foreground uppercase`,children:r(`cards.k.${t.kind}`)}),(0,U.jsx)(P,{tx:t,names:_,account:e})]},t.id))}),c.transactions.length===0&&(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:r(`tx.emptyFiltered`)})]})})]})})}function G({value:e,max:t,label:n}){let r=t>0?Math.min(1,e/t):0;return(0,U.jsx)(`div`,{role:`progressbar`,"aria-label":n,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(r*100),className:`h-2 w-full rounded-full bg-muted`,children:(0,U.jsx)(`div`,{className:`h-2 rounded-full bg-[var(--chart-1)]`,style:{width:`${Math.max(r?2:0,r*100)}%`}})})}function K({d:e,asOf:t}){let{t:n,lang:r}=l(),i=e.summary?.current,a=e.terms.statementDay,o=e.account.id;return(0,U.jsx)(D,{title:n(`cards.currentPeriod`),children:i?(0,U.jsxs)(`dl`,{className:`divide-y`,children:[(0,U.jsx)(T,{label:n(`cards.purchasesSoFar`),children:(0,U.jsx)(w,{filter:{account:o,from:i.from,to:t},className:`font-medium`,children:(0,U.jsx)(E,{amount:i.purchases})})}),a&&(0,U.jsxs)(T,{label:n(`cards.closesOn`),children:[S(z(t,a),r),` · `,(0,U.jsx)(`span`,{className:`text-muted-foreground`,children:n(`cards.daysLeft`,{n:R(t,a)})})]}),e.payByToday&&(0,U.jsxs)(T,{label:n(`cards.payByToday`),children:[(0,U.jsx)(`span`,{className:`font-medium`,children:S(e.payByToday,r)}),` · `,(0,U.jsx)(`span`,{className:`text-muted-foreground`,children:n(`cards.daysLeft`,{n:x(t,e.payByToday)})})]})]}):(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n(a?`cards.noActivity`:`cards.noStatementDay`)})})}function q({s:e,id:t,asOf:n}){let{t:r,lang:i}=l();return(0,U.jsx)(D,{title:e?r(`cards.statementOf`,{date:S(e.close,i)}):r(`cards.lastStatement`),action:e?(0,U.jsx)(O,{status:e.status}):void 0,children:e?(0,U.jsxs)(`dl`,{className:`divide-y`,children:[(0,U.jsx)(T,{label:r(`cards.amountDue`),children:(0,U.jsx)(w,{filter:{account:t,from:e.from,to:e.close},className:`text-lg font-semibold`,children:(0,U.jsx)(E,{amount:e.amountDue})})}),e.due&&(0,U.jsxs)(T,{label:r(`cards.dueDate`),children:[S(e.due,i),` `,e.toPay>0&&(0,U.jsx)(M,{days:x(n,e.due),className:`ml-1`})]}),(0,U.jsx)(T,{label:r(`cards.paid`),children:(0,U.jsx)(w,{filter:{account:t,from:C(e.close,1),to:n},children:(0,U.jsx)(E,{amount:e.paid})})}),(0,U.jsx)(T,{label:r(`cards.toPay`),className:`font-medium`,children:(0,U.jsx)(E,{amount:e.toPay})}),e.deferred>0&&(0,U.jsx)(T,{label:r(`cards.deferred`),children:(0,U.jsx)(E,{amount:e.deferred})}),e.bank!==null&&(0,U.jsxs)(T,{label:r(`cards.bankAmount`),children:[(0,U.jsx)(E,{amount:e.bank}),e.bankDiff!==null&&e.bankDiff!==0&&(0,U.jsx)(`span`,{className:`block text-xs text-warning`,children:r(`cards.bankDiff`,{amount:`${e.bankDiff>0?`+`:`−`}${y(Math.abs(e.bankDiff),i)}`})})]})]}):(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:r(`cards.noClosed`)})})}function J({list:e,onOpen:n}){let{t:r,lang:i}=l();return(0,U.jsx)(D,{title:r(`cards.history`),children:e.length===0?(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:r(`cards.noHistory`)}):(0,U.jsx)(`ul`,{className:`-mx-2 flex flex-col divide-y`,children:e.map(e=>(0,U.jsx)(`li`,{children:(0,U.jsxs)(`button`,{type:`button`,onClick:()=>n(e.close),className:`flex min-h-12 w-full items-center gap-3 rounded-md px-2 py-1.5 text-left outline-none hover:bg-muted/50 focus-visible:ring-3 focus-visible:ring-ring/50`,children:[(0,U.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,U.jsx)(`span`,{className:`truncate text-sm font-medium`,children:e.open?r(`cards.currentPeriod`):S(e.close,i)}),(0,U.jsxs)(`span`,{className:`truncate text-xs text-muted-foreground`,children:[S(e.from,i,{day:`2-digit`,month:`2-digit`}),` – `,S(e.close,i,{day:`2-digit`,month:`2-digit`}),` · `,r(`cards.purchasesShort`),` `,(0,U.jsx)(E,{amount:e.purchases,mode:`short`})]})]}),(0,U.jsxs)(`span`,{className:`flex shrink-0 flex-col items-end`,children:[(0,U.jsx)(E,{amount:e.open?e.closing:e.amountDue,mode:`short`,className:`text-sm font-medium`}),!e.open&&(0,U.jsx)(O,{status:e.status})]}),(0,U.jsx)(t,{className:`size-4 shrink-0 text-muted-foreground`,"aria-hidden":!0})]})},e.close))})})}function Y({d:e}){let{t,lang:n}=l(),r=e.summary?.cashback??null,i=(0,H.useMemo)(()=>[...e.cashback].filter(e=>!e.open).reverse().slice(-12),[e.cashback]).map(e=>({ym:e.close,label:_(e.close.slice(0,7)),expected:e.expected,received:e.received}));return!e.terms.cashback&&!e.cashback.some(e=>e.expected>0||e.received>0)?(0,U.jsxs)(D,{title:t(`cards.cashback`),children:[(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t(`cards.noCashback`)}),(0,U.jsx)(d,{prompt:t(`ask.cardTerms`,{name:e.account.name,list:t(`cards.missing.cashback_rates`)})})]}):(0,U.jsxs)(D,{title:t(`cards.cashback`),children:[r&&(0,U.jsxs)(`dl`,{className:`divide-y`,children:[(0,U.jsx)(T,{label:t(`cards.spendThisPeriod`),children:(0,U.jsx)(w,{filter:{account:e.account.id,from:r.from,to:r.close},children:(0,U.jsx)(E,{amount:r.spend})})}),(0,U.jsx)(T,{label:t(`cards.expected`),children:r.incomplete?(0,U.jsx)(`span`,{className:`text-warning`,children:t(`cards.rateNotSet`)}):(0,U.jsx)(E,{amount:r.expected,className:`font-medium`})}),r.cap!==null&&r.capLeft!==null&&(0,U.jsxs)(T,{label:t(`cards.capLeftLabel`),children:[(0,U.jsx)(E,{amount:r.capLeft}),` `,(0,U.jsxs)(`span`,{className:`text-muted-foreground`,children:[`/ `,(0,U.jsx)(E,{amount:r.cap,mode:`short`})]})]})]}),r&&r.minSpend!==null&&(0,U.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,U.jsx)(G,{value:r.spend,max:r.minSpend,label:t(`cards.minSpend`)}),(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r.minMet?t(`cards.minMet`,{amount:y(r.minSpend,n)}):t(`cards.minNeed`,{amount:y(r.needForMin,n),min:y(r.minSpend,n)})})]}),i.length>0&&(0,U.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,U.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground`,children:t(`cards.last12`)}),(0,U.jsx)(`div`,{className:`flex h-40 flex-col`,children:(0,U.jsx)(L,{legend:[{label:t(`cards.earned`),color:F.accent},{label:t(`cards.expected`),color:F.second}],table:{head:[t(`chart.month`),t(`cards.earned`),t(`cards.expected`)],rows:i.map(e=>[e.label,y(e.received,n),y(e.expected,n)])},children:(0,U.jsx)(I,{data:i,xKey:`label`,series:[{key:`received`,label:t(`cards.earned`),color:F.accent},{key:`expected`,label:t(`cards.expected`),color:F.second}]})})})]})]})}function X({d:e,asOf:t}){let{t:n,lang:r}=l(),i=e.feeWaiver;return!i&&!e.terms.annualFee?null:(0,U.jsx)(D,{title:n(`cards.feeWaiver`),children:i?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(G,{value:i.spent,max:i.target,label:n(`cards.feeWaiver`)}),(0,U.jsxs)(`dl`,{className:`divide-y`,children:[(0,U.jsxs)(T,{label:n(`cards.spent`),children:[(0,U.jsx)(w,{filter:{account:e.account.id,from:i.yearFrom,to:t},children:(0,U.jsx)(E,{amount:i.spent})}),` `,(0,U.jsxs)(`span`,{className:`text-muted-foreground`,children:[`/ `,(0,U.jsx)(E,{amount:i.target,mode:`short`})]})]}),(0,U.jsxs)(T,{label:n(`cards.deadline`),children:[S(i.deadline,r),` `,(0,U.jsxs)(`span`,{className:`text-muted-foreground`,children:[`· `,n(`cards.daysLeft`,{n:i.daysLeft})]})]}),!i.met&&(0,U.jsx)(T,{label:n(`cards.perMonth`),children:(0,U.jsx)(E,{amount:i.perMonth})}),e.terms.annualFee?(0,U.jsx)(T,{label:n(`cards.annualFee`),children:(0,U.jsx)(E,{amount:e.terms.annualFee})}):null]}),(0,U.jsx)(`p`,{className:a(`text-sm font-medium`,i.met||i.onTrack?`text-foreground`:`text-critical`),children:i.met?n(`cards.feeMet`):i.onTrack?n(`cards.onTrack`):n(`cards.behind`)})]}):(0,U.jsxs)(`dl`,{children:[(0,U.jsx)(T,{label:n(`cards.annualFee`),children:(0,U.jsx)(E,{amount:e.terms.annualFee})}),(0,U.jsx)(`p`,{className:`py-1 text-sm text-muted-foreground`,children:n(`cards.noWaiver`)})]})})}function Z({d:e}){let{t}=l();return e.instalments.length===0?null:(0,U.jsx)(D,{title:t(`cards.instalments`),children:(0,U.jsx)(`ul`,{className:`flex flex-col gap-3`,children:e.instalments.map(e=>(0,U.jsxs)(`li`,{className:`flex flex-col gap-1`,children:[(0,U.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2 text-sm`,children:[(0,U.jsx)(w,{filter:{plan:e.plan},className:`min-w-0 truncate font-medium`,children:e.name}),(0,U.jsxs)(`span`,{className:`shrink-0 text-xs text-muted-foreground tabular-nums`,children:[e.paidCount,`/`,e.count??`–`]})]}),(0,U.jsx)(G,{value:e.paidCount,max:e.count??0,label:e.name}),(0,U.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[t(`cards.perMonthPay`),` `,(0,U.jsx)(E,{amount:e.perPayment,mode:`short`}),e.leftAmount!==null&&(0,U.jsxs)(U.Fragment,{children:[` · `,t(`cards.left`),` `,(0,U.jsx)(E,{amount:e.leftAmount,mode:`short`})]})]})]},e.plan))})})}function Q({d:e}){let{t,lang:n}=l(),r=e.record;if(!r)return(0,U.jsxs)(D,{title:t(`cards.lifecycle`),children:[(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t(`cards.noRecord`)}),(0,U.jsx)(d,{prompt:t(`ask.cardRecord`,{name:e.account.name})})]});let i=e=>e?S(e,n):null,a=[[t(`cards.issued`),i(r.issued)],[t(`cards.activated`),i(r.activated)],[t(`cards.lockedOn`),i(r.locked)],[t(`cards.cancelledOn`),i(r.cancelled)],[t(`cards.network`),r.network?r.network.toUpperCase():null],[t(`cards.form`),r.physical?t(`cards.physical.${r.physical}`):null]];return(0,U.jsxs)(D,{title:t(`cards.lifecycle`),action:(0,U.jsx)(A,{status:r.status??`active`}),children:[(0,U.jsxs)(`dl`,{className:`divide-y`,children:[a.filter(([,e])=>e).map(([e,t])=>(0,U.jsx)(T,{label:e,children:t},e)),r.annual_fee?(0,U.jsx)(T,{label:t(`cards.annualFee`),children:(0,U.jsx)(E,{amount:r.annual_fee})}):null,r.close_fee?(0,U.jsx)(T,{label:t(`cards.closeFee`),children:(0,U.jsx)(E,{amount:r.close_fee})}):null,r.keep_for_limit&&(0,U.jsx)(T,{label:t(`cards.keepForLimit`),children:t(`cards.yes`)})]}),r.cancel_plan&&(0,U.jsxs)(`div`,{className:`rounded-md bg-muted/60 p-3 text-sm`,children:[(0,U.jsx)(`p`,{className:`font-medium`,children:t(`cards.cancelPlan`,{by:r.cancel_plan.by??``})}),r.cancel_plan.note&&(0,U.jsx)(`p`,{className:`text-muted-foreground`,children:r.cancel_plan.note})]}),r.note&&(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:r.note})]})}function $({d:e}){let{t}=l(),n=e.value;return n?(0,U.jsx)(D,{title:t(`cards.netValue`),children:(0,U.jsxs)(`dl`,{className:`divide-y`,children:[(0,U.jsx)(T,{label:t(`cards.value.benefits`),children:(0,U.jsx)(E,{amount:n.benefits})}),(0,U.jsx)(T,{label:t(`cards.cashback`),children:(0,U.jsx)(E,{amount:n.cashback})}),(0,U.jsx)(T,{label:n.feesFrom===`record`?`${t(`cards.value.fees`)} (${t(`cards.value.estimated`)})`:t(`cards.value.fees`),children:(0,U.jsx)(E,{amount:-n.fees})}),n.closeFee>0&&(0,U.jsx)(T,{label:t(`cards.closeFee`),children:(0,U.jsx)(E,{amount:-n.closeFee})}),(0,U.jsx)(T,{label:t(`cards.value.sinceIssued`),className:`font-medium`,children:(0,U.jsx)(E,{amount:n.net,tone:`auto`})}),(0,U.jsx)(T,{label:t(`cards.value.last12`),className:`font-medium`,children:(0,U.jsx)(E,{amount:n.last12.net,tone:`auto`})})]})}):null}function ee({params:e}){let{t}=l(),n=decodeURIComponent(e.account),{data:r,error:i,isLoading:a}=c(n),[o,s]=(0,H.useState)(null),d=(0,U.jsxs)(`a`,{href:`#/cards`,className:`inline-flex min-h-11 items-center gap-1 self-start rounded-md text-sm text-muted-foreground outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50`,children:[(0,U.jsx)(V,{className:`size-4`,"aria-hidden":!0}),t(`cards.back`)]});if(i)return(0,U.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[d,(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:i instanceof u&&i.status===404?t(`cards.notFound`):t(`common.error`,{message:i.message})})]});if(a||!r)return(0,U.jsxs)(`div`,{className:`flex flex-col gap-3`,"aria-busy":`true`,children:[d,(0,U.jsx)(h,{className:`h-8 w-56`}),(0,U.jsx)(h,{className:`h-40 w-full`})]});let f=r.summary,p=r.record?.status??(r.account.closed?`cancelled`:`active`),m=r.terms.last4,g=[r.terms.bank,m?t(`cards.last4`,{n:m}):null].filter(Boolean).join(` · `);return(0,U.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[d,(0,U.jsxs)(`header`,{className:`flex flex-col gap-2`,children:[(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,U.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:r.account.name}),(0,U.jsx)(A,{status:p})]}),g&&(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:g}),f&&(0,U.jsx)(j,{owed:f.owed,limit:f.limit,atLeast:f.limitAtLeast,className:`max-w-md`}),f&&(0,U.jsx)(k,{card:f,className:`max-w-md`})]}),(0,U.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-[minmax(0,1fr)_22rem]`,children:[(0,U.jsx)(`div`,{className:`flex min-w-0 flex-col gap-4`,children:f?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(K,{d:r,asOf:r.asOf}),(0,U.jsx)(q,{s:f.last,id:r.account.id,asOf:r.asOf}),(0,U.jsx)(J,{list:r.statements,onOpen:s})]}):(0,U.jsx)(D,{title:t(`cards.statements`),children:(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t(`cards.noStatements`)})})}),(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-4`,children:[(0,U.jsx)(Y,{d:r}),(0,U.jsx)(X,{d:r,asOf:r.asOf}),(0,U.jsx)(Z,{d:r}),(0,U.jsx)(Q,{d:r}),(0,U.jsx)($,{d:r})]})]}),(0,U.jsx)(W,{account:r.account.id,close:o,onClose:()=>s(null)})]})}export{ee as default};
@@ -1 +1 @@
1
- import{B as e,I as t,L as n,a as r,u as i,w as a}from"./queries-C_4ufx4u.js";import{t as o}from"./Money-DCMKf898.js";import{a as s,i as c,n as l,o as u,r as d,s as f}from"./bits-BoWPOwTB.js";import{H as p,U as m,W as h,n as g,u as _}from"./index-DYyIpxqK.js";import{i as v,t as y}from"./cards-AZlSJQ0z.js";import{t as b}from"./drill-t1zr57xi.js";var x=e(t(),1),S=n();function C({label:e,amount:t,sub:n}){return(0,S.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5 rounded-xl border bg-card p-3`,children:[(0,S.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e}),(0,S.jsx)(o,{amount:t,mode:`short`,className:`text-xl font-semibold tracking-tight`}),n&&(0,S.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n})]})}function w({c:e}){let{t,lang:n}=a(),r=e.cashback,i=r&&(r.expected>0||r.spend>0||r.cap!==null);return(0,S.jsxs)(`li`,{className:`relative flex flex-col gap-2 rounded-xl border bg-card p-3 focus-within:ring-3 focus-within:ring-ring/50 hover:bg-muted/30`,children:[(0,S.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,S.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,S.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,S.jsx)(`a`,{href:y(e.account),className:`min-h-6 truncate rounded-md text-sm font-medium outline-none after:absolute after:inset-0 after:rounded-xl focus-visible:underline`,children:e.name}),(0,S.jsx)(l,{status:e.status})]}),(0,S.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:[e.bank,e.last4?t(`cards.last4`,{n:e.last4}):null].filter(Boolean).join(` · `)})]}),(0,S.jsx)(`div`,{className:`flex shrink-0 flex-col items-end`,children:e.toPay>0?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(o,{amount:e.toPay,mode:`short`,className:`text-base font-semibold`}),(0,S.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[e.due&&(0,S.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:g(e.due)}),(0,S.jsx)(d,{days:e.daysToDue})]})]}):(0,S.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t(`cards.nothingToPay`)})})]}),(0,S.jsx)(u,{owed:e.owed,limit:e.limit,atLeast:e.limitAtLeast}),(0,S.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-4 gap-y-1`,children:[e.last?(0,S.jsx)(s,{status:e.last.status}):(0,S.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t(`cards.noStatement`)}),i&&(0,S.jsxs)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,children:[t(`cards.cashbackShort`),` `,r.incomplete?t(`cards.rateNotSet`):(0,S.jsx)(o,{amount:r.expected,mode:`short`,className:`font-medium text-foreground`}),r.capLeft!==null&&(0,S.jsxs)(S.Fragment,{children:[` · `,t(`cards.capLeft`,{amount:_(r.capLeft,n)})]})]})]}),(0,S.jsx)(c,{card:e})]})}function T({r:e}){let{t}=a(),n=e.name??([e.bank,e.last4].filter(Boolean).join(` `)||e.id),r=[e.bank,e.network?.toUpperCase(),e.last4?t(`cards.last4`,{n:e.last4}):null,t(`cards.kind.${e.kind}`)].filter(Boolean).join(` · `),i=(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,S.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,S.jsx)(`span`,{className:`truncate text-sm font-medium`,children:n}),(0,S.jsx)(l,{status:e.status??`active`})]}),(0,S.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:r})]}),(0,S.jsx)(`span`,{className:`shrink-0 text-right text-xs text-muted-foreground`,children:e.annual_fee?(0,S.jsxs)(S.Fragment,{children:[t(`cards.annualFee`),` `,(0,S.jsx)(o,{amount:e.annual_fee,mode:`short`,className:`text-foreground`})]}):t(`cards.noFee`)})]});return(0,S.jsx)(`li`,{children:e.account?(0,S.jsx)(`a`,{href:b({account:e.account}),className:`flex min-h-11 items-center gap-3 rounded-md px-1 py-1.5 outline-none hover:bg-muted/50 focus-visible:ring-3 focus-visible:ring-ring/50`,children:i}):(0,S.jsx)(`div`,{className:`flex min-h-11 items-center gap-3 px-1 py-1.5`,children:i})})}function E(){let{t:e,lang:t}=a(),n=i().data,o=!!n?.features?.cards,[s,c]=(0,x.useState)(`active`),l=r(o,!1),u=r(o&&s===`cancelled`,!0),d=s===`cancelled`?u.data??l.data:l.data,g=l.error??(s===`cancelled`?u.error:null),y=(0,x.useMemo)(()=>(d?.cards??[]).filter(e=>v(e.status)===s),[d,s]),b=(0,x.useMemo)(()=>(d?.records??[]).filter(e=>e.kind!==`credit`&&v(e.status??`active`)===s),[d,s]),E=(l.data?.cards??[]).filter(e=>e.owed>0).length;if(!o&&n)return(0,S.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,S.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:e(`cards.title`)}),(0,S.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`cards.off`)})]});let D=l.data?.totals;return(0,S.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,S.jsxs)(`header`,{className:`flex flex-col gap-1`,children:[(0,S.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:e(`cards.title`)}),D?(0,S.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`cards.headline`,{owed:_(D.owed,t),n:E})}):(0,S.jsx)(h,{className:`h-5 w-64`})]}),g?(0,S.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`common.error`,{message:g.message})}):d?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`section`,{"aria-label":e(`cards.totals`),className:`grid grid-cols-3 gap-2`,children:[(0,S.jsx)(C,{label:e(`cards.owedAll`),amount:d.totals.owed}),(0,S.jsx)(C,{label:e(`cards.dueWeek`),amount:d.totals.dueWeek}),(0,S.jsx)(C,{label:e(`cards.dueMonth`),amount:d.totals.dueMonth})]}),(0,S.jsx)(p,{type:`single`,variant:`outline`,value:s,onValueChange:e=>e&&c(e),"aria-label":e(`cards.filter`),className:`self-start`,children:[`active`,`locked`,`cancelled`].map(t=>(0,S.jsx)(m,{value:t,className:`min-h-11 px-3 md:min-h-8`,children:e(`cards.group.${t}`)},t))}),(0,S.jsxs)(`section`,{className:`flex flex-col gap-3`,"aria-labelledby":`cards-credit`,children:[(0,S.jsx)(`h2`,{id:`cards-credit`,className:`text-base font-semibold`,children:e(`cards.credit`)}),y.length===0?(0,S.jsx)(`p`,{className:`rounded-lg border border-dashed p-4 text-sm text-muted-foreground`,children:e(`cards.emptyCredit`)}):(0,S.jsx)(`ul`,{className:`grid gap-3 lg:grid-cols-2 2xl:grid-cols-3`,children:y.map(e=>(0,S.jsx)(w,{c:e},e.account))})]}),b.length>0&&(0,S.jsxs)(`section`,{className:`flex flex-col gap-2`,"aria-labelledby":`cards-debit`,children:[(0,S.jsx)(`h2`,{id:`cards-debit`,className:`text-base font-semibold`,children:e(`cards.debit`)}),(0,S.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`cards.debitHint`)}),(0,S.jsx)(`ul`,{className:`flex flex-col divide-y rounded-xl border bg-card px-2`,children:b.map(e=>(0,S.jsx)(T,{r:e},e.id))})]}),d.values.length>0&&(0,S.jsxs)(`section`,{className:`flex flex-col gap-2`,"aria-labelledby":`cards-value`,children:[(0,S.jsx)(`h2`,{id:`cards-value`,className:`text-base font-semibold`,children:e(`widget.cards_value`)}),(0,S.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[e(`cards.value.hint`),` `,(0,S.jsx)(`span`,{children:e(`cards.value.total`,{amount:_(d.values.reduce((e,t)=>e+t.last12.net,0),t)})})]}),(0,S.jsx)(`div`,{className:`rounded-xl border bg-card px-3`,children:(0,S.jsx)(f,{values:d.values})})]})]}):(0,S.jsxs)(`div`,{className:`flex flex-col gap-3`,"aria-busy":`true`,children:[(0,S.jsx)(h,{className:`h-16 w-full`}),(0,S.jsx)(h,{className:`h-32 w-full`}),(0,S.jsx)(h,{className:`h-32 w-full`})]})]})}export{E as default};
1
+ import{B as e,I as t,L as n,a as r,u as i,w as a}from"./queries-BcMmmb36.js";import{t as o}from"./Money-BwLucm7P.js";import{a as s,i as c,n as l,o as u,r as d,s as f}from"./bits-D34d9IBm.js";import{H as p,U as m,W as h,n as g,u as _}from"./index-DBHFdsYB.js";import{i as v,t as y}from"./cards-Ct0jh73r.js";import{t as b}from"./drill-t1zr57xi.js";var x=e(t(),1),S=n();function C({label:e,amount:t,sub:n}){return(0,S.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5 rounded-xl border bg-card p-3`,children:[(0,S.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e}),(0,S.jsx)(o,{amount:t,mode:`short`,className:`text-xl font-semibold tracking-tight`}),n&&(0,S.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n})]})}function w({c:e}){let{t,lang:n}=a(),r=e.cashback,i=r&&(r.expected>0||r.spend>0||r.cap!==null);return(0,S.jsxs)(`li`,{className:`relative flex flex-col gap-2 rounded-xl border bg-card p-3 focus-within:ring-3 focus-within:ring-ring/50 hover:bg-muted/30`,children:[(0,S.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,S.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,S.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,S.jsx)(`a`,{href:y(e.account),className:`min-h-6 truncate rounded-md text-sm font-medium outline-none after:absolute after:inset-0 after:rounded-xl focus-visible:underline`,children:e.name}),(0,S.jsx)(l,{status:e.status})]}),(0,S.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:[e.bank,e.last4?t(`cards.last4`,{n:e.last4}):null].filter(Boolean).join(` · `)})]}),(0,S.jsx)(`div`,{className:`flex shrink-0 flex-col items-end`,children:e.toPay>0?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(o,{amount:e.toPay,mode:`short`,className:`text-base font-semibold`}),(0,S.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[e.due&&(0,S.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:g(e.due)}),(0,S.jsx)(d,{days:e.daysToDue})]})]}):(0,S.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t(`cards.nothingToPay`)})})]}),(0,S.jsx)(u,{owed:e.owed,limit:e.limit,atLeast:e.limitAtLeast}),(0,S.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-4 gap-y-1`,children:[e.last?(0,S.jsx)(s,{status:e.last.status}):(0,S.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t(`cards.noStatement`)}),i&&(0,S.jsxs)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,children:[t(`cards.cashbackShort`),` `,r.incomplete?t(`cards.rateNotSet`):(0,S.jsx)(o,{amount:r.expected,mode:`short`,className:`font-medium text-foreground`}),r.capLeft!==null&&(0,S.jsxs)(S.Fragment,{children:[` · `,t(`cards.capLeft`,{amount:_(r.capLeft,n)})]})]})]}),(0,S.jsx)(c,{card:e})]})}function T({r:e}){let{t}=a(),n=e.name??([e.bank,e.last4].filter(Boolean).join(` `)||e.id),r=[e.bank,e.network?.toUpperCase(),e.last4?t(`cards.last4`,{n:e.last4}):null,t(`cards.kind.${e.kind}`)].filter(Boolean).join(` · `),i=(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,S.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,S.jsx)(`span`,{className:`truncate text-sm font-medium`,children:n}),(0,S.jsx)(l,{status:e.status??`active`})]}),(0,S.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:r})]}),(0,S.jsx)(`span`,{className:`shrink-0 text-right text-xs text-muted-foreground`,children:e.annual_fee?(0,S.jsxs)(S.Fragment,{children:[t(`cards.annualFee`),` `,(0,S.jsx)(o,{amount:e.annual_fee,mode:`short`,className:`text-foreground`})]}):t(`cards.noFee`)})]});return(0,S.jsx)(`li`,{children:e.account?(0,S.jsx)(`a`,{href:b({account:e.account}),className:`flex min-h-11 items-center gap-3 rounded-md px-1 py-1.5 outline-none hover:bg-muted/50 focus-visible:ring-3 focus-visible:ring-ring/50`,children:i}):(0,S.jsx)(`div`,{className:`flex min-h-11 items-center gap-3 px-1 py-1.5`,children:i})})}function E(){let{t:e,lang:t}=a(),n=i().data,o=!!n?.features?.cards,[s,c]=(0,x.useState)(`active`),l=r(o,!1),u=r(o&&s===`cancelled`,!0),d=s===`cancelled`?u.data??l.data:l.data,g=l.error??(s===`cancelled`?u.error:null),y=(0,x.useMemo)(()=>(d?.cards??[]).filter(e=>v(e.status)===s),[d,s]),b=(0,x.useMemo)(()=>(d?.records??[]).filter(e=>e.kind!==`credit`&&v(e.status??`active`)===s),[d,s]),E=(l.data?.cards??[]).filter(e=>e.owed>0).length;if(!o&&n)return(0,S.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,S.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:e(`cards.title`)}),(0,S.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`cards.off`)})]});let D=l.data?.totals;return(0,S.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,S.jsxs)(`header`,{className:`flex flex-col gap-1`,children:[(0,S.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:e(`cards.title`)}),D?(0,S.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`cards.headline`,{owed:_(D.owed,t),n:E})}):(0,S.jsx)(h,{className:`h-5 w-64`})]}),g?(0,S.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`common.error`,{message:g.message})}):d?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`section`,{"aria-label":e(`cards.totals`),className:`grid grid-cols-3 gap-2`,children:[(0,S.jsx)(C,{label:e(`cards.owedAll`),amount:d.totals.owed}),(0,S.jsx)(C,{label:e(`cards.dueWeek`),amount:d.totals.dueWeek}),(0,S.jsx)(C,{label:e(`cards.dueMonth`),amount:d.totals.dueMonth})]}),(0,S.jsx)(p,{type:`single`,variant:`outline`,value:s,onValueChange:e=>e&&c(e),"aria-label":e(`cards.filter`),className:`self-start`,children:[`active`,`locked`,`cancelled`].map(t=>(0,S.jsx)(m,{value:t,className:`min-h-11 px-3 md:min-h-8`,children:e(`cards.group.${t}`)},t))}),(0,S.jsxs)(`section`,{className:`flex flex-col gap-3`,"aria-labelledby":`cards-credit`,children:[(0,S.jsx)(`h2`,{id:`cards-credit`,className:`text-base font-semibold`,children:e(`cards.credit`)}),y.length===0?(0,S.jsx)(`p`,{className:`rounded-lg border border-dashed p-4 text-sm text-muted-foreground`,children:e(`cards.emptyCredit`)}):(0,S.jsx)(`ul`,{className:`grid gap-3 lg:grid-cols-2 2xl:grid-cols-3`,children:y.map(e=>(0,S.jsx)(w,{c:e},e.account))})]}),b.length>0&&(0,S.jsxs)(`section`,{className:`flex flex-col gap-2`,"aria-labelledby":`cards-debit`,children:[(0,S.jsx)(`h2`,{id:`cards-debit`,className:`text-base font-semibold`,children:e(`cards.debit`)}),(0,S.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`cards.debitHint`)}),(0,S.jsx)(`ul`,{className:`flex flex-col divide-y rounded-xl border bg-card px-2`,children:b.map(e=>(0,S.jsx)(T,{r:e},e.id))})]}),d.values.length>0&&(0,S.jsxs)(`section`,{className:`flex flex-col gap-2`,"aria-labelledby":`cards-value`,children:[(0,S.jsx)(`h2`,{id:`cards-value`,className:`text-base font-semibold`,children:e(`widget.cards_value`)}),(0,S.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[e(`cards.value.hint`),` `,(0,S.jsx)(`span`,{children:e(`cards.value.total`,{amount:_(d.values.reduce((e,t)=>e+t.last12.net,0),t)})})]}),(0,S.jsx)(`div`,{className:`rounded-xl border bg-card px-3`,children:(0,S.jsx)(f,{values:d.values})})]})]}):(0,S.jsxs)(`div`,{className:`flex flex-col gap-3`,"aria-busy":`true`,children:[(0,S.jsx)(h,{className:`h-16 w-full`}),(0,S.jsx)(h,{className:`h-32 w-full`}),(0,S.jsx)(h,{className:`h-32 w-full`})]})]})}export{E as default};
@@ -1 +1 @@
1
- import{t as e}from"./Money-DCMKf898.js";import{o as t,r as n}from"./bits-BoWPOwTB.js";import{M as r,n as i}from"./index-DYyIpxqK.js";import{L as a,a as o,u as s,w as c}from"./queries-C_4ufx4u.js";import{t as l}from"./cards-AZlSJQ0z.js";import{n as u}from"./shared-CR-hvb-r.js";var d=a(),f=8;function p({widget:a,menu:p}){let{t:m}=c(),h=u(a,`widget.cards`),g=!!s().data?.features?.cards,{data:_,error:v,isLoading:y}=o(g),b=(_?.cards??[]).filter(e=>e.status!==`cancelled`);return(0,d.jsxs)(r,{title:h,titleHref:`#/cards`,menu:p,loading:g&&y,error:g?v?.message:void 0,empty:!g||_&&b.length===0?m(`cards.emptyCredit`):void 0,children:[(0,d.jsx)(`ul`,{className:`flex flex-col divide-y`,children:b.slice(0,f).map(r=>(0,d.jsxs)(`li`,{className:`flex flex-col gap-1.5 py-2`,children:[(0,d.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2`,children:[(0,d.jsx)(`a`,{href:l(r.account),className:`min-w-0 truncate rounded-md text-sm font-medium outline-none hover:underline focus-visible:ring-3 focus-visible:ring-ring/50`,children:r.name}),r.toPay>0?(0,d.jsxs)(`span`,{className:`flex shrink-0 items-baseline gap-2`,children:[(0,d.jsx)(e,{amount:r.toPay,mode:`short`,className:`text-sm font-medium`}),r.due&&(0,d.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:i(r.due)}),(0,d.jsx)(n,{days:r.daysToDue})]}):(0,d.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:m(`cards.nothingToPay`)})]}),(0,d.jsx)(t,{owed:r.owed,limit:r.limit,atLeast:r.limitAtLeast})]},r.account))}),b.length>f&&(0,d.jsx)(`a`,{href:`#/cards`,className:`min-h-11 self-start py-2 text-sm underline`,children:m(`attention.seeAll`,{n:b.length})})]})}export{p as default};
1
+ import{t as e}from"./Money-BwLucm7P.js";import{o as t,r as n}from"./bits-D34d9IBm.js";import{M as r,n as i}from"./index-DBHFdsYB.js";import{L as a,a as o,u as s,w as c}from"./queries-BcMmmb36.js";import{t as l}from"./cards-Ct0jh73r.js";import{n as u}from"./shared-BgU6fc7z.js";var d=a(),f=8;function p({widget:a,menu:p}){let{t:m}=c(),h=u(a,`widget.cards`),g=!!s().data?.features?.cards,{data:_,error:v,isLoading:y}=o(g),b=(_?.cards??[]).filter(e=>e.status!==`cancelled`);return(0,d.jsxs)(r,{title:h,titleHref:`#/cards`,menu:p,loading:g&&y,error:g?v?.message:void 0,empty:!g||_&&b.length===0?m(`cards.emptyCredit`):void 0,children:[(0,d.jsx)(`ul`,{className:`flex flex-col divide-y`,children:b.slice(0,f).map(r=>(0,d.jsxs)(`li`,{className:`flex flex-col gap-1.5 py-2`,children:[(0,d.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2`,children:[(0,d.jsx)(`a`,{href:l(r.account),className:`min-w-0 truncate rounded-md text-sm font-medium outline-none hover:underline focus-visible:ring-3 focus-visible:ring-ring/50`,children:r.name}),r.toPay>0?(0,d.jsxs)(`span`,{className:`flex shrink-0 items-baseline gap-2`,children:[(0,d.jsx)(e,{amount:r.toPay,mode:`short`,className:`text-sm font-medium`}),r.due&&(0,d.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:i(r.due)}),(0,d.jsx)(n,{days:r.daysToDue})]}):(0,d.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:m(`cards.nothingToPay`)})]}),(0,d.jsx)(t,{owed:r.owed,limit:r.limit,atLeast:r.limitAtLeast})]},r.account))}),b.length>f&&(0,d.jsx)(`a`,{href:`#/cards`,className:`min-h-11 self-start py-2 text-sm underline`,children:m(`attention.seeAll`,{n:b.length})})]})}export{p as default};
@@ -1 +1 @@
1
- import{s as e}from"./bits-BoWPOwTB.js";import{M as t}from"./index-DYyIpxqK.js";import{L as n,a as r,u as i,w as a}from"./queries-C_4ufx4u.js";import{n as o}from"./shared-CR-hvb-r.js";var s=n();function c({widget:n,menu:c}){let{t:l}=a(),u=o(n,`widget.cards_value`),d=!!i().data?.features?.cards,{data:f,error:p,isLoading:m}=r(d),h=f?.values??[];return(0,s.jsxs)(t,{title:u,titleHref:`#/cards`,menu:c,loading:d&&m,error:d?p?.message:void 0,empty:!d||f&&h.length===0?l(`cards.value.empty`):void 0,children:[(0,s.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:l(`cards.value.hint`)}),(0,s.jsx)(e,{values:h,limit:8,compact:!0})]})}export{c as default};
1
+ import{s as e}from"./bits-D34d9IBm.js";import{M as t}from"./index-DBHFdsYB.js";import{L as n,a as r,u as i,w as a}from"./queries-BcMmmb36.js";import{n as o}from"./shared-BgU6fc7z.js";var s=n();function c({widget:n,menu:c}){let{t:l}=a(),u=o(n,`widget.cards_value`),d=!!i().data?.features?.cards,{data:f,error:p,isLoading:m}=r(d),h=f?.values??[];return(0,s.jsxs)(t,{title:u,titleHref:`#/cards`,menu:c,loading:d&&m,error:d?p?.message:void 0,empty:!d||f&&h.length===0?l(`cards.value.empty`):void 0,children:[(0,s.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:l(`cards.value.hint`)}),(0,s.jsx)(e,{values:h,limit:8,compact:!0})]})}export{c as default};
@@ -1 +1 @@
1
- import{t as e}from"./Money-DCMKf898.js";import{M as t,u as n}from"./index-DYyIpxqK.js";import{L as r,a as i,u as a,w as o}from"./queries-C_4ufx4u.js";import{t as s}from"./cards-AZlSJQ0z.js";import{n as c}from"./shared-CR-hvb-r.js";var l=r();function u({widget:r,menu:u}){let{t:d,lang:f}=o(),p=c(r,`widget.cashback`),m=!!a().data?.features?.cards,{data:h,error:g,isLoading:_}=i(m),v=(h?.cards??[]).filter(e=>e.status!==`cancelled`&&e.cashback&&(e.cashback.cap!==null||e.cashback.expected>0||e.cashback.spend>0||e.cashback.incomplete)),y=v.reduce((e,t)=>e+(t.cashback?.expected??0),0);return(0,l.jsxs)(t,{title:p,titleHref:`#/cards`,menu:u,loading:m&&_,error:m?g?.message:void 0,empty:!m||h&&v.length===0?d(`cashback.empty`):void 0,children:[(0,l.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[d(`cashback.total`),` `,(0,l.jsx)(e,{amount:y,mode:`short`,className:`font-medium text-foreground`})]}),(0,l.jsx)(`ul`,{className:`flex flex-col divide-y`,children:v.map(t=>{let r=t.cashback,i=r.cap?Math.min(1,(r.cap-(r.capLeft??r.cap))/r.cap):0;return(0,l.jsxs)(`li`,{className:`flex flex-col gap-1 py-2`,children:[(0,l.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2`,children:[(0,l.jsx)(`a`,{href:s(t.account),className:`min-w-0 truncate rounded-md text-sm font-medium outline-none hover:underline focus-visible:ring-3 focus-visible:ring-ring/50`,children:t.name}),r.incomplete?(0,l.jsx)(`span`,{className:`shrink-0 text-xs text-warning`,children:d(`cards.rateNotSet`)}):(0,l.jsx)(e,{amount:r.expected,mode:`short`,className:`shrink-0 text-sm font-medium`})]}),r.cap!==null&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`div`,{role:`progressbar`,"aria-label":d(`cards.capLeftLabel`),"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(i*100),className:`h-1.5 w-full rounded-full bg-muted`,children:(0,l.jsx)(`div`,{className:`h-1.5 rounded-full bg-[var(--chart-1)]`,style:{width:`${Math.max(i?2:0,i*100)}%`}})}),(0,l.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:d(`cards.capLeft`,{amount:n(r.capLeft??r.cap,f)})})]})]},t.account)})})]})}export{u as default};
1
+ import{t as e}from"./Money-BwLucm7P.js";import{M as t,u as n}from"./index-DBHFdsYB.js";import{L as r,a as i,u as a,w as o}from"./queries-BcMmmb36.js";import{t as s}from"./cards-Ct0jh73r.js";import{n as c}from"./shared-BgU6fc7z.js";var l=r();function u({widget:r,menu:u}){let{t:d,lang:f}=o(),p=c(r,`widget.cashback`),m=!!a().data?.features?.cards,{data:h,error:g,isLoading:_}=i(m),v=(h?.cards??[]).filter(e=>e.status!==`cancelled`&&e.cashback&&(e.cashback.cap!==null||e.cashback.expected>0||e.cashback.spend>0||e.cashback.incomplete)),y=v.reduce((e,t)=>e+(t.cashback?.expected??0),0);return(0,l.jsxs)(t,{title:p,titleHref:`#/cards`,menu:u,loading:m&&_,error:m?g?.message:void 0,empty:!m||h&&v.length===0?d(`cashback.empty`):void 0,children:[(0,l.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[d(`cashback.total`),` `,(0,l.jsx)(e,{amount:y,mode:`short`,className:`font-medium text-foreground`})]}),(0,l.jsx)(`ul`,{className:`flex flex-col divide-y`,children:v.map(t=>{let r=t.cashback,i=r.cap?Math.min(1,(r.cap-(r.capLeft??r.cap))/r.cap):0;return(0,l.jsxs)(`li`,{className:`flex flex-col gap-1 py-2`,children:[(0,l.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2`,children:[(0,l.jsx)(`a`,{href:s(t.account),className:`min-w-0 truncate rounded-md text-sm font-medium outline-none hover:underline focus-visible:ring-3 focus-visible:ring-ring/50`,children:t.name}),r.incomplete?(0,l.jsx)(`span`,{className:`shrink-0 text-xs text-warning`,children:d(`cards.rateNotSet`)}):(0,l.jsx)(e,{amount:r.expected,mode:`short`,className:`shrink-0 text-sm font-medium`})]}),r.cap!==null&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`div`,{role:`progressbar`,"aria-label":d(`cards.capLeftLabel`),"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(i*100),className:`h-1.5 w-full rounded-full bg-muted`,children:(0,l.jsx)(`div`,{className:`h-1.5 rounded-full bg-[var(--chart-1)]`,style:{width:`${Math.max(i?2:0,i*100)}%`}})}),(0,l.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:d(`cards.capLeft`,{amount:n(r.capLeft??r.cap,f)})})]})]},t.account)})})]})}export{u as default};
@@ -1 +1 @@
1
- import{t as e}from"./createLucideIcon-DUW9Fpzj.js";import{$ as t,Q as n,rt as r}from"./index-DYyIpxqK.js";import{L as i,T as a}from"./queries-C_4ufx4u.js";var o={name:`banknote`,size:24,node:[[`rect`,{width:`20`,height:`12`,x:`2`,y:`6`,rx:`2`,key:`9lu3g6`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}],[`path`,{d:`M6 12h.01M18 12h.01`,key:`113zkx`}]]};o.node;var s=e(o),c={name:`car`,size:24,node:[[`path`,{d:`M19 17h2c.6 0 1-.4 1-1v-3c0-.9-.7-1.7-1.5-1.9C18.7 10.6 16 10 16 10s-1.3-1.4-2.2-2.3c-.5-.4-1.1-.7-1.8-.7H5c-.6 0-1.1.4-1.4.9l-1.4 2.9A3.7 3.7 0 0 0 2 12v4c0 .6.4 1 1 1h2`,key:`5owen`}],[`circle`,{cx:`7`,cy:`17`,r:`2`,key:`u2ysq9`}],[`path`,{d:`M9 17h6`,key:`r8uit2`}],[`circle`,{cx:`17`,cy:`17`,r:`2`,key:`axvx0g`}]]};c.node;var l=e(c),u={name:`circle-ellipsis`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M17 12h.01`,key:`1m0b6t`}],[`path`,{d:`M12 12h.01`,key:`1mp3jc`}],[`path`,{d:`M7 12h.01`,key:`eqddd0`}]]};u.node;var d=e(u),f={name:`circle-plus`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M8 12h8`,key:`1wcyev`}],[`path`,{d:`M12 8v8`,key:`napkw2`}]],aliases:[`plus-circle`]};f.node;var p=e(f),m={name:`gamepad-2`,size:24,node:[[`line`,{x1:`6`,x2:`10`,y1:`11`,y2:`11`,key:`1gktln`}],[`line`,{x1:`8`,x2:`8`,y1:`9`,y2:`13`,key:`qnk9ow`}],[`line`,{x1:`15`,x2:`15.01`,y1:`12`,y2:`12`,key:`krot7o`}],[`line`,{x1:`18`,x2:`18.01`,y1:`10`,y2:`10`,key:`1lcuu1`}],[`path`,{d:`M17.32 5H6.68a4 4 0 0 0-3.978 3.59c-.006.052-.01.101-.017.152C2.604 9.416 2 14.456 2 16a3 3 0 0 0 3 3c1 0 1.5-.5 2-1l1.414-1.414A2 2 0 0 1 9.828 16h4.344a2 2 0 0 1 1.414.586L17 18c.5.5 1 1 2 1a3 3 0 0 0 3-3c0-1.545-.604-6.584-.685-7.258-.007-.05-.011-.1-.017-.151A4 4 0 0 0 17.32 5z`,key:`mfqc10`}]]};m.node;var h=e(m),g={name:`gift`,size:24,node:[[`path`,{d:`M12 7v14`,key:`1akyts`}],[`path`,{d:`M20 11v8a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-8`,key:`1sqzm4`}],[`path`,{d:`M7.5 7a1 1 0 0 1 0-5A4.8 8 0 0 1 12 7a4.8 8 0 0 1 4.5-5 1 1 0 0 1 0 5`,key:`kc0143`}],[`rect`,{x:`3`,y:`7`,width:`18`,height:`4`,rx:`1`,key:`1hberx`}]]};g.node;var _=e(g),v={name:`graduation-cap`,size:24,node:[[`path`,{d:`M21.42 10.922a1 1 0 0 0-.019-1.838L12.83 5.18a2 2 0 0 0-1.66 0L2.6 9.08a1 1 0 0 0 0 1.832l8.57 3.908a2 2 0 0 0 1.66 0z`,key:`j76jl0`}],[`path`,{d:`M22 10v6`,key:`1lu8f3`}],[`path`,{d:`M6 12.5V16a6 3 0 0 0 12 0v-3.5`,key:`1r8lef`}]]};v.node;var y=e(v),b={name:`hand-coins`,size:24,node:[[`path`,{d:`M11 15h2a2 2 0 1 0 0-4h-3c-.6 0-1.1.2-1.4.6L3 17`,key:`geh8rc`}],[`path`,{d:`m7 21 1.6-1.4c.3-.4.8-.6 1.4-.6h4c1.1 0 2.1-.4 2.8-1.2l4.6-4.4a2 2 0 0 0-2.75-2.91l-4.2 3.9`,key:`1fto5m`}],[`path`,{d:`m2 16 6 6`,key:`1pfhp9`}],[`circle`,{cx:`16`,cy:`9`,r:`2.9`,key:`1n0dlu`}],[`circle`,{cx:`6`,cy:`5`,r:`3`,key:`151irh`}]]};b.node;var x=e(b),S={name:`heart-pulse`,size:24,node:[[`path`,{d:`M2 9.5a5.5 5.5 0 0 1 9.591-3.676.56.56 0 0 0 .818 0A5.49 5.49 0 0 1 22 9.5c0 2.29-1.5 4-3 5.5l-5.492 5.313a2 2 0 0 1-3 .019L5 15c-1.5-1.5-3-3.2-3-5.5`,key:`mvr1a0`}],[`path`,{d:`M3.22 13H9.5l.5-1 2 4.5 2-7 1.5 3.5h5.27`,key:`auskq0`}]]};S.node;var C=e(S),w={name:`laptop`,size:24,node:[[`path`,{d:`M18 5a2 2 0 0 1 2 2v8.526a2 2 0 0 0 .212.897l1.068 2.127a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45l1.068-2.127A2 2 0 0 0 4 15.526V7a2 2 0 0 1 2-2z`,key:`1pdavp`}],[`path`,{d:`M20.054 15.987H3.946`,key:`14rxg9`}]]};w.node;var T=e(w),E={name:`percent`,size:24,node:[[`line`,{x1:`19`,x2:`5`,y1:`5`,y2:`19`,key:`1x9vlm`}],[`circle`,{cx:`6.5`,cy:`6.5`,r:`2.5`,key:`4mh3h7`}],[`circle`,{cx:`17.5`,cy:`17.5`,r:`2.5`,key:`1mdrzq`}]]};E.node;var D=e(E),O={name:`repeat`,size:24,node:[[`path`,{d:`m17 2 4 4-4 4`,key:`nntrym`}],[`path`,{d:`M3 11v-1a4 4 0 0 1 4-4h14`,key:`84bu3i`}],[`path`,{d:`m7 22-4-4 4-4`,key:`1wqhfi`}],[`path`,{d:`M21 13v1a4 4 0 0 1-4 4H3`,key:`1rx37r`}]]};O.node;var k=e(O),A={name:`shopping-bag`,size:24,node:[[`path`,{d:`M16 10a4 4 0 0 1-8 0`,key:`1ltviw`}],[`path`,{d:`M3.103 6.034h17.794`,key:`awc11p`}],[`path`,{d:`M3.4 5.467a2 2 0 0 0-.4 1.2V20a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6.667a2 2 0 0 0-.4-1.2l-2-2.667A2 2 0 0 0 17 2H7a2 2 0 0 0-1.6.8z`,key:`o988cm`}]]};A.node;var j=e(A),M={name:`users`,size:24,node:[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]};M.node;var N=e(M),P={name:`utensils`,size:24,node:[[`path`,{d:`M3 2v7c0 1.1.9 2 2 2h4a2 2 0 0 0 2-2V2`,key:`cjf0a3`}],[`path`,{d:`M7 2v20`,key:`1473qp`}],[`path`,{d:`M21 15V2a5 5 0 0 0-5 5v6c0 1.1.9 2 2 2h3Zm0 0v7`,key:`j28e5`}]],aliases:[`fork-knife`]};P.node;var F=e(P),I={name:`wrench`,size:24,node:[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z`,key:`1ngwbx`}]]};I.node;var L=e(I),R=i(),z={food:F,transport:l,home:t,family:N,health:C,shopping:j,fun:h,learning:y,"work-tools":L,subscriptions:k,"bank-fees":n,other:d,salary:s,freelance:T,interest:D,cashback:x,"gifts-received":_,"other-income":p},B=[`bg-sky-100 text-sky-800 dark:bg-sky-950 dark:text-sky-200`,`bg-amber-100 text-amber-900 dark:bg-amber-950 dark:text-amber-200`,`bg-emerald-100 text-emerald-800 dark:bg-emerald-950 dark:text-emerald-200`,`bg-violet-100 text-violet-800 dark:bg-violet-950 dark:text-violet-200`,`bg-rose-100 text-rose-800 dark:bg-rose-950 dark:text-rose-200`,`bg-teal-100 text-teal-800 dark:bg-teal-950 dark:text-teal-200`];function V(e){let t=0;for(let n of e)t=t*31+n.charCodeAt(0)>>>0;return t}function H({category:e,name:t,transfer:n,className:r}){let i=`flex size-9 shrink-0 items-center justify-center rounded-full`;if(n)return(0,R.jsx)(`span`,{"aria-hidden":!0,className:a(i,`bg-muted text-muted-foreground`,r),children:(0,R.jsx)(U,{})});let o=(e??`other`).split(`/`)[0],s=z[o];if(s)return(0,R.jsx)(`span`,{"aria-hidden":!0,className:a(i,`bg-muted text-foreground`,r),children:(0,R.jsx)(s,{className:`size-4`})});let c=([...t??o][0]??`?`).toUpperCase();return(0,R.jsx)(`span`,{"aria-hidden":!0,className:a(i,`text-sm font-medium`,B[V(o)%B.length],r),children:c})}var U=()=>(0,R.jsx)(r,{className:`size-4`});export{H as t};
1
+ import{t as e}from"./createLucideIcon-XZ28znwT.js";import{$ as t,Q as n,rt as r}from"./index-DBHFdsYB.js";import{L as i,T as a}from"./queries-BcMmmb36.js";var o={name:`banknote`,size:24,node:[[`rect`,{width:`20`,height:`12`,x:`2`,y:`6`,rx:`2`,key:`9lu3g6`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}],[`path`,{d:`M6 12h.01M18 12h.01`,key:`113zkx`}]]};o.node;var s=e(o),c={name:`car`,size:24,node:[[`path`,{d:`M19 17h2c.6 0 1-.4 1-1v-3c0-.9-.7-1.7-1.5-1.9C18.7 10.6 16 10 16 10s-1.3-1.4-2.2-2.3c-.5-.4-1.1-.7-1.8-.7H5c-.6 0-1.1.4-1.4.9l-1.4 2.9A3.7 3.7 0 0 0 2 12v4c0 .6.4 1 1 1h2`,key:`5owen`}],[`circle`,{cx:`7`,cy:`17`,r:`2`,key:`u2ysq9`}],[`path`,{d:`M9 17h6`,key:`r8uit2`}],[`circle`,{cx:`17`,cy:`17`,r:`2`,key:`axvx0g`}]]};c.node;var l=e(c),u={name:`circle-ellipsis`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M17 12h.01`,key:`1m0b6t`}],[`path`,{d:`M12 12h.01`,key:`1mp3jc`}],[`path`,{d:`M7 12h.01`,key:`eqddd0`}]]};u.node;var d=e(u),f={name:`circle-plus`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M8 12h8`,key:`1wcyev`}],[`path`,{d:`M12 8v8`,key:`napkw2`}]],aliases:[`plus-circle`]};f.node;var p=e(f),m={name:`gamepad-2`,size:24,node:[[`line`,{x1:`6`,x2:`10`,y1:`11`,y2:`11`,key:`1gktln`}],[`line`,{x1:`8`,x2:`8`,y1:`9`,y2:`13`,key:`qnk9ow`}],[`line`,{x1:`15`,x2:`15.01`,y1:`12`,y2:`12`,key:`krot7o`}],[`line`,{x1:`18`,x2:`18.01`,y1:`10`,y2:`10`,key:`1lcuu1`}],[`path`,{d:`M17.32 5H6.68a4 4 0 0 0-3.978 3.59c-.006.052-.01.101-.017.152C2.604 9.416 2 14.456 2 16a3 3 0 0 0 3 3c1 0 1.5-.5 2-1l1.414-1.414A2 2 0 0 1 9.828 16h4.344a2 2 0 0 1 1.414.586L17 18c.5.5 1 1 2 1a3 3 0 0 0 3-3c0-1.545-.604-6.584-.685-7.258-.007-.05-.011-.1-.017-.151A4 4 0 0 0 17.32 5z`,key:`mfqc10`}]]};m.node;var h=e(m),g={name:`gift`,size:24,node:[[`path`,{d:`M12 7v14`,key:`1akyts`}],[`path`,{d:`M20 11v8a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-8`,key:`1sqzm4`}],[`path`,{d:`M7.5 7a1 1 0 0 1 0-5A4.8 8 0 0 1 12 7a4.8 8 0 0 1 4.5-5 1 1 0 0 1 0 5`,key:`kc0143`}],[`rect`,{x:`3`,y:`7`,width:`18`,height:`4`,rx:`1`,key:`1hberx`}]]};g.node;var _=e(g),v={name:`graduation-cap`,size:24,node:[[`path`,{d:`M21.42 10.922a1 1 0 0 0-.019-1.838L12.83 5.18a2 2 0 0 0-1.66 0L2.6 9.08a1 1 0 0 0 0 1.832l8.57 3.908a2 2 0 0 0 1.66 0z`,key:`j76jl0`}],[`path`,{d:`M22 10v6`,key:`1lu8f3`}],[`path`,{d:`M6 12.5V16a6 3 0 0 0 12 0v-3.5`,key:`1r8lef`}]]};v.node;var y=e(v),b={name:`hand-coins`,size:24,node:[[`path`,{d:`M11 15h2a2 2 0 1 0 0-4h-3c-.6 0-1.1.2-1.4.6L3 17`,key:`geh8rc`}],[`path`,{d:`m7 21 1.6-1.4c.3-.4.8-.6 1.4-.6h4c1.1 0 2.1-.4 2.8-1.2l4.6-4.4a2 2 0 0 0-2.75-2.91l-4.2 3.9`,key:`1fto5m`}],[`path`,{d:`m2 16 6 6`,key:`1pfhp9`}],[`circle`,{cx:`16`,cy:`9`,r:`2.9`,key:`1n0dlu`}],[`circle`,{cx:`6`,cy:`5`,r:`3`,key:`151irh`}]]};b.node;var x=e(b),S={name:`heart-pulse`,size:24,node:[[`path`,{d:`M2 9.5a5.5 5.5 0 0 1 9.591-3.676.56.56 0 0 0 .818 0A5.49 5.49 0 0 1 22 9.5c0 2.29-1.5 4-3 5.5l-5.492 5.313a2 2 0 0 1-3 .019L5 15c-1.5-1.5-3-3.2-3-5.5`,key:`mvr1a0`}],[`path`,{d:`M3.22 13H9.5l.5-1 2 4.5 2-7 1.5 3.5h5.27`,key:`auskq0`}]]};S.node;var C=e(S),w={name:`laptop`,size:24,node:[[`path`,{d:`M18 5a2 2 0 0 1 2 2v8.526a2 2 0 0 0 .212.897l1.068 2.127a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45l1.068-2.127A2 2 0 0 0 4 15.526V7a2 2 0 0 1 2-2z`,key:`1pdavp`}],[`path`,{d:`M20.054 15.987H3.946`,key:`14rxg9`}]]};w.node;var T=e(w),E={name:`percent`,size:24,node:[[`line`,{x1:`19`,x2:`5`,y1:`5`,y2:`19`,key:`1x9vlm`}],[`circle`,{cx:`6.5`,cy:`6.5`,r:`2.5`,key:`4mh3h7`}],[`circle`,{cx:`17.5`,cy:`17.5`,r:`2.5`,key:`1mdrzq`}]]};E.node;var D=e(E),O={name:`repeat`,size:24,node:[[`path`,{d:`m17 2 4 4-4 4`,key:`nntrym`}],[`path`,{d:`M3 11v-1a4 4 0 0 1 4-4h14`,key:`84bu3i`}],[`path`,{d:`m7 22-4-4 4-4`,key:`1wqhfi`}],[`path`,{d:`M21 13v1a4 4 0 0 1-4 4H3`,key:`1rx37r`}]]};O.node;var k=e(O),A={name:`shopping-bag`,size:24,node:[[`path`,{d:`M16 10a4 4 0 0 1-8 0`,key:`1ltviw`}],[`path`,{d:`M3.103 6.034h17.794`,key:`awc11p`}],[`path`,{d:`M3.4 5.467a2 2 0 0 0-.4 1.2V20a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6.667a2 2 0 0 0-.4-1.2l-2-2.667A2 2 0 0 0 17 2H7a2 2 0 0 0-1.6.8z`,key:`o988cm`}]]};A.node;var j=e(A),M={name:`users`,size:24,node:[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]};M.node;var N=e(M),P={name:`utensils`,size:24,node:[[`path`,{d:`M3 2v7c0 1.1.9 2 2 2h4a2 2 0 0 0 2-2V2`,key:`cjf0a3`}],[`path`,{d:`M7 2v20`,key:`1473qp`}],[`path`,{d:`M21 15V2a5 5 0 0 0-5 5v6c0 1.1.9 2 2 2h3Zm0 0v7`,key:`j28e5`}]],aliases:[`fork-knife`]};P.node;var F=e(P),I={name:`wrench`,size:24,node:[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z`,key:`1ngwbx`}]]};I.node;var L=e(I),R=i(),z={food:F,transport:l,home:t,family:N,health:C,shopping:j,fun:h,learning:y,"work-tools":L,subscriptions:k,"bank-fees":n,other:d,salary:s,freelance:T,interest:D,cashback:x,"gifts-received":_,"other-income":p},B=[`bg-sky-100 text-sky-800 dark:bg-sky-950 dark:text-sky-200`,`bg-amber-100 text-amber-900 dark:bg-amber-950 dark:text-amber-200`,`bg-emerald-100 text-emerald-800 dark:bg-emerald-950 dark:text-emerald-200`,`bg-violet-100 text-violet-800 dark:bg-violet-950 dark:text-violet-200`,`bg-rose-100 text-rose-800 dark:bg-rose-950 dark:text-rose-200`,`bg-teal-100 text-teal-800 dark:bg-teal-950 dark:text-teal-200`];function V(e){let t=0;for(let n of e)t=t*31+n.charCodeAt(0)>>>0;return t}function H({category:e,name:t,transfer:n,className:r}){let i=`flex size-9 shrink-0 items-center justify-center rounded-full`;if(n)return(0,R.jsx)(`span`,{"aria-hidden":!0,className:a(i,`bg-muted text-muted-foreground`,r),children:(0,R.jsx)(U,{})});let o=(e??`other`).split(`/`)[0],s=z[o];if(s)return(0,R.jsx)(`span`,{"aria-hidden":!0,className:a(i,`bg-muted text-foreground`,r),children:(0,R.jsx)(s,{className:`size-4`})});let c=([...t??o][0]??`?`).toUpperCase();return(0,R.jsx)(`span`,{"aria-hidden":!0,className:a(i,`text-sm font-medium`,B[V(o)%B.length],r),children:c})}var U=()=>(0,R.jsx)(r,{className:`size-4`});export{H as t};
@@ -1 +1 @@
1
- import{B as e,I as t,L as n,d as r,w as i}from"./queries-C_4ufx4u.js";import{t as a}from"./Combobox-lRNTmjKR.js";var o=e(t(),1),s=n();function c(e,t){let n=(e?.categories??[]).filter(e=>!e.path.startsWith(`_`)&&(!t||e.kind===t)),r=e=>e.split(`/`).map((e,t,n)=>n.slice(0,t+1).join(`/`)),i=new Map(n.map((e,t)=>[e.path,t]));return[{options:[...n].sort((e,t)=>{let n=r(e.path).map(e=>i.get(e)??1e9),a=r(t.path).map(e=>i.get(e)??1e9);for(let e=0;e<Math.max(n.length,a.length);e++)if((n[e]??-1)!==(a[e]??-1))return(n[e]??-1)-(a[e]??-1);return 0}).map(e=>({value:e.path,label:e.name,depth:e.path.split(`/`).length-1,keywords:[e.path]}))}]}function l({value:e,onSelect:t,className:n}){let{t:l}=i(),u=r().data,d=(0,o.useMemo)(()=>c(u,`expense`),[u]);return(0,s.jsx)(a,{label:l(`filter.category`),groups:d,value:e,onSelect:t,className:n??`w-full`})}export{c as n,l as t};
1
+ import{B as e,I as t,L as n,d as r,w as i}from"./queries-BcMmmb36.js";import{t as a}from"./Combobox-BvX68J3o.js";var o=e(t(),1),s=n();function c(e,t){let n=(e?.categories??[]).filter(e=>!e.path.startsWith(`_`)&&(!t||e.kind===t)),r=e=>e.split(`/`).map((e,t,n)=>n.slice(0,t+1).join(`/`)),i=new Map(n.map((e,t)=>[e.path,t]));return[{options:[...n].sort((e,t)=>{let n=r(e.path).map(e=>i.get(e)??1e9),a=r(t.path).map(e=>i.get(e)??1e9);for(let e=0;e<Math.max(n.length,a.length);e++)if((n[e]??-1)!==(a[e]??-1))return(n[e]??-1)-(a[e]??-1);return 0}).map(e=>({value:e.path,label:e.name,depth:e.path.split(`/`).length-1,keywords:[e.path]}))}]}function l({value:e,onSelect:t,className:n}){let{t:l}=i(),u=r().data,d=(0,o.useMemo)(()=>c(u,`expense`),[u]);return(0,s.jsx)(a,{label:l(`filter.category`),groups:d,value:e,onSelect:t,className:n??`w-full`})}export{c as n,l as t};
@@ -1 +1 @@
1
- import{B as e,I as t,L as n,m as r,w as i}from"./queries-C_4ufx4u.js";import{a,i as o,n as s,r as c,t as l}from"./charts-Cj_hTR4h.js";import{t as u}from"./Money-DCMKf898.js";import{M as d,a as f,l as p,n as m}from"./index-DYyIpxqK.js";import{t as h}from"./drill-t1zr57xi.js";import{t as g}from"./shared-CR-hvb-r.js";var _=e(t(),1),v=n(),y=new Set([`day`,`week`,`month`]);function b(e,t,n,r){let i={from:r.from,to:r.to,category:e.category,account:Array.isArray(e.account)?void 0:e.account,who:e.who,event:e.event,tag:e.tag,text:e.text};switch(t){case`category`:case`top`:return h({...i,category:n});case`account`:return h({...i,account:n});case`who`:return h({...i,who:n});case`event`:return h({...i,event:n});case`tag`:return h({...i,tag:n});case`month`:{let[e,t]=n.split(`-`).map(Number);return h({...i,from:`${n}-01`,to:`${n}-${String(new Date(e,t,0).getDate()).padStart(2,`0`)}`})}case`day`:return h({...i,from:n,to:n});default:return}}function x({widget:e,menu:t}){let{t:n,lang:a}=i(),o=e.query,{data:s,error:c,isLoading:l}=r(o??{metric:`spending`},!!o),u=e.chart??`bar`,f=e.title?.trim()||n(`widget.chart`);return(0,v.jsx)(d,{title:f,menu:t,byAi:e.by_ai,loading:!!o&&l,error:o?c?.message:void 0,empty:o?s&&s.points.length===0&&u!==`stat`?n(`chart.empty`):void 0:n(`chart.noQuery`),children:s&&o&&(0,v.jsx)(S,{data:s,q:o,kind:u,lang:a})})}function S({data:e,q:t,kind:n,lang:r}){let{t:d}=i(),x=y.has(e.by),S=t.metric===`count`,w=t=>e.by===`month`?f(String(t)):m(String(t)),T=(0,_.useMemo)(()=>e.points.map(e=>({key:e.key,name:e.name,value:e.value,compare:e.compare??null})),[e]),E=T.some(e=>e.compare!==null),D={head:[d(`chart.item`),d(`chart.value`),...E?[d(`chart.compare`)]:[]],rows:T.map(e=>[x?w(e.key):e.name,p(e.value,r),...E?[p(e.compare??0,r)]:[]])},O=e=>S?(0,v.jsx)(`span`,{className:`tabular-nums`,children:p(e,r)}):(0,v.jsx)(u,{amount:e,mode:`short`});if(n===`stat`){let n=e.compareTotal?(e.total-e.compareTotal)/Math.abs(e.compareTotal)*100:null;return(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(`a`,{href:h({from:e.period.from,to:e.period.to,category:t.category,account:Array.isArray(t.account)?void 0:t.account,who:t.who,event:t.event,tag:t.tag,text:t.text}),className:`text-2xl font-semibold tracking-tight outline-none hover:underline focus-visible:ring-3 focus-visible:ring-ring/50`,children:S?p(e.total,r):(0,v.jsx)(u,{amount:e.total})}),n!==null&&(0,v.jsxs)(`p`,{className:`flex items-center gap-1 text-sm text-muted-foreground`,children:[(0,v.jsx)(g,{pct:n,goodWhenDown:t.metric===`spending`}),t.compare===`usual`?d(`pace.vsUsual`):d(`chart.vsPrevious`)]})]})}if(n===`table`)return(0,v.jsxs)(`table`,{className:`w-full text-sm tabular-nums`,children:[(0,v.jsx)(`thead`,{children:(0,v.jsx)(`tr`,{className:`text-left text-xs text-muted-foreground`,children:D.head.map((e,t)=>(0,v.jsx)(`th`,{className:`py-1 font-medium ${t>0?`text-right`:``}`,children:e},e))})}),(0,v.jsx)(`tbody`,{children:T.map((n,r)=>(0,v.jsxs)(`tr`,{className:`border-t`,children:[(0,v.jsx)(`td`,{className:`py-1.5`,children:(0,v.jsx)(`a`,{className:`hover:underline`,href:b(t,e.by,n.key,e.period),children:D.rows[r][0]})}),(0,v.jsx)(`td`,{className:`py-1.5 text-right`,children:O(n.value)}),E&&(0,v.jsx)(`td`,{className:`py-1.5 text-right text-muted-foreground`,children:O(n.compare??0)})]},n.key))})]});if(n===`hbar`)return(0,v.jsx)(c,{rows:T.map(n=>({key:n.key,name:x?w(n.key):n.name,value:n.value,label:O(n.value),href:b(t,e.by,n.key,e.period)}))});let k=[{key:`value`,label:C(t,d),color:a.accent},...E?[{key:`compare`,label:t.compare===`usual`?d(`pace.usual`):d(`chart.previous`),color:a.muted}]:[]];return(0,v.jsx)(l,{table:D,legend:k.map(e=>({label:e.label,color:e.color})),children:n===`line`?(0,v.jsx)(o,{data:T,xKey:`key`,formatX:x?w:e=>T.find(t=>t.key===e)?.name??String(e),specs:k.map(e=>({key:e.key,label:e.label,kind:`line`,color:e.color,width:e.key===`value`?2:1,dashed:e.key!==`value`}))}):(0,v.jsx)(s,{data:T.map(e=>({key:e.key,value:e.value,...E?{compare:e.compare??0}:{}})),xKey:`key`,formatX:x?w:e=>T.find(t=>t.key===e)?.name??String(e),series:k})})}function C(e,t){return t(`chart.metric.${e.metric}`)}export{x as default};
1
+ import{B as e,I as t,L as n,m as r,w as i}from"./queries-BcMmmb36.js";import{a,i as o,n as s,r as c,t as l}from"./charts-D-1glV8L.js";import{t as u}from"./Money-BwLucm7P.js";import{M as d,a as f,l as p,n as m}from"./index-DBHFdsYB.js";import{t as h}from"./drill-t1zr57xi.js";import{t as g}from"./shared-BgU6fc7z.js";var _=e(t(),1),v=n(),y=new Set([`day`,`week`,`month`]);function b(e,t,n,r){let i={from:r.from,to:r.to,category:e.category,account:Array.isArray(e.account)?void 0:e.account,who:e.who,event:e.event,tag:e.tag,text:e.text};switch(t){case`category`:case`top`:return h({...i,category:n});case`account`:return h({...i,account:n});case`who`:return h({...i,who:n});case`event`:return h({...i,event:n});case`tag`:return h({...i,tag:n});case`month`:{let[e,t]=n.split(`-`).map(Number);return h({...i,from:`${n}-01`,to:`${n}-${String(new Date(e,t,0).getDate()).padStart(2,`0`)}`})}case`day`:return h({...i,from:n,to:n});default:return}}function x({widget:e,menu:t}){let{t:n,lang:a}=i(),o=e.query,{data:s,error:c,isLoading:l}=r(o??{metric:`spending`},!!o),u=e.chart??`bar`,f=e.title?.trim()||n(`widget.chart`);return(0,v.jsx)(d,{title:f,menu:t,byAi:e.by_ai,loading:!!o&&l,error:o?c?.message:void 0,empty:o?s&&s.points.length===0&&u!==`stat`?n(`chart.empty`):void 0:n(`chart.noQuery`),children:s&&o&&(0,v.jsx)(S,{data:s,q:o,kind:u,lang:a})})}function S({data:e,q:t,kind:n,lang:r}){let{t:d}=i(),x=y.has(e.by),S=t.metric===`count`,w=t=>e.by===`month`?f(String(t)):m(String(t)),T=(0,_.useMemo)(()=>e.points.map(e=>({key:e.key,name:e.name,value:e.value,compare:e.compare??null})),[e]),E=T.some(e=>e.compare!==null),D={head:[d(`chart.item`),d(`chart.value`),...E?[d(`chart.compare`)]:[]],rows:T.map(e=>[x?w(e.key):e.name,p(e.value,r),...E?[p(e.compare??0,r)]:[]])},O=e=>S?(0,v.jsx)(`span`,{className:`tabular-nums`,children:p(e,r)}):(0,v.jsx)(u,{amount:e,mode:`short`});if(n===`stat`){let n=e.compareTotal?(e.total-e.compareTotal)/Math.abs(e.compareTotal)*100:null;return(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(`a`,{href:h({from:e.period.from,to:e.period.to,category:t.category,account:Array.isArray(t.account)?void 0:t.account,who:t.who,event:t.event,tag:t.tag,text:t.text}),className:`text-2xl font-semibold tracking-tight outline-none hover:underline focus-visible:ring-3 focus-visible:ring-ring/50`,children:S?p(e.total,r):(0,v.jsx)(u,{amount:e.total})}),n!==null&&(0,v.jsxs)(`p`,{className:`flex items-center gap-1 text-sm text-muted-foreground`,children:[(0,v.jsx)(g,{pct:n,goodWhenDown:t.metric===`spending`}),t.compare===`usual`?d(`pace.vsUsual`):d(`chart.vsPrevious`)]})]})}if(n===`table`)return(0,v.jsxs)(`table`,{className:`w-full text-sm tabular-nums`,children:[(0,v.jsx)(`thead`,{children:(0,v.jsx)(`tr`,{className:`text-left text-xs text-muted-foreground`,children:D.head.map((e,t)=>(0,v.jsx)(`th`,{className:`py-1 font-medium ${t>0?`text-right`:``}`,children:e},e))})}),(0,v.jsx)(`tbody`,{children:T.map((n,r)=>(0,v.jsxs)(`tr`,{className:`border-t`,children:[(0,v.jsx)(`td`,{className:`py-1.5`,children:(0,v.jsx)(`a`,{className:`hover:underline`,href:b(t,e.by,n.key,e.period),children:D.rows[r][0]})}),(0,v.jsx)(`td`,{className:`py-1.5 text-right`,children:O(n.value)}),E&&(0,v.jsx)(`td`,{className:`py-1.5 text-right text-muted-foreground`,children:O(n.compare??0)})]},n.key))})]});if(n===`hbar`)return(0,v.jsx)(c,{rows:T.map(n=>({key:n.key,name:x?w(n.key):n.name,value:n.value,label:O(n.value),href:b(t,e.by,n.key,e.period)}))});let k=[{key:`value`,label:C(t,d),color:a.accent},...E?[{key:`compare`,label:t.compare===`usual`?d(`pace.usual`):d(`chart.previous`),color:a.muted}]:[]];return(0,v.jsx)(l,{table:D,legend:k.map(e=>({label:e.label,color:e.color})),children:n===`line`?(0,v.jsx)(o,{data:T,xKey:`key`,formatX:x?w:e=>T.find(t=>t.key===e)?.name??String(e),specs:k.map(e=>({key:e.key,label:e.label,kind:`line`,color:e.color,width:e.key===`value`?2:1,dashed:e.key!==`value`}))}):(0,v.jsx)(s,{data:T.map(e=>({key:e.key,value:e.value,...E?{compare:e.compare??0}:{}})),xKey:`key`,formatX:x?w:e=>T.find(t=>t.key===e)?.name??String(e),series:k})})}function C(e,t){return t(`chart.metric.${e.metric}`)}export{x as default};