ownledger 1.2.1 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (166) hide show
  1. package/AGENTS.md +73 -1
  2. package/CHANGELOG.md +64 -0
  3. package/README.md +13 -0
  4. package/assets/apple-touch-icon.png +0 -0
  5. package/assets/icon-192.png +0 -0
  6. package/assets/icon-512.png +0 -0
  7. package/assets/icon-maskable-512.png +0 -0
  8. package/assets/index.html +15 -18
  9. package/assets/manifest.webmanifest +1 -1
  10. package/assets/static/Account-sw3qGLbB.js +1 -0
  11. package/assets/static/Accounts-DWyzX3qB.js +1 -0
  12. package/assets/static/Attention-DxV-4qdY.js +1 -0
  13. package/assets/static/ByCategory-B4P3ikmE.js +1 -0
  14. package/assets/static/CardDetail-CayBXBm-.js +1 -0
  15. package/assets/static/Cards-CVuOP8Bt.js +1 -0
  16. package/assets/static/Cards-XUBdWxyo.js +1 -0
  17. package/assets/static/CardsValue-EoW2jG_0.js +1 -0
  18. package/assets/static/Cashback-BibVYHf_.js +1 -0
  19. package/assets/static/CategoryIcon-HfjYhH1l.js +1 -0
  20. package/assets/static/CategoryPicker-BkmvzX2I.js +1 -0
  21. package/assets/static/ChartWidget-u09-whUU.js +1 -0
  22. package/assets/static/Combobox-xXeyjGgK.js +1 -0
  23. package/assets/static/Deposits-CLAda4dj.js +1 -0
  24. package/assets/static/DrillLink-Bvfam9FA.js +1 -0
  25. package/assets/static/Field-tKFmKDEF.js +1 -0
  26. package/assets/static/HomeEditor-4vxj5LMD.js +1 -0
  27. package/assets/static/Import-DwaaFpRJ.js +2 -0
  28. package/assets/static/IncomeSpending-RVDSxAK4.js +1 -0
  29. package/assets/static/KV-DMA1AlP-.js +1 -0
  30. package/assets/static/Left-C_4gTGSX.js +1 -0
  31. package/assets/static/Money-PfFNNDOw.js +1 -0
  32. package/assets/static/NetWorth-BSoseczC.js +1 -0
  33. package/assets/static/Pace-B8p-9174.js +1 -0
  34. package/assets/static/Panel-BnfWrw9R.js +1 -0
  35. package/assets/static/PinDialog-BqAU9Vh4.js +1 -0
  36. package/assets/static/Plans-2KuQH2_I.js +1 -0
  37. package/assets/static/Recent-Ccmb34bq.js +1 -0
  38. package/assets/static/Reports-Dd-dhclr.js +1 -0
  39. package/assets/static/Settings-BR8WBlen.js +1 -0
  40. package/assets/static/Transactions-BAuQ-6Eb.js +1 -0
  41. package/assets/static/TxRow-EKIIMQKa.js +1 -0
  42. package/assets/static/Unusual-CwFp8aA5.js +1 -0
  43. package/assets/static/Upcoming-B28roT9r.js +1 -0
  44. package/assets/static/WhichCard-B3kLc842.js +1 -0
  45. package/assets/static/arrow-up-D3gxUKLo.js +1 -0
  46. package/assets/static/bits-Dr2E0ObC.js +1 -0
  47. package/assets/static/button-rfwMVz0i.js +1 -0
  48. package/assets/static/cards-Bb5zjzRG.js +1 -0
  49. package/assets/static/charts-BqP7HKwP.js +65 -0
  50. package/assets/static/chevron-down-Co1w7ApZ.js +1 -0
  51. package/assets/static/chevron-right-Dqh3vs9Y.js +1 -0
  52. package/assets/static/createLucideIcon-flJrJK2p.js +1 -0
  53. package/assets/static/dialog-BuRqO4sc.js +1 -0
  54. package/assets/static/dist-B4_eGtNj.js +1 -0
  55. package/assets/static/dist-B7PR2b0C.js +1 -0
  56. package/assets/static/dist-BDn7ydjn.js +1 -0
  57. package/assets/static/dist-Dl-m8cc2.js +1 -0
  58. package/assets/static/drill-t1zr57xi.js +1 -0
  59. package/assets/static/es2015-DJh4h8NX.js +41 -0
  60. package/assets/static/fold-CGWYt9Iu.js +1 -0
  61. package/assets/static/index-eR1GkdC_.js +14 -0
  62. package/assets/static/index-iYMxgw-7.css +1 -0
  63. package/assets/static/queries-DZIMMe4i.js +1 -0
  64. package/assets/static/react-dom-wK_7mEjs.js +1 -0
  65. package/assets/static/select-eaSi9K-d.js +1 -0
  66. package/assets/static/shared-Box7on3B.js +1 -0
  67. package/assets/static/triangle-exclamation-point-CuL0XSJl.js +1 -0
  68. package/assets/static/useMutation-_Lw8xXWa.js +1 -0
  69. package/dist/cli/cards.d.ts +2 -0
  70. package/dist/cli/cards.js +86 -0
  71. package/dist/cli/check.js +7 -1
  72. package/dist/cli/dev.js +22 -2
  73. package/dist/cli/import.js +12 -2
  74. package/dist/cli/index.js +6 -0
  75. package/dist/cli/statements.d.ts +1 -0
  76. package/dist/cli/statements.js +231 -0
  77. package/dist/engine/actions.d.ts +5 -0
  78. package/dist/engine/actions.js +9 -5
  79. package/dist/engine/attention.d.ts +15 -0
  80. package/dist/engine/attention.js +63 -0
  81. package/dist/engine/check.js +8 -1
  82. package/dist/engine/dashboard.d.ts +72 -0
  83. package/dist/engine/dashboard.js +180 -0
  84. package/dist/engine/features.d.ts +20 -0
  85. package/dist/engine/features.js +37 -0
  86. package/dist/engine/index.d.ts +5 -0
  87. package/dist/engine/index.js +5 -0
  88. package/dist/engine/insights.d.ts +164 -0
  89. package/dist/engine/insights.js +534 -0
  90. package/dist/engine/load.js +6 -0
  91. package/dist/engine/registry.d.ts +2 -0
  92. package/dist/engine/registry.js +15 -33
  93. package/dist/engine/reports.d.ts +21 -2
  94. package/dist/engine/reports.js +51 -3
  95. package/dist/engine/schedules.d.ts +7 -84
  96. package/dist/engine/schedules.js +8 -207
  97. package/dist/engine/types.d.ts +2 -0
  98. package/dist/engine/write.d.ts +9 -0
  99. package/dist/engine/write.js +26 -5
  100. package/dist/import/mapping.js +6 -0
  101. package/dist/import/run.d.ts +7 -0
  102. package/dist/import/run.js +28 -1
  103. package/dist/modules/api.d.ts +22 -0
  104. package/dist/modules/api.js +16 -0
  105. package/dist/modules/cards/api.d.ts +3 -0
  106. package/dist/modules/cards/api.js +105 -0
  107. package/dist/modules/cards/engine.d.ts +42 -0
  108. package/dist/modules/cards/engine.js +102 -0
  109. package/dist/modules/cards/files.d.ts +11 -0
  110. package/dist/modules/cards/files.js +17 -0
  111. package/dist/modules/cards/index.d.ts +26 -0
  112. package/dist/modules/cards/index.js +304 -0
  113. package/dist/modules/cards/statements.d.ts +128 -0
  114. package/dist/modules/cards/statements.js +426 -0
  115. package/dist/modules/cards/terms.d.ts +105 -0
  116. package/dist/modules/cards/terms.js +194 -0
  117. package/dist/modules/cards/tracker.d.ts +36 -0
  118. package/dist/modules/cards/tracker.js +232 -0
  119. package/dist/modules/cards/types.d.ts +2 -0
  120. package/dist/modules/cards/types.js +16 -0
  121. package/dist/modules/deposits/engine.d.ts +14 -0
  122. package/dist/modules/deposits/engine.js +32 -0
  123. package/dist/modules/deposits/index.d.ts +2 -0
  124. package/dist/modules/deposits/index.js +24 -0
  125. package/dist/modules/deposits/types.d.ts +2 -0
  126. package/dist/modules/deposits/types.js +15 -0
  127. package/dist/modules/index.d.ts +5 -0
  128. package/dist/modules/index.js +10 -0
  129. package/dist/modules/insurance/index.d.ts +3 -0
  130. package/dist/modules/insurance/index.js +8 -0
  131. package/dist/modules/insurance/types.d.ts +2 -0
  132. package/dist/modules/insurance/types.js +3 -0
  133. package/dist/modules/investments/index.d.ts +2 -0
  134. package/dist/modules/investments/index.js +24 -0
  135. package/dist/modules/investments/types.d.ts +2 -0
  136. package/dist/modules/investments/types.js +7 -0
  137. package/dist/modules/loans/engine.d.ts +30 -0
  138. package/dist/modules/loans/engine.js +77 -0
  139. package/dist/modules/loans/index.d.ts +2 -0
  140. package/dist/modules/loans/index.js +27 -0
  141. package/dist/modules/loans/types.d.ts +2 -0
  142. package/dist/modules/loans/types.js +5 -0
  143. package/dist/modules/types.d.ts +39 -0
  144. package/dist/modules/types.js +1 -0
  145. package/dist/modules/util.d.ts +8 -0
  146. package/dist/modules/util.js +8 -0
  147. package/dist/node/scaffold.js +2 -2
  148. package/dist/node/statements.d.ts +64 -0
  149. package/dist/node/statements.js +218 -0
  150. package/dist/worker/api.d.ts +11 -1
  151. package/dist/worker/api.js +169 -13
  152. package/dist/worker/bestcard.d.ts +31 -9
  153. package/dist/worker/bestcard.js +78 -50
  154. package/dist/worker/github.d.ts +3 -1
  155. package/dist/worker/github.js +13 -2
  156. package/dist/worker/mcp.js +209 -30
  157. package/dist/worker/store.d.ts +2 -0
  158. package/dist/worker/store.js +7 -2
  159. package/dist/worker/tar.d.ts +2 -1
  160. package/dist/worker/tar.js +4 -1
  161. package/dist/worker/version.d.ts +1 -1
  162. package/dist/worker/version.js +1 -1
  163. package/package.json +28 -4
  164. package/presets/misa.mapping.yaml +7 -0
  165. package/assets/app.css +0 -61
  166. package/assets/app.js +0 -369
@@ -0,0 +1,2 @@
1
+ import{t as e}from"./useMutation-_Lw8xXWa.js";import{B as t,F as n,I as r,L as i,T as a,b as o,l as s,u as c,w as l}from"./queries-DZIMMe4i.js";import{t as u}from"./triangle-exclamation-point-CuL0XSJl.js";import{it as d,l as f,s as p,tt as m}from"./index-eR1GkdC_.js";import{t as h}from"./Money-PfFNNDOw.js";import{t as g}from"./Panel-BnfWrw9R.js";import{t as _}from"./button-rfwMVz0i.js";import{a as v,i as y,n as b,r as x,t as S}from"./select-eaSi9K-d.js";var C=t(r(),1),w=i();async function T(e){let t=new Uint8Array(await e.arrayBuffer()),n=``;for(let e=0;e<t.length;e+=32768)n+=String.fromCharCode(...t.subarray(e,e+32768));return btoa(n)}function E({summary:e,children:t,open:n}){return(0,w.jsxs)(`details`,{open:n,className:`rounded-lg border px-3`,children:[(0,w.jsx)(`summary`,{className:`flex min-h-11 cursor-pointer items-center text-sm font-medium`,children:e}),(0,w.jsx)(`div`,{className:`flex flex-col gap-2 pb-3`,children:t})]})}var D=e=>[e.account,e.category].filter(Boolean).join(` › `);function O({r:e}){let{t,lang:n}=l(),r=e.reconcile.filter(e=>!e.ok),i=e=>(0,w.jsxs)(`li`,{className:`flex items-baseline justify-between gap-3 text-xs`,children:[(0,w.jsxs)(`span`,{className:`min-w-0 truncate`,children:[e.date,` · `,e.sheet,` #`,e.row,` · `,e.note]}),(0,w.jsx)(h,{amount:e.amount,mode:`short`,className:`shrink-0`})]},`${e.sheet}-${e.row}`);return(0,w.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,w.jsxs)(`p`,{className:a(`flex items-center gap-2 text-base font-semibold`,e.ok?`text-foreground`:`text-critical`),children:[e.ok?(0,w.jsx)(m,{className:`size-5`,"aria-hidden":!0}):(0,w.jsx)(u,{className:`size-5`,"aria-hidden":!0}),e.ok?t(`import.reconciles`):t(`import.refused`)]}),(0,w.jsxs)(`p`,{className:`text-sm`,children:[t(`import.summary`,{rows:f(e.rows,n),skipped:f(e.skipped,n)}),` `,(0,w.jsx)(`b`,{children:t(`import.newCount`,{n:f(e.new,n)})}),e.accounts.length>0&&(0,w.jsxs)(w.Fragment,{children:[` · `,t(`import.newAccounts`,{n:e.accounts.length})]})]}),e.accounts.length>0&&(0,w.jsx)(`ul`,{className:`flex flex-wrap gap-1.5`,children:e.accounts.map(e=>(0,w.jsx)(`li`,{className:`rounded-full bg-secondary px-2 py-0.5 text-xs text-secondary-foreground`,children:e},e))}),(0,w.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t(`import.matches`,{ok:e.reconcile.length-r.length,total:e.reconcile.length})}),r.length>0&&(0,w.jsx)(E,{open:!0,summary:t(`import.problems`,{n:r.length}),children:(0,w.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,w.jsx)(`thead`,{children:(0,w.jsxs)(`tr`,{className:`text-left text-muted-foreground`,children:[(0,w.jsx)(`th`,{scope:`col`,className:`py-1 font-medium`,children:t(`import.account`)}),(0,w.jsx)(`th`,{scope:`col`,className:`py-1 font-medium`,children:t(`import.problem`)})]})}),(0,w.jsx)(`tbody`,{children:r.map(e=>(0,w.jsxs)(`tr`,{className:`border-t align-top`,children:[(0,w.jsx)(`td`,{className:`py-1 pr-3`,children:e.sheet}),(0,w.jsx)(`td`,{className:`py-1`,children:e.problems.join(`; `)})]},e.sheet))})]})}),e.unresolvedCategories.length>0&&(0,w.jsx)(E,{open:!0,summary:(0,w.jsx)(`span`,{className:`text-critical`,children:t(`import.unresolvedCategories`,{n:e.unresolvedCategories.length})}),children:(0,w.jsx)(`ul`,{className:`flex flex-col gap-1 text-xs`,children:e.unresolvedCategories.map(e=>(0,w.jsxs)(`li`,{children:[(0,w.jsx)(`span`,{className:`font-medium`,children:e.key}),` (`,t(`import.rowsCount`,{n:e.rows}),`) `,(0,w.jsx)(`span`,{className:`text-muted-foreground`,children:e.example})]},e.key))})}),e.unresolvedRows.length>0&&(0,w.jsx)(E,{summary:t(`import.unresolvedRows`,{n:e.unresolvedRows.length}),children:(0,w.jsx)(`ul`,{className:`flex flex-col gap-1`,children:e.unresolvedRows.map(i)})}),e.unpaired.length>0&&(0,w.jsx)(E,{summary:t(`import.unpaired`,{n:e.unpaired.length}),children:(0,w.jsx)(`ul`,{className:`flex flex-col gap-1`,children:e.unpaired.slice(0,50).map(i)})}),(e.changed.length>0||e.gone.length>0)&&(0,w.jsxs)(`p`,{className:`flex items-start gap-2 text-sm font-medium text-critical`,children:[(0,w.jsx)(u,{className:`mt-0.5 size-4 shrink-0`,"aria-hidden":!0}),t(`import.changedGone`,{changed:e.changed.length,gone:e.gone.length})]}),e.rounding.length>0&&(0,w.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`import.rounding`,{n:e.rounding.length})}),e.zeroed.length>0&&(0,w.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`import.zeroed`,{n:e.zeroed.length})}),e.cardTerms.length>0&&(0,w.jsx)(E,{summary:t(`import.cardTerms`,{n:e.cardTerms.length}),children:(0,w.jsx)(`ul`,{className:`flex flex-wrap gap-1.5`,children:e.cardTerms.map(e=>(0,w.jsx)(`li`,{className:`rounded-full bg-secondary px-2 py-0.5 text-xs text-secondary-foreground`,children:e},e))})}),e.nameWarnings.length>0&&(0,w.jsx)(E,{open:!0,summary:(0,w.jsx)(`span`,{className:`text-warning`,children:t(`import.nameWarnings`,{n:e.nameWarnings.length})}),children:(0,w.jsx)(`ul`,{className:`flex list-disc flex-col gap-1 pl-5 text-xs`,children:e.nameWarnings.map((e,t)=>(0,w.jsx)(`li`,{children:e},t))})}),e.errors.length>0&&(0,w.jsx)(E,{open:!0,summary:(0,w.jsx)(`span`,{className:`text-critical`,children:t(`import.errors`,{n:e.errors.length})}),children:(0,w.jsx)(`pre`,{className:`overflow-x-auto text-xs whitespace-pre-wrap`,children:e.errors.join(`
2
+ `)})}),e.sample.length>0&&(0,w.jsx)(E,{open:!0,summary:t(`import.sample`,{n:e.sample.length}),children:(0,w.jsx)(`ul`,{className:`flex flex-col divide-y`,children:e.sample.map(e=>(0,w.jsxs)(`li`,{className:`flex flex-col gap-0.5 py-1.5 text-xs`,children:[(0,w.jsxs)(`span`,{className:`flex items-baseline justify-between gap-3`,children:[(0,w.jsx)(`span`,{className:`min-w-0 truncate font-medium`,children:e.note||`–`}),(0,w.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:p(e.date,n)})]}),(0,w.jsx)(`span`,{className:`flex flex-col text-muted-foreground`,children:e.lines.map((e,t)=>(0,w.jsxs)(`span`,{className:`flex justify-between gap-3`,children:[(0,w.jsx)(`span`,{className:`min-w-0 truncate`,children:D(e)}),(0,w.jsx)(h,{amount:e.amount,mode:`short`,className:`shrink-0`})]},t))})]},e.id))})})]})}function k(){let{t}=l(),r=c().data,i=n(),a=s(),[u,f]=(0,C.useState)(void 0),[p,h]=(0,C.useState)(null),E=(0,C.useRef)(null),D=u??a.data?.[0],k=e({mutationFn:async()=>{let e=JSON.stringify({file_name:p.name,base64:await T(p),mapping:D});return o(`import/preview`,{method:`POST`,body:e})}}),A=e({mutationFn:e=>o(`import/apply`,{method:`POST`,body:JSON.stringify({preview_id:e})}),onSuccess:()=>void i.invalidateQueries()}),j=()=>{k.reset(),A.reset()},M=(0,w.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:t(`import.title`)});if(r&&!r.features?.imports)return(0,w.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[M,(0,w.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t(`import.cli`)})]});let N=k.data;return(0,w.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,w.jsxs)(`header`,{className:`flex flex-col gap-1`,children:[M,(0,w.jsx)(`p`,{className:`max-w-2xl text-sm text-muted-foreground`,children:t(`import.intro`)})]}),a.data&&a.data.length===0?(0,w.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t(`import.cli`)}):(0,w.jsx)(g,{title:t(`import.choose`),children:(0,w.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),p&&(A.reset(),k.mutate())},children:[a.data&&a.data.length>1&&(0,w.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,w.jsx)(`span`,{className:`text-muted-foreground`,children:t(`import.mapping`)}),(0,w.jsxs)(S,{value:D,onValueChange:e=>{f(e),j()},children:[(0,w.jsx)(y,{className:`min-h-11 w-full sm:w-96 md:min-h-8`,children:(0,w.jsx)(v,{})}),(0,w.jsx)(b,{children:a.data.map(e=>(0,w.jsx)(x,{value:e,className:`min-h-11 md:min-h-8`,children:e.replace(/^imports\//,``).replace(/\.mapping\.yaml$/,``)},e))})]})]}),a.data?.length===1&&(0,w.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t(`import.mappingOne`,{name:a.data[0].replace(/^imports\//,``)})}),(0,w.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,w.jsx)(`span`,{className:`text-muted-foreground`,children:t(`import.file`)}),(0,w.jsx)(d,{ref:E,type:`file`,accept:`.xlsx,.csv,.json`,onChange:e=>{h(e.target.files?.[0]??null),j()},className:`h-11 py-2 md:h-9`})]}),(0,w.jsx)(_,{type:`submit`,className:`min-h-11 self-start md:min-h-8`,disabled:!p||!D||k.isPending,children:k.isPending?t(`import.reading`):t(`import.preview`)})]})}),k.error&&(0,w.jsx)(`p`,{role:`alert`,className:`text-sm font-medium text-critical`,children:t(`common.error`,{message:k.error.message})}),N&&(0,w.jsxs)(g,{title:t(`import.result`),children:[(0,w.jsx)(O,{r:N.report}),N.preview_id?(0,w.jsxs)(`div`,{className:`flex flex-col gap-2 border-t pt-3`,children:[A.isSuccess?(0,w.jsxs)(`p`,{role:`status`,className:`flex items-center gap-2 text-sm font-medium`,children:[(0,w.jsx)(m,{className:`size-4`,"aria-hidden":!0}),t(`import.committed`,{sha:A.data.sha.slice(0,10)}),` `,(0,w.jsx)(`span`,{className:`font-normal text-muted-foreground`,children:A.data.message})]}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(_,{type:`button`,className:`min-h-11 self-start md:min-h-8`,disabled:A.isPending,onClick:()=>A.mutate(N.preview_id),children:A.isPending?t(`import.committing`):t(`import.commit`,{n:N.report.new})}),N.message&&(0,w.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:N.message})]}),A.error&&(0,w.jsx)(`p`,{role:`alert`,className:`text-sm font-medium text-critical`,children:t(`common.error`,{message:A.error.message})})]}):N.report.ok&&(0,w.jsx)(`p`,{className:`border-t pt-3 text-sm text-muted-foreground`,children:t(`import.nothingNew`)})]})]})}export{k as default};
@@ -0,0 +1 @@
1
+ import{B as e,I as t,L as n,f as r,u as i,w as a}from"./queries-DZIMMe4i.js";import{a as o,n as s,t as c}from"./charts-BqP7HKwP.js";import{t as l}from"./DrillLink-Bvfam9FA.js";import{M as u,P as d,a as f,l as p,o as m}from"./index-eR1GkdC_.js";import{n as h,t as g}from"./drill-t1zr57xi.js";import{n as _}from"./shared-Box7on3B.js";var v=e(t(),1),y=n();function b({widget:e,menu:t}){let{t:n,lang:b}=a(),x=_(e,`widget.incomeSpending`),S=i().data?.today??new Date().toISOString().slice(0,10),C=Math.min(24,Math.max(2,e.months??6)),w=S.slice(0,7),T=m(w,-(C-1)),{data:E,error:D,isLoading:O}=r(`${T}-01`,h(w).to),k=(0,v.useMemo)(()=>{let e=new Map((E?.rows??[]).map(e=>[e.key,e]));return Array.from({length:C},(t,n)=>{let r=m(T,n),i=e.get(r);return{ym:r,income:i?.income??0,expense:i?.expense??0}})},[E,C,T]),A=k.reduce((e,t)=>e+t.income,0),j=k.reduce((e,t)=>e+t.expense,0),M=A>0?(A-j)/A*100:null,N=e=>e.income>0?`${p((e.income-e.expense)/e.income*100,b)}%`:``;return(0,y.jsx)(u,{title:x,titleHref:`#/reports`,menu:t,loading:O,error:D?.message,empty:E&&A===0&&j===0?n(`incsp.empty`):void 0,children:E&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:M===null?n(`incsp.noIncome`):n(`incsp.rate`,{pct:p(M,b)})}),(0,y.jsx)(c,{legend:[{label:n(`tx.in`),color:o.accent},{label:n(`tx.out`),color:o.second}],table:{head:[n(`chart.month`),n(`tx.in`),n(`tx.out`),n(`incsp.rateShort`)],rows:k.map(e=>[(0,y.jsx)(l,{filter:h(e.ym),children:f(e.ym)},e.ym),p(e.income,b),p(e.expense,b),N(e)])},children:(0,y.jsx)(s,{data:k,xKey:`ym`,formatX:e=>f(String(e)),onSelect:e=>d(g(h(e)).slice(1)),series:[{key:`income`,label:n(`tx.in`),color:o.accent},{key:`expense`,label:n(`tx.out`),color:o.second}]})})]})})}export{b as default};
@@ -0,0 +1 @@
1
+ import{L as e,T as t}from"./queries-DZIMMe4i.js";var n=e();function r({label:e,children:r,className:i}){return(0,n.jsxs)(`div`,{className:t(`flex items-baseline justify-between gap-4 py-1.5 text-sm`,i),children:[(0,n.jsx)(`dt`,{className:`shrink-0 text-muted-foreground`,children:e}),(0,n.jsx)(`dd`,{className:`min-w-0 text-right break-words tabular-nums`,children:r})]})}export{r as t};
@@ -0,0 +1 @@
1
+ import{t as e}from"./DrillLink-Bvfam9FA.js";import{t}from"./Money-PfFNNDOw.js";import{M as n}from"./index-eR1GkdC_.js";import{L as r,c as i,w as a}from"./queries-DZIMMe4i.js";import{n as o}from"./shared-Box7on3B.js";var s=r();function c({widget:r,menu:c}){let{t:l}=a(),u=o(r,`widget.left`),{data:d,error:f,isLoading:p}=i(),m=d?.left;return(0,s.jsx)(n,{title:u,menu:c,loading:p,error:f?.message,children:m&&d&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(t,{amount:m.now,tone:`auto`,className:`text-2xl font-semibold tracking-tight`}),(0,s.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[l(`left.monthEnd`),` `,(0,s.jsx)(t,{amount:m.monthEnd,tone:`auto`,mode:`short`,className:`font-medium`})]}),(0,s.jsxs)(`dl`,{className:`grid grid-cols-2 gap-2 text-sm`,children:[(0,s.jsxs)(`div`,{children:[(0,s.jsx)(`dt`,{className:`text-muted-foreground`,children:l(`tx.in`)}),(0,s.jsx)(`dd`,{children:(0,s.jsx)(e,{filter:{from:`${d.asOf.slice(0,7)}-01`,to:d.asOf},children:(0,s.jsx)(t,{amount:m.income,mode:`short`})})})]}),(0,s.jsxs)(`div`,{children:[(0,s.jsx)(`dt`,{className:`text-muted-foreground`,children:l(`tx.out`)}),(0,s.jsx)(`dd`,{children:(0,s.jsx)(t,{amount:m.spent,mode:`short`})})]})]})]})})}export{c as default};
@@ -0,0 +1 @@
1
+ import{L as e,T as t,u as n,w as r}from"./queries-DZIMMe4i.js";import{c as i,u as a}from"./index-eR1GkdC_.js";var o=e(),s={in:`text-positive`,out:`text-critical`,transfer:`text-muted-foreground`};function c({amount:e,mode:c=`full`,tone:l=`none`,plus:u=!1,className:d}){let{lang:f}=r(),p=n().data?.base??`VND`,m=c===`short`?a(e,f):i(e,f,p),h=Math.sign(e),g=l===`auto`?h===1?`in`:h===-1?`out`:`none`:l;return(0,o.jsxs)(`span`,{className:t(`whitespace-nowrap tabular-nums`,g!==`none`&&s[g],d),children:[u&&h===1?`+`:``,m]})}export{c as t};
@@ -0,0 +1 @@
1
+ import{B as e,I as t,L as n,c as r,w as i}from"./queries-DZIMMe4i.js";import{t as a}from"./Money-PfFNNDOw.js";import{a as o,i as s,t as c}from"./charts-BqP7HKwP.js";import{M as l,a as u,l as d,u as f}from"./index-eR1GkdC_.js";import{n as p}from"./shared-Box7on3B.js";var m=e(t(),1),h=n();function g({widget:e,menu:t}){let{t:n,lang:g}=i(),_=p(e,`widget.netWorth`),{data:v,error:y,isLoading:b}=r(),x=v?.netWorth,S=(0,m.useMemo)(()=>(x?.series??[]).map(e=>({date:e.date,ym:e.date.slice(0,7),net:e.net})),[x]),C=(e,t)=>e===null?null:(0,h.jsxs)(`li`,{className:`flex items-baseline justify-between gap-2`,children:[(0,h.jsx)(`span`,{className:`text-muted-foreground`,children:n(t)}),(0,h.jsx)(a,{amount:e,mode:`short`,tone:`auto`,plus:!0,className:`font-medium`})]});return(0,h.jsx)(l,{title:_,titleHref:`#/accounts`,menu:t,loading:b,error:y?.message,children:x&&v&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`p`,{className:`text-2xl font-semibold tracking-tight tabular-nums`,children:f(x.net,g)}),(0,h.jsxs)(`ul`,{className:`flex flex-col gap-0.5 text-sm`,children:[C(x.changeMonth,`nw.changeMonth`),C(x.change12,`nw.change12`),v.pool.on&&(0,h.jsxs)(`li`,{className:`flex items-baseline justify-between gap-2`,children:[(0,h.jsx)(`span`,{className:`text-muted-foreground`,children:v.pool.name??n(`pool.name`)}),(0,h.jsx)(a,{amount:v.pool.balance,mode:`short`,className:`font-medium`})]})]}),x.unpriced>0&&(0,h.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`nw.unpriced`,{n:x.unpriced})}),(0,h.jsx)(c,{table:{head:[n(`chart.month`),n(`widget.netWorth`)],rows:S.map(e=>[u(e.ym),d(e.net,g)])},children:(0,h.jsx)(s,{data:S,xKey:`ym`,formatX:e=>u(String(e)),specs:[{key:`net`,label:n(`widget.netWorth`),kind:`line`,color:o.accent}]})})]})})}export{g as default};
@@ -0,0 +1 @@
1
+ import{B as e,I as t,L as n,c as r,w as i}from"./queries-DZIMMe4i.js";import{t as a}from"./DrillLink-Bvfam9FA.js";import{t as o}from"./Money-PfFNNDOw.js";import{a as s,i as c,t as l}from"./charts-BqP7HKwP.js";import{M as u,l as d}from"./index-eR1GkdC_.js";import{n as f,t as p}from"./shared-Box7on3B.js";var m=e(t(),1),h=n();function g({widget:e,menu:t}){let{t:n,lang:g}=i(),_=f(e,`widget.pace`),{data:v,error:y,isLoading:b}=r(),x=v?.pace,S=(0,m.useMemo)(()=>x?Array.from({length:x.daysInMonth},(e,t)=>({day:t+1,now:x.daily[t]??null,last:x.lastMonth?.daily[t]??null,usual:x.usual?.daily[t]??null,band:x.usual?.low?.[t]!==void 0&&x.usual?.high?.[t]!==void 0?[x.usual.low[t],x.usual.high[t]]:null,low:x.usual?.low?.[t]??null,high:x.usual?.high?.[t]??null})):[],[x]),C=[...x?.usual?.low?.length?[{key:`band`,label:n(`pace.range`),kind:`band`,color:s.muted}]:[],...x?.usual?[{key:`usual`,label:n(`pace.usual`),kind:`line`,color:s.muted,width:1.5}]:[],...x?.lastMonth?[{key:`last`,label:n(`pace.lastMonth`),kind:`line`,color:s.muted,width:1,dashed:!0}]:[],{key:`now`,label:n(`pace.thisMonth`),kind:`line`,color:s.accent,width:2}],w=x?.usual&&x.usual.toDate>0?x.usual.toDate:x?.lastMonth&&x.lastMonth.toDate>0?x.lastMonth.toDate:null,T=x&&w?(x.spent-w)/w*100:null,E=x?{from:`${x.month}-01`,to:x.asOf}:{};return(0,h.jsx)(u,{title:_,titleHref:`#/transactions`,menu:t,loading:b,error:y?.message,children:x&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-3 gap-y-1`,children:[(0,h.jsx)(a,{filter:E,className:`text-2xl font-semibold tracking-tight`,children:(0,h.jsx)(o,{amount:x.spent})}),T!==null&&(0,h.jsxs)(`span`,{className:`flex items-center gap-1 text-sm text-muted-foreground`,children:[(0,h.jsx)(p,{pct:T}),x.usual?n(`pace.vsUsual`):n(`pace.vsLast`)]})]}),(0,h.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[n(`pace.estimate`),` `,(0,h.jsx)(o,{amount:x.estimate,mode:`short`,className:`font-medium text-foreground`})]}),(0,h.jsx)(l,{legend:C.map(e=>({label:e.label,color:e.color,dashed:e.dashed})),table:{head:[n(`chart.day`),n(`pace.thisMonth`),...x.usual?[n(`pace.usual`)]:[],...x.usual?.low?.length?[n(`pace.low`),n(`pace.high`)]:[],...x.lastMonth?[n(`pace.lastMonth`)]:[]],rows:S.map(e=>[e.day,e.now===null?``:d(e.now,g),...x.usual?[d(e.usual??0,g)]:[],...x.usual?.low?.length?[d(e.low??0,g),d(e.high??0,g)]:[],...x.lastMonth?[d(e.last??0,g)]:[]])},children:(0,h.jsx)(c,{data:S,xKey:`day`,specs:C,xTicks:[1,8,15,22,x.daysInMonth]})})]})})}export{g as default};
@@ -0,0 +1 @@
1
+ import{F as e,I as t,L as n,R as r,z as i}from"./index-eR1GkdC_.js";import{L as a,T as o}from"./queries-DZIMMe4i.js";var s=a();function c({title:a,action:c,children:l,className:u}){return(0,s.jsxs)(e,{className:o(`min-w-0`,u),children:[(0,s.jsxs)(r,{children:[(0,s.jsx)(i,{children:(0,s.jsx)(`h2`,{children:a})}),c&&(0,s.jsx)(t,{children:c})]}),(0,s.jsx)(n,{className:`flex flex-col gap-3`,children:l})]})}export{c as t};
@@ -0,0 +1 @@
1
+ import{C as e,D as t,O as n,S as r,it as i,tt as a,y as o}from"./index-eR1GkdC_.js";import{B as s,I as c,L as l,u,w as d}from"./queries-DZIMMe4i.js";import{t as f}from"./button-rfwMVz0i.js";import{a as p,i as m,n as h,o as g,r as _,t as v}from"./dialog-BuRqO4sc.js";import{t as y}from"./Field-tKFmKDEF.js";var b=s(c(),1),x=l();function S({query:s,title:c,onClose:l}){let{t:S}=d(),C=u().data,[w,T]=(0,b.useState)(c.slice(0,80)),[E,D]=(0,b.useState)(!1),[O,k]=(0,b.useState)(null),[A,j]=(0,b.useState)(!1),M=async()=>{D(!0),k(null);try{let i=C?.dashboard?.widgets??[],a=o(i,{type:`chart`,...w.trim()?{title:w.trim()}:{},query:e(s),chart:r(s)},n.chart.size);await t([...i,a]),j(!0)}catch(e){k(S(`pin.error`,{message:e.message}))}D(!1)};return(0,x.jsx)(v,{open:!0,onOpenChange:e=>!e&&l(),children:(0,x.jsxs)(h,{children:[(0,x.jsxs)(p,{children:[(0,x.jsx)(g,{children:S(A?`pin.done`:`pin.title`)}),(0,x.jsx)(_,{children:S(A?`pin.doneHint`:`pin.description`)})]}),A?(0,x.jsxs)(m,{children:[(0,x.jsx)(f,{type:`button`,variant:`outline`,className:`min-h-11 md:min-h-8`,onClick:l,children:S(`pin.close`)}),(0,x.jsx)(f,{asChild:!0,className:`min-h-11 md:min-h-8`,children:(0,x.jsxs)(`a`,{href:`#/`,onClick:l,children:[(0,x.jsx)(a,{}),S(`pin.openHome`)]})})]}):(0,x.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),M()},children:[(0,x.jsx)(y,{label:S(`pin.titleLabel`),children:e=>(0,x.jsx)(i,{id:e,className:`min-h-11 md:min-h-8`,maxLength:80,value:w,onChange:e=>T(e.target.value)})}),O&&(0,x.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:O}),(0,x.jsxs)(m,{children:[(0,x.jsx)(f,{type:`button`,variant:`outline`,className:`min-h-11 md:min-h-8`,disabled:E,onClick:l,children:S(`common.cancel`)}),(0,x.jsx)(f,{type:`submit`,className:`min-h-11 md:min-h-8`,disabled:E,children:S(E?`pin.saving`:`pin.save`)})]})]})]})})}export{S as default};
@@ -0,0 +1 @@
1
+ import{B as e,I as t,L as n,T as r,p as i,u as a,w as o}from"./queries-DZIMMe4i.js";import{A as s,W as c,n as l,r as u,s as d,t as f}from"./index-eR1GkdC_.js";import{t as p}from"./DrillLink-Bvfam9FA.js";import{t as m}from"./Money-PfFNNDOw.js";import{t as h}from"./Panel-BnfWrw9R.js";var g=e(t(),1),_=n(),v=30;function y({value:e,max:t,label:n}){let r=t>0?Math.min(1,e/t):0;return(0,_.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,_.jsx)(`div`,{className:`h-2 rounded-full bg-[var(--chart-1)]`,style:{width:`${Math.max(r?2:0,r*100)}%`}})})}function b({d:e,overdue:t}){let{t:n,lang:i}=o();return(0,_.jsxs)(`li`,{className:`flex min-h-12 items-center gap-3 py-1.5`,children:[(0,_.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,_.jsx)(p,{filter:{plan:e.plan},className:`truncate text-sm font-medium`,children:e.name}),(0,_.jsx)(`span`,{className:r(`text-xs`,t?`font-medium text-critical`:`text-muted-foreground`),children:t?n(`upcoming.overdue`,{date:l(e.date)}):d(e.date,i,{weekday:`short`,day:`2-digit`,month:`2-digit`})})]}),(0,_.jsx)(m,{amount:e.amount,mode:`short`,className:`shrink-0 text-sm font-medium`}),t&&(0,_.jsx)(s,{prompt:n(`ask.plan`,{name:e.name})})]})}function x({p:e}){let{t}=o(),n=e.overdue.length>0,r=null;return n?r=(0,_.jsx)(`span`,{className:`font-medium text-critical`,children:t(`plans.lateCount`,{n:e.overdue.length})}):e.next&&(r=(0,_.jsx)(`span`,{children:t(`plans.next`,{date:l(e.next)})})),(0,_.jsxs)(`li`,{className:`flex flex-col gap-1 py-2`,children:[(0,_.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2`,children:[(0,_.jsx)(p,{filter:{plan:e.plan},className:`min-w-0 truncate text-sm font-medium`,children:e.name}),(0,_.jsxs)(`span`,{className:`shrink-0 text-xs text-muted-foreground tabular-nums`,children:[e.paidCount,`/`,e.count??`–`]})]}),e.count!==null&&(0,_.jsx)(y,{value:e.paidCount,max:e.count,label:e.name}),(0,_.jsxs)(`p`,{className:`flex flex-wrap items-baseline justify-between gap-x-3 text-xs text-muted-foreground`,children:[(0,_.jsxs)(`span`,{children:[t(`plans.perPayment`),` `,(0,_.jsx)(m,{amount:e.perPayment,mode:`short`}),e.leftAmount!==null&&(0,_.jsxs)(_.Fragment,{children:[` · `,t(`cards.left`),` `,(0,_.jsx)(m,{amount:e.leftAmount,mode:`short`})]})]}),r]})]})}function S(){let{t:e,lang:t}=o(),n=a().data?.today??new Date().toISOString().slice(0,10),{data:d,error:p,isLoading:y}=i(v),S=(0,g.useMemo)(()=>{let e=d?.due??[],t=e.filter(e=>e.overdue||e.date<n).sort((e,t)=>e.date.localeCompare(t.date)),r=e.filter(e=>!t.includes(e)&&e.date<=f(n,29)).sort((e,t)=>e.date.localeCompare(t.date)),i=new Map;for(let e of r)i.set(e.date,(i.get(e.date)??0)+e.amount);let a=Array.from({length:v},(e,t)=>{let r=f(n,t);return{date:r,amount:i.get(r)??0}}),o=Array.from({length:5},(e,t)=>({start:f(n,t*7),amount:0}));for(let e of r)o[Math.min(4,Math.floor(u(n,e.date)/7))].amount+=e.amount;let s=(d?.status??[]).filter(e=>!e.finished),c=e=>(e.overdue.length?`0`:`1`)+(e.next??`9999`);return{overdue:t,upcoming:r,days:a,weeks:o,counted:s.filter(e=>e.count!==null).sort((e,t)=>c(e).localeCompare(c(t))),open:s.filter(e=>e.count===null).sort((e,t)=>c(e).localeCompare(c(t))),total:r.reduce((e,t)=>e+t.amount,0),overdueTotal:t.reduce((e,t)=>e+t.amount,0)}},[d,n]),C=Math.max(1,...S.days.map(e=>e.amount)),w=Math.max(1,...S.weeks.map(e=>e.amount));return(0,_.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,_.jsxs)(`header`,{className:`flex flex-col gap-1`,children:[(0,_.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:e(`plans.title`)}),d?(0,_.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[e(`upcoming.total`),` `,(0,_.jsx)(m,{amount:S.total,mode:`short`,className:`font-medium text-foreground`}),S.overdue.length>0&&(0,_.jsxs)(_.Fragment,{children:[` · `,(0,_.jsxs)(`span`,{className:`font-medium text-critical`,children:[e(`plans.overdueTotal`,{n:S.overdue.length}),` `,(0,_.jsx)(m,{amount:S.overdueTotal,mode:`short`})]})]})]}):(0,_.jsx)(c,{className:`h-5 w-64`})]}),p?(0,_.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`common.error`,{message:p.message})}):y||!d?(0,_.jsxs)(`div`,{className:`flex flex-col gap-3`,"aria-busy":`true`,children:[(0,_.jsx)(c,{className:`h-28 w-full`}),(0,_.jsx)(c,{className:`h-40 w-full`})]}):d.status.length===0&&d.due.length===0?(0,_.jsxs)(`div`,{className:`flex flex-col items-start gap-3 rounded-lg border border-dashed p-6 text-sm text-muted-foreground`,children:[(0,_.jsx)(`p`,{children:e(`plans.empty`)}),(0,_.jsx)(s,{prompt:e(`ask.addPlan`)})]}):(0,_.jsxs)(_.Fragment,{children:[S.overdue.length>0&&(0,_.jsx)(h,{title:e(`plans.overdue`),className:`ring-critical/30`,children:(0,_.jsx)(`ul`,{className:`flex flex-col divide-y`,children:S.overdue.map(e=>(0,_.jsx)(b,{d:e,overdue:!0},`${e.plan}-${e.date}`))})}),(0,_.jsxs)(h,{title:e(`plans.next30`),children:[(0,_.jsx)(`ol`,{className:`grid grid-cols-5 gap-1.5`,"aria-label":e(`upcoming.weeks`),children:S.weeks.map(e=>(0,_.jsxs)(`li`,{className:`flex flex-col items-center gap-1`,children:[(0,_.jsx)(`span`,{className:`flex h-10 w-full items-end rounded-sm bg-muted`,children:(0,_.jsx)(`span`,{className:`w-full rounded-sm`,style:{height:`${e.amount?Math.max(8,e.amount/w*100):0}%`,background:`var(--chart-1)`}})}),(0,_.jsx)(`span`,{className:`text-[11px] text-muted-foreground tabular-nums`,children:l(e.start)}),(0,_.jsx)(`span`,{className:`text-xs tabular-nums`,children:e.amount?(0,_.jsx)(m,{amount:e.amount,mode:`short`}):`–`})]},e.start))}),(0,_.jsx)(`div`,{className:`-mx-4 overflow-x-auto px-4 pb-1`,children:(0,_.jsx)(`ol`,{className:`flex gap-1`,"aria-label":e(`plans.perDay`),children:S.days.map(e=>(0,_.jsxs)(`li`,{className:`flex w-9 shrink-0 flex-col items-center gap-1`,children:[(0,_.jsx)(`span`,{className:`flex h-12 w-full items-end rounded-sm bg-muted`,children:(0,_.jsx)(`span`,{className:`w-full rounded-sm`,style:{height:`${e.amount?Math.max(10,e.amount/C*100):0}%`,background:`var(--chart-1)`}})}),(0,_.jsx)(`span`,{className:r(`text-[11px] tabular-nums`,e.date===n?`font-semibold text-foreground`:`text-muted-foreground`),children:e.date.slice(8,10)}),(0,_.jsx)(`span`,{className:`h-3 text-[10px] text-muted-foreground tabular-nums`,children:e.amount?(0,_.jsx)(m,{amount:e.amount,mode:`short`}):``})]},e.date))})}),S.upcoming.length===0?(0,_.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`upcoming.empty`)}):(0,_.jsx)(`ul`,{className:`flex flex-col divide-y`,children:S.upcoming.map(e=>(0,_.jsx)(b,{d:e},`${e.plan}-${e.date}`))})]}),S.counted.length>0&&(0,_.jsx)(h,{title:e(`plans.progress`),children:(0,_.jsx)(`ul`,{className:`flex flex-col divide-y`,children:S.counted.map(e=>(0,_.jsx)(x,{p:e},e.plan))})}),S.open.length>0&&(0,_.jsx)(h,{title:e(`plans.recurring`),children:(0,_.jsx)(`ul`,{className:`flex flex-col divide-y`,children:S.open.map(e=>(0,_.jsx)(x,{p:e},e.plan))})})]})]})}export{S as default};
@@ -0,0 +1 @@
1
+ import{n as e,t}from"./TxRow-EKIIMQKa.js";import{M as n}from"./index-eR1GkdC_.js";import{B as r,I as i,L as a,d as o,g as s,w as c}from"./queries-DZIMMe4i.js";import{n as l}from"./shared-Box7on3B.js";var u=r(i(),1),d=a();function f({widget:r,menu:i}){let{t:a}=c(),f=l(r,`widget.recent`),p=Math.min(30,Math.max(3,r.count??8)),{data:m,error:h,isLoading:g}=s({},p),_=o().data,v=(0,u.useMemo)(()=>e(_),[_]),y=m?.pages[0]?.items.slice(0,p)??[];return(0,d.jsx)(n,{title:f,titleHref:`#/transactions`,menu:i,loading:g||!_,error:h?.message,empty:m&&y.length===0?a(`recent.empty`):void 0,children:(0,d.jsx)(`ul`,{className:`-mx-2 flex flex-col`,children:y.map(e=>(0,d.jsx)(`li`,{children:(0,d.jsx)(`a`,{href:`#/transactions?tx=${encodeURIComponent(e.id)}&from=${e.date}&to=${e.date}`,className:`block rounded-lg outline-none focus-visible:ring-3 focus-visible:ring-ring/50`,children:(0,d.jsx)(t,{tx:e,names:v})})},e.id))})})}export{f as default};
@@ -0,0 +1 @@
1
+ import{t as e}from"./chevron-down-Co1w7ApZ.js";import{t}from"./chevron-right-Dqh3vs9Y.js";import{B as n,I as r,L as i,f as a,n as o,u as s,v as c,w as l}from"./queries-DZIMMe4i.js";import{B as u,H as d,P as f,U as p,W as m,a as h,it as g,l as _,o as v,u as ee,vt as te}from"./index-eR1GkdC_.js";import{t as y}from"./DrillLink-Bvfam9FA.js";import{t as b}from"./Money-PfFNNDOw.js";import{t as x}from"./Panel-BnfWrw9R.js";import{t as S}from"./bits-Dr2E0ObC.js";import{a as C,n as ne,t as re}from"./charts-BqP7HKwP.js";import{t as ie}from"./shared-Box7on3B.js";import{n as w,t as ae}from"./drill-t1zr57xi.js";var T=n(r(),1),E=i();function oe({category:e}){let{t}=l(),{data:n,error:r,isLoading:i}=o(e,!0);return i?(0,E.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`common.loading`)}):r?(0,E.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`common.error`,{message:r.message})}):n?.length?(0,E.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,E.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground`,children:t(`best.title`)}),(0,E.jsx)(S,{rows:n,limit:2})]}):(0,E.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`best.none`)})}var D=[{id:`this-month`,key:`period.thisMonth`},{id:`last-month`,key:`period.lastMonth`},{id:`3-months`,key:`period.3months`},{id:`6-months`,key:`period.6months`},{id:`this-year`,key:`period.thisYear`},{id:`last-year`,key:`period.lastYear`},{id:`custom`,key:`period.custom`}],O=(e,t)=>e<t?e:t;function k(e,t){let n=t.slice(0,7),r=Number(t.slice(0,4));switch(e){case`this-month`:return{from:`${n}-01`,to:t};case`last-month`:return w(v(n,-1));case`3-months`:return{from:`${v(n,-2)}-01`,to:t};case`6-months`:return{from:`${v(n,-5)}-01`,to:t};case`this-year`:return{from:`${r}-01-01`,to:t};case`last-year`:return{from:`${r-1}-01-01`,to:`${r-1}-12-31`}}}var A=(e,t,n,r)=>{if(t===`(none)`)return null;let i={from:n,to:r};return e===`top`||e===`category`?i.category=t:e===`account`?i.account=t:e===`who`?i.who=t:e===`event`?i.event=t:i.tag=t,i};function j(){let{t:n,lang:r}=l(),i=s().data,o=i?.today??new Date().toISOString().slice(0,10),S=i?.features,j=te(),M=(0,T.useMemo)(()=>new URLSearchParams(j),[j]),N=D.some(e=>e.id===M.get(`p`))?M.get(`p`):`this-month`,P=N===`custom`?{from:M.get(`from`)||`${o.slice(0,7)}-01`,to:M.get(`to`)||o}:k(N,o),se=P.from<=P.to,[F,I]=(0,T.useState)(`top`),[L,ce]=(0,T.useState)(`expense`),[R,z]=(0,T.useState)(new Set),B=(e,t)=>{let n=new URLSearchParams;n.set(`p`,e),e===`custom`&&(n.set(`from`,t?.from??P.from),n.set(`to`,t?.to??P.to)),f(`/reports?${n.toString()}`,{replace:!0})},V=[`top`,`category`,`account`,...S?.who?[`who`]:[],...S?.event?[`event`]:[],...S?.tags?[`tag`]:[]],H=V.includes(F)?F:`top`,U=c(P.from,P.to,H,L),W=c(P.from,P.to,`top`,`expense`),G=P.to.slice(0,7),K=O(P.from.slice(0,7),v(G,-5)),q=K<v(G,-23)?v(G,-23):K,J=a(`${q}-01`,w(G).to),Y=(0,T.useMemo)(()=>{let e=new Map((J.data?.rows??[]).map(e=>[e.key,e])),t=(Number(G.slice(0,4))-Number(q.slice(0,4)))*12+Number(G.slice(5))-Number(q.slice(5))+1;return Array.from({length:t},(t,n)=>{let r=v(q,n),i=e.get(r);return{ym:r,income:i?.income??0,expense:i?.expense??0}})},[J.data,q,G]),X=Y.reduce((e,t)=>e+t.income,0),Z=Y.reduce((e,t)=>e+t.expense,0),Q=X>0?(X-Z)/X*100:null,le=e=>e.income>0?`${_((e.income-e.expense)/e.income*100,r)}%`:``,ue={metric:L===`income`?`income`:`spending`,by:H,from:P.from,to:P.to,compare:`usual`},de={metric:`spending`,by:`month`,from:`${q}-01`,to:w(G).to},fe=!!S?.cards&&L===`expense`&&(H===`top`||H===`category`),pe=e=>z(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n}),$=W.data;return(0,E.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,E.jsxs)(`header`,{className:`flex flex-col gap-1`,children:[(0,E.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:n(`reports.title`)}),$?(0,E.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[(0,E.jsx)(y,{filter:{from:P.from,to:P.to},className:`text-lg font-semibold text-foreground`,children:(0,E.jsx)(b,{amount:$.current})}),` `,$.months>=1?n(`reports.headlineUsual`,{usual:ee($.usual,r)}):n(`reports.headline`)]}):(0,E.jsx)(m,{className:`h-6 w-72`})]}),(0,E.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,E.jsx)(`div`,{className:`-mx-4 overflow-x-auto px-4 pb-1 md:mx-0 md:px-0`,children:(0,E.jsx)(d,{type:`single`,variant:`outline`,value:N,onValueChange:e=>e&&B(e),"aria-label":n(`period.label`),className:`w-max`,children:D.map(e=>(0,E.jsx)(p,{value:e.id,className:`min-h-11 shrink-0 px-3 md:min-h-8`,children:n(e.key)},e.id))})}),N===`custom`&&(0,E.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,E.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,E.jsx)(`span`,{className:`text-muted-foreground`,children:n(`period.from`)}),(0,E.jsx)(g,{type:`date`,value:P.from,max:P.to,onChange:e=>e.target.value&&B(`custom`,{from:e.target.value}),className:`h-11 w-auto md:h-9`})]}),(0,E.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,E.jsx)(`span`,{className:`text-muted-foreground`,children:n(`period.to`)}),(0,E.jsx)(g,{type:`date`,value:P.to,min:P.from,onChange:e=>e.target.value&&B(`custom`,{to:e.target.value}),className:`h-11 w-auto md:h-9`})]})]})]}),se?(0,E.jsxs)(`div`,{className:`grid items-start gap-6 2xl:grid-cols-2`,children:[(0,E.jsxs)(x,{title:n(`reports.compare`),action:(0,E.jsx)(u,{query:ue,title:n(`reports.compare`)}),children:[(0,E.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2`,children:[(0,E.jsxs)(d,{type:`single`,variant:`outline`,size:`sm`,value:L,onValueChange:e=>e&&ce(e),"aria-label":n(`reports.kind`),children:[(0,E.jsx)(p,{value:`expense`,className:`min-h-11 px-3 md:min-h-8`,children:n(`chart.metric.spending`)}),(0,E.jsx)(p,{value:`income`,className:`min-h-11 px-3 md:min-h-8`,children:n(`chart.metric.income`)})]}),(0,E.jsx)(`div`,{className:`-mx-4 max-w-full overflow-x-auto px-4 md:mx-0 md:px-0`,children:(0,E.jsx)(d,{type:`single`,variant:`outline`,size:`sm`,value:H,onValueChange:e=>e&&I(e),"aria-label":n(`reports.groupBy`),className:`w-max`,children:V.map(e=>(0,E.jsx)(p,{value:e,className:`min-h-11 shrink-0 px-3 md:min-h-8`,children:n(`reports.by.${e}`)},e))})})]}),U.error?(0,E.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n(`common.error`,{message:U.error.message})}):U.data?U.data.rows.length===0?(0,E.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n(`reports.empty`)}):(0,E.jsxs)(E.Fragment,{children:[U.data.months<1&&(0,E.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`unusual.needHistory`)}),(0,E.jsxs)(`table`,{className:`w-full text-sm tabular-nums`,children:[(0,E.jsx)(`caption`,{className:`sr-only`,children:n(`reports.compare`)}),(0,E.jsx)(`thead`,{children:(0,E.jsxs)(`tr`,{className:`border-b text-xs text-muted-foreground`,children:[(0,E.jsx)(`th`,{scope:`col`,className:`py-1.5 text-left font-medium`,children:n(`reports.by.${H}`)}),(0,E.jsx)(`th`,{scope:`col`,className:`px-2 py-1.5 text-right font-medium`,children:n(`reports.thisPeriod`)}),(0,E.jsx)(`th`,{scope:`col`,className:`px-2 py-1.5 text-right font-medium`,children:n(`reports.usual`)}),(0,E.jsx)(`th`,{scope:`col`,className:`py-1.5 pl-2 text-right font-medium`,children:n(`reports.change`)})]})}),(0,E.jsx)(`tbody`,{children:[...U.data.rows].sort((e,t)=>Math.abs(t.change)-Math.abs(e.change)).map(r=>{let i=A(H,r.key,P.from,P.to),a=R.has(r.key),o=fe&&r.key!==`(none)`;return(0,E.jsxs)(T.Fragment,{children:[(0,E.jsxs)(`tr`,{className:`border-b last:border-0`,children:[(0,E.jsx)(`td`,{className:`max-w-0 py-0`,children:(0,E.jsxs)(`div`,{className:`flex min-h-11 items-center gap-1`,children:[o&&(0,E.jsx)(`button`,{type:`button`,"aria-expanded":a,"aria-label":n(`reports.bestCard`,{name:r.name}),onClick:()=>pe(r.key),className:`flex size-11 shrink-0 items-center justify-center rounded-md text-muted-foreground outline-none hover:bg-muted focus-visible:ring-3 focus-visible:ring-ring/50 md:size-8`,children:a?(0,E.jsx)(e,{className:`size-4`,"aria-hidden":!0}):(0,E.jsx)(t,{className:`size-4`,"aria-hidden":!0})}),i?(0,E.jsx)(y,{filter:i,className:`truncate`,children:r.name}):(0,E.jsx)(`span`,{className:`truncate`,children:r.name===`(none)`?n(`reports.none`):r.name})]})}),(0,E.jsx)(`td`,{className:`px-2 py-1 text-right`,children:i?(0,E.jsx)(y,{filter:i,children:(0,E.jsx)(b,{amount:r.current,mode:`short`})}):(0,E.jsx)(b,{amount:r.current,mode:`short`})}),(0,E.jsx)(`td`,{className:`px-2 py-1 text-right text-muted-foreground`,children:(0,E.jsx)(b,{amount:r.usual,mode:`short`})}),(0,E.jsxs)(`td`,{className:`py-1 pl-2 text-right`,children:[(0,E.jsx)(b,{amount:r.change,mode:`short`,plus:!0}),(0,E.jsx)(`span`,{className:`block text-xs`,children:r.changePct===null?r.current>0?(0,E.jsx)(`span`,{className:`text-muted-foreground`,children:n(`unusual.new`)}):null:(0,E.jsx)(ie,{pct:r.changePct,goodWhenDown:L===`expense`,className:`text-xs`})})]})]}),o&&a&&(0,E.jsx)(`tr`,{className:`border-b last:border-0`,children:(0,E.jsx)(`td`,{colSpan:4,className:`bg-muted/30 px-3 py-2`,children:(0,E.jsx)(oe,{category:r.key})})})]},r.key)})}),(0,E.jsx)(`tfoot`,{children:(0,E.jsxs)(`tr`,{className:`border-t font-medium`,children:[(0,E.jsx)(`th`,{scope:`row`,className:`py-2 text-left font-medium`,children:n(`reports.total`)}),(0,E.jsx)(`td`,{className:`px-2 py-2 text-right`,children:(0,E.jsx)(b,{amount:U.data.current,mode:`short`})}),(0,E.jsx)(`td`,{className:`px-2 py-2 text-right`,children:(0,E.jsx)(b,{amount:U.data.usual,mode:`short`})}),(0,E.jsx)(`td`,{className:`py-2 pl-2 text-right`,children:(0,E.jsx)(b,{amount:U.data.current-U.data.usual,mode:`short`,plus:!0})})]})})]}),(0,E.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`reports.usualNote`,{n:U.data.months})})]}):(0,E.jsx)(m,{className:`h-40 w-full`})]}),(0,E.jsx)(x,{title:n(`reports.byMonth`),action:(0,E.jsx)(u,{query:de,title:n(`reports.byMonth`)}),children:J.error?(0,E.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n(`common.error`,{message:J.error.message})}):J.data?X===0&&Z===0?(0,E.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n(`incsp.empty`)}):(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:Q===null?n(`incsp.noIncome`):n(`incsp.rate`,{pct:_(Q,r)})}),(0,E.jsx)(`div`,{className:`flex h-56 flex-col`,children:(0,E.jsx)(re,{legend:[{label:n(`tx.in`),color:C.accent},{label:n(`tx.out`),color:C.second}],table:{head:[n(`chart.month`),n(`tx.in`),n(`tx.out`),n(`incsp.rateShort`)],rows:Y.map(e=>[(0,E.jsx)(y,{filter:w(e.ym),children:h(e.ym)},e.ym),_(e.income,r),_(e.expense,r),le(e)])},children:(0,E.jsx)(ne,{data:Y,xKey:`ym`,formatX:e=>h(String(e)),onSelect:e=>f(ae(w(e)).slice(1)),series:[{key:`income`,label:n(`tx.in`),color:C.accent},{key:`expense`,label:n(`tx.out`),color:C.second}]})})})]}):(0,E.jsx)(m,{className:`h-48 w-full`})})]}):(0,E.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n(`reports.badRange`)})]})}export{j as default};
@@ -0,0 +1 @@
1
+ import{t as e}from"./useMutation-_Lw8xXWa.js";import{B as t,F as n,I as r,L as i,T as a,b as o,d as s,s as c,u as l,w as u}from"./queries-DZIMMe4i.js";import{A as d,V as f,W as p,et as m,it as h,j as g,lt as _,s as v,tt as y}from"./index-eR1GkdC_.js";import{t as b}from"./KV-DMA1AlP-.js";import{t as x}from"./Panel-BnfWrw9R.js";import{s as S,t as C}from"./button-rfwMVz0i.js";import{i as w,o as T,r as E,s as D}from"./dist-BDn7ydjn.js";import{t as O}from"./dist-B7PR2b0C.js";import{a as ee,i as te,n as ne,r as k,t as re}from"./select-eaSi9K-d.js";import{t as A}from"./fold-CGWYt9Iu.js";var j=t(r(),1),M=i(),N=Object.defineProperty,P=(e,t)=>N(e,`name`,{value:t,configurable:!0}),F=`Checkbox`,[I,ie]=T(F),[L,R]=I(F);function z(e){let{__scopeCheckbox:t,checked:n,children:r,defaultChecked:i,disabled:a,form:o,name:s,onCheckedChange:c,required:l,value:u=`on`,internal_do_not_use_render:d}=e,[f,p]=E({prop:n,defaultProp:i??!1,onChange:c,caller:F}),[m,h]=j.useState(null),[g,_]=j.useState(null),[v,y]=j.useState(null),b=!m||!!o||!!m.closest(`form`),x={checked:f,disabled:a,setChecked:p,control:m,setControl:h,name:s,form:o,value:u,userClick:v,onUserClick:y,required:l,defaultChecked:!U(i)&&i,isFormControl:b,bubbleInput:g,setBubbleInput:_};return(0,M.jsx)(L,{scope:t,...x,children:H(d)?d(x):r})}P(z,`CheckboxProvider`);var B=`CheckboxTrigger`,ae=j.forwardRef(P(function({__scopeCheckbox:e,onKeyDown:t,onClick:n,...r},i){let{control:a,value:o,disabled:s,checked:c,required:l,setControl:u,setChecked:d,onUserClick:f,isFormControl:p,bubbleInput:m}=R(B,e),h=S(i,u),g=j.useRef(c);return j.useEffect(()=>{let e=a?.form;if(e){let t=P(()=>d(g.current),`reset`);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[a,d]),(0,M.jsx)(D.button,{type:`button`,role:`checkbox`,"aria-checked":U(c)?`mixed`:c,"aria-required":l,"data-state":W(c),"data-disabled":s?``:void 0,disabled:s,value:o,...r,ref:h,onKeyDown:w(t,e=>{e.key===`Enter`&&e.preventDefault()}),onClick:w(n,e=>{let t=e.isPropagationStopped();f({requestedChecked:U(c)?!0:!c,hasConsumerStoppedPropagation:t}),d(e=>U(e)?!0:!e),m&&p&&(t||e.stopPropagation())})})},`CheckboxTrigger`)),V=j.forwardRef(P(function(e,t){let{__scopeCheckbox:n,name:r,checked:i,defaultChecked:a,required:o,disabled:s,value:c,onCheckedChange:l,form:u,...d}=e;return(0,M.jsx)(z,{__scopeCheckbox:n,checked:i,defaultChecked:a,disabled:s,required:o,onCheckedChange:l,name:r,form:u,value:c,internal_do_not_use_render:({isFormControl:e})=>(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(ae,{...d,ref:t,__scopeCheckbox:n}),e&&(0,M.jsx)(le,{__scopeCheckbox:n})]})})},`Checkbox`)),oe=`CheckboxIndicator`,se=j.forwardRef(P(function(e,t){let{__scopeCheckbox:n,forceMount:r,...i}=e,a=R(oe,n);return(0,M.jsx)(O,{present:r||U(a.checked)||a.checked===!0,children:(0,M.jsx)(D.span,{"data-state":W(a.checked),"data-disabled":a.disabled?``:void 0,...i,ref:t,style:{pointerEvents:`none`,...e.style}})})},`CheckboxIndicator`)),ce=`CheckboxBubbleInput`,le=j.forwardRef(P(function({__scopeCheckbox:e,onClick:t,...n},r){let{control:i,userClick:a,checked:o,defaultChecked:s,required:c,disabled:l,name:u,value:d,form:f,bubbleInput:p,setBubbleInput:m}=R(ce,e),h=S(r,m),g=_(i),v=j.useRef(!1),y=j.useRef(o),b=j.useRef(a),x=j.useRef(null);j.useEffect(()=>{let e=p;if(!e)return;let t=window.HTMLInputElement.prototype,n=Object.getOwnPropertyDescriptor(t,`checked`).set;if(!n)return;let r=y.current!==o;y.current=o;let i=a!==null&&a!==b.current;if(b.current=a,i)x.current=r?null:a,r&&(e.indeterminate=U(o),n.call(e,!U(o)&&o)),e.dispatchEvent(new Event(`click`,{bubbles:!a.hasConsumerStoppedPropagation}));else if(r){let t=x.current;x.current=null;let r=t?.requestedChecked===o;v.current=!0,e.indeterminate=U(o),n.call(e,!U(o)&&o),e.dispatchEvent(new Event(`click`,{bubbles:!(r&&t.hasConsumerStoppedPropagation)})),v.current=!1}},[p,o,a]);let C=j.useRef(!U(o)&&o);return(0,M.jsx)(D.input,{type:`checkbox`,"aria-hidden":!0,defaultChecked:s??C.current,required:c,disabled:l,name:u,value:d,form:f,...n,tabIndex:-1,ref:h,onClick:w(t,e=>{v.current&&e.stopPropagation()}),style:{...n.style,...g,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0,transform:`translateX(-100%)`}})},`CheckboxBubbleInput`));function H(e){return typeof e==`function`}P(H,`isFunction`);function U(e){return e===`indeterminate`}P(U,`isIndeterminate`);function W(e){return U(e)?`indeterminate`:e?`checked`:`unchecked`}P(W,`getState`);var ue=Object.defineProperty,G=(e,t)=>ue(e,`name`,{value:t,configurable:!0}),K=`Switch`,[de,fe]=T(K),[q,J]=de(K);function Y(e){let{__scopeSwitch:t,checked:n,children:r,defaultChecked:i,disabled:a,form:o,name:s,onCheckedChange:c,required:l,value:u=`on`,internal_do_not_use_render:d}=e,[f,p]=E({prop:n,defaultProp:i??!1,onChange:c,caller:K}),[m,h]=j.useState(null),[g,_]=j.useState(null),[v,y]=j.useState(null),b={checked:f,setChecked:p,disabled:a,control:m,setControl:h,name:s,form:o,value:u,userClick:v,onUserClick:y,required:l,defaultChecked:i,isFormControl:!m||!!o||!!m.closest(`form`),bubbleInput:g,setBubbleInput:_};return(0,M.jsx)(q,{scope:t,...b,children:X(d)?d(b):r})}G(Y,`SwitchProvider`);var pe=`SwitchTrigger`,me=j.forwardRef(G(function({__scopeSwitch:e,onClick:t,...n},r){let{control:i,form:a,value:o,disabled:s,checked:c,required:l,setControl:u,setChecked:d,onUserClick:f,isFormControl:p,bubbleInput:m}=J(pe,e),h=S(r,u),g=j.useRef(c);return j.useEffect(()=>{let e=a?i?.ownerDocument.getElementById(a):i?.form;if(e instanceof HTMLFormElement){let t=G(()=>d(g.current),`reset`);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[i,a,d]),(0,M.jsx)(D.button,{type:`button`,role:`switch`,"aria-checked":c,"aria-required":l,"data-state":Z(c),"data-disabled":s?``:void 0,disabled:s,value:o,...n,ref:h,onClick:w(t,e=>{let t=e.isPropagationStopped();f({requestedChecked:!c,hasConsumerStoppedPropagation:t}),d(e=>!e),m&&p&&(t||e.stopPropagation())})})},`SwitchTrigger`)),he=j.forwardRef(G(function(e,t){let{__scopeSwitch:n,name:r,checked:i,defaultChecked:a,required:o,disabled:s,value:c,onCheckedChange:l,form:u,...d}=e;return(0,M.jsx)(Y,{__scopeSwitch:n,checked:i,defaultChecked:a,disabled:s,required:o,onCheckedChange:l,name:r,form:u,value:c,internal_do_not_use_render:({isFormControl:e})=>(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(me,{...d,ref:t,__scopeSwitch:n}),e&&(0,M.jsx)(ye,{__scopeSwitch:n})]})})},`Switch`)),ge=`SwitchThumb`,_e=j.forwardRef(G(function(e,t){let{__scopeSwitch:n,...r}=e,i=J(ge,n);return(0,M.jsx)(D.span,{"data-state":Z(i.checked),"data-disabled":i.disabled?``:void 0,...r,ref:t})},`SwitchThumb`)),ve=`SwitchBubbleInput`,ye=j.forwardRef(G(function({__scopeSwitch:e,onClick:t,...n},r){let{control:i,userClick:a,checked:o,defaultChecked:s,required:c,disabled:l,name:u,value:d,form:f,bubbleInput:p,setBubbleInput:m}=J(ve,e),h=S(r,m),g=_(i),v=j.useRef(!1),y=j.useRef(o),b=j.useRef(a),x=j.useRef(null);j.useEffect(()=>{let e=p;if(!e)return;let t=window.HTMLInputElement.prototype,n=Object.getOwnPropertyDescriptor(t,`checked`).set;if(!n)return;let r=y.current!==o;y.current=o;let i=a!==null&&a!==b.current;if(b.current=a,i)x.current=r?null:a,r&&n.call(e,o),e.dispatchEvent(new Event(`click`,{bubbles:!a.hasConsumerStoppedPropagation}));else if(r){let t=x.current;x.current=null;let r=t?.requestedChecked===o;v.current=!0,n.call(e,o),e.dispatchEvent(new Event(`click`,{bubbles:!(r&&t.hasConsumerStoppedPropagation)})),v.current=!1}},[p,o,a]);let C=j.useRef(o);return(0,M.jsx)(D.input,{type:`checkbox`,"aria-hidden":!0,defaultChecked:s??C.current,required:c,disabled:l,name:u,value:d,form:f,...n,tabIndex:-1,ref:h,onClick:w(t,e=>{v.current&&e.stopPropagation()}),style:{...n.style,...g,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0,transform:`translateX(-100%)`}})},`SwitchBubbleInput`));function X(e){return typeof e==`function`}G(X,`isFunction`);function Z(e){return e?`checked`:`unchecked`}G(Z,`getState`);function be({className:e,...t}){return(0,M.jsx)(V,{"data-slot":`checkbox`,className:a(`peer relative flex size-4 shrink-0 items-center justify-center rounded-[4px] border border-input transition-colors outline-none group-has-disabled/field:opacity-50 group-has-[:focus-visible]/field-label:ring-0 group-has-[:focus-visible]/field-label:not-data-checked:border-input after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground group-has-[:focus-visible]/field-label:data-checked:border-primary dark:data-checked:bg-primary`,e),...t,children:(0,M.jsx)(se,{"data-slot":`checkbox-indicator`,className:`grid place-content-center text-current transition-none [&>svg]:size-3.5`,children:(0,M.jsx)(y,{})})})}function xe({className:e,size:t=`default`,...n}){return(0,M.jsx)(he,{"data-slot":`switch`,"data-size":t,className:a(`peer group/switch relative inline-flex shrink-0 items-center rounded-full border border-transparent transition-all outline-none group-has-[:focus-visible]/field-label:border-transparent group-has-[:focus-visible]/field-label:ring-0 after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-[size=default]:h-[18.4px] data-[size=default]:w-[32px] data-[size=sm]:h-[14px] data-[size=sm]:w-[24px] dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:bg-primary data-unchecked:bg-input dark:data-unchecked:bg-input/80 data-disabled:cursor-not-allowed data-disabled:opacity-50`,e),...n,children:(0,M.jsx)(_e,{"data-slot":`switch-thumb`,className:`pointer-events-none block rounded-full bg-background ring-0 transition-transform group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 group-data-[size=default]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=sm]/switch:data-checked:translate-x-[calc(100%-2px)] dark:data-checked:bg-primary-foreground group-data-[size=default]/switch:data-unchecked:translate-x-0 group-data-[size=sm]/switch:data-unchecked:translate-x-0 dark:data-unchecked:bg-foreground`})})}var Q=`__none`;function Se({me:t}){let{t:r,lang:i}=u(),c=n(),l=s().data,d=t.dashboard?.prefs?.pool??{},f=(0,j.useMemo)(()=>(l?.accounts??[]).filter(e=>!e.closed&&l?.types[e.type]?.liquid),[l]),m=(0,j.useMemo)(()=>new Set(f.map(e=>e.id)),[f]),[g,_]=(0,j.useState)(d.on??!0),[v,b]=(0,j.useState)(d.name??``),[S,w]=(0,j.useState)(new Set(d.exclude??[])),[T,E]=(0,j.useState)(d.default_account??``),[D,O]=(0,j.useState)(``),N=(0,j.useMemo)(()=>{let e={on:g};return S.size&&(e.exclude=[...S].sort()),v.trim()&&(e.name=v.trim()),T&&(e.default_account=T),e},[g,S,v,T]),P=(0,j.useMemo)(()=>{let e={on:d.on??!0};return d.exclude?.length&&(e.exclude=[...d.exclude].sort()),d.name?.trim()&&(e.name=d.name.trim()),d.default_account&&(e.default_account=d.default_account),e},[d.on,d.exclude,d.name,d.default_account]),F=JSON.stringify(N)!==JSON.stringify(P),I=e({mutationFn:()=>o(`dashboard`,{method:`PUT`,body:JSON.stringify({prefs:{...t.dashboard?.prefs??{},pool:N}})}),onSuccess:()=>void c.invalidateQueries()});(0,j.useEffect)(()=>{F&&(I.isSuccess||I.isError)&&I.reset()},[F]);let ie=(e,t)=>w(n=>{let r=new Set(n);return t?r.delete(e):r.add(e),r}),L=e=>w(t=>{let n=new Set([...t].filter(e=>!m.has(e)));if(!e)for(let e of m)n.add(e);return n}),R=f.filter(e=>!D||A(`${e.name} ${e.id}`).includes(A(D))),z=f.filter(e=>!S.has(e.id)).length,B=e=>l?.types[e]?.[i]??e;return(0,M.jsxs)(x,{title:r(`pool.name`),children:[(0,M.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:r(`pool.hint`)}),(0,M.jsxs)(`label`,{className:`flex min-h-11 items-center justify-between gap-3 text-sm font-medium`,children:[r(`pool.on`),(0,M.jsx)(xe,{checked:g,onCheckedChange:_})]}),(0,M.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,M.jsx)(`span`,{className:`text-muted-foreground`,children:r(`pool.nameLabel`)}),(0,M.jsx)(h,{value:v,onChange:e=>b(e.target.value),placeholder:r(`pool.name`),maxLength:40,className:`h-11 md:h-9`})]}),(0,M.jsxs)(`div`,{className:a(`flex flex-col gap-1 text-sm`,!g&&`opacity-60`),children:[(0,M.jsx)(`span`,{className:`text-muted-foreground`,children:r(`pool.default`)}),(0,M.jsxs)(re,{value:T||Q,onValueChange:e=>E(e===Q?``:e),disabled:!g,children:[(0,M.jsx)(te,{"aria-label":r(`pool.default`),className:`min-h-11 w-full sm:w-96 md:min-h-8`,children:(0,M.jsx)(ee,{})}),(0,M.jsxs)(ne,{className:`max-h-72`,children:[(0,M.jsx)(k,{value:Q,className:`min-h-11 md:min-h-8`,children:r(`pool.noDefault`)}),f.map(e=>(0,M.jsx)(k,{value:e.id,className:`min-h-11 md:min-h-8`,children:e.name},e.id))]})]}),(0,M.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:r(`pool.defaultHint`)})]}),(0,M.jsxs)(`fieldset`,{disabled:!g,className:a(`flex min-w-0 flex-col gap-2`,!g&&`opacity-60`),children:[(0,M.jsx)(`legend`,{className:`mb-1 text-sm text-muted-foreground`,children:r(`pool.accounts`,{n:z,total:f.length})}),(0,M.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,M.jsx)(h,{type:`search`,value:D,onChange:e=>O(e.target.value),placeholder:r(`filter.search`),"aria-label":r(`filter.search`),className:`h-11 min-w-40 flex-1 md:h-9`}),(0,M.jsx)(C,{type:`button`,variant:`outline`,className:`min-h-11 md:min-h-8`,onClick:()=>L(!0),children:r(`pool.all`)}),(0,M.jsx)(C,{type:`button`,variant:`outline`,className:`min-h-11 md:min-h-8`,onClick:()=>L(!1),children:r(`pool.none`)})]}),l?(0,M.jsxs)(`ul`,{className:`max-h-80 overflow-y-auto rounded-lg border`,children:[R.map(e=>(0,M.jsx)(`li`,{className:`border-b last:border-0`,children:(0,M.jsxs)(`label`,{className:`flex min-h-11 cursor-pointer items-center gap-3 px-3 text-sm`,children:[(0,M.jsx)(be,{checked:!S.has(e.id),onCheckedChange:t=>ie(e.id,t===!0)}),(0,M.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),(0,M.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:B(e.type)})]})},e.id)),R.length===0&&(0,M.jsx)(`li`,{className:`p-3 text-sm text-muted-foreground`,children:r(`filter.noMatch`)})]}):(0,M.jsx)(p,{className:`h-24 w-full`})]}),(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,M.jsx)(C,{type:`button`,className:`min-h-11 md:min-h-8`,disabled:!F||I.isPending,onClick:()=>I.mutate(),children:I.isPending?r(`settings.saving`):r(`settings.save`)}),(0,M.jsxs)(`span`,{"aria-live":`polite`,className:`text-sm`,children:[I.isSuccess&&!F&&(0,M.jsxs)(`span`,{className:`flex items-center gap-1 text-muted-foreground`,children:[(0,M.jsx)(y,{className:`size-4`,"aria-hidden":!0}),r(`settings.saved`)]}),I.isError&&(0,M.jsx)(`span`,{role:`alert`,className:`font-medium text-critical`,children:r(`common.error`,{message:I.error.message})})]})]})]})}function Ce(){let{t:e}=u(),t=`${location.origin}/mcp`,[n,r]=(0,j.useState)(!1),i=(0,j.useRef)(void 0);return(0,j.useEffect)(()=>()=>clearTimeout(i.current),[]),(0,M.jsxs)(x,{title:e(`settings.connector`),children:[(0,M.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`settings.connectorHint`)}),(0,M.jsxs)(`div`,{className:`flex gap-2`,children:[(0,M.jsx)(h,{readOnly:!0,value:t,"aria-label":e(`settings.connector`),onFocus:e=>e.currentTarget.select(),className:`h-11 font-mono md:h-9`}),(0,M.jsxs)(C,{type:`button`,variant:`outline`,className:`min-h-11 shrink-0 md:min-h-8`,onClick:async()=>{await g(t)&&(r(!0),clearTimeout(i.current),i.current=setTimeout(()=>r(!1),2e3))},children:[n?(0,M.jsx)(y,{}):(0,M.jsx)(m,{}),(0,M.jsx)(`span`,{"aria-live":`polite`,children:e(n?`ask.copied`:`common.copy`)})]})]})]})}function $({label:e,confirmLabel:t,onConfirm:n,pending:r}){let{t:i}=u(),[a,o]=(0,j.useState)(!1);return a?(0,M.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,role:`group`,"aria-label":t,children:[(0,M.jsx)(C,{type:`button`,variant:`destructive`,className:`min-h-11 md:min-h-8`,disabled:r,onClick:()=>{n(),o(!1)},children:t}),(0,M.jsx)(C,{type:`button`,variant:`outline`,className:`min-h-11 md:min-h-8`,onClick:()=>o(!1),children:i(`common.cancel`)})]}):(0,M.jsx)(C,{type:`button`,variant:`outline`,className:`min-h-11 md:min-h-8`,onClick:()=>o(!0),children:e})}function we(){let{t}=u(),r=n(),i=e({mutationFn:()=>o(`dashboard`,{method:`DELETE`}),onSuccess:()=>void r.invalidateQueries()});return(0,M.jsxs)(x,{title:t(`settings.reset`),children:[(0,M.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t(`settings.resetHint`)}),(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,M.jsx)($,{label:t(`settings.reset`),confirmLabel:t(`settings.resetConfirm`),pending:i.isPending,onConfirm:()=>i.mutate()}),(0,M.jsxs)(`span`,{"aria-live":`polite`,className:`text-sm`,children:[i.isSuccess&&(0,M.jsxs)(`span`,{className:`flex items-center gap-1 text-muted-foreground`,children:[(0,M.jsx)(y,{className:`size-4`,"aria-hidden":!0}),t(`settings.resetDone`)]}),i.isError&&(0,M.jsx)(`span`,{role:`alert`,className:`font-medium text-critical`,children:t(`common.error`,{message:i.error.message})})]})]})]})}function Te(){let{t,lang:r}=u(),i=n(),{data:a,error:s,isLoading:l}=c(),d=e({mutationFn:e=>o(`grants?id=${encodeURIComponent(e)}`,{method:`DELETE`}),onSuccess:()=>void i.invalidateQueries({queryKey:[`grants`]})}),f=e=>{let t=typeof e==`number`?e<0xe8d4a51000?e*1e3:e:Date.parse(e);return Number.isFinite(t)?v(new Date(t).toISOString(),r):``};return(0,M.jsxs)(x,{title:t(`settings.apps`),children:[s?(0,M.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t(`common.error`,{message:s.message})}):l?(0,M.jsx)(p,{className:`h-16 w-full`}):a?.length?(0,M.jsx)(`ul`,{className:`flex flex-col divide-y`,children:a.map(e=>(0,M.jsxs)(`li`,{className:`flex flex-wrap items-center justify-between gap-2 py-2`,children:[(0,M.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,M.jsx)(`span`,{className:`truncate text-sm font-medium`,children:e.client}),(0,M.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t(`settings.connectedOn`,{date:f(e.created)})})]}),(0,M.jsx)($,{label:t(`settings.revoke`),confirmLabel:t(`settings.revokeConfirm`),pending:d.isPending,onConfirm:()=>d.mutate(e.id)})]},e.id))}):(0,M.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t(`settings.appsEmpty`)}),d.isError&&(0,M.jsx)(`p`,{role:`alert`,className:`text-sm font-medium text-critical`,children:t(`common.error`,{message:d.error.message})})]})}function Ee(){let{t:e}=u(),t=l().data;if(!t)return(0,M.jsx)(p,{className:`h-8 w-48`});let n=t.check.errors>0;return(0,M.jsxs)(`div`,{className:`flex max-w-3xl flex-col gap-4`,children:[(0,M.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:e(`settings.title`)}),(0,M.jsx)(x,{title:e(`lang.label`),children:(0,M.jsx)(f,{className:`self-start`})}),(0,M.jsx)(Se,{me:t}),(0,M.jsx)(Ce,{}),!t.features?.imports&&(0,M.jsx)(x,{title:e(`import.title`),children:(0,M.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`import.cli`)})}),(0,M.jsxs)(x,{title:e(`settings.data`),children:[(0,M.jsxs)(`dl`,{className:`divide-y`,children:[(0,M.jsx)(b,{label:e(`settings.repo`),children:t.data}),(0,M.jsx)(b,{label:e(`settings.commit`),children:(0,M.jsx)(`span`,{className:`font-mono`,children:t.commit.slice(0,10)})}),(0,M.jsx)(b,{label:e(`settings.checkLabel`),children:(0,M.jsx)(`span`,{className:a(n&&`font-medium text-critical`),children:e(`settings.check`,{errors:t.check.errors,warnings:t.check.warnings})})}),(0,M.jsx)(b,{label:e(`settings.versionLabel`),children:t.version})]}),(t.check.errors>0||t.check.warnings>0)&&(0,M.jsx)(d,{className:`self-start`,prompt:e(`ask.check`)})]}),(0,M.jsx)(Te,{}),(0,M.jsx)(we,{})]})}export{Ee as default};
@@ -0,0 +1 @@
1
+ import{n as e,t}from"./Combobox-xXeyjGgK.js";import{A as n,G as r,J as i,K as a,P as o,W as s,X as c,Y as l,it as u,k as d,o as f,q as p,s as m,t as ee,vt as te}from"./index-eR1GkdC_.js";import{B as h,I as g,L as _,T as v,d as y,g as ne,u as b,w as x}from"./queries-DZIMMe4i.js";import{t as S}from"./Money-PfFNNDOw.js";import{t as C}from"./CategoryIcon-HfjYhH1l.js";import{t as w}from"./button-rfwMVz0i.js";import{n as re,r as T,t as ie}from"./TxRow-EKIIMQKa.js";import{n as ae}from"./CategoryPicker-BkmvzX2I.js";import{n as E}from"./drill-t1zr57xi.js";var D=h(g(),1),O=_();function k({label:e,children:t}){return(0,O.jsxs)(`div`,{className:`flex items-baseline justify-between gap-4 py-1.5 text-sm`,children:[(0,O.jsx)(`dt`,{className:`shrink-0 text-muted-foreground`,children:e}),(0,O.jsx)(`dd`,{className:`min-w-0 text-right break-words`,children:t})]})}function A({tx:e,names:t,account:r,Header:i=`div`,Title:a=`h2`,Description:o=`p`,actions:s}){let{t:c,lang:l}=x(),u=T(e,t,r),d=u.kind===`transfer`?c(`tx.transfer`):t.category(u.category);return(0,O.jsxs)(O.Fragment,{children:[s,(0,O.jsxs)(i,{children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,O.jsx)(C,{category:u.category,name:d,transfer:u.kind===`transfer`}),(0,O.jsxs)(`div`,{className:`min-w-0`,children:[(0,O.jsx)(a,{className:`truncate`,children:e.note||d}),(0,O.jsxs)(o,{children:[m(e.date,l,{weekday:`long`,day:`2-digit`,month:`2-digit`,year:`numeric`}),e.time?` · ${e.time}`:``]})]})]}),(0,O.jsx)(S,{amount:u.amount,tone:u.kind===`transfer`?`transfer`:`auto`,className:`text-2xl font-semibold`}),e.void&&(0,O.jsx)(`p`,{className:`text-sm text-critical`,children:c(`tx.void`)})]}),(0,O.jsxs)(`div`,{className:`flex flex-col gap-4 px-4 pb-4`,children:[(0,O.jsxs)(`section`,{"aria-label":c(`tx.lines`),children:[(0,O.jsx)(`h3`,{className:`mb-1 text-xs font-medium tracking-wide text-muted-foreground uppercase`,children:c(`tx.lines`)}),(0,O.jsx)(`ul`,{className:`divide-y rounded-lg border`,children:e.lines.map((e,n)=>(0,O.jsxs)(`li`,{className:`flex items-start justify-between gap-3 p-2.5 text-sm`,children:[(0,O.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[e.account&&(0,O.jsx)(`span`,{className:`truncate`,children:t.account(e.account)}),e.category&&(0,O.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:t.categoryPath(e.category)}),e.asset&&(0,O.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[e.asset,e.qty===void 0?``:` × ${e.qty}`]}),e.note&&(0,O.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.note})]}),(0,O.jsx)(S,{amount:e.amount,tone:`auto`,plus:!0,className:`shrink-0`})]},n))})]}),(0,O.jsxs)(`dl`,{className:`divide-y`,children:[e.who&&(0,O.jsx)(k,{label:c(`tx.who`),children:e.who}),e.event&&(0,O.jsx)(k,{label:c(`tx.event`),children:e.event}),e.tags&&e.tags.length>0&&(0,O.jsx)(k,{label:c(`tx.tags`),children:e.tags.map(e=>`#${e}`).join(` `)}),e.plan&&(0,O.jsx)(k,{label:c(`tx.plan`),children:e.plan}),(0,O.jsx)(k,{label:c(`tx.id`),children:(0,O.jsx)(`code`,{className:`text-xs`,children:e.id})})]}),(0,O.jsx)(n,{size:`default`,label:c(`tx.askEdit`),prompt:c(`ask.editTx`,{id:e.id,date:e.date,summary:`${e.note||d}, ${u.amount}`})})]})]})}function oe({tx:e,names:t,onClose:n,account:o}){let s=d(`(max-width: 767px)`);return(0,O.jsx)(r,{open:!!e,onOpenChange:e=>!e&&n(),children:(0,O.jsx)(a,{side:s?`bottom`:`right`,className:s?`max-h-[85svh] overflow-auto rounded-t-xl`:`overflow-auto sm:max-w-md`,children:e&&(0,O.jsx)(A,{tx:e,names:t,account:o,Header:i,Title:l,Description:p})})})}function se({tx:e,names:t,onClose:n,account:r}){let{t:i}=x();return(0,O.jsx)(`aside`,{"aria-label":i(`tx.details`),className:`sticky top-6 max-h-[calc(100svh-3rem)] overflow-auto rounded-xl border bg-card text-card-foreground`,children:(0,O.jsx)(A,{tx:e,names:t,account:r,Header:j,Title:M,Description:N,actions:(0,O.jsx)(w,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":i(`tx.close`),className:`absolute top-2 right-2`,onClick:n,children:(0,O.jsx)(c,{})})})})}function j({children:e}){return(0,O.jsx)(`div`,{className:`flex flex-col gap-1.5 p-4 pr-12`,children:e})}function M({children:e,className:t}){return(0,O.jsx)(`h2`,{className:v(`font-heading text-base font-medium`,t),children:e})}function N({children:e}){return(0,O.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e})}function ce(){let{t:e,lang:t}=x(),n=y().data,r=b().data?.pool,i=r?.name??e(`pool.name`);return(0,D.useMemo)(()=>{let a=[];r?.on&&a.push({options:[{value:`pool`,label:i}]});let o=(n?.accounts??[]).filter(e=>!e.closed),s=(n?.accounts??[]).filter(e=>e.closed),c=new Map;for(let e of o)c.set(e.type,[...c.get(e.type)??[],e]);let l=e=>n?.types[e]?.[t]??e;for(let[e,n]of[...c].sort((e,n)=>l(e[0]).localeCompare(l(n[0]),t)))a.push({heading:l(e),options:n.map(e=>({value:e.id,label:e.name,keywords:[e.id]}))});return s.length&&a.push({heading:e(`filter.closed`),options:s.map(e=>({value:e.id,label:e.name,keywords:[e.id]}))}),a},[n,r?.on,i,t,e])}var P=[`from`,`to`,`account`,`category`,`text`,`who`,`event`,`tag`,`tx`,`plan`,`within`,`all`];function F(e,t){let n=t.slice(0,7);switch(e){case`this-month`:return E(n);case`last-month`:return E(f(n,-1));case`3-months`:return{from:`${f(n,-2)}-01`,to:E(n).to};case`this-year`:return{from:`${t.slice(0,4)}-01-01`,to:`${t.slice(0,4)}-12-31`}}}function le(e){let t=new URLSearchParams(e),n={};for(let e of P){let r=t.get(e);r&&(n[e]=r)}return n}var I=e=>{let t=new URLSearchParams;for(let n of P)e[n]&&t.set(n,e[n]);return t.toString()};function L(){let{t:n,lang:r}=x(),i=te(),a=b().data,l=y().data,f=(0,D.useMemo)(()=>re(l),[l]),p=a?.today??new Date().toISOString().slice(0,10),h=a?.pool,g=h?.name??n(`pool.name`),_=(0,D.useMemo)(()=>le(i),[i]),C=!i,E=(0,D.useMemo)(()=>_.all?{..._,from:void 0,to:void 0}:C?{...F(`this-month`,p)}:_,[_,C,p]),k=(0,D.useCallback)((e,t=!1)=>{let n={...C?E:_,...e};for(let e of P)(n[e]===void 0||n[e]===``)&&delete n[e];(e.from!==void 0||e.to!==void 0)&&delete n.all,o(`/transactions${I(n)?`?${I(n)}`:``}`,{replace:t})},[C,E,_]),[A,j]=(0,D.useState)(_.text??``);(0,D.useEffect)(()=>j(_.text??``),[_.text]),(0,D.useEffect)(()=>{if(A===(_.text??``))return;let e=setTimeout(()=>k({text:A.trim()||void 0},!0),300);return()=>clearTimeout(e)},[A,_.text,k]);let M=(0,D.useMemo)(()=>{let e={};for(let t of P)t!==`all`&&(e[t]=E[t]);return e},[E]),{data:N,isLoading:L,isFetching:ue,isFetchingNextPage:R,hasNextPage:de,fetchNextPage:fe,error:z,refetch:pe}=ne(M),B=(0,D.useMemo)(()=>N?.pages.flatMap(e=>e.items)??[],[N]),V=N?.pages[0]?.totals,H=E.account&&E.account!==`pool`&&!E.account.includes(`,`)?E.account:void 0,[U,W]=(0,D.useState)(null),G=(0,D.useRef)(null);(0,D.useEffect)(()=>{_.tx&&B.length===1&&G.current!==_.tx&&(G.current=_.tx,W(B[0].id))},[_.tx,B]);let K=B.find(e=>e.id===U)??null,q=d(`(min-width: 1280px)`),J=(0,D.useMemo)(()=>{if(!E.from&&!E.to)return`all`;for(let e of[`this-month`,`last-month`,`3-months`,`this-year`]){let t=F(e,p);if(t.from===E.from&&t.to===E.to)return e}return`custom`},[E.from,E.to,p]),[me,Y]=(0,D.useState)(!1),he=me||J===`custom`,ge=e=>{if(e===`all`)return k({from:void 0,to:void 0,all:`1`});e===`custom`?Y(!0):(Y(!1),k(F(e,p)))},_e=[{id:`this-month`,label:n(`period.thisMonth`)},{id:`last-month`,label:n(`period.lastMonth`)},{id:`3-months`,label:n(`period.3months`)},{id:`this-year`,label:n(`period.thisYear`)},{id:`all`,label:n(`period.all`)},{id:`custom`,label:n(`period.custom`)}],ve=ce(),ye=(0,D.useMemo)(()=>ae(l),[l]),X=[];E.account&&X.push({key:`account`,label:E.account===`pool`?g:E.account.split(`,`).map(e=>f.account(e)).join(`, `)}),E.category&&X.push({key:`category`,label:f.categoryPath(E.category)}),E.text&&X.push({key:`text`,label:`“${E.text}”`}),E.who&&X.push({key:`who`,label:n(`chip.who`,{v:E.who})}),E.event&&X.push({key:`event`,label:n(`chip.event`,{v:E.event})}),E.tag&&X.push({key:`tag`,label:`#${E.tag}`}),E.plan&&X.push({key:`plan`,label:n(`chip.plan`,{v:E.plan})}),E.tx&&X.push({key:`tx`,label:n(`chip.tx`)});let Z=!!h?.on&&(!E.account||E.account===`pool`),be=(0,D.useMemo)(()=>{let e=[];for(let t of B){let n=e[e.length-1];n&&n.date===t.date||(n={date:t.date,items:[],net:0},e.push(n)),n.items.push(t);let r=T(t,f,H);!t.void&&(H||r.kind!==`transfer`)&&(n.net+=r.amount)}return e},[B,f,H]),Q=e=>{let t=r===`vi`?`${e.slice(8,10)}/${e.slice(5,7)}`:m(e,r,{day:`2-digit`,month:`2-digit`});if(e===p)return`${n(`tx.today`)}, ${t}`;if(e===ee(p,-1))return`${n(`tx.yesterday`)}, ${t}`;let i=m(e,r,{weekday:`long`,day:`2-digit`,month:`2-digit`,...e.slice(0,4)===p.slice(0,4)?{}:{year:`numeric`}});return i.charAt(0).toLocaleUpperCase(r)+i.slice(1)},$=X.length>0||J!==`this-month`;return(0,O.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,O.jsxs)(`header`,{className:`flex flex-col gap-1`,children:[(0,O.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:n(`transactions.title`)}),V?(0,O.jsxs)(`p`,{className:`text-sm text-muted-foreground`,"aria-live":`polite`,children:[(0,O.jsxs)(`span`,{children:[n(`tx.in`),` `,(0,O.jsx)(S,{amount:V.income,tone:`in`,mode:`short`,className:`font-medium`})]}),` · `,(0,O.jsxs)(`span`,{children:[n(`tx.out`),` `,(0,O.jsx)(S,{amount:V.expense,mode:`short`,className:`font-medium text-foreground`})]}),` · `,(0,O.jsxs)(`span`,{children:[n(`tx.net`),` `,(0,O.jsx)(S,{amount:V.net,tone:`auto`,mode:`short`,className:`font-medium`})]}),` · `,(0,O.jsx)(`span`,{children:n(`tx.count`,{n:V.count})})]}):(0,O.jsx)(s,{className:`h-5 w-72`})]}),(0,O.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,O.jsxs)(`div`,{className:`relative`,children:[(0,O.jsx)(e,{className:`pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-muted-foreground`,"aria-hidden":!0}),(0,O.jsx)(u,{type:`search`,value:A,onChange:e=>j(e.target.value),placeholder:n(`filter.searchPlaceholder`),"aria-label":n(`filter.searchLabel`),className:`h-11 pl-9 md:h-9`})]}),(0,O.jsx)(`div`,{className:`-mx-4 flex gap-2 overflow-x-auto px-4 pb-1 md:mx-0 md:flex-wrap md:px-0`,role:`group`,"aria-label":n(`period.label`),children:_e.map(e=>(0,O.jsx)(w,{type:`button`,size:`sm`,variant:J===e.id?`default`:`outline`,"aria-pressed":J===e.id,className:`min-h-11 shrink-0 rounded-full px-3 md:min-h-8`,onClick:()=>ge(e.id),children:e.label},e.id))}),he&&(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,O.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,O.jsx)(`span`,{className:`text-muted-foreground`,children:n(`period.from`)}),(0,O.jsx)(u,{type:`date`,value:E.from??``,max:E.to||void 0,onChange:e=>k({from:e.target.value||void 0}),className:`h-11 w-auto md:h-9`})]}),(0,O.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,O.jsx)(`span`,{className:`text-muted-foreground`,children:n(`period.to`)}),(0,O.jsx)(u,{type:`date`,value:E.to??``,min:E.from||void 0,onChange:e=>k({to:e.target.value||void 0}),className:`h-11 w-auto md:h-9`})]})]}),(0,O.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,O.jsx)(t,{label:n(`filter.account`),groups:ve,value:E.account,onSelect:e=>k({account:e}),className:`w-full sm:w-52`}),(0,O.jsx)(t,{label:n(`filter.category`),groups:ye,value:E.category,onSelect:e=>k({category:e}),className:`w-full sm:w-52`})]}),(X.length>0||Z)&&(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[X.map(e=>(0,O.jsxs)(`span`,{className:`inline-flex min-h-11 items-center gap-1 rounded-full bg-secondary pl-3 text-sm text-secondary-foreground md:min-h-8`,children:[(0,O.jsx)(`span`,{className:`max-w-56 truncate`,children:e.label}),(0,O.jsx)(`button`,{type:`button`,"aria-label":n(`filter.remove`,{name:e.label}),className:`flex size-11 items-center justify-center rounded-full outline-none hover:bg-foreground/10 focus-visible:ring-3 focus-visible:ring-ring/50 md:size-8`,onClick:()=>k({[e.key]:void 0,...e.key===`tx`?{from:void 0,to:void 0}:{}}),children:(0,O.jsx)(c,{className:`size-3.5`})})]},e.key)),Z&&(0,O.jsx)(w,{type:`button`,size:`sm`,variant:E.within===`1`?`default`:`outline`,"aria-pressed":E.within===`1`,className:`min-h-11 rounded-full md:min-h-8`,onClick:()=>k({within:E.within===`1`?void 0:`1`}),children:n(`filter.within`,{name:g})})]})]}),z?(0,O.jsxs)(`div`,{className:`flex flex-col items-start gap-2 text-sm`,children:[(0,O.jsx)(`p`,{children:n(`common.error`,{message:z.message})}),(0,O.jsx)(w,{type:`button`,variant:`outline`,className:`min-h-11`,onClick:()=>void pe(),children:n(`common.retry`)})]}):L||!l?(0,O.jsx)(`div`,{className:`flex flex-col gap-3`,"aria-busy":`true`,children:Array.from({length:6},(e,t)=>(0,O.jsx)(s,{className:`h-12 w-full`},t))}):B.length===0?(0,O.jsxs)(`div`,{className:`flex flex-col items-start gap-3 rounded-lg border border-dashed p-6 text-sm text-muted-foreground`,children:[(0,O.jsx)(`p`,{children:n($?`tx.emptyFiltered`:`tx.empty`)}),$&&(0,O.jsx)(w,{type:`button`,variant:`outline`,className:`min-h-11`,onClick:()=>o(`/transactions?all=1`),children:n(`filter.clear`)})]}):(0,O.jsxs)(`div`,{className:v(q&&K&&`grid grid-cols-[minmax(0,1fr)_380px] items-start gap-6`),children:[(0,O.jsxs)(`div`,{className:v(`flex flex-col`,ue&&!R&&`opacity-70`),children:[H&&(0,O.jsx)(`p`,{className:`px-2 pb-1 text-right text-xs text-muted-foreground`,children:n(`tx.balanceCol`)}),be.map(e=>(0,O.jsxs)(`section`,{"aria-label":Q(e.date),children:[(0,O.jsxs)(`h2`,{className:`sticky top-0 z-10 flex items-baseline justify-between gap-2 border-b bg-background/95 px-2 py-2 text-sm font-medium backdrop-blur`,children:[(0,O.jsx)(`span`,{children:Q(e.date)}),(0,O.jsx)(S,{amount:e.net,mode:`short`,tone:e.net>0?`in`:`none`,plus:!0,className:`text-sm`})]}),(0,O.jsx)(`ul`,{children:e.items.map(e=>(0,O.jsx)(`li`,{children:(0,O.jsx)(ie,{tx:e,names:f,account:H,showBalance:!!H,balance:e.balance,selected:e.id===U,onOpen:()=>W(e.id)})},e.id))})]},e.date)),de&&(0,O.jsx)(w,{type:`button`,variant:`outline`,className:`mt-4 min-h-11 self-center`,disabled:R,onClick:()=>void fe(),children:n(R?`common.loading`:`tx.loadMore`)})]}),q&&K&&(0,O.jsx)(se,{tx:K,names:f,account:H,onClose:()=>W(null)})]}),!q&&(0,O.jsx)(oe,{tx:K,names:f,account:H,onClose:()=>W(null)})]})}export{L as default};
@@ -0,0 +1 @@
1
+ import{t as e}from"./CategoryIcon-HfjYhH1l.js";import{t}from"./Money-PfFNNDOw.js";import{L as n,T as r,w as i}from"./queries-DZIMMe4i.js";function a(e){let t=new Map((e?.accounts??[]).map(e=>[e.id,e.name])),n=new Map((e?.categories??[]).map(e=>[e.path,e.name])),r=e=>n.get(e)??e.split(`/`).pop()??e;return{account:e=>e?t.get(e)??e:``,category:e=>e?r(e):``,categoryPath:e=>{if(!e)return``;let t=e.split(`/`);return t.map((e,n)=>r(t.slice(0,n+1).join(`/`))).join(` › `)}}}var o=e=>e.startsWith(`_`);function s(e,t,n){let r=e.lines.filter(e=>e.category&&!o(e.category)),i=n?e.lines.filter(e=>e.account===n).reduce((e,t)=>e+t.amount,0):null;if(r.length===0){let n=[...new Set(e.lines.filter(e=>e.amount<0&&e.account).map(e=>t.account(e.account)))],r=[...new Set(e.lines.filter(e=>e.amount>0&&e.account).map(e=>t.account(e.account)))],a=e.lines.reduce((e,t)=>e+Math.max(0,t.amount),0);return{kind:`transfer`,amount:i??a,category:null,from:n,to:r}}let a=-r.reduce((e,t)=>e+t.amount,0),s=[...r].sort((e,t)=>Math.abs(t.amount)-Math.abs(e.amount))[0];return{kind:a<0?`out`:`in`,amount:i??a,category:s.category??null,from:[],to:[]}}var c=n();function l({tx:n,names:a,account:o,onOpen:l,selected:u,balance:d,showBalance:f,className:p}){let{t:m}=i(),h=s(n,a,o),g=h.kind===`transfer`?m(`tx.transfer`):a.category(h.category),_=[h.kind===`transfer`&&(h.from.length||h.to.length)?`${h.from.join(`, `)||`?`} → ${h.to.join(`, `)||`?`}`:null,n.note,n.who].filter(Boolean).join(` · `),v=(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(e,{category:h.category,name:g,transfer:h.kind===`transfer`}),(0,c.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col text-left`,children:[(0,c.jsx)(`span`,{className:r(`truncate text-sm font-medium`,n.void&&`line-through`),children:g}),_&&(0,c.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:_})]}),(0,c.jsxs)(`span`,{className:`flex shrink-0 flex-col items-end`,children:[(0,c.jsx)(t,{amount:h.amount,tone:h.kind===`transfer`?`transfer`:h.amount>0?`in`:`none`,plus:!0,className:`text-sm font-medium`}),f&&d!=null&&(0,c.jsx)(t,{amount:d,className:`text-xs text-muted-foreground`})]})]}),y=r(`flex min-h-14 w-full items-center gap-3 rounded-lg px-2 py-2 outline-none`,l&&`hover:bg-muted/60 focus-visible:ring-3 focus-visible:ring-ring/50`,u&&`bg-muted`,p);return l?(0,c.jsx)(`button`,{type:`button`,className:y,onClick:l,children:v}):(0,c.jsx)(`div`,{className:y,children:v})}export{a as n,s as r,l as t};
@@ -0,0 +1 @@
1
+ import{n as e,t}from"./arrow-up-D3gxUKLo.js";import{t as n}from"./chevron-right-Dqh3vs9Y.js";import{M as r,Z as i}from"./index-eR1GkdC_.js";import{t as a}from"./triangle-exclamation-point-CuL0XSJl.js";import{t as o}from"./Money-PfFNNDOw.js";import{L as s,c,u as l,w as u}from"./queries-DZIMMe4i.js";import{n as d}from"./shared-Box7on3B.js";var f=s();function p(n){let{t:r}=u();switch(n.kind){case`category_up`:return{icon:t,iconLabel:r(`delta.up`),label:n.name,amount:n.current,meta:r(`unusual.vsUsual`,{pct:`+${Math.round(n.changePct)}`}),tone:`text-critical`};case`category_down`:return{icon:e,iconLabel:r(`delta.down`),label:n.name,amount:n.current,meta:r(`unusual.vsUsual`,{pct:`${Math.round(n.changePct)}`.replace(`-`,`−`)}),tone:`text-positive`};case`new_category`:return{icon:i,iconLabel:r(`unusual.new`),label:r(`unusual.new_category`,{name:n.name}),amount:n.amount,meta:null,tone:`text-foreground`};case`new_who`:return{icon:i,iconLabel:r(`unusual.new`),label:r(`unusual.new_who`,{who:n.who}),amount:n.amount,meta:r(`unusual.times`,{n:n.count}),tone:`text-foreground`};case`large`:return{icon:a,iconLabel:r(`unusual.large`),label:r(`unusual.large_label`,{name:n.note||n.name}),amount:n.amount,meta:null,tone:`text-warning`}}}function m({c:e}){let t=p(e),r=t.icon;return(0,f.jsx)(`li`,{children:(0,f.jsxs)(`a`,{href:e.link,className:`flex min-h-11 items-center gap-3 rounded-md py-1 outline-none hover:bg-muted/50 focus-visible:ring-3 focus-visible:ring-ring/50`,children:[(0,f.jsx)(r,{className:`size-4 shrink-0 ${t.tone}`,"aria-hidden":!0}),(0,f.jsx)(`span`,{className:`sr-only`,children:t.iconLabel}),(0,f.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,f.jsx)(`span`,{className:`truncate text-sm`,children:t.label}),t.meta&&(0,f.jsx)(`span`,{className:`text-xs ${t.tone}`,children:t.meta})]}),(0,f.jsx)(o,{amount:t.amount,mode:`short`,className:`shrink-0 text-sm font-medium`}),(0,f.jsx)(n,{className:`size-4 shrink-0 text-muted-foreground`,"aria-hidden":!0})]})})}function h({widget:e,menu:t}){let{t:n}=u(),i=d(e,`widget.unusual`),{data:a,error:o,isLoading:s}=c(),p=l().data?.features,h=(a?.unusual??[]).slice(0,5),g=a&&h.length===0?p&&p.historyMonths<2?n(`unusual.needHistory`):n(`unusual.empty`):void 0;return(0,f.jsx)(r,{title:i,menu:t,loading:s,error:o?.message,empty:g,children:(0,f.jsx)(`ul`,{className:`flex flex-col`,children:h.map((e,t)=>(0,f.jsx)(m,{c:e},`${e.kind}-${t}`))})})}export{h as default};
@@ -0,0 +1 @@
1
+ import{B as e,I as t,L as n,T as r,i,p as a,u as o,w as s}from"./queries-DZIMMe4i.js";import{t as c}from"./Money-PfFNNDOw.js";import{M as l,n as u,r as d,t as f}from"./index-eR1GkdC_.js";import{n as p}from"./shared-Box7on3B.js";var m=e(t(),1),h=n();function g({widget:e,menu:t}){let{t:n}=s(),g=p(e,`widget.upcoming`),_=o().data,v=_?.today??``,y=a(30),b=i(!!_?.features?.cards),x=y.isLoading||!!_?.features?.cards&&b.isLoading,{items:S,weeks:C,total:w}=(0,m.useMemo)(()=>{let e=[];for(let t of y.data?.due??[])e.push({key:`p-${t.plan}-${t.date}`,name:t.name,date:t.date,amount:t.amount,overdue:t.overdue,href:`#/plans`});let t=f(v,30);for(let n of b.data??[])0<(n.toPay??0)&&n.dueDate&&n.dueDate<=t&&e.push({key:`c-${n.account}`,name:n.name,date:n.dueDate,amount:n.toPay,overdue:n.dueDate<v,href:`#/cards/${encodeURIComponent(n.account)}`});e.sort((e,t)=>e.date.localeCompare(t.date));let n=Array.from({length:5},(e,t)=>({start:f(v,t*7),amount:0}));for(let t of e){let e=Math.min(4,Math.max(0,Math.floor(d(v,t.date)/7)));n[e].amount+=t.amount}return{items:e,weeks:n,total:e.reduce((e,t)=>e+t.amount,0)}},[y.data,b.data,v]),T=Math.max(1,...C.map(e=>e.amount));return(0,h.jsxs)(l,{title:g,titleHref:`#/plans`,menu:t,loading:x,error:y.error?.message,empty:!x&&S.length===0?n(`upcoming.empty`):void 0,children:[(0,h.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[n(`upcoming.total`),` `,(0,h.jsx)(c,{amount:w,mode:`short`,className:`font-medium text-foreground`})]}),(0,h.jsx)(`ol`,{className:`grid grid-cols-5 gap-1.5`,"aria-label":n(`upcoming.weeks`),children:C.map(e=>(0,h.jsxs)(`li`,{className:`flex flex-col items-center gap-1`,children:[(0,h.jsx)(`span`,{className:`flex h-10 w-full items-end rounded-sm bg-muted`,children:(0,h.jsx)(`span`,{className:`w-full rounded-sm`,style:{height:`${e.amount?Math.max(8,e.amount/T*100):0}%`,background:`var(--chart-1)`}})}),(0,h.jsx)(`span`,{className:`text-[11px] text-muted-foreground tabular-nums`,children:u(e.start)}),(0,h.jsx)(`span`,{className:`text-xs tabular-nums`,children:e.amount?(0,h.jsx)(c,{amount:e.amount,mode:`short`}):`–`})]},e.start))}),(0,h.jsx)(`ul`,{className:`flex flex-col divide-y`,children:S.slice(0,6).map(e=>(0,h.jsx)(`li`,{children:(0,h.jsxs)(`a`,{href:e.href,className:`flex min-h-11 items-center gap-2 rounded-md py-1 outline-none hover:bg-muted/50 focus-visible:ring-3 focus-visible:ring-ring/50`,children:[(0,h.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,h.jsx)(`span`,{className:`truncate text-sm`,children:e.name}),(0,h.jsx)(`span`,{className:r(`text-xs`,e.overdue?`text-critical`:`text-muted-foreground`),children:e.overdue?n(`upcoming.overdue`,{date:u(e.date)}):u(e.date)})]}),(0,h.jsx)(c,{amount:e.amount,mode:`short`,className:`shrink-0 text-sm font-medium`})]})},e.key))})]})}export{g as default};
@@ -0,0 +1 @@
1
+ import{B as e,I as t,L as n,n as r,u as i,w as a}from"./queries-DZIMMe4i.js";import{t as o}from"./bits-Dr2E0ObC.js";import{t as s}from"./CategoryPicker-BkmvzX2I.js";import{M as c}from"./index-eR1GkdC_.js";import{n as l}from"./shared-Box7on3B.js";var u=e(t(),1),d=n();function f({widget:e,menu:t}){let{t:n}=a(),f=l(e,`widget.which_card`),p=!!i().data?.features?.cards,[m,h]=(0,u.useState)(void 0),{data:g,error:_,isLoading:v}=r(m,p),y=(0,u.useMemo)(()=>g??[],[g]);return(0,d.jsxs)(c,{title:f,menu:t,empty:p?void 0:n(`cards.emptyCredit`),children:[(0,d.jsx)(s,{value:m,onSelect:h}),m?_?(0,d.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n(`common.error`,{message:_.message})}):v?(0,d.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n(`common.loading`)}):y.length===0?(0,d.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n(`best.none`)}):(0,d.jsx)(o,{rows:y}):(0,d.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n(`best.pick`)})]})}export{f as default};
@@ -0,0 +1 @@
1
+ import{t as e}from"./createLucideIcon-flJrJK2p.js";var t={name:`arrow-down`,size:24,node:[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]};t.node;var n=e(t),r={name:`arrow-up`,size:24,node:[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]};r.node;var i=e(r);export{n,i as t};
@@ -0,0 +1 @@
1
+ import{A as e,l as t,n,tt as r,u as i}from"./index-eR1GkdC_.js";import{t as a}from"./Money-PfFNNDOw.js";import{L as o,T as s,w as c}from"./queries-DZIMMe4i.js";import{t as l}from"./cards-Bb5zjzRG.js";var u=o();function d({owed:e,limit:t,atLeast:n,className:r}){let{t:o,lang:l}=c(),d=t?Math.min(1,Math.max(0,e/t)):0,f=t&&e/t>=1?`bg-critical`:t&&e/t>=.8?`bg-warning`:`bg-[var(--chart-1)]`;return(0,u.jsxs)(`div`,{className:s(`flex flex-col gap-1`,r),children:[t?(0,u.jsx)(`div`,{role:`progressbar`,"aria-label":o(`cards.used`),"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(d*100),className:`h-2 w-full rounded-full bg-muted`,children:(0,u.jsx)(`div`,{className:s(`h-2 rounded-full`,f),style:{width:`${Math.max(d?2:0,d*100)}%`}})}):(0,u.jsx)(`div`,{className:`h-2 w-full rounded-full bg-muted`,"aria-hidden":!0}),(0,u.jsxs)(`p`,{className:`flex flex-wrap items-baseline justify-between gap-x-2 text-xs text-muted-foreground tabular-nums`,children:[(0,u.jsxs)(`span`,{children:[(0,u.jsx)(a,{amount:e,mode:`short`,className:`font-medium text-foreground`}),t?(0,u.jsxs)(u.Fragment,{children:[` `,o(`cards.ofLimit`),` `,(0,u.jsx)(a,{amount:t,mode:`short`})]}):null]}),!t&&(n??0)>0&&(0,u.jsx)(`span`,{children:o(`cards.limitAtLeast`,{amount:i(n,l)})}),!t&&!n&&(0,u.jsx)(`span`,{children:o(`cards.noLimit`)})]})]})}function f({days:e,className:t}){let{t:n}=c();if(e===null)return null;let r=e<0?n(`cards.overdueDays`,{n:-e}):e===0?n(`cards.dueToday`):n(`cards.daysLeft`,{n:e});return(0,u.jsx)(`span`,{className:s(`whitespace-nowrap text-xs font-medium tabular-nums`,e<=3?`text-critical`:e<=7?`text-warning`:`text-muted-foreground`,t),children:r})}function p({status:e,className:t}){let{t:n}=c();return(0,u.jsxs)(`span`,{className:s(`inline-flex items-center gap-1 text-xs`,e===`late`||e===`partly`||e===`unpaid`?`font-medium text-critical`:e===`due`?`font-medium text-warning`:`text-muted-foreground`,t),children:[e===`paid`&&(0,u.jsx)(r,{className:`size-3.5`,"aria-hidden":!0}),n(`cards.st.${e}`)]})}function m({status:e}){let{t}=c();return e===`active`?null:(0,u.jsx)(`span`,{className:`shrink-0 rounded-full bg-secondary px-2 py-0.5 text-[11px] font-medium text-secondary-foreground`,children:t(`cards.status.${e}`)})}function h(e,t){return e.map(e=>t(`cards.missing.${e}`)).join(`, `)}function g({card:t,className:n}){let{t:r}=c();if(!t.missing.length)return null;let i=h(t.missing,r);return(0,u.jsxs)(`div`,{className:s(`relative z-10 flex flex-wrap items-center justify-between gap-2 rounded-md bg-muted/60 px-3 py-2 text-xs text-muted-foreground`,n),children:[(0,u.jsx)(`span`,{children:r(`cards.missing`,{list:i})}),(0,u.jsx)(e,{prompt:r(`ask.cardTerms`,{name:t.name,list:i})})]})}function _(e,r,a){let o=[];return o.push(e.rate===null?r(`cards.best.noRate`):r(`cards.best.rate`,{rate:t(e.rate,a,2)})),e.capLeft!==null&&o.push(r(`cards.best.capLeft`,{amount:i(e.capLeft,a)})),e.minSpendShort>0&&o.push(r(`cards.best.minShort`,{amount:i(e.minSpendShort,a)})),e.payBy&&o.push(e.freeDays===null?r(`cards.best.payBy`,{date:n(e.payBy)}):r(`cards.best.payByDays`,{date:n(e.payBy),n:e.freeDays})),e.limitLeft!==null&&o.push(r(`cards.best.limitLeft`,{amount:i(e.limitLeft,a)})),o.join(` · `)}function v({rows:e,limit:t}){let{t:n,lang:r}=c();return(0,u.jsx)(`ol`,{className:`flex flex-col divide-y`,children:e.slice(0,t??e.length).map((e,t)=>(0,u.jsxs)(`li`,{className:`flex min-h-11 items-center gap-2 py-1.5`,children:[(0,u.jsx)(`span`,{className:`w-4 shrink-0 text-xs text-muted-foreground tabular-nums`,children:t+1}),(0,u.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,u.jsx)(`a`,{href:l(e.account),className:`truncate rounded-md text-sm font-medium outline-none hover:underline focus-visible:ring-3 focus-visible:ring-ring/50`,children:e.name}),(0,u.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:_(e,n,r)})]}),e.earn!==null&&(0,u.jsx)(a,{amount:e.earn,mode:`short`,plus:!0,tone:`in`,className:`shrink-0 text-sm font-medium`})]},e.account))})}function y({values:e,limit:t,compact:n}){let{t:r,lang:o}=c(),s=[...e].sort((e,t)=>e.last12.net-t.last12.net||e.name.localeCompare(t.name)),d=s.slice(0,t??s.length),f=e=>e.account&&e.kind===`credit`?(0,u.jsx)(`a`,{href:l(e.account),className:`truncate rounded-md outline-none hover:underline focus-visible:ring-3 focus-visible:ring-ring/50`,children:e.name}):(0,u.jsx)(`span`,{className:`truncate`,children:e.name});return(0,u.jsx)(`ul`,{className:`flex flex-col divide-y`,children:d.map(e=>(0,u.jsxs)(`li`,{className:`flex min-h-11 flex-col justify-center gap-0.5 py-1.5`,children:[(0,u.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2 text-sm`,children:[(0,u.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2 font-medium`,children:[f(e),(0,u.jsx)(m,{status:e.status})]}),(0,u.jsx)(`span`,{className:`shrink-0 tabular-nums`,children:(0,u.jsx)(a,{amount:e.last12.net,mode:`short`,tone:`auto`,className:`font-medium`})})]}),(0,u.jsxs)(`div`,{className:`flex flex-wrap items-baseline justify-between gap-x-3 text-xs text-muted-foreground`,children:[(0,u.jsxs)(`span`,{children:[r(`cards.value.sinceIssued`),` `,(0,u.jsx)(a,{amount:e.net,mode:`short`,tone:`auto`}),e.feesFrom===`record`&&(0,u.jsxs)(u.Fragment,{children:[` · `,r(`cards.value.estimated`)]})]}),!n&&(0,u.jsx)(`span`,{className:`tabular-nums`,children:r(`cards.value.parts`,{benefits:i(e.last12.benefits,o),cashback:i(e.last12.cashback,o),fees:i(e.last12.fees,o)})})]})]},e.card))})}export{p as a,g as i,m as n,d as o,f as r,y as s,v as t};
@@ -0,0 +1 @@
1
+ import{B as e,E as t,I as n,L as r,T as i}from"./queries-DZIMMe4i.js";var a=e(n(),1),o=Object.defineProperty,s=(e,t)=>o(e,`name`,{value:t,configurable:!0});function c(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}s(c,`setRef`);function l(...e){return t=>{let n=!1,r=e.map(e=>{let r=c(e,t);return!n&&typeof r==`function`&&(n=!0),r});if(n)return()=>{for(let t=0;t<r.length;t++){let n=r[t];typeof n==`function`?n():c(e[t],null)}}}}s(l,`composeRefs`);function u(...e){return a.useCallback(l(...e),e)}s(u,`useComposedRefs`);var d=Object.defineProperty,f=(e,t)=>d(e,`name`,{value:t,configurable:!0});function p(e){let t=a.forwardRef((t,n)=>{let{children:r,...i}=t,o=null,s=!1,c=[];r=w(r),a.Children.forEach(r,e=>{if(b(e)){s=!0;let t=e,n=`child`in t.props?t.props.child:t.props.children;for(;S(n)&&typeof O==`function`;)n=O(n._payload);o=_(t,n),c.push(o?.props?.children)}else c.push(e)}),o?o=a.cloneElement(o,void 0,c):!s&&a.Children.count(r)===1&&a.isValidElement(r)&&(o=r);let l=o?y(o):void 0,d=u(n,l);if(!o){if(r||r===0)throw Error(s?D(e):E(e));return r}let f=v(i,o.props??{});return o.type!==a.Fragment&&(f.ref=n?d:l),a.cloneElement(o,f)});return t.displayName=`${e}.Slot`,t}f(p,`createSlot`);var m=p(`Slot`),h=Symbol.for(`radix.slottable`);function g(e){let t=f(e=>`child`in e?e.children(e.child):e.children,`Slottable`);return t.displayName=`${e}.Slottable`,t.__radixId=h,t}f(g,`createSlottable`);var _=f((e,t)=>`child`in e.props?a.isValidElement(t)?a.cloneElement(t,void 0,e.props.children(t.props.children)):null:a.isValidElement(t)?t:null,`getSlottableElementFromSlottable`);function v(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{let t=a(...e);return i(...e),t}:i&&(n[r]=i):r===`style`?n[r]={...i,...a}:r===`className`?n[r]=[i,a].filter(Boolean).join(` `):r===`aria-describedby`&&(n[r]=T(a,i))}return{...e,...n}}f(v,`mergeProps`);function y(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}f(y,`getElementRef`);function b(e){return a.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===h}f(b,`isSlottable`);var x=Symbol.for(`react.lazy`);function S(e){return typeof e==`object`&&!!e&&`$$typeof`in e&&e.$$typeof===x&&`_payload`in e&&C(e._payload)}f(S,`isLazyComponent`);function C(e){return typeof e==`object`&&!!e&&`then`in e}f(C,`isPromiseLike`);function w(e){let t=e;for(;S(t)&&typeof O==`function`;)t=O(t._payload);return t}f(w,`useUnwrappedLazy`);function T(...e){let t=new Set;for(let n of e)if(typeof n==`string`)for(let e of String(n).trim().split(/\s+/))e&&t.add(e);return t.size>0?Array.from(t).join(` `):void 0}f(T,`concatAriaDescribedby`);var E=f(e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,`createSlotError`),D=f(e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,`createSlottableError`),O=a.use,k=e=>typeof e==`boolean`?`${e}`:e===0?`0`:e,A=t,j=(e,t)=>n=>{if(t?.variants==null)return A(e,n?.class,n?.className);let{variants:r,defaultVariants:i}=t,a=Object.keys(r).map(e=>{let t=n?.[e],a=i?.[e];if(t===null)return null;let o=k(t)||k(a);return r[e][o]}),o=n&&Object.entries(n).reduce((e,t)=>{let[n,r]=t;return r===void 0||(e[n]=r),e},{});return A(e,a,t?.compoundVariants?.reduce((e,t)=>{let{class:n,className:r,...a}=t;return Object.entries(a).every(e=>{let[t,n]=e;return Array.isArray(n)?n.includes({...i,...o}[t]):{...i,...o}[t]===n})?[...e,n,r]:e},[]),n?.class,n?.className)},M=r(),N=j(`group/button inline-flex shrink-0 items-center justify-center rounded-lg border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,{variants:{variant:{default:`bg-primary text-primary-foreground hover:bg-primary/80`,outline:`border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50`,secondary:`bg-secondary text-secondary-foreground hover:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)] aria-expanded:bg-secondary aria-expanded:text-secondary-foreground`,ghost:`hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50`,destructive:`bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40`,link:`text-primary underline-offset-4 hover:underline`},size:{default:`h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2`,xs:`h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3`,sm:`h-7 gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5`,lg:`h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2`,icon:`size-8`,"icon-xs":`size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3`,"icon-sm":`size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg`,"icon-lg":`size-9`}},defaultVariants:{variant:`default`,size:`default`}});function P({className:e,variant:t=`default`,size:n=`default`,asChild:r=!1,...a}){let o=r?m:`button`;return(0,M.jsx)(o,{"data-slot":`button`,"data-variant":t,"data-size":n,className:i(N({variant:t,size:n,className:e})),...a})}export{g as a,p as i,j as n,l as o,m as r,u as s,P as t};
@@ -0,0 +1 @@
1
+ import{d as e,i as t,r as n}from"./index-eR1GkdC_.js";function r(n,r){let i=e(n),a=(e,n)=>t(new Date(e,n,Math.min(r,new Date(e,n+1,0).getDate()))),o=a(i.getFullYear(),i.getMonth());return o>=n?o:a(i.getFullYear(),i.getMonth()+1)}var i=(e,t)=>n(e,r(e,t)),a=e=>`#/cards/${encodeURIComponent(e)}`,o=e=>e===`locked`?`locked`:e===`cancelled`?`cancelled`:`active`;export{o as i,i as n,r,a as t};