@actual-app/web 23.10.0 → 23.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/asset-manifest.json +15 -15
- package/build/index.html +1 -1
- package/build/kcab/{kcab.worker.b835d2cdcf8004c363da.js → kcab.worker.8a181a0b032adc34600e.js} +54 -54
- package/build/kcab/{kcab.worker.b835d2cdcf8004c363da.js.map → kcab.worker.8a181a0b032adc34600e.js.map} +1 -1
- package/build/static/js/312.9f087b98.chunk.js +2 -0
- package/build/static/js/312.9f087b98.chunk.js.map +1 -0
- package/build/static/js/{713.1731d555.chunk.js → 444.301f7ece.chunk.js} +2 -2
- package/build/static/js/444.301f7ece.chunk.js.map +1 -0
- package/build/static/js/848.aa73d5a0.chunk.js +19 -0
- package/build/static/js/848.aa73d5a0.chunk.js.map +1 -0
- package/build/static/js/main.fd0bdfe2.js +188 -0
- package/build/static/js/main.fd0bdfe2.js.map +1 -0
- package/build/static/js/narrow-components.9ae206be.chunk.js +2 -0
- package/build/static/js/narrow-components.9ae206be.chunk.js.map +1 -0
- package/build/static/js/reports.778a42ee.chunk.js +2 -0
- package/build/static/js/reports.778a42ee.chunk.js.map +1 -0
- package/build/static/js/wide-components.481c39ec.chunk.js +2 -0
- package/build/static/js/wide-components.481c39ec.chunk.js.map +1 -0
- package/package.json +3 -2
- package/build/static/js/389.c8f94185.chunk.js +0 -2
- package/build/static/js/389.c8f94185.chunk.js.map +0 -1
- package/build/static/js/678.bf349f5d.chunk.js +0 -2
- package/build/static/js/678.bf349f5d.chunk.js.map +0 -1
- package/build/static/js/713.1731d555.chunk.js.map +0 -1
- package/build/static/js/main.7e6eedd0.js +0 -188
- package/build/static/js/main.7e6eedd0.js.map +0 -1
- package/build/static/js/narrow-components.11cf3591.chunk.js +0 -2
- package/build/static/js/narrow-components.11cf3591.chunk.js.map +0 -1
- package/build/static/js/reports.39b7254a.chunk.js +0 -2
- package/build/static/js/reports.39b7254a.chunk.js.map +0 -1
- package/build/static/js/wide-components.fd8595f4.chunk.js +0 -2
- package/build/static/js/wide-components.fd8595f4.chunk.js.map +0 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";(self["webpackChunk_actual_app_web"]=self["webpackChunk_actual_app_web"]||[]).push([[162],{18535:function(e,t,n){n.d(t,{Z:function(){return d}});var r=n(43188);var o=n(66204);var a=n(75433);var i=n(24307);var s=n(52582);var l=n(57651);var c=n(31038);function d({carryover:e,balance:t,disabled:n,style:o,balanceStyle:d,carryoverStyle:u}){let h=(0,l.Z)(e);let p=(0,l.Z)(t);return(0,r.jsxs)(i.Z,{style:o,children:[(0,r.jsx)(s.Z,{binding:t,type:"financial",getStyle:c.TV,style:{textAlign:"right",...!n&&{cursor:"pointer",":hover":{textDecoration:"underline"}},...d}}),h&&(0,r.jsx)(i.Z,{style:{alignSelf:"center",marginLeft:2,position:"absolute",right:-8,top:0,bottom:0,justifyContent:"center",...u},children:(0,r.jsx)(a.Z,{width:7,height:7,style:(0,c.TV)(p)})})]})}},94477:function(e,t,n){n.d(t,{Z:function(){return m}});var r=n(43188);var o=n(66204);var a=n(46055);var i=n(31941);var s=n(57651);var l=n(63541);var c=n(9579);var d=n(44048);var u=n(56816);var h=n(91871);var p=n(24307);var g=n(31038);function f({tooltipProps:e,onSubmit:t,onClose:n}){let{grouped:a}=(0,c.Z)();a=(0,g.iX)(a.filter(e=>!e.is_income));let[i,s]=(0,o.useState)(null);function f(){if(i){t(i);n()}}return(0,r.jsxs)(l.u,{position:"bottom-right",width:200,style:{padding:10},...e,onClose:n,children:[(0,r.jsx)(p.Z,{style:{marginBottom:5},children:"Cover from category:"}),(0,r.jsx)(h.Z,{children:e=>(0,r.jsx)(d.Z,{categoryGroups:a,value:null,openOnFocus:true,onUpdate:e=>{},onSelect:e=>s(e),inputProps:{inputRef:e,onKeyDown:e=>{if(e.key==="Enter"){f()}}}})}),(0,r.jsx)(p.Z,{style:{alignItems:"flex-end",marginTop:10},children:(0,r.jsx)(u.Z,{type:"primary",style:{fontSize:12,paddingTop:3},onClick:f,children:"Transfer"})})]})}var x=n(45990);function m({categoryId:e,tooltip:t,monthIndex:n,onBudgetAction:c,onClose:d,...u}){let h=(0,s.Z)(a.aK.catCarryover(e));let p=(0,s.Z)(a.aK.catBalance(e));let[g,m]=(0,o.useState)("menu");let y=()=>{t.close();d?.()};return(0,r.jsxs)(r.Fragment,{children:[g==="menu"&&(0,r.jsx)(l.u,{position:"bottom-right",width:200,style:{padding:0},onClose:y,...u,children:(0,r.jsx)(i.Z,{onMenuSelect:t=>{if(t==="carryover"){c(n,"carryover",{category:e,flag:!h});y()}else{m(t)}},items:[{name:"transfer",text:"Transfer to another category"},{name:"carryover",text:h?"Remove overspending rollover":"Rollover overspending"},p<0&&{name:"cover",text:"Cover overspending"}].filter(e=>e)})}),g==="transfer"&&(0,r.jsx)(x.Z,{initialAmountName:a.aK.catBalance(e),showToBeBudgeted:true,onClose:y,onSubmit:(t,r)=>{c(n,"transfer-category",{amount:t,from:e,to:r})}}),g==="cover"&&(0,r.jsx)(f,{onClose:y,onSubmit:t=>{c(n,"cover",{to:e,from:t})}})]})}},45990:function(e,t,n){n.d(t,{Z:function(){return m}});var r=n(43188);var o=n(66204);var a=n(55833);var i=n(11535);var s=n(89362);var l=n(9579);var c=n(44048);var d=n(56816);var u=n(91871);var h=n(383);var p=n(24307);var g=n(57201);var f=n(63541);var x=n(31038);function m({initialAmount:e,initialAmountName:t,showToBeBudgeted:n,tooltipProps:m,onSubmit:y,onClose:v}){let w=(0,a.M)();let b=(0,o.useContext)(g.Z);let{grouped:S}=(0,l.Z)();S=S.filter(e=>!e.is_income);if(n){S=(0,x.iX)(S)}let[j,C]=(0,o.useState)(null);let[Z,k]=(0,o.useState)(null);(0,o.useEffect)(()=>{(async()=>{if(t){const e=await w.get(b,t);C((0,s.zA)(Math.max(e.value,0)))}else{C((0,s.zA)(Math.max(e,0)))}})()},[]);function T(){let e=(0,i.Z)(j,null);if(e&&Z){y((0,s.l9)(e),Z);v()}}if(j===null){return null}return(0,r.jsxs)(f.u,{position:"bottom-right",width:200,style:{padding:10},...m,onClose:v,children:[(0,r.jsx)(p.Z,{style:{marginBottom:5},children:"Transfer this amount:"}),(0,r.jsx)(p.Z,{children:(0,r.jsx)(u.Z,{children:(0,r.jsx)(h.ZP,{value:j,onChange:e=>C(e.target["value"]),onEnter:T})})}),(0,r.jsx)(p.Z,{style:{margin:"10px 0 5px 0"},children:"To:"}),(0,r.jsx)(c.Z,{categoryGroups:S,value:null,openOnFocus:true,onUpdate:e=>{},onSelect:e=>k(e),inputProps:{onEnter:T,placeholder:"(none)"}}),(0,r.jsx)(p.Z,{style:{alignItems:"flex-end",marginTop:10},children:(0,r.jsx)(d.Z,{type:"primary",style:{fontSize:12,paddingTop:3,paddingBottom:3},onClick:T,children:"Transfer"})})]})}},31038:function(e,t,n){n.d(t,{Df:function(){return c},Rk:function(){return a},TV:function(){return s},XE:function(){return l},hd:function(){return i},iX:function(){return o},np:function(){return u},qc:function(){return d}});var r=n(45492);function o(e){return[{id:"to-be-budgeted",name:"To Be Budgeted",categories:[{id:"to-be-budgeted",name:"To Be Budgeted",cat_group:"to-be-budgeted",group:{id:"to-be-budgeted",name:"To Be Budgeted"}}]},...e]}function a(e){return[e.filter(e=>!e.is_income),e.find(e=>e.is_income)]}function i(e){return e===0||e==="0"||e===""||e==null?{color:r.rS.altMenuItemText}:null}function s(e){const t=i(e);if(t){return t}if(e<0){return{color:r.rS.errorText}}}function l(e){return{color:e<0?r.rS.errorText:e===0?r.rS.altMenuItemText:r.rS.noticeText}}function c(e,t,n){if(t==="top"){return{targetId:n}}else{let t=e.findIndex(e=>e.id===n);if(t===-1){throw new Error("findSort: item not found: "+n)}let r=t+1;if(r<e.length-1){return{targetId:e[r].id}}else{return{targetId:null}}}}function d(e,t,n){if(t==="bottom"){return{targetId:n}}else{let t=e.findIndex(e=>e.id===n);if(t===-1){throw new Error("findSort: item not found: "+n)}let r=t-1;if(r>=0){return{targetId:e[r].id}}else{return{targetId:null}}}}function u(){return Math.max(r.W2.scrollbarWidth-2,0)}},74664:function(e,t,n){n.r(t);n.d(t,{Account:function(){return n5},Accounts:function(){return n5},Budget:function(){return tS},GoCardlessLink:function(){return tM},Schedules:function(){return tT}});var r={};n.r(r);n.d(r,{BudgetSummary:function(){return eJ},BudgetTotalsMonth:function(){return e1},CategoryMonth:function(){return e8},ExpenseCategoryMonth:function(){return e6},ExpenseGroupMonth:function(){return e3},GroupMonth:function(){return e5},IncomeCategoryMonth:function(){return e9},IncomeGroupMonth:function(){return e7},IncomeHeaderMonth:function(){return e2}});var o={};n.r(o);n.d(o,{BudgetSummary:function(){return th},BudgetTotalsMonth:function(){return tg},ExpenseCategoryMonth:function(){return tm},ExpenseGroupMonth:function(){return tx},IncomeCategoryMonth:function(){return tv},IncomeGroupMonth:function(){return ty},IncomeHeaderMonth:function(){return tf}});var a=n(43188);var i=n(66204);var s=n(37496);var l=n(59379);var c=n(55833);var d=n(84094);var u=n(25258);var h=n(73416);var p=n(1447);var g=n(9579);var f=n(58068);var x=n(24868);var m=n(45492);var y=n(24307);var v=n(44593);var w=n(38638);var b=n(75025);var S=n(37418);const j=({startMonth:e,numDisplayed:t,monthBounds:n,style:r,onSelect:o})=>{const[s,l]=(0,i.useState)(null);const[c,d]=(0,i.useState)(12);const u=h.dK();const p=e;const g=h.zI(p,t-1);const f=h.Do(h.W9(p,c/2-t/2),h.zI(g,c/2-t/2));const x=Math.floor(f.length/2)-Math.floor(t/2);const v=x+t-1;const[w,b]=(0,i.useState)("small");const j=(0,S.Z)(e=>{b(e.width<=400?"small":"big");d(Math.min(Math.max(Math.floor(e.width/50),12),24))});let C=[];return(0,a.jsx)(y.Z,{style:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",...r},children:(0,a.jsx)(y.Z,{innerRef:j,style:{flexDirection:"row",flex:1,alignItems:"center",justifyContent:"center"},children:f.map((e,r)=>{const i=h.WU(e,"MMM");const c=r>=x&&r<=v;const d=s+t-1;const p=s===null?false:r>=s&&r<=d;const g=u===e;const f=h.So(e);let b=false;if(!C.includes(f)){C.push(f);b=true}const S=e>=n.start&&e<=n.end;return(0,a.jsxs)(y.Z,{style:{padding:"3px 3px",width:w==="big"?"35px":"20px",textAlign:"center",userSelect:"none",cursor:"default",borderRadius:2,border:"none",...!S&&{textDecoration:"line-through",color:m.rS.pageTextSubdued},...m.W2.smallText,...c&&{backgroundColor:m.rS.tableBorderHover,color:m.rS.buttonPrimaryText},...(p||c)&&{borderRadius:0,cursor:"pointer"},...p&&!c&&{backgroundColor:"rgba(100, 100, 100, .15)"},...p&&c&&{backgroundColor:m.rS.tableBorderHover},...(r===x||r===s&&!c)&&{borderTopLeftRadius:2,borderBottomLeftRadius:2},...(r===v||r===d&&!c)&&{borderTopRightRadius:2,borderBottomRightRadius:2},...g&&{fontWeight:"bold"}},onClick:()=>o(e),onMouseEnter:()=>l(r),onMouseLeave:()=>l(null),children:[w==="small"?i[0]:i,b&&(0,a.jsx)(y.Z,{style:{position:"absolute",top:-14,left:0,fontSize:10,fontWeight:"bold",color:S?m.rS.pageText:m.rS.pageTextSubdued},children:f})]},e)})})})};var C=n(31038);const Z=(0,i.memo)(({startMonth:e,onMonthSelect:t,numMonths:n,monthBounds:r,style:o})=>{function i(e){let t=r.start;let o=h.W9(r.end,n-1);if(e<t){return t}else if(e>o){return o}return e}return(0,a.jsx)(y.Z,{style:{marginLeft:200+5,flexShrink:0},children:(0,a.jsx)(y.Z,{style:{marginRight:5+(0,C.np)()},children:(0,a.jsx)(j,{startMonth:e,numDisplayed:n,monthBounds:r,style:{paddingTop:5},onSelect:e=>t(i(e))})})})});var k=Z;var T=n(63541);var A=n(35562);var B=n(64651);var M=n(57201);function I(e,t,n){return{start:t<e.start?e.start:t,end:n>e.end?e.end:n}}let R=(0,i.createContext)(null);function E({startMonth:e,numMonths:t,monthBounds:n,type:r,children:o}){let i=h.zI(e,t-1);let s=I(n,e,i);let l=h.Do(s.start,s.end);return(0,a.jsx)(R.Provider,{value:{months:l,type:r},children:o})};function D({component:e,editingIndex:t,args:n,style:r}){let{months:o}=(0,i.useContext)(R);return o.map((o,i)=>{let s=t===i;return(0,a.jsx)(M.Z.Provider,{value:h.cv(o),children:(0,a.jsx)(y.Z,{style:{flex:1,borderLeft:"1px solid "+m.rS.tableBorder,...r},children:(0,a.jsx)(e,{monthIndex:i,editing:s,...n})})},i)})}var P=D;var W=n(85025);var L=n(56816);var N=n(31941);var F=n(7709);var _=n(99818);var H=n(53440);var G=n(10959);var O=n(69304);const z=e=>(0,a.jsx)("svg",{...e,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 19 24",style:{color:"inherit",...e.style},children:(0,a.jsx)("path",{fill:"currentColor",d:"M17 24H2a2 2 0 0 1-2-2V2a2 2 0 0 1 2-2h9a1 1 0 0 1 .707.293l7 7A1 1 0 0 1 19 8v14a2 2 0 0 1-2 2ZM2 21.5a.5.5 0 0 0 .5.5h14a.5.5 0 0 0 .5-.5V9a.5.5 0 0 0-.5-.5h-4a2 2 0 0 1-2-2v-4A.5.5 0 0 0 10 2H2.5a.5.5 0 0 0-.5.5v19Z"})});var U=z;var K=n(76447);function $(){const e=this.data();function t(t,n){const r=e[t]?e[t]:e[t]=[];r.push(n)}t("fromMarkdownExtensions",{enter:{lineEndingBlank:function e(e){this.enter({type:"break",value:"",data:{},children:[]},e)}},exit:{lineEndingBlank:function e(e){this.exit(e)}}})}function Q(){return K.F}var V=n(77644);const q=[$,H.Z,Q];const X=(0,_.iv)({display:"block",maxWidth:350,padding:8,overflowWrap:"break-word","& p":{margin:0,":not(:first-child)":{marginTop:"0.25rem"}},"& ul, & ol":{listStylePosition:"inside",margin:0,paddingLeft:0},"&>* ul, &>* ol":{marginLeft:"1.5rem"},"& li>p":{display:"contents"},"& blockquote":{paddingLeft:"0.75rem",borderLeft:"3px solid "+m.rS.markdownDark,margin:0},"& hr":{borderTop:"none",borderLeft:"none",borderRight:"none",borderBottom:"1px solid "+m.rS.markdownNormal},"& code":{backgroundColor:m.rS.markdownLight,padding:"0.1rem 0.5rem",borderRadius:"0.25rem"},"& pre":{padding:"0.5rem",backgroundColor:m.rS.markdownLight,borderRadius:"0.5rem",margin:0,":not(:first-child)":{marginTop:"0.25rem"},"& code":{background:"inherit",padding:0,borderRadius:0}},"& table, & th, & td":{border:"1px solid "+m.rS.markdownNormal},"& table":{borderCollapse:"collapse",wordBreak:"break-word"},"& td":{padding:"0.25rem 0.75rem"}});function Y({editable:e,defaultNotes:t,position:n="bottom-left",onClose:r}){let[o,s]=(0,i.useState)(t);let l=(0,i.createRef)();(0,i.useEffect)(()=>{if(e){l.current.focus()}},[l,e]);return(0,a.jsx)(T.u,{position:n,onClose:()=>r(o),children:e?(0,a.jsx)("textarea",{ref:l,className:`${(0,_.iv)({border:"1px solid "+m.rS.buttonNormalBorder,padding:7,minWidth:350,minHeight:120,outline:"none"})}`,value:o||"",onChange:e=>s(e.target.value),placeholder:"Notes (markdown supported)"}):(0,a.jsx)(V.Z,{...X,children:(0,a.jsx)(F.D,{remarkPlugins:q,linkTarget:"_blank",children:o})})})}function J({id:e,width:t=12,height:n=12,defaultColor:r=m.rS.pageBackgroundModalActive,tooltipPosition:o,style:s}){let[l,c]=(0,i.useState)(false);let u=(0,T.lL)();let h=(0,O.y)(()=>(0,G.ZP)("notes").filter({id:e}).select("*"),[e]);let p=h&&h.length>0?h[0].note:null;let g=p&&p!=="";function f(t){(0,d.lW)("notes-save",{id:e,note:t});u.close()}const[x,v]=(0,i.useState)(null);const w=()=>{v(setTimeout(()=>{c(true)},300))};const b=()=>{clearTimeout(x);c(false)};const S=u.isOpen||g&&l;return(0,a.jsxs)(y.Z,{style:{flexShrink:0},onMouseEnter:w,onMouseLeave:b,children:[(0,a.jsx)(L.Z,{type:"bare",className:!g&&!S?"hover-visible":"",style:{color:r,...s,...g&&{display:"flex !important"},...S&&{color:m.rS.buttonNormalText}},...u.getOpenEvents(),children:(0,a.jsx)(U,{style:{width:t,height:n}})}),S&&(0,a.jsx)(Y,{editable:u.isOpen,defaultNotes:p,position:o,onClose:f})]})};function ee({innerRef:e,category:t,dragPreview:n,dragging:r,editing:o,style:s,borderColor:l=m.rS.tableBorder,isLast:c,onDragChange:d,onEditMonth:u,onEditName:h,onSave:p,onDelete:g,onHideNewCategory:f}){const x=t.id==="new";const[v,w]=(0,i.useState)(false);const b=(0,a.jsxs)(y.Z,{style:{flexDirection:"row",alignItems:"center",userSelect:"none",WebkitUserSelect:"none",opacity:t.hidden?.33:undefined},children:[(0,a.jsx)("div",{"data-testid":"category-name",style:{textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden",minWidth:0},children:t.name}),(0,a.jsxs)(y.Z,{style:{flexShrink:0,marginLeft:5},children:[(0,a.jsx)(L.Z,{type:"bare",onClick:e=>{e.stopPropagation();w(true)},style:{color:"currentColor",padding:3},children:(0,a.jsx)(W.Z,{width:14,height:14,style:{color:"currentColor"}})}),v&&(0,a.jsx)(T.u,{position:"bottom-left",width:200,style:{padding:0},onClose:()=>w(false),children:(0,a.jsx)(N.Z,{onMenuSelect:e=>{if(e==="rename"){h(t.id)}else if(e==="delete"){g(t.id)}else if(e==="toggle-visibility"){p({...t,hidden:!t.hidden})}w(false)},items:[{name:"toggle-visibility",text:t.hidden?"Show":"Hide"},{name:"rename",text:"Rename"},{name:"delete",text:"Delete"}]})})]}),(0,a.jsx)(y.Z,{style:{flex:1}}),(0,a.jsx)(J,{id:t.id,style:r&&{color:"currentColor"}})]});return(0,a.jsx)(y.Z,{innerRef:e,style:{width:200,"& button":{display:"none"},...!r&&!n&&{"&:hover button":{display:"flex",color:m.rS.tableTextHover}},...r&&{color:m.rS.formInputTextPlaceholderSelected},...n&&{backgroundColor:"white",zIndex:1e4,borderRadius:6,overflow:"hidden"},...s},onKeyDown:e=>{if(e.key==="Enter"){h(null);e.stopPropagation()}},children:(0,a.jsx)(B.F3,{value:t.name,formatter:e=>b,width:"flex",exposed:o||x,onUpdate:e=>{if(x){if(e===""){f()}else if(e!==""){p({...t,name:e})}}else{if(e!==t.name){p({...t,name:e})}}},onBlur:()=>h(null),style:{paddingLeft:13,...c&&{borderBottomWidth:0}},inputProps:{placeholder:x?"New Category Name":""}})})}var et=ee;function en({cat:e,budgetArray:t,editingCell:n,dragState:r,MonthComponent:o,onEditName:i,onEditMonth:s,onSave:l,onDelete:c,onBudgetAction:d,onShowActivity:u,onDragChange:h,onReorder:p}){let g=r&&r.item===e;if(r&&r.item.id===e.cat_group){g=true}let{dragRef:f}=(0,A.O1)({type:"category",onDragChange:h,item:e,canDrag:n===null});let{dropRef:x,dropPos:v}=(0,A.Zj)({types:"category",id:e.id,onDrop:p});return(0,a.jsxs)(B.X2,{innerRef:x,collapsed:true,style:{backgroundColor:m.rS.tableBackground,opacity:e.hidden?.5:undefined},children:[(0,a.jsx)(A.OJ,{pos:v,offset:{top:1}}),(0,a.jsxs)(y.Z,{style:{flex:1,flexDirection:"row"},children:[(0,a.jsx)(et,{innerRef:f,category:e,dragPreview:g&&r.preview,dragging:g&&!r.preview,editing:n&&n.cell==="name"&&n.id===e.id,onEditName:i,onSave:l,onDelete:c,onDragChange:h}),(0,a.jsx)(P,{component:o,editingIndex:n&&n.id===e.id&&n.cell,args:{category:e,onEdit:s,onBudgetAction:d,onShowActivity:u}})]})]})}var er=en;var eo=n(67459);function ea({group:e,editing:t,collapsed:n,dragPreview:r,innerRef:o,style:s,borderColor:l=m.rS.tableBorder,onEdit:c,onSave:d,onDelete:u,onShowNewCategory:h,onHideNewGroup:p,onToggleCollapse:g}){const f=e.id==="new";const[x,v]=(0,i.useState)(false);const w=(0,a.jsxs)(y.Z,{style:{flexDirection:"row",alignItems:"center",userSelect:"none",WebkitUserSelect:"none"},onClick:t=>{g(e.id)},children:[!r&&(0,a.jsx)(eo.Z,{width:8,height:8,style:{marginRight:5,marginLeft:5,flexShrink:0,transition:"transform .1s",transform:n?"rotate(-90deg)":""}}),(0,a.jsxs)("div",{style:{textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden",minWidth:0},children:[r&&(0,a.jsx)(V.Z,{style:{fontWeight:500},children:"Group: "}),e.name]}),!r&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(y.Z,{style:{marginLeft:5,flexShrink:0},children:[(0,a.jsx)(L.Z,{type:"bare",onClick:e=>{e.stopPropagation();v(true)},style:{padding:3},children:(0,a.jsx)(W.Z,{width:14,height:14})}),x&&(0,a.jsx)(T.u,{position:"bottom-left",width:200,style:{padding:0},onClose:()=>v(false),children:(0,a.jsx)(N.Z,{onMenuSelect:t=>{if(t==="rename"){c(e.id)}else if(t==="add-category"){h(e.id)}else if(t==="delete"){u(e.id)}else if(t==="toggle-visibility"){d({...e,hidden:!e.hidden})}v(false)},items:[{name:"add-category",text:"Add category"},{name:"toggle-visibility",text:e.hidden?"Show":"Hide"},{name:"rename",text:"Rename"},u&&{name:"delete",text:"Delete"}]})})]}),(0,a.jsx)(y.Z,{style:{flex:1}}),(0,a.jsx)(J,{id:e.id})]})]});return(0,a.jsx)(y.Z,{innerRef:o,style:{...s,width:200,backgroundColor:m.rS.altTableBackground,"& button":{display:"none"},"&:hover button":{display:"flex",color:m.rS.tableTextHover},...r&&{paddingLeft:10,zIndex:1e4,borderRadius:6,overflow:"hidden"}},onKeyDown:e=>{if(e.key==="Enter"){c(null);e.stopPropagation()}},children:(0,a.jsx)(B.F3,{value:e.name,formatter:e=>w,width:"flex",exposed:t,onUpdate:t=>{if(f){if(t===""){p()}else if(t!==""){d({id:e.id,name:t})}}else{d({id:e.id,name:t})}},onBlur:()=>c(null),style:{fontWeight:600},inputProps:{value:undefined,style:{marginLeft:20},placeholder:f?"New Group Name":""}})})}var ei=ea;function es({group:e,collapsed:t,editingCell:n,dragState:r,itemPos:o,MonthComponent:i,onEditName:s,onSave:l,onDelete:c,onDragChange:d,onReorderGroup:u,onReorderCategory:h,onToggleCollapse:p,onShowNewCategory:g}){let f=r&&r.item===e;let{dragRef:x}=(0,A.O1)({type:"group",onDragChange:d,item:e,canDrag:n===null});let{dropRef:v,dropPos:w}=(0,A.Zj)({types:"group",id:e.id,onDrop:u});let{dropRef:b,dropPos:S}=(0,A.Zj)({types:"category",id:e.id,onDrop:h,onLongHover:()=>{if(t){p(e.id)}}});return(0,a.jsxs)(B.X2,{collapsed:true,style:{fontWeight:600,opacity:e.hidden?.33:undefined,backgroundColor:m.rS.altTableBackground},children:[r&&!r.preview&&r.type==="group"&&(0,a.jsx)(y.Z,{innerRef:v,style:{position:"absolute",left:0,right:0,height:t?B.dN-1:(1+e.categories.length)*(B.dN-1)+1,zIndex:1e4},children:(0,a.jsx)(A.OJ,{pos:w,offset:{top:1}})}),(0,a.jsx)(A.OJ,{pos:S,offset:{top:1}}),(0,a.jsxs)(y.Z,{innerRef:b,style:{flex:1,flexDirection:"row",opacity:f&&!r.preview?.3:1},children:[(0,a.jsx)(ei,{innerRef:x,group:e,editing:n&&n.cell==="name"&&n.id===e.id,dragPreview:f&&r.preview,collapsed:t,onToggleCollapse:p,onEdit:s,onSave:l,onDelete:c,onShowNewCategory:g}),(0,a.jsx)(P,{component:i,args:{group:e}})]})]})}var el=es;function ec({cat:e,isLast:t,editingCell:n,MonthComponent:r,onEditName:o,onEditMonth:i,onSave:s,onDelete:l,onDragChange:c,onBudgetAction:d,onReorder:u,onShowActivity:h}){let{dragRef:p}=(0,A.O1)({type:"income-category",onDragChange:c,item:e,canDrag:n===null});let{dropRef:g,dropPos:f}=(0,A.Zj)({types:"income-category",id:e.id,onDrop:u});return(0,a.jsxs)(B.X2,{innerRef:g,collapsed:true,children:[(0,a.jsx)(A.OJ,{pos:f,offset:{top:1}}),(0,a.jsx)(et,{innerRef:p,category:e,isLast:t,editing:n&&n.cell==="name"&&n.id===e.id,onEditName:o,onSave:s,onDelete:l}),(0,a.jsx)(P,{component:r,editingIndex:n&&n.id===e.id&&n.cell,args:{category:e,onEdit:i,isLast:t,onShowActivity:h,onBudgetAction:d}})]})}var ed=ec;function eu({group:e,editingCell:t,collapsed:n,MonthComponent:r,onEditName:o,onSave:i,onToggleCollapse:s,onShowNewCategory:l}){return(0,a.jsxs)(B.X2,{collapsed:true,style:{fontWeight:600,backgroundColor:m.rS.altTableBackground},children:[(0,a.jsx)(ei,{group:e,collapsed:n,editing:t&&t.cell==="name"&&t.id===e.id,onEdit:o,onSave:i,onToggleCollapse:s,onShowNewCategory:l}),(0,a.jsx)(P,{component:r,args:{group:e}})]})}var eh=eu;function ep({MonthComponent:e,onShowNewGroup:t}){return(0,a.jsxs)(y.Z,{style:{flexDirection:"row",flex:1},children:[(0,a.jsx)(y.Z,{style:{width:200,alignItems:"flex-start",justifyContent:"flex-start"},children:(0,a.jsx)(L.Z,{onClick:t,style:{fontSize:12,margin:10},children:"Add Group"})}),(0,a.jsx)(P,{component:e,style:{border:0,justifyContent:"flex-end"}})]})}var eg=ep;const ef=(0,i.memo)(({categoryGroups:e,newCategoryForGroup:t,showHiddenCategories:n,isAddingGroup:r,editingCell:o,collapsed:s,setCollapsed:l,dataComponents:c,onBudgetAction:d,onShowActivity:u,onEditName:h,onEditMonth:p,onSaveCategory:g,onSaveGroup:f,onDeleteCategory:x,onDeleteGroup:v,onReorderCategory:w,onReorderGroup:b,onShowNewCategory:S,onHideNewCategory:j,onShowNewGroup:Z,onHideNewGroup:k})=>{let T=(0,i.useMemo)(()=>{let[o,a]=(0,C.Rk)(e);let i=Array.prototype.concat.apply([],o.map(e=>{if(e.hidden&&!n){return[]}const r=e.categories.filter(e=>n||!e.hidden);let o=[{type:"expense-group",value:{...e}}];if(t===e.id){o.push({type:"new-category"})}return[...o,...(s.includes(e.id)?[]:r).map(e=>({type:"expense-category",value:e}))]}));if(r){i.push({type:"new-group"})}if(a){i=i.concat([{type:"income-separator"},{type:"income-group",value:a},t===a.id&&{type:"new-category"},...(s.includes(a.id)?[]:a.categories.filter(e=>n||!e.hidden)).map(e=>({type:"income-category",value:e}))].filter(e=>e))}return i},[e,s,t,r,n]);let[M,I]=(0,i.useState)(null);let[R,E]=(0,i.useState)(null);function D(e){let{state:t}=e;if(t==="start-preview"){I({type:e.type,item:e.item,preview:true})}else if(t==="start"){if(M){I({...M,preview:false});E(s)}}else if(t==="hover"){I({...M,hoveredId:e.id,hoveredPos:e.pos})}else if(t==="end"){I(null);l(R||[])}}function P(e){if(s.includes(e)){l(s.filter(t=>t!==e))}else{l([...s,e])}}return(0,a.jsx)(y.Z,{style:{marginBottom:10,backgroundColor:m.rS.tableBackground,overflow:"hidden",boxShadow:m.W2.cardShadow,borderRadius:"0 0 4px 4px",flex:1},children:T.map((n,r)=>{let i;switch(n.type){case"new-group":i=(0,a.jsx)(B.X2,{style:{backgroundColor:m.rS.altTableBackground},children:(0,a.jsx)(ei,{group:{id:"new",name:""},editing:true,onSave:f,onHideNewGroup:k,onEdit:h})});break;case"new-category":i=(0,a.jsx)(B.X2,{children:(0,a.jsx)(et,{category:{name:"",cat_group:t,is_income:t===e.find(e=>e.is_income).id,id:"new"},editing:true,onSave:g,onHideNewCategory:j,onEditName:h})});break;case"expense-group":i=(0,a.jsx)(el,{group:n.value,editingCell:o,collapsed:s.includes(n.value.id),MonthComponent:c.ExpenseGroupComponent,dragState:M,onEditName:h,onSave:f,onDelete:v,onDragChange:D,onReorderGroup:b,onReorderCategory:w,onToggleCollapse:P,onShowNewCategory:S});break;case"expense-category":i=(0,a.jsx)(er,{cat:n.value,editingCell:o,MonthComponent:c.ExpenseCategoryComponent,dragState:M,onEditName:h,onEditMonth:p,onSave:g,onDelete:x,onDragChange:D,onReorder:w,onBudgetAction:d,onShowActivity:u});break;case"income-separator":i=(0,a.jsx)(y.Z,{style:{height:m.W2.incomeHeaderHeight,backgroundColor:m.rS.tableBackground},children:(0,a.jsx)(eg,{MonthComponent:c.IncomeHeaderComponent,onShowNewGroup:Z})});break;case"income-group":i=(0,a.jsx)(eh,{group:n.value,editingCell:o,MonthComponent:c.IncomeGroupComponent,collapsed:s.includes(n.value.id),onEditName:h,onSave:f,onToggleCollapse:P,onShowNewCategory:S});break;case"income-category":i=(0,a.jsx)(ed,{cat:n.value,editingCell:o,isLast:r===T.length-1,MonthComponent:c.IncomeCategoryComponent,onEditName:h,onEditMonth:p,onSave:g,onDelete:x,onDragChange:D,onReorder:w,onBudgetAction:d,onShowActivity:u});break;default:throw new Error("Unknown item type: "+n.type)}let l=r===0?"first":r===T.length-1?"last":null;return(0,a.jsx)(A.aB.Provider,{value:l,children:(0,a.jsx)(y.Z,{style:!M&&{":hover":{backgroundColor:"#fcfcfc"}},children:i})},n.value?n.value.id:n.type==="income-separator"?"separator":r)})})});var ex=ef;var em=n(13015);function ey({SummaryComponent:e}){let{months:t}=(0,i.useContext)(R);let[n,r]=(0,i.useState)(0);let[o,s]=(0,em.q_)(()=>({x:0,config:{mass:3,tension:600,friction:80}}));let l=(0,S.Z)((0,i.useCallback)(e=>{r(e.width)},[]));let c=(0,i.useRef)(t[0]);let d=[...t];d.unshift(h.W9(t[0],1));d.push(h.zI(t[t.length-1],1));let u=n/t.length;(0,i.useLayoutEffect)(()=>{let e=c.current;let n=e>t[0];let r=u;let o=n?-r*2:0;if(e!==d[0]&&e!==d[2]){o=-r}let a=-r;s.start({from:{x:o},x:a})},[t[0]]);(0,i.useLayoutEffect)(()=>{c.current=t[0]},[t[0]]);(0,i.useLayoutEffect)(()=>{s.start({from:{x:-u},to:{x:-u}})},[u]);return(0,a.jsx)("div",{className:`${(0,_.iv)([{flex:1,overflow:"hidden"},t.length===1&&{marginLeft:-4,marginRight:-4}])}`,ref:l,children:(0,a.jsx)(em.q.div,{className:"view",style:{flexDirection:"row",width:n,willChange:"transform",transform:o.x.to(e=>`translateX(${e}px)`)},children:d.map(t=>{return(0,a.jsx)(y.Z,{style:{flex:`0 0 ${u}px`,paddingLeft:4,paddingRight:4},children:(0,a.jsx)(e,{month:t})},t)})})})}var ev=n(94276);const ew=(0,i.memo)(function e({MonthComponent:e,toggleHiddenCategories:t,expandAllCategories:n,collapseAllCategories:r}){const[o,s]=(0,i.useState)(false);return(0,a.jsxs)(y.Z,{"data-testid":"budget-totals",style:{backgroundColor:m.rS.tableBackground,flexDirection:"row",flexShrink:0,boxShadow:m.W2.cardShadow,marginLeft:5,marginRight:5+(0,C.np)(),borderRadius:"4px 4px 0 0",borderBottom:"1px solid "+m.rS.tableBorder},children:[(0,a.jsxs)(y.Z,{style:{width:200,color:m.rS.pageTextLight,justifyContent:"center",paddingLeft:15,paddingRight:5,display:"flex",flexDirection:"row",alignItems:"center",userSelect:"none",WebkitUserSelect:"none"},children:[(0,a.jsx)(y.Z,{style:{flexGrow:"1"},children:"Category"}),(0,a.jsxs)(L.Z,{type:"bare",onClick:()=>{s(true)},style:{color:"currentColor",padding:3},children:[(0,a.jsx)(ev.Z,{width:15,height:15,style:{color:m.rS.pageTextLight}}),o&&(0,a.jsx)(T.u,{position:"bottom-right",width:200,style:{padding:0},onClose:()=>{s(false)},children:(0,a.jsx)(N.Z,{onMenuSelect:e=>{if(e==="toggle-visibility"){t()}else if(e==="expandAllCategories"){n()}else if(e==="collapseAllCategories"){r()}s(false)},items:[{name:"toggle-visibility",text:"Toggle hidden categories"},{name:"expandAllCategories",text:"Expand all"},{name:"collapseAllCategories",text:"Collapse all"}]})})]})]}),(0,a.jsx)(P,{component:e})]})});var eb=ew;class eS extends i.Component{constructor(e){super(e);this.budgetCategoriesRef=(0,i.createRef)();this.state={editing:null,draggingState:null,showHiddenCategories:e.prefs["budget.showHiddenCategories"]??false}}onEditMonth=(e,t)=>{this.setState({editing:e?{id:e,cell:t}:null})};onEditName=e=>{this.setState({editing:e?{id:e,cell:"name"}:null})};onReorderCategory=(e,t,n)=>{let{categoryGroups:r}=this.props;let o=!!r.find(e=>e.id===n);if(o){let{targetId:o}=(0,C.qc)(r,t,n);let a=r.find(e=>e.id===o);if(a){let{categories:n}=a;this.props.onReorderCategory({id:e,groupId:a.id,targetId:n.length===0||t==="top"?null:n[0].id})}}else{let o;for(let e of r){if(e.categories.find(e=>e.id===n)){o=e;break}}this.props.onReorderCategory({id:e,groupId:o.id,...(0,C.Df)(o.categories,t,n)})}};onReorderGroup=(e,t,n)=>{let{categoryGroups:r}=this.props;this.props.onReorderGroup({id:e,...(0,C.Df)(r,t,n)})};moveVertically=e=>{let{editing:t}=this.state;let{type:n,categoryGroups:r,collapsed:o}=this.props;const a=r.reduce((e,t)=>{if(o.includes(t.id)){return e.concat({id:t.id,isGroup:true})}return e.concat([{id:t.id,isGroup:true},...t.categories])},[]);if(t){const r=a.findIndex(e=>e.id===t.id);let o=r+e;while(o>=0&&o<a.length){const r=a[o];if(r.isGroup){o+=e;continue}else if(n==="report"||!r.is_income){this.onEditMonth(r.id,t.cell);return}else{break}}}};onKeyDown=e=>{if(!this.state.editing){return null}if(e.key==="Enter"||e.key==="Tab"){e.preventDefault();this.moveVertically(e.shiftKey?-1:1)}};onShowActivity=(e,t,n)=>{this.props.onShowActivity(e,t,this.resolveMonth(n))};onBudgetAction=(e,t,n)=>{this.props.onBudgetAction(this.resolveMonth(e),t,n)};resolveMonth=e=>{return h.zI(this.props.startMonth,e)};clearEditing(){this.setState({editing:null})}toggleHiddenCategories=()=>{this.setState(e=>({showHiddenCategories:!e.showHiddenCategories}));this.props.savePrefs({"budget.showHiddenCategories":!this.state.showHiddenCategories})};expandAllCategories=()=>{this.props.setCollapsed([])};collapseAllCategories=()=>{let{setCollapsed:e,categoryGroups:t}=this.props;e(t.map(e=>e.id))};render(){let{type:e,categoryGroups:t,prewarmStartMonth:n,startMonth:r,numMonths:o,monthBounds:i,collapsed:s,setCollapsed:l,newCategoryForGroup:c,dataComponents:d,isAddingGroup:u,onSaveCategory:h,onSaveGroup:p,onDeleteCategory:g,onDeleteGroup:f,onShowNewCategory:x,onHideNewCategory:v,onShowNewGroup:w,onHideNewGroup:b}=this.props;let{editing:S,draggingState:j,showHiddenCategories:Z}=this.state;return(0,a.jsxs)(y.Z,{"data-testid":"budget-table",style:{flex:1,...m.W2.lightScrollbar&&{"& ::-webkit-scrollbar":{backgroundColor:"transparent"},"& ::-webkit-scrollbar-thumb:vertical":{backgroundColor:m.rS.tableHeaderBackground}}},children:[(0,a.jsxs)(y.Z,{style:{flexDirection:"row",overflow:"hidden",flexShrink:0,paddingLeft:5,paddingRight:5+(0,C.np)()},children:[(0,a.jsx)(y.Z,{style:{width:200}}),(0,a.jsx)(E,{startMonth:n,numMonths:o,monthBounds:i,type:e,children:(0,a.jsx)(ey,{SummaryComponent:d.SummaryComponent})})]}),(0,a.jsxs)(E,{startMonth:r,numMonths:o,monthBounds:i,type:e,children:[(0,a.jsx)(eb,{MonthComponent:d.BudgetTotalsComponent,toggleHiddenCategories:this.toggleHiddenCategories,expandAllCategories:this.expandAllCategories,collapseAllCategories:this.collapseAllCategories}),(0,a.jsx)(T.Hp.Provider,{value:this.budgetCategoriesRef,children:(0,a.jsx)(y.Z,{style:{overflowY:"scroll",overflowAnchor:"none",flex:1,paddingLeft:5,paddingRight:5},innerRef:this.budgetCategoriesRef,children:(0,a.jsx)(y.Z,{style:{opacity:j?.5:1,flexShrink:0},onKeyDown:this.onKeyDown,innerRef:e=>this.budgetDataNode=e,children:(0,a.jsx)(ex,{showHiddenCategories:Z,categoryGroups:t,newCategoryForGroup:c,isAddingGroup:u,editingCell:S,collapsed:s,setCollapsed:l,dataComponents:d,onEditMonth:this.onEditMonth,onEditName:this.onEditName,onSaveCategory:h,onSaveGroup:p,onDeleteCategory:g,onDeleteGroup:f,onReorderCategory:this.onReorderCategory,onReorderGroup:this.onReorderGroup,onShowNewCategory:x,onHideNewCategory:v,onShowNewGroup:w,onHideNewGroup:b,onBudgetAction:this.onBudgetAction,onShowActivity:this.onShowActivity})})})})]})]})}}var ej=eS;function eC(e){let t=e-200;if(t<500){return 1}else if(t<750){return 2}else if(t<1e3){return 3}else if(t<1250){return 4}else if(t<1500){return 5}return 6}const eZ=(0,i.forwardRef)(({width:e,height:t,categoryGroups:n,prewarmStartMonth:r,startMonth:o,maxMonths:l=3,monthBounds:c,onMonthSelect:d,onPreload:u,...h},g)=>{let f=(0,s.v9)(e=>e.prefs.local);let{setDisplayMax:x}=(0,b.s)();let m=(0,p.o)();let v=eC(e);let w=Math.min(v,l);let S=200+500*w;(0,i.useEffect)(()=>{x(v)},[v]);function j(e){d(e,w)}return(0,a.jsx)(y.Z,{style:{width:e,height:t,alignItems:"center",opacity:e<=0||t<=0?0:1},children:(0,a.jsxs)(y.Z,{style:{width:"100%",maxWidth:S},children:[(0,a.jsx)(k,{startMonth:r,numMonths:w,monthBounds:c,onMonthSelect:j}),(0,a.jsx)(ej,{ref:g,categoryGroups:n,prewarmStartMonth:r,startMonth:o,numMonths:w,monthBounds:c,prefs:f,...m,...h})]})})});var ek=(0,i.forwardRef)((e,t)=>{return(0,a.jsx)(w.Z,{children:({width:n,height:r})=>(0,a.jsx)(eZ,{ref:t,width:n,height:r,...e})})});var eT=n(46055);var eA=n(11535);var eB=n(89362);var eM=n(52582);var eI=n(5291);var eR=n(57651);var eE=n(18535);const eD=e=>(0,a.jsxs)("svg",{...e,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",style:{color:"inherit",...e.style},children:[(0,a.jsx)("path",{d:"M12 13.584a2.643 2.643 0 0 1-1.875-.775L.584 3.268a1.768 1.768 0 0 1 2.5-2.5l8.739 8.739a.25.25 0 0 0 .354 0L20.916.768a1.768 1.768 0 0 1 2.5 2.5l-9.541 9.541a2.643 2.643 0 0 1-1.875.775Z",fill:"currentColor"}),(0,a.jsx)("path",{d:"M12 23.75a2.643 2.643 0 0 1-1.875-.775L.584 13.434a1.768 1.768 0 0 1 2.5-2.5l8.739 8.739a.25.25 0 0 0 .354 0l8.739-8.739a1.768 1.768 0 0 1 2.5 2.5l-9.541 9.541A2.643 2.643 0 0 1 12 23.75Z",fill:"currentColor"})]});var eP=eD;const eW=e=>(0,a.jsxs)("svg",{...e,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",style:{color:"inherit",...e.style},children:[(0,a.jsx)("path",{d:"M12 10.416a2.643 2.643 0 0 1 1.875.775l9.541 9.541a1.768 1.768 0 0 1-2.5 2.5l-8.739-8.739a.25.25 0 0 0-.354 0l-8.739 8.739a1.768 1.768 0 0 1-2.5-2.5l9.541-9.541A2.643 2.643 0 0 1 12 10.416Z",fill:"currentColor"}),(0,a.jsx)("path",{d:"M12 .25a2.643 2.643 0 0 1 1.875.775l9.541 9.541a1.768 1.768 0 0 1-2.5 2.5l-8.739-8.739a.25.25 0 0 0-.354 0l-8.739 8.739a1.768 1.768 0 0 1-2.5-2.5l9.541-9.541A2.643 2.643 0 0 1 12 .25Z",fill:"currentColor"})]});var eL=eW;var eN=n(30715);function eF({style:e,contentStyle:t,children:n,renderContent:r,disabled:o}){let[s,l]=(0,i.useState)(false);const c=(0,i.useCallback)(()=>{if(!o){l(true)}},[o]);const d=(0,i.useCallback)(()=>{if(!o){l(false)}},[o]);(0,i.useEffect)(()=>{if(o&&s){l(false)}},[o,s]);return(0,a.jsxs)(y.Z,{style:e,children:[(0,a.jsx)(y.Z,{onMouseEnter:c,onMouseLeave:d,style:t,children:n}),s&&r()]})}var e_=n(84196);var eH=n(16853);let eG=(0,i.createContext)(null);function eO({summaryCollapsed:e,onBudgetAction:t,onToggleSummaryCollapse:n,children:r}){let o=h.dK();return(0,a.jsx)(eG.Provider,{value:{currentMonth:o,summaryCollapsed:e,onBudgetAction:t,onToggleSummaryCollapse:n},children:r})}function ez(){return(0,i.useContext)(eG)};function eU({style:e,progress:t,color:n,backgroundColor:r}){let o=4;let i=2*Math.PI*o;let s=t*i;let l=i;return(0,a.jsxs)("svg",{viewBox:"0 0 20 20",style:e,children:[(0,a.jsx)("circle",{r:"10",cx:"10",cy:"10",fill:r}),(0,a.jsx)("circle",{r:o,cx:"10",cy:"10",fill:"none",stroke:n,strokeWidth:o*2,strokeDasharray:`${s} ${l}`,transform:"rotate(-90) translate(-20)"})," "]})}function eK(e,t){if(t===0){if(e>0){return 1}return 0}return e/t}function e$({current:e,target:t}){let n=(0,eR.Z)(e)||0;let r=(0,eR.Z)(t)||0;let o=false;if(n<0){o=true;n=-n}let i=eK(n,r);return(0,a.jsx)(eU,{progress:i,color:o?m.rS.errorText:m.rS.noticeTextLight,backgroundColor:o?m.rS.errorBackground:m.rS.pageBackground,style:{width:20,height:20}})}function eQ({current:e,target:t}){let n=(0,eR.Z)(e)||0;let r=(0,eR.Z)(t)||0;n=Math.max(-n,0);let o;let i=false;if(n>r){o=(n-r)/r;i=true}else{o=eK(n,r)}return(0,a.jsx)(eU,{progress:o,color:i?m.rS.errorText:m.rS.noticeTextLight,backgroundColor:i?m.rS.errorBackground:m.rS.pageBackground,style:{width:20,height:20}})}function eV({title:e,current:t,target:n,ProgressComponent:r,style:o}){return(0,a.jsxs)(y.Z,{style:{lineHeight:1.5,flexDirection:"row",alignItems:"center",fontSize:14,...o},children:[(0,a.jsx)(r,{current:t,target:n}),(0,a.jsxs)(y.Z,{style:{marginLeft:10},children:[(0,a.jsx)(y.Z,{children:(0,a.jsx)(V.Z,{style:{color:m.rS.pageTextLight},children:e})}),(0,a.jsxs)(V.Z,{children:[(0,a.jsx)(eM.Z,{binding:t,type:"financial"}),(0,a.jsxs)(V.Z,{style:{color:m.rS.pageTextSubdued,fontStyle:"italic"},children:[" of ",(0,a.jsx)(eM.Z,{binding:n,type:"financial",style:m.W2.notFixed})]})]})]})]})}function eq({style:e}){return(0,a.jsx)(eV,{title:"Income",current:eT.u8.totalIncome,target:eT.u8.totalBudgetedIncome,ProgressComponent:e$,style:e})}function eX({style:e}){return(0,a.jsx)(eV,{title:"Expenses",current:eT.u8.totalSpent,target:eT.u8.totalBudgetedExpense,ProgressComponent:eQ,style:e})}function eY({projected:e,style:t}){let n=(0,eR.Z)(eT.u8.totalBudgetedSaved)||0;let r=(0,eR.Z)(eT.u8.totalSaved)||0;let o=(0,eI.Z)();let i=e?n:r;let s=i<0;return(0,a.jsxs)(y.Z,{style:{alignItems:"center",fontSize:14,...t},children:[e?(0,a.jsx)(V.Z,{style:{color:m.rS.pageTextLight},children:"Projected Savings:"}):(0,a.jsx)(y.Z,{style:{color:m.rS.pageTextLight},children:s?"Overspent:":"Saved:"}),(0,a.jsx)(eF,{renderContent:()=>{if(!e){let e=r-n;return(0,a.jsxs)(T.u,{position:"bottom-center",style:{padding:10,fontSize:14},children:[(0,a.jsx)(eN.Z,{left:"Projected Savings:",right:(0,a.jsx)(V.Z,{style:{...(0,C.XE)(n),...m.W2.tnum},children:o(n,"financial-with-sign")})}),(0,a.jsx)(eN.Z,{left:"Difference:",right:(0,a.jsx)(V.Z,{style:{...(0,C.XE)(e),...m.W2.tnum},children:o(e,"financial-with-sign")})})]})}return null},children:(0,a.jsx)(y.Z,{className:`${(0,_.iv)([{fontSize:25,color:e?m.rS.alt2WarningText:s?m.rS.errorTextDark:m.rS.altUpcomingText}])}`,children:(0,a.jsx)(eH.ZP,{blurIntensity:7,children:o(i,"financial")})})})]})}function eJ({month:e}){let{currentMonth:t,summaryCollapsed:n,onBudgetAction:r,onToggleSummaryCollapse:o}=ez();const s=(0,f.Z)("goalTemplatesEnabled");let[l,c]=(0,i.useState)(false);function d(){c(true)}function u(){c(false)}let p=n?eP:eL;return(0,a.jsx)(y.Z,{style:{backgroundColor:m.rS.tableBackground,boxShadow:m.W2.cardShadow,borderRadius:6,marginLeft:0,marginRight:0,marginTop:5,flex:1,cursor:"default",marginBottom:5,overflow:"hidden","& .hover-visible":{opacity:0,transition:"opacity .25s"},"&:hover .hover-visible":{opacity:1}},children:(0,a.jsxs)(M.Z.Provider,{value:h.cv(e),children:[(0,a.jsxs)(y.Z,{style:{padding:"0 13px",...n?{margin:"10px 0"}:{marginTop:16}},children:[(0,a.jsx)(y.Z,{style:{position:"absolute",left:10,top:0},children:(0,a.jsx)(L.Z,{type:"bare",className:"hover-visible",onClick:o,children:(0,a.jsx)(p,{width:13,height:13,style:{color:m.rS.pageTextSubdued,margin:1}})})}),(0,a.jsx)("div",{className:`${(0,_.iv)([{textAlign:"center",marginTop:3,fontSize:18,fontWeight:500,textDecorationSkip:"ink"}])}`,children:h.WU(e,"MMMM")}),(0,a.jsxs)(y.Z,{style:{position:"absolute",right:10,top:0,flexDirection:"row",alignItems:"center"},children:[(0,a.jsx)(y.Z,{children:(0,a.jsx)(J,{id:`budget-${e}`,width:15,height:15,tooltipPosition:"bottom-right",defaultColor:m.rS.pageTextSubdued})}),(0,a.jsxs)(y.Z,{style:{userSelect:"none"},children:[(0,a.jsx)(L.Z,{type:"bare",onClick:d,children:(0,a.jsx)(ev.Z,{width:15,height:15,style:{color:m.rS.pageTextLight}})}),l&&(0,a.jsx)(T.u,{position:"bottom-right",width:200,style:{padding:0},onClose:u,children:(0,a.jsx)(N.Z,{onMenuSelect:t=>{u();r(e,t)},items:[{name:"copy-last",text:"Copy last month’s budget"},{name:"set-zero",text:"Set budgets to zero"},{name:"set-3-avg",text:"Set budgets to 3 month average"},s&&{name:"check-templates",text:"Check templates"},s&&{name:"apply-goal-template",text:"Apply budget template"},s&&{name:"overwrite-goal-template",text:"Overwrite with budget template"}]})})]})]})]}),!n&&(0,a.jsxs)(e_.Z,{spacing:2,style:{alignSelf:"center",backgroundColor:m.rS.tableRowHeaderBackground,borderRadius:4,padding:"10px 15px",marginTop:13},children:[(0,a.jsx)(eq,{}),(0,a.jsx)(eX,{})]}),n?(0,a.jsx)(y.Z,{style:{alignItems:"center",padding:"10px 20px",justifyContent:"space-between",backgroundColor:m.rS.tableRowHeaderBackground,borderTop:"1px solid "+m.rS.tableBorder},children:(0,a.jsx)(eY,{projected:e>=t})}):(0,a.jsx)(eY,{projected:e>=t,style:{marginTop:13,marginBottom:20}})]})})};let e0={flex:1,padding:"0 5px",textAlign:"right"};const e1=(0,i.memo)(function e(){const e=(0,eI.Z)();return(0,a.jsxs)(y.Z,{style:{flex:1,flexDirection:"row",marginRight:m.W2.monthRightPadding,paddingTop:10,paddingBottom:10},children:[(0,a.jsxs)(y.Z,{style:e0,children:[(0,a.jsx)(V.Z,{style:{color:m.rS.pageTextLight},children:"Budgeted"}),(0,a.jsx)(eM.Z,{binding:eT.u8.totalBudgetedExpense,type:"financial",style:{color:m.rS.pageTextLight,fontWeight:600},formatter:t=>{return e(parseFloat(t||"0"),"financial")}})]}),(0,a.jsxs)(y.Z,{style:e0,children:[(0,a.jsx)(V.Z,{style:{color:m.rS.pageTextLight},children:"Spent"}),(0,a.jsx)(eM.Z,{binding:eT.u8.totalSpent,type:"financial",style:{color:m.rS.pageTextLight,fontWeight:600}})]}),(0,a.jsxs)(y.Z,{style:e0,children:[(0,a.jsx)(V.Z,{style:{color:m.rS.pageTextLight},children:"Balance"}),(0,a.jsx)(eM.Z,{binding:eT.u8.totalLeftover,type:"financial",style:{color:m.rS.pageTextLight,fontWeight:600}})]})]})});function e2(){return(0,a.jsxs)(y.Z,{style:{flexDirection:"row",marginRight:m.W2.monthRightPadding,paddingBottom:5},children:[(0,a.jsx)(y.Z,{style:e0,children:(0,a.jsx)(V.Z,{style:{color:m.rS.pageTextLight},children:"Budgeted"})}),(0,a.jsx)(y.Z,{style:e0,children:(0,a.jsx)(V.Z,{style:{color:m.rS.pageTextLight},children:"Received"})})]})}const e5=(0,i.memo)(function e({group:e}){let{id:t}=e;return(0,a.jsxs)(y.Z,{style:{flex:1,flexDirection:"row"},children:[(0,a.jsx)(B.OX,{name:"budgeted",width:"flex",textAlign:"right",style:{fontWeight:600,...m.W2.tnum},valueProps:{binding:eT.u8.groupBudgeted(t),type:"financial"}}),(0,a.jsx)(B.OX,{name:"spent",width:"flex",textAlign:"right",style:{fontWeight:600,...m.W2.tnum},valueProps:{binding:eT.u8.groupSumAmount(t),type:"financial"}}),!e.is_income&&(0,a.jsx)(B.OX,{name:"balance",width:"flex",textAlign:"right",style:{fontWeight:600,paddingRight:m.W2.monthRightPadding,...m.W2.tnum},valueProps:{binding:eT.u8.groupBalance(t),type:"financial",privacyFilter:{style:{paddingRight:m.W2.monthRightPadding}}}})]})});function e4({categoryId:e,tooltip:t,monthIndex:n,onBudgetAction:r}){let o=(0,eR.Z)(eT.u8.catCarryover(e));return(0,a.jsx)(T.u,{position:"bottom-right",width:200,style:{padding:0},onClose:t.close,children:(0,a.jsx)(N.Z,{onMenuSelect:a=>{r(n,"carryover",{category:e,flag:!o});t.close()},items:[{name:"carryover",text:o?"Remove overspending rollover":"Rollover overspending"}]})})}const e8=(0,i.memo)(function e({monthIndex:e,category:t,editing:n,onEdit:r,onBudgetAction:o,onShowActivity:s}){let l=(0,T.lL)();const[c,d]=(0,i.useState)(false);const[u,h]=(0,i.useState)(false);const p=(0,f.Z)("goalTemplatesEnabled");return(0,a.jsxs)(y.Z,{style:{flex:1,flexDirection:"row","& .hover-visible":{opacity:0,transition:"opacity .25s"},"&:hover .hover-visible":{opacity:1}},children:[(0,a.jsxs)(y.Z,{style:{flex:1,flexDirection:"row"},onMouseOverCapture:()=>h(true),onMouseLeave:()=>{h(false)},children:[!n&&(u||c)&&(0,a.jsxs)(y.Z,{style:{flexShrink:0,marginRight:0,marginLeft:3,justifyContent:"center"},children:[(0,a.jsx)(L.Z,{type:"bare",onClick:e=>{e.stopPropagation();d(true)},style:{padding:3},children:(0,a.jsx)(W.Z,{width:14,height:14,className:"hover-visible",style:c&&{opacity:1}})}),c&&(0,a.jsx)(T.u,{position:"bottom-left",width:200,style:{padding:0},onClose:()=>d(false),children:(0,a.jsx)(N.Z,{onMenuSelect:n=>{o(e,n,{category:t.id});d(false)},items:[{name:"copy-single-last",text:"Copy last month’s budget"},{name:"set-single-3-avg",text:"Set to 3 month average"},{name:"set-single-6-avg",text:"Set to 6 month average"},{name:"set-single-12-avg",text:"Set to yearly average"},p&&{name:"apply-single-category-template",text:"Apply budget template"}]})})]}),(0,a.jsx)(B.OX,{name:"budget",exposed:n,focused:n,width:"flex",onExpose:()=>r(t.id,e),style:{...n&&{zIndex:100},...m.W2.tnum},textAlign:"right",valueStyle:{cursor:"default",margin:1,padding:"0 4px",borderRadius:4,":hover":{boxShadow:"inset 0 0 0 1px "+m.rS.mobileAccountShadow,backgroundColor:m.rS.tableBackground}},valueProps:{binding:eT.u8.catBudgeted(t.id),type:"financial",getValueStyle:C.hd,formatExpr:e=>{return(0,eB.zA)(e)},unformatExpr:e=>{return(0,eB.l9)((0,eA.Z)(e,0))}},inputProps:{onBlur:()=>{r(null)},style:{backgroundColor:"white"}},onSave:n=>{o(e,"budget-amount",{category:t.id,amount:n})}})]}),(0,a.jsx)(B.gN,{name:"spent",width:"flex",style:{textAlign:"right"},children:(0,a.jsx)("span",{"data-testid":"category-month-spent",onClick:()=>s(t.name,t.id,e),children:(0,a.jsx)(eM.Z,{binding:eT.u8.catSumAmount(t.id),type:"financial",getStyle:C.hd,style:{cursor:"pointer",":hover":{textDecoration:"underline"}}})})}),!t.is_income&&(0,a.jsxs)(B.gN,{name:"balance",truncate:false,width:"flex",style:{paddingRight:m.W2.monthRightPadding,textAlign:"right"},children:[(0,a.jsx)("span",{...t.is_income?{}:l.getOpenEvents(),children:(0,a.jsx)(eE.Z,{disabled:t.is_income,carryover:eT.u8.catCarryover(t.id),balance:eT.u8.catBalance(t.id)})}),l.isOpen&&(0,a.jsx)(e4,{categoryId:t.id,tooltip:l,monthIndex:e,onBudgetAction:o})]})]})});const e3=e5;const e6=e8;const e7=e5;const e9=e8;var te=n(94477);var tt=n(24924);var tn=n(50606);var tr=n(91871);var to=n(383);function ta({onSubmit:e,onClose:t}){const n=(0,c.M)();const r=(0,i.useContext)(M.Z);const[o,s]=(0,i.useState)(null);(0,i.useEffect)(()=>{(async()=>{const e=await n.get(r,"to-budget");s((0,eB.zA)(Math.max(e.value,0)))})()},[]);function l(){const n=(0,eA.Z)(o,null);if(n){e((0,eB.l9)(n))}t()}if(o===null){return null}return(0,a.jsxs)(T.u,{position:"bottom-right",width:200,style:{padding:10},onClose:t,children:[(0,a.jsx)(y.Z,{style:{marginBottom:5},children:"Hold this amount:"}),(0,a.jsx)(y.Z,{children:(0,a.jsx)(tr.Z,{children:(0,a.jsx)(to.ZP,{value:o,onChange:e=>s(e.target.value),onEnter:l})})}),(0,a.jsx)(y.Z,{style:{alignItems:"flex-end",marginTop:10},children:(0,a.jsx)(L.Z,{type:"primary",style:{fontSize:12,paddingTop:3,paddingBottom:3},onClick:l,children:"Hold"})})]})};let ti=(0,i.createContext)(null);function ts({categoryGroups:e,summaryCollapsed:t,onBudgetAction:n,onToggleSummaryCollapse:r,children:o}){let i=h.dK();return(0,a.jsx)(ti.Provider,{value:{currentMonth:i,categoryGroups:e,summaryCollapsed:t,onBudgetAction:n,onToggleSummaryCollapse:r},children:o})}function tl(){return(0,i.useContext)(ti)}var tc=n(45990);function td({prevMonthName:e,collapsed:t}){const n=(0,eI.Z)();return(0,a.jsxs)(y.Z,{style:{flexDirection:"row",lineHeight:1.5,justifyContent:"center",...!t&&{padding:"5px 0",marginTop:17,backgroundColor:m.rS.tableRowHeaderBackground,borderTopWidth:1,borderBottomWidth:1,borderColor:m.rS.tableBorder},...t&&{padding:7},...m.W2.smallText},children:[(0,a.jsxs)(y.Z,{style:{textAlign:"right",marginRight:10,minWidth:50},children:[(0,a.jsx)(eF,{style:{flexShrink:0},renderContent:()=>(0,a.jsxs)(T.u,{width:200,style:{lineHeight:1.5,padding:"6px 10px"},children:[(0,a.jsx)(eN.Z,{left:"Income:",right:(0,a.jsx)(eM.Z,{binding:eT.aK.totalIncome,type:"financial",privacyFilter:false})}),(0,a.jsx)(eN.Z,{left:"From Last Month:",right:(0,a.jsx)(eM.Z,{binding:eT.aK.fromLastMonth,type:"financial",privacyFilter:false})})]}),children:(0,a.jsx)(eM.Z,{binding:eT.aK.incomeAvailable,type:"financial",style:{fontWeight:600}})}),(0,a.jsx)(eM.Z,{binding:eT.aK.lastMonthOverspent,type:"financial",formatter:e=>{let t=n(e,"financial");return e>0?"+"+t:e===0?"-"+t:t},style:{fontWeight:600,...m.W2.tnum}}),(0,a.jsx)(eM.Z,{binding:eT.aK.totalBudgeted,type:"financial",formatter:e=>{let t=n(e,"financial");return e>0?"+"+t:e===0?"-"+t:t},style:{fontWeight:600,...m.W2.tnum}}),(0,a.jsx)(eM.Z,{binding:eT.aK.forNextMonth,type:"financial",formatter:e=>{let t=parseInt(e)||0;let r=n(Math.abs(t),"financial");return t>=0?"-"+r:"+"+r},style:{fontWeight:600,...m.W2.tnum}})]}),(0,a.jsxs)(y.Z,{children:[(0,a.jsx)(tt.Z,{children:"Available Funds"}),(0,a.jsxs)(tt.Z,{children:["Overspent in ",e]}),(0,a.jsx)(tt.Z,{children:"Budgeted"}),(0,a.jsx)(tt.Z,{children:"For Next Month"})]})]})}function tu({month:e,prevMonthName:t,collapsed:n,onBudgetAction:r}){let[o,s]=(0,i.useState)(null);let l=(0,tn.Z)(eT.aK.toBudget);let c=(0,eR.Z)({name:eT.aK.toBudget,value:0});let d=(0,eI.Z)();let u=parseInt(c);let h=isNaN(u)?0:u;let p=h<0;return(0,a.jsxs)(y.Z,{style:{alignItems:"center"},children:[(0,a.jsx)(tt.Z,{children:p?"Overbudgeted:":"To Budget:"}),(0,a.jsxs)(y.Z,{children:[(0,a.jsx)(eF,{disabled:!n||o,renderContent:()=>(0,a.jsx)(T.u,{position:"bottom-center",children:(0,a.jsx)(td,{collapsed:true,prevMonthName:t})}),children:(0,a.jsx)(eH.ZP,{blurIntensity:7,children:(0,a.jsx)(tt.Z,{onClick:()=>s("actions"),"data-cellname":l,className:`${(0,_.iv)([m.W2.veryLargeText,{fontWeight:400,userSelect:"none",cursor:"pointer",color:p?m.rS.errorText:m.rS.pageTextPositive,marginBottom:-1,borderBottom:"1px solid transparent",":hover":{borderColor:p?m.rS.errorBorder:m.rS.pageTextPositive}}])}`,children:d(h,"financial")})})}),o==="actions"&&(0,a.jsx)(T.u,{position:"bottom-center",width:200,style:{padding:0},onClose:()=>s(null),children:(0,a.jsx)(N.Z,{onMenuSelect:t=>{if(t==="reset-buffer"){r(e,"reset-hold");s(null)}else{s(t)}},items:[{name:"transfer",text:"Move to a category"},{name:"buffer",text:"Hold for next month"},{name:"reset-buffer",text:"Reset next month’s buffer"}]})}),o==="buffer"&&(0,a.jsx)(ta,{onClose:()=>s(null),onSubmit:t=>{r(e,"hold",{amount:t})}}),o==="transfer"&&(0,a.jsx)(tc.Z,{initialAmount:u,onClose:()=>s(null),onSubmit:(t,n)=>{r(e,"transfer-available",{amount:t,category:n})}})]})]})}function th({month:e,isGoalTemplatesEnabled:t}){let{currentMonth:n,summaryCollapsed:r,onBudgetAction:o,onToggleSummaryCollapse:s}=tl();let[l,c]=(0,i.useState)(false);function d(e){c(true)}function u(){c(false)}let p=h.WU(h.dy(e),"MMM");let g=r?eP:eL;return(0,a.jsx)(y.Z,{"data-testid":"budget-summary",style:{backgroundColor:m.rS.tableBackground,boxShadow:m.W2.cardShadow,borderRadius:6,marginLeft:0,marginRight:0,marginTop:5,flex:1,cursor:"default",marginBottom:5,overflow:"hidden","& .hover-visible":{opacity:0,transition:"opacity .25s"},"&:hover .hover-visible":{opacity:1}},children:(0,a.jsxs)(M.Z.Provider,{value:h.cv(e),children:[(0,a.jsxs)(y.Z,{style:{padding:"0 13px",...r?{margin:"10px 0"}:{marginTop:16}},children:[(0,a.jsx)(y.Z,{style:{position:"absolute",left:10,top:0},children:(0,a.jsx)(L.Z,{type:"bare",className:"hover-visible",onClick:s,children:(0,a.jsx)(g,{width:13,height:13,style:{color:m.rS.altTableText,margin:1}})})}),(0,a.jsx)("div",{className:`${(0,_.iv)([{textAlign:"center",marginTop:3,fontSize:18,fontWeight:500,textDecorationSkip:"ink"},n===e&&{fontWeight:"bold"}])}`,children:h.WU(e,"MMMM")}),(0,a.jsxs)(y.Z,{style:{position:"absolute",right:10,top:0,flexDirection:"row",alignItems:"center"},children:[(0,a.jsx)(y.Z,{children:(0,a.jsx)(J,{id:`budget-${e}`,width:15,height:15,tooltipPosition:"bottom-right",defaultColor:m.rS.altTableText})}),(0,a.jsxs)(y.Z,{style:{userSelect:"none",marginLeft:2},children:[(0,a.jsx)(L.Z,{type:"bare",onClick:d,children:(0,a.jsx)(ev.Z,{width:15,height:15,style:{color:m.rS.alt2PillText}})}),l&&(0,a.jsx)(T.u,{position:"bottom-right",width:200,style:{padding:0},onClose:u,children:(0,a.jsx)(N.Z,{onMenuSelect:t=>{u();o(e,t)},items:[{name:"copy-last",text:"Copy last month’s budget"},{name:"set-zero",text:"Set budgets to zero"},{name:"set-3-avg",text:"Set budgets to 3 month average"},t&&{name:"check-templates",text:"Check templates"},t&&{name:"apply-goal-template",text:"Apply budget template"},t&&{name:"overwrite-goal-template",text:"Overwrite with budget template"},t&&{name:"cleanup-goal-template",text:"End of month cleanup"}]})})]})]})]}),r?(0,a.jsx)(y.Z,{style:{alignItems:"center",padding:"10px 20px",justifyContent:"space-between",backgroundColor:m.rS.tableHeaderBackground,borderTop:"1px solid "+m.rS.tableBorder},children:(0,a.jsx)(tu,{collapsed:r,prevMonthName:p,month:e,onBudgetAction:o})}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(td,{prevMonthName:p}),(0,a.jsx)(y.Z,{style:{margin:"23px 0"},children:(0,a.jsx)(tu,{month:e,onBudgetAction:o})})]})]})})};let tp={flex:1,padding:"0 5px",textAlign:"right"};const tg=(0,i.memo)(function e(){const e=(0,eI.Z)();return(0,a.jsxs)(y.Z,{style:{flex:1,flexDirection:"row",marginRight:m.W2.monthRightPadding,paddingTop:10,paddingBottom:10},children:[(0,a.jsxs)(y.Z,{style:tp,children:[(0,a.jsx)(V.Z,{style:{color:m.rS.alt2TableText},children:"Budgeted"}),(0,a.jsx)(eM.Z,{binding:eT.aK.totalBudgeted,type:"financial",style:{color:m.rS.alt2TableText,fontWeight:600},formatter:t=>{return e(-parseFloat(t||"0"),"financial")}})]}),(0,a.jsxs)(y.Z,{style:tp,children:[(0,a.jsx)(V.Z,{style:{color:m.rS.alt2TableText},children:"Spent"}),(0,a.jsx)(eM.Z,{binding:eT.aK.totalSpent,type:"financial",style:{color:m.rS.alt2TableText,fontWeight:600}})]}),(0,a.jsxs)(y.Z,{style:tp,children:[(0,a.jsx)(V.Z,{style:{color:m.rS.alt2TableText},children:"Balance"}),(0,a.jsx)(eM.Z,{binding:eT.aK.totalBalance,type:"financial",style:{color:m.rS.alt2TableText,fontWeight:600}})]})]})});function tf(){return(0,a.jsx)(B.X2,{style:{color:m.rS.alt2TableText,alignItems:"center",paddingRight:10},children:(0,a.jsx)(y.Z,{style:{flex:1,textAlign:"right"},children:"Received"})})}const tx=(0,i.memo)(function e({group:e}){let{id:t}=e;return(0,a.jsxs)(y.Z,{style:{flex:1,flexDirection:"row"},children:[(0,a.jsx)(B.OX,{name:"budgeted",width:"flex",textAlign:"right",style:{fontWeight:600,...m.W2.tnum},valueProps:{binding:eT.aK.groupBudgeted(t),type:"financial"}}),(0,a.jsx)(B.OX,{name:"spent",width:"flex",textAlign:"right",style:{fontWeight:600,...m.W2.tnum},valueProps:{binding:eT.aK.groupSumAmount(t),type:"financial"}}),(0,a.jsx)(B.OX,{name:"balance",width:"flex",textAlign:"right",style:{fontWeight:600,paddingRight:m.W2.monthRightPadding,...m.W2.tnum},valueProps:{binding:eT.aK.groupBalance(t),type:"financial",privacyFilter:{style:{paddingRight:m.W2.monthRightPadding}}}})]})});const tm=(0,i.memo)(function e({monthIndex:e,category:t,editing:n,onEdit:r,onBudgetAction:o,onShowActivity:s}){let l=(0,T.lL)();const[c,d]=(0,i.useState)(false);const[u,h]=(0,i.useState)(false);const p=(0,f.Z)("goalTemplatesEnabled");return(0,a.jsxs)(y.Z,{style:{flex:1,flexDirection:"row","& .hover-visible":{opacity:0,transition:"opacity .25s"},"&:hover .hover-visible":{opacity:1}},children:[(0,a.jsxs)(y.Z,{style:{flex:1,flexDirection:"row"},onMouseOverCapture:()=>h(true),onMouseLeave:()=>{h(false)},children:[!n&&(u||c)?(0,a.jsxs)(y.Z,{style:{flexShrink:1,paddingLeft:3,justifyContent:"center",borderTopWidth:1,borderColor:m.rS.tableBorder},children:[(0,a.jsx)(L.Z,{type:"bare",onClick:e=>{e.stopPropagation();d(true)},style:{padding:3},children:(0,a.jsx)(W.Z,{width:14,height:14,className:"hover-visible",style:c&&{opacity:1}})}),c&&(0,a.jsx)(T.u,{position:"bottom-left",width:200,style:{padding:0},onClose:()=>d(false),children:(0,a.jsx)(N.Z,{onMenuSelect:n=>{o(e,n,{category:t.id});d(false)},items:[{name:"copy-single-last",text:"Copy last month’s budget"},{name:"set-single-3-avg",text:"Set to 3 month average"},{name:"set-single-6-avg",text:"Set to 6 month average"},{name:"set-single-12-avg",text:"Set to yearly average"},p&&{name:"apply-single-category-template",text:"Apply budget template"}]})})]}):null,(0,a.jsx)(B.OX,{name:"budget",exposed:n,focused:n,width:"flex",onExpose:()=>r(t.id,e),style:{...n&&{zIndex:100},...m.W2.tnum},textAlign:"right",valueStyle:{cursor:"default",margin:1,padding:"0 4px",borderRadius:4,":hover":{boxShadow:"inset 0 0 0 1px "+m.rS.mobileAccountShadow,backgroundColor:"white"}},valueProps:{binding:eT.aK.catBudgeted(t.id),type:"financial",getValueStyle:C.hd,formatExpr:e=>{return(0,eB.zA)(e)},unformatExpr:e=>{return(0,eB.l9)((0,eA.Z)(e,0))}},inputProps:{onBlur:()=>{r(null)},style:{backgroundColor:"white"}},onSave:n=>{o(e,"budget-amount",{category:t.id,amount:n})}})]}),(0,a.jsx)(B.gN,{name:"spent",width:"flex",style:{textAlign:"right"},children:(0,a.jsx)("span",{"data-testid":"category-month-spent",onClick:()=>s(t.name,t.id,e),children:(0,a.jsx)(eM.Z,{binding:eT.aK.catSumAmount(t.id),type:"financial",getStyle:C.hd,style:{cursor:"pointer",":hover":{textDecoration:"underline"}}})})}),(0,a.jsxs)(B.gN,{name:"balance",truncate:false,width:"flex",style:{paddingRight:m.W2.monthRightPadding,textAlign:"right"},children:[(0,a.jsx)("span",{...l.getOpenEvents(),children:(0,a.jsx)(eE.Z,{carryover:eT.aK.catCarryover(t.id),balance:eT.aK.catBalance(t.id)})}),l.isOpen&&(0,a.jsx)(te.Z,{categoryId:t.id,tooltip:l,monthIndex:e,onBudgetAction:o})]})]})});function ty(){return(0,a.jsx)(y.Z,{style:{flex:1},children:(0,a.jsx)(B.OX,{name:"received",width:"flex",textAlign:"right",style:{fontWeight:600,paddingRight:m.W2.monthRightPadding,...m.W2.tnum},valueProps:{binding:eT.aK.groupIncomeReceived,type:"financial",privacyFilter:{style:{paddingRight:m.W2.monthRightPadding}}}})})}function tv({category:e,isLast:t,monthIndex:n,onShowActivity:r}){return(0,a.jsx)(y.Z,{style:{flex:1},children:(0,a.jsx)(B.gN,{name:"received",width:"flex",style:{paddingRight:m.W2.monthRightPadding,textAlign:"right",...t&&{borderBottomWidth:0}},children:(0,a.jsx)("span",{onClick:()=>r(e.name,e.id,n),children:(0,a.jsx)(eM.Z,{binding:eT.aK.catSumAmount(e.id),type:"financial",style:{cursor:"pointer",":hover":{textDecoration:"underline"}}})})})})};function tw(e){const t=h.dK();const n=(0,i.useRef)(null);const[r,o]=(0,i.useState)(false);const[s,l]=(0,i.useState)(e.startMonth||t);const[c,p]=(0,i.useState)(null);const[g,f]=(0,i.useState)(false);const[x,m]=(0,i.useState)(e.collapsedPrefs||[]);const[v,w]=(0,i.useState)({start:t,end:t});const[b,S]=(0,i.useState)(null);const[j,C]=(0,i.useState)(e.summaryCollapsed);async function Z(){let t=await e.getCategories();S(t.grouped)}(0,i.useEffect)(()=>{let{titlebar:t,budgetType:r}=e;async function o(){Z();let{start:e,end:t}=await (0,d.lW)("get-budget-bounds");w({start:e,end:t});T({start:e,end:t},r)}o();let a=[(0,d.oL)("sync-event",({type:e,tables:t})=>{if(e==="success"&&(t.includes("categories")||t.includes("category_mapping")||t.includes("category_groups"))){Z()}}),(0,d.oL)("undo-event",({tables:e})=>{if(n.current){n.current.clearEditing()}if(e.includes("categories")){Z()}}),t.subscribe(O)];return()=>{a.forEach(e=>e())}},[]);(0,i.useEffect)(()=>{e.savePrefs({"budget.collapsed":x})},[x]);(0,i.useEffect)(()=>{(0,d.lW)("get-budget-bounds").then(({start:e,end:t})=>{if(v.start!==e||v.end!==t){w({start:e,end:t})}})},[e.accountId]);const k=async(t,n=null)=>{n=n||e.budgetType;let r=n==="report"?"report-budget-month":"rollover-budget-month";let o=await (0,d.lW)(r,{month:t});for(let t of o){e.spreadsheet.prewarmCache(t.name,t)}};async function T(n,r=null){let a=3;const i=e.startMonth||t;n=I(n,h.W9(i,1),h.zI(i,a+1));let s=h.Do(n.start,n.end);await Promise.all(s.map(e=>k(e,r)));o(true)}const A=async(n,r)=>{l(n);const o=n;const a=e.startMonth||t;if(n<a){await k(h.W9(n,1))}else if(n>a){await k(h.zI(n,r))}if(o===n){e.savePrefs({"budget.startMonth":n})}};const B=e=>{p(e);m(t=>t.filter(t=>t!==e))};const M=()=>{p(null)};const R=()=>{f(true)};const E=()=>{f(false)};const D=async t=>{if(t.id==="new"){let n=await e.createCategory(t.name,t.cat_group,t.is_income);p(null);S(e=>(0,u.i8)(e,{...t,is_income:t.is_income?1:0,id:n}))}else{e.updateCategory(t);S(e=>(0,u.yr)(e,t))}};const P=async t=>{const n=await (0,d.lW)("must-category-transfer",{id:t});if(n){e.pushModal("confirm-category-delete",{category:t,onDelete:n=>{if(t!==n){e.deleteCategory(t,n);S(e=>(0,u.uu)(e,t))}}})}else{e.deleteCategory(t);S(e=>(0,u.uu)(e,t))}};const W=async t=>{if(t.id==="new"){let n=await e.createGroup(t.name);f(false);S(e=>(0,u.Rp)(e,{...t,is_income:0,categories:t.categories||[],id:n}))}else{e.updateGroup(t);S(e=>(0,u.mD)(e,t))}};const L=async t=>{let n=b.find(e=>e.id===t);let r=false;for(let e of n.categories){if(await (0,d.lW)("must-category-transfer",{id:e.id})){r=true;break}}if(r){e.pushModal("confirm-category-delete",{group:t,onDelete:n=>{e.deleteGroup(t,n);S(e=>(0,u.iE)(e,t))}})}else{e.deleteGroup(t);S(e=>(0,u.iE)(e,t))}};const N=(t,n,r)=>{e.applyBudgetAction(t,n,r)};const F=(t,n,r)=>{e.navigate("/accounts",{state:{goBack:true,filterName:`${t} (${h.WU(r,"MMMM yyyy")})`,filter:{category:n,date:{$transform:"$month",$eq:r}}}})};const _=async t=>{e.moveCategory(t.id,t.groupId,t.targetId);S(e=>(0,u.Wr)(e,t.id,t.groupId,t.targetId))};const H=async t=>{e.moveCategoryGroup(t.id,t.targetId);S(e=>(0,u.eq)(e,t.id,t.targetId))};const G=()=>{let t=!j;C(t);e.savePrefs({"budget.summaryCollapsed":t})};const O=async t=>{switch(t){case"budget/switch-type":{let t=e.budgetType;let n=t==="rollover"?"report":"rollover";e.spreadsheet.disableObservers();await (0,d.lW)("budget-set-type",{type:n});await T(v,n);e.spreadsheet.enableObservers();e.loadPrefs();break}default:}};let{maxMonths:z,budgetType:U,reportComponents:K,rolloverComponents:$}=e;z=z||1;if(!r||!b){return null}const Q=e.startMonth||t;let V;if(U==="report"){V=(0,a.jsx)(eO,{summaryCollapsed:j,onBudgetAction:N,onToggleSummaryCollapse:G,children:(0,a.jsx)(ek,{ref:n,type:U,categoryGroups:b,prewarmStartMonth:s,startMonth:Q,monthBounds:v,maxMonths:z,collapsed:x,setCollapsed:m,newCategoryForGroup:c,isAddingGroup:g,dataComponents:K,onMonthSelect:A,onShowNewCategory:B,onHideNewCategory:M,onShowNewGroup:R,onHideNewGroup:E,onDeleteCategory:P,onDeleteGroup:L,onSaveCategory:D,onSaveGroup:W,onBudgetAction:N,onShowActivity:F,onReorderCategory:_,onReorderGroup:H})})}else{V=(0,a.jsx)(ts,{categoryGroups:b,summaryCollapsed:j,onBudgetAction:N,onToggleSummaryCollapse:G,children:(0,a.jsx)(ek,{ref:n,type:U,categoryGroups:b,prewarmStartMonth:s,startMonth:Q,monthBounds:v,maxMonths:z,collapsed:x,setCollapsed:m,newCategoryForGroup:c,isAddingGroup:g,dataComponents:$,onMonthSelect:A,onShowNewCategory:B,onHideNewCategory:M,onShowNewGroup:R,onHideNewGroup:E,onDeleteCategory:P,onDeleteGroup:L,onSaveCategory:D,onSaveGroup:W,onBudgetAction:N,onShowActivity:F,onReorderCategory:_,onReorderGroup:H})})}return(0,a.jsx)(y.Z,{style:{flex:1},children:V})}const tb=(0,i.memo)(e=>{const t=(0,f.Z)("goalTemplatesEnabled");return(0,a.jsx)(th,{...e,isGoalTemplatesEnabled:t})});function tS(e){let t=(0,s.v9)(e=>e.prefs.local["budget.startMonth"]);let n=(0,s.v9)(e=>e.prefs.local["budget.collapsed"]);let d=(0,s.v9)(e=>e.prefs.local["budget.summaryCollapsed"]);let u=(0,s.v9)(e=>e.prefs.local.budgetType||"rollover");let h=(0,s.v9)(e=>e.prefs.global.maxMonths);let{grouped:f}=(0,g.Z)();let w=(0,p.o)();let b=(0,c.M)();let S=(0,i.useContext)(v.CR);let j=(0,l.TH)();let C=(0,l.bS)(j.pathname);let Z=(0,x.Z)();let k=(0,i.useMemo)(()=>({SummaryComponent:eJ,ExpenseCategoryComponent:e6,ExpenseGroupComponent:e3,IncomeCategoryComponent:e9,IncomeGroupComponent:e7,BudgetTotalsComponent:e1,IncomeHeaderComponent:e2}),[r]);let T=(0,i.useMemo)(()=>({SummaryComponent:tb,ExpenseCategoryComponent:tm,ExpenseGroupComponent:tx,IncomeCategoryComponent:tv,IncomeGroupComponent:ty,BudgetTotalsComponent:tg,IncomeHeaderComponent:tf}),[o]);return(0,a.jsx)(y.Z,{style:{...m.W2.page,paddingLeft:8,paddingRight:8,overflow:"hidden"},children:(0,a.jsx)(tw,{startMonth:t,collapsedPrefs:n,summaryCollapsed:d,budgetType:u,maxMonths:h,categoryGroups:f,...w,reportComponents:k,rolloverComponents:T,spreadsheet:b,titlebar:S,navigate:Z,match:C})})}var tj=n(62829);var tC=n(24198);var tZ=n(13308);var tk=n(77420);function tT(){const{pushModal:e}=(0,p.o)();const[t,n]=(0,i.useState)("");const r=(0,tj.gZ)();if(r==null){return null}const{schedules:o,statuses:s}=r;function l(t){e("schedule-edit",{id:t})}function c(){e("schedule-edit")}function u(){e("schedules-discover")}async function h(e,t){switch(e){case"post-transaction":await (0,d.lW)("schedule/post-transaction",{id:t});break;case"skip":await (0,d.lW)("schedule/skip-next-date",{id:t});break;case"complete":await (0,d.lW)("schedule/update",{schedule:{id:t,completed:true}});break;case"restart":await (0,d.lW)("schedule/update",{schedule:{id:t,completed:false},resetNextDate:true});break;case"delete":await (0,d.lW)("schedule/delete",{id:t});break;default:}}return(0,a.jsxs)(tZ.T,{title:"Schedules",children:[(0,a.jsx)(y.Z,{style:{flexDirection:"row",alignItems:"center",padding:"0 0 15px"},children:(0,a.jsx)(y.Z,{style:{flex:1,flexDirection:"row",justifyContent:"flex-end"},children:(0,a.jsx)(tC.Z,{placeholder:"Filter schedules…",value:t,onChange:n})})}),(0,a.jsx)(tk.Pz,{schedules:o,filter:t,statuses:s,allowCompleted:true,onSelect:l,onAction:h,style:{backgroundColor:m.rS.tableBackground}}),(0,a.jsxs)(y.Z,{style:{flexDirection:"row",justifyContent:"space-between",margin:"20px 0",flexShrink:0},children:[(0,a.jsx)(L.Z,{onClick:u,children:"Find schedules"}),(0,a.jsx)(L.Z,{type:"primary",onClick:c,children:"Add new schedule"})]})]})}var tA=n(8987);var tB=n(42994);function tM(){window.close();return(0,a.jsx)(tA.C,{isCurrent:true,showClose:false,title:"Account sync",children:()=>(0,a.jsxs)(y.Z,{style:{maxWidth:500},children:[(0,a.jsx)(tB.Z,{children:"Please wait..."}),(0,a.jsx)(tB.Z,{children:"The window should close automatically. If nothing happened you can close this window or tab."})]})})}var tI=n(82478);var tR=n(65485);var tE=n(43044);var tD=n(17853);var tP=n(11504);var tW=n(76804);var tL=n(18247);var tN=n(11892);var tF=n(25432);var t_=n(41071);var tH=n(79982);var tG=n(18748);var tO=n(15685);var tz=n(69289);const tU=e=>(0,a.jsx)("svg",{...e,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 91 51",style:{color:"inherit",...e.style},children:(0,a.jsx)("path",{fill:"currentColor",d:"M30.256 48.614a3.14 3.14 0 0 0-.989-2.153L10.803 29.063h76.915a3.2 3.2 0 0 0 .315 0c1.584-.084 2.95-1.64 2.867-3.266-.082-1.625-1.598-3.028-3.182-2.943H10.803L29.267 5.49c1.284-1.099 1.456-3.057.385-4.373a2.972 2.972 0 0 0-4.48-.187L.971 23.695a3.163 3.163 0 0 0 0 4.56l24.2 22.766a2.98 2.98 0 0 0 2.205.84c1.669-.08 2.958-1.534 2.88-3.247Z"})});var tK=tU;var t$=n(45219);const tQ=e=>(0,a.jsx)("svg",{...e,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",style:{color:"inherit",...e.style},children:(0,a.jsx)("path",{d:"m9 16.172-6.071-6.071-1.414 1.414L10 20l.707-.707 7.778-7.778-1.414-1.414L11 16.172V0H9z",fill:"currentColor"})});var tV=tQ;const tq=e=>(0,a.jsx)("svg",{...e,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",style:{color:"inherit",...e.style},children:(0,a.jsx)("path",{d:"M9 3.828 2.929 9.899 1.515 8.485 10 0l.707.707 7.778 7.778-1.414 1.414L11 3.828V20H9V3.828z",fill:"currentColor"})});var tX=tq;var tY=n(78393);var tJ=n(48880);const t0=e=>(0,a.jsxs)("svg",{...e,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",style:{color:"inherit",...e.style},children:[(0,a.jsx)("path",{d:"M12.406 14.905a1 1 0 0 0-.543 1.307 1 1 0 0 1-.217 1.09l-2.828 2.829a2 2 0 0 1-2.828 0L3.868 18.01a2 2 0 0 1 0-2.829L6.7 12.353a1.013 1.013 0 0 1 1.091-.217 1 1 0 0 0 .763-1.849 3.034 3.034 0 0 0-3.268.652l-2.832 2.828a4.006 4.006 0 0 0 0 5.657l2.122 2.121a4 4 0 0 0 5.656 0l2.829-2.828a3.008 3.008 0 0 0 .651-3.27 1 1 0 0 0-1.306-.542Z",fill:"currentColor"}),(0,a.jsx)("path",{d:"M7.757 16.241a1.011 1.011 0 0 0 1.414 0l7.779-7.778a1 1 0 0 0-1.414-1.414l-7.779 7.778a1 1 0 0 0 0 1.414Z",fill:"currentColor"}),(0,a.jsx)("path",{d:"m21.546 4.574-2.121-2.121a4.006 4.006 0 0 0-5.657 0l-2.829 2.828a3.006 3.006 0 0 0-.651 3.269 1 1 0 1 0 1.849-.764 1 1 0 0 1 .217-1.086l2.828-2.828a2 2 0 0 1 2.829 0l2.121 2.121a2 2 0 0 1 0 2.829L17.3 11.645a1.015 1.015 0 0 1-1.091.217 1 1 0 0 0-.765 1.849 3.026 3.026 0 0 0 3.27-.651l2.828-2.828a4.007 4.007 0 0 0 .004-5.658Z",fill:"currentColor"})]});var t1=t0;var t2=n(6790);var t5=n(44048);var t4=n(31261);var t8=n(7518);var t3=n(37998);function t6(e,t){return e?e[t]:""}function t7(e,t){let{amount:n,date:r}=e;if(nf(e.id)){n=(e._inverse?-1:1)*(0,tP.lP)(n)}let o=n<0?-n:null;let a=n>0?n:null;if(n===0){if(t){a=0}else{o=0}}if(!(0,tF.Z)((0,t_.Z)(r))){r=null}return{...e,date:r,debit:o!=null?(0,eB.zA)(o):"",credit:a!=null?(0,eB.zA)(a):""}}function t9(e,t){let{debit:n,credit:r,date:o,...a}=e;let i;if(n!==""){let e=(0,eA.Z)(n,null);i=e!=null?-e:null}else{i=(0,eA.Z)(r,null)}i=i!=null?(0,eB.l9)(i):t.amount;if(o==null){o=t.date||(0,h.PR)()}return{...a,date:o,amount:i}}function ne(e,t){let n=e[t];return n&&n.is_child&&(e[t+1]==null||e[t+1].parent_id!==n.parent_id)}let nt=(0,i.createContext)(null);function nn(){let e=(0,i.useContext)(nt);return(0,i.useMemo)(()=>({...e,expanded:t=>e.state.mode==="collapse"?!e.state.ids.has(t):e.state.ids.has(t)}),[e])}function nr({children:e,initialMode:t="expand"}){let n=(0,s.v9)(e=>e.app.lastSplitState);let r=(0,s.I0)();let[o,l]=(0,i.useReducer)((e,t)=>{switch(t.type){case"toggle-split":{let n=new Set([...e.ids]);let{id:r}=t;if(n.has(r)){n.delete(r)}else{n.add(r)}return{...e,ids:n}}case"open-split":{let n=new Set([...e.ids]);let{id:r}=t;if(e.mode==="collapse"){n.delete(r)}else{n.add(r)}return{...e,ids:n}}case"set-mode":{return{...e,mode:t.mode,ids:new Set,transitionId:null}}case"switch-mode":if(e.transitionId!=null){return e}return{...e,mode:e.mode==="expand"?"collapse":"expand",transitionId:t.id,ids:new Set};case"finish-switch-mode":return{...e,transitionId:null};default:throw new Error("Unknown action type: "+t.type)}},n.current||{ids:new Set,mode:t});(0,i.useEffect)(()=>{if(o.transitionId!=null){setTimeout(()=>{l({type:"finish-switch-mode"})},250)}},[o.transitionId]);(0,i.useEffect)(()=>{if(o.transitionId==null){r({type:"SET_LAST_SPLIT_STATE",splitState:o})}},[o]);let c=(0,i.useMemo)(()=>({state:o,dispatch:l}),[o,l]);return(0,a.jsx)(nt.Provider,{value:c,children:e})}function no(e,t,n,r="asc"){return e===n?t==="asc"?"desc":"asc":r}const na=(0,i.memo)(({hasSelected:e,showAccount:t,showCategory:n,showBalance:r,showCleared:o,scrollWidth:i,onSort:s,ascDesc:l,field:c})=>{let d=(0,tN.YP)();return(0,a.jsxs)(B.X2,{style:{fontWeight:300,zIndex:200,color:m.rS.tableHeaderText,backgroundColor:m.rS.tableBackground},children:[(0,a.jsx)(B._7,{exposed:true,focused:false,selected:e,width:20,onSelect:e=>d({type:"select-all",event:e})}),(0,a.jsx)(nl,{value:"Date",width:110,alignItems:"flex",marginLeft:-5,id:"date",icon:c==="date"?l:"clickable",onClick:()=>s("date",no(c,l,"date","desc"))}),t&&(0,a.jsx)(nl,{value:"Account",width:"flex",alignItems:"flex",marginLeft:-5,id:"account",icon:c==="account"?l:"clickable",onClick:()=>s("account",no(c,l,"account","asc"))}),(0,a.jsx)(nl,{value:"Payee",width:"flex",alignItems:"flex",marginLeft:-5,id:"payee",icon:c==="payee"?l:"clickable",onClick:()=>s("payee",no(c,l,"payee","asc"))}),(0,a.jsx)(nl,{value:"Notes",width:"flex",alignItems:"flex",marginLeft:-5,id:"notes",icon:c==="notes"?l:"clickable",onClick:()=>s("notes",no(c,l,"notes","asc"))}),n&&(0,a.jsx)(nl,{value:"Category",width:"flex",alignItems:"flex",marginLeft:-5,id:"category",icon:c==="category"?l:"clickable",onClick:()=>s("category",no(c,l,"category","asc"))}),(0,a.jsx)(nl,{value:"Payment",width:90,alignItems:"flex-end",marginRight:-5,id:"payment",icon:c==="payment"?l:"clickable",onClick:()=>s("payment",no(c,l,"payment","asc"))}),(0,a.jsx)(nl,{value:"Deposit",width:85,alignItems:"flex-end",marginRight:-5,id:"deposit",icon:c==="deposit"?l:"clickable",onClick:()=>s("deposit",no(c,l,"deposit","desc"))}),r&&(0,a.jsx)(B.bL,{value:"Balance",width:88,textAlign:"right"}),o&&(0,a.jsx)(B.gN,{width:23,truncate:false}),(0,a.jsx)(B.bL,{value:"",width:(5+i)??0})]})});function ni(e,t,n){let{payee:r}=e;if(n){return(0,a.jsx)(y.Z,{style:{flexDirection:"row",alignItems:"center"},children:(0,a.jsx)("div",{style:{overflow:"hidden",textOverflow:"ellipsis"},children:n.name})})}else if(t){return t.name}else if(r&&r.startsWith("new:")){return r.slice("new:".length)}return""}function ns({id:e,focused:t,selected:n,status:r,isChild:o,onEdit:s,onUpdate:l}){let c=r==="cleared"||r==null;let d=(0,t8.V)(r);let u=r==="cleared"?m.rS.noticeTextLight:r==="missed"?m.rS.errorText:r==="due"?m.rS.alt3WarningText:n?m.rS.pageTextLinkLight:m.rS.pageTextSubdued;function h(){if(c){l("cleared",!(r==="cleared"))}}return(0,a.jsx)(B.bL,{name:"cleared",width:23,focused:t,style:{padding:1},plain:true,children:(0,a.jsx)(B.Sx,{style:{padding:3,backgroundColor:"transparent",border:"1px solid transparent",borderRadius:50,":focus":{border:"1px solid "+m.rS.formInputBorderSelected,boxShadow:"0 1px 2px "+m.rS.formInputBorderSelected},cursor:c?"pointer":"default",...o&&{visibility:"hidden"}},onEdit:()=>s(e,"cleared"),onSelect:h,children:(0,i.createElement)(d.Icon,{style:{width:13,height:13,color:u,marginTop:r==="due"?-1:0}})})})}function nl({value:e,id:t,width:n,alignItems:r,marginLeft:o,marginRight:i,icon:s,onClick:l}){return(0,a.jsx)(B.wh,{width:n,name:t,alignItems:r,unexposedContent:(0,a.jsxs)(L.Z,{type:"bare",onClick:l,style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",color:m.rS.tableHeaderText,fontWeight:300,marginLeft:o,marginRight:i},children:[(0,a.jsx)(B.rt,{value:e}),s==="asc"&&(0,a.jsx)(tV,{width:10,height:10,style:{marginLeft:5}}),s==="desc"&&(0,a.jsx)(tX,{width:10,height:10,style:{marginLeft:5}})]})})}function nc({id:e,payeeId:t,accountId:n,focused:r,inherited:o,payees:s,accounts:l,valueStyle:c,transaction:d,payee:u,transferAcct:h,isPreview:p,onEdit:g,onUpdate:f,onCreatePayee:x,onManagePayees:y,onNavigateToTransferAccount:v,onNavigateToSchedule:w}){let b=(0,i.useRef)(false);l=l.filter(e=>e.id!==n);s=s.filter(e=>e.transfer_acct!==n);return(0,a.jsx)(B.wh,{width:"flex",name:"payee",textAlign:"flex",value:t,valueStyle:{...c,...o&&{color:m.rS.tableTextInactive}},exposed:r,onExpose:t=>!p&&g(e,t),onUpdate:async e=>{f("payee",e);if(e&&e.startsWith("new:")&&!b.current){b.current=true;let t=await x(e.slice("new:".length));f("payee",t);b.current=false}},unexposedContent:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(nd,{transaction:d,transferAccount:h,onNavigateToTransferAccount:v,onNavigateToSchedule:w}),(0,a.jsx)(B.rt,{value:t,formatter:()=>ni(d,u,h)})]}),children:({onBlur:e,onKeyDown:n,onUpdate:r,onSave:o,shouldSaveFromKey:i,inputStyle:c})=>{return(0,a.jsx)(t4.Z,{payees:s,accounts:l,value:t,shouldSaveFromKey:i,inputProps:{onBlur:e,onKeyDown:n,style:c},showManagePayees:true,tableBehavior:true,focused:true,onUpdate:r,onSelect:o,onManagePayees:()=>y(t),isCreatable:true,menuPortalTarget:undefined})}})}function nd({transaction:e,transferAccount:t,onNavigateToTransferAccount:n,onNavigateToSchedule:r,children:o}){let i=e.schedule;let s=(0,tj.oF)();let l=s?s.schedules.find(e=>e.id===i):null;if(l==null&&t==null){return o}let c={marginLeft:-5,marginRight:2,width:23,height:23,color:"inherit"};let d={width:13,height:13};let u={width:10,height:10};let h=l&&l._date&&!!l._date.frequency;return(0,a.jsxs)(a.Fragment,{children:[l&&(0,a.jsx)(L.Z,{type:"bare",style:c,onClick:e=>{e.stopPropagation();r(i)},children:h?(0,a.jsx)(tY.Z,{style:d}):(0,a.jsx)(tJ.Z,{style:d})}),t&&(0,a.jsx)(L.Z,{type:"bare",style:c,onClick:r=>{r.stopPropagation();if(!ng(e.id)){n(t.id)}},children:(e._inverse?-1:1)*e.amount>0?(0,a.jsx)(tK,{style:u}):(0,a.jsx)(t$.Z,{style:u})})]})}const nu=(0,i.memo)(function e(e){let{transaction:t,editing:n,showAccount:r,showBalance:o,showCleared:s,showZeroInDeposit:l,style:c,selected:d,highlighted:u,added:h,matched:p,expanded:g,inheritedFields:f,focusedField:x,categoryGroups:v,payees:w,accounts:b,balance:S,dateFormat:j="MM/dd/yyyy",hideFraction:C,onSave:Z,onEdit:k,onDelete:T,onSplit:A,onManagePayees:M,onCreatePayee:I,onToggleSplit:R,onNavigateToTransferAccount:E,onNavigateToSchedule:D}=e;let P=(0,tN.YP)();let[L,N]=(0,i.useState)(l);let[F,_]=(0,i.useState)(t);let[H,G]=(0,i.useState)(()=>t7(t,l));let O=nf(H.id);if(t!==F||l!==L){G(t7(t,l));_(t);N(l)}function z(e,n){if(H[e]!==n){let r={...H,[e]:n};if(e==="note"&&n===""&&H.note==null){return}if(e==="account"&&n&&(0,tG.gI)(b)[n].offbudget){r.category=null}if(e==="credit"){r["debit"]=""}else if(e==="debit"){r["credit"]=""}if(e==="payee"&&n&&n.startsWith("new:")){G(r)}else{let e=t9(r,t);G(t7(e,l));Z(e)}}}let{id:U,amount:K,debit:$,credit:Q,payee:q,imported_payee:X,notes:Y,date:J,account:ee,category:et,cleared:en,is_parent:er,_unmatched:eo=false,_inverse:ea=false}=H;let ei=w&&q&&(0,tG.yG)(w)[q];let es=b&&ee&&(0,tG.gI)(b)[ee];let el;if(ea){el=b&&ee&&(0,tG.gI)(b)[ee]}else{el=ei&&ei.transfer_acct&&(0,tG.gI)(b)[ei.transfer_acct]}let ec=H.is_child;let ed=el&&el.offbudget===0;let eu=es&&es.offbudget===1;let eh=h?{fontWeight:600}:null;let ep=x==="select";let eg=C?{letterSpacing:-.5}:null;let ef=!ng(U)?S:S+(ea?-1:1)*K;return(0,a.jsxs)(B.X2,{style:{backgroundColor:d?m.rS.tableRowBackgroundHighlight:ep?m.rS.tableRowBackgroundHover:m.rS.tableBackground,":hover":!(ep||d)&&{backgroundColor:m.rS.tableRowBackgroundHover},"& .hover-visible":{opacity:0},":hover .hover-visible":{opacity:1},...u||d?{color:m.rS.tableRowBackgroundHighlightText}:{color:m.rS.tableText},...c,...O&&{color:m.rS.tableTextInactive,backgroundColor:!d?"#fcfcfc":undefined,fontStyle:"italic"},...eo&&{opacity:.5}},children:[ec&&(0,a.jsx)(B.gN,{width:110,style:{width:110,backgroundColor:m.rS.tableRowBackgroundHover,border:0}}),ec&&r&&(0,a.jsx)(B.gN,{style:{flex:1,backgroundColor:m.rS.tableRowBackgroundHover,border:0}}),ng(H.id)?ec?(0,a.jsx)(B.nu,{onDelete:()=>T&&T(H.id),exposed:n,style:{...ec&&{borderLeftWidth:1},lineHeight:0}}):(0,a.jsx)(B.bL,{width:20}):(0,a.jsx)(B._7,{exposed:true,buttonProps:{className:d||n?null:"hover-visible"},focused:x==="select",onSelect:e=>{P({type:"select",id:H.id,event:e})},onEdit:()=>k(U,"select"),selected:d,style:{...ec&&{borderLeftWidth:1}},value:p&&(0,a.jsx)(t1,{style:{width:13,height:13,color:"inherit"}})}),!ec&&(0,a.jsx)(B.wh,{name:"date",width:110,textAlign:"flex",exposed:x==="date",value:J,valueStyle:eh,formatter:e=>e?(0,tH.Z)((0,t_.Z)(e),j):"",onExpose:e=>!O&&k(U,e),onUpdate:e=>{z("date",e)},children:({onBlur:e,onKeyDown:t,onUpdate:n,onSave:r,shouldSaveFromKey:o,inputStyle:i})=>(0,a.jsx)(t3.Z,{value:J||"",dateFormat:j,inputProps:{onBlur:e,onKeyDown:t,style:i},shouldSaveFromKey:o,tableBehavior:true,onUpdate:n,onSelect:r})}),!ec&&r&&(0,a.jsx)(B.wh,{name:"account",width:"flex",textAlign:"flex",value:ee,formatter:e=>{let t=e&&(0,tG.gI)(b)[e];if(t){return t.name}return""},valueStyle:eh,exposed:x==="account",onExpose:e=>!O&&k(U,e),onUpdate:async e=>{if(e){z("account",e)}},children:({onBlur:e,onKeyDown:t,onUpdate:n,onSave:r,shouldSaveFromKey:o,inputStyle:i})=>(0,a.jsx)(t2.Z,{includeClosedAccounts:false,value:ee,accounts:b,shouldSaveFromKey:o,tableBehavior:true,focused:true,inputProps:{onBlur:e,onKeyDown:t,style:i},onUpdate:n,onSelect:r,menuPortalTarget:undefined})}),(()=>(0,a.jsx)(nc,{id:U,payeeId:q,accountId:ee,focused:x==="payee",inherited:f&&f.has("payee"),payees:w,accounts:b,valueStyle:eh,transaction:H,payee:ei,transferAcct:el,importedPayee:X,isPreview:O,onEdit:k,onUpdate:z,onCreatePayee:I,onManagePayees:M,onNavigateToTransferAccount:E,onNavigateToSchedule:D}))(),O?(0,a.jsx)(B.bL,{name:"notes",width:"flex"}):(0,a.jsx)(B.F3,{width:"flex",name:"notes",textAlign:"flex",exposed:x==="notes",focused:x==="notes",value:Y||"",valueStyle:eh,onExpose:e=>!O&&k(U,e),inputProps:{value:Y||"",onUpdate:z.bind(null,"notes")}}),O?(0,a.jsx)(B.bL,{width:"flex",style:{alignItems:"flex-start"},exposed:true,children:()=>(0,a.jsx)(y.Z,{style:{color:Y==="missed"?m.rS.errorText:Y==="due"?m.rS.alt5WarningText:d?m.rS.formLabelText:m.rS.altTableText,backgroundColor:Y==="missed"?m.rS.errorBackground:Y==="due"?m.rS.altWarningBackground:d?m.rS.formLabelBackground:m.rS.alt2TableBackground,margin:"0 5px",padding:"3px 7px",borderRadius:4},children:(0,eB.VL)(Y)})}):er?(0,a.jsx)(B.bL,{name:"category",width:"flex",focused:x==="category",style:{padding:0},plain:true,children:(0,a.jsx)(B.Sx,{bare:true,style:{alignSelf:"flex-start",borderRadius:4,border:"1px solid transparent",":hover":{border:"1px solid "+m.rS.buttonNormalBorder}},disabled:ng(H.id),onEdit:()=>k(U,"category"),onSelect:()=>R(U),children:(0,a.jsxs)(y.Z,{style:{flexDirection:"row",alignItems:"center",alignSelf:"stretch",borderRadius:4,flex:1,padding:4},children:[er&&(0,a.jsx)(W.Z,{style:{color:"inherit",width:14,height:14,transition:"transform .08s",transform:g?"rotateZ(0)":"rotateZ(-90deg)"}}),(0,a.jsx)(V.Z,{style:{fontStyle:"italic",userSelect:"none"},children:"Split"})]})})}):ed||eu||O?(0,a.jsx)(B.F3,{name:"category",width:"flex",exposed:x==="category",focused:x==="category",onExpose:e=>!O&&k(U,e),value:er?"Split":eu?"Off Budget":ed?"Transfer":"",valueStyle:eh,style:{fontStyle:"italic",color:"#c0c0c0",fontWeight:300},inputProps:{readOnly:true,style:{fontStyle:"italic"}}}):(0,a.jsx)(B.wh,{name:"category",width:"flex",textAlign:"flex",value:et,formatter:e=>e?t6((0,tG.ch)(v)[e],"name"):H.id?"Categorize":"",exposed:x==="category",onExpose:e=>k(U,e),valueStyle:!et?{fontStyle:"italic",fontWeight:300,color:m.rS.formInputTextHighlight}:eh,onUpdate:async e=>{if(e==="split"){A(H.id)}else{z("category",e)}},children:({onBlur:e,onKeyDown:t,onUpdate:n,onSave:r,shouldSaveFromKey:o,inputStyle:i})=>(0,a.jsx)(t5.Z,{categoryGroups:v,value:et,focused:true,tableBehavior:true,showSplitOption:!ec&&!er,shouldSaveFromKey:o,inputProps:{onBlur:e,onKeyDown:t,style:i},onUpdate:n,onSelect:r,menuPortalTarget:undefined})}),(0,a.jsx)(B.F3,{type:"input",width:90,name:"debit",exposed:x==="debit",focused:x==="debit",value:$===""&&Q===""?"0.00":$,valueStyle:eh,textAlign:"right",title:$,onExpose:e=>!O&&k(U,e),style:{...er&&{fontStyle:"italic"},...m.W2.tnum,...eg},inputProps:{value:$===""&&Q===""?"0.00":$,onUpdate:z.bind(null,"debit")},privacyFilter:{activationFilters:[!ng(H.id)]}}),(0,a.jsx)(B.F3,{type:"input",width:85,name:"credit",exposed:x==="credit",focused:x==="credit",value:Q,valueStyle:eh,textAlign:"right",title:Q,onExpose:e=>!O&&k(U,e),style:{...er&&{fontStyle:"italic"},...m.W2.tnum,...eg},inputProps:{value:Q,onUpdate:z.bind(null,"credit")},privacyFilter:{activationFilters:[!ng(H.id)]}}),o&&(0,a.jsx)(B.bL,{name:"balance",value:ef==null||ec?"":(0,eB.zA)(ef),valueStyle:{color:ef<0?m.rS.errorText:m.rS.noticeTextLight},style:{...m.W2.tnum,...eg},width:88,textAlign:"right",privacyFilter:true}),s&&(0,a.jsx)(ns,{id:U,focused:x==="cleared",selected:d,isPreview:O,status:O?Y:en?"cleared":null,isChild:ec,onEdit:k,onUpdate:z}),(0,a.jsx)(B.bL,{width:5})]})});function nh({error:e,isDeposit:t,onAddSplit:n,style:r}){switch(e.type){case"SplitTransactionError":if(e.version===1){return(0,a.jsxs)(y.Z,{style:{flexDirection:"row",alignItems:"center",padding:"0 5px",...r},"data-testid":"transaction-error",children:[(0,a.jsxs)(V.Z,{children:["Amount left:"," ",(0,a.jsx)(V.Z,{style:{fontWeight:500},children:(0,eB.zA)(t?e.difference:-e.difference)})]}),(0,a.jsx)(y.Z,{style:{flex:1}}),(0,a.jsx)(L.Z,{type:"primary",style:{marginLeft:15,padding:"4px 10px"},onClick:n,children:"Add Split"})]})}break;default:return null}}function np(e,t,n){return[{id:"temp",date:n||(0,h.PR)(),account:e||null,category:t||null,cleared:false,amount:null}]}function ng(e){return e.indexOf("temp")!==-1}function nf(e){return e.indexOf("preview/")!==-1}function nx({transactions:e,accounts:t,categoryGroups:n,payees:r,editingTransaction:o,focusedField:i,showAccount:s,showCategory:l,showBalance:c,showCleared:d,dateFormat:u,hideFraction:h,onClose:p,onSplit:g,onEdit:f,onDelete:x,onSave:v,onAdd:w,onAddSplit:b,onManagePayees:S,onCreatePayee:j,onNavigateToTransferAccount:C,onNavigateToSchedule:Z,balance:k}){const T=e[0].error;const A=e[0].amount>0;return(0,a.jsxs)(y.Z,{style:{borderBottom:"1px solid "+m.rS.tableBorderHover,paddingBottom:6,backgroundColor:m.rS.tableBackground},"data-testid":"new-transaction",onKeyDown:e=>{if(e.key==="Escape"){p()}},children:[e.map(e=>(0,a.jsx)(nu,{isNew:true,editing:o===e.id,transaction:e,showAccount:s,showCategory:l,showBalance:c,showCleared:d,focusedField:o===e.id&&i,showZeroInDeposit:A,accounts:t,categoryGroups:n,payees:r,dateFormat:u,hideFraction:h,expanded:true,onEdit:f,onSave:v,onSplit:g,onDelete:x,onAdd:w,onManagePayees:S,onCreatePayee:j,style:{marginTop:-1},onNavigateToTransferAccount:C,onNavigateToSchedule:Z,balance:k},e.id)),(0,a.jsxs)(y.Z,{style:{flexDirection:"row",alignItems:"center",justifyContent:"flex-end",marginTop:6,marginRight:20},children:[(0,a.jsx)(L.Z,{style:{marginRight:10,padding:"4px 10px"},onClick:()=>p(),"data-testid":"cancel-button",children:"Cancel"}),T?(0,a.jsx)(nh,{error:T,isDeposit:A,onAddSplit:()=>b(e[0].id)}):(0,a.jsx)(L.Z,{type:"primary",style:{padding:"4px 10px"},onClick:w,"data-testid":"add-button",children:"Add"})]})]})}function nm({tableNavigator:e,tableRef:t,dateFormat:n="MM/dd/yyyy",newNavigator:r,renderEmpty:o,onScroll:s,...l}){const c=(0,i.createRef)();const d=(0,tz.Z)(l.isAdding);let[u,h]=(0,i.useState)(0);function p(e,t){let n=e>0&&t>0&&e-t;h(!n?0:n)}let g=(0,i.useCallback)(e=>{l.onCloseAddTransaction();l.onNavigateToTransferAccount(e)},[l.onCloseAddTransaction,l.onNavigateToTransferAccount]);let f=(0,i.useCallback)(e=>{l.onCloseAddTransaction();l.onNavigateToSchedule(e)},[l.onCloseAddTransaction,l.onNavigateToSchedule]);(0,i.useEffect)(()=>{if(!d&&l.isAdding){r.onEdit("temp","date")}},[d,l.isAdding,r]);const x=({item:t,index:r,position:o,editing:i})=>{const{transactions:s,selectedItems:c,accounts:d,categoryGroups:u,payees:h,showCleared:p,showAccount:x,showCategory:m,showBalances:y,balances:v,hideFraction:w,isNew:b,isMatched:S,isExpanded:j}=l;let C=t;let Z=c.has(C.id);let k=l.transactionMap.get(C.parent_id);let A=k&&k.amount>0;let B=j&&j((k||C).id);let M=B?k&&k.error||C.error:C.error;return(0,a.jsxs)(a.Fragment,{children:[(!B||ne(s,r))&&M&&M.type==="SplitTransactionError"&&(0,a.jsx)(T.u,{position:"bottom-right",width:250,forceTop:o,forceLayout:true,style:{transform:"translate(-5px, 2px)"},children:(0,a.jsx)(nh,{error:M,isDeposit:A,onAddSplit:()=>l.onAddSplit(C.id)})}),(0,a.jsx)(nu,{editing:i,transaction:C,showAccount:x,showCategory:m,showBalance:y,showCleared:p,selected:Z,highlighted:false,added:b?.(C.id),expanded:j?.(C.id),matched:S?.(C.id),showZeroInDeposit:A,balance:v?.[C.id]?.balance,focusedField:i&&e.focusedField,accounts:d,categoryGroups:u,payees:h,inheritedFields:k?.payee===C.payee?new Set(["payee"]):new Set,dateFormat:n,hideFraction:w,onEdit:e.onEdit,onSave:l.onSave,onDelete:l.onDelete,onSplit:l.onSplit,onManagePayees:l.onManagePayees,onCreatePayee:l.onCreatePayee,onToggleSplit:l.onToggleSplit,onNavigateToTransferAccount:g,onNavigateToSchedule:f})]})};return(0,a.jsxs)(y.Z,{innerRef:c,style:{flex:1,cursor:"default",...l.style},children:[(0,a.jsxs)(y.Z,{children:[(0,a.jsx)(na,{hasSelected:l.selectedItems.size>0,showAccount:l.showAccount,showCategory:l.showCategory,showBalance:l.showBalances,showCleared:l.showCleared,scrollWidth:u,onSort:l.onSort,ascDesc:l.ascDesc,field:l.sortField}),l.isAdding&&(0,a.jsx)(y.Z,{...r.getNavigatorProps({onKeyDown:e=>l.onCheckNewEnter(e)}),children:(0,a.jsx)(nx,{transactions:l.newTransactions,editingTransaction:r.editingId,focusedField:r.focusedField,accounts:l.accounts,categoryGroups:l.categoryGroups,payees:l.payees||[],showAccount:l.showAccount,showCategory:l.showCategory,showBalance:l.showBalances,showCleared:l.showCleared,dateFormat:n,hideFraction:l.hideFraction,onClose:l.onCloseAddTransaction,onAdd:l.onAddTemporary,onAddSplit:l.onAddSplit,onSplit:l.onSplit,onEdit:r.onEdit,onSave:l.onSave,onDelete:l.onDelete,onManagePayees:l.onManagePayees,onCreatePayee:l.onCreatePayee,onNavigateToTransferAccount:g,onNavigateToSchedule:f,balance:l.transactions?.length>0?l.balances?.[l.transactions[0]?.id]?.balance:0})})]}),(0,a.jsxs)(y.Z,{style:{flex:1,overflow:"hidden"},"data-testid":"transaction-table",children:[(0,a.jsx)(B.iA,{navigator:e,ref:t,items:l.transactions,renderItem:x,renderEmpty:o,loadMore:l.loadMoreTransactions,isSelected:e=>l.selectedItems.has(e),onKeyDown:e=>l.onCheckEnter(e),onScroll:s,saveScrollWidth:p}),l.isAdding&&(0,a.jsx)("div",{style:{position:"absolute",top:-20,left:0,right:0,height:20,backgroundColor:m.rS.errorText,boxShadow:"0 0 6px rgba(0, 0, 0, .20)"}},"shadow")]})]})}let ny=(0,i.forwardRef)((e,t)=>{let[n,r]=(0,i.useState)(null);let[o,s]=(0,i.useState)(false);let l=nn();let c=(0,i.useRef)(null);let d=(0,i.useRef)(null);let u=(0,tO.r)(d,t);let h=(0,i.useMemo)(()=>{let t;if(l.state.transitionId!=null){let n=e.transactions.findIndex(e=>e.id===l.state.transitionId);t=e.transactions.filter((e,t)=>{if(e.parent_id){if(t>=n){return l.expanded(e.parent_id)}else if(c.current){return c.current.expanded(e.parent_id)}}return true})}else{if(c.current&&c.current.state.transitionId!=null){d.current.anchor();d.current.setRowAnimation(false)}c.current=l;t=e.transactions.filter(e=>{if(e.parent_id){return l.expanded(e.parent_id)}return true})}c.current=l;return t},[e.transactions,l]);const p=(0,i.useMemo)(()=>{return new Map(h.map(e=>[e.id,e]))},[h]);(0,i.useEffect)(()=>{if(d.current.isAnchored()){d.current.unanchor();d.current.setRowAnimation(true)}},[c.current]);let g=(0,B.wz)(n,j);let f=(0,B.wz)(h,j);let x=(0,i.useRef)(false);let m=(0,i.useRef)({newTransactions:n,newNavigator:g,tableNavigator:f});let y=(0,i.useRef)(false);let v=(0,i.useRef)(false);let[w,b]=(0,i.useState)({});let S=(0,tN.D9)();(0,i.useLayoutEffect)(()=>{m.current={newTransactions:n,newNavigator:g,tableNavigator:f,transactions:e.transactions}});if(o!==e.isAdding){if(!o&&e.isAdding){r(np(e.currentAccountId,e.currentCategoryId))}s(e.isAdding)}(0,i.useEffect)(()=>{if(x.current){if(n[0].account==null){e.addNotification({type:"error",message:"Account is a required field"});g.onEdit("temp","account")}else{let t=m.current.newTransactions;let n=t.length>0?t[0].date:null;r(np(e.currentAccountId,e.currentCategoryId,n));g.onEdit("temp","date");e.onAdd(t)}x.current=false}});(0,i.useEffect)(()=>{if(y.current&&v.current){v.current(e);v.current=null}y.current=false},[n,e.transactions]);function j(t){let n=["select","date","account","payee","notes","category","debit","credit","cleared"];n=t.is_child?["select","payee","notes","category","debit","credit"]:n.filter(t=>(e.showAccount||t!=="account")&&(e.showCategory||t!=="category"));if(nf(t.id)){n=["select","cleared"]}if(ng(t.id)){n=n.slice(1)}return n}function C(t){if(y.current){v.current=t}else{t(e)}}function Z(e){if(e.key==="Enter"){if(e.metaKey){e.stopPropagation();T()}else if(!e.shiftKey){function t(e){let{newTransactions:t}=e.current;return t[t.length-1]}if(g.editingId===t(m).id){e.stopPropagation()}C(()=>{let e=t(m);let n=e.parent_id||e.is_parent;if(m.current.newTransactions[0].error&&g.editingId===e.id){R(e.id)}else if(g.editingId===e.id&&(!n||!e.error)){T()}})}}}function k(e){if(e.key==="Enter"&&!e.shiftKey){let{editingId:t,focusedField:n}=f;C(()=>{let r=m.current.transactions;let o=r.findIndex(e=>e.id===t);let a=p.get(r[o]?.parent_id);if(ne(r,o)&&a&&a.error&&n!=="select"){e.stopPropagation();R(t)}})}}let T=(0,i.useCallback)(()=>{x.current=true;b({})},[e.onAdd,g.onEdit]);let A=(0,i.useCallback)(async t=>{y.current=true;if(ng(t.id)){if(e.onApplyRules){t=await e.onApplyRules(t)}let n=m.current.newTransactions;r((0,tW.Ld)(n,t).data)}else{e.onSave(t)}},[e.onSave]);let M=(0,i.useCallback)(e=>{let t=ng(e);if(t){let t=m.current.newTransactions;if(e===t[0].id){return}r((0,tW.Ks)(t,e).data)}},[]);let I=(0,i.useMemo)(()=>{return t=>{if(ng(t)){let{newNavigator:e}=m.current;let n=m.current.newTransactions;let{data:o,diff:a}=(0,tW.oQ)(n,t);r(o);if(n[0].amount===null){e.onEdit(n[0].id,"debit")}else{e.onEdit(a.added[0].id,m.current.newNavigator.focusedField)}}else{let n=m.current.transactions.find(e=>e.id===t);let r=e.onSplit(t);l.dispatch({type:"open-split",id:n.id});let{tableNavigator:o}=m.current;if(n.amount===null){o.onEdit(n.id,"debit")}else{o.onEdit(r,o.focusedField)}}}},[e.onSplit,l.dispatch]);let R=(0,i.useCallback)(t=>{if(ng(t)){let e=m.current.newTransactions;let{data:n,diff:o}=(0,tW.CX)(e,t);r(n);g.onEdit(o.added[0].id,m.current.newNavigator.focusedField)}else{let n=e.onAddSplit(t);f.onEdit(n,m.current.tableNavigator.focusedField)}},[e.onAddSplit]);function E(){r(np(e.currentAccountId,e.currentCategoryId));e.onCloseAddTransaction()}let D=(0,i.useCallback)(e=>l.dispatch({type:"toggle-split",id:e}),[l.dispatch]);return(0,a.jsx)(nm,{tableRef:u,...e,transactions:h,transactionMap:p,selectedItems:S,isExpanded:l.expanded,onSave:A,onDelete:M,onSplit:I,onCheckNewEnter:Z,onCheckEnter:k,onAddTemporary:T,onAddSplit:R,onCloseAddTransaction:E,onToggleSplit:D,newTransactions:n,tableNavigator:f,newNavigator:g})});async function nv(e){let t=await (0,d.lW)("transactions-batch-update",{...e,learnCategories:true});if(t.length>0){return{updates:t}}return{}}async function nw(e,t,n){let r=await nv(e);n((0,tW._n)(t.newTransaction,r),(0,eB.zb)(r,t.data))}function nb({tableRef:e,transactions:t,allTransactions:n,loadMoreTransactions:r,account:o,accounts:s,category:c,categoryGroups:u,payees:h,balances:p,showBalances:g,showCleared:f,showAccount:x,headerContent:y,isAdding:v,isNew:w,isMatched:b,isFiltered:S,dateFormat:j,hideFraction:C,addNotification:Z,pushModal:k,renderEmpty:T,onSort:A,sortField:B,ascDesc:M,onChange:I,onRefetch:R,onCloseAddTransaction:E,onCreatePayee:D}){let P=(0,i.useRef)();let W=(0,l.s0)();(0,i.useLayoutEffect)(()=>{P.current=t},[t]);let L=(0,i.useCallback)(async e=>{e=(0,tW.V6)(e);await nv({added:e});R()},[]);let N=(0,i.useCallback)(async e=>{let t=(0,tW.Ld)(P.current,e);if(t.diff.updated.length>0){let e=!!t.diff.updated[0].date;if(e){t.diff.updated[0].sort_order=Date.now();await nv(t.diff);R()}else{I(t.newTransaction,t.data);nw(t.diff,t,I)}}},[]);let F=(0,i.useCallback)(e=>{const t=(0,tW.CX)(P.current,e);I(t.newTransaction,t.data);nw(t.diff,t,I);return t.diff.added[0].id},[]);let _=(0,i.useCallback)(e=>{const t=(0,tW.oQ)(P.current,e);I(t.newTransaction,t.data);nw(t.diff,t,I);return t.diff.added[0].id},[]);let H=(0,i.useCallback)(async e=>{let t=await (0,d.lW)("rules-run",{transaction:e});let n=(0,eB.k4)(e,t);let r={...e};if(n){Object.keys(n).forEach(e=>{if(r[e]==null||r[e]===""||r[e]===0||r[e]===false){r[e]=n[e]}})}return r},[]);let G=(0,i.useCallback)(e=>{W("/payees",{selectedPayee:e})});let O=(0,i.useCallback)(e=>{W(`/accounts/${e}`)});let z=(0,i.useCallback)(e=>{k("schedule-edit",{id:e})});return(0,a.jsx)(ny,{ref:e,transactions:n,loadMoreTransactions:r,accounts:s,categoryGroups:u,payees:h,showBalances:g,balances:p,showCleared:f,showAccount:x,showCategory:true,currentAccountId:o&&o.id,currentCategoryId:c&&c.id,isAdding:v,isNew:w,isMatched:b,isFiltered:S,dateFormat:j,hideFraction:C,addNotification:Z,headerContent:y,renderEmpty:T,onSave:N,onApplyRules:H,onSplit:_,onCloseAddTransaction:E,onAdd:L,onAddSplit:F,onManagePayees:G,onCreatePayee:D,style:{backgroundColor:m.rS.tableBackground},onNavigateToTransferAccount:O,onNavigateToSchedule:z,onSort:A,sortField:B,ascDesc:M})}var nS=n(63495);var nj=n(99458);var nC=n(74684);const nZ=e=>(0,a.jsx)("svg",{...e,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",style:{color:"inherit",...e.style},children:(0,a.jsx)("path",{fill:"currentColor",d:"M19.611 2.571h-3.754a1.286 1.286 0 1 1 0-2.571h6.857A1.286 1.286 0 0 1 24 1.286v6.857a1.286 1.286 0 0 1-2.571 0V4.39L15.48 10.34a1.286 1.286 0 0 1-1.817-1.817l5.948-5.95ZM1.286 14.571a1.286 1.286 0 0 1 1.285 1.286v3.754l5.949-5.946a1.286 1.286 0 0 1 1.817 1.817L4.39 21.429h3.753a1.285 1.285 0 1 1 0 2.571H1.286A1.286 1.286 0 0 1 0 22.714v-6.857a1.286 1.286 0 0 1 1.286-1.286Z"})});var nk=nZ;const nT=e=>(0,a.jsx)("svg",{...e,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",style:{color:"inherit",...e.style},children:(0,a.jsx)("path",{fill:"currentColor",d:"M14.143 1.714A1.286 1.286 0 0 1 15.429 3v3.753L21.806.377a1.286 1.286 0 0 1 1.817 1.817l-6.376 6.377H21a1.286 1.286 0 1 1 0 2.572h-6.857a1.286 1.286 0 0 1-1.286-1.286V3a1.286 1.286 0 0 1 1.286-1.286ZM9.857 22.286A1.285 1.285 0 0 1 8.571 21v-3.753l-6.377 6.376a1.286 1.286 0 0 1-1.817-1.817l6.376-6.377H3a1.286 1.286 0 0 1 0-2.572h6.857a1.286 1.286 0 0 1 1.286 1.286V21a1.286 1.286 0 0 1-1.286 1.286Z"})});var nA=nT;const nB=e=>(0,a.jsxs)("svg",{...e,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",style:{color:"inherit",...e.style},children:[(0,a.jsx)("path",{d:"M8.616 1.741A1.455 1.455 0 0 1 10.07.287h3.392a1.455 1.455 0 0 1 1.453 1.454v8.228a.25.25 0 0 0 .25.25h2.9a1.138 1.138 0 0 1 .827 2l-6.1 6.1a1.489 1.489 0 0 1-2.056 0l-6.1-6.1a1.137 1.137 0 0 1 .827-2h2.9a.249.249 0 0 0 .25-.25Z",fill:"currentColor"}),(0,a.jsx)("path",{d:"M0 19.677a4.039 4.039 0 0 0 4.035 4.035h15.93A4.039 4.039 0 0 0 24 19.677V17.8a1.225 1.225 0 0 0-2.449 0v1.874a1.588 1.588 0 0 1-1.586 1.586H4.035a1.588 1.588 0 0 1-1.586-1.586V17.8A1.225 1.225 0 0 0 0 17.8Z",fill:"currentColor"})]});var nM=nB;const nI=e=>(0,a.jsx)("svg",{...e,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",style:{color:"inherit",...e.style},children:(0,a.jsx)("path",{d:"M15.067 3.986a.5.5 0 0 0-.354-.148.5.5 0 0 0-.354.147L3.437 14.91a.5.5 0 0 0 0 .707l4.948 4.948a.5.5 0 0 0 .707 0L20.009 9.648a.5.5 0 0 0 0-.706ZM2.43 16.8a.5.5 0 0 0-.489-.127.5.5 0 0 0-.351.364L.084 23.314a.5.5 0 0 0 .133.47.507.507 0 0 0 .47.132l6.272-1.5a.5.5 0 0 0 .237-.84ZM23.2 2.924 21.077.8a2.5 2.5 0 0 0-3.532 0l-1.418 1.417a.5.5 0 0 0 0 .707l4.95 4.949a.5.5 0 0 0 .707 0L23.2 6.454a2.5 2.5 0 0 0 0-3.53Z",fill:"currentColor"})});var nR=nI;var nE=n(19637);function nD({onClick:e}){return(0,a.jsx)(L.Z,{type:"bare",onClick:e,"aria-label":"Menu",children:(0,a.jsx)(ev.Z,{width:15,height:15,style:{transform:"rotateZ(90deg)"}})})}var nP=n(30076);var nW=n(16598);var nL=n(1482);var nN=n(39235);function nF({getTransaction:e,onShow:t,onDuplicate:n,onDelete:r,onEdit:o,onUnlink:s,onCreateRule:l,onScheduleAction:c,pushModal:d}){let u=(0,tN.D9)();let h=(0,i.useMemo)(()=>{let e=[...u];return{preview:!!e.find(e=>nf(e)),trans:!!e.find(e=>!nf(e))}},[u]);let p=(0,i.useMemo)(()=>{let t=[...u].map(t=>e(t));return t.some(e=>e&&e.is_child)},[u]);let g=(0,i.useMemo)(()=>{return!h.preview&&[...u].every(t=>{let n=e(t);return n&&n.schedule})},[h.preview,u,e]);return(0,a.jsx)(B.Vg,{name:"transactions",keyHandlers:h.trans&&{f:()=>t([...u]),d:()=>r([...u]),a:()=>o("account",[...u]),p:()=>o("payee",[...u]),n:()=>o("notes",[...u]),c:()=>o("category",[...u]),l:()=>o("cleared",[...u])},items:[...!h.trans?[{name:"view-schedule",text:"View schedule"},{name:"post-transaction",text:"Post transaction"},{name:"skip",text:"Skip scheduled date"}]:[{name:"show",text:"Show",key:"F"},{name:"duplicate",text:"Duplicate",disabled:p},{name:"delete",text:"Delete",key:"D"},...g?[{name:"view-schedule",text:"View schedule",disabled:u.size>1},{name:"unlink-schedule",text:"Unlink schedule"}]:[{name:"link-schedule",text:"Link schedule"},{name:"create-rule",text:"Create rule"}],N.Z.line,{type:N.Z.label,name:"Edit field"},{name:"date",text:"Date"},{name:"account",text:"Account",key:"A"},{name:"payee",text:"Payee",key:"P"},{name:"notes",text:"Notes",key:"N"},{name:"category",text:"Category",key:"C"},{name:"amount",text:"Amount"},{name:"cleared",text:"Cleared",key:"L"}]],onSelect:a=>{switch(a){case"show":t([...u]);break;case"duplicate":n([...u]);break;case"delete":r([...u]);break;case"post-transaction":case"skip":c(a,u);break;case"view-schedule":let i=[...u][0];let h;if(nf(i)){let e=i.split("/");h=e[1]}else{let t=e(i);h=t&&t.schedule}if(h){d("schedule-edit",{id:h})}break;case"link-schedule":d("schedule-link",{transactionIds:[...u]});break;case"unlink-schedule":s([...u]);break;case"create-rule":l([...u]);break;default:o(a,[...u])}}})};const n_=e=>(0,a.jsxs)("svg",{...e,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",style:{color:"inherit",...e.style},children:[(0,a.jsx)("path",{d:"M13.584 12a2.643 2.643 0 0 1-.775 1.875l-9.541 9.541a1.768 1.768 0 0 1-2.5-2.5l8.739-8.739a.25.25 0 0 0 0-.354L.768 3.084a1.768 1.768 0 0 1 2.5-2.5l9.541 9.541A2.643 2.643 0 0 1 13.584 12Z",fill:"currentColor"}),(0,a.jsx)("path",{d:"M23.75 12a2.643 2.643 0 0 1-.775 1.875l-9.541 9.541a1.768 1.768 0 0 1-2.5-2.5l8.739-8.739a.25.25 0 0 0 0-.354l-8.739-8.739a1.768 1.768 0 0 1 2.5-2.5l9.541 9.541A2.643 2.643 0 0 1 23.75 12Z",fill:"currentColor"})]});var nH=n_;function nG({name:e,balance:t,isExactBalance:n=true}){const r=(0,eI.Z)();return(0,a.jsxs)(V.Z,{style:{marginLeft:15,borderRadius:4,padding:"4px 6px",color:m.rS.alt2PillText,backgroundColor:m.rS.pillBackground},children:[e," ",(0,a.jsx)(eH.ZP,{children:(0,a.jsxs)(V.Z,{style:{fontWeight:600},children:[!n&&"~ ",r(t,"financial")]})})]})}function nO({selectedItems:e,account:t}){let n=`selected-balance-${[...e].join("-")}`;let r=(0,eR.Z)({name:n,query:(0,G.ZP)("transactions").filter({id:{$oneof:[...e]},parent_id:{$oneof:[...e]}}).select("id")});let o=new Set((r||[]).map(e=>e.id));let i=[...e].filter(e=>!o.has(e));let s=(0,eR.Z)({name:n+"-sum",query:(0,G.ZP)("transactions").filter({id:{$oneof:i}}).options({splits:"all"}).calculate({$sum:"$amount"})});let l=null;let c=(0,tj.oF)();let d=c?c.schedules:[];let u=[...e].filter(e=>nf(e)).map(e=>e.slice(8));let h=true;for(let e of d){if(u.includes(e.id)){if(e._amountOp==="isbetween"){h=false}if(!t||t.id===e._account){l+=(0,tP.lP)(e._amount)}else{l-=(0,tP.lP)(e._amount)}}}if(s==null){if(l==null){return null}else{s=l}}else if(l!=null){s+=l}return(0,a.jsx)(nG,{name:"Selected balance:",balance:s,isExactBalance:h})}function nz({balanceQuery:e}){let t=(0,eR.Z)({name:e.name+"-cleared",query:e.query.filter({cleared:true})});let n=(0,eR.Z)({name:e.name+"-uncleared",query:e.query.filter({cleared:false})});return(0,a.jsxs)(y.Z,{style:{flexDirection:"row"},children:[(0,a.jsx)(nG,{name:"Cleared total:",balance:t}),(0,a.jsx)(nG,{name:"Uncleared total:",balance:n})]})}function nU({balanceQuery:e,showExtraBalances:t,onToggleExtraBalances:n,account:r}){let o=(0,tN.D9)();return(0,a.jsxs)(y.Z,{style:{flexDirection:"row",alignItems:"center",marginTop:-5,marginLeft:-5},children:[(0,a.jsxs)(L.Z,{"data-testid":"account-balance",type:"bare",onClick:n,style:{"& svg":{opacity:o.size>0||t?1:0},"&:hover svg":{opacity:1}},children:[(0,a.jsx)(eM.Z,{binding:{...e,value:0},type:"financial",style:{fontSize:22,fontWeight:400},getStyle:e=>({color:e<0?m.rS.errorText:e>0?m.rS.noticeTextLight:m.rS.pageTextSubdued}),privacyFilter:{blurIntensity:5}}),(0,a.jsx)(nH,{style:{width:10,height:10,marginLeft:10,color:m.rS.alt2PillText,transform:t?"rotateZ(180deg)":"rotateZ(0)"}})]}),t&&(0,a.jsx)(nz,{balanceQuery:e}),o.size>0&&(0,a.jsx)(nO,{selectedItems:o,account:r})]})}var nK=n(6564);function n$({balanceQuery:e,targetBalance:t,onDone:n,onCreateTransaction:r}){let o=(0,eR.Z)({name:e.name+"-cleared",value:0,query:e.query.filter({cleared:true})});let i=(0,eI.Z)();let s=t-o;return(0,a.jsx)(y.Z,{style:{flexDirection:"row",alignSelf:"center",backgroundColor:m.rS.tableBackground,...m.W2.shadow,borderRadius:4,marginTop:5,marginBottom:15,padding:10},children:(0,a.jsxs)(y.Z,{style:{flexDirection:"row",alignItems:"center"},children:[s===0?(0,a.jsxs)(y.Z,{style:{color:m.rS.noticeTextLight,flex:1,flexDirection:"row",alignItems:"center",justifyContent:"center"},children:[(0,a.jsx)(nK.Z,{style:{width:13,height:13,color:"inherit",marginRight:3}}),"All reconciled!"]}):(0,a.jsx)(y.Z,{style:{color:m.rS.tableText},children:(0,a.jsxs)(V.Z,{style:{fontStyle:"italic",textAlign:"center"},children:["Your cleared balance"," ",(0,a.jsx)("strong",{children:i(o,"financial")})," needs"," ",(0,a.jsx)("strong",{children:(s>0?"+":"")+i(s,"financial")})," ","to match",(0,a.jsx)("br",{})," your bank’s balance of"," ",(0,a.jsx)(V.Z,{style:{fontWeight:700},children:i(t,"financial")})]})}),(0,a.jsx)(y.Z,{style:{marginLeft:15},children:(0,a.jsx)(L.Z,{type:"primary",onClick:n,children:"Done Reconciling"})}),s!==0&&(0,a.jsx)(y.Z,{style:{marginLeft:15},children:(0,a.jsx)(L.Z,{onClick:()=>r(s),children:"Create Reconciliation Transaction"})})]})})}function nQ({account:e,onReconcile:t,onClose:n}){let r=eT.cW(e);let o=(0,eR.Z)({name:r.name+"-cleared",value:null,query:r.query.filter({cleared:true})});let i=(0,eI.Z)();function s(e){e.preventDefault();let r=e.target.elements[0];let a=(0,eB.qT)(r.value);if(a!=null){t(a==null?o:a);n()}else{r.select()}}return(0,a.jsx)(T.u,{position:"bottom-right",width:275,onClose:n,children:(0,a.jsxs)(y.Z,{style:{padding:"5px 8px"},children:[(0,a.jsx)(V.Z,{children:"Enter the current balance of your bank account that you want to reconcile with:"}),(0,a.jsxs)("form",{onSubmit:s,children:[o!=null&&(0,a.jsx)(tr.Z,{children:(0,a.jsx)(to.ZP,{defaultValue:i(o,"financial"),style:{margin:"7px 0"}})}),(0,a.jsx)(L.Z,{type:"primary",children:"Reconcile"})]})]})})};function nV({tableRef:e,editingName:t,isNameEditable:n,workingHard:r,accountName:o,account:s,filterId:l,filtersList:c,accountsSyncing:d,accounts:u,transactions:h,showBalances:p,showExtraBalances:g,showCleared:f,showEmptyMessage:x,balanceQuery:v,reconcileAmount:w,canCalculateBalance:b,isSorted:S,search:j,filters:C,conditionsOp:Z,savePrefs:k,pushModal:T,onSearch:A,onAddTransaction:B,onShowTransactions:M,onDoneReconciling:I,onCreateReconciliationTransaction:R,onToggleExtraBalances:E,onSaveName:D,onExposeName:P,onSync:W,onImport:N,onMenuSelect:F,onReconcile:_,onBatchDelete:H,onBatchDuplicate:G,onBatchEdit:O,onBatchUnlink:z,onCreateRule:U,onApplyFilter:K,onUpdateFilter:$,onClearFilters:Q,onReloadSavedFilter:V,onCondOpChange:q,onDeleteFilter:X,onScheduleAction:Y}){let[ee,et]=(0,i.useState)(false);let en=(0,i.useRef)(null);let er=nn();let eo=s&&s.account_id;if(!s){eo=!!u.find(e=>!!e.account_id)}function ea(){if(e.current){er.dispatch({type:"switch-mode",id:e.current.getScrolledItem()});k({"expand-splits":!(er.state.mode==="expand")})}}return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(nN.U,{keys:{"ctrl+f, cmd+f":()=>{if(en.current){en.current.focus()}}}}),(0,a.jsxs)(y.Z,{style:{...m.W2.pageContent,paddingBottom:10,flexShrink:0},children:[(0,a.jsx)(y.Z,{style:{marginTop:2,alignItems:"flex-start"},children:(0,a.jsx)(y.Z,{children:t?(0,a.jsx)(tr.Z,{children:(0,a.jsx)(to.ZP,{defaultValue:o,onEnter:e=>D(e.target.value),onBlur:()=>P(false),style:{fontSize:25,fontWeight:500,marginTop:-5,marginBottom:-2,marginLeft:-5}})}):n?(0,a.jsxs)(y.Z,{style:{flexDirection:"row",alignItems:"center",gap:3,"& .hover-visible":{opacity:0,transition:"opacity .25s"},"&:hover .hover-visible":{opacity:1}},children:[(0,a.jsx)(y.Z,{style:{fontSize:25,fontWeight:500,marginRight:5,marginBottom:5},"data-testid":"account-name",children:s&&s.closed?"Closed: "+o:o}),s&&(0,a.jsx)(J,{id:`account-${s.id}`}),(0,a.jsx)(L.Z,{type:"bare",className:"hover-visible",onClick:()=>P(true),children:(0,a.jsx)(nR,{style:{width:11,height:11,color:m.rS.altButtonBareText}})})]}):(0,a.jsx)(y.Z,{style:{fontSize:25,fontWeight:500,marginBottom:5},"data-testid":"account-name",children:s&&s.closed?"Closed: "+o:o})})}),(0,a.jsx)(nU,{balanceQuery:v,showExtraBalances:g,onToggleExtraBalances:E,account:s}),(0,a.jsxs)(e_.Z,{spacing:2,direction:"row",align:"center",style:{marginTop:12},children:[(s&&!s.closed||eo)&&(0,a.jsx)(L.Z,{type:"bare",onClick:eo?W:N,children:eo?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(nE.Z,{width:13,height:13,animating:s&&d===s.name||d==="__all",style:{marginRight:4}})," ","Sync"]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(nM,{width:13,height:13,style:{marginRight:4}})," ","Import"]})}),!x&&(0,a.jsxs)(L.Z,{type:"bare",onClick:B,children:[(0,a.jsx)(nC.Z,{width:10,height:10,style:{marginRight:3}})," Add New"]}),(0,a.jsx)(y.Z,{style:{flexShrink:0},children:(0,a.jsx)(nW.L,{onApply:K})}),(0,a.jsx)(y.Z,{style:{flex:1}}),(0,a.jsx)(tC.Z,{placeholder:"Search",value:j,onChange:A,inputRef:en}),r?(0,a.jsx)(y.Z,{children:(0,a.jsx)(nj.Z,{style:{width:16,height:16}})}):(0,a.jsx)(nF,{getTransaction:e=>h.find(t=>t.id===e),onShow:M,onDuplicate:G,onDelete:H,onEdit:O,onUnlink:z,onCreateRule:U,onScheduleAction:Y,pushModal:T}),(0,a.jsx)(L.Z,{type:"bare",disabled:j!==""||C.length>0,style:{padding:6,marginLeft:10},onClick:ea,title:er.state.mode==="collapse"?"Collapse split transactions":"Expand split transactions",children:er.state.mode==="collapse"?(0,a.jsx)(nA,{style:{width:14,height:14}}):(0,a.jsx)(nk,{style:{width:14,height:14}})}),s?(0,a.jsxs)(y.Z,{children:[(0,a.jsx)(nD,{onClick:()=>et(true)}),ee&&(0,a.jsx)(nq,{account:s,canSync:eo,canShowBalances:b(),isSorted:S,showBalances:p,showCleared:f,onMenuSelect:e=>{et(false);F(e)},onReconcile:_,onClose:()=>et(false)})]}):(0,a.jsxs)(y.Z,{children:[(0,a.jsx)(nD,{onClick:()=>et(true)}),ee&&(0,a.jsx)(nX,{onMenuSelect:e=>{et(false);F(e)},onClose:()=>et(false),isSorted:S})]})]}),C&&C.length>0&&(0,a.jsx)(nL.O,{filters:C,conditionsOp:Z,onUpdateFilter:$,onDeleteFilter:X,onClearFilters:Q,onReloadSavedFilter:V,filterId:l,filtersList:c,onCondOpChange:q})]}),w!=null&&(0,a.jsx)(n$,{targetBalance:w,balanceQuery:v,onDone:I,onCreateTransaction:R})]})}function nq({account:e,canSync:t,showBalances:n,canShowBalances:r,showCleared:o,onClose:s,isSorted:l,onReconcile:c,onMenuSelect:d}){let[u,h]=(0,i.useState)("default");const p=(0,nS.Z)();return u==="reconcile"?(0,a.jsx)(nQ,{account:e,onClose:s,onReconcile:c}):(0,a.jsx)(nP.Z,{width:200,onClose:s,children:(0,a.jsx)(N.Z,{onMenuSelect:e=>{if(e==="reconcile"){h("reconcile")}else{d(e)}},items:[l&&{name:"remove-sorting",text:"Remove all sorting"},r&&{name:"toggle-balance",text:(n?"Hide":"Show")+" running balance"},{name:"toggle-cleared",text:(o?"Hide":"Show")+" “cleared” checkboxes"},{name:"export",text:"Export"},{name:"reconcile",text:"Reconcile"},e&&!e.closed&&(t?{name:"unlink",text:"Unlink account"}:p==="online"&&{name:"link",text:"Link account"}),e.closed?{name:"reopen",text:"Reopen account"}:{name:"close",text:"Close account"}].filter(e=>e)})})}function nX({onClose:e,onMenuSelect:t,isSorted:n}){return(0,a.jsx)(nP.Z,{width:200,onClose:e,children:(0,a.jsx)(N.Z,{onMenuSelect:e=>{t(e)},items:[n&&{name:"remove-sorting",text:"Remove all sorting"},{name:"export",text:"Export"}]})})};function nY({onAdd:e}){return(0,a.jsx)(y.Z,{style:{color:m.rS.tableText,backgroundColor:m.rS.tableBackground,flex:1,alignItems:"center",borderTopWidth:1,borderColor:m.rS.tableBorder},children:(0,a.jsxs)(y.Z,{style:{width:550,marginTop:75,fontSize:15,alignItems:"center"},children:[(0,a.jsxs)(V.Z,{style:{textAlign:"center",lineHeight:"1.4em"},children:["For Actual to be useful, you need to ",(0,a.jsx)("strong",{children:"add an account"}),". You can link an account to automatically download transactions, or manage it locally yourself."]}),(0,a.jsx)(L.Z,{type:"primary",style:{marginTop:20},onClick:e,children:"Add account"}),(0,a.jsx)(y.Z,{style:{marginTop:20,fontSize:13,color:m.rS.alttableText},children:"In the future, you can add accounts from the sidebar."})]})})}function nJ({account:e={},transactions:t,balances:n,showBalances:r,filtered:o,children:a}){const{id:s}=e;let l=(0,tj.oF)();t??=[];let c=(0,i.useMemo)(()=>l?l.schedules.filter(e=>!e.completed&&["due","upcoming","missed"].includes(l.statuses.get(e.id))):[],[l]);let d=(0,i.useMemo)(()=>{return c.map(e=>({id:`preview/${e.id}`,payee:e._payee,account:e._account,amount:e._amount,date:e.next_date,notes:l.statuses.get(e.id),schedule:e.id,_inverse:s?s!==e._account:false}))},[c,s]);let u=(0,i.useMemo)(()=>{if(!r){return 0}return n&&t?.length>0?n[t[0].id]?.balance??0:0},[r,n,t]);let h=(0,i.useMemo)(()=>{if(!r){return null}let e=[...d].reverse().map(e=>{let t=(e._inverse?-1:1)*(0,tP.lP)(e.amount);return{balance:u+=t,id:e.id}});return(0,eB.ZZ)(e)},[r,d,u]);let p=(0,i.useMemo)(()=>{if(!o&&d.length>0){return d.concat(t)}return t},[o,d,t]);let g=(0,i.useMemo)(()=>{if(!o&&h&&n){return{...h,...n}}return n},[o,h,n]);if(l==null){return a(t,n)}return a(p,g)}function n0(e){switch(e){case"account":return"account.name";case"payee":return"payee.name";case"category":return"category.name";case"payment":return"amount";case"deposit":return"amount";default:return e}}class n1 extends i.PureComponent{constructor(e){super(e);this.paged=null;this.table=(0,i.createRef)();this.animated=true;this.state={search:"",filters:[],loading:true,workingHard:false,reconcileAmount:null,transactions:[],transactionsCount:0,showBalances:e.showBalances,balances:null,showCleared:e.showCleared,editingName:false,isAdding:false,latestDate:null,filterId:[],conditionsOp:"and",sort:[]}}async componentDidMount(){let e=e=>{if(e.includes("transactions")||e.includes("category_mapping")||e.includes("payee_mapping")){return this.refetchTransactions()}};let t=async({tables:t,messages:n,undoTag:r})=>{await e(t);let o;if(n.every(e=>e.dataset==="transactions")&&!n.find(e=>e.column==="tombstone")){let e=n.filter(e=>e.dataset==="transactions"&&!(e.column==="tombstone"));o=e.length===1?e[0].row:null}if(this.table.current){this.table.current.edit(null);if(o){this.table.current.scrollTo(o)}}this.props.setLastUndoState(null)};let n=[(0,d.oL)("undo-event",t)];this.unlisten=()=>{n.forEach(e=>e())};await this.props.initiallyLoadPayees();await this.fetchTransactions();if(this.props.lastUndoState&&this.props.lastUndoState.current){t(this.props.lastUndoState.current)}}componentDidUpdate(e){if(this.state.isAdding&&this.props.accountId!==e.accountId){this.setState({isAdding:false})}if(e.modalShowing&&!this.props.modalShowing){setTimeout(()=>{this.refetchTransactions()},100)}if(this.props.accountId!==e.accountId){this.setState({sort:[],search:"",filters:[]})}}componentWillUnmount(){if(this.unlisten){this.unlisten()}if(this.paged){this.paged.unsubscribe()}}fetchAllIds=async()=>{let{data:e}=await (0,G.Vn)(this.paged.getQuery().select("id"));return e.reduce((e,t)=>{e.push(t.id);t.subtransactions.forEach(t=>e.push(t.id));return e},[])};refetchTransactions=async()=>{this.paged?.run()};fetchTransactions=()=>{let e=this.makeRootQuery();this.rootQuery=this.currentQuery=e;this.updateQuery(e);if(this.props.accountId){this.props.markAccountRead(this.props.accountId)}};makeRootQuery=()=>{let e=this.props.location.state;let t=this.props.accountId;if(e&&e.filter){return(0,G.ZP)("transactions").options({splits:"grouped"}).filter({"account.offbudget":false,...e.filter})}return eT.yf(t)};updateQuery(e,t){if(this.paged){this.paged.unsubscribe()}this.paged=(0,G.Fr)(e.select("*"),async(e,n)=>{const r=n==null;if(r){this.table.current?.setRowAnimation(false);if(t){this.props.splitsExpandedDispatch({type:"set-mode",mode:"collapse"})}else{this.props.splitsExpandedDispatch({type:"set-mode",mode:this.props.expandSplits?"expand":"collapse"})}}this.setState({transactions:e,transactionCount:this.paged.getTotalCount(),transactionsFiltered:t,loading:false,workingHard:false,balances:this.state.showBalances?await this.calculateBalances():null},()=>{if(r){this.table.current?.scrollToTop()}setTimeout(()=>{this.table.current?.setRowAnimation(true)},0)})},{pageCount:150,onlySync:true,mapper:tW.Xt})}UNSAFE_componentWillReceiveProps(e){if(this.props.accountId!==e.accountId){this.setState({editingName:false,loading:true,search:"",showBalances:e.showBalances,balances:null,showCleared:e.showCleared,reconcileAmount:null},()=>{this.fetchTransactions()})}}onSearch=e=>{this.paged.unsubscribe();this.setState({search:e},this.onSearchDone)};onSearchDone=(0,tI.debounce)(()=>{if(this.state.search===""){this.updateQuery(this.currentQuery,this.state.filters.length>0)}else{this.updateQuery(eT.jS(this.currentQuery,this.state.search,this.props.dateFormat),true)}},150);onSync=async()=>{const e=this.props.accountId;const t=this.props.accounts.find(t=>t.id===e);await this.props.syncAndDownload(t?t.id:null)};onImport=async()=>{const e=this.props.accountId;const t=this.props.accounts.find(t=>t.id===e);if(t){const t=await window.Actual.openFileDialog({filters:[{name:"Financial Files",extensions:["qif","ofx","qfx","csv","tsv"]}]});if(t){this.props.pushModal("import-transactions",{accountId:e,filename:t[0],onImported:e=>{if(e){this.fetchTransactions()}}})}}};onExport=async e=>{let t=await (0,d.lW)("transactions-export-query",{query:this.currentQuery.serialize()});let n=e&&e.replace(/[()]/g,"").replace(/\s+/g,"-");let r=`${n||"transactions"}.csv`;window.Actual.saveFile(t,r,"Export Transactions")};onTransactionsChange=(e,t)=>{this.paged.optimisticUpdate(t=>{if(e._deleted){return t.filter(t=>t.id!==e.id)}else{return t.map(t=>{return t.id===e.id?e:t})}},e=>{return t});this.props.updateNewTransactions(e.id)};canCalculateBalance=()=>{let e=this.props.accountId;let t=this.props.accounts.find(t=>t.id===e);return t&&this.state.search===""&&this.state.filters.length===0&&(this.state.sort.length===0||this.state.sort.field==="date"&&this.state.sort.ascDesc==="desc")};async calculateBalances(){if(!this.canCalculateBalance()){return null}let{data:e}=await (0,G.Vn)(this.paged.getQuery().options({splits:"none"}).select([{balance:{$sumOver:"$amount"}}]));return(0,eB.ZZ)(e)}onAddTransaction=()=>{this.setState({isAdding:true})};onExposeName=e=>{this.setState({editingName:e})};onSaveName=e=>{if(e.trim().length){const t=this.props.accountId;const n=this.props.accounts.find(e=>e.id===t);this.props.updateAccount({...n,name:e});this.setState({editingName:false})}};onToggleExtraBalances=()=>{let{accountId:e,showExtraBalances:t}=this.props;let n="show-extra-balances-"+e||0;this.props.savePrefs({[n]:!t})};onMenuSelect=async e=>{const t=this.props.accountId;const n=this.props.accounts.find(e=>e.id===t);switch(e){case"link":(0,tL.F)(this.props.pushModal,{upgradingAccountId:t});break;case"unlink":this.props.unlinkAccount(t);break;case"close":this.props.openAccountCloseModal(t);break;case"reopen":this.props.reopenAccount(t);break;case"export":const r=this.getAccountTitle(n,t);this.onExport(r);break;case"toggle-balance":if(this.state.showBalances){this.props.savePrefs({["show-balances-"+t]:false});this.setState({showBalances:false,balances:null})}else{this.props.savePrefs({["show-balances-"+t]:true});this.setState({transactions:[],transactionCount:0,filters:[],search:"",sort:[],showBalances:true},()=>{this.fetchTransactions()})}break;case"remove-sorting":{this.setState({sort:[]},()=>{let e=this.state.filters;if(e.length>0){this.applyFilters([...e])}else{this.fetchTransactions()}if(this.state.search!==""){this.onSearch(this.state.search)}});break}case"toggle-cleared":if(this.state.showCleared){this.props.savePrefs({["hide-cleared-"+t]:true});this.setState({showCleared:false})}else{this.props.savePrefs({["hide-cleared-"+t]:false});this.setState({showCleared:true})}break;default:}};getAccountTitle(e,t){let{filterName:n}=this.props.location.state||{};if(n){return n}if(!e){if(t==="budgeted"){return"Budgeted Accounts"}else if(t==="offbudget"){return"Off Budget Accounts"}else if(t==="uncategorized"){return"Uncategorized"}else if(!t){return"All Accounts"}return null}return e.name}getBalanceQuery(e,t){return{name:`balance-query-${t}`,query:this.makeRootQuery().calculate({$sum:"$amount"})}}isNew=e=>{return this.props.newTransactions.includes(e)};isMatched=e=>{return this.props.matchedTransactions.includes(e)};onCreatePayee=e=>{let t=e.trim();if(t!==""){return this.props.createPayee(e)}return null};onReconcile=e=>{this.setState({reconcileAmount:e})};onDoneReconciling=()=>{this.setState({reconcileAmount:null})};onCreateReconciliationTransaction=async e=>{const t=(0,tW.V6)([{id:"temp",account:this.props.accountId,cleared:true,amount:e,date:(0,h.PR)(),notes:"Reconciliation balance adjustment"}]);this.setState({transactions:[...this.state.transactions,...t]});await (0,d.lW)("transactions-batch-update",{added:t});await this.refetchTransactions()};onShowTransactions=async e=>{this.onApplyFilter({customName:"Selected transactions",filter:{id:{$oneof:e}}})};onBatchEdit=async(e,t)=>{let n=async(e,n)=>{this.setState({workingHard:true});let{data:r}=await (0,G.Vn)((0,G.ZP)("transactions").filter({id:{$oneof:t}}).select("*").options({splits:"grouped"}));let o=(0,tW.Xt)(r);let a={deleted:[],updated:[]};if(e==="cleared"){n=!!o.find(e=>!e.cleared)}const i=new Set(t);o.forEach(t=>{if(!i.has(t.id)){return}let{diff:r}=(0,tW.Ld)(o,{...t,[e]:n});o=(0,eB.zb)(r,o);a.deleted=a.deleted?a.deleted.concat(r.deleted):r.deleted;a.updated=a.updated?a.updated.concat(r.updated):r.updated;a.added=a.added?a.added.concat(r.added):r.added});await (0,d.lW)("transactions-batch-update",a);await this.refetchTransactions();if(this.table.current){this.table.current.edit(o[0].id,"select",false)}};if(e==="cleared"){n("cleared",null)}else{this.props.pushModal("edit-field",{name:e,onSubmit:n})}};onBatchDuplicate=async e=>{this.setState({workingHard:true});let{data:t}=await (0,G.Vn)((0,G.ZP)("transactions").filter({id:{$oneof:e}}).select("*").options({splits:"grouped"}));let n={added:t.reduce((e,t)=>{return e.concat((0,tW.V6)((0,tW.F6)(t)))},[]).map(({sort_order:e,...t})=>({...t}))};await (0,d.lW)("transactions-batch-update",n);await this.refetchTransactions()};onBatchDelete=async e=>{this.setState({workingHard:true});let{data:t}=await (0,G.Vn)((0,G.ZP)("transactions").filter({id:{$oneof:e}}).select("*").options({splits:"grouped"}));let n=(0,tW.Xt)(t);let r=new Set(e);let o={deleted:[],updated:[]};n.forEach(e=>{let t=e.parent_id;if(!r.has(e.id)||t&&r.has(t)){return}let{diff:a}=(0,tW.Ks)(n,e.id);n=(0,eB.zb)(a,n);o.deleted=a.deleted?o.deleted.concat(a.deleted):a.deleted;o.updated=a.updated?o.updated.concat(a.updated):a.updated});await (0,d.lW)("transactions-batch-update",o);await this.refetchTransactions()};onBatchUnlink=async e=>{await (0,d.lW)("transactions-batch-update",{updated:e.map(e=>({id:e,schedule:null}))});await this.refetchTransactions()};onCreateRule=async e=>{let{data:t}=await (0,G.Vn)((0,G.ZP)("transactions").filter({id:{$oneof:e}}).select("*").options({splits:"grouped"}));let n=(0,tW.Xt)(t);let r=n[0].imported_payee?{field:"imported_payee",op:"is",value:n[0].imported_payee,type:"string"}:{field:"payee",op:"is",value:n[0].payee,type:"id"};let o={stage:null,conditionsOp:"and",conditions:[r],actions:[{op:"set",field:"category",value:n[0].category,type:"id"}]};this.props.pushModal("edit-rule",{rule:o})};onCondOpChange=(e,t)=>{this.setState({conditionsOp:e});this.setState({filterId:{...this.state.filterId,status:"changed"}});this.applyFilters([...t]);if(this.state.search!==""){this.onSearch(this.state.search)}};onReloadSavedFilter=(e,t)=>{if(t==="reload"){let[e]=this.props.filtersList.filter(e=>e.id===this.state.filterId.id);this.setState({conditionsOp:e.conditionsOp});this.applyFilters([...e.conditions])}else{if(e.status){this.setState({conditionsOp:e.conditionsOp});this.applyFilters([...e.conditions])}}this.setState({filterId:{...this.state.filterId,...e}})};onClearFilters=()=>{this.setState({conditionsOp:"and"});this.setState({filterId:[]});this.applyFilters([]);if(this.state.search!==""){this.onSearch(this.state.search)}};onUpdateFilter=(e,t)=>{this.applyFilters(this.state.filters.map(n=>n===e?t:n));this.setState({filterId:{...this.state.filterId,status:this.state.filterId&&"changed"}});if(this.state.search!==""){this.onSearch(this.state.search)}};onDeleteFilter=e=>{this.applyFilters(this.state.filters.filter(t=>t!==e));if(this.state.filters.length===1){this.setState({filterId:[]});this.setState({conditionsOp:"and"})}else{this.setState({filterId:{...this.state.filterId,status:this.state.filterId&&"changed"}})}if(this.state.search!==""){this.onSearch(this.state.search)}};onApplyFilter=async e=>{let t=this.state.filters;if(e.customName){t=t.filter(t=>t.customName!==e.customName)}if(e.conditions){this.setState({filterId:{...e,status:"saved"}});this.setState({conditionsOp:e.conditionsOp});this.applyFilters([...e.conditions])}else{this.setState({filterId:{...this.state.filterId,status:this.state.filterId&&"changed"}});this.applyFilters([...t,e])}if(this.state.search!==""){this.onSearch(this.state.search)}};onScheduleAction=async(e,t)=>{switch(e){case"post-transaction":for(let e of t){let t=e.split("/");await (0,d.lW)("schedule/post-transaction",{id:t[1]})}this.refetchTransactions();break;case"skip":for(let e of t){let t=e.split("/");await (0,d.lW)("schedule/skip-next-date",{id:t[1]})}break;default:}};applyFilters=async e=>{if(e.length>0){let t=e.filter(e=>!!e.customName).map(e=>e.filter);let{filters:n}=await (0,d.lW)("make-filters-from-conditions",{conditions:e.filter(e=>!e.customName)});const r=this.state.conditionsOp==="or"?"$or":"$and";this.currentQuery=this.rootQuery.filter({[r]:[...n,...t]});this.setState({filters:e},()=>{this.updateQuery(this.currentQuery,true)})}else{this.setState({transactions:[],transactionCount:0,filters:e},()=>{this.fetchTransactions()})}if(this.state.sort.length!==0){this.applySort()}};applySort=(e,t,n,r)=>{let o=this.state.filters;let a=n0(!e?this.state.sort.field:e);let i=!t?this.state.sort.ascDesc:t;let s=n0(!n?this.state.sort.prevField:n);let l=!n?this.state.sort.prevAscDesc:r;if(!e){this.currentQuery=this.currentQuery.orderBy({[a]:i})}else{if(o.length>0){this.applyFilters([...o]);this.currentQuery=this.currentQuery.orderBy({[a]:i})}else{this.currentQuery=this.rootQuery.orderBy({[a]:i})}}if(s){this.currentQuery=this.currentQuery.orderBy({[s]:l})}this.updateQuery(this.currentQuery,this.state.filters.length>0)};onSort=(e,t)=>{let n;let r;if(e===this.state.sort.field){n=this.state.sort.prevField;r=this.state.sort.prevAscDesc;this.setState({sort:{...this.state.sort,ascDesc:t}})}else{n=this.state.sort.field;r=this.state.sort.ascDesc;this.setState({sort:{field:e,ascDesc:t,prevField:this.state.sort.field,prevAscDesc:this.state.sort.ascDesc}})}this.applySort(e,t,n,r);if(this.state.search!==""){this.onSearch(this.state.search)}};render(){let{accounts:e,categoryGroups:t,payees:n,dateFormat:r,hideFraction:o,addNotification:i,accountsSyncing:s,pushModal:c,replaceModal:d,showExtraBalances:u,accountId:h,categoryId:p}=this.props;let{transactions:g,loading:f,workingHard:x,filterId:v,reconcileAmount:w,transactionsFiltered:b,editingName:S,showBalances:j,balances:C,showCleared:Z}=this.state;let k=e.find(e=>e.id===h);const T=this.getAccountTitle(k,h);if(!T&&!f){return(0,a.jsx)(l.Fg,{to:"/accounts",replace:true})}let A=t.flatMap(e=>e.categories).find(e=>e.id===p);let B=!f&&!h&&e.length===0;let M=h&&h!=="budgeted"&&h!=="offbudget"&&h!=="uncategorized";let I=this.getBalanceQuery(k,h);return(0,a.jsx)(nJ,{account:k,transactions:g,balances:C,showBalances:j,filtered:b,children:(l,p)=>(0,a.jsx)(tN.mL,{name:"transactions",items:l,fetchAllIds:this.fetchAllIds,registerDispatch:e=>this.dispatchSelected=e,children:(0,a.jsxs)(y.Z,{style:m.W2.page,children:[(0,a.jsx)(nV,{tableRef:this.table,editingName:S,isNameEditable:M,workingHard:x,account:k,filterId:v,filtersList:this.props.filtersList,location:this.props.location,accountName:T,accountsSyncing:s,accounts:e,transactions:g,showBalances:j,showExtraBalances:u,showCleared:Z,showEmptyMessage:B,balanceQuery:I,canCalculateBalance:this.canCalculateBalance,isSorted:this.state.sort.length!==0,reconcileAmount:w,search:this.state.search,filters:this.state.filters,conditionsOp:this.state.conditionsOp,savePrefs:this.props.savePrefs,pushModal:this.props.pushModal,onSearch:this.onSearch,onShowTransactions:this.onShowTransactions,onMenuSelect:this.onMenuSelect,onAddTransaction:this.onAddTransaction,onToggleExtraBalances:this.onToggleExtraBalances,onSaveName:this.onSaveName,onExposeName:this.onExposeName,onReconcile:this.onReconcile,onDoneReconciling:this.onDoneReconciling,onCreateReconciliationTransaction:this.onCreateReconciliationTransaction,onSync:this.onSync,onImport:this.onImport,onBatchDelete:this.onBatchDelete,onBatchDuplicate:this.onBatchDuplicate,onBatchEdit:this.onBatchEdit,onBatchUnlink:this.onBatchUnlink,onCreateRule:this.onCreateRule,onUpdateFilter:this.onUpdateFilter,onClearFilters:this.onClearFilters,onReloadSavedFilter:this.onReloadSavedFilter,onCondOpChange:this.onCondOpChange,onDeleteFilter:this.onDeleteFilter,onApplyFilter:this.onApplyFilter,onScheduleAction:this.onScheduleAction}),(0,a.jsx)(y.Z,{style:{flex:1},children:(0,a.jsx)(nb,{tableRef:this.table,account:k,transactions:g,allTransactions:l,animated:this.animated,loadMoreTransactions:()=>this.paged&&this.paged.fetchNext(),accounts:e,category:A,categoryGroups:t,payees:n,balances:p,showBalances:!!p,showCleared:Z,showAccount:!h||h==="offbudget"||h==="budgeted"||h==="uncategorized",isAdding:this.state.isAdding,isNew:this.isNew,isMatched:this.isMatched,isFiltered:this.state.search!==""||this.state.filters.length>0,dateFormat:r,hideFraction:o,addNotification:i,renderEmpty:()=>B?(0,a.jsx)(nY,{onAdd:()=>d("add-account")}):!f?(0,a.jsx)(y.Z,{style:{color:m.rS.tableText,marginTop:20,textAlign:"center",fontStyle:"italic"},children:"No transactions"}):null,pushModal:c,onSort:this.onSort,sortField:this.state.sort.field,ascDesc:this.state.sort.ascDesc,onChange:this.onTransactionsChange,onRefetch:this.refetchTransactions,onRefetchUpToRow:e=>this.paged.refetchUpToRow(e,{field:"date",order:"desc"}),onCloseAddTransaction:()=>this.setState({isAdding:false}),onCreatePayee:this.onCreatePayee})})]})})})}}function n2(e){let{dispatch:t}=nn();let n=(0,l.bS)(e.location.pathname);return(0,a.jsx)(n1,{...e,match:n,splitsExpandedDispatch:t})}function n5(){let e=(0,l.UO)();let t=(0,l.TH)();let{grouped:n}=(0,g.Z)();let r=(0,s.v9)(t=>({newTransactions:t.queries.newTransactions,matchedTransactions:t.queries.matchedTransactions,accounts:t.queries.accounts,failedAccounts:t.account.failedAccounts,dateFormat:t.prefs.local.dateFormat||"MM/dd/yyyy",hideFraction:t.prefs.local.hideFraction||false,expandSplits:t.prefs.local["expand-splits"],showBalances:e.id&&t.prefs.local["show-balances-"+e.id],showCleared:e.id&&!t.prefs.local["hide-cleared-"+e.id],showExtraBalances:t.prefs.local["show-extra-balances-"+e.id||0],payees:t.queries.payees,modalShowing:t.modals.modalStack.length>0,accountsSyncing:t.account.accountsSyncing,lastUndoState:t.app.lastUndoState}));let o=(0,s.I0)();let c=(0,tD.m)();let d=(0,i.useMemo)(()=>(0,tR.DE)(tE,o),[o]);let u=(0,i.useMemo)(()=>{let n=eT.PK(e.id,"_account");let r=eT.PK(e.id,"_payee.transfer_acct");if(t.state&&t.state.filter||e.id==="uncategorized"){n={id:null};r={id:null}}return e=>{e=e.filter({$and:[{"_account.closed":false}],$or:[n,r]});return e.orderBy({next_date:"desc"})}},[e.id]);return(0,a.jsx)(tj.up,{transform:u,children:(0,a.jsx)(nr,{initialMode:r.expandSplits?"collapse":"expand",children:(0,a.jsx)(n2,{...r,categoryGroups:n,...d,modalShowing:r.modalShowing,accountId:e.id,categoryId:t?.state?.filter?.category,location:t,filtersList:c})})})};},25258:function(e,t,n){n.d(t,{Rp:function(){return l},Wr:function(){return a},eq:function(){return i},i8:function(){return r},iE:function(){return d},mD:function(){return c},uu:function(){return s},yr:function(){return o}});function r(e,t){return e.map(e=>{if(e.id===t.cat_group){e.categories=[t,...e.categories]}return{...e}})}function o(e,t){return e.map(e=>{if(e.id===t.cat_group){e.categories=e.categories.map(e=>{if(e.id===t.id){return{...e,...t}}return e})}return e})}function a(e,t,n,r){if(t===r){return e}let o=e.reduce((e,n)=>{return e||n.categories.find(e=>e.id===t)},null);o={...o,cat_group:n};return e.map(e=>{if(e.id===n){e.categories=e.categories.reduce((e,n)=>{if(n.id===r){e.push(o);e.push(n)}else if(n.id!==t){e.push(n)}return e},[]);if(!r){e.categories.push(o)}}else{e.categories=e.categories.filter(e=>e.id!==t)}return{...e}})}function i(e,t,n){if(t===n){return e}let r=e.find(e=>e.id===t);e=e.reduce((e,o)=>{if(o.id===n){e.push(r);e.push(o)}else if(o.id!==t){e.push(o)}return e},[]);if(!n){e.push(r)}return e}function s(e,t){return e.map(e=>{e.categories=e.categories.filter(e=>e.id!==t);return e})}function l(e,t){return[...e,t]}function c(e,t){return e.map(e=>{if(e.id===t.id){return{...e,...t}}return e})}function d(e,t){return e.filter(e=>e.id!==t)}}}]);
|
|
2
|
+
//# sourceMappingURL=wide-components.481c39ec.chunk.js.map
|