ownledger 2.4.1 → 2.4.2
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.
- package/CHANGELOG.md +5 -0
- package/assets/index.html +1 -1
- package/assets/static/{Account-CsYM8gHF.js → Account-jkuYredC.js} +1 -1
- package/assets/static/{Accounts-lS6XAdaj.js → Accounts-T0tTxTA9.js} +1 -1
- package/assets/static/{Attention-BenmtPd7.js → Attention-4DNKdkp7.js} +1 -1
- package/assets/static/{ByCategory-JX6VL0r5.js → ByCategory-DtU4Zkk3.js} +1 -1
- package/assets/static/CardBudgets-BtBHlz3C.js +1 -0
- package/assets/static/{CardDetail-DauEkok4.js → CardDetail-CB3g66IY.js} +1 -1
- package/assets/static/{Cards-BPdfO3mX.js → Cards-3bs9xSfj.js} +1 -1
- package/assets/static/{Cards-CJ6D_yWD.js → Cards-BUMVT6bE.js} +1 -1
- package/assets/static/{CardsValue-BJ7TcmzC.js → CardsValue-DMmX0mml.js} +1 -1
- package/assets/static/{Cashback-C4cG7mgh.js → Cashback-BoqqbHWy.js} +1 -1
- package/assets/static/{CategoryIcon-DIqlujCD.js → CategoryIcon-CflJmLil.js} +1 -1
- package/assets/static/{CategoryPicker-X4mud6cY.js → CategoryPicker-Dfej_xSa.js} +1 -1
- package/assets/static/{ChartWidget-BFvDbLgz.js → ChartWidget-BlUJfeP6.js} +1 -1
- package/assets/static/{Combobox-CAP3wl4l.js → Combobox-B8QZhrQa.js} +1 -1
- package/assets/static/{Deposits-RX3YoIZZ.js → Deposits-DPcvQQvF.js} +1 -1
- package/assets/static/{Field-C2-VycnC.js → Field-BBqplLmm.js} +1 -1
- package/assets/static/{HomeEditor-Bxu25He1.js → HomeEditor-DQkikr9Z.js} +1 -1
- package/assets/static/{Import-C4HY1ABv.js → Import-IK5EMRoT.js} +1 -1
- package/assets/static/{IncomeSpending-B2I7znyM.js → IncomeSpending-ClJrjJ2Z.js} +1 -1
- package/assets/static/{Left-ZqQxfEIH.js → Left-C5n3tXzC.js} +1 -1
- package/assets/static/{Money-NpAKIj6n.js → Money-B9s3HUmo.js} +1 -1
- package/assets/static/{NetWorth-CxAiM-YK.js → NetWorth-_833T_T_.js} +1 -1
- package/assets/static/{Pace-DLtERmT4.js → Pace-CieGQVy7.js} +1 -1
- package/assets/static/{Panel-B3szLNCa.js → Panel-DZw2fIkp.js} +1 -1
- package/assets/static/{PinDialog-CI2hlJTi.js → PinDialog-BGAWyDEO.js} +1 -1
- package/assets/static/{Plans-Cjtbl3jy.js → Plans-BxBS3k0j.js} +1 -1
- package/assets/static/{Recent-CLidi89q.js → Recent-_Xy-D3cP.js} +1 -1
- package/assets/static/{Reports-De-UPdvX.js → Reports-CgTqFaoP.js} +1 -1
- package/assets/static/{Settings-DTqQmDcd.js → Settings-zi9DztS0.js} +1 -1
- package/assets/static/{Transactions-DOs7gcHH.js → Transactions-D1Ly4hmw.js} +1 -1
- package/assets/static/{TxRow-BDwN3FU8.js → TxRow-DsexHAVz.js} +1 -1
- package/assets/static/{Unusual-Cl_nAUxh.js → Unusual-C07wSZLQ.js} +1 -1
- package/assets/static/{Upcoming-C8qpBQsr.js → Upcoming-DtW_cXdu.js} +1 -1
- package/assets/static/{WhichCard-CHIiyqNI.js → WhichCard-CyxZ2M0u.js} +1 -1
- package/assets/static/{bits-93kCxLrY.js → bits-DjQRuWi5.js} +1 -1
- package/assets/static/{cards-Chi71C59.js → cards-BK8_l-rA.js} +1 -1
- package/assets/static/{charts-qUKGFulK.js → charts-BOS_LSem.js} +1 -1
- package/assets/static/{dialog-BVeS01WF.js → dialog-f8fJAP_M.js} +1 -1
- package/assets/static/{index-CXJ1Qnlx.js → index-DlIU4Ie4.js} +3 -3
- package/assets/static/{select-CnfPMAV_.js → select-DRhU1nFO.js} +1 -1
- package/dist/worker/version.d.ts +1 -1
- package/dist/worker/version.js +1 -1
- package/package.json +1 -1
- package/assets/static/CardBudgets-D6pSYb4p.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as e,D as t,E as n,G as r,J as i,K as a,N as o,O as s,T as c,X as l,Y as u,_ as d,b as f,g as p,h as m,it as h,k as g,m as _,nt as v,p as ee,q as y,tt as te,v as b,w as x,x as S,y as C}from"./index-CXJ1Qnlx.js";import{t as w}from"./createLucideIcon-IIIDTtW8.js";import{B as T,I as E,L as D,d as O,u as k,w as A}from"./queries-fhKGsTGv.js";import{t as j}from"./button-C7t0bIbi.js";import{t as M}from"./Combobox-CAP3wl4l.js";import{n as N,t as P}from"./Field-C2-VycnC.js";import{n as F,t as I}from"./arrow-up-7Upl0C9g.js";import{a as L,n as R,o as z,r as B,t as V}from"./dialog-BVeS01WF.js";var H={name:`grip-vertical`,size:24,node:[[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}],[`circle`,{cx:`9`,cy:`5`,r:`1`,key:`hp0tcf`}],[`circle`,{cx:`9`,cy:`19`,r:`1`,key:`fkjjf6`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`circle`,{cx:`15`,cy:`5`,r:`1`,key:`19l28e`}],[`circle`,{cx:`15`,cy:`19`,r:`1`,key:`f4zoj3`}]]};H.node;var U=w(H),W={name:`plus`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]};W.node;var G=w(W),ne={name:`rotate-ccw`,size:24,node:[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]};ne.node;var re=w(ne),ie={name:`settings-2`,size:24,node:[[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`path`,{d:`M19 7h-9`,key:`6i9tg`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]};ie.node;var ae=w(ie),K=T(E(),1),q=D(),oe={pace:`line`,attention:`list`,unusual:`list`,net_worth:`line`,left:`stat`,by_category:`bars`,income_spending:`columns`,recent:`list`,account:`line`,upcoming:`strip`,deposits:`list`,chart:`columns`,cards:`bars`,cashback:`list`,which_card:`list`,cards_value:`bars`},J=`rounded-sm bg-muted-foreground/25`;function se({kind:e}){return(0,q.jsxs)(`div`,{className:`flex h-16 w-24 shrink-0 flex-col gap-1.5 overflow-hidden rounded-md border bg-muted/40 p-2`,"aria-hidden":!0,children:[e===`stat`&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`div`,{className:`${J} h-2 w-1/2`}),(0,q.jsx)(`div`,{className:`rounded-sm h-5 w-4/5 bg-muted-foreground/40`})]}),e===`line`&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`div`,{className:`${J} h-2 w-1/2`}),(0,q.jsx)(`svg`,{viewBox:`0 0 80 28`,className:`h-full w-full text-muted-foreground/60`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,preserveAspectRatio:`none`,children:(0,q.jsx)(`path`,{d:`M2 24 L16 18 L30 21 L44 10 L58 13 L78 3`})})]}),e===`columns`&&(0,q.jsx)(`div`,{className:`flex h-full items-end gap-1`,children:[40,65,50,85,60,75].map((e,t)=>(0,q.jsx)(`div`,{className:`rounded-sm flex-1 bg-muted-foreground/40`,style:{height:`${e}%`}},t))}),e===`bars`&&(0,q.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:[90,65,45,30].map((e,t)=>(0,q.jsx)(`div`,{className:`rounded-sm h-2 bg-muted-foreground/40`,style:{width:`${e}%`}},t))}),e===`list`&&(0,q.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:[100,85,95,70].map((e,t)=>(0,q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,q.jsx)(`div`,{className:`size-2 shrink-0 rounded-full bg-muted-foreground/40`}),(0,q.jsx)(`div`,{className:`${J} h-2`,style:{width:`${e}%`}})]},t))}),e===`strip`&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`div`,{className:`${J} h-2 w-1/2`}),(0,q.jsx)(`div`,{className:`flex gap-1`,children:[1,2,3,4].map(e=>(0,q.jsx)(`div`,{className:`${J} h-7 flex-1`},e))})]})]})}function Y({name:e,description:t,sketch:n,icon:r,onPick:i}){return(0,q.jsxs)(`button`,{type:`button`,onClick:i,className:`flex min-h-11 w-full items-start gap-3 rounded-xl border bg-card p-3 text-left outline-none transition-colors hover:bg-muted focus-visible:ring-3 focus-visible:ring-ring/50`,children:[(0,q.jsx)(se,{kind:n}),(0,q.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,q.jsxs)(`span`,{className:`flex items-center gap-1.5 text-sm font-medium`,children:[r&&(0,q.jsx)(v,{className:`size-4`,"aria-hidden":!0}),e]}),(0,q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t})]})]})}function ce(e){return Object.values(s).filter(t=>t.type!==`chart`&&(!t.available||t.available(e))).map(e=>e.type)}function le({open:e,onOpenChange:t,features:n,onPick:o,onCustom:c}){let{t:l}=A();return(0,q.jsx)(r,{open:e,onOpenChange:t,children:(0,q.jsxs)(a,{className:`data-[side=right]:w-full data-[side=right]:sm:max-w-md`,children:[(0,q.jsxs)(i,{children:[(0,q.jsx)(u,{children:l(`cat.title`)}),(0,q.jsx)(y,{children:l(`cat.description`)})]}),(0,q.jsxs)(`ul`,{className:`flex min-h-0 flex-1 flex-col gap-2 overflow-y-auto px-4 pb-4`,children:[(0,q.jsx)(`li`,{children:(0,q.jsx)(Y,{name:l(`cat.custom`),description:l(`cat.customDesc`),sketch:`columns`,icon:!0,onPick:c})}),ce(n).map(e=>(0,q.jsx)(`li`,{children:(0,q.jsx)(Y,{name:l(s[e].titleKey),description:l(`widget.desc.${e}`),sketch:oe[e]??`list`,onPick:()=>o(e)})},e))]})]})})}var X={query:{metric:`spending`,period:`last-3-months`,by:`month`},chart:`bar`,title:``},Z=`__any`,Q=`__multi`,ue=`pool`,$=`__other`,de=(e,t)=>{let[n,r]=(0,K.useState)(e);return(0,K.useEffect)(()=>{let n=setTimeout(()=>r(e),t);return()=>clearTimeout(n)},[e,t]),n};function fe({initial:t,submitLabel:n,onSubmit:r,onCancel:i}){let{t:a}=A(),c=k().data?.features,l=k().data?.pool?.name||a(`pool.name`),u=O().data,[f,g]=(0,K.useState)(()=>({...t.query,period:t.query.period??`this-month`,by:t.query.by??(t.query.metric===`balance`?`month`:`top`)})),[v,ee]=(0,K.useState)(t.chart),[y,te]=(0,K.useState)(t.title),[C,w]=(0,K.useState)(()=>!!t.query.period&&!d.includes(t.query.period)),T=e=>g(t=>({...t,...e})),E=e=>t=>T({[e]:t}),D=S(f,y),F=e(f),I=de(JSON.stringify(F),350),L=(0,K.useMemo)(()=>JSON.parse(I),[I]),R={id:`preview`,type:`chart`,x:0,y:0,w:6,h:4,title:y.trim()||void 0,query:L,chart:v},z=s.chart.component,B=[{options:[{value:Z,label:a(`cf.any`)},...(u?.categories??[]).map(e=>({value:e.path,label:e.name,keywords:[e.path],depth:e.path.split(`/`).length-1})),...f.category&&!u?.categories.some(e=>e.path===f.category)?[{value:f.category,label:f.category}]:[]]}],V=[{options:[{value:Z,label:a(`cf.any`)},{value:ue,label:a(`cf.pool`,{name:l})},...(u?.accounts??[]).filter(e=>!e.closed||e.id===f.account).map(e=>({value:e.id,label:e.name,keywords:[e.id]})),...Array.isArray(f.account)?[{value:Q,label:f.account.map(e=>u?.accounts.find(t=>t.id===e)?.name??e).join(`, `)}]:[]]}],H=Array.isArray(f.account)?Q:f.account??Z,U=(f.metric===`balance`?b:_).filter(e=>e===`who`?c?.who||f.by===`who`:e===`event`?c?.event||f.by===`event`:e!==`tag`||c?.tags||f.by===`tag`),W=C?$:f.period??`this-month`,G=(e,t)=>t||!!f[e];return(0,q.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),D.length||r({query:F,chart:v,title:y.trim()})},children:[(0,q.jsxs)(`section`,{"aria-label":a(`cf.preview`),className:`flex flex-col gap-1.5`,children:[(0,q.jsx)(`h3`,{className:`text-sm font-medium`,children:a(`cf.preview`)}),(0,q.jsx)(`div`,{className:`flex h-72 flex-col *:flex-1`,children:D.length?(0,q.jsx)(`div`,{className:`rounded-xl border border-dashed p-4 text-sm text-muted-foreground`,role:`alert`,children:D.map(e=>(0,q.jsx)(`p`,{children:a(e)},e))}):(0,q.jsx)(K.Suspense,{fallback:(0,q.jsx)(o,{}),children:(0,q.jsx)(z,{widget:R})})})]}),(0,q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,q.jsx)(P,{label:a(`cf.metric`),children:e=>(0,q.jsx)(N,{id:e,value:f.metric,options:p.map(e=>({value:e,label:a(`cf.metric.${e}`)})),onChange:e=>T({metric:e,...e===`balance`&&!x(f.by)?{by:`month`}:{}})})}),(0,q.jsx)(P,{label:a(`cf.kind`),children:e=>(0,q.jsx)(N,{id:e,value:v,options:m.map(e=>({value:e,label:a(`cf.kind.${e}`)})),onChange:e=>ee(e)})}),(0,q.jsx)(P,{label:a(`cf.period`),children:e=>(0,q.jsx)(N,{id:e,value:W,options:[...d.map(e=>({value:e,label:a(`cf.period.${e}`)})),{value:$,label:a(`cf.periodOther`)}],onChange:e=>{e===$?(w(!0),T({period:d.includes(f.period??``)?``:f.period})):(w(!1),T({period:e}))}})}),C&&(0,q.jsx)(P,{label:a(`cf.periodValue`),children:e=>(0,q.jsx)(h,{id:e,className:`min-h-11 md:min-h-8`,inputMode:`numeric`,placeholder:`2026-11`,value:f.period??``,"aria-invalid":D.includes(`cf.err.period`),onChange:e=>T({period:e.target.value.trim()})})}),(0,q.jsx)(P,{label:a(`cf.by`),hint:f.metric===`balance`?a(`cf.balanceHint`):void 0,children:e=>(0,q.jsx)(N,{id:e,value:f.by??`top`,options:U.map(e=>({value:e,label:a(`cf.by.${e}`)})),onChange:e=>T({by:e})})}),(0,q.jsx)(P,{label:a(`cf.compare`),children:e=>(0,q.jsx)(N,{id:e,value:f.compare??`none`,options:[`none`,`previous`,`usual`].map(e=>({value:e,label:a(`cf.compare.${e}`)})),onChange:e=>T({compare:e===`none`?void 0:e})})})]}),(0,q.jsxs)(`fieldset`,{className:`flex flex-col gap-3`,children:[(0,q.jsx)(`legend`,{className:`mb-1 text-sm font-medium`,children:a(`cf.filters`)}),(0,q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1.5`,children:[(0,q.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:a(`cf.category`)}),(0,q.jsx)(M,{className:`w-full`,label:a(`cf.any`),ariaLabel:a(`cf.category`),groups:B,value:f.category??Z,onSelect:e=>T({category:e===Z?void 0:e})})]}),(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1.5`,children:[(0,q.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:a(`cf.account`)}),(0,q.jsx)(M,{className:`w-full`,label:a(`cf.any`),ariaLabel:a(`cf.account`),groups:V,value:H,onSelect:e=>e===Q?void 0:T({account:e===Z?void 0:e})})]}),G(`who`,c?.who)&&(0,q.jsx)(P,{label:a(`cf.who`),children:e=>(0,q.jsx)(h,{id:e,className:`min-h-11 md:min-h-8`,value:f.who??``,onChange:e=>E(`who`)(e.target.value)})}),G(`event`,c?.event)&&(0,q.jsx)(P,{label:a(`cf.event`),children:e=>(0,q.jsx)(h,{id:e,className:`min-h-11 md:min-h-8`,value:f.event??``,onChange:e=>E(`event`)(e.target.value)})}),G(`tag`,c?.tags)&&(0,q.jsx)(P,{label:a(`cf.tag`),children:e=>(0,q.jsx)(h,{id:e,className:`min-h-11 md:min-h-8`,value:f.tag??``,onChange:e=>E(`tag`)(e.target.value)})}),(0,q.jsx)(P,{label:a(`cf.text`),children:e=>(0,q.jsx)(h,{id:e,className:`min-h-11 md:min-h-8`,value:f.text??``,onChange:e=>E(`text`)(e.target.value)})})]})]}),(0,q.jsx)(P,{label:a(`cf.title`),hint:a(`wset.titleHint`),children:e=>(0,q.jsx)(h,{id:e,className:`min-h-11 md:min-h-8`,maxLength:100,placeholder:a(`cf.titlePlaceholder`),value:y,"aria-invalid":D.includes(`cf.err.title`),onChange:e=>te(e.target.value)})}),(0,q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,q.jsx)(j,{type:`button`,variant:`outline`,className:`min-h-11 md:min-h-8`,onClick:i,children:a(`common.cancel`)}),(0,q.jsx)(j,{type:`submit`,className:`min-h-11 md:min-h-8`,disabled:D.length>0,children:n})]})]})}function pe({id:e,name:t,first:n,last:r,canDrag:i,canSettings:a,onMove:o,onSettings:s,onRemove:c}){let{t:u}=A(),d=`size-11 md:size-8`;return(0,q.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[i&&(0,q.jsxs)(`span`,{className:`widget-drag-handle flex size-8 cursor-grab items-center justify-center rounded-lg text-muted-foreground hover:bg-muted active:cursor-grabbing`,title:u(`edit.drag`,{name:t}),children:[(0,q.jsx)(U,{className:`size-4`,"aria-hidden":!0}),(0,q.jsx)(`span`,{className:`sr-only`,children:u(`edit.drag`,{name:t})})]}),(0,q.jsx)(j,{type:`button`,variant:`ghost`,size:`icon`,className:d,"data-move":`up:${e}`,disabled:n,"aria-label":u(`edit.moveUp`,{name:t}),title:u(`edit.moveUp`,{name:t}),onClick:()=>o(-1),children:(0,q.jsx)(I,{})}),(0,q.jsx)(j,{type:`button`,variant:`ghost`,size:`icon`,className:d,"data-move":`down:${e}`,disabled:r,"aria-label":u(`edit.moveDown`,{name:t}),title:u(`edit.moveDown`,{name:t}),onClick:()=>o(1),children:(0,q.jsx)(F,{})}),a&&(0,q.jsx)(j,{type:`button`,variant:`ghost`,size:`icon`,className:d,"aria-label":u(`edit.settings`,{name:t}),title:u(`edit.settings`,{name:t}),onClick:s,children:(0,q.jsx)(ae,{})}),(0,q.jsx)(j,{type:`button`,variant:`ghost`,size:`icon`,className:`${d} hover:text-destructive`,"aria-label":u(`edit.remove`,{name:t}),title:u(`edit.remove`,{name:t}),onClick:c,children:(0,q.jsx)(l,{})})]})}var me=[`this-month`,`last-month`,`this-year`,`last-year`],he=[3,6,12,18,24],ge=[5,8,10,15,20,30],_e=(e,t)=>e.includes(t)?e:[...e,t].sort((e,t)=>e-t);function ve({widget:e,submitLabel:t,onSubmit:n,onCancel:r}){let{t:i}=A(),a=s[e.type]?.options??[],o=k().data,c=O().data,[l,u]=(0,K.useState)(e),[d,f]=(0,K.useState)(e.title??``),p=[{value:`pool`,label:i(`cf.pool`,{name:o?.pool?.name||i(`pool.name`)})},...(c?.accounts??[]).filter(e=>!e.closed||e.id===l.account).map(e=>({value:e.id,label:e.name,keywords:[e.id]}))],m=a.includes(`account`)&&!l.account,g=d.length>80;return(0,q.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{if(e.preventDefault(),m||g)return;let t={...l};d.trim()?t.title=d.trim():delete t.title,n(t)},children:[a.includes(`period`)&&(0,q.jsx)(P,{label:i(`wset.period`),children:e=>(0,q.jsx)(N,{id:e,value:me.includes(l.period??``)?l.period:`this-month`,options:me.map(e=>({value:e,label:i(`wset.period.${e}`)})),onChange:e=>u({...l,period:e})})}),a.includes(`months`)&&(0,q.jsx)(P,{label:i(`wset.months`),children:e=>(0,q.jsx)(N,{id:e,value:String(l.months??6),options:_e(he,l.months??6).map(e=>({value:String(e),label:i(`wset.monthsN`,{n:e})})),onChange:e=>u({...l,months:Number(e)})})}),a.includes(`count`)&&(0,q.jsx)(P,{label:i(`wset.count`),children:e=>(0,q.jsx)(N,{id:e,value:String(l.count??8),options:_e(ge,l.count??8).map(e=>({value:String(e),label:String(e)})),onChange:e=>u({...l,count:Number(e)})})}),a.includes(`account`)&&(0,q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,q.jsx)(`span`,{className:`text-sm font-medium`,children:i(`wset.account`)}),(0,q.jsx)(M,{className:`w-full`,label:i(`wset.accountNone`),ariaLabel:i(`wset.account`),groups:[{options:p}],value:l.account,onSelect:e=>u({...l,account:e})})]}),(0,q.jsx)(P,{label:i(`wset.titleLabel`),hint:i(`wset.titleHint`),children:t=>(0,q.jsx)(h,{id:t,className:`min-h-11 md:min-h-8`,value:d,"aria-invalid":g,placeholder:i(s[e.type]?.titleKey??`widget.chart`),onChange:e=>f(e.target.value)})}),g&&(0,q.jsx)(`p`,{className:`text-sm text-destructive`,role:`alert`,children:i(`cf.err.title`)}),(0,q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,q.jsx)(j,{type:`button`,variant:`outline`,className:`min-h-11 md:min-h-8`,onClick:r,children:i(`common.cancel`)}),(0,q.jsx)(j,{type:`submit`,className:`min-h-11 md:min-h-8`,disabled:m||g,children:t})]})]})}function ye({widget:e,isNew:t,onSave:n,onClose:r}){let{t:i}=A(),a=e?e.title?.trim()||i(s[e.type]?.titleKey??`widget.chart`):``,o=i(t?`wset.add`:`wset.save`);return(0,q.jsx)(V,{open:e!==null,onOpenChange:e=>!e&&r(),children:(0,q.jsxs)(R,{className:`max-h-[92svh] overflow-y-auto sm:max-w-2xl`,children:[(0,q.jsxs)(L,{children:[(0,q.jsx)(z,{children:i(`wset.title`,{name:a})}),(0,q.jsx)(B,{children:i(`wset.description`)})]}),e&&(e.type===`chart`?(0,q.jsx)(fe,{initial:e.query?{query:e.query,chart:e.chart??`bar`,title:e.title??``}:X,submitLabel:o,onCancel:r,onSubmit:t=>{let r={...e,query:t.query,chart:t.chart};t.title?r.title=t.title:delete r.title,n(r)}},e.id):(0,q.jsx)(ve,{widget:e,submitLabel:o,onCancel:r,onSubmit:n},e.id))]})})}function be({saved:e,renderWidget:r,onExit:i}){let{t:a}=A(),o=k().data?.features,l=g(`(max-width: 639px)`),[u,d]=(0,K.useState)(()=>e.map(e=>({...e}))),[p,m]=(0,K.useState)(!1),[h,_]=(0,K.useState)(null),[v,y]=(0,K.useState)(``),[b,x]=(0,K.useState)(null),[S,w]=(0,K.useState)(null),[T,E]=(0,K.useState)(!1),[D,O]=(0,K.useState)(null),M=(0,K.useRef)(null),N=e=>e.title?.trim()||a(s[e.type]?.titleKey??`widget.chart`),P=[...u].sort(f);(0,K.useEffect)(()=>{if(!D)return;let e=e=>document.querySelector(`[data-move="${e}:${D.id}"]`),t=e(D.dir<0?`up`:`down`);(t&&!t.disabled?t:e(D.dir<0?`down`:`up`))?.focus()},[D]);let F=e=>d(t=>{let n=!1,r=t.map(t=>{let r=e.find(e=>e.i===t.id);return!r||r.x===t.x&&r.y===t.y&&r.w===t.w&&r.h===t.h?t:(n=!0,{...t,x:r.x,y:r.y,w:r.w,h:r.h})});return n?r:t}),I=e=>{d(t=>[...t,e]),y(a(`edit.added`,{name:N(e)}))},L=e=>{let t=s[e];if(!t)return;m(!1);let n=C(u,{type:e},t.size);t.options?.includes(`account`)?_({widget:n,isNew:!0}):I(n)},R=()=>{m(!1),_({widget:C(u,{type:`chart`,query:X.query,chart:X.chart},s.chart.size),isNew:!0})},z=e=>{h?.isNew?I(e):(d(t=>t.map(t=>t.id===e.id?e:t)),y(a(`edit.updated`,{name:N(e)}))),_(null)},B=e=>{d(t=>t.filter(t=>t.id!==e.id)),y(a(`edit.removed`,{name:N(e)})),M.current?.focus()},V=(e,t)=>{d(n=>c(n,e.id,t)),y(a(`edit.moved`,{name:N(e)})),O({id:e.id,dir:t})},H=async e=>{x(e),w(null);try{e===`save`?await t(u):await n(),i()}catch(t){w(a(e===`save`?`edit.saveError`:`edit.resetError`,{message:t.message})),E(!1),x(null)}},U=`min-h-11 md:min-h-8`;return(0,q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,q.jsxs)(`div`,{className:`sticky top-0 z-30 -mx-4 flex flex-col gap-2 border-b bg-background/95 px-4 py-2 backdrop-blur md:-mx-6 md:px-6`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsxs)(`h2`,{ref:M,tabIndex:-1,className:`mr-auto text-sm font-medium outline-none`,children:[a(`home.title`),` · `,a(`edit.editing`)]}),T?(0,q.jsxs)(`div`,{role:`alertdialog`,"aria-label":a(`edit.reset`),className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsx)(`p`,{className:`text-sm`,children:a(`edit.resetConfirm`)}),(0,q.jsx)(j,{type:`button`,variant:`destructive`,className:U,disabled:b!==null,onClick:()=>void H(`reset`),children:a(b===`reset`?`edit.saving`:`edit.resetYes`)}),(0,q.jsx)(j,{type:`button`,variant:`outline`,className:U,disabled:b!==null,onClick:()=>E(!1),children:a(`edit.resetKeep`)})]}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(j,{type:`button`,variant:`ghost`,className:U,disabled:b!==null,onClick:()=>E(!0),children:[(0,q.jsx)(re,{}),a(`edit.reset`)]}),(0,q.jsxs)(j,{type:`button`,variant:`outline`,className:U,disabled:b!==null,onClick:()=>m(!0),children:[(0,q.jsx)(G,{}),a(`edit.add`)]}),(0,q.jsx)(j,{type:`button`,variant:`outline`,className:U,disabled:b!==null,onClick:i,children:a(`common.cancel`)}),(0,q.jsxs)(j,{type:`button`,className:U,disabled:b!==null,onClick:()=>void H(`save`),children:[(0,q.jsx)(te,{}),a(b===`save`?`edit.saving`:`edit.done`)]})]})]}),(0,q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:a(l?`edit.hintPhone`:`edit.hintDesktop`)}),S&&(0,q.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:S}),(0,q.jsx)(`p`,{role:`status`,className:`sr-only`,children:v})]}),u.length===0?(0,q.jsx)(`p`,{className:`rounded-xl border border-dashed p-6 text-center text-sm text-muted-foreground`,children:a(`edit.empty`)}):(0,q.jsx)(ee,{widgets:u,editing:!0,onLayoutChange:F,renderWidget:e=>{let t=P.findIndex(t=>t.id===e.id);return r(e,(0,q.jsx)(pe,{id:e.id,name:N(e),first:t===0,last:t===P.length-1,canDrag:!l,canSettings:!l&&!!s[e.type]?.options?.length,onMove:t=>V(e,t),onSettings:()=>_({widget:e,isNew:!1}),onRemove:()=>B(e)}))}}),(0,q.jsx)(le,{open:p,onOpenChange:m,features:o,onPick:L,onCustom:R}),(0,q.jsx)(ye,{widget:h?.widget??null,isNew:h?.isNew??!1,onSave:z,onClose:()=>_(null)})]})}export{be as default};
|
|
1
|
+
import{C as e,D as t,E as n,G as r,J as i,K as a,N as o,O as s,T as c,X as l,Y as u,_ as d,b as f,g as p,h as m,it as h,k as g,m as _,nt as v,p as ee,q as y,tt as te,v as b,w as x,x as S,y as C}from"./index-DlIU4Ie4.js";import{t as w}from"./createLucideIcon-IIIDTtW8.js";import{B as T,I as E,L as D,d as O,u as k,w as A}from"./queries-fhKGsTGv.js";import{t as j}from"./button-C7t0bIbi.js";import{t as M}from"./Combobox-B8QZhrQa.js";import{n as N,t as P}from"./Field-BBqplLmm.js";import{n as F,t as I}from"./arrow-up-7Upl0C9g.js";import{a as L,n as R,o as z,r as B,t as V}from"./dialog-f8fJAP_M.js";var H={name:`grip-vertical`,size:24,node:[[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}],[`circle`,{cx:`9`,cy:`5`,r:`1`,key:`hp0tcf`}],[`circle`,{cx:`9`,cy:`19`,r:`1`,key:`fkjjf6`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`circle`,{cx:`15`,cy:`5`,r:`1`,key:`19l28e`}],[`circle`,{cx:`15`,cy:`19`,r:`1`,key:`f4zoj3`}]]};H.node;var U=w(H),W={name:`plus`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]};W.node;var G=w(W),ne={name:`rotate-ccw`,size:24,node:[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]};ne.node;var re=w(ne),ie={name:`settings-2`,size:24,node:[[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`path`,{d:`M19 7h-9`,key:`6i9tg`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]};ie.node;var ae=w(ie),K=T(E(),1),q=D(),oe={pace:`line`,attention:`list`,unusual:`list`,net_worth:`line`,left:`stat`,by_category:`bars`,income_spending:`columns`,recent:`list`,account:`line`,upcoming:`strip`,deposits:`list`,chart:`columns`,cards:`bars`,cashback:`list`,which_card:`list`,cards_value:`bars`},J=`rounded-sm bg-muted-foreground/25`;function se({kind:e}){return(0,q.jsxs)(`div`,{className:`flex h-16 w-24 shrink-0 flex-col gap-1.5 overflow-hidden rounded-md border bg-muted/40 p-2`,"aria-hidden":!0,children:[e===`stat`&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`div`,{className:`${J} h-2 w-1/2`}),(0,q.jsx)(`div`,{className:`rounded-sm h-5 w-4/5 bg-muted-foreground/40`})]}),e===`line`&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`div`,{className:`${J} h-2 w-1/2`}),(0,q.jsx)(`svg`,{viewBox:`0 0 80 28`,className:`h-full w-full text-muted-foreground/60`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,preserveAspectRatio:`none`,children:(0,q.jsx)(`path`,{d:`M2 24 L16 18 L30 21 L44 10 L58 13 L78 3`})})]}),e===`columns`&&(0,q.jsx)(`div`,{className:`flex h-full items-end gap-1`,children:[40,65,50,85,60,75].map((e,t)=>(0,q.jsx)(`div`,{className:`rounded-sm flex-1 bg-muted-foreground/40`,style:{height:`${e}%`}},t))}),e===`bars`&&(0,q.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:[90,65,45,30].map((e,t)=>(0,q.jsx)(`div`,{className:`rounded-sm h-2 bg-muted-foreground/40`,style:{width:`${e}%`}},t))}),e===`list`&&(0,q.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:[100,85,95,70].map((e,t)=>(0,q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,q.jsx)(`div`,{className:`size-2 shrink-0 rounded-full bg-muted-foreground/40`}),(0,q.jsx)(`div`,{className:`${J} h-2`,style:{width:`${e}%`}})]},t))}),e===`strip`&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`div`,{className:`${J} h-2 w-1/2`}),(0,q.jsx)(`div`,{className:`flex gap-1`,children:[1,2,3,4].map(e=>(0,q.jsx)(`div`,{className:`${J} h-7 flex-1`},e))})]})]})}function Y({name:e,description:t,sketch:n,icon:r,onPick:i}){return(0,q.jsxs)(`button`,{type:`button`,onClick:i,className:`flex min-h-11 w-full items-start gap-3 rounded-xl border bg-card p-3 text-left outline-none transition-colors hover:bg-muted focus-visible:ring-3 focus-visible:ring-ring/50`,children:[(0,q.jsx)(se,{kind:n}),(0,q.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,q.jsxs)(`span`,{className:`flex items-center gap-1.5 text-sm font-medium`,children:[r&&(0,q.jsx)(v,{className:`size-4`,"aria-hidden":!0}),e]}),(0,q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t})]})]})}function ce(e){return Object.values(s).filter(t=>t.type!==`chart`&&(!t.available||t.available(e))).map(e=>e.type)}function le({open:e,onOpenChange:t,features:n,onPick:o,onCustom:c}){let{t:l}=A();return(0,q.jsx)(r,{open:e,onOpenChange:t,children:(0,q.jsxs)(a,{className:`data-[side=right]:w-full data-[side=right]:sm:max-w-md`,children:[(0,q.jsxs)(i,{children:[(0,q.jsx)(u,{children:l(`cat.title`)}),(0,q.jsx)(y,{children:l(`cat.description`)})]}),(0,q.jsxs)(`ul`,{className:`flex min-h-0 flex-1 flex-col gap-2 overflow-y-auto px-4 pb-4`,children:[(0,q.jsx)(`li`,{children:(0,q.jsx)(Y,{name:l(`cat.custom`),description:l(`cat.customDesc`),sketch:`columns`,icon:!0,onPick:c})}),ce(n).map(e=>(0,q.jsx)(`li`,{children:(0,q.jsx)(Y,{name:l(s[e].titleKey),description:l(`widget.desc.${e}`),sketch:oe[e]??`list`,onPick:()=>o(e)})},e))]})]})})}var X={query:{metric:`spending`,period:`last-3-months`,by:`month`},chart:`bar`,title:``},Z=`__any`,Q=`__multi`,ue=`pool`,$=`__other`,de=(e,t)=>{let[n,r]=(0,K.useState)(e);return(0,K.useEffect)(()=>{let n=setTimeout(()=>r(e),t);return()=>clearTimeout(n)},[e,t]),n};function fe({initial:t,submitLabel:n,onSubmit:r,onCancel:i}){let{t:a}=A(),c=k().data?.features,l=k().data?.pool?.name||a(`pool.name`),u=O().data,[f,g]=(0,K.useState)(()=>({...t.query,period:t.query.period??`this-month`,by:t.query.by??(t.query.metric===`balance`?`month`:`top`)})),[v,ee]=(0,K.useState)(t.chart),[y,te]=(0,K.useState)(t.title),[C,w]=(0,K.useState)(()=>!!t.query.period&&!d.includes(t.query.period)),T=e=>g(t=>({...t,...e})),E=e=>t=>T({[e]:t}),D=S(f,y),F=e(f),I=de(JSON.stringify(F),350),L=(0,K.useMemo)(()=>JSON.parse(I),[I]),R={id:`preview`,type:`chart`,x:0,y:0,w:6,h:4,title:y.trim()||void 0,query:L,chart:v},z=s.chart.component,B=[{options:[{value:Z,label:a(`cf.any`)},...(u?.categories??[]).map(e=>({value:e.path,label:e.name,keywords:[e.path],depth:e.path.split(`/`).length-1})),...f.category&&!u?.categories.some(e=>e.path===f.category)?[{value:f.category,label:f.category}]:[]]}],V=[{options:[{value:Z,label:a(`cf.any`)},{value:ue,label:a(`cf.pool`,{name:l})},...(u?.accounts??[]).filter(e=>!e.closed||e.id===f.account).map(e=>({value:e.id,label:e.name,keywords:[e.id]})),...Array.isArray(f.account)?[{value:Q,label:f.account.map(e=>u?.accounts.find(t=>t.id===e)?.name??e).join(`, `)}]:[]]}],H=Array.isArray(f.account)?Q:f.account??Z,U=(f.metric===`balance`?b:_).filter(e=>e===`who`?c?.who||f.by===`who`:e===`event`?c?.event||f.by===`event`:e!==`tag`||c?.tags||f.by===`tag`),W=C?$:f.period??`this-month`,G=(e,t)=>t||!!f[e];return(0,q.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),D.length||r({query:F,chart:v,title:y.trim()})},children:[(0,q.jsxs)(`section`,{"aria-label":a(`cf.preview`),className:`flex flex-col gap-1.5`,children:[(0,q.jsx)(`h3`,{className:`text-sm font-medium`,children:a(`cf.preview`)}),(0,q.jsx)(`div`,{className:`flex h-72 flex-col *:flex-1`,children:D.length?(0,q.jsx)(`div`,{className:`rounded-xl border border-dashed p-4 text-sm text-muted-foreground`,role:`alert`,children:D.map(e=>(0,q.jsx)(`p`,{children:a(e)},e))}):(0,q.jsx)(K.Suspense,{fallback:(0,q.jsx)(o,{}),children:(0,q.jsx)(z,{widget:R})})})]}),(0,q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,q.jsx)(P,{label:a(`cf.metric`),children:e=>(0,q.jsx)(N,{id:e,value:f.metric,options:p.map(e=>({value:e,label:a(`cf.metric.${e}`)})),onChange:e=>T({metric:e,...e===`balance`&&!x(f.by)?{by:`month`}:{}})})}),(0,q.jsx)(P,{label:a(`cf.kind`),children:e=>(0,q.jsx)(N,{id:e,value:v,options:m.map(e=>({value:e,label:a(`cf.kind.${e}`)})),onChange:e=>ee(e)})}),(0,q.jsx)(P,{label:a(`cf.period`),children:e=>(0,q.jsx)(N,{id:e,value:W,options:[...d.map(e=>({value:e,label:a(`cf.period.${e}`)})),{value:$,label:a(`cf.periodOther`)}],onChange:e=>{e===$?(w(!0),T({period:d.includes(f.period??``)?``:f.period})):(w(!1),T({period:e}))}})}),C&&(0,q.jsx)(P,{label:a(`cf.periodValue`),children:e=>(0,q.jsx)(h,{id:e,className:`min-h-11 md:min-h-8`,inputMode:`numeric`,placeholder:`2026-11`,value:f.period??``,"aria-invalid":D.includes(`cf.err.period`),onChange:e=>T({period:e.target.value.trim()})})}),(0,q.jsx)(P,{label:a(`cf.by`),hint:f.metric===`balance`?a(`cf.balanceHint`):void 0,children:e=>(0,q.jsx)(N,{id:e,value:f.by??`top`,options:U.map(e=>({value:e,label:a(`cf.by.${e}`)})),onChange:e=>T({by:e})})}),(0,q.jsx)(P,{label:a(`cf.compare`),children:e=>(0,q.jsx)(N,{id:e,value:f.compare??`none`,options:[`none`,`previous`,`usual`].map(e=>({value:e,label:a(`cf.compare.${e}`)})),onChange:e=>T({compare:e===`none`?void 0:e})})})]}),(0,q.jsxs)(`fieldset`,{className:`flex flex-col gap-3`,children:[(0,q.jsx)(`legend`,{className:`mb-1 text-sm font-medium`,children:a(`cf.filters`)}),(0,q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1.5`,children:[(0,q.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:a(`cf.category`)}),(0,q.jsx)(M,{className:`w-full`,label:a(`cf.any`),ariaLabel:a(`cf.category`),groups:B,value:f.category??Z,onSelect:e=>T({category:e===Z?void 0:e})})]}),(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1.5`,children:[(0,q.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:a(`cf.account`)}),(0,q.jsx)(M,{className:`w-full`,label:a(`cf.any`),ariaLabel:a(`cf.account`),groups:V,value:H,onSelect:e=>e===Q?void 0:T({account:e===Z?void 0:e})})]}),G(`who`,c?.who)&&(0,q.jsx)(P,{label:a(`cf.who`),children:e=>(0,q.jsx)(h,{id:e,className:`min-h-11 md:min-h-8`,value:f.who??``,onChange:e=>E(`who`)(e.target.value)})}),G(`event`,c?.event)&&(0,q.jsx)(P,{label:a(`cf.event`),children:e=>(0,q.jsx)(h,{id:e,className:`min-h-11 md:min-h-8`,value:f.event??``,onChange:e=>E(`event`)(e.target.value)})}),G(`tag`,c?.tags)&&(0,q.jsx)(P,{label:a(`cf.tag`),children:e=>(0,q.jsx)(h,{id:e,className:`min-h-11 md:min-h-8`,value:f.tag??``,onChange:e=>E(`tag`)(e.target.value)})}),(0,q.jsx)(P,{label:a(`cf.text`),children:e=>(0,q.jsx)(h,{id:e,className:`min-h-11 md:min-h-8`,value:f.text??``,onChange:e=>E(`text`)(e.target.value)})})]})]}),(0,q.jsx)(P,{label:a(`cf.title`),hint:a(`wset.titleHint`),children:e=>(0,q.jsx)(h,{id:e,className:`min-h-11 md:min-h-8`,maxLength:100,placeholder:a(`cf.titlePlaceholder`),value:y,"aria-invalid":D.includes(`cf.err.title`),onChange:e=>te(e.target.value)})}),(0,q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,q.jsx)(j,{type:`button`,variant:`outline`,className:`min-h-11 md:min-h-8`,onClick:i,children:a(`common.cancel`)}),(0,q.jsx)(j,{type:`submit`,className:`min-h-11 md:min-h-8`,disabled:D.length>0,children:n})]})]})}function pe({id:e,name:t,first:n,last:r,canDrag:i,canSettings:a,onMove:o,onSettings:s,onRemove:c}){let{t:u}=A(),d=`size-11 md:size-8`;return(0,q.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[i&&(0,q.jsxs)(`span`,{className:`widget-drag-handle flex size-8 cursor-grab items-center justify-center rounded-lg text-muted-foreground hover:bg-muted active:cursor-grabbing`,title:u(`edit.drag`,{name:t}),children:[(0,q.jsx)(U,{className:`size-4`,"aria-hidden":!0}),(0,q.jsx)(`span`,{className:`sr-only`,children:u(`edit.drag`,{name:t})})]}),(0,q.jsx)(j,{type:`button`,variant:`ghost`,size:`icon`,className:d,"data-move":`up:${e}`,disabled:n,"aria-label":u(`edit.moveUp`,{name:t}),title:u(`edit.moveUp`,{name:t}),onClick:()=>o(-1),children:(0,q.jsx)(I,{})}),(0,q.jsx)(j,{type:`button`,variant:`ghost`,size:`icon`,className:d,"data-move":`down:${e}`,disabled:r,"aria-label":u(`edit.moveDown`,{name:t}),title:u(`edit.moveDown`,{name:t}),onClick:()=>o(1),children:(0,q.jsx)(F,{})}),a&&(0,q.jsx)(j,{type:`button`,variant:`ghost`,size:`icon`,className:d,"aria-label":u(`edit.settings`,{name:t}),title:u(`edit.settings`,{name:t}),onClick:s,children:(0,q.jsx)(ae,{})}),(0,q.jsx)(j,{type:`button`,variant:`ghost`,size:`icon`,className:`${d} hover:text-destructive`,"aria-label":u(`edit.remove`,{name:t}),title:u(`edit.remove`,{name:t}),onClick:c,children:(0,q.jsx)(l,{})})]})}var me=[`this-month`,`last-month`,`this-year`,`last-year`],he=[3,6,12,18,24],ge=[5,8,10,15,20,30],_e=(e,t)=>e.includes(t)?e:[...e,t].sort((e,t)=>e-t);function ve({widget:e,submitLabel:t,onSubmit:n,onCancel:r}){let{t:i}=A(),a=s[e.type]?.options??[],o=k().data,c=O().data,[l,u]=(0,K.useState)(e),[d,f]=(0,K.useState)(e.title??``),p=[{value:`pool`,label:i(`cf.pool`,{name:o?.pool?.name||i(`pool.name`)})},...(c?.accounts??[]).filter(e=>!e.closed||e.id===l.account).map(e=>({value:e.id,label:e.name,keywords:[e.id]}))],m=a.includes(`account`)&&!l.account,g=d.length>80;return(0,q.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{if(e.preventDefault(),m||g)return;let t={...l};d.trim()?t.title=d.trim():delete t.title,n(t)},children:[a.includes(`period`)&&(0,q.jsx)(P,{label:i(`wset.period`),children:e=>(0,q.jsx)(N,{id:e,value:me.includes(l.period??``)?l.period:`this-month`,options:me.map(e=>({value:e,label:i(`wset.period.${e}`)})),onChange:e=>u({...l,period:e})})}),a.includes(`months`)&&(0,q.jsx)(P,{label:i(`wset.months`),children:e=>(0,q.jsx)(N,{id:e,value:String(l.months??6),options:_e(he,l.months??6).map(e=>({value:String(e),label:i(`wset.monthsN`,{n:e})})),onChange:e=>u({...l,months:Number(e)})})}),a.includes(`count`)&&(0,q.jsx)(P,{label:i(`wset.count`),children:e=>(0,q.jsx)(N,{id:e,value:String(l.count??8),options:_e(ge,l.count??8).map(e=>({value:String(e),label:String(e)})),onChange:e=>u({...l,count:Number(e)})})}),a.includes(`account`)&&(0,q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,q.jsx)(`span`,{className:`text-sm font-medium`,children:i(`wset.account`)}),(0,q.jsx)(M,{className:`w-full`,label:i(`wset.accountNone`),ariaLabel:i(`wset.account`),groups:[{options:p}],value:l.account,onSelect:e=>u({...l,account:e})})]}),(0,q.jsx)(P,{label:i(`wset.titleLabel`),hint:i(`wset.titleHint`),children:t=>(0,q.jsx)(h,{id:t,className:`min-h-11 md:min-h-8`,value:d,"aria-invalid":g,placeholder:i(s[e.type]?.titleKey??`widget.chart`),onChange:e=>f(e.target.value)})}),g&&(0,q.jsx)(`p`,{className:`text-sm text-destructive`,role:`alert`,children:i(`cf.err.title`)}),(0,q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,q.jsx)(j,{type:`button`,variant:`outline`,className:`min-h-11 md:min-h-8`,onClick:r,children:i(`common.cancel`)}),(0,q.jsx)(j,{type:`submit`,className:`min-h-11 md:min-h-8`,disabled:m||g,children:t})]})]})}function ye({widget:e,isNew:t,onSave:n,onClose:r}){let{t:i}=A(),a=e?e.title?.trim()||i(s[e.type]?.titleKey??`widget.chart`):``,o=i(t?`wset.add`:`wset.save`);return(0,q.jsx)(V,{open:e!==null,onOpenChange:e=>!e&&r(),children:(0,q.jsxs)(R,{className:`max-h-[92svh] overflow-y-auto sm:max-w-2xl`,children:[(0,q.jsxs)(L,{children:[(0,q.jsx)(z,{children:i(`wset.title`,{name:a})}),(0,q.jsx)(B,{children:i(`wset.description`)})]}),e&&(e.type===`chart`?(0,q.jsx)(fe,{initial:e.query?{query:e.query,chart:e.chart??`bar`,title:e.title??``}:X,submitLabel:o,onCancel:r,onSubmit:t=>{let r={...e,query:t.query,chart:t.chart};t.title?r.title=t.title:delete r.title,n(r)}},e.id):(0,q.jsx)(ve,{widget:e,submitLabel:o,onCancel:r,onSubmit:n},e.id))]})})}function be({saved:e,renderWidget:r,onExit:i}){let{t:a}=A(),o=k().data?.features,l=g(`(max-width: 639px)`),[u,d]=(0,K.useState)(()=>e.map(e=>({...e}))),[p,m]=(0,K.useState)(!1),[h,_]=(0,K.useState)(null),[v,y]=(0,K.useState)(``),[b,x]=(0,K.useState)(null),[S,w]=(0,K.useState)(null),[T,E]=(0,K.useState)(!1),[D,O]=(0,K.useState)(null),M=(0,K.useRef)(null),N=e=>e.title?.trim()||a(s[e.type]?.titleKey??`widget.chart`),P=[...u].sort(f);(0,K.useEffect)(()=>{if(!D)return;let e=e=>document.querySelector(`[data-move="${e}:${D.id}"]`),t=e(D.dir<0?`up`:`down`);(t&&!t.disabled?t:e(D.dir<0?`down`:`up`))?.focus()},[D]);let F=e=>d(t=>{let n=!1,r=t.map(t=>{let r=e.find(e=>e.i===t.id);return!r||r.x===t.x&&r.y===t.y&&r.w===t.w&&r.h===t.h?t:(n=!0,{...t,x:r.x,y:r.y,w:r.w,h:r.h})});return n?r:t}),I=e=>{d(t=>[...t,e]),y(a(`edit.added`,{name:N(e)}))},L=e=>{let t=s[e];if(!t)return;m(!1);let n=C(u,{type:e},t.size);t.options?.includes(`account`)?_({widget:n,isNew:!0}):I(n)},R=()=>{m(!1),_({widget:C(u,{type:`chart`,query:X.query,chart:X.chart},s.chart.size),isNew:!0})},z=e=>{h?.isNew?I(e):(d(t=>t.map(t=>t.id===e.id?e:t)),y(a(`edit.updated`,{name:N(e)}))),_(null)},B=e=>{d(t=>t.filter(t=>t.id!==e.id)),y(a(`edit.removed`,{name:N(e)})),M.current?.focus()},V=(e,t)=>{d(n=>c(n,e.id,t)),y(a(`edit.moved`,{name:N(e)})),O({id:e.id,dir:t})},H=async e=>{x(e),w(null);try{e===`save`?await t(u):await n(),i()}catch(t){w(a(e===`save`?`edit.saveError`:`edit.resetError`,{message:t.message})),E(!1),x(null)}},U=`min-h-11 md:min-h-8`;return(0,q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,q.jsxs)(`div`,{className:`sticky top-0 z-30 -mx-4 flex flex-col gap-2 border-b bg-background/95 px-4 py-2 backdrop-blur md:-mx-6 md:px-6`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsxs)(`h2`,{ref:M,tabIndex:-1,className:`mr-auto text-sm font-medium outline-none`,children:[a(`home.title`),` · `,a(`edit.editing`)]}),T?(0,q.jsxs)(`div`,{role:`alertdialog`,"aria-label":a(`edit.reset`),className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsx)(`p`,{className:`text-sm`,children:a(`edit.resetConfirm`)}),(0,q.jsx)(j,{type:`button`,variant:`destructive`,className:U,disabled:b!==null,onClick:()=>void H(`reset`),children:a(b===`reset`?`edit.saving`:`edit.resetYes`)}),(0,q.jsx)(j,{type:`button`,variant:`outline`,className:U,disabled:b!==null,onClick:()=>E(!1),children:a(`edit.resetKeep`)})]}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(j,{type:`button`,variant:`ghost`,className:U,disabled:b!==null,onClick:()=>E(!0),children:[(0,q.jsx)(re,{}),a(`edit.reset`)]}),(0,q.jsxs)(j,{type:`button`,variant:`outline`,className:U,disabled:b!==null,onClick:()=>m(!0),children:[(0,q.jsx)(G,{}),a(`edit.add`)]}),(0,q.jsx)(j,{type:`button`,variant:`outline`,className:U,disabled:b!==null,onClick:i,children:a(`common.cancel`)}),(0,q.jsxs)(j,{type:`button`,className:U,disabled:b!==null,onClick:()=>void H(`save`),children:[(0,q.jsx)(te,{}),a(b===`save`?`edit.saving`:`edit.done`)]})]})]}),(0,q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:a(l?`edit.hintPhone`:`edit.hintDesktop`)}),S&&(0,q.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:S}),(0,q.jsx)(`p`,{role:`status`,className:`sr-only`,children:v})]}),u.length===0?(0,q.jsx)(`p`,{className:`rounded-xl border border-dashed p-6 text-center text-sm text-muted-foreground`,children:a(`edit.empty`)}):(0,q.jsx)(ee,{widgets:u,editing:!0,onLayoutChange:F,renderWidget:e=>{let t=P.findIndex(t=>t.id===e.id);return r(e,(0,q.jsx)(pe,{id:e.id,name:N(e),first:t===0,last:t===P.length-1,canDrag:!l,canSettings:!l&&!!s[e.type]?.options?.length,onMove:t=>V(e,t),onSettings:()=>_({widget:e,isNew:!1}),onRemove:()=>B(e)}))}}),(0,q.jsx)(le,{open:p,onOpenChange:m,features:o,onPick:L,onCustom:R}),(0,q.jsx)(ye,{widget:h?.widget??null,isNew:h?.isNew??!1,onSave:z,onClose:()=>_(null)})]})}export{be as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{t as e}from"./useMutation-DFgEN5Dk.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-fhKGsTGv.js";import{t as u}from"./triangle-exclamation-point-l1kwARXk.js";import{it as d,l as f,s as p,tt as m}from"./index-
|
|
1
|
+
import{t as e}from"./useMutation-DFgEN5Dk.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-fhKGsTGv.js";import{t as u}from"./triangle-exclamation-point-l1kwARXk.js";import{it as d,l as f,s as p,tt as m}from"./index-DlIU4Ie4.js";import{t as h}from"./Money-B9s3HUmo.js";import{t as g}from"./Panel-DZw2fIkp.js";import{t as _}from"./button-C7t0bIbi.js";import{a as v,i as y,n as b,r as x,t as S}from"./select-DRhU1nFO.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
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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{B as e,I as t,L as n,f as r,u as i,w as a}from"./queries-fhKGsTGv.js";import{a as o,n as s,t as c}from"./charts-
|
|
1
|
+
import{B as e,I as t,L as n,f as r,u as i,w as a}from"./queries-fhKGsTGv.js";import{a as o,n as s,t as c}from"./charts-BOS_LSem.js";import{t as l}from"./DrillLink-yroQT8gZ.js";import{M as u,P as d,a as f,l as p,o as m}from"./index-DlIU4Ie4.js";import{n as h,t as g}from"./drill-t1zr57xi.js";import{n as _}from"./shared-BvrPq08n.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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./DrillLink-yroQT8gZ.js";import{t}from"./Money-
|
|
1
|
+
import{t as e}from"./DrillLink-yroQT8gZ.js";import{t}from"./Money-B9s3HUmo.js";import{M as n}from"./index-DlIU4Ie4.js";import{L as r,c as i,w as a}from"./queries-fhKGsTGv.js";import{n as o}from"./shared-BvrPq08n.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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{L as e,T as t,u as n,w as r}from"./queries-fhKGsTGv.js";import{c as i,u as a}from"./index-
|
|
1
|
+
import{L as e,T as t,u as n,w as r}from"./queries-fhKGsTGv.js";import{c as i,u as a}from"./index-DlIU4Ie4.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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{B as e,I as t,L as n,c as r,w as i}from"./queries-fhKGsTGv.js";import{t as a}from"./Money-
|
|
1
|
+
import{B as e,I as t,L as n,c as r,w as i}from"./queries-fhKGsTGv.js";import{t as a}from"./Money-B9s3HUmo.js";import{a as o,i as s,t as c}from"./charts-BOS_LSem.js";import{M as l,a as u,l as d,u as f}from"./index-DlIU4Ie4.js";import{n as p}from"./shared-BvrPq08n.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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{B as e,I as t,L as n,c as r,w as i}from"./queries-fhKGsTGv.js";import{t as a}from"./DrillLink-yroQT8gZ.js";import{t as o}from"./Money-
|
|
1
|
+
import{B as e,I as t,L as n,c as r,w as i}from"./queries-fhKGsTGv.js";import{t as a}from"./DrillLink-yroQT8gZ.js";import{t as o}from"./Money-B9s3HUmo.js";import{a as s,i as c,t as l}from"./charts-BOS_LSem.js";import{M as u,l as d}from"./index-DlIU4Ie4.js";import{n as f,t as p}from"./shared-BvrPq08n.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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{F as e,I as t,L as n,R as r,z as i}from"./index-
|
|
1
|
+
import{F as e,I as t,L as n,R as r,z as i}from"./index-DlIU4Ie4.js";import{L as a,T as o}from"./queries-fhKGsTGv.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};
|
|
@@ -1 +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-
|
|
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-DlIU4Ie4.js";import{B as s,I as c,L as l,u,w as d}from"./queries-fhKGsTGv.js";import{t as f}from"./button-C7t0bIbi.js";import{a as p,i as m,n as h,o as g,r as _,t as v}from"./dialog-f8fJAP_M.js";import{t as y}from"./Field-BBqplLmm.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};
|
|
@@ -1 +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-fhKGsTGv.js";import{A as s,W as c,n as l,r as u,s as d,t as f}from"./index-
|
|
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-fhKGsTGv.js";import{A as s,W as c,n as l,r as u,s as d,t as f}from"./index-DlIU4Ie4.js";import{t as p}from"./DrillLink-yroQT8gZ.js";import{t as m}from"./Money-B9s3HUmo.js";import{t as h}from"./Panel-DZw2fIkp.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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,t}from"./TxRow-
|
|
1
|
+
import{n as e,t}from"./TxRow-DsexHAVz.js";import{M as n}from"./index-DlIU4Ie4.js";import{B as r,I as i,L as a,d as o,g as s,w as c}from"./queries-fhKGsTGv.js";import{n as l}from"./shared-BvrPq08n.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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./chevron-down-D8cJv15D.js";import{t}from"./chevron-right-BoH5yblW.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-fhKGsTGv.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-CXJ1Qnlx.js";import{t as y}from"./DrillLink-yroQT8gZ.js";import{t as b}from"./Money-NpAKIj6n.js";import{t as x}from"./Panel-B3szLNCa.js";import{t as S}from"./bits-93kCxLrY.js";import{a as C,n as ne,t as re}from"./charts-qUKGFulK.js";import{t as ie}from"./shared-BvrPq08n.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};
|
|
1
|
+
import{t as e}from"./chevron-down-D8cJv15D.js";import{t}from"./chevron-right-BoH5yblW.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-fhKGsTGv.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-DlIU4Ie4.js";import{t as y}from"./DrillLink-yroQT8gZ.js";import{t as b}from"./Money-B9s3HUmo.js";import{t as x}from"./Panel-DZw2fIkp.js";import{t as S}from"./bits-DjQRuWi5.js";import{a as C,n as ne,t as re}from"./charts-BOS_LSem.js";import{t as ie}from"./shared-BvrPq08n.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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./useMutation-DFgEN5Dk.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-fhKGsTGv.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-CXJ1Qnlx.js";import{t as b}from"./KV-D0yMpiyZ.js";import{t as x}from"./Panel-B3szLNCa.js";import{s as S,t as C}from"./button-C7t0bIbi.js";import{i as w,o as T,r as E,s as D}from"./dist-BbQYk9ka.js";import{t as O}from"./dist-C6_xObjc.js";import{a as ee,i as te,n as ne,r as k,t as re}from"./select-CnfPMAV_.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};
|
|
1
|
+
import{t as e}from"./useMutation-DFgEN5Dk.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-fhKGsTGv.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-DlIU4Ie4.js";import{t as b}from"./KV-D0yMpiyZ.js";import{t as x}from"./Panel-DZw2fIkp.js";import{s as S,t as C}from"./button-C7t0bIbi.js";import{i as w,o as T,r as E,s as D}from"./dist-BbQYk9ka.js";import{t as O}from"./dist-C6_xObjc.js";import{a as ee,i as te,n as ne,r as k,t as re}from"./select-DRhU1nFO.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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,t}from"./Combobox-CAP3wl4l.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-CXJ1Qnlx.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-fhKGsTGv.js";import{t as S}from"./Money-NpAKIj6n.js";import{t as C}from"./CategoryIcon-DIqlujCD.js";import{t as w}from"./button-C7t0bIbi.js";import{n as re,r as T,t as ie}from"./TxRow-BDwN3FU8.js";import{n as ae}from"./CategoryPicker-X4mud6cY.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};
|
|
1
|
+
import{n as e,t}from"./Combobox-B8QZhrQa.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-DlIU4Ie4.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-fhKGsTGv.js";import{t as S}from"./Money-B9s3HUmo.js";import{t as C}from"./CategoryIcon-CflJmLil.js";import{t as w}from"./button-C7t0bIbi.js";import{n as re,r as T,t as ie}from"./TxRow-DsexHAVz.js";import{n as ae}from"./CategoryPicker-Dfej_xSa.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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./CategoryIcon-
|
|
1
|
+
import{t as e}from"./CategoryIcon-CflJmLil.js";import{t}from"./Money-B9s3HUmo.js";import{L as n,T as r,w as i}from"./queries-fhKGsTGv.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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,t}from"./arrow-up-7Upl0C9g.js";import{t as n}from"./chevron-right-BoH5yblW.js";import{M as r,Z as i}from"./index-
|
|
1
|
+
import{n as e,t}from"./arrow-up-7Upl0C9g.js";import{t as n}from"./chevron-right-BoH5yblW.js";import{M as r,Z as i}from"./index-DlIU4Ie4.js";import{t as a}from"./triangle-exclamation-point-l1kwARXk.js";import{t as o}from"./Money-B9s3HUmo.js";import{L as s,c,u as l,w as u}from"./queries-fhKGsTGv.js";import{n as d}from"./shared-BvrPq08n.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};
|
|
@@ -1 +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-fhKGsTGv.js";import{t as c}from"./Money-
|
|
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-fhKGsTGv.js";import{t as c}from"./Money-B9s3HUmo.js";import{M as l,n as u,r as d,t as f}from"./index-DlIU4Ie4.js";import{n as p}from"./shared-BvrPq08n.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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{B as e,I as t,L as n,n as r,u as i,w as a}from"./queries-fhKGsTGv.js";import{t as o}from"./bits-
|
|
1
|
+
import{B as e,I as t,L as n,n as r,u as i,w as a}from"./queries-fhKGsTGv.js";import{t as o}from"./bits-DjQRuWi5.js";import{t as s}from"./CategoryPicker-Dfej_xSa.js";import{M as c}from"./index-DlIU4Ie4.js";import{n as l}from"./shared-BvrPq08n.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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{A as e,l as t,n,tt as r,u as i}from"./index-
|
|
1
|
+
import{A as e,l as t,n,tt as r,u as i}from"./index-DlIU4Ie4.js";import{t as a}from"./Money-B9s3HUmo.js";import{L as o,T as s,w as c}from"./queries-fhKGsTGv.js";import{t as l}from"./cards-BK8_l-rA.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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as e,i as t,r as n}from"./index-
|
|
1
|
+
import{d as e,i as t,r as n}from"./index-DlIU4Ie4.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};
|